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/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:' + + msg + '
'), + buttonSet; + var i = 0; + if (buttons) { + buttonSet = $('').appendTo(dlg); + $.each(buttons, function (caption, callback) { + buttonSet.append($('') + .text(caption) + .bind('click', function () { + if (typeof callback === "function") + callback(); + dlg.dialog('close') + })); + }); + } + dlg.dialog({modal:true}); +}; + +window.alert = function (msg) { + $.rib.msgbox(msg, {"OK": null}); +} + +var old_confirm = window.confirm; +/** + * Override confirm for prettier UI. + * Note that if only one parameter is supplied, original confirm will be called. + * Callbacks are used here because there is no way to block the execution of + * script and wait for the user to choose "yes" or "no" in the customized dialog + * + * @param {String} msg The message that needs to be shown + * @param {function()=} ok_handler Callback when "OK" button is clicked + * @param {function()=} cancel_handler Callback when "Cancel" button is clicked + * @return {Boolean/None} The same as original confirm if only one parameter is + * is supplied. None if more than one parameter is + * supplied. + */ +window.confirm = function (msg, ok_handler, cancel_handler ) { + if (ok_handler) { + $.rib.msgbox(msg, {'Cancel': cancel_handler, 'OK': ok_handler}); + } + else + return old_confirm(msg) +} + diff --git a/src/js/views/live.js b/src/js/views/live.js index aed0b32c..0fe82151 100644 --- a/src/js/views/live.js +++ b/src/js/views/live.js @@ -99,7 +99,7 @@ } return false; }) - deviceForm.dialog({title: label, modal:true, width: 360, height: 260, resizable:false }); + deviceForm.dialog({title: label, modal:true, width: 360, resizable:false }); }); $('' + label +'').appendTo(deviceToolbar).click(function () { deviceButton.trigger('click'); diff --git a/src/js/views/project.js b/src/js/views/project.js index 27867f5b..c54ecaef 100644 --- a/src/js/views/project.js +++ b/src/js/views/project.js @@ -289,10 +289,9 @@ }); } }; - var continueToDelete = confirm("Are you sure you want to delete it?"); - if(continueToDelete) { + confirm("Are you sure you want to delete it?", function() { $.rib.pmUtils.deleteProject(pid, success); - } + }); }; // draw project box box = $('').attr('id',pid) diff --git a/src/js/views/property.js b/src/js/views/property.js index 124ab42e..64acb7e7 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -371,36 +371,39 @@ content.find('#deleteElement') .bind('click', function (e) { var parent, zone, index; - try { - index = node.getZoneIndex(); - parent = node.getParent(); - zone = parent.getZoneArray(node.getZone()); - if (type === "Page") { - continueToDelete = confirm("Are you sure you want to delete the page?"); - if(!continueToDelete) { - return false; + var doDelete = function () { + try { + index = node.getZoneIndex(); + parent = node.getParent(); + zone = parent.getZoneArray(node.getZone()); + if (type === "Page") { + $.rib.pageUtils.deletePage(node.getUid(), false); + } else { + ADM.removeChild(node.getUid(), false); } - $.rib.pageUtils.deletePage(node.getUid(), false); - } else { - ADM.removeChild(node.getUid(), false); - } - // Select sibling of removed node, or parent node - // if removed node is the last node of parent. The - // order is next sibling, prev sibling and parent - if (zone.length === 0) { - //find the first selectable ancestor - while (!parent.isSelectable()) { - parent = parent.getParent(); + // Select sibling of removed node, or parent node + // if removed node is the last node of parent. The + // order is next sibling, prev sibling and parent + if (zone.length === 0) { + //find the first selectable ancestor + while (!parent.isSelectable()) { + parent = parent.getParent(); + } + ADM.setSelected(parent); + } else if (index < zone.length) { + ADM.setSelected(zone[index]) + } else { + ADM.setSelected(zone[zone.length - 1]); } - ADM.setSelected(parent); - } else if (index < zone.length) { - ADM.setSelected(zone[index]) - } else { - ADM.setSelected(zone[zone.length - 1]); + } + catch (err) { + console.error(err.message); } } - catch (err) { - console.error(err.message); + if (type === "Page") { + confirm("Are you sure you want to delete the page?", doDelete); + } else { + doDelete(); } e.stopPropagation(); return false;