简体   繁体   English

jQuery Mobile Web应用程序中Firebase身份验证屏幕的性能奇特

[英]Odd performance with Firebase Authentication Screen in jQuery Mobile web application

I'm working on a jQuery Mobile site, utilizing Firebase Authentication. 我正在使用Firebase身份验证在jQuery Mobile网站上工作。 In my case we're using the auth tokens (with custom claims ) to restrict access to a team telephone roster. 就我而言,我们使用auth令牌(带有自定义声明 )来限制对团队电话花名册的访问。 If you aren't on the team, the node server won't offer up that content. 如果您不在团队中,则节点服务器将不会提供该内容。 The ajax call, authentication verification and server stuff all works great. ajax调用,身份验证验证和服务器内容都可以很好地工作。 What doesn't work is the appearance for first time login. 无效的是首次登录的外观。

When the website is first displayed and then the Phonelist page is selected, ( http://localhost/#phone_list ) we see this: 当首次显示该网站,然后选择“电话列表”页面时,( http://localhost/#phone_list )我们看到:

糟糕,看不到用于输入电话号码的框

The page is unusable in this form. 该页面无法以这种形式使用。 There is no place to enter a phone number. 没有可以输入电话号码的地方。

When the page is simply refreshed, the display converts to: 仅刷新页面时,显示转换为:

显示现在看起来很棒...

Obviously this is exactly how it should look. 显然,这正是它的外观。 There is a readily identifiable space for the user to enter a mobile phone number. 用户可以很容易地识别出一个输入手机号码的空间。

This is very repeatable. 这是非常可重复的。 I'm assuming this has something to do with the timing of the Javascript class entries. 我假设这与Javascript类条目的时间有关。 The enter phone number content, is all coming from a 'canned' javascript element from Google. 输入的电话号码内容全部来自Google的“罐头” javascript元素。

When I inspect the key elements in Chrome dev tools, I see... 当我检查Chrome开发工具中的关键元素时,我看到...

Problem display: 问题显示:

<button class="firebaseui-id-country-selector firebaseui-country-selector mdl-button mdl-js-button ui-btn ui-shadow ui-corner-all" data-upgraded=",MaterialButton">
     <span class="firebaseui-flag firebaseui-country-selector-flag firebaseui-id-country-selector-flag firebaseui-flag-US"></span>
     <span class="firebaseui-id-country-selector-code">‎+1</span>
</button>

After a simple refresh: 简单刷新后:

<button class="firebaseui-id-country-selector firebaseui-country-selector mdl-button mdl-js-button" data-upgraded=",MaterialButton">
     <span class="firebaseui-flag firebaseui-country-selector-flag firebaseui-id-country-selector-flag firebaseui-flag-US"></span>
    <span class="firebaseui-id-country-selector-code">‎+1</span>
</button>

The whole refresh thing isn't a great fix. 整个刷新不是一个很好的解决方案。 My users are way confused. 我的用户很困惑。 I'm overriding key CSS elements to make this remotely functional, but I'm not quite sure how to best fix this. 我将覆盖关键的CSS元素以使其能够远程运行,但是我不确定如何最好地解决此问题。 Because of the jQueryMobile navigation functioning, there really isn't a simple way to perform a repaint / refresh of this 'page'. 由于jQueryMobile导航功能的存在,确实没有一种简单的方法可以对此“页面”进行重新绘制/刷新。 I did find this reference posting , but it doesn't seem to be of much help. 我确实找到了此参考发布 ,但似乎并没有太大帮助。

Any ideas on how to make this fully functional? 关于如何使此功能完全正常的任何想法?

Here's a fix, but it's a total hack. 这是一个修复程序,但这是完全破解。 I carefully examined the class structure before and after. 我之前和之后都仔细检查了班级结构。 Apply brute force using CSS specificity. 使用CSS特异性应用蛮力。

$(document).on('pagecreate', "#phone_list", function() {
    console.log("on #phone_list 'page' ");
    $('#firebaseui-container button').removeClass("ui-btn ui-shadow ui-corner-all");
    $('div.mdl-textfield div.ui-input-text').removeClass("ui-input-text");
});

The ui-btn ui-shadow ui-corner-all ui-input-text are JQM classes. ui-btn ui-shadow ui-corner-all ui-input-text是JQM类。 To prevent the JQM auto-enhancement You need to set the default ignoreContentEnabled to: true and then mark the html container part with the JQM data attribute data-enhance="false" . 为了防止JQM自动增强,您需要将默认的ignoreContentEnabled设置为: true ,然后使用JQM数据属性data-enhance="false" ignoreContentEnabled data-enhance="false"标记html容器部分。 This has been already pointed out in some previous SO answers . 先前的一些SO答案已经指出了这一点。

I believe this is a nice question, because It would be perfect if, all the other mixed JS/CSS libraries had the same feature to skip enhancement. 我相信这是一个很好的问题,因为如果所有其他混合JS / CSS库都具有相同的功能来跳过增强功能,那将是完美的 Regarding the intersecting CSS styles, there is nothing else to do that use CSS specificity or the important declaration. 关于相交的CSS样式,没有其他事情可以使用CSS特定性或important声明。

Below is a concrete example: JQM together with Material Design Lite 下面是一个具体示例:JQM与Material Design Lite一起

 function injectCard() { var card = ['<div class="mdl-card mdl-shadow--2dp">', '<div class="mdl-card__title">', '<h2 class="mdl-card__title-text">Welcome</h2>', '</div>', '<div class="mdl-card__supporting-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>', '<div class="mdl-cell">', '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">', '<input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\\.[0-9]+)?" id="sample4">', '<label class="mdl-textfield__label" for="sample4">Number...</label>', '<span class="mdl-textfield__error">Input is not a number!</span>', '</div>', '</div>', '<div class="mdl-card__actions mdl-typography--text-right">', '<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">Cancel</a>', '<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect">Verify</button>', '</div>', '</div>' ].join(""); $("#container").html(card); componentHandler.upgradeDom(); } $(document).on('pagecontainershow', function(e, ui) { $.mobile.loading("show"); }); $(document).ready(function() { // Just a test setTimeout(function() { $.mobile.loading("hide"); injectCard(); }, 1000); }); 
 /* Some manual adjustmets */ .mdl-textfield__label { margin-bottom: 0px !important; } .mdl-button { font-weight: 500 !important; } .ui-header .ui-title, .ui-footer .ui-title { font-weight: inherit; font-size: 1.250em !important; } 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css"> <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css"> <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <script type="text/javascript"> $(document).on('mobileinit', function() { $.mobile.ignoreContentEnabled = true; }); </script> <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script> <script src="https://code.getmdl.io/1.3.0/material.min.js"></script> </head> <body> <div id="page-1" data-role="page"> <div data-role="header"> <h1>Login</h1> </div> <div role="main" class="ui-content"> <form> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Enhanced by jQuery Mobile:</legend> <label for="select-h-2a">Select A</label> <select name="select-h-2a" id="select-h-2a"> <option value="#">One</option> <option value="#">Two</option> <option value="#">Three</option> </select> <label for="select-h-2b">Select B</label> <select name="select-h-2b" id="select-h-2b"> <option value="#">One</option> <option value="#" selected>Two</option> <option value="#">Three</option> </select> <label for="select-h-2c">Select C</label> <select name="select-h-2c" id="select-h-2c"> <option value="#">One</option> <option value="#">Two</option> <option value="#" selected>Three</option> </select> </fieldset> <input name="search-1" id="search-1" value="" type="search"> </form> <hr> <div data-enhance="false" id="container"> <legend>Not Enhanced</legend> </div> </div> </div> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM