completePageHandler
can parse the relevant content into a JSON string that the client-side js can make unambiguous sense of. So, if an OopsException is thrown, for example, that can also be returned as JSON which the js waiting on the other side of the originating ajax call can present to the user as an error because the context
variable is set as oops and the content
variable contains the error message. Likewise, if a redirect to login is made, the login form is presented and hijaxed for submission over ajax.
It uses the redirectCgiQueryHandler so it'll only work if there are no other plugins earlier in the alphabet that also use the redirectCgiQueryHandler This needs to be updated to remove the use of this deprecated handler.
%TMPL:DEF{}%
templates like content
in tags that a completePageHandler can parse out and return to the client in a JSON object. Using COVER also means that VIEW_TEMPLATES are inherently respected.
location
contains the complete url of the returned page,
head
and body
contain the respective ADDTOZONE content,
context
is the script of the returned page.
tmplp
- this refers to %TMPL:DEF{}%
templates that are parsed out when the skin template is read, i.e. common to each page. By default, content
is always returned unless it hasn't been specifically requested and another tmplp or hijax has been requested. The view.ajax.tmpl
cover also has templates that are available for request: revisions, queryparamstring, revarg
and revtitle
because these are handled by the view script only and are not part of the main rendering task.
hijax
- this refers to user defined templates that contain TML that is intended to work with the current %BASEWEB%, %BASETOPIC% etc. There is an example of this in the HijaxPluginTemplate topic. hierarchy
is used by the HierarchyBuilder application which is included in the download as a demonstration of the HijaxPlugin.
tmplp
relevant templates with the following syntax:
%TMPL:DEF{"usertmplptemplates"}% %TEMPLATE:<name1>% %TMPLP:P{<name1>}% %TEMPLATE:<name2>% %TMPLP:P{<name2>}% %TEMPLATE:<name3>% %TMPLP:P{<name3>}% ... %TMPL:END%
hijax
relevant templates just need to be wrapped in %TMPL:DEF{}%%TMPL:END%
returntemplate
is the third associated parameter. If this is set and it's not an oops
script and there's no redirect cache, the redirectCgiQueryHandler adds template=
to the url. There is a nocontent
template provided which wipes out the content
and ajaxhead
templates for performance purposes, e.g. you're saving an %ACTION{}%
to your action list topic and you only want to know that it worked, i.e. a redirect to the view
script, you don't want the core to put effort in to parsing all those actions so you use this flag.
hijax.js
javascript nohijax
class is given a hoverIntent
event so that when hovering over it with intent a small menu customised to the href of the link appears above it with options to Preview, Raw edit, Raw view, History and Create new topic. Clicking on one of these menu links triggers the request over ajax and presents the result in a jQuery UI Dialog: for each page the HijaxPlugin defines two jQuery UI Dialogs, one for oops
responses and one for all other responses (excl. login responses which always get their own dialog). The response dialog maintains a history which can be traversed via the Forward
and Back
buttons, and the page being currently viewed in the dialog can be launched to its own tab/window via the Launch
button.
Note that if the link being hovered over has parameters, then only the option to Preview is presented.
HTML select elements with the class 'userlist' are sorted into alphabetical order by default.
A slightly customised version of the jQuery Supersleight plugin is provided and used to handle png images in IE6. DOM elements with the 'nossleight' class are skipped by default.
foswiki.HijaxPlugin
object. serverAction
: can be considered almost as a 1:1 drop in replacement for the jQuery $.ajax() function in your code. It handles login, oops and validate (strikeone) responses. The arguments it accepts as part of a javascript object are: cover
parameter contains 'ajax'. If a .serialize() string is passed in, it gets objectified, checked, and rejoined into a string. To avoid the objectify step, it is recommended to use the HijaxPlugin asObject
function which takes a jQuery selection as its arguement.
oops
. The JSON object is passed as the only argument.
oops
is not always an error is Foswiki . The JSON object is passed as the only argument.
loadContent
below. Note that if a target
as well as a success
function are specified, then both are executed.
showResponse
: this is the function used by hijax
as the success action passed into serverAction
. See the description above.
showOops
: this is the function used by hijax
to present an oops
response to the user. See the description above.
loadContent
: this is the low-level function used by showResponse
and showOops
. It takes three arguments: response
can also be a string.
html
.
sortUserlists
: alphabetically sorts select elements that have the class 'userlist'.
parseURL
: this is a customisation of a function by James Padolsey. As well as exposing the usual elements of a URL in a js object it also exposes the Foswiki relevant web, topic and script.
hijax.js
file for further comments and functions. Lots of code examples can be found in the javascript of the FullCalendar and Object plugins.
This provides a random integer from the base 999999. With elements being incrementally added to a page via ajax, applications can use this as a way of having a simple unique identifier.
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available inconfigure
, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Plugin Author: | Foswiki:Main.DavidPatterson | ||||||||||||
License: | GPL (GNU General Public License) | ||||||||||||
Release: | 1.2 | ||||||||||||
Version: | 8534 (2010-08-18) | ||||||||||||
Change History: | |||||||||||||
17 Aug 2010: | problem with JQueryPlugin compatibility so moved addDefaultsToPage out of init into commonTagsHandler | ||||||||||||
06 Aug 2010: | javascript framework added to help using Foswiki over ajax, hijax.js |
||||||||||||
15 Apr 2010: | quick fix to make it work - was trying to get query params from the response object | ||||||||||||
25 Nov 2009: | initial release | ||||||||||||
Dependencies: |
|
||||||||||||
Home: | Foswiki:Extensions/HijaxPlugin | ||||||||||||
Support: | Foswiki:Support/HijaxPlugin |