mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 01:26:43 +08:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const Alert = function (){
|
|
let fn = null;
|
|
|
|
return {
|
|
now: function(Component, okCallback){
|
|
if(!fn){ return window.setTimeout(() => this.now(Component, okCallback), 50); }
|
|
fn(Component, okCallback);
|
|
},
|
|
subscribe: function(_fn){
|
|
fn = _fn;
|
|
}
|
|
};
|
|
};
|
|
export const alert = new Alert();
|
|
|
|
|
|
const Prompt = function (){
|
|
let fn = null;
|
|
|
|
return {
|
|
now: function(text, okCallback, cancelCallback, type){
|
|
if(!fn){ return window.setTimeout(() => this.now(text, okCallback, cancelCallback, type), 50); }
|
|
fn(text, okCallback, cancelCallback, type);
|
|
},
|
|
subscribe: function(_fn){
|
|
fn = _fn;
|
|
}
|
|
};
|
|
};
|
|
export const prompt = new Prompt();
|
|
|
|
|
|
const Confirm = function (){
|
|
let fn = null;
|
|
|
|
return {
|
|
now: function(comp, okCallback, cancelCallback){
|
|
if(!fn){ return window.setTimeout(() => this.now(comp, okCallback, cancelCallback), 50); }
|
|
fn(comp, okCallback, cancelCallback);
|
|
},
|
|
subscribe: function(_fn){
|
|
fn = _fn;
|
|
}
|
|
};
|
|
};
|
|
export const confirm = new Confirm();
|