search
HomeWeb Front-endH5 TutorialFront-end framework-pop-up window research

Front-end framework-pop-up window research

Jul 15, 2017 am 11:52 AM
h5front-end frameworkPop-ups

I have been working in an electric power company for two years, and all the applications developed are based on H5 applications. The H5 reference is developed based on the cordova.js library. When various outsourcing companies received the application, they were all confused and did not know how to develop it. This article mainly explains the use of a front-end built based on the seajs library and the Bootstrap framework. Universal framework.

The front-end framework mainly studies four points

1. ResearchThe dynamic loading technology of the Web framework

For In the mobile Internet environment, mobile terminals have limited memory, traffic, and battery resources. By using dynamic loading technology, program files are broken into multiple small files, and lazy loading technology (LazyLoading) is used to achieve on-demand loading to improve user experience. Reduce resource usage on mobile terminal. In terms of business and style, front-end developers only need to reference the required js library and css style at the head of the JS code block. Logically, developers only need to call the interface provided by the backend to read and display. The main advantages of this technology include high maintainability, fast dynamic loading, and good front-end performance optimization.

2. Research on modularizationBuilding technology

Based on the development of mobile application projects by front-end personnel, by using modular construction technology, Each page is divided into multiple functions for segmentation processing, which can not only quickly obtain the page on the mobile terminal, but also quickly locate related problems during debugging on the mobile terminal. By defining multiple modules to call each other, it not only ensures that there is no conflict between modules, but also improves the coding efficiency of developers. Its main advantages are single responsibility and close dependence.

3. Research on multi-resolution and multi-size mobile terminal interface adaptation technology

For various terminal devices on the mobile side, based on the bootstrap framework On the basis of, a unified style is set through the media query function (Medie Query), and equal proportion windows are set through the window (meta) attribute content. This solves the problem of different mobile phone models with different resolutions and different sizes of terminals being unable to adapt. , further reducing code redundancy and redevelopment.

4. Study on the encapsulation of public components on the mobile terminal

Based on the limited encapsulation of some components under the bootstrap framework, through the time plug-in (datatime), pop-up window plug-in (dialog), graphics plug-in (echarts), pull-down refresh and pull-up loading plug-in (Refresh), sliding plug-in (swiper), province and city selection (citypicker) plug-in, prompt information plug-in (UED) ) and other plug-ins are encapsulated, called on demand, and loaded on demand, so that different pages can reference different plug-ins and implement the calling of components, which greatly reduces the time of front-end developers and also improves the user experience.

Here, we will use one of the plug-ins-the pop-up window to explain

Let me show you the renderings first

Pop-up windows are basically used in every application, and there are so many kinds of pop-up windows. Many programmers, here Write one set, write another over there, the code is very messy, here I also found a set on the Internet, and sorted it out myself. I hope everyone will use a common set of codes in the future to make it concise and simple.

Front-end h5 code

The h5 page should be concise and simple, and separate css and js logic codes are not allowed (the following css code is for testing)

nbsp;html>


    <meta>
    <meta>
    <title>首页</title>
    <meta>
    <style>.col-xs-6 {
            padding: 10px 1px;
        }</style>


    <div>

        <div>
            <div><button>默认的弹窗</button></div>
            <div><button>success</button></div>
            <div><button>primary</button></div>
            <div><button>danger</button></div>
            <div><button>warning</button></div>
            <div><button>可设置背景色</button></div>
            <div><button>自定义标题、描述</button></div>
            <div><button>点后回调</button></div>
            <div><button>box-shadow</button></div>
            <div><button>box-shadow</button></div>
            <div>
                <button>box-shadow</button>
            </div>
            <div><button>无进入动画</button></div>
            <div><button>单个按钮</button></div>
            <div>
                <button>bootstrap弹窗</button>
            </div>
            <div>
                <button>无标题</button>
            </div>
        </div>
    </div>
    <script>
        <div id="dialogContent">这里是用户获取到的内容,获取的内容,可直接设置在这里,然后在页面显示</script>
         <script>var basepath = "../../";//定义当前目录的位置(如果全部在根目录的话,则不需要定义)</script>     <script></script>          <script></script>          <script>seajs.use("../js/dialogs");</script>
