Freigeben über


Vwa.VwaControl.removeHandler Method

Letzte Änderung: Samstag, 6. August 2011

Gilt für: apps for SharePoint | SharePoint Server 2013

Entfernt einen Ereignishandler aus dem Visio Web Access-Steuerelement.

var value = VwaControl.removeHandler(String eventName, Function eventHandler)

Parameter

eventName Der Name des Ereignisses zum Entfernen eines Handlers für.

eventHandler Die Funktion JavaScript aufrufen, wenn eventName ausgelöst wird, von einem vorherigen Aufruf an die AddHandler -Methode hinzugefügt.

Rückgabewert

Void Gibt Nothing zurück.

Hinweise

Der Wert der eventName muss eine der folgenden sein:

  • diagramcomplete

  • diagramerror

  • shapemouseenter

  • shapemouseleave

  • shapeselectionchanged

Wenn Sie einen Wert, der für eventNamenicht gültig ist übergeben, wird das Visio Web Access-Steuerelement ein eventNotFound -Fehler zurückgegeben.

Weitere Informationen zum Hinzufügen eines Visio Web Access-Webparts zu einer SharePoint-Webparts-Seite finden Sie unter Customizing Visio Web Drawings in the Visio Web Access Web Part.

Beispiel

Das folgende Beispiel fügt einen Handler an die Ereignisse Vwa.shapeselectionchanged -Ereignis. Wenn das Ereignis ausgelöst wird, ruft das Codebeispiel die Hyperlinks auf die Form, die das Ereignis ausgelöst hat und zeigt diese im Inhalts-Editor-Webpart angewendet.

<script type="text/javascript">

document.write("Hyperlinks contained in this shape:");
document.write("<div id='shapelinks'></div>");

// Declare the global variables for the Visio Web Access Web Part, the active page in the Web Part,
// the shapes on the active page, and the <div> tag in the Content Editor Web Part.
var vwaControl;
var vwaPage;
var vwaShapes;
var linkList;

// Add a handler to the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
            vwaControl= new Vwa.VwaControl(getVWAWebPartID());
            vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {
    
    // Get a NodesList of all the div tags on the page. 
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;
    
    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];
        
        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to global variables and add handler functions to events.
function onDiagramComplete(){
    try{
        // Set the vwaPage and vwaShapes variables to the active page and the shapes collection on that page, respectively.
        vwaPage = vwaControl.getActivePage();
        vwaShapes = vwaPage.getShapes();
        linkList = document.getElementById("shapelinks");

        // Remove the handler from the shape selection changed event and then add it back to the event.
        vwaControl.removeHandler("shapeselectionchanged", onShapeSelectionChanged);
        vwaControl.addHandler("shapeselectionchanged", onShapeSelectionChanged);
        
    }
    catch(err){
        alert(err);
    }
}

// Get the hyperlinks from a shape when the selection changes and display them in the Content Editor Web Part.
function onShapeSelectionChanged(source, args){
    try{
        // Clear any displayed links from the Content Editor Web Part.
        linkList.innerHTML = "";

        // Get the array of hyperlinks from the selected shape.
        var vwaShape = vwaShapes.getItemById(args);
        var newURLArray = vwaShape.getHyperlinks();

        // Check to see whether the shape has any hyperlinks.
        if (newURLArray.length > 0) {
            
            // Iterate through all the links applied to the shape.
            for (var i = 0; i < newURLArray.length; i++) {
                
                // Get the anonymous object from the array.
                currLink = newURLArray[i];

                // Get the URL for the hyperlink.
                var newURL = currLink.value;
                var newLink;
                var newText;

                // Check if the link goes to another page in the drawing.
                if (newURL.indexOf("vdw") >= 0) {
                    
                    // Create a paragraph element for a link to a page.
                    newLink = document.createElement("p");

                }
                else {
                    
                    // Create a hyperlink element for a link to a web address.
                    newLink = document.createElement("a");
                    newLink.setAttribute("href", newURL);
                    newLink.setAttribute("target", "_blank");
                }

                // Check whether there is a description for the hyperlink.
                if (currLink.description) {
                    newText = document.createTextNode(currLink.description);
                }
                else {
                    newText = document.createTextNode(newURL);
                }

                // Add the link, link text, and a line break to the <div> tag in the Content Editor Web Part.
                var lineBreak = document.createElement("br");
                linkList.appendChild(newLink);
                newLink.appendChild(newText);
                linkList.appendChild(lineBreak);

            }
        }
    }
    catch(err){
          alert(err);
    }
}

</script>

Siehe auch

Referenz

Vwa.VwaControl Class

Vwa.VwaControl Class Methods

Konzepte

Vwa.VwaControl Class Events