diff --git a/Inquirer.js b/Inquirer.js index 9bf6408..a833324 100644 --- a/Inquirer.js +++ b/Inquirer.js @@ -1,6 +1,6 @@ /* * Web Inquirer V 0.2 - * Copyright 2016 XWolfOVerride@gmail.com + * Copyright 2016 XWolfOverride@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software diff --git a/Merger.js b/Merger.js index 386d35c..e159581 100644 --- a/Merger.js +++ b/Merger.js @@ -1,6 +1,6 @@ /* * Merger UI V0.3 - * Copyright 2016 XWolfOVerride@gmail.com + * Copyright 2016 XWolfOverride@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software @@ -380,6 +380,7 @@ function MergerApplication(id, def) { this.merge({ _type: "app", + icon: sys.icon, getId: function () { return id; }, @@ -410,6 +411,7 @@ MergerApplication.prototype.removeWindow = function (win) { if (!this.windows[win.getId()]) return; + win.hide(); delete this.windows[win.getId()]; core.getDesktop().removeChild(win); } @@ -445,6 +447,16 @@ controller.check(); } + /** + * Generates a random id + */ + function randId(prefix) { + var id = Number(Math.round(Math.random() * 0xFFFFF)).toString(16); + while (id.length < 5) + id = '0' + id; + return prefix + "_" + id; + } + /** * Drag'N'Drop system */ @@ -842,6 +854,8 @@ if (this.left === undefined) this.setLeft((document.body.clientWidth - this.width) / 2); } + def.width = dw; + def.height = dh; w.client = w.content.client; w.titlebar = w.content.titlebar; w.content = w.client.content; @@ -875,6 +889,20 @@ } /** + * HTML control creation + */ + function html(id, def) { + var c = control("html", id, core.mkDefinition({ + setHtml: function (text) { + this.innerHTML = text; + } + }, def)); + if (def.text !== undefined) + c.setText(def.text); + return c; + } + + /** * TextBox control creation */ function textbox(id, def) { @@ -964,6 +992,83 @@ } /** + * Dialog creation tool + */ + function dialog(app, id, def, buttons) { + if (!def) + def = {}; + def.merge({ + width: def.width || 300, + height: def.height || 300, + onClose: function () { + app.removeWindow(w); + } + }); + var w, i, bt, x = def.width; + if (buttons) { + def.content = def.content || []; + for (i = 0; i < buttons.length; i++) + def.content.push(buttons[i]); + } + w = window(id || randId("dialog"), def); + app.addWindow(w); + for (i = buttons.length - 1; i >= 0; i--) { + bt = buttons[i]; + x -= bt.offsetWidth; + bt.merge({ + top: def.height - bt.offsetHeight, + left: x, + _user_onClick: bt.onClick, + onClick: function () { + app.removeWindow(w); + if (this._user_onClick) + this._user_onClick(); + } + }); + } + return w; + } + + /** + * MessageBox creation tool + */ + function dialog_messageBox(app, text, title, buttons, icon, height) { + var def = { + modal: true, + title: title, + width: icon ? 260 : 200, + height: height || 75, + content: [ + ] + }, d; + if (icon) + def.content.push( + picture("pIcon", { + top: 0, + left: 0, + width: 48, + height: 48, + src: icon, + }) + ); + def.content.push( + html("htText", { + top: 24, + left: icon ? 60 : 0, + width: 200, + html: text, + }) + ); + if (!buttons || buttons.length == 0) { + buttons = [button("btOk", { text: "Ok" })]; + } + d = dialog(app, null, def, buttons); + d.show(); + d.focus(); + return d; + } + + /** * Merger API */ // -- Kernel @@ -975,8 +1080,10 @@ // -- UI ui: { window: window, + dialog: dialog, list: list, label: label, + html: html, textbox: textbox, checkbox: checkbox, button: button, @@ -984,6 +1091,9 @@ menuItem: menuItem, menuSeparator: menuSeparator, }, + dialogs: { + messageBox: dialog_messageBox, + }, media: { createIcon: core.mkIcon, helpIcon: core.getHelpIcon.bind(core), diff --git a/MergerTester.js b/MergerTester.js index 0248028..f001839 100644 --- a/MergerTester.js +++ b/MergerTester.js @@ -1,6 +1,6 @@ /* * Merger Tester Applicaion V 0.2 - * Copyright 2016 XWolfOVerride@gmail.com + * Copyright 2016 XWolfOverride@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software @@ -51,8 +51,8 @@ src: "https://cdn1.iconfinder.com/static/e9bcefc0c5591114fcd0b4b0aff67962/assets/img/extended-library/icon.svg", top: 0, left: 0, - width: 32, - height: 32, + width: 48, + height: 48, }), merger.ui.label("Linfo", { top: 20, @@ -99,5 +99,6 @@ onLoad: function () { }, onAbout: function () { + merger.dialogs.messageBox(this, "MergerTester (C)2017 XWolf Override.
Merger desktop is a framework that mimiks a classic desktop on a webpage.", "About merger", null, this.icon, 100); }, });