zoukankan      html  css  js  c++  java
  • jquery弹出层控件

    (function($) {
        // 插件的定义
        // var opts;
        $.fn.modelwindow = function(options) {
            debug(this);
            // build main options before element iteration
            opts = $.extend({}, $.fn.modelwindow.defaults, options);

            $("#contentdiv").css({ display: "none" });
            // iterate and reformat each matched element     
            this.each(function() {

                //  var markup = $this.html();
                // call our format function

                $(this).click(function() {
                    $("#contentdiv").html(showdiv($(this).attr("href")), opts);
                    $("#contentdiv").fadeIn(700)
                    return false;
                });

            });
        };
        // 私有函数:debugging     
        function debug($obj) {
            if (window.console && window.console.log)
                window.console.log('modelwindow selection count: ' + $obj.size());
        };
        // 定义暴露format函数     
        $.fn.modelwindow.format = function(txt) {
            return '<strong>' + txt + '</strong>';
        };
        // 定义弹出层函数
        showdiv = function(url, opts) {
            return '<div id="maskdiv" onclick="modelwindowhidden()"></div><div id="showdiv" ><div class="showdivbar"><a href="#" class="showdivbarclose" onclick="modelwindowhidden(opts)">close</a></div><iframe name="iframe" id="iframe" src=' + url + ' width="100%" height="500" /></div>';
        };
        //隐藏窗口
        modelwindowhidden = function(opts) {
             
            var d = $("#iframe").contents().find(opts.callbackcontentid).val();
            opts.callback;
            opts.onclosed(d);
           
            $('#contentdiv').fadeOut(700);
            $('#contentdiv').html("");

           
        }
        // 插件的defaults     
        $.fn.modelwindow.defaults = {
            foreground: 'red',
            background: 'yellow',
            callback: {},
            onclosed: {},
            callbackcontentid: ""

        };
        // 闭包结束     
    })(jQuery);     
     
     
    调用方法
    $(document).ready(function() {
         $("a").modelwindow({
          onclosed: function(data) { $("#cb").val(data); },
          callbackcontentid: "#Text4"

        })
    })
  • 相关阅读:
    SplitViewController的简单使用
    ViewController容器
    AnchorPoint 和Position 关系
    __OSX_AVAILABLE_BUT_DEPRECATED
    __OSX_AVAILABLE_STARTING
    UIButton重复点击,重复触发,怎么办
    iOS小技巧:用runtime 解决UIButton 重复点击问题
    FOUNDATION_EXPORT 或#define 或 extern
    nginx第一天
    053-001
  • 原文地址:https://www.cnblogs.com/mz121star/p/2250493.html
Copyright © 2011-2022 走看看