issue #1 reset form resets selected icon to empty

This commit is contained in:
kplaczek
2018-04-04 19:44:11 +02:00
commit bcc445f75a
196 changed files with 49208 additions and 0 deletions

70
public/js/printer.js Normal file
View File

@@ -0,0 +1,70 @@
var content, preview, selfPrinter;
var Printer = function () {
this.init = function () {
this.reset = document.querySelector('.js-reset');
this.delete = document.querySelector('.js-delete');
content = this.content = document.querySelector('.js-content');
selfPrinter = this;
this.reset.addEventListener('click', this.clear);
content.addEventListener("mouseup", this.contentResize);
this.restoreContentHeight();
if (this.delete != null) {
this.delete.addEventListener('click', this.confirmDelete);
}
document.querySelectorAll('.icon').forEach(function (e) {
e.addEventListener('click', function () {
selfPrinter.selectIcon(this.title);
});
})
};
/**
* resetuje wybór ikony
*/
this.selectIcon = function(iconTitle){
document.querySelectorAll('.icon').forEach(function (e, i) {
e.classList.remove('selected');
});
document.querySelector('#icon').value = iconTitle;
var selector = '.icon[title="' + iconTitle + '"]';
document.querySelector(selector).classList.add('selected');
};
this.restoreContentHeight = function () {
if(!!localStorage.getItem('contentHeight')){
document.querySelector('.js-content').style.height = localStorage.getItem('contentHeight')
}
};
this.contentResize = function () {
localStorage.setItem('contentHeight', this.style.height);
};
this.divToTextbox = function () {
content.value = preview.innerHTML;
};
this.clear = function () {
selfPrinter.content.innerHTML = '';
selfPrinter.selectIcon('empty');
};
this.confirmDelete = function (e) {
if (!confirm('Usunąć wpis?')) {
e.preventDefault();
return false;
}
};
};

19
public/js/semantic.min.js vendored Normal file

File diff suppressed because one or more lines are too long