Skip to content

Commit

Permalink
RUC-UP compilado
Browse files Browse the repository at this point in the history
  • Loading branch information
reginaldo.marinho committed May 18, 2024
1 parent b585b65 commit 11893b2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 28 deletions.
12 changes: 8 additions & 4 deletions dist/Rucula.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ export declare class Rucula {
text: string;
timeout?: number | undefined;
disableadFooter?: boolean | undefined;
}) => void;
disableadHeader?: boolean | undefined;
}, callback?: import("./popup/callback").callbackYesNo | undefined) => void;
sucess: (config: {
text: string;
timeout?: number | undefined;
disableadFooter?: boolean | undefined;
}) => void;
disableadHeader?: boolean | undefined;
}, callback?: import("./popup/callback").callbackYesNo | undefined) => void;
warning: (config: {
text: string;
timeout?: number | undefined;
disableadFooter?: boolean | undefined;
}) => void;
disableadHeader?: boolean | undefined;
}, callback?: import("./popup/callback").callbackYesNo | undefined) => void;
error: (config: {
text: string;
timeout?: number | undefined;
disableadFooter?: boolean | undefined;
}) => void;
disableadHeader?: boolean | undefined;
}, callback?: import("./popup/callback").callbackYesNo | undefined) => void;
};
};
object: {
Expand Down
4 changes: 4 additions & 0 deletions dist/const.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ export declare const constFrameLineActions: {
ADD: string;
REMOVE: string;
};
export declare const constYesNo: {
NO: boolean;
YES: boolean;
};
3 changes: 3 additions & 0 deletions dist/popup/callback.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface callbackYesNo {
(): void;
}
10 changes: 6 additions & 4 deletions dist/popup/popup.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { callbackYesNo } from "./callback";
type configCommon = {
text: string;
timeout?: number;
disableadFooter?: boolean;
disableadHeader?: boolean;
};
export declare let popup: {
messsage: {
info: (config: configCommon) => void;
sucess: (config: configCommon) => void;
warning: (config: configCommon) => void;
error: (config: configCommon) => void;
info: (config: configCommon, callback?: callbackYesNo) => void;
sucess: (config: configCommon, callback?: callbackYesNo) => void;
warning: (config: configCommon, callback?: callbackYesNo) => void;
error: (config: configCommon, callback?: callbackYesNo) => void;
};
};
export {};
55 changes: 36 additions & 19 deletions dist/rucula.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const constFrameLineActions = {
ADD: 'f-l-action-add',
REMOVE: 'f-l-action-remove'
};
const constYesNo = {
NO: false,
YES: true
};

function convertValueType(value, type) {
type = GetType(type);
Expand Down Expand Up @@ -2209,8 +2213,8 @@ let popup = (() => {
}
function messageElement(config) {
let message = document.createElement('div');
message.classList.add('r-message');
message.innerHTML = `
<div class="r-message">
<div class="r-message-header">
<div class="r-message-header-icon">
<i class="bi ${config.icon}"></i>
Expand All @@ -2227,39 +2231,50 @@ let popup = (() => {
</div>
<div class="r-message-footer">
${config.footer}
</div>
</div>
`;
</div>`;
if (config?.disableadHeader) {
let header = message.querySelector('.r-message-header');
header?.remove();
}
if (config?.disableadFooter) {
let footer = message.querySelector('.r-message-footer');
footer?.classList.add("r-display-none");
footer?.remove();
}
return message;
}
function closeTimeout(div, timeout) {
function closeTimeout(div, timeout, callback) {
setTimeout(() => {
div.remove();
close();
if (callback) {
callback();
}
}, timeout);
}
function closeOKOrCancel(div) {
function closeOKOrCancel(callback, div) {
let ok = div.querySelector('button.ok');
let cancel = div.querySelector('button.cancel');
ok?.addEventListener('click', () => {
div.remove();
close();
if (callback) {
callback(constYesNo.YES);
}
});
cancel?.addEventListener('click', () => {
div.remove();
close();
if (callback) {
callback(constYesNo.NO);
}
});
}
function close() {
boxShow.classList.remove('r-box-show-center');
}
return {
messsage: {
info: function (config) {
info: function (config, callback) {
let info = messageElement({
icon: "bi-info-circle color-darkgrey",
title: "Informação",
Expand All @@ -2269,15 +2284,16 @@ let popup = (() => {
<button class="ok">OK</button>
</div>
</div>`,
disableadFooter: config.disableadFooter
disableadFooter: config.disableadFooter,
disableadHeader: config.disableadHeader
});
closeOKOrCancel(info);
if (config.timeout) {
closeTimeout(info, config.timeout);
if (config?.timeout) {
closeTimeout(info, config.timeout, callback);
}
closeOKOrCancel(callback, info);
boxShowAppendChield(info);
},
sucess: function (config) {
sucess: function (config, callback) {
let sucess = messageElement({
icon: "bi-check2-circle color-green",
title: "Sucesso",
Expand All @@ -2289,31 +2305,32 @@ let popup = (() => {
</div>`,
disableadFooter: config.disableadFooter
});
closeOKOrCancel(sucess);
closeOKOrCancel(callback, sucess);
if (config.timeout) {
closeTimeout(sucess, config.timeout);
}
boxShowAppendChield(sucess);
},
warning: function (config) {
warning: function (config, callback) {
let warning = messageElement({
icon: "bi-exclamation-triangle color-orange",
title: "Atenção",
text: config.text,
footer: `<div class="r-message-footer">
<div class="cancel-ok">
<button class="ok">OK</button>
<button class="ok">OK</button>
<button class="cancel">Cancel</button>
</div>
</div>`,
disableadFooter: config.disableadFooter
});
closeOKOrCancel(warning);
closeOKOrCancel(callback, warning);
if (config.timeout) {
closeTimeout(warning, config.timeout);
}
boxShowAppendChield(warning);
},
error: function (config) {
error: function (config, callback) {
let warning = messageElement({
icon: "bi-x-circle color-red",
title: "Erro",
Expand All @@ -2325,7 +2342,7 @@ let popup = (() => {
</div>`,
disableadFooter: config.disableadFooter
});
closeOKOrCancel(warning);
closeOKOrCancel(callback, warning);
if (config.timeout) {
closeTimeout(warning, config.timeout);
}
Expand Down
5 changes: 4 additions & 1 deletion dist/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
width: 100%;
height: 100%;
z-index: 10;
padding: 0 20px;
}

.r-item-center {
Expand Down Expand Up @@ -535,7 +536,9 @@ form.r-f-items{
}

.r-message-footer button.cancel {
background-color: red;
background-color: #dd0000;
margin-left: 10px;
color: #fff;
}
.r-message-footer button.ok {
margin-left: 10px;
Expand Down

0 comments on commit 11893b2

Please sign in to comment.