Bug 361495 Advanced property editor should start suggesting values again r=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 07 Aug 2011 14:08:49 +0100
changeset 8253 a0adbb4addc84977d284208aa286bd3e63c3152b
parent 8252 c63fefad39c037cf02b2a05dc77baef8a1b56f0d
child 8254 f80dd2316fcbfb445bb95453b454992951af0dfe
push id6346
push userneil@parkwaycc.co.uk
push dateSun, 07 Aug 2011 13:08:54 +0000
treeherdercomm-central@a0adbb4addc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs361495
Bug 361495 Advanced property editor should start suggesting values again r=IanN
editor/ui/dialogs/content/EdAEHTMLAttributes.js
editor/ui/dialogs/content/EdAdvancedEdit.xul
--- a/editor/ui/dialogs/content/EdAEHTMLAttributes.js
+++ b/editor/ui/dialogs/content/EdAEHTMLAttributes.js
@@ -144,31 +144,16 @@ function BuildHTMLAttributeTable()
       }
     }
 
     if (added)
       SelectHTMLTree(0);
   }
 }
 
-// add or select an attribute in the tree widget
-function onChangeHTMLAttribute()
-{
-  var name = TrimString(gDialog.AddHTMLAttributeNameInput.value);
-  if (!name)
-    return;
-
-  var value = TrimString(gDialog.AddHTMLAttributeValueInput.value);
-
-  // First try to update existing attribute
-  // If not found, add new attribute
-  if (!UpdateExistingAttribute( name, value, "HTMLAList" ) && value)
-    AddTreeItem (name, value, "HTMLAList", HTMLAttrs);
-}
-
 function ClearHTMLInputWidgets()
 {
   gDialog.AddHTMLAttributeTree.view.selection.clearSelection();
   gDialog.AddHTMLAttributeNameInput.value ="";
   gDialog.AddHTMLAttributeValueInput.value = "";
   SetTextboxFocus(gDialog.AddHTMLAttributeNameInput);
 }
 
@@ -231,17 +216,17 @@ function onInputHTMLAttributeName()
     // Index to which widget we were using to edit the value
     var deckIndex = gDialog.AddHTMLAttributeValueDeck.getAttribute("selectedIndex");
 
     if (valueListName in gHTMLAttr)
     {
       var valueList = gHTMLAttr[valueListName];
 
       listLen = valueList.length;
-      if (listLen > 0)
+      if (listLen == 1)
         newValue = valueList[0];
 
       // Note: For case where "value list" is actually just 
       // one (default) item, don't use menulist for that
       if (listLen > 1)
       {
         gDialog.AddHTMLAttributeValueMenulist.removeAllItems();
 
@@ -280,16 +265,19 @@ function onInputHTMLAttributeName()
 
     // If attribute already exists in tree, use associated value,
     //  else use default found above
     var existingValue = GetAndSelectExistingAttributeValue(attName, "HTMLAList");
     if (existingValue)
       newValue = existingValue;
       
     gDialog.AddHTMLAttributeValueInput.value = newValue;
+
+    if (!existingValue)
+      onInputHTMLAttributeValue();
   }
 }
 
 function onInputHTMLAttributeValue()
 {
   if (!gUpdateTreeValue)
     return;
 
--- a/editor/ui/dialogs/content/EdAdvancedEdit.xul
+++ b/editor/ui/dialogs/content/EdAdvancedEdit.xul
@@ -113,25 +113,26 @@
             <row equalsize="always">
               <label control="AddHTMLAttributeNameInput" value="&AttName.label;"/>
               <label control="AddHTMLAttributeValueInput" value="&AttValue.label;"/>
             </row>
             <row align="top" equalsize="always">
               <!-- Lists are built at runtime -->
               <menulist id="AddHTMLAttributeNameInput" editable="true" flex="1"
                         oninput="onInputHTMLAttributeName();"
-                        onchange="onChangeHTMLAttribute();"/>
+                        oncommand="onInputHTMLAttributeName();"/>
               <deck id="AddHTMLAttributeValueDeck" selectedIndex="0">
                 <hbox align="top">
                   <textbox id="AddHTMLAttributeValueTextbox" flex="1"
                            oninput="onInputHTMLAttributeValue();"/>
                 </hbox>
                 <hbox align="top">
                   <menulist id="AddHTMLAttributeValueMenulist" editable="true" flex="1"
-                            oninput="onInputHTMLAttributeValue();"/>
+                            oninput="onInputHTMLAttributeValue();"
+                            oncommand="onInputHTMLAttributeValue();"/>
                 </hbox>
               </deck>
             </row>
           </rows>
         </grid>
       </vbox>
       <!-- ============================================================== -->
       <!--                         CSS Attributes                         -->
@@ -160,18 +161,17 @@
           </columns>
           <rows>
             <row equalsize="always">
               <label value="&PropertyName.label;"/>
               <label value="&AttValue.label;"/>
             </row>
             <row align="top" equalsize="always">
               <textbox id="AddCSSAttributeNameInput" flex="1"
-                oninput="onInputCSSAttributeName();"
-                onchange="onChangeCSSAttribute();"/>
+                oninput="onInputCSSAttributeName();"/>
           	  <textbox id="AddCSSAttributeValueInput" flex="1"
                 oninput="onChangeCSSAttribute();"/>
             </row>
           </rows>
         </grid>
       </vbox>
       <!-- ============================================================== -->
       <!--                    JavaScript Event Handlers                   -->
@@ -201,19 +201,17 @@
           <rows>
             <row equalsize="always">
               <label value="&AttName.label;"/>
               <label value="&AttValue.label;"/>
             </row>
             <row align="top" equalsize="always">
               <!-- List is built at runtime -->
               <menulist id="AddJSEAttributeNameList" flex="1"
-                oncommand="onSelectJSEAttribute();">
-                <menupopup/>
-              </menulist>
+                oncommand="onSelectJSEAttribute();"/>
           	  <textbox id="AddJSEAttributeValueInput" flex="1"
                 oninput="onInputJSEAttributeValue();"/>
             </row>
           </rows>
         </grid>
       </vbox>
     </tabpanels>
   </tabbox>