Code view functions

 < Day Day Up > 

Code view functions include operations that are related to editing document source code (and that have subsequent impact on the Design view). The functions in this section let you add navigational controls to Code views within a split document view or the Code inspector window.

dom.formatRange()

Availability

Dreamweaver MX.

Description

Applies Dreamweaver automatic syntax formatting to a specified range of characters in the Code view, according to the settings in the Preferences > Code Format dialog box.

Arguments

 startOffset, endOffset 

  • The startOffset argument is an integer that represents the beginning of the specified range as the offset from the beginning of the document.

  • The endOffset argument is an integer that represents the end of the specified range as the offset from the beginning of the document.

Returns

Nothing.

dom.formatSelection()

Availability

Dreamweaver MX.

Description

Applies Dreamweaver automatic syntax formatting to the selected content (the same as selecting the Commands > Apply Source Formatting to Selection option) according to the settings in the Preferences > Code Format dialog box.

Arguments

None.

Returns

Nothing.

dom.getShowNoscript()

Availability

Dreamweaver MX.

Description

Gets the current state of the noscript content option (from the View > Noscript Content menu option). On by default, the noscript tag identifies page script content that can be rendered, or not (by choice), in the browser.

Arguments

None.

Returns

A Boolean value: TRue if the noscript tag content is currently rendered; false otherwise.

dom.getAutoValidationCount()

Availability

Dreamweaver MX 2004.

Description

Gets the number of errors, warnings, and information messages for the last auto-validation (also known as an inline validation) of the document. Currently only a target-browser check is performed during auto-validation (see "dom.runValidation()" on page 826).

NOTE

This function returns only the results that are currently in the results window for the document. If you want to make sure that the counts are up-to-date, you can call dom.runValidation() before calling this function.


Arguments

None.

Returns

An object with the following properties:

  • The numError property, which is the number of errors

  • The numWarning property, which is the number of warnings

  • The numInfo property, which is the number of information messages

Example

 theDom = dw.getDocumentDOM(); theDom.runValidation(); theDom.getAutoValidationCount(); 

dom.isDesignViewUpdated()

Availability

Dreamweaver 4.

Description

Determines whether the Design view and Text view content is synchronized for those Dreamweaver operations that require a valid document state.

Arguments

None.

Returns

A Boolean value: true if the Design view (WYSIWYG) is synchronized with the text in the Text view; false otherwise.

dom.isSelectionValid()

Availability

Dreamweaver 4.

Description

Determines whether a selection is valid, meaning it is currently synchronized with the Design view, or if it needs to be moved before an operation occurs.

Arguments

None.

Returns

A Boolean value: TRue if the current selection is in a valid piece of code; false if the document has not been synchronized, because the selection is not updated.

dom.setShowNoscript()

Availability

Dreamweaver MX.

Description

Sets the noscript content option on or off (the same as selecting the View > Noscript Content option). On by default, the noscript tag identifies page script content that can be rendered, or not (by choice), in the browser.

Arguments

 {bShowNoscript} 

  • The bShowNoscript argument, which is optional, is a Boolean value that indicates whether the noscript tag content should be rendered; true if the noscript tag content should be rendered, false otherwise.

Returns

Nothing.

dom.source.arrowDown()

Availability

Dreamweaver 4.

Description

Moves the insertion point down the Code view document, line by line. If content is already selected, this function extends the selection line by line.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of lines that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.arrowLeft()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the left in the current line of the Code view. If content is already selected, this function extends the selection to the left.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of characters that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.arrowRight()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the right in the current line of the Code view. If content is already selected, this function extends the selection to the right.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of characters that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected; otherwise it is not.

Returns

Nothing.

dom.source.arrowUp()

Availability

Dreamweaver 4.

Description

Moves the insertion point up the Code view document, line by line. If content is already selected, this function extends the selection line by line.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument is the number of lines that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.balanceBracesTextview()

Availability

Dreamweaver 4.

Description

This function is a Code view extension that enables parentheses balancing. You can call dom.source.balanceBracesTextview() to extend a currently highlighted selection or insertion point from the opening of the surrounding parenthetical statement to the end of the statement to balance the following characters: [], {} and (). Subsequent calls expand the selection through further levels of punctuation nesting.

Arguments

None.

Returns

Nothing.

dom.source.endOfDocument()

Availability

Dreamweaver 4.

Description

Places the insertion point at the end of the current Code view document. If content is already selected, this function extends the selection to the end of the document.

Arguments

 bShiftIsDown 

  • The bShiftIsDown argument is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.endOfLine()

Availability

Dreamweaver 4.

Description

