MACROMEDIA DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER Spécifications Page 152

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 504
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 151
152 Insert Bar Objects
Next, decide whether to use objectTag() or insertObject() for the next function. The
Strikethrough object simply wraps the
s tag around the selected text, so it doesnt meet the
criteria for using the
insertObject() function (see “insertObject()” on page 162).
Within the
objectTag() function, use dw.getFocus() to determine whether the Code view
is the current view. If the Code view has input focus, the function should wrap the
appropriate (uppercase or lowercase) tag around the selected text. If the Design view has input
focus, the function can use
dom.applyCharacterMarkup() to assign the formatting to the
selected text. Remember that this function works only for supported tags (see
dom.applyCharacterMarkup() in the Dreamweaver API Reference). For other tags or
operations, you may need to use other API functions. After Dreamweaver applies the
formatting, it should return the insertion point (cursor) to the document without any
messages or prompting. The following procedure shows how the
objectTag() function
now reads.
To add the objectTag() function:
1. In the HEAD section of the Strikethrough.htm file, after the isDOMRequired() function,
add the following function:
function objectTag() {
// Determine if the user is in Code view.
var dom = dw.getDocumentDOM();
if (dw.getFocus() == 'textView' || dw.getFocus(true) == 'html'){
var upCaseTag = (dw.getPreferenceString("Source Format", "Tags Upper
Case", "") == 'TRUE');
// Manually wrap tags around selection.
if (upCaseTag){
dom.source.wrapSelection('<S>','</S>');
}else{
dom.source.wrapSelection('<s>','</s>');
}
// If the user is not in Code view, apply the formatting in Design
view.
}else if (dw.getFocus() == 'document'){
dom.applyCharacterMarkup("s");
}
// Just return--don't do anything else.
return;
}
2.
Save the file as Strikethrough.htm in the Configuration/Objects/Text folder.
Instead of including the JavaScript functions in the
HEAD section of the HTML file, you can
create a separate JavaScript file. This separate organization is useful for objects that contain
several functions, or functions that might be shared by other objects.
Vue de la page 151
1 2 ... 147 148 149 150 151 152 153 154 155 156 157 ... 503 504

Commentaires sur ces manuels

Pas de commentaire