View Code

The above code uses my general framework code. If you use pop-up windows, you can directly quote the dialog. js, dialog.css, jquery.js and dialogtest.js can

dialogtest.js code is as follows

define(function (require) {
    require("bootstrap");//加载bootstrap
    require(&#39;dialog&#39;);//加载弹窗  
    require(&#39;dialogcss&#39;);//加载弹窗  
  
 
    var modal = new Modal({
        title: &#39;测试案例&#39;,
        content: $(&#39;#modal-tpl&#39;).html(),
        width: "90%",
        onOk: function () {
            //操作
            alert("你点击了确定");
        },
        onModalShow: function () {
            //弹窗初始化操作
            
        }
    });
    $(".btn").each(function (index) {
        $(this).on("click", function () {
            if(index==0)
            {
                $(&#39;body&#39;).dailog({ type: &#39;defalut&#39; });
            }else if(index==1)
            {
                $(&#39;body&#39;).dailog({ type: &#39;success&#39; })
            }
            else if (index == 2) {
                $(&#39;body&#39;).dailog({ type: &#39;primary&#39; })
            }
            else if (index == 3) {
                $(&#39;body&#39;).dailog({ type: &#39;danger&#39; })
            }
            else if (index == 4) {
                $(&#39;body&#39;).dailog({ type: &#39;warning&#39; })
            }
            else if (index ==5) {
               $(&#39;body&#39;).dailog({ type: &#39;success&#39;, maskBg: &#39;rgba(33,11,22,0.5)&#39; })
            }
            else if (index ==6) {
                $(&#39;body&#39;).dailog({
                    type: &#39;danger&#39;, title: &#39;我是自定义标题&#39;, 
                    discription: &#39;这里是自定义的描述,可以写上你的描述或者他的描述,总之可以写很多文字,你自己看着办吧&#39;
                }, function (ret) {
                    if (ret.index == 0)
                    {
                        alert("你点击了确定按钮");
                    } else
                    {
                        alert("你点击了取消操作");
                    }
                    console.log("信息为:"+JSON.stringify(ret));
                })
            } else if (index ==7) {
                $(&#39;body&#39;).dailog({
                    type: &#39;danger&#39;, title: &#39;错误提示&#39;,
                    discription: &#39;这里是自定义的描述,可以写上你的描述或者他的描述,总之可以写很多文字,你自己看着办吧&#39;,
                    isInput: true
                }, function (ret) {
                    console.log(ret);
                    if (ret.index === 0)
                    {
                        alert(&#39;你点击的是第&#39; + ret.index + &#39;个按钮,状态:&#39; + ret.input.status + &#39;;输入的值为:&#39; + ret.input.value)
                    };
                });
            } else if (index == 8) {
                $(&#39;body&#39;).dailog({ type: &#39;defalut&#39;, showBoxShadow: true })
            } else if (index ==9) {
                $(&#39;body&#39;).dailog({ type: &#39;success&#39;, showBoxShadow: true, maskBg: &#39;#fff&#39; })
            } else if (index == 10) {
                $(&#39;body&#39;).dailog({ type: &#39;primary&#39;, showBoxShadow: true, maskBg: &#39;#ccc&#39; })
            } else if (index == 11) {
                $(&#39;body&#39;).dailog({ type: &#39;primary&#39;, showBoxShadow: true, animateStyle: &#39;none&#39; })
            } else if (index == 12) {
                $(&#39;body&#39;).dailog({
                    type: &#39;warning&#39;, showBoxShadow: true, animateStyle: &#39;none&#39;,
                    bottons: [&#39;确定&#39;], discription: &#39;也许有点问题!&#39;
                })
            }else if(index==13)
            {
                modal.open();
            } else if (index == 14) {
                $(&#39;body&#39;).dailog({ type: &#39;defalut&#39;,showBoxShadow: true, animateStyle: &#39;none&#39;,isnobutton:false,
                    bottons: [&#39;关闭&#39;], discription: &#39;也许有点问题也许有点问题也许有点问题也许有点问题也许有点问题也许有点问题也许有点问题也许有点问题也许有点问题!&#39;
                });
            }
        })
    })

})

The above is the detailed content of Front-end framework-pop-up window research. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
H5: New Features and Capabilities for Web DevelopmentH5: New Features and Capabilities for Web DevelopmentApr 29, 2025 am 12:07 AM

H5 brings a number of new functions and capabilities, greatly improving the interactivity and development efficiency of web pages. 1. Semantic tags such as enhance SEO. 2. Multimedia support simplifies audio and video playback through and tags. 3. Canvas drawing provides dynamic graphics drawing tools. 4. Local storage simplifies data storage through localStorage and sessionStorage. 5. The geolocation API facilitates the development of location-based services.

H5: Key Improvements in HTML5H5: Key Improvements in HTML5Apr 28, 2025 am 12:26 AM

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

HTML5: The Standard and its Impact on Web DevelopmentHTML5: The Standard and its Impact on Web DevelopmentApr 27, 2025 am 12:12 AM

The core features of HTML5 include semantic tags, multimedia support, offline storage and local storage, and form enhancement. 1. Semantic tags such as, etc. to improve code readability and SEO effect. 2. Simplify multimedia embedding with labels. 3. Offline storage and local storage such as ApplicationCache and LocalStorage support network-free operation and data storage. 4. Form enhancement introduces new input types and verification properties to simplify processing and verification.

H5 Code Examples: Practical Applications and TutorialsH5 Code Examples: Practical Applications and TutorialsApr 25, 2025 am 12:10 AM

H5 provides a variety of new features and functions, greatly enhancing the capabilities of front-end development. 1. Multimedia support: embed media through and elements, no plug-ins are required. 2. Canvas: Use elements to dynamically render 2D graphics and animations. 3. Local storage: implement persistent data storage through localStorage and sessionStorage to improve user experience.

The Connection Between H5 and HTML5: Similarities and DifferencesThe Connection Between H5 and HTML5: Similarities and DifferencesApr 24, 2025 am 12:01 AM

H5 and HTML5 are different concepts: HTML5 is a version of HTML, containing new elements and APIs; H5 is a mobile application development framework based on HTML5. HTML5 parses and renders code through the browser, while H5 applications need to run containers and interact with native code through JavaScript.

The Building Blocks of H5 Code: Key Elements and Their PurposeThe Building Blocks of H5 Code: Key Elements and Their PurposeApr 23, 2025 am 12:09 AM

Key elements of HTML5 include,,,,,, etc., which are used to build modern web pages. 1. Define the head content, 2. Used to navigate the link, 3. Represent the content of independent articles, 4. Organize the page content, 5. Display the sidebar content, 6. Define the footer, these elements enhance the structure and functionality of the web page.

HTML5 and H5: Understanding the Common UsageHTML5 and H5: Understanding the Common UsageApr 22, 2025 am 12:01 AM

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

HTML5: The Building Blocks of the Modern Web (H5)HTML5: The Building Blocks of the Modern Web (H5)Apr 21, 2025 am 12:05 AM

HTML5 is the latest version of the Hypertext Markup Language, standardized by W3C. HTML5 introduces new semantic tags, multimedia support and form enhancements, improving web structure, user experience and SEO effects. HTML5 introduces new semantic tags, such as, ,, etc., to make the web page structure clearer and the SEO effect better. HTML5 supports multimedia elements and no third-party plug-ins are required, improving user experience and loading speed. HTML5 enhances form functions and introduces new input types such as, etc., which improves user experience and form verification efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor