CallBackery

 view release on metacpan or  search on metacpan

lib/CallBackery/qooxdoo/callbackery/source/class/callbackery/ui/Login.js  view on Meta::CPAN

         * getElementById then returns null. That is a missed save prompt and
         * nothing more, so every step is guarded and the caller ignores the
         * outcome -- this must never come between the user and their session.
         *
         * @param username {String} the user name to offer for saving
         * @param password {String} the password to offer, may be undefined
         * @return {void}
         */
        __rememberCredentials: function(username, password) {
            try {
                var doc = this.__getIframeDocument();
                var form = doc && doc.getElementById('cbLoginForm');
                var userField = doc && doc.getElementById('cbUsername');
                var passField = doc && doc.getElementById('cbPassword');
                if (!form || !userField) {
                    this.debug('login iframe not ready, skipping the password save prompt');
                    return;
                }
                userField.value = username;
                if (password !== undefined && passField) {
                    passField.value = password;
                }
                form.submit();
            }
            catch (e) {
                this.debug('could not offer the credentials for saving: ' + e);
            }
        },

        /**
         * Handler for the login events
         *
         * @param username {String} the user name that was submitted.
         * @param password {String} the password that was submitted, may be undefined.
         * @param ret {Boolean} true if the login is ok and false if it is not ok.
         * @param exc {Exception} any error found during the login process.
         * @return {void}
         */
        __iframe: null,
        __passwdBtn: null,
        __registrationBtn: null,
        __ensureIframe: function(){
            var iframe = document.getElementById("cbLoginIframe");
            if (!iframe) {
                iframe = qx.dom.Element.create('iframe',{
                    id: "cbLoginIframe",
                    style: "width:0px;height:0px;border:0px;"
                });
                document.body.appendChild(iframe);
            }
            iframe.setAttribute('src',
                'login?nocache='+Math.round(1000000*Math.random()).toString(16));
            return iframe;
        },
        __getIframeDocument: function(){
            var iframe = this.__iframe;
            return iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
        },
        __loginHandler : function(username, password, ret, exc) {
            if (exc == null) {
                if (qx.lang.Type.isObject(ret) && ret.sessionCookie) {
                    this.__rememberCredentials(username, password);
                    this.fireDataEvent('login', ret);
                    this.close();
                }
                else {
                    var element = this.getContentElement().getDomElement();
                    var tada = {duration: 1000, keyFrames : {
                        0 :  {scale: 1, rotate: "0deg"},
                        10 : {scale: 0.9, rotate: "-3deg"},
                        20 : {scale: 0.9, rotate: "-3deg"},
                        30 : {scale: 1.1, rotate: "3deg"},
                        40 : {scale: 1.1, rotate: "-3deg"},
                        50 : {scale: 1.1, rotate: "3deg"},
                        60 : {scale: 1.1, rotate: "-3deg"},
                        70 : {scale: 1.1, rotate: "3deg"},
                        80 : {scale: 1.1, rotate: "-3deg"},
                        90 : {scale: 1.1, rotate: "3deg"},
                        100 : {scale: 1, rotate: "0deg"}
                    }};
                    qx.bom.element.Animation.animate(element,tada);
                    this.setEnabled(true);
                }
            }
            else {
                callbackery.ui.MsgBox.getInstance().exc(exc);
                this.setEnabled(true);
            }
        },
        __makeExtraButton: function(cfg,label) {
            var ul = this.tr('<span style="text-decoration: underline;">%1</span>',label);
            var button = new qx.ui.basic.Label(ul).set({
                cursor: 'pointer',
                rich: true
            });
            button.addListener('tap',function(e) {
                var popup = new callbackery.ui.Popup(cfg);
                popup.addListenerOnce('close', function(e) {
                    this.getApplicationRoot().remove(popup);
                    popup.dispose();
                    this.setModal(true);
                },this);
                this.setModal(false);
                popup.open();
            },this);
            return button;
        },
        __setMaxWidth: function() {
            let bounds = this.getApplicationRoot().getBounds();
            // make sure the window does not get larger than the screen by default ... 
            if (bounds) {
                this.setMaxWidth(bounds.width-20);
            }
        }
    }
});



( run in 1.101 second using v1.01-cache-2.11-cpan-84e82930d8c )