|
@@ -24,6 +24,36 @@ class applet_animations {
|
|
|
target.style.right = -target.offsetWidth + "px";
|
|
target.style.right = -target.offsetWidth + "px";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ static hide_opacity_generator(time) {
|
|
|
|
|
+ return (state, target) => {
|
|
|
|
|
+ if (state) {
|
|
|
|
|
+ target.style.display = "";
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ target.style.opacity = "1";
|
|
|
|
|
+ }, time);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ target.style.opacity = "0";
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ target.style.display = "none";
|
|
|
|
|
+ }, time);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static hide_opacity(state, target) {
|
|
|
|
|
+ if (state) {
|
|
|
|
|
+ target.style.display = "";
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => { target.style.opacity = "1"; }, 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ target.style.opacity = "0";
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => { target.style.display = "none"; }, 500);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class applet_builder {
|
|
class applet_builder {
|
|
@@ -103,6 +133,15 @@ class applet_builder {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ #build_dualbutton() {
|
|
|
|
|
+ return new dualbutton_applet(
|
|
|
|
|
+ this.#target,
|
|
|
|
|
+ this.#maximalise,
|
|
|
|
|
+ this.#minimalise,
|
|
|
|
|
+ this.#animation
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
build() {
|
|
build() {
|
|
|
if (!this.is_valid) {
|
|
if (!this.is_valid) {
|
|
|
throw "Builder is not valid yes.";
|
|
throw "Builder is not valid yes.";
|
|
@@ -111,6 +150,8 @@ class applet_builder {
|
|
|
if (this.#is_swapable) {
|
|
if (this.#is_swapable) {
|
|
|
return this.#build_swapable();
|
|
return this.#build_swapable();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ return this.#build_dualbutton();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -178,4 +219,47 @@ class swapable_applet extends applet {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+class dualbutton_applet extends applet {
|
|
|
|
|
+ #open;
|
|
|
|
|
+ #close;
|
|
|
|
|
+
|
|
|
|
|
+ constructor(target, open, close, animation) {
|
|
|
|
|
+ super();
|
|
|
|
|
+
|
|
|
|
|
+ if (!dom_manager.is_element(target)) {
|
|
|
|
|
+ throw "Target must be an HTML element.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!dom_manager.is_element(close)) {
|
|
|
|
|
+ throw "Closer must be an HTML element.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!dom_manager.is_element(open)) {
|
|
|
|
|
+ throw "Opener must be an HTML element.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!type_manager.is_function(animation)) {
|
|
|
|
|
+ throw "Animation must be an function.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.#open = open;
|
|
|
|
|
+ this.#close = close;
|
|
|
|
|
+ this._animation = animation;
|
|
|
|
|
+ this._target = target;
|
|
|
|
|
+ this._state = false;
|
|
|
|
|
+ this.hide();
|
|
|
|
|
+ this.#listen();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ #listen() {
|
|
|
|
|
+ this.#open.addEventListener("click", () => {
|
|
|
|
|
+ this.show();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.#close.addEventListener("click", () => {
|
|
|
|
|
+ this.hide();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export { applet_builder, applet_animations };
|
|
export { applet_builder, applet_animations };
|