New Advanced Properties Editor UI. Fixes bugs 71743, 71973, 71027, 73167. Fix is shown on 71743, r=brade, sr=kin, a=asa-drivers

This commit is contained in:
cmanske%netscape.com 2001-06-13 01:04:39 +00:00
Родитель cd35552f35
Коммит a8e5c0b7bc
12 изменённых файлов: 2603 добавлений и 413 удалений

Просмотреть файл

@ -178,6 +178,7 @@ comm.jar:
content/editor/EdAECSSAttributes.js (ui/dialogs/content/EdAECSSAttributes.js)
content/editor/EdAEHTMLAttributes.js (ui/dialogs/content/EdAEHTMLAttributes.js)
content/editor/EdAEJSEAttributes.js (ui/dialogs/content/EdAEJSEAttributes.js)
content/editor/EdAEAttributes.js (ui/dialogs/content/EdAEAttributes.js)
content/editor/EdImageMap.js (ui/dialogs/content/EdImageMap.js)
content/editor/EdImageMap.xul (ui/dialogs/content/EdImageMap.xul)
content/editor/EdImageMapHotSpot.js (ui/dialogs/content/EdImageMapHotSpot.js)

Просмотреть файл

@ -159,8 +159,5 @@ RemoveLinks=Remove Links
StopLinks=Discontinue Link
#
NoAltText=It is recommended that you supply alternate text that will appear in text-only browsers, and that will appear in other browsers when an image is loading or when image loading is disabled.
NoAlignChar=No alignment character supplied.\nEnter a single character or\nselect a different alignment style.
SaveImageAs=Save Image (%NAME%)...
Add=Add
Set=Set
NoSeparatorCharacter=Please enter a single character to use for separating into columns

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,21 +1,40 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben "Count XULula" Goodger
*/
// build attribute list in tree form from element attributes
function BuildCSSAttributeTable()
{
// dump("populating CSS Attributes tree\n");
// dump(" style=\"" + element.getAttribute("style") + "\"\n");
// get the CSS declaration from DOM 2 ElementCSSInlineStyle
var style = element.style;
var style = gElement.style;
if(style == undefined)
if (style == undefined)
{
dump("Inline styles undefined\n");
return;
}
var l = style.length;
if(l == undefined || l == 0)
if (l == undefined || l == 0)
{
if (l == undefined) {
dump("Failed to query the number of inline style declarations\n");
@ -23,76 +42,135 @@ function BuildCSSAttributeTable()
return;
}
for (i = 0; i < l; i++) {
name = style.item(i);
value = style.getPropertyValue(name);
// dump(" adding property '" + name + "' with value '" + value +"'\n");
if ( !AddTreeItem( name, value, "CSSAList", CSSAttrs ) )
dump("Failed to add CSS attribute: " + i + "\n");
if (l > 0)
{
var added = false;
for (i = 0; i < l; i++)
{
name = style.item(i);
value = style.getPropertyValue(name);
AddTreeItem( name, value, "CSSAList", CSSAttrs );
}
}
return;
ClearCSSInputWidgets();
}
// add an attribute to the tree widget
function onAddCSSAttribute()
// add or select attribute in the tree widget
function onChangeCSSAttribute()
{
var which = document.getElementById("AddCSSAttribute");
if(!which || which.getAttribute ( "disabled" ) )
var name = TrimString(dialog.AddCSSAttributeNameInput.value);
if ( !name )
return;
var name = dialog.AddCSSAttributeNameInput.value;
var value = TrimString(dialog.AddCSSAttributeValueInput.value);
if(!name || !CheckAttributeNameSimilarity( name, CSSAttrs ) )
return;
if ( AddTreeItem ( name, value, "CSSAList", CSSAttrs ) ) {
dialog.AddCSSAttributeNameInput.value = "";
dialog.AddCSSAttributeValueInput.value = "";
}
dialog.AddCSSAttributeNameInput.focus();
doCSSEnabling();
// First try to update existing attribute
// If not found, add new attribute
if ( !UpdateExistingAttribute( name, value, "CSSAList" ) )
AddTreeItem( name, value, "CSSAList", CSSAttrs );
}
// does enabling based on any user input.
function doCSSEnabling()
function ClearCSSInputWidgets()
{
var name = TrimString(dialog.AddCSSAttributeNameInput.value).toLowerCase();
if( !name || !CheckAttributeNameSimilarity(name,CSSAttrs))
dialog.AddCSSAttribute.setAttribute("disabled","true");
else
dialog.AddCSSAttribute.removeAttribute("disabled");
dialog.AddCSSAttributeTree.clearItemSelection();
dialog.AddCSSAttributeNameInput.value ="";
dialog.AddCSSAttributeValueInput.value = "";
dialog.AddCSSAttributeNameInput.inputField.focus();
}
function onSelectCSSTreeItem()
{
if (!gDoOnSelectTree)
return;
var tree = dialog.AddCSSAttributeTree;
if (tree && tree.selectedItems && tree.selectedItems.length)
{
dialog.AddCSSAttributeNameInput.value = GetTreeItemAttributeStr(tree.selectedItems[0]);
dialog.AddCSSAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]);
}
}
function onInputCSSAttributeName()
{
var attName = TrimString(dialog.AddCSSAttributeNameInput.value).toLowerCase();
var newValue = "";
var existingValue = GetAndSelectExistingAttributeValue(attName, "CSSAList");
if (existingValue)
newValue = existingValue;
dialog.AddCSSAttributeValueInput.value = newValue;
}
function onInputCSSAttributeValue()
{
// Update value in the tree list
UpdateExistingAttribute( dialog.AddCSSAttributeNameInput.value,
dialog.AddCSSAttributeValueInput.value,
"CSSAList" );
}
function editCSSAttributeValue(targetCell)
{
if (IsNotTreeHeader(targetCell))
dialog.AddCSSAttributeValueInput.inputField.select();
}
function UpdateCSSAttributes()
{
dump("===============[ Setting and Updating STYLE ]===============\n");
var CSSAList = document.getElementById("CSSAList");
var styleString = "";
for(var i = 0; i < CSSAList.childNodes.length; i++)
{
var item = CSSAList.childNodes[i];
var name = TrimString(item.firstChild.firstChild.getAttribute("label"));
var value = TrimString(item.firstChild.lastChild.firstChild.value);
var name = GetTreeItemAttributeStr(item);
var value = GetTreeItemValueStr(item);
// this code allows users to be sloppy in typing in values, and enter
// things like "foo: " and "bar;". This will trim off everything after the
// respective character.
if(name.indexOf(":") != -1)
if (name.indexOf(":") != -1)
name = name.substring(0,name.lastIndexOf(":"));
if(value.indexOf(";") != -1)
if (value.indexOf(";") != -1)
value = value.substring(0,value.lastIndexOf(";"));
if(i == (CSSAList.childNodes.length - 1))
if (i == (CSSAList.childNodes.length - 1))
styleString += name + ": " + value + ";"; // last property
else
styleString += name + ": " + value + "; ";
}
dump("stylestring: ||" + styleString + "||\n");
if(styleString.length > 0) {
element.removeAttribute("style");
element.setAttribute("style",styleString); // NOTE BUG 18894!!!
} else {
if(element.getAttribute("style"))
element.removeAttribute("style");
if (styleString.length > 0)
{
gElement.removeAttribute("style");
gElement.setAttribute("style",styleString); // NOTE BUG 18894!!!
}
else if (gElement.getAttribute("style"))
gElement.removeAttribute("style");
}
function RemoveCSSAttribute()
{
var treechildren = dialog.AddCSSAttributeTree.lastChild;
// We only allow 1 selected item
if (dialog.AddCSSAttributeTree.selectedItems.length)
{
var item = dialog.AddCSSAttributeTree.selectedItems[0];
// Remove the item from the tree
// We always rebuild complete "style" string,
// so no list of "removed" items
treechildren.removeChild (item);
ClearCSSInputWidgets();
}
}
function SelectCSSTree( index )
{
gDoOnSelectTree = false;
try {
dialog.AddCSSAttributeTree.selectedIndex = index;
} catch (e) {}
gDoOnSelectTree = true;
}

Просмотреть файл

@ -1,83 +1,332 @@
/** EdAEHTMLAttributes.js
* - this file applies to the Editor Advanced Edit dialog box.
* - contains functions for creating the HTML Attributes list
**/
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben "Count XULula" Goodger
*/
function BuildHTMLAttributeNameList()
{
ClearMenulist(dialog.AddHTMLAttributeNameInput);
var elementName = gElement.localName.toLowerCase();
var attNames = gHTMLAttr[elementName];
if (attNames && attNames.length)
{
var forceOneChar = false;
var forceInteger = false;
for (var i = 0; i < attNames.length; i++)
{
var name = attNames[i];
if (name == "_core")
{
// Signal to append the common 'core' attributes.
// Note: These currently don't have any filtering
for (var j = 0; j < gCoreHTMLAttr.length; j++)
AppendStringToMenulist(dialog.AddHTMLAttributeNameInput, gCoreHTMLAttr[j]);
}
else if (name == "-")
{
// Signal for separator
var popup = dialog.AddHTMLAttributeNameInput.firstChild;
if (popup)
{
sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator");
if (sep)
popup.appendChild(sep);
}
}
else
{
// Get information about value filtering
forceOneChar = name.indexOf("!") >= 0;
forceInteger = name.indexOf("#") >= 0;
forceIntOrPercent = name.indexOf("%") >= 0;
//var required = name.indexOf("$") >= 0;
// Strip flag characters ("_" is used when attribute name is reserved JS word)
name = name.replace(/[!#%$_]/g, "");
var menuitem = AppendStringToMenulist(dialog.AddHTMLAttributeNameInput, name);
if (menuitem)
{
// Signify "required" attributes by special style
//TODO: Don't do this until next version, when we add
// explanatory text and an 'Autofill Required Attributes' button
//if (required)
// menuitem.setAttribute("class", "menuitem-highlight-1");
// Set flags to filter value input
menuitem.setAttribute("forceOneChar", forceOneChar ? "true" : "");
menuitem.setAttribute("forceInteger", forceInteger ? "true" : "");
menuitem.setAttribute("forceIntOrPercent", forceIntOrPercent ? "true" : "");
}
}
}
}
// Always start with empty input fields
ClearHTMLInputWidgets();
}
// build attribute list in tree form from element attributes
function BuildHTMLAttributeTable()
{
var nodeMap = element.attributes;
var nodeMap = gElement.attributes;
var i;
if(nodeMap.length > 0) {
if (nodeMap.length > 0)
{
var added = false;
for(i = 0; i < nodeMap.length; i++)
{
if ( !CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) ||
if ( CheckAttributeNameSimilarity( nodeMap[i].nodeName, HTMLAttrs ) ||
IsEventHandler( nodeMap[i].nodeName ) ||
TrimString( nodeMap[i].nodeName.toLowerCase() ) == "style" ) {
continue; // repeated or non-HTML attribute, ignore this one and go to next
}
var name = nodeMap[i].nodeName.toLowerCase();
var value = element.getAttribute ( nodeMap[i].nodeName );
if (name.indexOf("_moz") != 0)
AddTreeItem ( name, value, "HTMLAList", HTMLAttrs );
var value = gElement.getAttribute ( nodeMap[i].nodeName );
if ( name.indexOf("_moz") != 0 &&
AddTreeItem(name, value, "HTMLAList", HTMLAttrs) )
added = true;
}
if (added)
SelectHTMLTree(0);
}
}
// add or select an attribute in the tree widget
function onChangeHTMLAttribute()
{
var name = TrimString(dialog.AddHTMLAttributeNameInput.value);
if (!name)
return;
var value = TrimString(dialog.AddHTMLAttributeValueInput.value);
// First try to update existing attribute
// If not found, add new attribute
if ( !UpdateExistingAttribute( name, value, "HTMLAList" ) )
AddTreeItem ( name, value, "HTMLAList", HTMLAttrs );
}
function ClearHTMLInputWidgets()
{
dialog.AddHTMLAttributeTree.clearItemSelection();
dialog.AddHTMLAttributeNameInput.value ="";
dialog.AddHTMLAttributeValueInput.value = "";
dialog.AddHTMLAttributeNameInput.inputField.focus();
}
function onSelectHTMLTreeItem()
{
if (!gDoOnSelectTree)
return;
var tree = dialog.AddHTMLAttributeTree;
if (tree && tree.selectedItems && tree.selectedItems.length)
{
var inputName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase();
var selectedName = tree.selectedItems[0].firstChild.firstChild.getAttribute("label");
if (inputName == selectedName)
{
// Already editing selected name - just update the value input
dialog.AddHTMLAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]);
}
else
{
dialog.AddHTMLAttributeNameInput.value = selectedName;
// Change value input based on new selected name
onInputHTMLAttributeName();
}
}
}
// add an attribute to the tree widget
function onAddHTMLAttribute()
function onInputHTMLAttributeName()
{
var which = document.getElementById('AddHTMLAttribute');
if(!which || which.getAttribute ( "disabled" ) )
return;
var attName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase();
var name = dialog.AddHTMLAttributeNameInput.value;
var value = TrimString(dialog.AddHTMLAttributeValueInput.value);
if(!name || !CheckAttributeNameSimilarity( name, CSSAttrs ) )
return;
// Clear value widget, but prevent triggering update in tree
gUpdateTreeValue = false;
dialog.AddHTMLAttributeValueInput.value = "";
gUpdateTreeValue = true;
if ( AddTreeItem ( name, value, "HTMLAList", HTMLAttrs ) ) {
dialog.AddHTMLAttributeNameInput.value = "";
dialog.AddHTMLAttributeValueInput.value = "";
}
dialog.AddHTMLAttributeNameInput.focus();
doHTMLEnabling();
}
if (attName)
{
// Get value list for current attribute name
var valueList = gHTMLAttr[gElement.localName.toLowerCase() + "_" + attName];
// does enabling based on any user input.
function doHTMLEnabling()
{
var name = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase();
if( !name || !CheckAttributeNameSimilarity(name,HTMLAttrs)) {
dialog.AddHTMLAttribute.setAttribute("disabled","true");
} else {
dialog.AddHTMLAttribute.removeAttribute("disabled");
// Index to which widget we were using to edit the value
var deckIndex = dialog.AddHTMLAttributeValueDeck.getAttribute("index");
var newValue = "";
var listLen = 0;
if (valueList)
{
listLen = valueList.length;
if (listLen > 0)
newValue = valueList[0];
// Note: For case where "value list" is actually just
// one (default) item, don't use menulist for that
if (listLen > 1)
{
ClearMenulist(dialog.AddHTMLAttributeValueMenulist);
if (deckIndex != "1")
{
// Switch to using editable menulist
dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueMenulist;
dialog.AddHTMLAttributeValueDeck.setAttribute("index", "1");
}
// Rebuild the list
for (var i = 0; i < listLen; i++)
AppendStringToMenulist(dialog.AddHTMLAttributeValueMenulist, valueList[i]);
}
}
if (listLen <= 1 && deckIndex != "0")
{
// No list: Use textbox for input instead
dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueTextbox;
dialog.AddHTMLAttributeValueDeck.setAttribute("index", "0");
}
// If attribute already exists in tree, use associated value,
// else use default found above
var existingValue = GetAndSelectExistingAttributeValue(attName, "HTMLAList");
if (existingValue)
newValue = existingValue;
dialog.AddHTMLAttributeValueInput.value = newValue;
}
}
function onInputHTMLAttributeValue()
{
if (!gUpdateTreeValue)
return;
// Trim spaces only from left since we must allow spaces within the string
// (we always reset the input field's value below)
var value = TrimStringLeft(dialog.AddHTMLAttributeValueInput.value);
if (value)
{
// Do value filtering based on type of attribute
// (Do not use "LimitStringLength()" and "forceInteger()"
// to avoid multiple reseting of input's value and flickering)
var selectedItem = dialog.AddHTMLAttributeNameInput.selectedItem;
if (selectedItem)
{
if ( selectedItem.getAttribute("forceOneChar") == "true" &&
value.length > 1 )
value = value.slice(0, 1);
if ( selectedItem.getAttribute("forceIntOrPercent") == "true" )
{
// Allow integer with optional "%" as last character
var percent = TrimStringRight(value).slice(-1);
value = value.replace(/\D+/g,"");
if (percent == "%")
value += percent;
}
else if ( selectedItem.getAttribute("forceInteger") == "true" )
{
value = value.replace(/\D+/g,"");
}
// Update once only if it changed
if ( value != dialog.AddHTMLAttributeValueInput.value )
dialog.AddHTMLAttributeValueInput.value = value;
}
}
// Always update value in the tree list
UpdateExistingAttribute( dialog.AddHTMLAttributeNameInput.value, value, "HTMLAList" );
}
function editHTMLAttributeValue(targetCell)
{
if (IsNotTreeHeader(targetCell))
dialog.AddHTMLAttributeValueInput.inputField.select();
}
// update the object with added and removed attributes
function UpdateHTMLAttributes()
{
dump("===============[ Setting and Updating HTML ]===============\n");
var HTMLAList = document.getElementById("HTMLAList");
var name;
var i;
// remove removed attributes
for( i = 0; i < HTMLRAttrs.length; i++ )
{
name = HTMLRAttrs[i];
if(element.getAttribute(name))
element.removeAttribute(name);
else continue; // doesn't exist, so don't bother removing it.
var name = HTMLRAttrs[i];
// We can't use getAttribute to figure out if attribute already
// exists for attributes that don't require a value
// This gets the attribute NODE from the attributes NamedNodeMap
if (gElement.attributes.getNamedItem(name))
gElement.removeAttribute(name);
}
// Set added attributes
// Set added or changed attributes
for( i = 0; i < HTMLAList.childNodes.length; i++)
{
var item = HTMLAList.childNodes[i];
name = TrimString(item.firstChild.firstChild.getAttribute("label"));
var value = TrimString(item.firstChild.lastChild.firstChild.value);
// set the attribute
element.setAttribute(name,value);
gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) );
}
}
function RemoveHTMLAttribute()
{
var treechildren = dialog.AddHTMLAttributeTree.lastChild;
// We only allow 1 selected item
if (dialog.AddHTMLAttributeTree.selectedItems.length)
{
var item = dialog.AddHTMLAttributeTree.selectedItems[0];
var attr = GetTreeItemAttributeStr(item);
// remove the item from the attribute array
HTMLRAttrs[HTMLRAttrs.length] = attr;
RemoveNameFromAttArray(attr, HTMLAttrs);
// Remove the item from the tree
treechildren.removeChild(item);
// Clear inputs and selected item in tree
ClearHTMLInputWidgets();
}
}
function SelectHTMLTree( index )
{
gDoOnSelectTree = false;
try {
dialog.AddHTMLAttributeTree.selectedIndex = index;
} catch (e) {}
gDoOnSelectTree = true;
}

Просмотреть файл

@ -1,19 +1,97 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Ben "Count XULula" Goodger
*/
function BuildJSEAttributeNameList()
{
ClearMenulist(dialog.AddJSEAttributeNameList);
// Get events specific to current element
var attNames = gJSAttr[gElement.localName.toLowerCase()];
var i;
var popup;
var sep;
if (attNames && attNames.length)
{
for (i = 0; i < attNames.length; i++)
AppendStringToMenulist(dialog.AddJSEAttributeNameList, attNames[i]);
popup = dialog.AddJSEAttributeNameList.firstChild;
if (popup)
{
sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator");
if (sep)
popup.appendChild(sep);
}
}
// Always add core JS events
for (i = 0; i < gCoreJSEvents.length; i++)
{
if (gCoreJSEvents[i] == "-")
{
if (!popup)
popup = dialog.AddJSEAttributeNameList.firstChild;
sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator");
if (popup && sep)
popup.appendChild(sep);
}
else
AppendStringToMenulist(dialog.AddJSEAttributeNameList, gCoreJSEvents[i]);
}
dialog.AddJSEAttributeNameList.selectedIndex = 0;
// Use current name and value of first tree item if it exists
onSelectJSETreeItem();
dialog.AddJSEAttributeNameList.focus();
}
// build attribute list in tree form from element attributes
function BuildJSEAttributeTable()
{
var nodeMap = element.attributes;
if(nodeMap.length > 0) {
for(var i = 0; i < nodeMap.length; i++)
var nodeMap = gElement.attributes;
if (nodeMap.length > 0)
{
var added = false;
for (var i = 0; i < nodeMap.length; i++)
{
if( !CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) )
if( CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) )
continue; // repeated or non-JS handler, ignore this one and go to next
if( !IsEventHandler( nodeMap[i].nodeName ) )
continue; // attribute isn't an event handler.
var name = nodeMap[i].nodeName.toLowerCase();
var value = element.getAttribute(nodeMap[i].nodeName);
AddTreeItem( name, value, "JSEAList", JSEAttrs ); // add item to tree
var value = gElement.getAttribute(nodeMap[i].nodeName);
if (AddTreeItem( name, value, "JSEAList", JSEAttrs )) // add item to tree
added = true;
}
// Select first item
if (added)
dialog.AddJSEAttributeTree.selectedIndex = 0;
}
}
@ -22,71 +100,118 @@ function IsEventHandler( which )
{
var handlerName = which.toLowerCase();
var firstTwo = handlerName.substring(0,2);
if(firstTwo == "on")
if (firstTwo == "on")
return true;
else
return false;
}
// add an attribute to the tree widget
function onAddJSEAttribute()
function onSelectJSEAttribute()
{
var which = document.getElementById("AddJSEAttribute");
if(!which || which.getAttribute ( "disabled" ) )
if(!gDoOnSelectTree)
return;
var name = dialog.AddJSEAttributeNameInput.value;
var value = TrimString(dialog.AddJSEAttributeValueInput.value);
if( !name )
return;
if ( name.substring(0,2).toLowerCase() != "on" )
name = "on" + name; // user has entered event without "on" prefix, add it
if ( AddTreeItem( name, value, "JSEAList", JSEAttrs ) ) {
dialog.AddJSEAttributeNameInput.value = "";
dialog.AddJSEAttributeValueInput.value = "";
}
dialog.AddJSEAttributeNameInput.focus();
doJSEEnabling();
dialog.AddJSEAttributeValueInput.value =
GetAndSelectExistingAttributeValue(dialog.AddJSEAttributeNameList.label, "JSEAList");
}
// does enabling based on any user input.
function doJSEEnabling()
function onSelectJSETreeItem()
{
var name = TrimString(dialog.AddJSEAttributeNameInput.value).toLowerCase();
var tree = dialog.AddJSEAttributeTree;
if (tree && tree.selectedItems && tree.selectedItems.length)
{
var name = GetTreeItemAttributeStr(tree.selectedItems[0]);
if ( name.substring(0,2) != "on" )
name = "on" + name; // user has entered event without "on" prefix, add it
// Select attribute name in list
if (dialog.AddJSEAttributeNameList.firstChild)
{
var arr = dialog.AddJSEAttributeNameList.firstChild.getElementsByAttribute('label', name);
if (arr && arr.length)
dialog.AddJSEAttributeNameList.selectedItem = arr[0];
if( name == "on" || !CheckAttributeNameSimilarity(name, JSEAttrs))
dialog.AddJSEAttribute.setAttribute("disabled","true");
else
dialog.AddJSEAttribute.removeAttribute("disabled");
// Set value input to that in tree (no need to update this in the tree)
gUpdateTreeValue = false;
dialog.AddJSEAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]);
gUpdateTreeValue = true;
}
}
}
function onInputJSEAttributeValue()
{
if (gUpdateTreeValue)
{
var name = TrimString(dialog.AddJSEAttributeNameList.label);
var value = TrimString(dialog.AddJSEAttributeValueInput.value);
// Update value in the tree list
// Since we have a non-editable menulist,
// we MUST automatically add the event attribute if it doesn't exist
if (!UpdateExistingAttribute( name, value, "JSEAList" ))
AddTreeItem( name, value, "JSEAList", JSEAttrs );
}
}
function editJSEAttributeValue(targetCell)
{
if (IsNotTreeHeader(targetCell))
dialog.AddJSEAttributeValueInput.inputField.select();
}
function UpdateJSEAttributes()
{
dump("===============[ Setting and Updating JSE ]===============\n");
var JSEAList = document.getElementById("JSEAList");
var i;
// remove removed attributes
for( i = 0; i < JSERAttrs.length; i++ )
for (i = 0; i < JSERAttrs.length; i++)
{
var name = JSERAttrs[i];
if(element.getAttribute(name))
element.removeAttribute(name);
else continue; // doesn't exist, so don't bother removing it.
name = JSERAttrs[i];
if (gElement.getAttribute(name))
gElement.removeAttribute(name);
}
// Add events
for( i = 0; i < JSEAList.childNodes.length; i++)
for (i = 0; i < JSEAList.childNodes.length; i++)
{
var item = JSEAList.childNodes[i];
name = TrimString(item.firstChild.firstChild.getAttribute("label"));
value = TrimString(item.firstChild.lastChild.firstChild.value);
// set the event handler
element.setAttribute(name,value);
gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) );
}
}
function RemoveJSEAttribute()
{
var treechildren = dialog.AddJSEAttributeTree.lastChild;
// This differs from HTML and CSS panels:
// We reselect after removing, because there is not
// editable attribute name input, so we can't clear that
// like we do in other panels
var newIndex = dialog.AddJSEAttributeTree.selectedIndex;
// We only allow 1 selected item
if (dialog.AddJSEAttributeTree.selectedItems.length)
{
var item = dialog.AddJSEAttributeTree.selectedItems[0];
// Name is the text of the treecell
var attr = GetTreeItemAttributeStr(item);
// remove the item from the attribute array
if (newIndex >= (JSEAttrs.length-1))
newIndex--;
// remove the item from the attribute array
JSERAttrs[JSERAttrs.length] = attr;
RemoveNameFromAttArray(attr, JSEAttrs);
// Remove the item from the tree
treechildren.removeChild (item);
// Reselect an item
dialog.AddJSEAttributeTree.selectedIndex = newIndex;
}
}

