Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.
Merged
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
4 changes: 3 additions & 1 deletion src/js/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ $(function() {
// remove the temp input element
input.remove();
});
input.click();
setTimeout(function() {
input.click();
}, 0);
},

/**
Expand Down
100 changes: 100 additions & 0 deletions src/js/jquery-workarounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

20 changes: 20 additions & 0 deletions src/js/views/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@
value.find("#" + valueId).attr("checked", "checked");
}
break;
case "url-uploadable":
$('<input type ="text" value="">')
.attr('id', valueId)
.addClass('title labelInput')
.appendTo(value);
//set default value
value.find('#' + valueId).val(valueVal);
$('<button> Upload </button>')
.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":
$('<table/>')
.attr('id', 'selectOption')
Expand Down
91 changes: 30 additions & 61 deletions src/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ var BWidgetRegistry = {
*/
Base: {
parent: null,
allowIn: [],
applyProperties: function (node, code) {
var id = node.getProperty("id");
if (id && node.isPropertyExplicit("id")) {
code.attr("id", id);
}
return code;
},
showInPalette: false,
selectable: false,
moveable: false,
selectable: true,
moveable: true,
properties: {
id: {
type: "string",
Expand Down Expand Up @@ -216,7 +214,7 @@ var BWidgetRegistry = {
parent: "Base",
properties: {
background: {
type: "string",
type: "url-uploadable",
defaultValue: "",
htmlAttribute: {
name: "style",
Expand Down Expand Up @@ -660,7 +658,7 @@ var BWidgetRegistry = {
template: '<img/>',
properties: {
src: {
type: "string",
type: "url-uploadable",
defaultValue: "src/css/images/widgets/tizen_image.svg",
htmlAttribute: "src",
forceAttribute: true
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
},
Expand Down Expand Up @@ -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;
Expand All @@ -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);
},

/**
Expand All @@ -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);
},

/**
Expand All @@ -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
Expand Down