diff --git a/editor/ui/composer/locale/en-US/editor.properties b/editor/ui/composer/locale/en-US/editor.properties index 4e55cbd2f9ab..d9f9549938bc 100644 --- a/editor/ui/composer/locale/en-US/editor.properties +++ b/editor/ui/composer/locale/en-US/editor.properties @@ -148,3 +148,4 @@ RemoveLinks=Remove Links StopLinks=Discontinue Link RemoveLinksAccesskey=n NoAltText=You should always supply alternative text for an image,\nbut you may use a space if you really don't want it. +NoAlignChar=No alignment character supppied.\nEnter a single character or\nselect a different alignment style. \ No newline at end of file diff --git a/editor/ui/dialogs/content/EdAECSSAttributes.js b/editor/ui/dialogs/content/EdAECSSAttributes.js index 18915dea4ed5..a8032fa2f302 100644 --- a/editor/ui/dialogs/content/EdAECSSAttributes.js +++ b/editor/ui/dialogs/content/EdAECSSAttributes.js @@ -8,7 +8,7 @@ function BuildCSSAttributeTable() if(style == undefined || style == "") { dump("no style attributes to add\n"); - return false; + return; } if(style.indexOf(";") == -1) { if(style.indexOf(":") != -1) { @@ -17,7 +17,7 @@ function BuildCSSAttributeTable() if ( !AddTreeItem( name, value, "CSSATree", CSSAttrs ) ) dump("Failed to add CSS attribute: " + i + "\n"); } else - return false; + return; } nvpairs = style.split(";"); for(i = 0; i < nvpairs.length; i++) @@ -46,7 +46,7 @@ function onAddCSSAttribute( which ) return; if ( !CheckAttributeNameSimilarity( name, CSSAttrs ) ) - return false; + return; if ( AddTreeItem ( name, value, "CSSAList", CSSAttrs ) ) { dialog.AddCSSAttributeNameInput.value = ""; diff --git a/editor/ui/dialogs/content/EdAEHTMLAttributes.js b/editor/ui/dialogs/content/EdAEHTMLAttributes.js index ce25dcd8dfa9..d6f4f154f27a 100644 --- a/editor/ui/dialogs/content/EdAEHTMLAttributes.js +++ b/editor/ui/dialogs/content/EdAEHTMLAttributes.js @@ -7,6 +7,7 @@ function BuildHTMLAttributeTable() { var nodeMap = element.attributes; + var i; if(nodeMap.length > 0) { for(i = 0; i < nodeMap.length; i++) { @@ -37,7 +38,7 @@ function onAddHTMLAttribute(which) return; if ( !CheckAttributeNameSimilarity( name, CSSAttrs ) ) - return false; + return; if ( AddTreeItem ( name, value, "HTMLAList", HTMLAttrs ) ) { dialog.AddHTMLAttributeNameInput.value = ""; @@ -49,6 +50,7 @@ function onAddHTMLAttribute(which) // does enabling based on any user input. function doHTMLEnabling( keycode ) { +dump("***doHTMLEnabling\n"); if(keycode == 13) { onAddHTMLAttribute(document.getElementById("AddHTMLAttribute")); return; @@ -66,18 +68,20 @@ function UpdateHTMLAttributes() { dump("===============[ Setting and Updating HTML ]===============\n"); var HTMLAList = document.getElementById("HTMLAList"); - for(var i = 0; i < HTMLAList.childNodes.length; i++) + var name; + var i; + for( i = 0; i < HTMLAList.childNodes.length; i++) { var item = HTMLAList.childNodes[i]; - var name = TrimString(item.firstChild.firstChild.getAttribute("value")); + name = TrimString(item.firstChild.firstChild.getAttribute("value")); var value = TrimString(item.firstChild.lastChild.firstChild.value); // set the attribute element.setAttribute(name,value); } // remove removed attributes - for( var i = 0; i < HTMLRAttrs.length; i++ ) + for( i = 0; i < HTMLRAttrs.length; i++ ) { - var name = HTMLRAttrs[i]; + name = HTMLRAttrs[i]; if(element.getAttribute(name)) element.removeAttribute(name); else continue; // doesn't exist, so don't bother removing it. diff --git a/editor/ui/dialogs/content/EdAEJSEAttributes.js b/editor/ui/dialogs/content/EdAEJSEAttributes.js index 8d50630577e9..ebe177d0c4d7 100644 --- a/editor/ui/dialogs/content/EdAEJSEAttributes.js +++ b/editor/ui/dialogs/content/EdAEJSEAttributes.js @@ -72,7 +72,8 @@ function UpdateJSEAttributes() { dump("===============[ Setting and Updating JSE ]===============\n"); var JSEAList = document.getElementById("JSEAList"); - for(var i = 0; i < JSEAList.childNodes.length; i++) + var i; + for( i = 0; i < JSEAList.childNodes.length; i++) { var item = JSEAList.childNodes[i]; name = TrimString(item.firstChild.firstChild.getAttribute("value")); @@ -81,7 +82,7 @@ function UpdateJSEAttributes() element.setAttribute(name,value); } // remove removed attributes - for( var i = 0; i < JSERAttrs.length; i++ ) + for( i = 0; i < JSERAttrs.length; i++ ) { var name = JSERAttrs[i]; if(element.getAttribute(name)) diff --git a/editor/ui/dialogs/content/EdAdvancedEdit.js b/editor/ui/dialogs/content/EdAdvancedEdit.js index 550f914575d7..6638412bb873 100644 --- a/editor/ui/dialogs/content/EdAdvancedEdit.js +++ b/editor/ui/dialogs/content/EdAdvancedEdit.js @@ -37,9 +37,8 @@ var HTMLAttrs = []; // html attributes var CSSAttrs = []; // css attributes var JSEAttrs = []; // js events -var HTMLRAttrs = []; // removed html attributes -var CSSRAttrs = []; // removed css attributes -var JSERAttrs = []; // removed js events +var gSelecting = false; // To prevent recursive selection +var dialog; /************** INITIALISATION && SETUP **************/ @@ -61,9 +60,6 @@ function Startup() // initialise the ok and cancel buttons doSetOKCancel(onOK, onCancel); - // load string bundle - bundle = srGetStrBundle("chrome://editor/locale/editor.properties"); - // Element to edit is passed in element = window.arguments[1]; if (!element || element == undefined) { @@ -168,81 +164,63 @@ function CheckAttributeNotRemoved( attName, attArray ) * returns : nothing * desc. : removes an attribute or attributes from the tree **/ -// Note: now changing this to remove all selected ITEMS. this makes it easier. -function doRemoveAttribute( which ) +function RemoveAttribute( treeId ) { - if(which.nodeName != "tree") { - var tree = which.parentNode; - while ( tree.nodeName != "tree" ) - { - tree = tree.parentNode; // climb up the tree one notch - } // now we are pointing at the tree element - } else - tree = which; + var tree = document.getElementById(treeId); + if (!tree) return; var kids = tree.lastChild; // treechildren element of tree - var selArray = []; - for ( var i = 0; i < tree.selectedItems.length; i++ ) + var newIndex = tree.selectedIndex; + // We only allow 1 selected item + if (tree.selectedItems.length) { - var item = tree.selectedItems[i]; - // add to array of removed items for the particular panel that is displayed - var name = item.firstChild.firstChild; + var item = tree.selectedItems[0]; + // Name is the value of the treecell + var name = item.firstChild.firstChild.getAttribute("value"); + + // remove the item from the attribute arrary switch ( tree.id ) { case "HTMLATree": - HTMLRAttrs[HTMLRAttrs.length] = TrimString(name.getAttribute("value")); -// dump("HTMLRAttrs[" + (HTMLRAttrs.length - 1) + "]: " + HTMLRAttrs[HTMLRAttrs.length-1] + "\n"); + if (newIndex >= (HTMLAttrs.length-1)) + newIndex--; + RemoveNameFromAttArray(HTMLAttrs, name); break; case "CSSATree": - CSSRAttrs[CSSRAttrs.length] = TrimString(name.getAttribute("value")); + if (newIndex >= (CSSAttrs.length-1)) + newIndex--; + RemoveNameFromAttArray(CSSAttrs, name); break; case "JSEATree": - JSERAttrs[JSERAttrs.length] = TrimString(name.getAttribute("value")); + if (newIndex >= (JSEAttrs.length-1)) + newIndex--; + RemoveNameFromAttArray(JSEAttrs, name); break; default: break; } - selArray[i] = item; - } - // need to do this in a separate loop because selectedItems is NOT STATIC and - // this causes problems. - for ( var i = 0; i < selArray.length; i++ ) - { - // remove the item - kids.removeChild ( selArray[i] ); - } -} -/** - * function : void doAddAttribute( DOMElement which ); - * parameters : DOMElement referring to element context-clicked - * returns : nothing - * desc. : focusses the add attribute "name" field in the current pane. - **/ -function doAddAttribute(which) + // Remove the item from the tree + kids.removeChild (item); + + // Reselect an item + tree.selectedIndex = newIndex; + SelectTreeItem(tree); + } +} +function RemoveNameFromAttArray(attArray, name) { - if(which.nodeName != "tree") { - var tree = which.parentNode; - while ( tree.nodeName != "tree" ) + for (var i=0; i < attArray.length; i++) + { + if (attArray[i] == name) { - tree = tree.parentNode; // climb up the tree one notch - } // now we are pointing at the tree element - } else - tree = which; - - switch(tree.id) { - case "HTMLATree": - SetTextfieldFocus(document.getElementById("AddHTMLAttributeNameInput")); - break; - case "CSSATree": - SetTextfieldFocus(document.getElementById("AddCSSAttributeNameInput")); - break; - case "JSEATree": - SetTextfieldFocus(document.getElementById("AddJSEAttributeNameInput")); - break; - default: - break; + // Remove 1 array item + attArray.splice(i,1); + break; + } } } +// NOT USED +/* function doSelect(e) { if ( TEXT_WIDGETS_DONT_SUCK && PERFORMANCE_BOOSTS ) { @@ -264,23 +242,28 @@ function doSelect(e) SetTextfieldFocus(input); } } +*/ // adds a generalised treeitem. -function AddTreeItem ( name, value, treekids, attArray, valueCaseFunc ) +function AddTreeItem ( name, value, treekidsId, attArray, valueCaseFunc ) { attArray[attArray.length] = name; - var treekids = document.getElementById ( treekids ); + var treekids = document.getElementById ( treekidsId ); var treeitem = document.createElementNS ( XUL_NS, "treeitem" ); var treerow = document.createElementNS ( XUL_NS, "treerow" ); var attrcell = document.createElementNS ( XUL_NS, "treecell" ); attrcell.setAttribute( "class", "propertylist" ); attrcell.setAttribute( "value", name.toLowerCase() ); + // Modify treerow selection to better show focus in textfield + treeitem.setAttribute( "class", "ae-selection"); + treerow.appendChild ( attrcell ); if ( !valueCaseFunc ) { // no handling function provided, create default cell. - var valcell = CreateCellWithField ( name, value); - treerow.appendChild ( valcell ); + var valCell = CreateCellWithField ( name, value ); + if (!valCell) return null; + treerow.appendChild ( valCell ); } else valueCaseFunc(); // run user specified function for adding content @@ -293,16 +276,56 @@ function AddTreeItem ( name, value, treekids, attArray, valueCaseFunc ) // optional parameters for initial values. function CreateCellWithField( name, value ) { - var valcell = document.createElementNS ( XUL_NS, "treecell" ); - valcell.setAttribute ( "class", "value propertylist" ); - valcell.setAttribute ( "allowevents", "true" ); + var valCell = document.createElementNS ( XUL_NS, "treecell" ); + if (!valCell) return null; + valCell.setAttribute ( "class", "value propertylist" ); + valCell.setAttribute ( "allowevents", "true" ); var valField = document.createElementNS ( XUL_NS, "textfield" ); if ( name ) valField.setAttribute ( "id", name ); + if (!valField) return null; if ( value ) valField.setAttribute ( "value", value ); valField.setAttribute ( "flex", "1" ); valField.setAttribute ( "class", "plain" ); - valcell.appendChild ( valField ); - return valcell; + //XXX JS errors (can't tell where!) are preventing this from firing + valField.setAttribute ( "onfocus", "SelectItemWithTextfield("+name+")"); + valCell.appendChild ( valField ); + return valCell; +} + +function SelectItemWithTextfield(id) +{ +dump("*** SelectItemWithTextfield\n"); + var textfield = document.getItemById(id); + if (textfield) + { + var treerow = textfield.parentNode.parentNode; + var tree = treeerow.parentNode.parentNode; + if (tree) + { + gSelecting = true; + tree.selectedItem = textfield.parentNode; + gSelecting = false; + } + } +} + +// When a "name" treecell is selected, shift focus to the textfield +function SelectTreeItem(tree) +{ + // Prevent infinite loop -- SetTextfieldFocusById triggers recursive call + if (gSelecting) return; + gSelecting = true; + if (tree && tree.selectedItems && tree.selectedItems.length) + { + // 2nd cell (value column) contains the textfield + var textfieldCell = tree.selectedItems[0].firstChild.firstChild.nextSibling; + if (textfieldCell) + { + // Select its contents and set focus + SetTextfieldFocusById(textfieldCell.firstChild.id); + } + } + gSelecting = false; } // todo: implement attribute parsing, e.g. colorpicker appending, etc. diff --git a/editor/ui/dialogs/content/EdAdvancedEdit.xul b/editor/ui/dialogs/content/EdAdvancedEdit.xul index 47995b5a014f..c7f0b66ef463 100644 --- a/editor/ui/dialogs/content/EdAdvancedEdit.xul +++ b/editor/ui/dialogs/content/EdAdvancedEdit.xul @@ -41,6 +41,7 @@ orient="vertical"> +