Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<body class="vbox fullsize">
<script src="lib/jquery-1.6.4.min.js"></script>
<script src="lib/jquery-ui-1.8.16.custom.min.js"></script>
<script src="src/js/msg-box.js"></script>
<script src="src/js/widgets.js"></script>
<script src="src/js/adm.js"></script>
<script src="src/js/pageTemplate.js"></script>
Expand Down
14 changes: 8 additions & 6 deletions src/css/builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}

Expand Down
60 changes: 33 additions & 27 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,44 +590,50 @@ $(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)/;
if (!supportedBrowser.test(navigator.userAgent) ||
!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:<br/><br/>' + navigator.userAgent + '<br/><br/>' +
'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:<br/><br/>' +
redirect + '<br/><br/>' +
'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();
});
67 changes: 67 additions & 0 deletions src/js/msg-box.js
Original file line number Diff line number Diff line change
@@ -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 = $("<div/>").append('<p class="title">'
+ msg + '</p>'),
buttonSet;
var i = 0;
if (buttons) {
buttonSet = $('<div id="buttonSet"/>').appendTo(dlg);
$.each(buttons, function (caption, callback) {
buttonSet.append($('<button class="buttonStyle"/>')
.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)
}

2 changes: 1 addition & 1 deletion src/js/views/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
$('<a href="javascript:void(0)">' + label +'</a>').appendTo(deviceToolbar).click(function () {
deviceButton.trigger('click');
Expand Down
5 changes: 2 additions & 3 deletions src/js/views/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div/>').attr('id',pid)
Expand Down
55 changes: 29 additions & 26 deletions src/js/views/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down