Difference between revisions of "JavaScript Functions and Variables"
imported>Aeric |
imported>Aeric |
||
Line 6: | Line 6: | ||
===lj_closeDialog=== | ===lj_closeDialog=== | ||
Close the current dialog. Typically used in conjunction with [[#lj_refreshCurrentTab|<tt>lj_refreshCurrentTab</tt>]]. | Close the current dialog. Typically used in conjunction with [[#lj_refreshCurrentTab|<tt>lj_refreshCurrentTab</tt>]]. | ||
;Sample Usage: | |||
{{:Javascript closeDialog Sample}} | |||
;Syntax: | ;Syntax: | ||
Line 11: | Line 14: | ||
lj_refreshCurrentTab(); | lj_refreshCurrentTab(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===lj_printRecord=== | ===lj_printRecord=== | ||
This function displays a customized print dialog for a record. Use it to set defaults, to limit the available choices, and to choose the [[Print Template]] which is used. (It is only available for {{type|}}s.) | This function displays a customized print dialog for a record. Use it to set defaults, to limit the available choices, and to choose the [[Print Template]] which is used. (It is only available for {{type|}}s.) | ||
;Sample Usage: | ;Sample Usage: | ||
Line 37: | Line 32: | ||
::; <tt><nowiki><input type='button' ...</nowiki></tt>: Define the button. (The entire string is one uninterrupted line.) | ::; <tt><nowiki><input type='button' ...</nowiki></tt>: Define the button. (The entire string is one uninterrupted line.) | ||
::; <tt>onClick=\"javascript:lj_printRecord(...</tt>: Specify the button's action | ::; <tt>onClick=\"javascript:lj_printRecord(...</tt>: Specify the button's action | ||
;Syntax: | |||
:<syntaxhighlight lang="javascript" enclose="div"> | |||
lj_printRecord('{option1}={value}&{option2}={value}&...'); | |||
</syntaxhighlight> | |||
;Parameters: | ;Parameters: | ||
Line 69: | Line 69: | ||
===lj_refreshCurrentTab=== | ===lj_refreshCurrentTab=== | ||
Refresh the current tab. Typically used in conjunction with [[#lj_closeDialog|<tt>lj_closeDialog</tt>]] | Refresh the current tab. Typically used in conjunction with [[#lj_closeDialog|<tt>lj_closeDialog</tt>]] | ||
;Sample Usage: | |||
{{:Javascript closeDialog Sample}} | |||
;Syntax: | ;Syntax: | ||
Line 74: | Line 77: | ||
lj_refreshCurrentTab(); | lj_refreshCurrentTab(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===lj_refreshTab=== | |||
Refresh a specific tab. Typically used in conjunction with [[#lj_closeDialog|<tt>lj_closeDialog</tt>]] | |||
;Sample Usage: | ;Sample Usage: | ||
{{:Javascript closeDialog Sample}} | {{:Javascript closeDialog Sample}} | ||
;Syntax: | ;Syntax: | ||
Line 85: | Line 88: | ||
{window}.lj_refreshTab(); | {window}.lj_refreshTab(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===lj_showDialog=== | ===lj_showDialog=== | ||
This function displays a JSP/HTML [[Page]] as a dialog. | This function displays a JSP/HTML [[Page]] as a dialog. | ||
;Sample Usage: | ;Sample Usage: | ||
Line 107: | Line 101: | ||
top.lj_showDialog(url,300,350,"popupdialogWithCloser","My Page Title"); | top.lj_showDialog(url,300,350,"popupdialogWithCloser","My Page Title"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
;Syntax: | |||
:<syntaxhighlight lang="javascript" enclose="div"> | |||
lj_showDialog(url,vertical_coordinate, horizontal_coordinate, "dialog style", "title"); | |||
</syntaxhighlight> | |||
:{{TBD|Are horizontal & vertical coordinates in the right order?}} | |||
;Parameters: | ;Parameters: |
Revision as of 21:21, 25 August 2011
These Javascript functions and variables are available for use in a JSP/HTML Page in the platform. They can also be used in Javascript defined for Action buttons.
Functions
lj_closeDialog
Close the current dialog. Typically used in conjunction with lj_refreshCurrentTab.
- Sample Usage
- Syntax
lj_refreshCurrentTab();
lj_printRecord
This function displays a customized print dialog for a record. Use it to set defaults, to limit the available choices, and to choose the Print Template which is used. (It is only available for Custom Objects.)
- Sample Usage
This code adds a [Custom Print] button to a Form, when placed in an On Load Form Script. In this case, the goal is restrict a user who has access to that form to a specific template. (The standard Print operation makes all templates available. A standard Action button, meanwhile, is present in every form. This code puts the button in a specific form, to restrict template access for users whose role causes it to be displayed.)
$("print_button").remove(); $("#edit_button").parent().append( "<input type='button' id='customPrint' value='Custom Print' class='lj-button fg-button ui-state-default ui-corner-all' onClick=\"javascript:lj_printRecord('default_print_layout=template&show_print_layout=no&default_print_document=jsp&default_page_orientation=landscape&default_pdf=yes&show_pdf=no&print_immediately=yes');\">" );
- How it Works
-
- $("print_button").remove()
- Remove the standard print button
- $("#edit_button").parent().append
- Finds the location of the edit button (present in every form), gets it's parent (the toolbar), and adds the new button to it.
- class='lj-button fg-button ui-state-default ui-corner-all'
- The standard CSS style elements for platform buttons.
- <input type='button' ...
- Define the button. (The entire string is one uninterrupted line.)
- onClick=\"javascript:lj_printRecord(...
- Specify the button's action
- Syntax
lj_printRecord('{option1}={value}&{option2}={value}&...');
- Parameters
Each option has two parameters: One to specify a default value, the other to determine whether it should be displayed so it can be overridden by the user.
By default, an option is always shown, unless explicitly hidden.
Parameter Description (default value in bold) default_print_document Object form or JSP/HTML [Page] show_print_document yes default_print_layout The form layout or template page to use. show_print_layout yes default_page_orientation portrait or landscape show_page_orientation yes default_pdf yes (otherwise, an HTML page is generated) show_pdf yes print_immediately no (queued, instead) show_print_immediately yes
lj_refreshCurrentTab
Refresh the current tab. Typically used in conjunction with lj_closeDialog
- Sample Usage
- Syntax
lj_refreshCurrentTab();
lj_refreshTab
Refresh a specific tab. Typically used in conjunction with lj_closeDialog
- Sample Usage
- Syntax
{window}.lj_refreshTab();
lj_showDialog
This function displays a JSP/HTML Page as a dialog.
- Sample Usage
This sample displays a page at the specified URL in a popup dialog that has a close button.
var url = "/networking/pages/MyPage.jsp?recordId="+someValue + "&returnUrl="+encodeURIComponent(lj_window_src); top.lj_showDialog(url,300,350,"popupdialogWithCloser","My Page Title");
- Syntax
lj_showDialog(url,vertical_coordinate, horizontal_coordinate, "dialog style", "title");
- __TBD: Are horizontal & vertical coordinates in the right order?__
- Parameters
All parameters are coded as strings.
Parameter Description url The URL of a JSP/HTML Page in the platform, in the form /networking/pages/SomePage.jsp with optional query parameters to pass data, in the form ?param1=abc¶m2=xyz&... vertical_coordinate Pixel location of the upper left corner, counting down from the top of the parent window. horizontal_coordinate Pixel location of the upper left corner, counting from the left side of the parent window. dialog style A string that specifies the display style - popupdialogWithCloser - Displays the page in a popup, with a close button.
- __TBD: What other styles are there?__
title Displayed in the banner of the dialog.
Variables
lj_window_src
Contains the URL of the current page. (Needs to be URL encoded when used.)
- Sample Usage
encodeURIComponent(lj_window_src)