zoukankan      html  css  js  c++  java
  • jQuery面向对象定制业务框架开发

    jbase.js 业务框架基类

    /**
    * @class: Jbase
    * @description: 定制框架基类
    * @author: fangxianghua
    */
    var Jbase = function() {
      this.namespace = "Jbase";//命名空间
      this.version = "2.0.0"; //版本
      this.parent = null;
      this.className = "Jbase";
    };
    /**
    * @function: extend
    * @description: 父子类继承函数
    * @author: fangxianghua
    */
    Jbase.extend = function (subClass, superClass) {
      var F = function () { };
      F.prototype = superClass.prototype;
      subClass.prototype = new F();
      subClass.prototype.constructor = subClass;

      subClass.parent = superClass.prototype;
      if (superClass.prototype.constructor == Object.prototype.constructor) {
        superClass.prototype.constructor = superClass;
      }
    };
    //-------------------------常用工具函数定义在基类begin-----------------------------//
    //工具函数开发原则:jquery类库中已有的尽量使用其的,否则在此定制相关工具函数
    /**
    * @function: getKeyCode
    * @description: 获取事件转换码
    * @author: fangxianghua
    * @param: event
    * @return: keyCode
    */
    Jbase.getKeyCode = function (event) {
      event = (event) ? event : ((window.event) ? window.event : "");
      return event.keyCode ? event.keyCode : event.which;
    };


    Jbase.showKeyCode = function (event) {
      return event;
    };
    //-------------------------常用工具函数定义在基类end-----------------------------// 

    keyboard.js 基于定制框架基类的业务子类

    /**
    * @class: Keyboard
    * @description: 测试框架类
    * @author: fangxianghua
    */
    Jbase.Keyboard = function () {
      //------------全局变量----------
      this.className = "Jbase.Keyboard";
      this.stylePath = "../style/default/";
      this.name = "";
      //------------全局变量----------
    };
    Jbase.extend(Jbase.Keyboard, Jbase);
    /**
    * @function: Init
    * @description: 初始化
    * @author: fangxianghua
    * @param: null
    * @return: null
    */
    Jbase.Keyboard.prototype.init = function () {
      this.className = "石英,没来!";
      this.name = "石英";
    };
    /**
    * @function: showKeyboard
    * @description: 显示
    * @author: fangxianghua
    * @param: null
    * @return: null
    */
    Jbase.Keyboard.prototype.showKeyboard = function () {
      var aa = Jbase.showKeyCode("石英");
      alert(aa);
    };
    var jbaseKeyboard;
    if (jbaseKeyboard == null) {
      jbaseKeyboard = new Jbase.Keyboard();
    }
    jQuery.extend(jbaseKeyboard); //为了统一使用jQuery框架将定制业务类追加至jQuery静态构造函数中

    jQuery_oop.html 调用页面

    <html>
    <head>
      <title>软键盘</title>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
      <meta name="page-view-size" content="1280*720" />
      <link id="settingcss" rel="stylesheet" type="text/css" href="style/default/setting.css" />
      <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
      <script type="text/javascript" src="js/jbase.js"></script>
      <script type="text/javascript" src="js/keyboard.js"></script>
      <script type="text/javascript">
        jQuery(document).ready(function () {
          jQuery.showKeyboard();
        });
      </script>
    </head>
    <body style="background-color: #ffffff;">
      <div id="main" class="main">
      </div>
    </body>
    </html>

  • 相关阅读:
    ArrayList和LinkedList的底层代码实现思想
    ArrayList(顺序表)和LinkedList(链表)的区别联系,优劣取舍问题
    【AR】增强现实安卓编程
    【报错】"The constructor Notification(int, CharSequence, long) is deprecated
    【gradle报错】error: package org.apache.http does not exist
    【安卓面试题】多线程下载怎么实现?断点续传怎么实现?
    【安卓面试题】在一个Activity启动另一个Activity和在Service中启动一个Activity有什么区别
    java.lang.IllegalArgumentException: Service Intent must be explicit: Intent
    【Android Studio 小技巧】一键查看文件方法结构目录File Structure
    【安卓面试题】使用SQLiteOpenHelper的getReadableDatabase()获得的数据库能不能,做写的操作
  • 原文地址:https://www.cnblogs.com/fx2008/p/2299122.html
Copyright © 2011-2022 走看看