Преглед изворни кода

javascript continued dojo removal / refactoring

Jason Rivard пре 4 година
родитељ
комит
29ec060982

+ 1 - 0
server/src/main/java/password/pwm/http/PwmRequestAttribute.java

@@ -35,6 +35,7 @@ public enum PwmRequestAttribute
     ModuleBean,
     ModuleBean_String,
     CspNonce,
+    BrowserInfo,
 
     FormConfiguration,
     FormInitialValues,

+ 8 - 0
server/src/main/java/password/pwm/http/servlet/ClientApiServlet.java

@@ -43,6 +43,7 @@ import password.pwm.http.PwmHttpRequestWrapper;
 import password.pwm.http.PwmRequest;
 import password.pwm.http.PwmSession;
 import password.pwm.i18n.Display;
+import password.pwm.svc.sessiontrack.UserAgentUtils;
 import password.pwm.svc.stats.EpsStatistic;
 import password.pwm.svc.stats.Statistic;
 import password.pwm.svc.stats.StatisticsManager;
@@ -72,6 +73,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -321,6 +323,12 @@ public class ClientApiServlet extends ControlledPwmServlet
         settingMap.put( "setting-displayEula", PwmConstants.ENABLE_EULA_DISPLAY );
         settingMap.put( "setting-showStrengthMeter", config.readSettingAsBoolean( PwmSetting.PASSWORD_SHOW_STRENGTH_METER ) );
 
+        {
+            final Optional<UserAgentUtils.BrowserType> optionalBrowserType = UserAgentUtils.getBrowserType( pwmRequest );
+            final String browserTypeString = optionalBrowserType.isPresent() ? optionalBrowserType.get().toString() : "other";
+            settingMap.put( "browserType", browserTypeString );
+        }
+
         {
             long idleSeconds = config.readSettingAsLong( PwmSetting.IDLE_TIMEOUT_SECONDS );
             if ( pageUrl == null || pageUrl.isEmpty() )

+ 78 - 23
server/src/main/java/password/pwm/svc/sessiontrack/UserAgentUtils.java

@@ -24,18 +24,23 @@ import com.blueconic.browscap.Capabilities;
 import com.blueconic.browscap.ParseException;
 import com.blueconic.browscap.UserAgentParser;
 import com.blueconic.browscap.UserAgentService;
+import lombok.Value;
 import password.pwm.error.ErrorInformation;
 import password.pwm.error.PwmError;
 import password.pwm.error.PwmUnrecoverableException;
 import password.pwm.http.HttpHeader;
 import password.pwm.http.PwmRequest;
+import password.pwm.http.PwmRequestAttribute;
+import password.pwm.util.java.JavaHelper;
 import password.pwm.util.java.LazySoftReference;
 import password.pwm.util.java.StringUtil;
 import password.pwm.util.java.TimeDuration;
 import password.pwm.util.logging.PwmLogger;
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.time.Instant;
+import java.util.Optional;
 
 public class UserAgentUtils
 {
@@ -43,6 +48,33 @@ public class UserAgentUtils
 
     private static final LazySoftReference<UserAgentParser> CACHED_PARSER = new LazySoftReference<>( UserAgentUtils::loadUserAgentParser );
 
+    public enum BrowserType
+    {
+        ie( "IE" ),
+        ff( "Firefox" ),
+        webkit( "Safari" ),
+        chrome( "Chrome" ),;
+
+        private final String browserCapName;
+
+        BrowserType( final String browserCapName )
+        {
+            this.browserCapName = browserCapName;
+        }
+
+        static Optional<BrowserType> forBrowserCapName( final String browserCapName )
+        {
+            for ( final BrowserType browserType : BrowserType.values() )
+            {
+                if ( browserType.browserCapName.equalsIgnoreCase( browserCapName ) )
+                {
+                    return Optional.of( browserType );
+                }
+            }
+            return Optional.empty();
+        }
+    }
+
     private static UserAgentParser loadUserAgentParser( )
     {
         try
@@ -67,39 +99,62 @@ public class UserAgentUtils
 
     public static void checkIfPreIE11( final PwmRequest pwmRequest ) throws PwmUnrecoverableException
     {
+        final Optional<BrowserInfo> optionalBrowserInfo = getBrowserInfo( pwmRequest );
+
+        if ( optionalBrowserInfo.isPresent() )
+        {
+            final BrowserInfo browserInfo = optionalBrowserInfo.get();
+            if ( BrowserType.ie == browserInfo.getBrowserType() )
+            {
+                if ( browserInfo.getMajorVersion() <= 10 && browserInfo.getMajorVersion() > -1 )
+                {
+                    final String errorMsg = "Internet Explorer version is not supported for this function.  Please use Internet Explorer 11 or higher or another web browser.";
+                    throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_UNAUTHORIZED, errorMsg ) );
+                }
+            }
+        }
+    }
+
+    public static Optional<BrowserType> getBrowserType( final PwmRequest pwmRequest )
+    {
+        final Optional<BrowserInfo> optionalBrowserInfo = getBrowserInfo( pwmRequest );
+        if ( optionalBrowserInfo.isPresent() )
+        {
+            final BrowserInfo browserInfo = optionalBrowserInfo.get();
+            return Optional.ofNullable( browserInfo.getBrowserType() );
+        }
+        return Optional.empty();
+    }
+
+    public static Optional<BrowserInfo> getBrowserInfo( final PwmRequest pwmRequest )
+    {
+        final BrowserInfo cachedBrowserInfo = ( BrowserInfo ) pwmRequest.getAttribute( PwmRequestAttribute.BrowserInfo );
+        if ( cachedBrowserInfo != null )
+        {
+            return Optional.of( cachedBrowserInfo );
+        }
         final String userAgentString = pwmRequest.readHeaderValueAsString( HttpHeader.UserAgent );
         if ( StringUtil.isEmpty( userAgentString ) )
         {
-            return;
+            return Optional.empty();
         }
 
-        boolean badBrowser = false;
-
         final UserAgentParser userAgentParser = CACHED_PARSER.get();
         final Capabilities capabilities = userAgentParser.parse( userAgentString );
         final String browser = capabilities.getBrowser();
         final String browserMajorVersion = capabilities.getBrowserMajorVersion();
+        final int intMajorVersion = JavaHelper.silentParseInt( browserMajorVersion, -1 );
+        final Optional<BrowserType> optionalBrowserType = BrowserType.forBrowserCapName( browser );
 
-        if ( "IE".equalsIgnoreCase( browser ) )
-        {
-            try
-            {
-                final int majorVersionInt = Integer.parseInt( browserMajorVersion );
-                if ( majorVersionInt <= 10 )
-                {
-                    badBrowser = true;
-                }
-            }
-            catch ( final NumberFormatException e )
-            {
-                LOGGER.error( () -> "error parsing user-agent major version" + e.getMessage(), e );
-            }
-        }
+        final BrowserInfo browserInfo = new BrowserInfo( optionalBrowserType.orElse( null ), intMajorVersion );
+        pwmRequest.setAttribute( PwmRequestAttribute.BrowserInfo, browserInfo );
+        return Optional.of( browserInfo );
+    }
 
-        if ( badBrowser )
-        {
-            final String errorMsg = "Internet Explorer version is not supported for this function.  Please use Internet Explorer 11 or higher or another web browser.";
-            throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_UNAUTHORIZED, errorMsg ) );
-        }
+    @Value
+    private static class BrowserInfo implements Serializable
+    {
+        private final BrowserType browserType;
+        private final int majorVersion;
     }
 }

