zoukankan      html  css  js  c++  java
  • 自己写的一个很绕的Js 运用 prototype和allay

    var qq = {};
    qq.extend
    = function (first, second) {
    for (var prop in second) {
    first[prop]
    = second[prop];
    }
    };
    qq.FileUploaderBasic
    = function (o) {
    this._options = {
    data:
    false,
    url:
    false,
    msg: { typeerror:
    "类型错误",
    sizeerror:
    "大小错误",
    maxfile:
    "限额错误"
    }
    };
    qq.extend(
    this._options, o);
    this._handler = this._CreateUploadHandle();
    this._button = this._CreateButton();
    // this._preventLeaveInProgress();
    };

    qq.FileUploader
    = function (o) {
    qq.FileUploaderBasic.apply(
    this, arguments);

    qq.extend(
    this._options, {
    element:
    null,
    template:
    "<div></div>"
    });
    qq.extend(
    this._options, o);

    this._element = this._options.element;
    this._template = this._options.template;

    };

    qq.UploadHandlerForm
    = function (o) {
    //复杂没写
    };
    qq.UploadHandlerForm.prototype
    = {
    upload:
    function (id, params) {
    this._upload();
    }
    };

    qq.extend(qq.UploadHandlerForm.prototype, {
    _upload:
    function (id) {
    alert(
    "upload");
    }
    });

    qq.FileUploaderBasic.prototype
    = {
    _CreateUploadHandle:
    function () {
    var handlerClass, self = this;
    handlerClass
    = "UploadHandlerForm";
    var _handler = new qq[handlerClass]() || {};
    return _handler;
    },
    _CreateButton:
    function () {
    var self = this;
    var input = document.createElement("input");
    input.setAttribute(
    "type", "button");
    input.setAttribute(
    "id", "inputfile");
    $(input).click(
    function () {
    self._handler.upload();
    });
    $(document.body).append($(input));
    return input;
    },
    _preventLeaveInProgress:
    function () { }

    };
    qq.extend(qq.FileUploader.prototype, qq.FileUploaderBasic.prototype);
    qq.extend(qq.FileUploader.prototype, {

    /**
    * delegate click event for cancel link
    *
    */
    _bindCancelEvent:
    function () {

    }
    });

  • 相关阅读:
    51nod 1284:2 3 5 7的倍数 容斥原理
    POJ 2006:Litmus Test 化学公式
    POJ 2039:To and Fro
    POJ 2014:Flow Layout 模拟水题
    南阳722--数独(Dfs)
    Poj2377--Bad Cowtractors(最大生成树)
    并查集知识点总结
    Poj1861--Network(最小生成树)
    杭电2824--The Euler function(欧拉函数)
    杭电1284--钱币兑换问题(有趣)
  • 原文地址:https://www.cnblogs.com/shikyoh/p/2057495.html
Copyright © 2011-2022 走看看