home *** CD-ROM | disk | FTP | other *** search
-
-
- //form field names:
- //Description - text field
-
- // *********** GLOBAL VARS *****************************
-
- var helpDoc = "html/204.creatingdocuments.fm23.html";
-
- // ******************** API ****************************
- function canInspectSelection(){
-
- var metaObj = getSelectedObj();
- return (metaObj.tagName && metaObj.tagName == "META" &&
- metaObj.getAttribute("name") &&
- metaObj.getAttribute("name").toLowerCase()=="description");
- }
-
- function inspectSelection(){
- var inspectorState = arguments[0],currKeyVal;
- var contentLayer = findObject("contentField");
- var contentCell = contentLayer.getElementsByTagName("TD").item(0);
- var minText= '<textarea name="Description" onBlur="setMetaTag()" '
- + 'style="width:350;height:32" rows="2" wrap="virtual"></textarea>'
- var maxText='<textarea name="Description" onBlur="setMetaTag()" '+
- 'style="width:350;height:76" rows="4" wrap="virtual"></textarea>';
- //change inspector state if needed
- //the rows=X check determines whether current state is min or max
- if (inspectorState=="min"&& (findString('rows="4"',contentCell.innerHTML)||contentCell.innerHTML=="")){
- currKeyVal = findObject("Description").value;
- contentCell.innerHTML=minText;
- findObject("Description").value = currKeyVal;
- }
- else if (inspectorState=="max" && (findString('rows="2"',contentCell.innerHTML)||contentCell.innerHTML=="")){
- currKeyVal = findObject("Description").value;
- contentCell.innerHTML=maxText;
- findObject("Description").value = currKeyVal;
- }
- if (getSelectedObj().getAttribute("content"))
- findObject("Description").value= getSelectedObj().getAttribute("content");
- else
- findObject("Description").value="";
- }
-
- function findString(stringToFind,stringToLookIn){
- if (stringToLookIn.indexOf(stringToFind)==-1)
- return false;
- return true;
- }
-
-
- // ******************** LOCAL FUNCTIONS ****************************
-
- function setMetaTag(){
- getSelectedObj().setAttribute("content",findObject("Description").value);
- }
-
-
- // ******************** GENERIC FUNCTIONS ****************************
-
-
- function findObject(objName, parentObj) {
- var i,tempObj="",found=false,curObj = "";
- var NS = (navigator.appName.indexOf("Netscape") != -1);
- if (!NS && document.all) curObj = document.all[objName]; //IE4
- else {
- parentObj = (parentObj != null)? parentObj.document : document;
- if (parentObj[objName] != null) curObj = parentObj[objName]; //at top level
- else { //if in form
- if (parentObj.forms) for (i=0; i<parentObj.forms.length; i++) { //search level for form object
- if (parentObj.forms[i][objName]) {
- curObj = parentObj.forms[i][objName];
- found = true; break;
- } }
- if (!found && NS && parentObj.layers && parentObj.layers.length > 0) {
- parentObj = parentObj.layers;
- for (i=0; i<parentObj.length; i++) { //else search for child layers
- tempObj = findObject(objName,parentObj[i]); //recurse
- if (tempObj) { curObj = tempObj; break;} //if found, done
- } } } }
- return curObj;
- }
-
- // ******************** GENERIC DOM MANIPULATION FUNCTIONS ****************************
-
- //Returns the selected object
- function getSelectedObj() {
- var selArr=dreamweaver.getSelection();
- return dreamweaver.offsetsToNode(selArr[0],selArr[1]);
- }
-