Просмотреть файл

@ -21,27 +21,25 @@
* Ben "Count XULula" Goodger
*/
/************** FOR NOW **************/
const TEXT_WIDGETS_DONT_SUCK = false;
const PERFORMANCE_BOOSTS = false;
/************** NAMESPACES ***************/
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
/************** GLOBALS **************/
var tagname = null; // element.nodeName;
var element = null; // handle for the actual element
var gElement = null; // handle to actual element edited
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
/* Set false to allow changing selection in tree
without doing "onselect" handler actions
*/
var gDoOnSelectTree = true;
var gUpdateTreeValue = true;
var dialog;
/************** INITIALISATION && SETUP **************/
@ -65,32 +63,51 @@ function Startup()
doSetOKCancel(onOK, onCancel);
// Element to edit is passed in
element = window.arguments[1];
if (!element || element == undefined) {
if (!window.arguments[1])
{
dump("Advanced Edit: Element to edit not supplied\n");
window.close();
return;
}
// The actual element edited (not a copy!)
gElement = window.arguments[1];
// place the tag name in the header
var tagLabel = document.getElementById("tagLabel");
tagLabel.setAttribute("value", ("<" + element.localName + ">"));
tagLabel.setAttribute("value", ("<" + gElement.localName + ">"));
// Create dialog object to store controls for easy access
dialog = {};
dialog.AddHTMLAttributeNameInput = document.getElementById("AddHTMLAttributeNameInput");
dialog.AddHTMLAttributeValueInput = document.getElementById("AddHTMLAttributeValueInput");
dialog.AddHTMLAttribute = document.getElementById("AddHTMLAttribute");
dialog.AddCSSAttributeNameInput = document.getElementById("AddCSSAttributeNameInput");
dialog.AddCSSAttributeValueInput = document.getElementById("AddCSSAttributeValueInput");
dialog.AddCSSAttribute = document.getElementById("AddCSSAttribute");
dialog.AddJSEAttributeNameInput = document.getElementById("AddJSEAttributeNameInput");
dialog.AddJSEAttributeValueInput = document.getElementById("AddJSEAttributeValueInput");
dialog.AddJSEAttribute = document.getElementById("AddJSEAttribute");
// We use a <deck> to switch between editable menulist and textbox
dialog.AddHTMLAttributeValueDeck = document.getElementById("AddHTMLAttributeValueDeck");
dialog.AddHTMLAttributeValueMenulist = document.getElementById("AddHTMLAttributeValueMenulist");
dialog.AddHTMLAttributeValueTextbox = document.getElementById("AddHTMLAttributeValueTextbox");
dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueTextbox;
dialog.AddHTMLAttributeTree = document.getElementById("HTMLATree");
dialog.AddCSSAttributeNameInput = document.getElementById("AddCSSAttributeNameInput");
dialog.AddCSSAttributeValueInput = document.getElementById("AddCSSAttributeValueInput");
dialog.AddCSSAttributeTree = document.getElementById("CSSATree");
dialog.AddJSEAttributeNameList = document.getElementById("AddJSEAttributeNameList");
dialog.AddJSEAttributeValueInput = document.getElementById("AddJSEAttributeValueInput");
dialog.AddJSEAttributeTree = document.getElementById("JSEATree");
dialog.okButton = document.getElementById("ok");
// build the attribute trees
BuildHTMLAttributeTable();
BuildCSSAttributeTable();
BuildJSEAttributeTable();
// Build attribute name arrays for menulists
BuildJSEAttributeNameList();
// No menulists for CSS panel (yet), so just clear input fields
ClearCSSInputWidgets();
// Do this last -- sets focus to HTML Name menulist
BuildHTMLAttributeNameList();
// size the dialog properly
window.sizeToContent();
@ -106,120 +123,159 @@ function Startup()
**/
function onOK()
{
UpdateObject(); // call UpdateObject fn to update element in document
window.opener.AdvancedEditOK = true;
window.opener.globalElement = element;
// Update our gElement attributes
UpdateHTMLAttributes();
UpdateCSSAttributes();
UpdateJSEAttributes();
window.opener.AdvancedEditOK = true;
SaveWindowLocation();
return true; // do close the window
}
/**
* function : void UpdateObject ( void );
* parameters : none
* returns : none
* desc. : Updates the copy of the page object with the data set in this dialog.
**/
function UpdateObject()
{
UpdateHTMLAttributes();
UpdateCSSAttributes();
UpdateJSEAttributes();
}
/**
* function : bool CheckAttributeNameSimilarity ( string attName, array attArray );
* parameters : attribute to look for, array of current attributes
* returns : false if attribute already exists, true if it does not
* returns : true if attribute already exists, false if it does not
* desc. : checks to see if any other attributes by the same name as the arg supplied
* already exist.
**/
function CheckAttributeNameSimilarity(attName, attArray)
{
for(var i = 0; i < attArray.length; i++)
for (var i = 0; i < attArray.length; i++)
{
if(attName.toLowerCase() == attArray[i].toLowerCase())
return false;
if (attName.toLowerCase() == attArray[i].toLowerCase())
return true;
}
return true;
return false;
}
/**
* function : bool CheckAttributeNotRemoved ( string attName, array attArray );
* parameters : attribute to look for, array of deleted attributes
* returns : false if attribute already exists, true if it does not
* desc. : check to see if the attribute is in the array marked for removal
* before updating the final object
* function : bool UpdateExistingAttribute ( string attName, string attValue, string treeChildrenId );
* parameters : attribute to look for, new value, ID of <treeChildren> node in XUL tree
* returns : true if attribute already exists in tree, false if it does not
* desc. : checks to see if any other attributes by the same name as the arg supplied
* already exist while setting the associated value if different from current value
**/
function CheckAttributeNotRemoved( attName, attArray )
function UpdateExistingAttribute( attName, attValue, treeChildrenId )
{
for( var i = 0; i < attArray.length; i++ )
var treeChildren = document.getElementById(treeChildrenId);
if (!treeChildren)
return;
var name;
var i;
attName = TrimString(attName).toLowerCase();
attValue = TrimString(attValue);
for (i = 0; i < treeChildren.childNodes.length; i++)
{
if(attName.toLowerCase() == attArray[i].toLowerCase())
return false;
}
return true;
}
var item = treeChildren.childNodes[i];
name = GetTreeItemAttributeStr(item);
if (name.toLowerCase() == attName)
{
// Set the text in the "value' column treecell
SetTreeItemValueStr(item, attValue);
/**
* function : void doRemoveAttribute( DOMElement which);
* parameters : DOMElement that was context-clicked.
* returns : nothing
* desc. : removes an attribute or attributes from the tree
**/
function RemoveAttribute( treeId )
{
var tree = document.getElementById(treeId);
if (!tree) return;
// Select item just changed,
// but don't trigger the tree's onSelect handler
gDoOnSelectTree = false;
try {
treeChildren.parentNode.selectItem(item);
} catch (e) {}
gDoOnSelectTree = true;
var kids = tree.lastChild; // treechildren element of tree
var newIndex = tree.selectedIndex;
// We only allow 1 selected item
if (tree.selectedItems.length)
{
var item = tree.selectedItems[0];
// Name is the value of the treecell
var attr = TrimString(item.firstChild.firstChild.getAttribute("value"));
// remove the item from the attribute arrary
switch ( tree.id ) {
case "HTMLATree":
HTMLRAttrs[HTMLRAttrs.length] = attr;
if (newIndex >= (HTMLAttrs.length-1))
newIndex--;
RemoveNameFromAttArray(attr, HTMLAttrs);
break;
case "CSSATree":
// We write a completely new "style" string, so we don't need "remove" array
//CSSRAttrs[CSSRAttrs.length] = attr;
if (newIndex >= (CSSAttrs.length-1))
newIndex--;
RemoveNameFromAttArray(attr, CSSAttrs);
break;
case "JSEATree":
JSERAttrs[JSERAttrs.length] = attr;
if (newIndex >= (JSEAttrs.length-1))
newIndex--;
RemoveNameFromAttArray(attr, JSEAttrs);
break;
default: break;
return true;
}
// Remove the item from the tree
kids.removeChild (item);
// Reselect an item
tree.selectedIndex = newIndex;
SelectTreeItem(tree);
}
return false;
}
/**
* function : string GetAndSelectExistingAttributeValue ( string attName, string treeChildrenId );
* parameters : attribute to look for, ID of <treeChildren> node in XUL tree
* returns : value in from the tree or empty string if name not found
**/
function GetAndSelectExistingAttributeValue( attName, treeChildrenId )
{
if (!attName)
return "";
var treeChildren = document.getElementById(treeChildrenId);
var name;
var i;
for (i = 0; i < treeChildren.childNodes.length; i++)
{
var item = treeChildren.childNodes[i];
name = GetTreeItemAttributeStr(item);
if (name.toLowerCase() == attName.toLowerCase())
{
// Select item in the tree
// but don't trigger the tree's onSelect handler
gDoOnSelectTree = false;
try {
treeChildren.parentNode.selectItem(item);
} catch (e) {}
gDoOnSelectTree = true;
// Get the text in the "value' column treecell
return GetTreeItemValueStr(item);
}
}
// Attribute doesn't exist in tree, so remove selection
gDoOnSelectTree = false;
try {
treeChildren.parentNode.clearItemSelection();
} catch (e) {}
gDoOnSelectTree = true;
return "";
}
/* Tree structure:
<treeItem>
<treeRow>
<treeCell> // Name Cell
<treeCell // Value Cell
*/
function GetTreeItemAttributeStr(treeItem)
{
if (treeItem)
return TrimString(treeItem.firstChild.firstChild.getAttribute("label"));
return "";
}
function GetTreeItemValueStr(treeItem)
{
if (treeItem)
return TrimString(treeItem.firstChild.lastChild.getAttribute("label"));
return "";
}
function SetTreeItemValueStr(treeItem, value)
{
if (treeItem && GetTreeItemValueStr(treeItem) != value)
treeItem.firstChild.lastChild.setAttribute("label", value);
}
function IsNotTreeHeader(treeCell)
{
if (treeCell)
return (treeCell.parentNode.parentNode.nodeName != "treehead");
return false;
}
function RemoveNameFromAttArray(attName, attArray)
{
for (var i=0; i < attArray.length; i++)
{
if(attName.toLowerCase() == attArray[i].toLowerCase())
if (attName.toLowerCase() == attArray[i].toLowerCase())
{
// Remove 1 array item
attArray.splice(i,1);
@ -228,117 +284,34 @@ function RemoveNameFromAttArray(attName, attArray)
}
}
// NOT USED
/*
function doSelect(e)
{
if ( TEXT_WIDGETS_DONT_SUCK && PERFORMANCE_BOOSTS ) {
var cell = e.target.parentNode.lastChild;
var input = cell.firstChild;
var selitems = document.getElementsByAttribute("class","FocusSelected");
for ( var i = 0; i < selitems.length; i++ )
{
if ( selitems[i].nodeName == "input" ) {
selitems[i].removeAttribute("class","FocusSelected");
selitems[i].setAttribute("class","AttributesCell");
} else if ( selitems[i].nodeName == "treecell" )
selitems[i].removeAttribute("class","FocusSelected");
}
cell.setAttribute("class","FocusSelected");
input.setAttribute("class","FocusSelected");
SetTextboxFocus(input);
}
}
*/
// adds a generalised treeitem.
function AddTreeItem ( name, value, treekidsId, attArray, valueCaseFunc )
function AddTreeItem ( name, value, treeChildrenId, attArray )
{
attArray[attArray.length] = name;
var treekids = document.getElementById ( treekidsId );
var treeChildren = document.getElementById ( treeChildrenId );
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( "label", name );
// Modify treerow selection to better show focus in textbox
treeitem.setAttribute( "class", "ae-selection");
treerow.appendChild ( attrcell );
var attrCell = document.createElementNS ( XUL_NS, "treecell" );
attrCell.setAttribute( "class", "propertylist" );
attrCell.setAttribute( "label", name );
if ( !valueCaseFunc ) {
// no handling function provided, create default cell.
var valCell = CreateCellWithField ( name, value );
if (!valCell) return null;
treerow.appendChild ( valCell );
} else
valueCaseFunc(); // run user specified function for adding content
var valueCell = document.createElementNS ( XUL_NS, "treecell" );
valueCell.setAttribute( "class", "propertylist" );
valueCell.setAttribute( "label", value );
treerow.appendChild ( attrCell );
treerow.appendChild ( valueCell );
treeitem.appendChild ( treerow );
treekids.appendChild ( treeitem );
treeChildren.appendChild ( treeitem );
// Select item just added,
// but suppress calling the onSelect handler
gDoOnSelectTree = false;
try {
treeChildren.parentNode.selectItem(treeitem);
} catch (e) {}
gDoOnSelectTree = true;
return treeitem;
}
// creates a generic treecell with field inside.
// optional parameters for initial values.
function CreateCellWithField( name, value )
{
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, "textbox" );
if ( name ) valField.setAttribute ( "id", name );
if (!valField) return null;
if ( value ) valField.setAttribute ( "value", value );
valField.setAttribute ( "flex", "1" );
valField.setAttribute ( "class", "plain" );
valField.setAttribute ( "onfocus", "SelectItemWithTextbox(\""+name+"\")");
valField.setAttribute ( "allowevents", "true");
valCell.appendChild ( valField );
return valCell;
}
function SelectItemWithTextbox(id)
{
var textbox = document.getElementById(id);
if (textbox)
{
var treeItem = textbox.parentNode.parentNode.parentNode;
if (treeItem)
{
// Prevent SelectTreeItem() from setting selection to entire textbox
gSelecting = true;
treeItem.parentNode.parentNode.selectItem(treeItem);
gSelecting = false;
}
}
}
// When a "name" treecell is selected, shift focus to the textbox
function SelectTreeItem(tree)
{
// Prevent infinite loop -- SetTextboxFocusById triggers recursive call
if (gSelecting) return;
gSelecting = true;
if (tree && tree.selectedItems && tree.selectedItems.length)
{
// 2nd cell (value column) contains the textbox
var textboxCell = tree.selectedItems[0].firstChild.firstChild.nextSibling;
if (textboxCell)
{
// Select its contents and set focus
SetTextboxFocusById(textboxCell.firstChild.id);
}
}
gSelecting = false;
}
// todo: implement attribute parsing, e.g. colorpicker appending, etc.
function AttributeParser( name, value )
{
}

Просмотреть файл

@ -45,13 +45,14 @@
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<!-- global dialog functions -->
<script type="application/x-javascript" src="chrome://editor/content/EdAdvancedEdit.js"/>
<!-- element page functions -->
<script type="application/x-javascript" src="chrome://editor/content/EdAEHTMLAttributes.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdAECSSAttributes.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdAEJSEAttributes.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdAEAttributes.js"/>
<!-- global dialog functions -->
<script type="application/x-javascript" src="chrome://editor/content/EdAdvancedEdit.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript" src="chrome://global/content/strres.js" />
@ -78,19 +79,18 @@
<tree id="HTMLATree"
class="AttributesTree inset"
flex="1"
tooltip="aTooltip" tooltiptext="Click on item to edit value"
onselect="SelectTreeItem(this)">
<treecols>
onselect="onSelectHTMLTreeItem();"
onclick="onSelectHTMLTreeItem();"
ondblclick="editHTMLAttributeValue(event.target);">
<treecolgroup>
<treecol flex="35" width="0"/>
<splitter class="tree-splitter"/>
<treecol flex="65" width="0"/>
</treecols>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header treecell-inset-header" label="&tree.attributeHeader.label;"
tooltip="aTooltip" tooltiptext="Click on item to edit value"/>
<treecell class="treecell-header treecell-inset-header" label="&tree.valueHeader.label;"
tooltip="aTooltip" tooltiptext="Click on item to edit value"/>
<treecell class="treecell-header treecell-inset-header" label="&tree.attributeHeader.label;"/>
<treecell class="treecell-header treecell-inset-header" label="&tree.valueHeader.label;"/>
</treerow>
</treehead>
<treechildren id="HTMLAList" flex="1"/>
@ -98,28 +98,40 @@
<box valign="middle" autostretch="never" flex="1">
<text class="label" value="&editAttribute.label;"/>
<spring flex="1"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveAttribute('HTMLATree')"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveHTMLAttribute();"/>
</box>
<box orient="vertical">
<spring class="spacer"/>
<titledbox orient="vertical">
<label value="&AddHTMLAttributeLabel.label;"/>
<box autostretch="never">
<grid>
<columns>
<column flex="1"/><column flex="1"/>
</columns>
<rows>
<row valign="bottom" equalsize="always">
<text class="label" for="AddHTMLAttributeNameInput" value="&AttName.label;"/>
<textbox flex="1" id="AddHTMLAttributeNameInput" oninput="doHTMLEnabling()" onkeyup="if (event.keyCode == 13) onAddHTMLAttribute();"/>
<text class="label" for="AddHTMLAttributeValueInput" value="&AttValue.label;"/>
<textbox flex="1" id="AddHTMLAttributeValueInput" oninput="doHTMLEnabling()" onkeyup="if (event.keyCode == 13) onAddHTMLAttribute();"/>
<button class="dialog" id="AddHTMLAttribute" oncommand="onAddHTMLAttribute()" label="&AddAttributeButton.label;" disabled="true"/>
</box>
</titledbox>
</box>
</row>
<row valign="middle" equalsize="always">
<!-- Lists are built at runtime -->
<menulist id="AddHTMLAttributeNameInput" editable="true" flex="1"
oninput="onInputHTMLAttributeName();"
onchange="onChangeHTMLAttribute();"/>
<deck id="AddHTMLAttributeValueDeck" flex="1" index="0">
<textbox id="AddHTMLAttributeValueTextbox" flex="1"
oninput="onInputHTMLAttributeValue();"/>
<menulist id="AddHTMLAttributeValueMenulist" editable="true" flex="1"
oninput="onInputHTMLAttributeValue();"/>
</deck>
</row>
</rows>
</grid>
</box>
<!-- ============================================================== -->
<!-- CSS Attributes -->
<!-- ============================================================== -->
<box flex="1" orient="vertical">
<tree id="CSSATree" class="AttributesTree inset" flex="1"
onselect="SelectTreeItem(this)">
onselect="onSelectCSSTreeItem();"
onclick="onSelectCSSTreeItem();"
ondblclick="editCSSAttributeValue(event.target);">
<treecolgroup>
<treecol flex="35" width="0"/>
<splitter class="tree-splitter"/>
@ -136,28 +148,35 @@
<box valign="middle" autostretch="never" flex="1">
<text class="label" value="&editAttribute.label;"/>
<spring flex="1"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveAttribute('CSSATree')"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveCSSAttribute();"/>
</box>
<box orient="vertical">
<spring class="spacer"/>
<titledbox orient="vertical">
<label value="&AddCSSAttributeLabel.label;"/>
<box autostretch="never">
<text class="label" for="AddCSSAttributeNameInput" value="&AttName.label;"/>
<textbox flex="1" id="AddCSSAttributeNameInput" oninput="doCSSEnabling()" onkeyup="if (event.keyCode == 13) onAddCSSAttribute();"/>
<grid>
<columns>
<column flex="1"/><column flex="1"/>
</columns>
<rows>
<row valign="bottom" equalsize="always">
<text class="label" for="AddCSSAttributeNameInput" value="&AttName.label;"/>
<text class="label" for="AddCSSAttributeValueInput" value="&AttValue.label;"/>
<textbox flex="1" id="AddCSSAttributeValueInput" oninput="doCSSEnabling()" onkeyup="if (event.keyCode == 13) onAddCSSAttribute();"/>
<button class="dialog" id="AddCSSAttribute" oncommand="onAddCSSAttribute()" label="&AddAttributeButton.label;" disabled="true"/>
</box>
</titledbox>
</box>
</row>
<row valign="middle" equalsize="always">
<textbox id="AddCSSAttributeNameInput" flex="1"
oninput="onInputCSSAttributeName();"
onchange="onChangeCSSAttribute();"/>
<textbox id="AddCSSAttributeValueInput" flex="1"
oninput="onInputCSSAttributeValue();"/>
</row>
</rows>
</grid>
</box>
<!-- ============================================================== -->
<!-- JavaScript Event Handlers -->
<!-- ============================================================== -->
<box flex="1" orient="vertical">
<tree id="JSEATree" class="AttributesTree inset" flex="1"
onselect="SelectTreeItem(this)">
onselect="onSelectJSETreeItem();"
onclick="onSelectJSETreeItem();"
ondblclick="editJSEAttributeValue(event.target);">
<treecolgroup>
<treecol flex="35" width="0"/>
<splitter class="tree-splitter"/>
@ -174,23 +193,27 @@
<box valign="middle" autostretch="never" flex="1">
<text class="label" value="&editAttribute.label;"/>
<spring flex="1"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveAttribute('JSEATree')"/>
<button class="dialog" label="&removeAttribute.label;" oncommand="RemoveJSEAttribute()"/>
</box>
<box orient="vertical">
<spring class="spacer"/>
<titledbox orient="vertical">
<label value="&AddJSEAttributeLabel.label;"/>
<box autostretch="never">
<text class="label" for="AddJSEAttributeNameInput" value="&AttName.label;"/>
<textbox flex="1" id="AddJSEAttributeNameInput" oninput="doJSEEnabling()" onkeyup="if (event.keyCode == 13) onAddJSAttribute();"/>
<grid>
<columns>
<column flex="1"/><column flex="1"/>
</columns>
<rows>
<row valign="bottom" equalsize="always">
<text class="label" for="AddJSEAttributeNameList" value="&AttName.label;"/>
<text class="label" for="AddJSEAttributeValueInput" value="&AttValue.label;"/>
<textbox flex="1" id="AddJSEAttributeValueInput" oninput="doJSEEnabling()" onkeyup="if (event.keyCode == 13) onAddJSAttribute();"/>
<button class="dialog" id="AddJSEAttribute" oncommand="onAddJSEAttribute()" label="&AddAttributeButton.label;" disabled="true"/>
</box>
</titledbox>
</box>
</row>
<row valign="middle" equalsize="always">
<!-- List is built at runtime -->
<menulist id="AddJSEAttributeNameList" flex="1"
oncommand="onSelectJSEAttribute();"/>
<textbox id="AddJSEAttributeValueInput" flex="1"
oninput="onInputJSEAttributeValue();"/>
</row>
</rows>
</grid>
</box>
<!-- ============================================================== -->
</tabpanels>
</tabbox>
<spring class="spacer"/>

Просмотреть файл

@ -507,13 +507,14 @@ function AppendLabelAndValueToMenulist(menulist, labelStr, valueStr)
function ClearMenulist(menulist)
{
// There is usually not more than 1 menupopup under a menulist,
// but look for > 1 children anyway.
// Note -- this doesn't remove menuitems from the menupopop -- SHOULD WE?
// Always use "AppendStringToMenulist" so we know there's
// just one <menupopup> as 1st child of <menulist>
if (menulist) {
menulist.selectedItem = null;
while (menulist.firstChild)
menulist.removeChild(menulist.firstChild);
var popup = menulist.firstChild;
if (popup)
while (popup.firstChild)
popup.removeChild(popup.firstChild);
}
}
@ -686,10 +687,13 @@ function forceInteger(elementID)
var stringIn = editField.value;
if (stringIn && stringIn.length > 0)
{
// Strip out all nonnumeric characters
stringIn = stringIn.replace(/\D+/g,"");
if (!stringIn) stringIn = "";
// Strip out all nonnumeric characters
editField.value = stringIn;
// Write back only if changed
if (stringIn != editField.value)
editField.value = stringIn;
}
}

Просмотреть файл

@ -57,6 +57,7 @@ EdColorPicker.js
EdAECSSAttributes.js
EdAEHTMLAttributes.js
EdAEJSEAttributes.js
EdAEAttributes.js
EdImageMap.js
EdImageMap.xul
EdImageMapHotSpot.js

Просмотреть файл

@ -60,6 +60,7 @@ CHROME_CONTENT = \
.\EdAECSSAttributes.js \
.\EdAEHTMLAttributes.js \
.\EdAEJSEAttributes.js \
.\EdAEAttributes.js \
.\EdImageMap.js \
.\EdImageMap.xul \
.\EdImageMapHotSpot.js \

Просмотреть файл

@ -22,7 +22,7 @@
-->
<!ENTITY WindowTitle.label "Advanced Property Editor">
<!ENTITY AttName.label "Name: ">
<!ENTITY AttName.label "Attribute: ">
<!ENTITY AttValue.label "Value: ">
<!ENTITY currentattributesfor.label "Current attributes for: ">
<!ENTITY tree.attributeHeader.label "Attribute">
@ -31,13 +31,5 @@
<!ENTITY tabCSS.label "Inline Style">
<!ENTITY tabJSE.label "JavaScript Events">
<!-- REMOVE THIS AFTER NEW ADVANCED EDIT DIALOG IS FINISHED -->
<!ENTITY AddAttributeButton.label "Add">
<!ENTITY AddJSEAttributeLabel.label "Edit or Add a JavaScript Event Handler">
<!ENTITY AddHTMLAttributeLabel.label "Edit or Add an HTML Attribute">
<!ENTITY AddCSSAttributeLabel.label "Edit or Add a Style Attribute">
<!ENTITY editAttribute.label "Click on an item to edit its value">
<!ENTITY editAttribute.label "Click on an item above to edit its value">
<!ENTITY removeAttribute.label "Remove Attribute">
<!ENTITY newButton.label "New">