Places the insertion point at the end of the current line. If content is already selected, this function extends the selection to the end of the current line.

Arguments

 bShiftIsDown 

  • The bShiftIsDown argument is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.endPage()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the end of the current page or to the end of the next page if the insertion point is already at the end of a page. If content is already selected, this function extends the selection page by page.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of pages that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.getCurrentLines()

Availability

Dreamweaver 4.

Description

Returns the line numbers for the specified offset locations from the beginning of the document.

Arguments

None.

Returns

The line numbers for the current selection.

dom.source.getSelection()

Description

Gets the selection in the current document, which is expressed as character offsets into the document's Code view.

Arguments

None.

Returns

A pair of integers that represent offsets from the beginning of the source document. The first integer is the opening of the selection; the second is the closing of the selection. If the two numbers are equal, the selection is an insertion point. If there is no selection in the source, both numbers are -1.

dom.source.getLineFromOffset()

Availability

Dreamweaver MX.

Description

Takes an offset into the source document.

Arguments

None.

Returns

The associated line number, or -1 if the offset is negative or past the end of the file.

dom.source.getText()

Availability

Dreamweaver 4.

Description

Returns the text string in the source between the designated offsets.

Arguments

 startOffset, endOffset 

  • The startOffset argument is an integer that represents the offset from the beginning of the document.

  • The endOffset argument is an integer that represents the end of the document.

Returns

A string that represents the text in the source code between the offsets start and end.

dom.source.getValidationErrorsForOffset()

Availability

Dreamweaver MX 2004.

Description

Returns a list of validation errors at the specified offset, or it searches from the offset for the next error. If none are found the function, it returns null.

Arguments

 offset, {searchDirection} 

  • The offset argument is a number that specifies the offset in the code for which the function will return any errors.

  • The searchDirection argument, which is optional, is a string that specifies "empty", "forward" or "back". If specified, the function searches forward or back from the given offset to the next characters with errors and returns them. If not specified, the function simply checks for errors at the given offset.

Returns

An array of objects or the value null. Each object in the array has the following properties:

  • The message object is a string that contains the error message.

  • The floaterName object is a string that contains the name of the results window. You can pass this value to the showResults() or setFloaterVisibility() functions.

  • The floaterIndex object is an index of items in the floater results list.

  • The start object is the opening index of underlined code.

  • The end object is the closing index of underlined code.

    NOTE

    The returned floater indexes should not be stored because they can change frequently, such as when documents are opened or closed.


Example

The following example calls getValidationErrorsForOffset() to check for any errors at the offset of the current selection. If the function returns an error, the code calls the alert() function to display the error message to the user.

 var offset = dw.getDocumentDOM().source.getSelection()[0]; var errors = dw.getDocumentDOM().source.getValidationErrorsForOffset(offset); if ( errors && errors.length > 0 )   alert( errors[0].message ); 

dom.source.indentTextview()

Availability

Dreamweaver 4.

Description

Moves selected Code view text one tab stop to the right.

Arguments

None.

Returns

Nothing.

dom.source.insert()

Availability

Dreamweaver 4.

Description

Inserts the specified string into the source code at the specified offset from the beginning of the source file. If the offset is not greater than or equal to zero, the insertion fails and the function returns false.

Arguments

 offset, string 

  • The offset argument is the offset from the beginning of the file where the string must be inserted.

  • The string argument is the string to insert.

Returns

A Boolean value: true if successful; false otherwise.

dom.source.nextWord()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the beginning of the next word (or words, if specified) in the Code view. If content is already selected, this function extends the selection to the right.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of words that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.outdentTextview()

Availability

Dreamweaver 4.

Description

Moves selected Code view text one tab stop to the left.

Arguments

None.

Returns

Nothing.

dom.source.pageDown()

Availability

Dreamweaver 4.

Description

Moves the insertion point down the Code view document, page by page. If content is already selected, this function extends the selection page by page.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of pages that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.pageUp()

Availability

Dreamweaver 4.

Description

Moves the insertion point up the Code view document, page by page. If content is already selected, this function extends the selection page by page.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of pages that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.previousWord()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the beginning of the previous word (or words, if specified) in Code view. If content is already selected, this function extends the selection to the left.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of words that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.replaceRange()

Availability

Dreamweaver 4.

Description

Replaces the range of source text between startOffset and endOffset with string. If startOffset is greater than endOffset or if either offset is not a positive integer, it does nothing and returns false. If endOffset is greater than the number of characters in the file, it replaces the range between startOffset and the end of the file. If both startOffset and endOffset are greater than the number of characters in the file, it inserts the text at the end of the file.

