Merged older paper pi with the newer, with some recent updates.

This commit is contained in:
kplaczek
2018-04-02 22:34:15 +02:00
parent 3c0ebd26ed
commit ad53e0c861
19 changed files with 1071 additions and 160 deletions

View File

@@ -8,41 +8,63 @@ var Printer = function () {
this.delete = document.querySelector('.js-delete');
content = this.content = document.querySelector('.js-content');
preview = this.preview = document.querySelector('#editor');
// preview = this.preview = document.querySelector('#editor');
selfPrinter = this;
this.reset.addEventListener('click', this.clear);
this.content.addEventListener('keypress', this.printPreview);
this.preview.addEventListener('keyup', this.divToTextbox);
// this.content.addEventListener('keypress', this.printPreview);
// this.preview.addEventListener('keyup', this.divToTextbox);
content.addEventListener("mouseup", this.contentResize);
if(this.delete != null){
this.restoreContentHeight();
if (this.delete != null) {
this.delete.addEventListener('click', this.confirmDelete);
}
this.commandCenter = document.querySelector('.icon.command.center');
this.commandLeft = document.querySelector('.icon.command.left');
this.commandRight = document.querySelector('.icon.command.right');
this.commandBold = document.querySelector('.icon.command.bold');
this.commandItalic = document.querySelector('.icon.command.italic');
this.commandUnderline = document.querySelector('.icon.command.underline');
this.commandCenter.addEventListener('click', function(){document.execCommand('justifyCenter', false);});
this.commandLeft.addEventListener('click', function(){document.execCommand('justifyLeft', false);});
this.commandRight.addEventListener('click', function(){document.execCommand('justifyRight', false);});
document.querySelectorAll('.icon').forEach(function (e) {
e.addEventListener('click', function () {
document.querySelectorAll('.icon').forEach(function (e, i) {
e.classList.remove('selected');
});
document.querySelector('#icon').value = this.title;
this.classList.add('selected');
});
})
this.commandBold.addEventListener('click', function(){document.execCommand('bold', false);});
this.commandItalic.addEventListener('click', function(){document.execCommand('italic', false);});
this.commandUnderline.addEventListener('click', function(){document.execCommand('underline', false);});
// this.commandCenter = document.querySelector('.icon.command.center');
// this.commandLeft = document.querySelector('.icon.command.left');
// this.commandRight = document.querySelector('.icon.command.right');
// this.commandBold = document.querySelector('.icon.command.bold');
// this.commandItalic = document.querySelector('.icon.command.italic');
// this.commandUnderline = document.querySelector('.icon.command.underline');
// this.commandCenter.addEventListener('click', function(){document.execCommand('justifyCenter', false);});
// this.commandLeft.addEventListener('click', function(){document.execCommand('justifyLeft', false);});
// this.commandRight.addEventListener('click', function(){document.execCommand('justifyRight', false);});
// this.commandBold.addEventListener('click', function(){document.execCommand('bold', false);});
// this.commandItalic.addEventListener('click', function(){document.execCommand('italic', false);});
// this.commandUnderline.addEventListener('click', function(){document.execCommand('underline', false);});
};
this.printPreview = function(){
preview.innerText = content.value;
// this.printPreview = function(){
// preview.innerText = content.value;
// };
this.restoreContentHeight = function () {
if(!!localStorage.getItem('contentHeight')){
document.querySelector('.js-content').style.height = localStorage.getItem('contentHeight')
}
};
this.divToTextbox = function(){
this.contentResize = function () {
localStorage.setItem('contentHeight', this.style.height);
};
this.divToTextbox = function () {
content.value = preview.innerHTML;
};
@@ -51,7 +73,7 @@ var Printer = function () {
};
this.confirmDelete = function (e) {
if(!confirm('Usunąć wpis?')){
if (!confirm('Usunąć wpis?')) {
e.preventDefault();
return false;
}