From d4d2d0d2418a163f16717dc5ede350189363fef5 Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 25 Jun 2012 16:37:46 +0800 Subject: [PATCH 1/4] [General] Implement msg-box and overide alert and confirm Also refactor css definitions for 'Add device' dialog so that it can be resued by msg-box. --- FILES | 1 + index.html | 1 + src/css/builder.css | 14 +++++---- src/js/msg-box.js | 67 ++++++++++++++++++++++++++++++++++++++++++++ src/js/views/live.js | 2 +- 5 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 src/js/msg-box.js diff --git a/FILES b/FILES index 015231fd..637ed04b 100644 --- a/FILES +++ b/FILES @@ -23,6 +23,7 @@ Intel src/js/composer.js APLv2 N/A Intel src/js/codeview-mode.js APLv2 N/A Intel src/js/devices.js APLv2 N/A Intel src/js/projects.js APLv2 N/A +Intel src/js/msg-box.js APLv2 N/A Intel src/js/views/live.js APLv2 N/A Intel src/js/views/widget.js APLv2 N/A Intel src/js/views/outline.js APLv2 N/A diff --git a/index.html b/index.html index 21e8d05e..e0042ee9 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + diff --git a/src/css/builder.css b/src/css/builder.css index b87caf01..b1f57612 100644 --- a/src/css/builder.css +++ b/src/css/builder.css @@ -1329,13 +1329,15 @@ div.propertyItems label[for|=id] { size: 4; } -.deviceSetting #buttonSet{ - position: absolute; - bottom: 0px; - width: 100%; +p.title { + margin-left:1em; + margin-right: 1em; +} +#buttonSet { + text-align: center; } -.deviceSetting #buttonSet * { - margin: 0 1em 3em 1em; +#buttonSet * { + margin: 1.5em 1em 1.5em 1em; min-width: 25%; } diff --git a/src/js/msg-box.js b/src/js/msg-box.js new file mode 100644 index 00000000..2a88914b --- /dev/null +++ b/src/js/msg-box.js @@ -0,0 +1,67 @@ +/* + * Rapid Interface Builder (RIB) - A simple WYSIWYG HTML5 app creator + * Copyright (c) 2011-2012, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ +"use strict"; + +$.rib = $.rib || {}; +/** + * Show a simple message box + * + * @param {String} msg The message that needs to be shown + * @param {Object} buttons The buttons to be shown in the dialog + * and their corresponding callbacks + * For example: {'OK': callback1; "Cancel": callback2} + * @return {None}. + */ +$.rib.msgbox = function (msg, buttons){ + var dlg = $("
").append('

' + + msg + '

'), + buttonSet; + var i = 0; + if (buttons) { + buttonSet = $('
').appendTo(dlg); + $.each(buttons, function (caption, callback) { + buttonSet.append($('