Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
[Property View] Add event to update image options
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnaWuDongxia authored and grgustaf committed Aug 30, 2012
1 parent 60969b0 commit ad2d354
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,18 @@ RIBEventSource.prototype.suppressEvents = function (flag) {
$.rib[i] = eventSource[i];
}
}());
/*
* Event sent by the when the usage status of images changes.
*
* @name pmUtils#imagesUpdated
* @event
* @param {Object} event Object including standard "id" and "name"
* properties, as well as a
* "usageStatus" is an object contains
* current usage status of
* all existing images
* @param {Any} data The data you supplied to the bind() call.
* @see RIBEventSource.bind
* @see RIBEventSource.unbind
*/
$.rib.addEventType("imagesUpdated");
3 changes: 3 additions & 0 deletions src/js/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ $(function () {
} else {
pmUtils.resourceRef[refPath]++;
}
$.rib.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
return;
};

Expand All @@ -1015,8 +1016,10 @@ $(function () {
$.rib.confirm('Unused resource: "' + entry.name +
'". \nWould you like to delete it from the project?', function () {
$.rib.fsUtils.rm(entry.fullPath);
$.rib.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
}, function () {
pmUtils.resourceRef[refPath] = 0;
$.rib.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
});
});
}
Expand Down
17 changes: 17 additions & 0 deletions src/js/views/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
e.stopPropagation();
});

$.rib.bind("imagesUpdated", this._imagesUpdatedHandler, this);
return this;
},

Expand Down Expand Up @@ -110,6 +111,17 @@
// happen when selection changes
},

_imagesUpdatedHandler: function(event, widget) {
widget = widget || this;
var optionsList, options;
if (widget.options.imagesDatalist) {
options = event.usageStatus || $.rib.pmUtils.resourceRef;
optionsList = widget.options.imagesDatalist.find('ul');
updateOptions(optionsList, Object.keys(options));
}
return;
},

_showProperties: function(node) {
var labelId, labelVal, valueId, valueVal, count,
widget = this, type, i, child, index, propType,
Expand All @@ -133,6 +145,9 @@
.addClass('title')
.text(BWidget.getDisplayLabel(type)+' Properties');
content.empty();

// get rid of old datalist element
this.options.imagesDatalist = null;
propertyItems = $('<div/>').addClass("propertyItems")
.appendTo(content);
props = node.getProperties();
Expand Down Expand Up @@ -215,6 +230,8 @@
.attr('id', valueId)
.addClass('title labelInput')
.val(valueVal);
// save the datalist for update
this.options.imagesDatalist = $(this.options.imagesDatalist).add(datalist);
break;

case "record-array":
Expand Down

0 comments on commit ad2d354

Please sign in to comment.