diff --git a/index.html b/index.html index 16382dc8..4d15006a 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + @@ -34,7 +35,6 @@ - diff --git a/src/assets/groups.json b/src/assets/groups.json index bb05bd01..202514fa 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -21,8 +21,25 @@ "Boolean": ["#0._hidden_node.jqm_input_boolean"] } ], - "List Views": [ - "List", "OrderedList", "ListItem", "ListDivider", "ListButton" + "List Views": [ { + "Single Lists": [ + "SimpleList", + "ButtonList", + "TextList", + "IconList", + "ThumbnailList", + "SimpleListItem", + "ListDivider" + ], + "Split Lists": [ + "ButtonSplitList", + "TextSplitList", + "IconSplitList", + "ThumbnailSplitList", + "SimpleListItem", + "ListDivider" + ] + } ], "Image": ["Image"] } diff --git a/src/css/builder.css b/src/css/builder.css index 6ec9b547..d5c76ff7 100644 --- a/src/css/builder.css +++ b/src/css/builder.css @@ -1344,6 +1344,11 @@ div.propertyItems label[for|=id] { font-weight: bold; } +.titleBar input { + width: 150px; + margin: 3px; +} + .openButton { background-image: url("images/openButton_up.png"); background-repeat: no-repeat; diff --git a/src/css/composer.css b/src/css/composer.css index 5663474c..40b1d136 100644 --- a/src/css/composer.css +++ b/src/css/composer.css @@ -48,7 +48,7 @@ /*************************/ /* Class specific tweaks */ /*************************/ -.nrc-sortable-container.ui-content .adm-node { +.nrc-sortable-container.ui-content > * { margin-top: 10px; margin-bottom: 10px; } diff --git a/src/css/images/widgets/jqm_button_list.svg b/src/css/images/widgets/jqm_button_list.svg new file mode 100644 index 00000000..647be337 --- /dev/null +++ b/src/css/images/widgets/jqm_button_list.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +Button List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_button_split_list.svg b/src/css/images/widgets/jqm_button_split_list.svg new file mode 100644 index 00000000..edd6c5ce Binary files /dev/null and b/src/css/images/widgets/jqm_button_split_list.svg differ diff --git a/src/css/images/widgets/jqm_icon_list.svg b/src/css/images/widgets/jqm_icon_list.svg new file mode 100644 index 00000000..af655fe4 Binary files /dev/null and b/src/css/images/widgets/jqm_icon_list.svg differ diff --git a/src/css/images/widgets/jqm_icon_list_button.svg b/src/css/images/widgets/jqm_icon_list_button.svg new file mode 100644 index 00000000..53c6e1f2 --- /dev/null +++ b/src/css/images/widgets/jqm_icon_list_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +Icon List Button + + + diff --git a/src/css/images/widgets/jqm_icon_split_list.svg b/src/css/images/widgets/jqm_icon_split_list.svg new file mode 100644 index 00000000..7293b6df Binary files /dev/null and b/src/css/images/widgets/jqm_icon_split_list.svg differ diff --git a/src/css/images/widgets/jqm_list.svg b/src/css/images/widgets/jqm_list.svg index ff9dd70b..4481b865 100644 --- a/src/css/images/widgets/jqm_list.svg +++ b/src/css/images/widgets/jqm_list.svg @@ -32,7 +32,7 @@ -Unordered List +Simple List diff --git a/src/css/images/widgets/jqm_list_split_button.svg b/src/css/images/widgets/jqm_list_split_button.svg deleted file mode 100644 index 2411051f..00000000 --- a/src/css/images/widgets/jqm_list_split_button.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - -List Split Button - - - - diff --git a/src/css/images/widgets/jqm_text_list.svg b/src/css/images/widgets/jqm_text_list.svg new file mode 100644 index 00000000..a093acef --- /dev/null +++ b/src/css/images/widgets/jqm_text_list.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +Text List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_text_list_button.svg b/src/css/images/widgets/jqm_text_list_button.svg new file mode 100644 index 00000000..7bee4b5c Binary files /dev/null and b/src/css/images/widgets/jqm_text_list_button.svg differ diff --git a/src/css/images/widgets/jqm_text_split_list.svg b/src/css/images/widgets/jqm_text_split_list.svg new file mode 100644 index 00000000..f9faa178 Binary files /dev/null and b/src/css/images/widgets/jqm_text_split_list.svg differ diff --git a/src/css/images/widgets/jqm_thumbnail_list.svg b/src/css/images/widgets/jqm_thumbnail_list.svg new file mode 100644 index 00000000..0538fc87 Binary files /dev/null and b/src/css/images/widgets/jqm_thumbnail_list.svg differ diff --git a/src/css/images/widgets/jqm_thumbnail_list_button.svg b/src/css/images/widgets/jqm_thumbnail_list_button.svg new file mode 100644 index 00000000..2dfb18aa --- /dev/null +++ b/src/css/images/widgets/jqm_thumbnail_list_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +Thumbnail List Button + + + diff --git a/src/css/images/widgets/jqm_thumbnail_split_list.svg b/src/css/images/widgets/jqm_thumbnail_split_list.svg new file mode 100644 index 00000000..309ee419 Binary files /dev/null and b/src/css/images/widgets/jqm_thumbnail_split_list.svg differ diff --git a/src/js/adm.js b/src/js/adm.js index 364f82fa..20e81603 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -518,7 +518,7 @@ ADM.endTransaction = function () { * @return {ADMNode} The child object, on success; null, on failure. */ ADM.addChild = function (parentRef, childRef, dryrun) { - var parent, child; + var parent, child, oldParent, oldZone, oldZoneIndex; parent = ADM.toNode(parentRef); if (!parent) { @@ -538,6 +538,11 @@ ADM.addChild = function (parentRef, childRef, dryrun) { return null; } + oldParent = child.getParent(); + if (oldParent) { + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (parent.addChild(child, dryrun)) { if (dryrun) { return true; @@ -547,7 +552,10 @@ ADM.addChild = function (parentRef, childRef, dryrun) { ADM.transaction({ type: "add", parent: child.getParent(), - child: child + child: child, + oldParent: oldParent, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -634,7 +642,7 @@ ADM.addChildRecursive = function (parentRef, childRef, dryrun) { * @private */ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { - var sibling, child; + var sibling, child, oldParent, oldZone, oldZoneIndex; sibling = ADM.toNode(siblingRef); if (!sibling) { @@ -655,6 +663,11 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { childRef); } + oldParent = child.getParent(); + if (oldParent) { + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (sibling.insertChildRelative(child, offset, dryrun)) { if (dryrun) { return true; @@ -663,7 +676,10 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { type: "insertRelative", sibling: sibling, child: child, - offset: offset + offset: offset, + oldParent: oldParent, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -922,6 +938,9 @@ ADM.undo = function () { if (obj.type === "add") { ADM.ensurePageInactive(obj.child); obj.parent.removeChild(obj.child); + if (obj.oldParent) { + obj.oldParent.addChildToZone(obj.child, obj.oldZone, obj.oldZoneIndex); + } } else if (obj.type === "remove") { obj.parent.insertChildInZone(obj.child, obj.zone, obj.zoneIndex); @@ -933,6 +952,9 @@ ADM.undo = function () { } else if (obj.type === "insertRelative") { obj.sibling.getParent().removeChild(obj.child); + if (obj.oldParent) { + obj.oldParent.addChildToZone(obj.child, obj.oldZone, obj.oldZoneIndex); + } } else if (obj.type === "propertyChange") { // TODO: this could require deeper copy of complex properties @@ -1167,18 +1189,8 @@ function ADMNode(widgetType) { var currentType = widgetType, widget, zones, length, i, func; this._valid = false; - this._inheritance = []; - - while (currentType) { - widget = BWidgetRegistry[currentType]; - if (typeof widget === "object") { - this._inheritance.push(currentType); - currentType = widget.parent; - } else { - console.error("Error: invalid type hierarchy creating ADM node"); - return; - } - } + this._inheritance = [widgetType]; + $.merge(this._inheritance, BWidget.getAncestors(widgetType)); this._uid = ++ADMNode.prototype._lastUid; @@ -1666,11 +1678,20 @@ ADMNode.prototype.addChild = function (child, dryrun) { ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, dryrun) { // requires: assumes cardinality is "N", or a numeric string - var add = false, myType, childType, zone, cardinality, limit; + var add = false, myType, childType, zone, cardinality, limit, morph, morphedChildType; myType = this.getType(); childType = child.getType(); zone = this._zones[zoneName]; + morph = BWidget.getZone(myType, zoneName).morph; + if (morph) + { + morphedChildType = morph(childType, myType); + if (morphedChildType !== childType) { + childType = morphedChildType; + $.extend(true, child, ADM.createNode(morphedChildType)); + } + } if (!BWidget.zoneAllowsChild(myType, zoneName, childType)) { if (!dryrun) { console.warn("Warning: zone " + zoneName + @@ -1693,6 +1714,7 @@ ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, return false; } + cardinality = cardinality.max || cardinality; if (cardinality !== "N") { limit = parseInt(cardinality, 10); if (zone.length >= limit) { @@ -1777,7 +1799,7 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, } } - var zone = this._zones[zoneName]; + var zone = this._zones[zoneName], oldParent, oldZone, oldZoneIndex; if (!zone) { console.error("Error: zone not found in insertChildInZone: " + zoneName); @@ -1788,6 +1810,9 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, return false; } if (child instanceof ADMNode) { + oldParent = child.getParent(); + if (oldParent) + return child.moveNode(this, zoneName, index, dryrun); if (!dryrun) { zone.splice(index, 0, child); @@ -1845,6 +1870,9 @@ ADMNode.prototype.moveNode = function (newParent, zoneName, zoneIndex, dryrun) { oldZone = this._zone; oldIndex = this.getZoneIndex(); removed = oldParent.removeChild(this, dryrun); + if (oldParent === newParent && oldZone === zoneName + && oldIndex < zoneIndex) + zoneIndex --; if (removed) { if (removed != this) { @@ -1904,12 +1932,30 @@ ADMNode.prototype.removeChild = function (child, dryrun) { * @return {ADMNode} The removed child, or null if not found. */ ADMNode.prototype.removeChildFromZone = function (zoneName, index, dryrun) { - var zone, removed, child, parentNode, parent; + var zone, removed, child, parent, cardinality, min; zone = this._zones[zoneName]; if (!zone) { console.error("Error: no such zone found while removing child: " + zoneName); } + cardinality = BWidget.getZoneCardinality(this.getType(), zoneName); + if (!cardinality) { + console.warn("Warning: no cardinality found for zone " + zoneName); + return false; + } + + if (cardinality.min) { + min = parseInt(cardinality.min, 10); + + if (zone.length <= min) { + alert("At least " + + cardinality.min + " " + + BWidget.getDisplayLabel(zone[index].getType()) + + (min === 1 ? " " : "s ") + + (min === 1 ? "is": "are") + " required and cannot be deleted!"); + return false; + } + } if (dryrun) { removed = [zone[index]]; diff --git a/src/js/composer.js b/src/js/composer.js index 7f85a8c7..f86594cc 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -279,58 +279,6 @@ $(function() { } }; - var addNewNodeOnDrop = function (domParent, domChildren, adm, pid, - nodeRef, role, domNode) { - var newNode, domSibling, sid, admChildren, domIndex, debug; - - debug = (window.top.$.rib && window.top.$.rib.debug()); - domIndex = domChildren.index(domNode); - - // Append first(only)/last child to this container - if (domIndex >= domChildren.length-1 || role === 'page') { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Appended node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Append child failed:',role); - } - } else if (domIndex > 0) { - // Insert nth child into this container - domSibling = $(domNode, domParent).prev('.adm-node'); - sid = domSibling.attr('data-uid'); - if (adm.insertChildAfter(sid, nodeRef, true)) { - newNode = adm.insertChildAfter(sid, nodeRef); - debug && console.log('Inserted nth node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert nth child failed:',role); - } - } else { - // Add 1st child into an empty container - if (domChildren.length-1 <= 0) { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Added 1st node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Add 1st child failed:',role); - } - } else { - // Insert 1st child into non-empty container - admChildren = adm.toNode(pid).getChildren(); - sid = admChildren.length && admChildren[0].getUid(); - if (adm.insertChildBefore(sid, nodeRef, true)) { - newNode = adm.insertChildBefore(sid, nodeRef); - debug && console.log('Inserted 1st node', role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert 1st child failed:', role); - } - } - } - }; - window.top.$.rib = window.top.$.rib || {}; window.top.$.rib.dndfilter = dndfilter; @@ -550,6 +498,7 @@ $(function() { '> .ui-collapsible-content > .adm-node,' + '> ul > li.adm-node,' + '> div > .adm-node,' + + '> div > div > a > .adm-node,' + '> *.orig-adm-node:not(.ui-header,.ui-content,.ui-footer)', start: function(event, ui){ trackOffsets('start: ',ui,$(this).data('sortable')); @@ -634,16 +583,14 @@ $(function() { }, stop: function(event, ui){ trackOffsets('stop: ',ui,$(this).data('sortable')); - var type, isDrop, + var isDrop, pid = $(this).attr('data-uid'), - node = null, adm = window.parent.ADM, - bw = window.parent.BWidget, root = adm.getDesignRoot(), - node, zones, newParent, newZone, - rdx, idx, cid, pid, sid, + nodeRef, newParent, + cid, pid, sibling, children, parent, - role, card; + role, prevItem = ui.item, nextItem = ui.item; role = $(this).attr('data-role') || ''; @@ -694,87 +641,48 @@ $(function() { ui.item.remove(); return false; } - - // Drop from palette: add a node if (isDrop) { if (ui.item.data('adm-node')) { - type = ui.item.data('adm-node').type; + nodeRef = ui.item.data('adm-node').type; } - if (!type) { + if (!nodeRef) { console.warn('Drop failed: Missing node type'); ui.item.remove(); return false; } - - children = $($(this).sortable('option', 'items'), this) - .add(ui.item); - addNewNodeOnDrop(this, children, adm, pid, type, - role, ui.item); - ui.item.remove(); - return; - - // Sorted from layoutView: move a node - } else { - children = ui.item.parent().children('.adm-node') - .add(ui.item); - idx = children.index(ui.item); + } + else { cid = ui.item.attr('data-uid'); // closest() will select current element if it matches // the selector, so we start with its parent. + nodeRef = cid && root.findNodeByUid(cid); + if (event && event.ctrlKey) { + nodeRef = adm.copySubtree(nodeRef); + } + } + + while (prevItem[0] || nextItem[0]) { + prevItem = prevItem.prev('.adm-node'); + if (prevItem[0] && adm.insertChildAfter + (prevItem.attr('data-uid'), nodeRef)) + break; + nextItem = nextItem.next('.adm-node'); + if (nextItem[0] && adm.insertChildBefore + (nextItem.attr('data-uid'), nodeRef)) + break; + } + if (!prevItem[0] && !nextItem[0]) { pid = ui.item.parent() .closest('.adm-node.ui-sortable,'+ '.orig-adm-node.ui-sortable') .attr('data-uid'); - node = cid && root.findNodeByUid(cid); - if (event && event.ctrlKey) { - node = adm.copySubtree(node); // Clone it - addNewNodeOnDrop(this, children, adm, pid, node, - role, ui.item); - } else { - newParent = pid && root.findNodeByUid(pid); - zones = newParent && bw.getZones(newParent.getType()); - card = newParent && zones && - bw.getZoneCardinality(newParent.getType(), - zones[0]); - - // Notify the ADM that element has been moved - if ((zones && zones.length===1 && card !== '1')) { - if (!node || - !adm.moveNode(node, newParent, zones[0], - idx)) { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } else { - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } - } else if (node && newParent && - newParent.getType() === 'Header') { - for (var z=0; z < zones.length; z++) { - if (adm.moveNode(node, newParent, zones[z], - 0, true)) { - newZone = zones[z]; - break; - } - } - if (newZone) { - adm.moveNode(node, newParent, newZone, 0); - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } else { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } - } else { - console.warn('Move node failed: invalid zone'); - ui.item.remove(); - return false; - } - } + newParent = pid && root.findNodeByUid(pid); + if (nodeRef = adm.addChild(newParent, nodeRef)) + return false; } + if (nodeRef) + adm.setSelected(nodeRef); } }) .bind('mousedown.composer', function(event) { diff --git a/src/js/projects.js b/src/js/projects.js index fbb8a852..841f8f55 100644 --- a/src/js/projects.js +++ b/src/js/projects.js @@ -27,7 +27,9 @@ $(function () { // Filter to find sandbox resources relativeFilter:{ type: "url-uploadable", - value: /^(?!(https?|ftp):\/+).+/i + value: function (valueObject) { + return valueObject.inSandbox; + } }, // Object to save refernce count for sandbox resource resourceRef: {}, @@ -956,6 +958,7 @@ $(function () { * @return {None} */ pmUtils.addRefCount = function (refPath) { + refPath = refPath.value || refPath; if (!pmUtils.resourceRef[refPath]) { pmUtils.resourceRef[refPath] = 1; } else { @@ -972,6 +975,7 @@ $(function () { */ pmUtils.reduceRefCount = function (refPath) { var projectDir = pmUtils.ProjectDir + "/" + pmUtils.getActive() + "/"; + refPath = refPath.value || refPath; if (pmUtils.resourceRef.hasOwnProperty(refPath)) { pmUtils.resourceRef[refPath]--; // Delete the resource if the reference count is 0 diff --git a/src/js/serialize.js b/src/js/serialize.js index 64f5b2cc..cba181d9 100644 --- a/src/js/serialize.js +++ b/src/js/serialize.js @@ -425,11 +425,23 @@ $(function () { } function getDesignHeaders(design, useSandboxUrl) { - var i, props, el, designRoot, headers; + var i, props, el, designRoot, headers, toCorrectPath; designRoot = design || ADM.getDesignRoot(); headers = []; props = designRoot.getProperty('metas'); + toCorrectPath = function (header) { + var path = header.value; + // If need to use sandbox url + if (header.inSandbox) { + if (useSandboxUrl) { + path = toSandboxUrl(path); + } else { + path = path.replace(/^\//, ''); + } + } + return path; + }; for (i in props) { // Skip design only header properties if (props[i].hasOwnProperty('designOnly') && props[i].designOnly) { @@ -444,12 +456,7 @@ $(function () { if ((typeof props[i].value !== 'string') || (props[i].value.length <= 0)) { continue; } - // If need to use sandbox url - if (useSandboxUrl && props[i].inSandbox) { - el = el + '="' + toSandboxUrl(props[i].value) + '"'; - } else { - el = el + '="' + props[i].value + '"'; - } + el = el + '="' + toCorrectPath(props[i]) + '"'; if (props[i].hasOwnProperty('content')) { el = el + ' content="' + props[i].content + '"'; } @@ -470,11 +477,7 @@ $(function () { } el = ''; headers.push(el); } @@ -492,11 +495,7 @@ $(function () { } el = ''; headers.push(el); } @@ -659,7 +658,7 @@ $(function () { for (p in matched) { files.push({ "src": toSandboxUrl(matched[p]), - "dst": matched[p] + "dst": matched[p].value ? matched[p].value : matched[p] }); } }); @@ -730,19 +729,23 @@ $(function () { } function toSandboxUrl(path, pid) { - var projectDir, fullPath; + var projectDir, pathStr; pid = pid || $.rib.pmUtils.getActive(); projectDir = $.rib.pmUtils.getProjectDir(pid); - if (typeof path !== "string") { - console.error("Invalid path in toSandboxUrl: " + path); + if ((path instanceof Object) && path.inSandbox) { + pathStr = path.value; + } else { + pathStr = path; + } + if (typeof pathStr !== "string") { + console.error("Invalid path in toSandboxUrl: " + pathStr); return null; } - fullPath = path; // If the first char is '/', then it will be the absolute path in sandbox - if (path[0] !== '/' && projectDir) { - fullPath = projectDir + path; + if (pathStr[0] !== '/' && projectDir) { + pathStr = projectDir + pathStr; } - return $.rib.fsUtils.pathToUrl(fullPath); + return $.rib.fsUtils.pathToUrl(pathStr); } function indexOfArray(array, value) { diff --git a/src/js/views/layout.js b/src/js/views/layout.js index e925c36c..98fa2f0f 100644 --- a/src/js/views/layout.js +++ b/src/js/views/layout.js @@ -428,15 +428,6 @@ // these lines. $(domNode).removeAttr('disabled'); $(domNode).children().removeAttr('disabled'); - - // Set default src for empty image to make them show up - // TODO: This case may need to improve, such as we can show a box - // with "empty image" message to notice the user - if ((admNode.getType() === "Image") && (!admNode.getProperty('src'))) { - if ($(domNode).is('img')) { - $(domNode).attr('src', "src/css/images/widgets/tizen_image.svg"); - } - } } }); })(jQuery); diff --git a/src/js/views/project.js b/src/js/views/project.js index 6d82e466..453752f5 100644 --- a/src/js/views/project.js +++ b/src/js/views/project.js @@ -361,7 +361,34 @@ '-webkit-transform-origin':'2 2'}); }, _buttonEvents: function(box, pid, widget) { - var openHandler, cloneHandler, deleteHandler; + var renameHandler, openHandler, cloneHandler, deleteHandler; + renameHandler = function(e) { + var spanElement = $(this), + renameProject = function(e, inputElement, spanElement) { + var projectName = inputElement.val(); + if (projectName.trim() == '') + projectName = 'Untitled' + $.rib.pmUtils.setProperty(pid, "name", projectName); + spanElement.html(projectName); + spanElement.show(); + inputElement.remove(); + }; + + spanElement.hide(); + $('') + .attr('type', 'text') + .val(spanElement.html()) + .appendTo(spanElement.parent()) + .keydown(function(e) { + if(e.keyCode == '13') { + renameProject(e, $(this), spanElement); + } + }) + .blur(function(e) { + renameProject(e, $(this), spanElement); + }) + .focus(); + }; openHandler = function () { var success = function () { // show the layout tab @@ -397,6 +424,7 @@ $.rib.pmUtils.deleteProject(pid, success); }); }; + box.find('.titleBar > span').dblclick(renameHandler); box.find('.openButton').click(openHandler); box.find('.clone.button').click(cloneHandler); box.find('.delete.button').click(deleteHandler); diff --git a/src/js/views/property.js b/src/js/views/property.js index 3cbbf9de..838a57d4 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -81,12 +81,20 @@ }, _modelUpdatedHandler: function(event, widget) { + var affectedWidget, id; + widget = widget || this; if (event && (event.type === "propertyChanged" && event.node.getType() === 'Design')) { return; } else { widget.refresh(event,widget); + if(event.type === 'propertyChanged') { + id = event.property + '-value'; + affectedWidget = widget.element.find('#' + id); + affectedWidget[0].scrollIntoViewIfNeeded(); + affectedWidget.effect("highlight", {}, 1000); + } } }, @@ -96,7 +104,7 @@ p, props, options, code, o, propertyItems, label, value, title = this.element.parent().find('.property_title'), content = this.element.find('.property_content'), - continueToDelete; + continueToDelete, container; // Clear the properties pane when nothing is selected if (node === null || node === undefined) { @@ -169,18 +177,18 @@ .addClass('title labelInput') .appendTo(value); //set default value - value.find('#' + valueId).val(valueVal); + value.find('#' + valueId).val(valueVal.value); $('') .addClass('buttonStyle') - .click(function (e) { - var target, saveDir; - target = $(this).prev("input:text"); - saveDir = $.rib.pmUtils.ProjectDir + "/" + $.rib.pmUtils.getActive() + "/images/"; + .click({node:node, property:p}, function (e) { + var saveDir = $.rib.pmUtils.getProjectDir() + "images/"; $.rib.fsUtils.upload("image", $(this).parent(), function(file) { // Write uploaded file to sandbox $.rib.fsUtils.write(saveDir + file.name, file, function (newFile) { - target.val("images/" + newFile.name); - target.trigger('change'); + ADM.setProperty(e.data.node, e.data.property, { + inSandbox: true, + value: "images/" + newFile.name + }); }); }); }).appendTo(value); @@ -382,8 +390,16 @@ value = e.data.value, p = e.data.p; items += '
  • previous page
  • '; + container = node.getParent(); + while (container !== null && + container.getType() !== "Page") { + container = container.getParent(); + } pages = ADM.getDesignRoot().getChildren(); for (o = 0; o < pages.length; o++) { + if (pages[o] === container) { + continue; + } id = pages[o].getProperty('id'); items += '
  • #' + id + '
  • '; } diff --git a/src/js/widgets.js b/src/js/widgets.js index 292e87f8..761fd52f 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -25,6 +25,11 @@ var BCommonProperties = { defaultValue: false, htmlAttribute: "disabled" }, + filter: { + type: "boolean", + defaultValue: false, + htmlAttribute: "data-filter" + }, icon: { type: "datalist", options: [ "none", "alert", "arrow-d", "arrow-l", "arrow-r", @@ -64,6 +69,10 @@ var BCommonProperties = { defaultValue: "default", htmlAttribute: "data-position" }, + text: { + type: "string", + defaultValue: "Button" + }, theme: { type: "string", options: function() { @@ -88,6 +97,16 @@ var BCommonProperties = { options: [ "default", "a", "b", "c", "d", "e" ], defaultValue: "default", htmlAttribute: "data-track-theme" + }, + inset: { + type: "boolean", + defaultValue: true, + htmlAttribute: "data-inset", + // because data-inset="false" is the real default, do this: + forceAttribute: true + // FIXME: would be better to distinguish from the default that + // occurs if you leave it off, vs. the default we think + // the user is most likely to want } }; @@ -135,7 +154,8 @@ var BCommonProperties = { * Each zone description in the array should be an object with: * 1) name identifying the zone point * 2) cardinality, either "1" or "N" representing number of contained items - * 3) allow: string or array of string names of allowable widgets + * 3) allow: string or array of string names or a function that returns + * a string or an array of allowable widgets * (all others will be denied) * 4) deny: string or array of string names of disallowed widgets * (all others will be allowed) @@ -144,6 +164,8 @@ var BCommonProperties = { * of this zone. * 6) itemWrapper: an HTML tag used to wrapp a child node before appending * to the zone + * 7) morph: function used to change the child type to another type before + * adding it to the zone * * The "properties" of each widget definition is an object, each property of * which names a property of the widget. These are objects with the following @@ -292,10 +314,11 @@ var BWidgetRegistry = { properties: { background: { type: "url-uploadable", - defaultValue: "", + defaultValue: {}, htmlAttribute: "style", htmlValueMap: function (propValue) { - return "background-image: url('" + propValue + "'); " + + return "background-image: url('" + + propValue + "'); " + "background-attachment: fixed; " + "background-repeat: no-repeat; " + "background-size: 100% 100%;"; @@ -647,26 +670,11 @@ var BWidgetRegistry = { }, /** - * Represents a button. A "text" string property holds the button text. + * Represents a base button widget */ - Button: { + ButtonBase: { parent: "Base", - paletteImageName: "jqm_button.svg", - editable: { - selector: "span > .ui-btn-text", - propertyName: "text" - }, properties: { - text: { - type: "string", - defaultValue: "Button" - }, - right: { - displayName: "align right", - validIn: "Header", - type: "boolean", - defaultValue: false - }, target: { type: "targetlist", defaultValue: "", @@ -691,6 +699,29 @@ var BWidgetRegistry = { defaultValue: "slide", htmlAttribute: "data-transition" }, + }, + template: '%TEXT%' + }, + + /** + * Represents a button. A "text" string property holds the button text. + */ + + Button: { + parent: "ButtonBase", + paletteImageName: "jqm_button.svg", + editable: { + selector: "span > .ui-btn-text", + propertyName: "text" + }, + properties: { + text: BCommonProperties.text, + right: { + displayName: "align right", + validIn: "Header", + type: "boolean", + defaultValue: false + }, icon: BCommonProperties.icon, iconpos: $.extend({}, BCommonProperties.iconpos, { invalidIn: "Navbar" @@ -743,7 +774,10 @@ var BWidgetRegistry = { properties: { src: { type: "url-uploadable", - defaultValue: "", + defaultValue: { + value: "src/css/images/widgets/tizen_image.svg", + inSandbox: false + }, htmlAttribute: "src", forceAttribute: true }, @@ -1351,34 +1385,10 @@ var BWidgetRegistry = { /** * Represents a unordered list element. */ - List: { - parent: "Base", + SimpleList: { + parent: "ListBase", paletteImageName: "jqm_list.svg", - dragHeader: true, properties: { - inset: { - type: "boolean", - defaultValue: true, - htmlAttribute: "data-inset", - // because data-inset="false" is the real default, do this: - forceAttribute: true - // FIXME: would be better to distinguish from the default that - // occurs if you leave it off, vs. the default we think - // the user is most likely to want - }, - theme: BCommonProperties.theme, - divider: { - displayName: "divider theme", - type: "string", - options: [ "default", "a", "b", "c", "d", "e" ], - defaultValue: "default", - htmlAttribute: "data-divider-theme" - }, - filter: { - type: "boolean", - defaultValue: false, - htmlAttribute: "data-filter" - }, filter_theme: $.extend({}, BCommonProperties.theme, { displayName: "filter theme", htmlAttribute: "data-filter-theme" @@ -1390,12 +1400,80 @@ var BWidgetRegistry = { htmlAttribute: "data-filter-placeholder" } }, - template: '