diff --git a/src/js/fs.js b/src/js/fs.js
index 4350ba4e..e3af3659 100644
--- a/src/js/fs.js
+++ b/src/js/fs.js
@@ -527,7 +527,9 @@ $(function() {
// remove the temp input element
input.remove();
});
- input.click();
+ setTimeout(function() {
+ input.click();
+ }, 0);
},
/**
diff --git a/src/js/jquery-workarounds.js b/src/js/jquery-workarounds.js
index 16d08e90..b8b7b9b1 100644
--- a/src/js/jquery-workarounds.js
+++ b/src/js/jquery-workarounds.js
@@ -342,3 +342,103 @@ $.widget("ui.droppable", $.extend({}, $.ui.droppable.prototype, {
}
}));
+
+/*
+ * This is an enhencement for jquery.extend, which tries to extend
+ * an array field just like an object while deep extending and in some
+ * case produces unexpected reuslt. For example, [0, 1, 2] extends by
+ * [3] results in [3, 1, 2] instead of [3].
+ * See http://bugs.jquery.com/ticket/9477 for more details about this
+ * issue.
+ *
+ * We override jquery.extend function so that a flag can be specified
+ * to indicate whether arrays should be replaced or not.
+ *
+ * Copied from jquery version 1.6.4, jquery-1.6.4.js
+ */
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ replaceArray = false;
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ // Start of our changes
+ // Introduce a new argument to specifiy if we need to replace
+ // an array when encountered.
+ if ( typeof target === "boolean" ) {
+ replaceArray = target;
+ target = arguments[2] || {};
+ // skip the boolean and the target
+ i = 3;
+ }
+ /////////////////////////////////////////////////////////////////
+ // End of our changes
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ /////////////////////////////////////////////////////////////////
+ // Start of our changes
+ // If replaceArray is true, we uses an empty array as clone so
+ // the whole array will be replaced by copy
+ // Following is the original line:
+ // clone = src && jQuery.isArray(src) ? src : [];
+ clone = src && jQuery.isArray(src) && !replaceArray ? src : [];
+ /////////////////////////////////////////////////////////////////
+ // End of our changes
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
diff --git a/src/js/views/property.js b/src/js/views/property.js
index 6be0924a..d3c62872 100644
--- a/src/js/views/property.js
+++ b/src/js/views/property.js
@@ -160,6 +160,26 @@
value.find("#" + valueId).attr("checked", "checked");
}
break;
+ case "url-uploadable":
+ $('')
+ .attr('id', valueId)
+ .addClass('title labelInput')
+ .appendTo(value);
+ //set default value
+ value.find('#' + valueId).val(valueVal);
+ $('')
+ .addClass('buttonStyle')
+ .click(function (e) {
+ var target, saveDir;
+ target = $(this).prev("input:text");
+ saveDir = $.rib.pmUtils.ProjectDir + "/" + $.rib.pmUtils.getActive() + "/images/";
+ $.rib.fsUtils.uploadAndSave("image", saveDir, $(this).parent(), function (file) {
+ target.val(file.toURL());
+ target.trigger('change');
+ });
+ })
+ .appendTo(value);
+ break;
case "record-array":
$('
')
.attr('id', 'selectOption')
diff --git a/src/js/widgets.js b/src/js/widgets.js
index 97a4b161..2db053f1 100644
--- a/src/js/widgets.js
+++ b/src/js/widgets.js
@@ -113,7 +113,6 @@ var BWidgetRegistry = {
*/
Base: {
parent: null,
- allowIn: [],
applyProperties: function (node, code) {
var id = node.getProperty("id");
if (id && node.isPropertyExplicit("id")) {
@@ -121,9 +120,8 @@ var BWidgetRegistry = {
}
return code;
},
- showInPalette: false,
- selectable: false,
- moveable: false,
+ selectable: true,
+ moveable: true,
properties: {
id: {
type: "string",
@@ -216,7 +214,7 @@ var BWidgetRegistry = {
parent: "Base",
properties: {
background: {
- type: "string",
+ type: "url-uploadable",
defaultValue: "",
htmlAttribute: {
name: "style",
@@ -660,7 +658,7 @@ var BWidgetRegistry = {
template: '
',
properties: {
src: {
- type: "string",
+ type: "url-uploadable",
defaultValue: "src/css/images/widgets/tizen_image.svg",
htmlAttribute: "src",
forceAttribute: true
@@ -2053,7 +2051,7 @@ var BWidget = {
init: function () {
// effects: add the type and displayLabel properties to widget
// registry objects
- var type;
+ var type, parentName;
for (type in BWidgetRegistry) {
if (BWidgetRegistry.hasOwnProperty(type)) {
BWidgetRegistry[type].type = type;
@@ -2089,6 +2087,11 @@ var BWidget = {
if (type === "OptionHeader") {
BWidgetRegistry[type].displayLabel = "Option Header";
}
+ parentName = BWidgetRegistry[type].parent;
+ while (parentName) {
+ BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]);
+ parentName = BWidgetRegistry[parentName].parent;
+ }
}
}
},
@@ -2246,26 +2249,17 @@ var BWidget = {
* @throws {Error} If widgetType is invalid.
*/
getPropertyTypes: function (widgetType) {
- var stack = [], props = {}, length, i, property, widget, currentWidget;
- widget = currentWidget = BWidgetRegistry[widgetType];
+ var stack = [], props = {}, length, i, property, widget;
+ widget = BWidgetRegistry[widgetType];
if (typeof widget !== "object") {
throw new Error("undefined widget type in getPropertyTypes: " +
widgetType);
}
- // build hierarchical stack so child properties will override parents
- while (currentWidget) {
- stack.unshift(currentWidget.properties);
- currentWidget = BWidgetRegistry[currentWidget.parent];
- }
-
- length = stack.length;
- for (i = 0; i < length; i++) {
- for (property in stack[i]) {
- if (stack[i].hasOwnProperty(property)) {
- props[property] = stack[i][property].type;
- }
+ for (property in widget.properties) {
+ if (widget.properties.hasOwnProperty(property)) {
+ props[property] = widget.properties[property].type;
}
}
return props;
@@ -2282,30 +2276,20 @@ var BWidget = {
* @throws {Error} If widgetType is invalid.
*/
getPropertyOptions: function (widgetType) {
- var stack = [], options = {}, length, i, property, widget, currentWidget;
- widget = currentWidget = BWidgetRegistry[widgetType];
+ var stack = [], options = {}, length, i, property, widget;
+ widget = BWidgetRegistry[widgetType];
if (typeof widget !== "object") {
throw new Error("undefined widget type in getPropertyOptions: " +
widgetType);
}
- // build hierarchical stack so child properties will override parents
- // although, really there should be no such conflicts
- while (currentWidget) {
- stack.unshift(currentWidget.properties);
- currentWidget = BWidgetRegistry[currentWidget.parent];
- }
-
- length = stack.length;
- for (i = 0; i < length; i++) {
- for (property in stack[i]) {
- if (stack[i].hasOwnProperty(property)) {
- options[property] = stack[i][property].options;
- }
+ for (property in widget.properties) {
+ if (widget.properties.hasOwnProperty(property)) {
+ options[property] = widget.properties[property].options;
}
}
- return options;
+ return $.extend(true, {}, options);
},
/**
@@ -2318,30 +2302,20 @@ var BWidget = {
* @throws {Error} If widgetType is invalid.
*/
getPropertyDefaults: function (widgetType) {
- var stack = [], props = {}, length, i, property, widget, currentWidget;
- widget = currentWidget = BWidgetRegistry[widgetType];
+ var stack = [], props = {}, length, i, property, widget;
+ widget = BWidgetRegistry[widgetType];
if (typeof widget !== "object") {
throw new Error("undefined widget type in getPropertyDefaults: "+
widgetType);
}
-
- // build hierarchical stack so child properties will override parents
- // although, really there should be no such conflicts
- while (currentWidget) {
- stack.unshift(currentWidget.properties);
- currentWidget = BWidgetRegistry[currentWidget.parent];
- }
-
- length = stack.length;
- for (i = 0; i < length; i++) {
- for (property in stack[i]) {
- if (stack[i].hasOwnProperty(property)) {
- props[property] = stack[i][property].defaultValue;
- }
+ for (property in widget.properties) {
+ if (widget.properties.hasOwnProperty(property)) {
+ props[property] = widget.properties[property].defaultValue;
}
}
- return props;
+
+ return $.extend(true, {}, props);
},
/**
@@ -2360,13 +2334,8 @@ var BWidget = {
widgetType);
}
- // build hierarchical stack so child properties will override parents
- while (widget) {
- if (widget.properties && widget.properties[property]) {
- return widget.properties[property];
- }
- widgetType = widget.parent;
- widget = BWidgetRegistry[widgetType];
+ if (widget.properties && widget.properties[property]) {
+ return $.extend(true, {}, widget.properties[property]);
}
// no such property found in hierarchy