]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/unload.js.uncompressed.js
1 define("dojo/_base/unload", ["./kernel", "./lang", "../on"], function(dojo
, lang
, on
){
10 // This module contains the document and window unload detection API.
12 addOnWindowUnload: function(/*Object|Function?*/ obj
, /*String|Function?*/ functionName
){
14 // registers a function to be triggered when window.onunload
17 // The first time that addOnWindowUnload is called Dojo
18 // will register a page listener to trigger your unload
19 // handler with. Note that registering these handlers may
20 // destroy "fastback" page caching in browsers that support
21 // it. Be careful trying to modify the DOM or access
22 // JavaScript properties during this phase of page unloading:
23 // they may not always be available. Consider
24 // addOnUnload() if you need to modify the DOM or do
25 // heavy JavaScript work since it fires at the equivalent of
26 // the page's "onbeforeunload" event.
28 // | unload.addOnWindowUnload(functionPointer)
29 // | unload.addOnWindowUnload(object, "functionName");
30 // | unload.addOnWindowUnload(object, function(){ /* ... */});
32 if (!dojo
.windowUnloaded
){
33 on(win
, "unload", (dojo
.windowUnloaded = function(){
35 // signal fired by impending window destruction. You may use
36 // dojo.addOnWindowUnload() to register a listener for this
37 // event. NOTE: if you wish to dojo.connect() to this method
38 // to perform page/application cleanup, be aware that this
39 // event WILL NOT fire if no handler has been registered with
40 // addOnWindowUnload(). This behavior started in Dojo 1.3.
41 // Previous versions always triggered windowUnloaded(). See
42 // addOnWindowUnload for more info.
45 on(win
, "unload", lang
.hitch(obj
, functionName
));
48 addOnUnload: function(/*Object?|Function?*/ obj
, /*String|Function?*/ functionName
){
50 // registers a function to be triggered when the page unloads.
52 // The first time that addOnUnload is called Dojo will
53 // register a page listener to trigger your unload handler
56 // In a browser environment, the functions will be triggered
57 // during the window.onbeforeunload event. Be careful of doing
58 // too much work in an unload handler. onbeforeunload can be
59 // triggered if a link to download a file is clicked, or if
60 // the link is a javascript: link. In these cases, the
61 // onbeforeunload event fires, but the document is not
62 // actually destroyed. So be careful about doing destructive
63 // operations in a dojo.addOnUnload callback.
65 // Further note that calling dojo.addOnUnload will prevent
66 // browsers from using a "fast back" cache to make page
67 // loading via back button instantaneous.
69 // | dojo.addOnUnload(functionPointer)
70 // | dojo.addOnUnload(object, "functionName")
71 // | dojo.addOnUnload(object, function(){ /* ... */});
73 on(win
, "beforeunload", lang
.hitch(obj
, functionName
));
77 dojo
.addOnWindowUnload
= unload
.addOnWindowUnload
;
78 dojo
.addOnUnload
= unload
.addOnUnload
;