~divmod-dev/divmod.org/iotp-auth-2784

« back to all changes in this revision

Viewing changes to Nevow/nevow/js/Nevow/Athena/__init__.js

  • Committer: mithrandi
  • Date: 2008-10-15 14:34:46 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:16846
Fix onbeforeunload functionality in IE browsers.

Fixes #2731
Author: mithrandi
Reviewer: exarkun

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    },
56
56
 
57
57
    /**
58
 
     * Bind this page's global event handlers to a window object.
 
58
     * Construct an event handler function that dispatches to a method on
 
59
     * self.
59
60
     */
60
 
    function bindEvents(self, aWindow) {
61
 
        var evts = ['onbeforeunload', 'onkeypress'];
62
 
        for (var i = 0; i < evts.length; i++) {
63
 
            Divmod.Base.addToCallStack(
64
 
                aWindow, evts[i],
65
 
                // This mess of nested functions is the easiest way to capture
66
 
                // evts[i] and still get 'self' right in the inner function.
67
 
                // Honest!
68
 
                (function (evtName) {
69
 
                    var thunk = function (evtObj) {
70
 
                        return self[evtName](evtObj);
71
 
                    };
72
 
                    return thunk;
73
 
                })(evts[i]),
74
 
                false);
75
 
        }
 
61
    function makeHandler(self, evtName) {
 
62
        var thunk = function (evtObj) {
 
63
            return self[evtName](evtObj);
 
64
        };
 
65
        return thunk;
76
66
    },
77
67
 
78
68
    /**
1464
1454
    var self = this;
1465
1455
    var pageClass = Divmod.namedAny(pageClassName);
1466
1456
    self.page = pageClass(clientID, Nevow.Athena._createMessageDelivery);
1467
 
    self.page.bindEvents(window);
 
1457
    Divmod.Base.addToCallStack(
 
1458
        window, 'onkeypress', self.page.makeHandler('onkeypress'));
 
1459
 
1468
1460
 
1469
1461
    Divmod.Runtime.theRuntime.addLoadEvent(function transportStartup() {
 
1462
            Divmod.Runtime.theRuntime.addBeforeUnloadHandler(
 
1463
                window, self.page.makeHandler('onbeforeunload'));
1470
1464
            Divmod.debug("transport", "starting up");
1471
1465
            self.page.deliveryChannel.start();
1472
1466
            Divmod.debug("transport", "started up");