+ 1 - 2
webapp/src/main/webapp/WEB-INF/jsp/configeditor.jsp

@@ -135,9 +135,8 @@
                             <input type="radio" name="radio-setting-level" value="0" id="radio-setting-level-0" />
                             <label for="radio-setting-level-0"><pwm:display key="Display_SettingFilter_Level_0" bundle="Config"/></label>
                         </div>
-
                     </div>
-                    <div style="text-align: center; display: inline-block">
+                    <div class="toggleWrapper">
                         <div class="toggle" id="radio-modified-only" >
                             <input type="radio" name="radio-modified-only" value="all" id="radio-modified-only-all" />
                             <label for="radio-modified-only-all">All Settings</label>

+ 1 - 1
webapp/src/main/webapp/WEB-INF/jsp/fragment/ldap-selector.jsp

@@ -68,7 +68,7 @@
     </select>
 </div>
 <% } %>
-<div <%=showContextSelector?"":"class=\"display-none\" "%>" id="contextSelectorWrapper">
+<div <%=showContextSelector?"":"class=\"display-none\" "%> id="contextSelectorWrapper">
     <h2 class="loginFieldLabel"><label for="<%=PwmConstants.PARAM_CONTEXT%>"><pwm:display key="Field_Location"/></label></h2>
     <div class="formFieldWrapper">
         <select name="<%=PwmConstants.PARAM_CONTEXT%>" id="<%=PwmConstants.PARAM_CONTEXT%>" class="selectfield" title="<pwm:display key="Field_Location"/>">

+ 3 - 3
webapp/src/main/webapp/WEB-INF/jsp/fragment/message.jsp

@@ -35,10 +35,10 @@
 <% final ErrorInformation requestError = (ErrorInformation)JspUtility.getAttribute(pageContext, PwmRequestAttribute.PwmErrorInfo); %>
 <% if (requestError != null) { %>
     <span id="message" class="message message-error"><pwm:ErrorMessage/></span>
-    <span id="errorCode" style="display: none"><%=requestError.getError().getErrorCode()%></span>
-    <span id="errorName" style="display: none"><%=requestError.getError().toString()%></span>
+    <span id="errorCode"><%=requestError.getError().getErrorCode()%></span>
+    <span id="errorName"><%=requestError.getError().toString()%></span>
 <% } else { %>
-    <span id="message" class="message display-none">&nbsp;</span>
+    <span id="message" class="message nodisplay">&nbsp;</span>
 <% } %>
     <div id="capslockwarning" class="display-none"><pwm:display key="Display_CapsLockIsOn"/></div>
 </div>

