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
11 changes: 11 additions & 0 deletions src/css/builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,17 @@ body.ui-tabs.ui-widget {
overflow-x: hidden;
overflow-y: auto;
}
.propertyView .datalist .upload-button {
text-align: center;
border: 1px solid #a1a1a1;
line-height: 12px;
background-color: #fbfbfb;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
margin-top: 2px;
margin-bottom: 2px;
}
.propertyView .datalist li {
clear:both;
cursor: pointer;
Expand Down
18 changes: 18 additions & 0 deletions src/js/adm.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,24 @@ ADM.addEventType("activePageChanged");
*/
ADM.addEventType("selectionChanged");

/**
* Event sent by the ADM object when the usage status of images change.
* When the active page changes, the selected widget is set to null
* automatically.
*
* @name ADM#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 ADMEventSource.bind
* @see ADMEventSource.unbind
*/
ADM.addEventType("imagesUpdated");

/**
* Gets the singleton design root.
*
Expand Down
23 changes: 16 additions & 7 deletions src/js/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ $(function () {
pmUtils._projectsInfo[newPid] = {};
pmUtils.setProperties(newPid, properties);
pmUtils.setProperty(newPid, "accessDate", new Date());
// init resource usage status
$.rib.pmUtils.resourceRef = {};

if (design && (design instanceof ADMNode)) {
ADM.setDesignRoot(design);
Expand Down Expand Up @@ -534,7 +536,7 @@ $(function () {
* @return {None}.
*/
pmUtils.openProject = function (pid, success, error) {
var designPath, successHandler;
var designPath, successHandler, imagePath;

if (!pmUtils._projectsInfo[pid]) {
console.error("Error: Invalid pid for project when opening project");
Expand All @@ -546,6 +548,7 @@ $(function () {
return;
}
designPath = pmUtils.getDesignPath(pid);
imagePath = pmUtils.getProjectDir(pid) + 'images/';

successHandler = function (result) {
var design, project;
Expand All @@ -556,6 +559,15 @@ $(function () {
pmUtils._activeProject = pid;
// update access time
pmUtils.setProperty(pid, "accessDate", new Date());
// init pmUtils.resourceRef, reset usage status of resources
$.rib.pmUtils.resourceRef = {};
$.rib.fsUtils.ls(imagePath, function (entries) {
$.each(entries, function (i, e) {
$.rib.pmUtils.resourceRef['images/'+e.name] = 0;
});
}, function (e) {
dumplog('There is no image in this project.');
});
// set the new design as design root
ADM.setDesignRoot(design);
success && success();
Expand Down Expand Up @@ -961,6 +973,7 @@ $(function () {
} else {
pmUtils.resourceRef[refPath]++;
}
ADM.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
return;
};

Expand All @@ -983,8 +996,10 @@ $(function () {
$.rib.confirm('Unused resource: "' + entry.name +
'". \nWould you like to delete it from the project?', function () {
$.rib.fsUtils.rm(entry.fullPath);
ADM.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
}, function () {
pmUtils.resourceRef[refPath] = 0;
ADM.fireEvent('imagesUpdated', {usageStatus: pmUtils.resourceRef});
});
});
}
Expand Down Expand Up @@ -1013,12 +1028,6 @@ $(function () {
if (!(node instanceof ADMNode)) {
return false;
}
// if the design is Design root
if (node.getType() === "Design") {
// reset pmUtils.resourceRef
pmUtils.resourceRef = {};
upFlag = true;
}
// Find all used sandbox resource nodes and the matched properties
matched = node.findNodesByProperty($.rib.pmUtils.relativeFilter);
for (i = 0; i < matched.length; i++) {
Expand Down
4 changes: 4 additions & 0 deletions src/js/views/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
o.selectionChanged = this._selectionChangedHandler;
o.activePageChanged = this._activePageChangedHandler;
o.modelUpdated = this._modelUpdatedHandler;
o.imagesUpdated = this._imagesUpdatedHandler;

// FIXME: This should work, but $.extend of options seems to be
// creating a copy of the ADM, which will not containt the
Expand Down Expand Up @@ -94,6 +95,9 @@
if (o.activePageChanged) {
a.bind("activePageChanged", o.activePageChanged, this);
}
if (o.imagesUpdated) {
a.bind("imagesUpdated", o.imagesUpdated, this);
}

// Since model changed, need to call our designReset hander
// to sync up the ADMDesign modelUpdated event handler
Expand Down
Loading