Framework7 Installation

Framework7 Installation

In this tutorial, we will discuss Framework7 Installation.

Download Framework7

There are two ways to download Framework7:

Download from Framework7 Github Repository:

Or you can install Framework7 via bower

  • bower install framework7  
  • Download Framework7 Library from CDNs

    A CDN or Content Delivery Network is a network of servers designed to serve files to users. If you use a CDN link in your web page, it moves the responsibility of hosting files from your own servers to a series of external ones. This also offers an advantage that if a visitor to your webpage has already downloaded a copy of Framework7 from the same CDN, it won’t have to be re-downloaded. You can include the following CDN files into the HTML document.

    CDN for iOS App layout:

    <link rel = "stylesheet"   
    href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />  

    Framework7 iOS CSS Library:

    <link rel = "stylesheet"   
    href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />  

    CDNs for Android/Material App Layout:

    <script src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>  

    Framework7 JS library:

    <script src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.material.min.css"></script>  

    Ampps Server

    We use AMPPS (AMPPS is a WAMP, MAMP and LAMP stack of Apache, MySQL, MongoDB, PHP, Perl & Python) server to execute all our examples.

    In the downloaded/installed package we need files from the dist/ folder.

    Dist folder path:

    Bydefault dist/ folder path is: C:\Program Files (x86)\Ampps\www\dist

    Framework7 Installation

    Put your HTML, .JS and CSS files in your server root folder (dist folder), open local host and then run the page.

    Example:

    Create an HTML page “framework7_environment.html”, having the following code:

    <!DOCTYPE html>  
    <html>  
         
       <head>  
          <meta name = "viewport" content = "width = device-width, initial-scale = 1,   
             maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />  
          <meta name = "apple-mobile-web-app-capable" content = "yes" />  
          <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />  
          <title>My App</title>  
          <link rel = "stylesheet"   
             href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />  
          <link rel = "stylesheet"   
             href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />  
       </head>  
         
       <body>  
          //you can control the background color of the Status bar  
          <div class = "statusbar-overlay"></div>  
          <div class = "panel-overlay"></div>  
            
          <div class = "panel panel-right panel-reveal">  
             <div class = "content-block">  
                <p>Contents goes here...</p>  
             </div>  
          </div>  
            
          <div class = "views">  
             <div class = "view view-main">  
                <div class = "navbar">  
                   <div class = "navbar-inner">  
                      <div class = "center sliding">My App</div>  
                      <div class = "right">  
                         <a href = "#" class = "link icon-only open-panel">  
                            <i class = "icon icon-bars"></i>  
                         </a>  
                      </div>  
                   </div>  
                </div>  
                  
                <div class = "pages navbar-through toolbar-through">  
                   <div data-page = "index" class = "page">  
                      <div class = "page-content">  
                         <p>This is simple application...</p>  
                         <div class = "list-block">  
                            <ul>  
                               <li>  
                                  <a href = "envirmnt_about.html" class = "">  
                                     <div class = "item-content">  
                                        <div class = "item-inner">  
                                           <div class = "item-title">Blog</div>  
                                        </div>  
                                     </div>  
                                  </a>  
                               </li>  
                            </ul>  
                         </div>  
                      </div>  
                   </div>  
                </div>  
                  
                <div class = "toolbar">  
                   <div class = "toolbar-inner">  
                      <a href = "#" class = "link">First Link</a>  
                      <a href = "#" class = "link">Second Link</a>  
                   </div>  
                </div>  
             </div>  
          </div>  
            
          <script type = "text/javascript"   
             src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>  
            
          <script>  
             // here initialize the app  
             var myApp = new Framework7();  
      
             // If your using custom DOM library, then save it to $$ variable  
             var $$ = Dom7;  
      
             // Add the view  
             var mainView = myApp.addView('.view-main', {  
                  
                // enable the dynamic navbar for this view:  
                dynamicNavbar: true  
             });  
      
             //use the 'pageInit' event handler for all pages  
             $$(document).on('pageInit', function (e) {  
               
                //get page data from event data  
                var page = e.detail.page;  
      
                if (page.name === 'blog') {  
                  
                   // you will get below message in alert box when page with data-page attribute is equal to "about"  
                   myApp.alert('Here its your About page');  
                }  
             })  
          </script>  
       </body>  
      
    </html>  

    Create another HTML page “envirmnt_about.html”, having the following code:

    <div class = "navbar">  
       <div class = "navbar-inner">  
          <div class = "left">  
             <a href = "#" class = "back link">  
                <i class = "icon icon-back"></i>  
                <span>Back</span>  
             </a>  
          </div>  
            
          <div class = "center sliding">My Blog</div>  
          <div class = "right">  
             <a href = "#" class = "link icon-only open-panel">  
                <i class = "icon icon-bars"></i>  
             </a>  
          </div>  
       </div>  
    </div>  
      
    <div class = "pages">  
       <div data-page = "blog" class = "page">  
          <div class = "page-content">  
             <div class = "content-block">  
                <h2>My Blog</h2>  
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.   
                Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,   
                when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>  
             </div>  
          </div>  
       </div>  
    </div>  

    Save the above both pages in dist folder. Now open server: http://localhost/dist/ and run the example.

    Next Topic:-Click Here

    Leave a Reply