+ 34 - 29
webapp/src/main/webapp/public/resources/js/configmanager.js

@@ -25,22 +25,22 @@ var PWM_GLOBAL = PWM_GLOBAL || {};
 
 PWM_CONFIG.lockConfiguration=function() {
     PWM_MAIN.showConfirmDialog({text:PWM_CONFIG.showString('Confirm_LockConfig'),okAction:function(){
-        PWM_MAIN.showWaitDialog({loadFunction:function() {
-            var url = 'ConfigManager?processAction=lockConfiguration';
-            var loadFunction = function(data) {
-                if (data['error'] === true) {
-                    PWM_MAIN.closeWaitDialog();
-                    PWM_MAIN.showDialog({
-                        title: PWM_MAIN.showString('Title_Error'),
-                        text: data['errorDetail']
-                    });
-                } else {
-                    PWM_CONFIG.waitForRestart();
-                }
-            };
-            PWM_MAIN.ajaxRequest(url,loadFunction);
+            PWM_MAIN.showWaitDialog({loadFunction:function() {
+                    var url = 'ConfigManager?processAction=lockConfiguration';
+                    var loadFunction = function(data) {
+                        if (data['error'] === true) {
+                            PWM_MAIN.closeWaitDialog();
+                            PWM_MAIN.showDialog({
+                                title: PWM_MAIN.showString('Title_Error'),
+                                text: data['errorDetail']
+                            });
+                        } else {
+                            PWM_CONFIG.waitForRestart();
+                        }
+                    };
+                    PWM_MAIN.ajaxRequest(url,loadFunction);
+                }});
         }});
-    }});
 };
 
 PWM_CONFIG.waitForRestart=function(options) {
@@ -103,19 +103,19 @@ PWM_CONFIG.waitForRestart=function(options) {
 
 PWM_CONFIG.startNewConfigurationEditor=function(template) {
     PWM_MAIN.showWaitDialog({title:'Loading...',loadFunction:function(){
-        require(["dojo"],function(dojo){
-            dojo.xhrGet({
-                url:"ConfigManager?processAction=setOption&pwmFormID=" + PWM_GLOBAL['pwmFormID'] + "&getTemplate=" + template,
-                preventCache: true,
-                error: function(errorObj) {
-                    PWM_MAIN.showError("error starting configuration editor: " + errorObj);
-                },
-                load: function() {
-                    window.location = "ConfigManager?processAction=editMode&pwmFormID=" + PWM_GLOBAL['pwmFormID'] + '&mode=SETTINGS';
-                }
+            require(["dojo"],function(dojo){
+                dojo.xhrGet({
+                    url:"ConfigManager?processAction=setOption&pwmFormID=" + PWM_GLOBAL['pwmFormID'] + "&getTemplate=" + template,
+                    preventCache: true,
+                    error: function(errorObj) {
+                        PWM_MAIN.showError("error starting configuration editor: " + errorObj);
+                    },
+                    load: function() {
+                        window.location = "ConfigManager?processAction=editMode&pwmFormID=" + PWM_GLOBAL['pwmFormID'] + '&mode=SETTINGS';
+                    }
+                });
             });
-        });
-    }});
+        }});
 };
 
 PWM_CONFIG.uploadConfigDialog=function() {
@@ -332,13 +332,18 @@ PWM_CONFIG.initConfigHeader = function() {
         PWM_CONFIG.openHeaderWarningPanel();
     });
 
-    require(["dojo/dom-construct", "dojo/_base/window", "dojo/dom", "dijit/place"], function(domConstruct, win, dom, place){
-        domConstruct.create("div", { id: "header-warning-backdrop", "class":"nodisplay" }, win.body());
+    var newElement = document.createElement('div');
+    newElement.id =  "header-warning-backdrop";
+    newElement.setAttribute('class','nodisplay');
+    document.body.appendChild(newElement);
 
+    /*
+    require(["dojo/dom-construct", "dojo/_base/window", "dojo/dom", "dijit/place"], function(domConstruct, win, dom, place){
         PWM_MAIN.addEventHandler(window, "resize", function () {
             place.around(dom.byId("header-warning"), dom.byId("header-username-caret"), ["below-alt"], false);
         });
     });
+     */
 
     PWM_CONFIG.showHeaderHealth();
 

+ 133 - 199
webapp/src/main/webapp/public/resources/js/main.js

@@ -131,21 +131,12 @@ PWM_MAIN.initPage = function() {
     PWM_MAIN.applyFormAttributes();
     PWM_MAIN.initDisplayTabPreferences();
 
-    require(["dojo"], function (dojo) {
-        if (dojo.isIE) {
-            document.body.setAttribute('data-browserType','ie');
-        } else if (dojo.isFF) {
-            document.body.setAttribute('data-browserType','ff');
-        } else if (dojo.isWebKit) {
-            document.body.setAttribute('data-browserType','webkit');
-        }
-    });
+    document.body.setAttribute( 'data-browserType', PWM_GLOBAL['browserType']);
 
     PWM_MAIN.addEventHandler(document, "keypress", function (event) {
         PWM_MAIN.checkForCapsLock(event);
     });
 
-
     PWM_MAIN.doQuery('.pwm-link-print',function(element){
         PWM_MAIN.addEventHandler(element, "click", function(){ window.print(); });
     });
@@ -177,22 +168,14 @@ PWM_MAIN.initPage = function() {
 
     if (PWM_MAIN.getObject('message')) {
         PWM_GLOBAL['message_originalStyle'] = PWM_MAIN.getObject('message').style;
-        require(["dojo"], function(dojo){
-            if(dojo.isIE <= 8){
-                return;
-            }
-
-            PWM_MAIN.addEventHandler(window, "resize", function(){ PWM_MAIN.messageDivFloatHandler() });
-            PWM_MAIN.addEventHandler(window, "scroll", function(){ PWM_MAIN.messageDivFloatHandler() });
-        });
+        PWM_MAIN.addEventHandler(window, "resize", function(){ PWM_MAIN.messageDivFloatHandler() });
+        PWM_MAIN.addEventHandler(window, "scroll", function(){ PWM_MAIN.messageDivFloatHandler() });
     }
 
-    require(["dojo/domReady!"],function(){
-        if (PWM_GLOBAL['enableIdleTimeout']) {
-            PWM_MAIN.IdleTimeoutHandler.initCountDownTimer(PWM_GLOBAL['MaxInactiveInterval']);
-        }
-        PWM_MAIN.initLocaleSelectorMenu('localeSelectionMenu');
-    });
+    if (PWM_GLOBAL['enableIdleTimeout']) {
+        PWM_MAIN.IdleTimeoutHandler.initCountDownTimer(PWM_GLOBAL['MaxInactiveInterval']);
+    }
+    PWM_MAIN.initLocaleSelectorMenu('localeSelectionMenu');
 
     if (PWM_MAIN.getObject('LogoutButton')) {
         PWM_MAIN.showTooltip({
@@ -280,27 +263,32 @@ PWM_MAIN.applyFormAttributes = function() {
     });
 
     // handle html5 form attribute in JS in case browser (IE) doesn't support it.
-    require(["dojo"], function (dojo) {
-        if(dojo.isIE){
-            PWM_MAIN.doQuery("button[type=submit][form]",function(element){
-                PWM_MAIN.log('added IE event handler for submit button with form attribute ' + element.id);
-                PWM_MAIN.addEventHandler(element,'click',function(e){
-                    e.preventDefault();
-                    PWM_MAIN.log('IE event handler intercepted submit for referenced form attribute ' + element.id);
-                    var formID = element.getAttribute('form');
-                    PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject(formID));
-                });
+    if(PWM_MAIN.isIE()){
+        PWM_MAIN.doQuery("button[type=submit][form]",function(element){
+            PWM_MAIN.log('added IE event handler for submit button with form attribute ' + element.id);
+            PWM_MAIN.addEventHandler(element,'click',function(e){
+                e.preventDefault();
+                PWM_MAIN.log('IE event handler intercepted submit for referenced form attribute ' + element.id);
+                var formID = element.getAttribute('form');
+                PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject(formID));
             });
-        }
-    });
+        });
+    }
 };
 
+PWM_MAIN.isIE = function() {
+    var browserType = document.body.getAttribute('data-browserType');
+    return browserType && "ie" === browserType.toLowerCase();
+}
+
 PWM_MAIN.preloadAll = function(nextFunction) {
-    require(["dijit/Dialog"],function(){
-        if (nextFunction) {
-            nextFunction();
-        }
-    });
+    if (!PWM_MAIN.html5DialogSupport()) {
+        require(["dijit/Dialog"], function () {
+            if (nextFunction) { nextFunction(); }
+        });
+    } else {
+        if (nextFunction) { nextFunction(); }
+    }
 };
 
 PWM_MAIN.showString = function (key, options) {
@@ -454,67 +442,42 @@ PWM_MAIN.handleFormSubmit = function(form, event) {
 
 
 PWM_MAIN.checkForCapsLock = function(e) {
-    require(["dojo","dojo/_base/fx","dojo/domReady!"],function(dojo,fx){
-        var capsLockWarningElement = PWM_MAIN.getObject('capslockwarning');
-        if (capsLockWarningElement === null || capsLockWarningElement === undefined) {
-            return;
-        }
+    var capsLockWarningElement = PWM_MAIN.getObject('capslockwarning');
+    if (capsLockWarningElement === null || capsLockWarningElement === undefined) {
+        return;
+    }
 
-        var capsLockKeyDetected = false;
-        {
-            var elementTarget = null;
-            if (e.target) {
-                elementTarget = e.target;
-            } else if (e.srcElement) {
-                elementTarget = e.srcElement;
-            }
-            if (elementTarget) {
-                if (elementTarget.nodeName === 'input' || elementTarget.nodeName === 'INPUT') {
-                    var kc = e.keyCode ? e.keyCode : e.which;
-                    var sk = e.shiftKey ? e.shiftKey : ((kc === 16));
-                    if (((kc >= 65 && kc <= 90) && !sk) || ((kc >= 97 && kc <= 122) && sk)) {
-                        capsLockKeyDetected = true;
-                    }
+    var capsLockKeyDetected = false;
+    {
+        var elementTarget = null;
+        if (e.target) {
+            elementTarget = e.target;
+        } else if (e.srcElement) {
+            elementTarget = e.srcElement;
+        }
+        if (elementTarget) {
+            if (elementTarget.nodeName === 'input' || elementTarget.nodeName === 'INPUT') {
+                var kc = e.keyCode ? e.keyCode : e.which;
+                var sk = e.shiftKey ? e.shiftKey : ((kc === 16));
+                if (((kc >= 65 && kc <= 90) && !sk) || ((kc >= 97 && kc <= 122) && sk)) {
+                    capsLockKeyDetected = true;
                 }
             }
         }
+    }
 
-        var displayDuration = 5 * 1000;
-        var fadeOutArgs = { node: "capslockwarning", duration: 3 * 1000 };
-        var fadeInArgs = { node: "capslockwarning", duration: 200 };
-
-        if(dojo.isIE){
-            if (capsLockKeyDetected) {
-                PWM_MAIN.removeCssClass('capslockwarning','display-none');
-                PWM_GLOBAL['lastCapsLockErrorTime'] = (new Date().getTime());
-                setTimeout(function(){
-                    if ((new Date().getTime() - PWM_GLOBAL['lastCapsLockErrorTime'] > displayDuration)) {
-                        PWM_MAIN.addCssClass('capslockwarning','display-none');
-                    }
-                },displayDuration + 500);
-            } else {
+    var displayDuration = 5 * 1000;
+    if (capsLockKeyDetected) {
+        PWM_MAIN.removeCssClass('capslockwarning','display-none');
+        PWM_GLOBAL['lastCapsLockErrorTime'] = (new Date().getTime());
+        setTimeout(function(){
+            if ((new Date().getTime() - PWM_GLOBAL['lastCapsLockErrorTime'] > displayDuration)) {
                 PWM_MAIN.addCssClass('capslockwarning','display-none');
             }
-        } else {
-            if (capsLockKeyDetected) {
-                PWM_MAIN.removeCssClass('capslockwarning','display-none');
-                fx.fadeIn(fadeInArgs).play();
-                PWM_GLOBAL['lastCapsLockErrorTime'] = (new Date().getTime());
-                setTimeout(function(){
-                    if ((new Date().getTime() - PWM_GLOBAL['lastCapsLockErrorTime'] > displayDuration)) {
-                        dojo.fadeOut(fadeOutArgs).play();
-                        setTimeout(function(){
-                            if ((new Date().getTime() - PWM_GLOBAL['lastCapsLockErrorTime'] > displayDuration)) {
-                                PWM_MAIN.addCssClass('capslockwarning','display-none');
-                            }
-                        },5 * 1000);
-                    }
-                },displayDuration + 500);
-            } else {
-                fx.fadeOut(fadeOutArgs).play();
-            }
-        }
-    });
+        },displayDuration + 500);
+    } else {
+        PWM_MAIN.addCssClass('capslockwarning','display-none');
+    }
 };
 
 PWM_MAIN.getObject = function(name) {
@@ -526,7 +489,7 @@ PWM_MAIN.getObject = function(name) {
         return name;
     }
 
-    if (name === document) {
+    if (name === document || name === window) {
         return name;
     }
 
@@ -630,20 +593,14 @@ PWM_MAIN.showLocaleSelectionMenu = function(nextFunction, options) {
     var excludeLocales = 'excludeLocales' in options ? options['excludeLocales'] : [];
 
     var localeData = PWM_GLOBAL['localeInfo'];
-    var localeIterator = function(f) {
-        for (var iter in localeData)
-            f(iter);
-
-    };
 
     var bodyHtml = '<table class="noborder" style="width:auto;margin-right:auto;margin-left:auto;overflow-x:scroll">';
-    localeIterator(function(localeKey){
+    PWM_MAIN.JSLibrary.forEachInObject(localeData, function (localeKey, loopDisplayName) {
         if (!PWM_MAIN.JSLibrary.arrayContains(excludeLocales, localeKey)) {
-            var loopDisplayName = localeData[localeKey];
             var flagCode = PWM_GLOBAL['localeFlags'][localeKey];
             var flagUrl = PWM_GLOBAL['url-resources'] + '/webjars/famfamfam-flags/dist/png/' + flagCode + '.png';
             bodyHtml += '<tr style="cursor:pointer" id="locale-row-' + localeKey + '">';
-            bodyHtml += '<td><img src="' + flagUrl + '"/></td>';
+            bodyHtml += '<td><img alt="Flag Image" src="' + flagUrl + '"/></td>';
             bodyHtml += '<td>' + loopDisplayName + '</td>';
             bodyHtml += '</tr>';
         }
@@ -651,12 +608,12 @@ PWM_MAIN.showLocaleSelectionMenu = function(nextFunction, options) {
     bodyHtml += '</table>';
 
     PWM_MAIN.showDialog({
-        showClose:true,
-        showOk:false,
-        text:bodyHtml,
-        title:PWM_MAIN.showString('Title_LocaleSelect'),
-        loadFunction:function(){
-            localeIterator(function(localeKey) {
+        showClose: true,
+        showOk: false,
+        text: bodyHtml,
+        title: PWM_MAIN.showString('Title_LocaleSelect'),
+        loadFunction: function () {
+            PWM_MAIN.JSLibrary.forEachInObject(localeData, function (localeKey, loopDisplayName) {
                 PWM_MAIN.addEventHandler('locale-row-' + localeKey, 'click', function () {
                     PWM_MAIN.closeWaitDialog();
                     nextFunction(localeKey);
@@ -666,11 +623,9 @@ PWM_MAIN.showLocaleSelectionMenu = function(nextFunction, options) {
     });
 };
 
-
 PWM_MAIN.initLocaleSelectorMenu = function(attachNode) {
     PWM_MAIN.addEventHandler(attachNode,'click',function(){
         PWM_MAIN.showLocaleSelectionMenu(function(localeKey){
-
             PWM_MAIN.showWaitDialog({loadFunction:function(){
                     var url = PWM_GLOBAL['url-context'] + '/public/api?locale=' + localeKey;
                     PWM_MAIN.ajaxRequest(url, function(){
@@ -1004,55 +959,25 @@ PWM_MAIN.doShow = function(destClass, message, fromFloatHandler) {
         return;
     }
 
+    // clear existing status
+    PWM_MAIN.removeCssClass(messageElement,'message-info');
+    PWM_MAIN.removeCssClass(messageElement,'message-error');
+    PWM_MAIN.removeCssClass(messageElement,'message-success');
+
     if (destClass === '') {
-        require(["dojo/dom", "dojo/_base/fx"],function(dom, fx){
-            var fadeArgs = { node: "message", duration: 500 };
-            fx.fadeOut(fadeArgs).play();
-        });
+        PWM_MAIN.addCssClass(messageElement, "nodisplay")
         return;
+    } else {
+        PWM_MAIN.removeCssClass(messageElement, "nodisplay")
     }
-    messageElement.firstChild.nodeValue = message;
 
-    try {
-        messageElement.style.display = 'inherit'; // doesn't work in older ie browsers
-    } catch (e) {
-        messageElement.style.display = 'block';
-    }
+    messageElement.firstChild.nodeValue = message;
 
-    messageElement.style.opacity = '1';
-    require(["dojo","dojo/dom-style"],function(dojo,domStyle){
-        if(dojo.isIE <= 8){ // only IE7 and below
+    PWM_MAIN.addCssClass(messageElement,destClass);
 
-            messageElement.className = "message " + destClass;
-        } else {
-            try {
-                // create a temp element and place it on the page to figure out what the destination color should be
-                var tempDivElement = document.createElement('div');
-                tempDivElement.className = "message " + destClass;
-                tempDivElement.style.display = "none";
-                tempDivElement.id = "tempDivElement";
-                messageElement.appendChild(tempDivElement);
-                var destStyle = window.getComputedStyle(tempDivElement, null);
-                var destBackground = destStyle.backgroundColor;
-                var destColor = destStyle.color;
-                messageElement.removeChild(tempDivElement);
-
-                dojo.animateProperty({
-                    node:"message",
-                    duration: 500,
-                    properties: {
-                        backgroundColor: destBackground,
-                        color: destColor
-                    }
-                }).play();
-            } catch (e) {
-                messageElement.className = "message " + destClass;
-            }
-            if (!fromFloatHandler) {
-                PWM_MAIN.messageDivFloatHandler();
-            }
-        }
-    });
+    if (!fromFloatHandler) {
+        PWM_MAIN.messageDivFloatHandler();
+    }
 };
 
 PWM_MAIN.createCSSClass = function(selector, style) {
@@ -1144,6 +1069,15 @@ PWM_MAIN.createCSSClass = function(selector, style) {
 };
 
 PWM_MAIN.flashDomElement = function(flashColor,elementName,durationMS) {
+    var element = PWM_MAIN.getObject(elementName);
+    if ( element ) {
+        PWM_MAIN.addCssClass(element,'background-alert-flash');
+        setTimeout(function(){
+      //      PWM_MAIN.removeCssClass(element, 'background-alert-flash');
+        },5000)
+    }
+    /*
+
     if (!PWM_MAIN.getObject(elementName)) {
         PWM_MAIN.log('cant flash non-existing element id ' + elementName);
         return;
@@ -1158,6 +1092,7 @@ PWM_MAIN.flashDomElement = function(flashColor,elementName,durationMS) {
             properties: { backgroundColor: originalBGColor}
         }).play();
     });
+     */
 };
 
 PWM_MAIN.getRenderedStyle = function(el,styleProp) {
@@ -1204,7 +1139,7 @@ PWM_MAIN.messageDivFloatHandler = function() {
         return;
     }
 
-    if (messageObj.style.display === 'none') {
+    if (PWM_MAIN.hasCssClass('message','nodisplay')) {
         return;
     }
 
@@ -1214,16 +1149,10 @@ PWM_MAIN.messageDivFloatHandler = function() {
         PWM_GLOBAL['message_scrollToggle'] = doFloatDisplay;
 
         if (doFloatDisplay) {
-            messageObj.style.position = 'fixed';
-            messageObj.style.top = '-3px';
-            messageObj.style.left = '0';
-            messageObj.style.width = '100%';
-            messageObj.style.zIndex = "100";
-            messageObj.style.textAlign = "center";
-            messageObj.style.backgroundColor = 'black';
+            PWM_MAIN.addCssClass(messageObj,'message-scrollFloat');
             PWM_MAIN.doShow(PWM_GLOBAL['messageStatus'],messageObj.innerHTML,true);
         } else {
-            messageObj.style.cssText = '';
+            PWM_MAIN.removeCssClass(messageObj,'message-scrollFloat');
             PWM_MAIN.doShow(PWM_GLOBAL['messageStatus'],messageObj.innerHTML,true);
         }
     }
@@ -1349,6 +1278,14 @@ PWM_MAIN.JSLibrary.arrayContains = function(array,element) {
     return array.indexOf(element) > -1;
 };
 
+PWM_MAIN.JSLibrary.getAttribute = function(element,attribute) {
+    return PWM_MAIN.getObject(element).getAttribute(attribute);
+};
+
+PWM_MAIN.JSLibrary.setAttribute = function(element,attribute,value) {
+    PWM_MAIN.getObject(element).setAttribute(attribute,value);
+}
+
 PWM_MAIN.JSLibrary.removeFromArray = function(array,element) {
     for(var i = array.length - 1; i >= 0; i--) {
         if(array[i] === element) {
@@ -1521,23 +1458,21 @@ ShowHidePasswordHandler.init = function(nodeName) {
         return;
     }
 
-    require(["dojo/dom-construct", "dojo/dom-attr"], function(domConstruct, attr){
-        var defaultType = attr.get(node, "type");
-        attr.set(node, "data-originalType", defaultType);
-        attr.set(node, "data-managedByShowHidePasswordHandler","true");
+    var defaultType = PWM_MAIN.JSLibrary.getAttribute(node, "type");
+    PWM_MAIN.JSLibrary.setAttribute(node, "data-originalType", defaultType);
+    PWM_MAIN.JSLibrary.setAttribute(node, "data-managedByShowHidePasswordHandler","true");
 
-        var divElement = document.createElement('div');
-        divElement.id = eyeId;
-        divElement.onclick = function(){ShowHidePasswordHandler.toggle(nodeName)};
-        divElement.style.cursor = 'pointer';
-        divElement.style.visibility = 'hidden';
-        divElement.setAttribute('class','pwm-icon icon-showhidepassword');
-        domConstruct.place(divElement,node,'after');
+    var divElement = document.createElement('div');
+    divElement.id = eyeId;
+    divElement.onclick = function(){ShowHidePasswordHandler.toggle(nodeName)};
+    divElement.style.cursor = 'pointer';
+    divElement.style.visibility = 'hidden';
+    divElement.setAttribute('class','pwm-icon icon-showhidepassword');
+    node.parentNode.insertBefore(divElement, node.nextSibling);
 
-        ShowHidePasswordHandler.state[nodeName] = (defaultType === "password");
-        ShowHidePasswordHandler.setupTooltip(nodeName, false);
-        ShowHidePasswordHandler.addInputEvents(nodeName);
-    });
+    ShowHidePasswordHandler.state[nodeName] = (defaultType === "password");
+    ShowHidePasswordHandler.setupTooltip(nodeName, false);
+    ShowHidePasswordHandler.addInputEvents(nodeName);
 };
 
 ShowHidePasswordHandler.renderIcon = function(nodeName) {
@@ -1719,8 +1654,9 @@ PWM_MAIN.IdleTimeoutHandler.pollActivity = function() {
 
 PWM_MAIN.IdleTimeoutHandler.pingServer = function() {
     PWM_MAIN.IdleTimeoutHandler.lastPingTime = new Date();
-    var pingURL = PWM_GLOBAL['url-command'] + "?processAction=idleUpdate&time=" + new Date().getTime() + "&pwmFormID=" + PWM_GLOBAL['pwmFormID'];
-    PWM_MAIN.ajaxRequest(pingURL, function(){},{method:'POST'});
+    console.log("idle timeout ping at " + PWM_MAIN.IdleTimeoutHandler.lastPingTime.toISOString());
+    var pingURL = PWM_GLOBAL['url-command'] + "?processAction=idleUpdate&j=1";
+    PWM_MAIN.ajaxRequest(pingURL, function(){},{method:'POST',preventCache:true});
 };
 
 PWM_MAIN.IdleTimeoutHandler.calcSecondsRemaining = function() {
@@ -1757,7 +1693,6 @@ PWM_MAIN.IdleTimeoutHandler.showIdleWarning = function() {
 };
 
 PWM_MAIN.IdleTimeoutHandler.closeIdleWarning = function() {
-    PWM_MAIN.clearDijitWidget('idleDialog');
     document.title = PWM_MAIN.IdleTimeoutHandler.realWindowTitle;
     PWM_MAIN.IdleTimeoutHandler.warningDisplayed = false;
 };
@@ -2038,11 +1973,22 @@ PWM_MAIN.setStyle = function(elementID, property, value) {
 };
 
 PWM_MAIN.addCssClass = function(elementID, className) {
-    require(["dojo"], function (dojo) { dojo.addClass(elementID, className); });
+    var element = PWM_MAIN.getObject(elementID);
+    if (element) {
+        element.classList.add(className);
+    }
 };
 
 PWM_MAIN.removeCssClass = function(elementID, className) {
-    require(["dojo"], function (dojo) { dojo.removeClass(elementID, className) });
+    var element = PWM_MAIN.getObject(elementID);
+    if (element) {
+        element.classList.remove(className);
+    }
+};
+
+PWM_MAIN.hasCssClass = function(elementID, className) {
+    var element = PWM_MAIN.getObject(elementID);
+    return element && element.classList.contains(className);
 };
 
 PWM_MAIN.newWindowOpen=function(windowUrl,windowName) {
@@ -2093,24 +2039,12 @@ PWM_MAIN.submitPostAction = function(actionUrl,actionValue,additionalValues) {
 };
 
 PWM_MAIN.doQuery = function(queryString, resultFunction) {
-    require(["dojo/query"], function (query) {
-        var results = query(queryString);
-        for (var i = 0; i < results.length; i++) {
-            (function(iterator){
-                var result = results[iterator];
-                resultFunction(result)
-            })(i);
-        }
-    });
+    var results = document.querySelectorAll(queryString);
+    PWM_MAIN.JSLibrary.forEachInArray(results,resultFunction);
 };
 
 PWM_MAIN.doIfQueryHasResults = function(queryString, trueFunction) {
-    require(["dojo/query"], function (query) {
-        var results = query(queryString);
-        if (results && results.length > 0) {
-            trueFunction();
-        }
-    });
+    if (document.querySelector(queryString)) trueFunction();
 };
 
 PWM_MAIN.stopEvent = function(e) {

+ 39 - 0
webapp/src/main/webapp/public/resources/style.css

@@ -660,18 +660,56 @@ html[dir="rtl"] #header-center-right {
     width: 90%;
     background-color: inherit;
     border-radius: 3px;
+    font-size: 1.1em;
 }
 
 .message-info {
     background-color: #dae1e1;
+    transition: background-color 1s ease;
 }
 
 .message-error {
     background-color: #FFCD59;
+    transition: background-color 1s ease;
 }
 
 .message-success {
     background-color: #70cff0;
+    transition: background-color 1s ease;
+}
+
+.message-scrollFloat {
+    position: fixed;
+    top: -3px;
+    left: 0;
+    width: 100%;
+    z-index: 100;
+    text-align: center;
+    transition: all 1s ;
+    border-bottom: 10px inherit solid;
+}
+
+.background-alert-flash {
+    background-color: red !important;
+    transition: all step-end;
+    animation-name: alert-flash2;
+    animation-duration: 1s;
+    animation-iteration-count: 5;
+}
+
+@keyframes alert-flash {
+    0%   {background-color:red !important; }
+    25%  {background-color:inherit !important; }
+    50%  {background-color:red !important; }
+    75%  {background-color:inherit !important;}
+    100% {background-color:red !important;}
+}
+@keyframes alert-flash2 {
+    0%   {background-color:red; }
+    25%  {background-color:inherit;  }
+    50%  {background-color:red; }
+    75%  {background-color:inherit;}
+    100% {background-color:red;}
 }
 
 .push, #footer {
@@ -718,6 +756,7 @@ html[dir="rtl"] #header-center-right {
     margin-bottom: 2px;
     background-color: #d20734;
     border-radius: 3px;
+    animation: fadein 2s;
 }
 
 .agreementText {

+ 2 - 10
webapp/src/main/webapp/public/resources/themes/pwm/configStyle.css

@@ -637,7 +637,7 @@ select {
 
 /* TOGGLE STYLING */
 .toggle {
-    margin: 0 0 0.2rem;
+    margin: 0 0 2px;
     box-sizing: border-box;
     font-size: 0;
     display: flex;
@@ -654,7 +654,7 @@ select {
 .toggle input + label {
     color: #656565;
     margin: 0;
-    padding: 0.3em;
+    padding: 4px;
     box-sizing: border-box;
     position: relative;
     display: inline-block;
@@ -665,14 +665,6 @@ select {
     text-align: center;
     box-shadow: 0 0 0 rgba(255, 255, 255, 0);
     transition: border-color 0.15s ease-out, color 0.25s ease-out, background-color 0.15s ease-out, box-shadow 0.15s ease-out;
-    /* ADD THESE PROPERTIES TO SWITCH FROM AUTO WIDTH TO FULL WIDTH */
-    /*
-    flex: 0 0 50%;
-     display: flex;
-     justify-content: center;
-     align-items: center;
-*/
-    /* ----- */
 }
 .toggle input + label:first-of-type {
     border-radius: 6px 0 0 6px;