MACROMEDIA DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER Manual page 350

Extending dreamweaver
Hide thumbs Also See for DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER:
Table of Contents

Advertisement

The
canInspectSelection()
Because the selection type is exact, it can return a value of
translated
HAPPY
indicates that the Property inspector is appropriate when the selection is within a locked region,
but because a document can have several locked regions, further checks must be performed to
determine if the Property inspector matches this particular locked region.
Another problem is inherent in inspecting translated content. When you call the
dom.getSelection()
source. To expand the selection properly so that the locked region (and only the locked region) is
selected, use the following technique:
var currentDOM = dw.getDocumentDOM();
var offsets = currentDOM.getSelection();
var theSelection = currentDOM.offsetsToNode(offsets[0],offsets[0]+1);
Using
offsets[0]+1
tag when you convert the offsets to a node. If you use
risk selecting the node above the lock.
After you make the selection (after ensuring that its nodeType is
inspect the
type
the following example:
if (theSelection.nodeType == node.ELEMENT_NODE && ¬
theSelection.getAttribute('type') == 'happy'){
return true;
}else{
return false
}
To populate the fields in the Property inspector for the translated tag, you must parse the value of
the
attribute. For example, if the untranslated code is
orig
inspector has a Time field, you must extract the value of the
function inspectSelection() {
var currentDOM = dw.getDocumentDOM();
var currSelection = currentDOM.getSelection();
var theObj = currentDOM.offsetsToNode¬
(curSelection[0],curSelection[0]+1);
if (theObj.nodeType != Node.ELEMENT_NODE) {
return;
}
// To convert the encoded characters back to their
// original values, use the unescape() method.
var origAtt = unescape(theObj.getAttribute("ORIG"));
// Convert the string to lower case for processing
var origAttLC = origAtt.toLowerCase();
var timeStart = origAttLC.indexOf('time="');
var timeEnd = origAttLC.indexOf('"',timeStart+6);
var timeValue = origAtt.substring(timeStart+6,timeEnd);
document.layers['timelayer'].document.timeForm.timefield.¬
value = timeValue;
}
350
Chapter 20: Data Translators
function for the untranslated
Property inspector, this function is more complicated; the keyword
function, the values that return by default are offsets into the untranslated
as the second argument ensures that you remain within the opening lock
attribute to see if the locked region matches this Property inspector, as shown in
Property inspector is simple.
HAPPY
without further analysis. For the
true
as the second argument, you
offsets[1]
node.ELEMENT_NODE
<HAPPY TIME="22">
attribute from the
TIME
*LOCKED*
), you can
and the Property
string:
orig

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Dreamweaver mx 2004

Table of Contents