Adobe Extending Dreamweaver CS4 Uživatelský manuál Strana 238

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 387
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 237
232
EXTENDING DREAMWEAVER CS4
Floating panels
function selectionChanged(){
/* get the selected node */
var theDOM = dw.getDocumentDOM();
var theNode = theDOM.getSelectedNode();
/* check to see if the node is a script marker */
if (theNode.nodeType == Node.ELEMENT_NODE && ¬
theNode.tagName == "SCRIPT"){
document.layers['blanklayer'].visibility = 'hidden';
document.layers['scriptlayer'].visibility = 'visible';}
else{
document.layers['scriptlayer'].visibility = 'hidden';
document.layers['blanklayer'].visibility = 'visible';
}
}
About performance
Declaring the selectionChanged() or documentEdited() function in your custom floating panels can impact
Dreamweaver performance adversely. Consider that the
documentEdited() and selectionChanged() functions are
called after every keystroke and mouse click when Dreamweaver is idle for more than one-tenth of a second. It’s
important to use different scenarios to test your floating panel, using large documents (100 KB or more of HTML)
whenever possible, to test performance impact.
To help avoid performance penalties, use the setTimeout() function. As in the browsers, the setTimeout() function
takes two arguments: the JavaScript to be called and the amount of time in milliseconds to wait before calling it.
The setTimeout() method lets you build pauses into your processing. These pauses let the user continue interacting
with the application. You must build in these pauses explicitly because the screen freezes while scripts process, which
prevents the user from performing further edits. The pauses also prevent you from updating the interface or the
floating panel.
The following example is from a floating panel that displays information about every AP element in the document. It
uses the
setTimeout() method to pause for half a second after processing each AP element.
Zobrazit stránku 237
1 2 ... 233 234 235 236 237 238 239 240 241 242 243 ... 386 387

Komentáře k této Příručce

Žádné komentáře