fixup: import report onclick
This commit is contained in:
parent
257fda4d1d
commit
b61dc4184b
|
@ -1,3 +1,4 @@
|
||||||
|
/* global messageBox */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const STYLISH_DUMP_FILE_EXT = '.txt';
|
const STYLISH_DUMP_FILE_EXT = '.txt';
|
||||||
|
@ -24,7 +25,7 @@ function importFromFile({fileTypeFilter, file} = {}) {
|
||||||
function readFile() {
|
function readFile() {
|
||||||
if (file || fileInput.value !== fileInput.initialValue) {
|
if (file || fileInput.value !== fileInput.initialValue) {
|
||||||
file = file || fileInput.files[0];
|
file = file || fileInput.files[0];
|
||||||
if (file.size > 100*1000*1000) {
|
if (file.size > 100e6) {
|
||||||
console.warn("100MB backup? I don't believe you.");
|
console.warn("100MB backup? I don't believe you.");
|
||||||
importFromString('').then(resolve);
|
importFromString('').then(resolve);
|
||||||
return;
|
return;
|
||||||
|
@ -94,19 +95,20 @@ function importFromString(jsonString) {
|
||||||
if (!oldStyle) {
|
if (!oldStyle) {
|
||||||
stats.added.names.push(style.name);
|
stats.added.names.push(style.name);
|
||||||
stats.added.ids.push(style.id);
|
stats.added.ids.push(style.id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!metaEqual && !codeEqual) {
|
if (!metaEqual && !codeEqual) {
|
||||||
stats.metaAndCode.names.push(reportNameChange(oldStyle, style));
|
stats.metaAndCode.names.push(reportNameChange(oldStyle, style));
|
||||||
stats.metaAndCode.ids.push(style.id);
|
stats.metaAndCode.ids.push(style.id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!codeEqual) {
|
if (!codeEqual) {
|
||||||
stats.codeOnly.names.push(style.name);
|
stats.codeOnly.names.push(style.name);
|
||||||
stats.codeOnly.ids.push(style.id);
|
stats.codeOnly.ids.push(style.id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
stats.metaOnly.names.push(reportNameChange(oldStyle, style));
|
stats.metaOnly.names.push(reportNameChange(oldStyle, style));
|
||||||
stats.metaOnly.ids.push(style.id);
|
stats.metaOnly.ids.push(style.id);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -181,16 +183,17 @@ function importFromString(jsonString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindClick(box) {
|
function bindClick(box) {
|
||||||
for (let block of $$('details')) {
|
const highlightElement = event => {
|
||||||
if (block.dataset.id != 'invalid') {
|
const styleElement = $('#style-' + event.target.dataset.id);
|
||||||
block.style.cursor = 'pointer';
|
|
||||||
block.onclick = event => {
|
|
||||||
const styleElement = $(`[style-id="${event.target.dataset.id}"]`);
|
|
||||||
if (styleElement) {
|
if (styleElement) {
|
||||||
scrollElementIntoView(styleElement);
|
scrollElementIntoView(styleElement);
|
||||||
animateElement(styleElement, {className: 'highlight'});
|
animateElement(styleElement, {className: 'highlight'});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
for (const block of $$('details')) {
|
||||||
|
if (block.dataset.id != 'invalid') {
|
||||||
|
block.style.cursor = 'pointer';
|
||||||
|
block.onclick = highlightElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +205,7 @@ function importFromString(jsonString) {
|
||||||
style.sections = style.sections.slice();
|
style.sections = style.sections.slice();
|
||||||
for (let i = 0, section; (section = style.sections[i]); i++) {
|
for (let i = 0, section; (section = style.sections[i]); i++) {
|
||||||
const copy = style.sections[i] = Object.assign({}, section);
|
const copy = style.sections[i] = Object.assign({}, section);
|
||||||
for (let propName in copy) {
|
for (const propName in copy) {
|
||||||
const prop = copy[propName];
|
const prop = copy[propName];
|
||||||
if (prop instanceof Array) {
|
if (prop instanceof Array) {
|
||||||
copy[propName] = prop.slice();
|
copy[propName] = prop.slice();
|
||||||
|
@ -236,7 +239,7 @@ $('#file-all-styles').onclick = () => {
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(res => res.blob())
|
.then(res => res.blob())
|
||||||
.then(blob => {
|
.then(blob => {
|
||||||
let a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.setAttribute('download', fileName);
|
a.setAttribute('download', fileName);
|
||||||
a.setAttribute('href', URL.createObjectURL(blob));
|
a.setAttribute('href', URL.createObjectURL(blob));
|
||||||
a.dispatchEvent(new MouseEvent('click'));
|
a.dispatchEvent(new MouseEvent('click'));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user