home *** CD-ROM | disk | FTP | other *** search
- // *********** GLOBAL VARS *****************************
-
- var helpDoc = "html/204.creatingdocuments.fm25.html";
-
- // ******************** API ****************************
- function canInspectSelection(){
- return true;
- }
-
- //look at target
- //if in list of targets, set to list item
- //if not, add to bottom of list and set it
-
-
- function inspectSelection(){
- var frameName,counter,frameList,listLen,counter,bTargetFound=false;
- var baseObj = getSelectedObj(),targetVal;
- var hrefVal = baseObj.getAttribute("href");
- var Href = findObject("Href");
- var frameTarget = findObject("frameTarget");
- var counter=5; //add frame names to picklist after standard frame targets
- //populate frame target picklist
- frameList=getObjectRefs("NS 4.0","parent","frame"); //get list of frames
- if (frameList && frameList.length>0) { //if frames
- //if the frame has a name, add name to target picklist
- for (i=0; i<frameList.length; i++) {
- if (frameList[i].indexOf('unnamed')==-1){ //if the frame has a name
- frameName=frameList[i].substring(frameList[i].indexOf("['")+2,frameList[i].indexOf("']"));
- frameTarget.options[counter++] = new Option(frameName);
- }}}
-
- //if base target value exists and matches choice in target picklist, set it
- //otherwise, add to bottom of picklist and select it
- if (baseObj.getAttribute("target")){
- targetVal = baseObj.getAttribute("target");
- for (i=0;i<counter&&!bTargetFound;i++){ //look for existing match in frame picklist
- if (targetVal==frameTarget.options[i].text){
- frameTarget.selectedIndex=i;
- bTargetFound=true;
- }
- }
- if (!bTargetFound){ //if no match found
- //dynamically add the frame target value to bottom of picklist
- frameTarget.options[counter] = new Option(targetVal);
- frameTarget.selectedIndex = counter;
- }
- }
-
- //fill in href value
- if (hrefVal)
- Href.value = hrefVal;
- else
- Href.value = "";
-
- }
-
- // ******************** LOCAL FUNCTIONS ****************************
-
- function setBaseTag(){
- var baseObj = getSelectedObj(),Attributes;
- var Href=findObject("Href").value;
- var frameTarget=findObject("frameTarget");
- var frameIndex = frameTarget.selectedIndex
-
- if (frameIndex!=0)
- baseObj.setAttribute("target",findObject("frameTarget").options[frameIndex].text)
- else
- baseObj.removeAttribute("target");
-
- if (Href)
- baseObj.setAttribute("href",Href);
- }
-
- function browseForFile(){
- var fileName=browseForFileURL();
- if (fileName)
- findObject("Href").value=fileName;
- }
-
-
- // ******************** 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]);
- }
-
-