vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
76 lines (75 loc) • 2.13 kB
JavaScript
class r {
constructor(e) {
this.container = e, this._views = [], this.length = 0, this.hidden = !1;
}
all() {
return this._views;
}
first() {
return this._views[0];
}
last() {
return this._views[this._views.length - 1];
}
indexOf(e) {
return this._views.indexOf(e);
}
slice() {
return this._views.slice.apply(this._views, arguments);
}
get(e) {
return this._views[e];
}
append(e) {
return this._views.push(e), this.container && this.container.appendChild(e.element), this.length++, e;
}
prepend(e) {
return this._views.unshift(e), this.container && this.container.insertBefore(e.element, this.container.firstChild), this.length++, e;
}
insert(e, i) {
return this._views.splice(i, 0, e), this.container && (i < this.container.children.length ? this.container.insertBefore(e.element, this.container.children[i]) : this.container.appendChild(e.element)), this.length++, e;
}
remove(e) {
var i = this._views.indexOf(e);
i > -1 && this._views.splice(i, 1), this.destroy(e), this.length--;
}
destroy(e) {
e.displayed && e.destroy(), this.container && this.container.removeChild(e.element), e = null;
}
// Iterators
forEach() {
return this._views.forEach.apply(this._views, arguments);
}
clear() {
var e, i = this.length;
if (this.length) {
for (var t = 0; t < i; t++)
e = this._views[t], this.destroy(e);
this._views = [], this.length = 0;
}
}
find(e) {
for (var i, t = this.length, s = 0; s < t; s++)
if (i = this._views[s], i.displayed && i.section.index == e.index)
return i;
}
displayed() {
for (var e = [], i, t = this.length, s = 0; s < t; s++)
i = this._views[s], i.displayed && e.push(i);
return e;
}
show() {
for (var e, i = this.length, t = 0; t < i; t++)
e = this._views[t], e.displayed && e.show();
this.hidden = !1;
}
hide() {
for (var e, i = this.length, t = 0; t < i; t++)
e = this._views[t], e.displayed && e.hide();
this.hidden = !0;
}
}
export {
r as default
};
//# sourceMappingURL=views.mjs.map