Arguments

 startOffset, endOffset, string 

  • The startOffset argument is the offset that indicates the beginning of the block to replace.

  • The endOffset argument is the offset that indicates the end of the block to replace.

  • The string argument is the string to insert.

Returns

A Boolean value: TRue if successful; false otherwise.

dom.source.scrollEndFile()

Availability

Dreamweaver 4.

Description

Scrolls the Code view to the bottom of the document file without moving the insertion point.

Arguments

None.

Returns

Nothing.

dom.source.scrollLineDown()

Availability

Dreamweaver 4.

Description

Scrolls the Code view down line by line without moving the insertion point.

Arguments

 nTimes 

  • The nTimes argument is the number of lines to scroll. If nTimes is omitted, the default is 1.

Returns

Nothing.

dom.source.scrollLineUp()

Availability

Dreamweaver 4.

Description

Scrolls the Code view up line by line without moving the insertion point.

Arguments

 nTimes 

  • The nTimes argument is the number of lines to scroll. If nTimes is omitted, the default is 1.

Returns

Nothing.

dom.source.scrollPageDown()

Availability

Dreamweaver 4.

Description

Scrolls the Code view down page by page without moving the insertion point.

Arguments

 nTimes 

  • The nTimes argument is the number of pages to scroll. If nTimes is omitted, the default is 1.

Returns

Nothing.

dom.source.scrollPageUp()

Availability

Dreamweaver 4.

Description

Scrolls the Code view up page by page without moving the insertion point.

Arguments

 nTimes 

  • The nTimes argument is the number of pages to scroll. If nTimes is omitted, the default is 1.

Returns

Nothing.

dom.source.scrollTopFile()

Availability

Dreamweaver 4.

Description

Scrolls the Code view to the top of the document file without moving the insertion point.

Arguments

None.

Returns

Nothing.

dom.source.selectParentTag()

Availability

Dreamweaver 4.

Description

This function is a Code view extension that enables tag balancing. You can call dom.source.selectParentTag() to extend a currently highlighted selection or insertion point from the surrounding open tag to the closing tag. Subsequent calls extend the selection to additional surrounding tags until there are no more enclosing tags.

Arguments

None.

Returns

Nothing.

dom.source.setCurrentLine()

Availability

Dreamweaver 4.

Description

Puts the insertion point at the beginning of the specified line. If the lineNumber argument is not a positive integer, the function does nothing and returns false. It puts the insertion point at the beginning of the last line if lineNumber is larger than the number of lines in the source.

Arguments

 lineNumber 

  • The lineNumber argument is the line at the beginning of which the insertion point is placed.

Returns

A Boolean value: true if successful; false otherwise.

dom.source.startOfDocument()

Availability

Dreamweaver 4.

Description

Places the insertion point at the beginning of the Code view document. If content is already selected, this function extends the selection to the beginning of the document.

Arguments

 bShiftIsDown 

  • The bShiftIsDown argument is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.startOfLine()

Availability

Dreamweaver 4.

Description

Places the insertion point at the beginning of the current line. If content is already selected, this function extends the selection to the beginning of the current line.

Arguments

 bShiftIsDown 

  • The bShiftIsDown argument is a Boolean value that indicates whether content is being selected. If bShiftIsDown is true, the content is selected.

Returns

Nothing.

dom.source.topPage()

Availability

Dreamweaver 4.

Description

Moves the insertion point to the top of the current page or to the top of the previous page if the insertion point is already at the top of a page. If content is already selected, this function extends the selection page by page.

Arguments

 {nTimes}, {bShiftIsDown} 

  • The nTimes argument, which is optional, is the number of pages that the insertion point must move. If nTimes is omitted, the default is 1.

  • The bShiftIsDown argument, which is optional, is a Boolean value that indicates whether content is being selected. If bShiftIsDown is TRue, the content is selected.

Returns

Nothing.

dom.source.wrapSelection()

Availability

Dreamweaver 4.

Description

Inserts the text of startTag before the current selection and the text of endTag after the current selection. The function then selects the entire range between, and including, the inserted tags. If the current selection was an insertion point, then the function places the insertion point between the startTag and endTag. (startTag and endTag don't have to be tags; they can be any arbitrary text.)

Arguments

 startTag, endTag 

  • The startTag argument is the text to insert at the beginning of the selection.

  • The endTag argument is the text to insert at the end of the selection.

Returns

Nothing.

dom.synchronizeDocument()

Availability

Dreamweaver 4.

Description

Synchronizes the Design and Code views.

Arguments

None.

Returns

Nothing.

     < Day Day Up > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net