diff --git a/FILES b/FILES index 015231fd..c3fb94e7 100644 --- a/FILES +++ b/FILES @@ -18,11 +18,13 @@ Intel src/js/pageTemplate.js APLv2 N/A Intel src/js/panel.js APLv2 N/A jQuery src/js/jquery-workarounds.js MIT, GPLv2 [6] & Intel & APLv2 +Intel src/js/jquery-plugins.js APLv2 N/A Intel src/js/main.js APLv2 N/A 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..16382dc8 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + @@ -34,6 +35,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/jquery-plugins.js b/src/js/jquery-plugins.js new file mode 100644 index 00000000..5770cc5e --- /dev/null +++ b/src/js/jquery-plugins.js @@ -0,0 +1,37 @@ +/* + * Rapid Interface Builder (RIB) - A simple WYSIWYG HTML5 app creator + * Copyright (c) 2011, 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"; + +/** + * Serialize form data to JSON object. + * + * Usage: + * $('form').serializeJSON(); + * >> {'a': 'a', 'b': 'b'} + * + */ + +$.fn.serializeJSON = function() +{ + var out = {}; + var arr = this.serializeArray(); + $.each(arr, function() { + if (out[this.name] !== undefined) { + if (!out[this.name].push) { + out[this.name] = [out[this.name]]; + } + out[this.name].push(this.value || ''); + } else { + out[this.name] = this.value || ''; + } + }); + return out; +}; diff --git a/src/js/main.js b/src/js/main.js index 13a172a7..a61cd146 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -590,6 +590,33 @@ $(function() { var fsUtils, cookieUtils, supportedBrowser, supportedOS, errorMsg, redirect = 'https://01.org/rib'; + var startBuilder = function () { + cookieUtils = $.rib.cookieUtils; + // if can't get the cookie(no this record), then add exportNotice cookie + if (!cookieUtils.get("exportNotice")) { + if(!cookieUtils.set("exportNotice", "true")) { + // Failed to set the cookie + if (window.location.protocol === "file:") { + console.error("Browser needs " + + "'--allow-file-access-from-files" + + "--enable-file-cookies' option." + + + "\nClose the browser if you have already" + + " opened it before."); + } else { + console.error("Set exportNotice cookie failed."); + } + } + } + // Actually invoke the plugin that sets up our app UI + $(document).builder({debugMode: true, model: ADM}); + + // init the sandbox file system + fsUtils = $.rib.fsUtils; + // Try to init a temporary filesystem to test '--allow-file-access-from-files' option + requestFileSystem(window.TEMPORARY, 10, function(filesystem) { + fsUtils.initFS(fsUtils.fsType, fsUtils.fsSize, fsInitSuccess, fsInitFailed); + }, fsInitFailed); + } // Detect browser and platform supportedBrowser = /(Chrome|Chromium)\/(\S+)/; supportedOS = /(Win|Linux|Mac)/; @@ -597,37 +624,16 @@ $(function() { !supportedOS.test(navigator.platform)) { errorMsg = 'Only Google Chrome or Chromium are supported right now. ' + 'Unfortunately, it seems you are not using one of these, ' + - 'but instead:\n\n\t' + navigator.userAgent + '\n\n' + + 'but instead:

' + navigator.userAgent + '

' + 'To learn more about Rapid Interface Builder and how to ' + - 'use it, please visit our project website at:\n\n\t' + - redirect + '\n\n' + + 'use it, please visit our project website at:

' + + redirect + '

' + 'You will be redirected there now (or press "Cancel" to ' + 'try Rapid Interface Builder at your own risk).'; - if (confirm(errorMsg)) { + confirm(errorMsg, startBuilder, function (){ document.location = redirect; return; - } - } - cookieUtils = $.rib.cookieUtils; - // if can't get the cookie(no this record), then add exportNotice cookie - if (!cookieUtils.get("exportNotice")) { - if(!cookieUtils.set("exportNotice", "true")) { - // Failed to set the cookie - if (window.location.protocol === "file:") { - console.error("Browser needs '--allow-file-access-from-files --enable-file-cookies' option." + - "\nClose the browser if you have already opened it before."); - } else { - console.error("Set exportNotice cookie failed."); - } - } + }); } - // Actually invoke the plugin that sets up our app UI - $(document).builder({debugMode: true, model: ADM}); - - // init the sandbox file system - fsUtils = $.rib.fsUtils; - // Try to init a temporary filesystem to test '--allow-file-access-from-files' option - requestFileSystem(window.TEMPORARY, 10, function(filesystem) { - fsUtils.initFS(fsUtils.fsType, fsUtils.fsSize, fsInitSuccess, fsInitFailed); - }, fsInitFailed); + else startBuilder(); }); 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($('