zoukankan      html  css  js  c++  java
  • 构建第一个单页应用

    注意:

    GOOGLE提供的jquery.min.js调用不到了怎么办?
    ajax.googleapis站下的/ajax/libs/jquery/1.7.2/jquery.min.js调用不到了怎么办?
    

     1.用百度的

    http://libs.baidu.com/jquery/1.7.2/jquery.min.js

    2.自己下载到本地

    源码:

    <!doctype html>
    <html>
    <head>
      <title>SPA Chapter 1 section 1.2.5</title>
      <style type="text/css">
        body {
          width	: 100%;
          height	: 100%;
          overflow	:hidden;
          background-color	: #777;
        }
        #spa {
          position	: 8px;
          top	: 8px;
          left	: 8px;
          bottom	: 8px;
          right	: 8px;
          border-radius	: 8px 8px 0 8px;
          background-color	: #fff;
        }
        .spa-slider {
          position	: absolute;
          bottom	: 0;
          right	: 2px;
          width	: 300px;
          height	: 16px;
          cursor	: pointer;
          border-radius	: 8px 0 0 0;
          background-color	: #f00;
        }
      </style>
      <script type="text/javascript" src=
        "http://libs.baidu.com/jquery/1.7.2/jquery.min.js">
      </script>
    
      <script>
        /*jslint		browser	: true, continue : true,
          devel	: true, indent	: 2,	maxerr   : 50,
          newcap	: true, nomen	: true, plusplus : true,
          regexp	: true, sloppy	: true, vars : true,
          white	:true,
        */
        /*global jQuery*/
        // Module /spa/
        //
        var spa = (function( $ ) {
          // Module scope variables
          var
          // Set constants
          configMap = {
            extended_height : 434,
            extended_title : 'Click to retract',
            retracted_height : 16,
            retracted_title : 'Click to extend',
            template_html : '<div class="spa-slider"></div>'
          },
          // Declare all other module scope variables
          $chatSlider,
          toggleSlider, onClickSlider, initModules;
          // DOM method /toggleSlider/
          // alternates slider height
          //
          toggleSlider = function () {
            var
              slider_height = $chatSlider.height();
              
            // extend slider if fully retracted
            if (slider_height === configMap.retracted_height ) {
              $chatSlider
                .animate({ height : configMap.extended_height })
                .attr( 'title', configMap.retracted_title );
              return true;
            }
    
            // retracted slider if fully extended
            else if ( slider_height === configMap.extended_height ) {
              $chatSlider
                .animate({ height : configMap.retracted_height })
                .attr( 'title', configMap.retracted_title);
              return true;
            }
            // do not take action if slider is in transition
            return false;
          }
    
          // Event handler /onClickslider/
          // receives click event and calls toggleSlider
          //
          onClickSlider = function () {
            toggleSlider();
            return false;
          };
          // Public method /initModules
          // sets initial state and provides feature
          //
          initModule = function ( $container ) {
            //render HTML
            $container.html( configMap.templates_html );
            
            $chatSlider = $container.find( '.spa-slider' );
            // initialize slider height and title
            // bind the user click evnet to the event handler
            $chatSlider
              .attr( 'title', configMap.retracted_title)
              .click( onClickSlider);
            return true;
          };
          return { initModule : initModule };
        }( jQuery ));
        // Start SPA once DOM is redy
      jQuery(document).ready(
        function () { spa.initModule( jQuery('#spa') ); }
      );
      </script>
    </head>
    <body>
      <div id="spa">
        <div class="spa-slider"></div>
      </div>
    </body>
    </html>
    
  • 相关阅读:
    Python PEP8 编码规范中文版
    MySQL分区表
    mybatis缓存,包含一级缓存与二级缓存,包括ehcache二级缓存
    斐讯K2刷不死breed与第三方固件教程
    Mysql 多表连接查询 inner join 和 outer join 的使用
    mysql多表关联删除示例
    sublime Text 几款插件
    多进程vs多线程
    git 命令常用总结
    LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
  • 原文地址:https://www.cnblogs.com/nodejsxxh/p/4414278.html
Copyright © 2011-2022 走看看