zoukankan      html  css  js  c++  java
  • Dialog

    jQuery主体部分:

      /*
         dialog UI
     */
        var __Dialog__ = function (ops) {
            this.__dialogC__ = {
                root: $('body'),
                 400,
                height: 500,
                title: 'Dialog',
                footFragement: [],
                status: false
            };
            this.__events__ = {
    
            };
            this.__dialogC__ = this.extends(this.__dialogC__, ops);
        };
        __Dialog__.prototype = {
            init: function () {
                this.root = this.__dialogC__.root;
                this.el = this.__dialogC__.el;
                this.footFragement = this.__dialogC__.footFragement;
                this.__render__();
            },
            __render__: function () {
                var
                    $dialogOuter = "<div class="ui-backdrop"></div>",
                    $dialog = "<div class="dialog" style=" +
                        "" + this.__dialogC__.width + "px" +
                        ";height:" + this.__dialogC__.height + "px" +
                        ";margin-top:" + -this.__dialogC__.height * 0.5 + "px" +
                        ";margin-left:" + -this.__dialogC__.width * 0.5 + "px" +
                        "></div>",
                    $dialogTitle = "<div class="dialog-title">" + this.__dialogC__.title + "</div>",
                    $dialogContent = "<div class="dialog-content"></div>",
                    $foot = document.createElement('div');
                $foot.classList.add("dialog-footer");
                if (this.footFragement.length !== 0)
                    this.footFragement.forEach(function (el, index) {
                        var button = document.createElement('button');
                        button.textContent = el.text;
                        button.onclick = function () {
                            el.click();
                        }
                        $foot.appendChild(button);
                    });
                this.root
                    .wrapInner($dialogContent)
                    .prepend($dialogTitle)
                    .wrapInner($dialog)
                    .wrapInner($dialogOuter);
                $('.dialog').append($foot);
                $('.dialog-footer button')[0].focus();
                if (this.__dialogC__.status == false) this.root.css('display', 'none');
                else this.root.css('display', '');
                return this;
            },
            setOptions: function (ops) {
                for (var i in ops) {
                    if (typeof ops[i] !== undefined) this.__dialogC__[i] = ops[i];
                };
                if (this.__dialogC__.status == false) this.root.css('display', 'none');
                else this.root.css('display', '');
                this.___reRender__();
            },
            ___reRender__: function () {
                var $dialog = $('.dialog');
                $dialog.css('width', this.__dialogC__.width + "px")
                    .css('height', this.__dialogC__.height + "px")
                    .css('margin-top', -this.__dialogC__.height * 0.5 + "px")
                    .css('margin-left', -this.__dialogC__.width * 0.5 + "px");
                $('.dialog-footer button')[0].focus();
            },
            extends: function (target, ops) {
                for (var i in ops) {
                    if (ops[i]) target[i] = ops[i];
                }
                return target;
            },
            destory: function () {
                $('.dialog-bg').remove();
            }
        };
    View Code

    react层面:

    import ReactWidget from './react-widget';
    class Dialog extends ReactWidget {
        constructor(props) {
            super(props);
            this.state = {};
            this.element = {};
        }
    
        componentWillReceiveProps(newProps) {
            this.element.setOptions({
                 this.props.width,
                height: this.props.height,
                status: newProps.status
            });
        }
    
        componentDidMount() {
            this.element = new aui.Dialog({
                root: $(ReactDOM.findDOMNode(this)),
                 this.props.width,
                height: this.props.height,
                footFragement: this.props.foot
            });
            this.element.init();
        }
    
        render() {
            return <div id={this.props.id || 'dialog-default-id'}>
                {this.props.children}
            </div>
        }
    }
    
    window.$$.Dialog = Dialog;
    View Code

    样式:

    section {
        border-bottom: 1px solid #FF9900;
        padding: 5px;
    }
    
    /*
        icon
    */
    .ui-dorpdown-icon {
        height: auto;
        width: 20px;
    
        &:after {
            content: '25BC'
        }
    }
    
    /*
        dialog 
    */
    button {
        border: 1px solid #9D9D9D;
        background-color: #fff;
        height: auto;
        padding: 5px 20px;
        border-radius: 5px;
        color: #9D9D9D;
        font-weight: inherit;
        font-style: inherit;
        font-family: inherit;
        cursor: pointer;
    
        &:hover {
            background: #9D9D9D;
            color: #fff;
        }
    }
    
    .ui-backdrop {
        POSITION: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(34, 34, 34, 0.5);
        z-index: 99;
    }
    
    .dialog {
        position: fixed;
        z-index: 100;
        top: 50%;
        left: 50%;
        right: 0;
        bottom: 0;
        border: 1px solid #ff9900;
        border-radius: 5px;
        text-align: center;
        background: #ffffff;
    
        .dialog-title {
            width: auto;
            height: 40px;
            line-height: 40px;
            background-color: #ff9900;
            font-weight: bold;
            color: #ffffff;
        }
    
        .dialog-content {
            padding: 10px;
        }
    
        .dialog-footer {
            position: absolute;
            bottom: 0px;
            background-color: #ff9900;
            width: 100%;
            height: auto;
            padding: 2px 0;
        }
    }
    
    /* 
        banner 
    */
    .banner {
        position: relative;
        width: 100%;
        height: 400px;
    
        .banner-indicators {
            position: absolute;
            bottom: 20px;
            z-index: 10;
            width: 60%;
            padding-left: 0;
            list-style: none;
            text-align: center;
            width: 25%;
            left: 42%;
    
            .banner-indicators-item {
                list-style: none;
                float: left;
                width: 50px;
                padding: 5px 0;
                margin: 0 2px;
                opacity: 0.5;
                border: 0;
                background-color: #fff;
                height: auto;
                border-radius: 5px;
                margin-right: 50px;
                cursor: pointer;
            }
    
            .active {
                background-image: -webkit-linear-gradient(left, #9D9D9D, #000000 25%, #4F4F4F 50%, #000000 75%, #9D9D9D 100%);
                -webkit-text-fill-color: transparent;
                -webkit-animation: indicators-animation 2s infinite linear;
            }
    
            @-webkit-keyframes indicators-animation {
                0% {
                    background: #9D9D9D;
                    border: 3px solid #ffffff;
                }
    
                50% {
                    background: #000000;
                    border: 3px solid #9D9D9D;
                }
    
                100% {
                    background: #9D9D9D;
                    border: 3px solid #ffffff;
                }
            }
        }
    
        .banner-inner {
            width: 100%;
            height: 100%;
            overflow: hidden;
    
            .banner-content {
                width: 300%;
                height: 100%;
                transform: translate3d(-66.66666666%, 0, 0);
                transition: transform 0.6s ease-in-out;
                -webkit-transition: -webkit-transform 0.6s ease-in-out;
    
                .banner-item {
                    display: inline-block;
                    position: relative;
                    width: 33.333333333%;
                    height: 100%;
                    background-repeat: no-repeat;
                    background-size: cover;
    
                    &:nth-child(1) {
                        background-image: url('./Image/banner0.jpg');
                    }
    
                    &:nth-child(2) {
                        background-image: url('./Image/banner1.jpg');
                    }
    
                    &:nth-child(3) {
                        background-image: url('./Image/banner2.jpg');
                    }
    
                    .banner-item-inner {
                        .title {
                            visibility: hidden;
                            transform: translate3d(-15%, 350%, 0);
                            transition: transform 0.3s ease-in-out;
                            -webkit-transition: -webkit-transform 0.3s ease-in-out;
                        }
    
                        .description {
                            visibility: hidden;
                            transform: translate3d(100%, 300%, 0);
                            transition: transform 0.3s ease-in-out;
                            -webkit-transition: -webkit-transform 0.3s ease-in-out;
                        }
                    }
    
                    .active {
                        .title {
                            visibility: visible;
                            transform: translate3d(30%, 350%, 0);
                        }
    
                        .description {
                            visibility: visible;
                            transform: translate3d(60%, 300%, 0);
                        }
                    }
    
                    .banner-item-inner {
                        p {
                            font-size: 40px;
                            font-weight: bold;
                            color: #fff;
                            font-style: italic;
                        }
                    }
                }
            }
        }
    }
    
    .ui-combobox {
        position: relative;
        width: 200px;
        min-width: 50px;
        height: 30px;
        line-height: 30px;
        background-color: #fff;
        border: 1px solid #bbb;
        outline: 0;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    
        .ui-combobox-input {
            position: absolute;
            width: 100%;
            height: 100%;
            margin: 0 auto;
            outline: 0;
            overflow: hidden;
            resize: none;
            border: none;
            background: #fff;
            cursor: default;
            padding: 1px 30px 1px 5px;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }
    
        .ui-combobox-dropdown-container {
            position: absolute;
            height: 100%;
            right: 0;
            top: 0;
            border-left: 1px solid transparent;
            cursor: default;
        }
    
        .ui-combobox-placeholder {
            position: absolute;
            display: table;
            table-layout: fixed;
            height: 100%;
            top: 0;
            left: 5px;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            color: #aaa;
        }
    }
    
    .ui-combobox-focused {
        border-color: #49d;
    }
    
    .ui-combobox-mouseover {
        border-color: #49d;
    }
    
    .ui-combobox-popup-shown {
        border-color: #49d;
    }
    
    .ui-combobox-popup {
        position: absolute;
        width: 198px;
        height: auto;
        background-color: #ffffff;
        border: 1px solid #bbb;
        box-sizing: content-box;
    
        .ui-combobox-listbox {
            height: auto;
            max-height: 300px;
            min-height: 22px;
            list-style: none;
            overflow: auto;
            background-color: #ffffff;
            box-sizing: border-box;
    
            .ui-combobox-listbox-container {
                display: table;
                width: 100%;
    
                .ui-combobox-selection-container {
                    display: table-row;
    
                    &:hover {
                        background-color: #F0F0F0;
                    }
    
                    .ui-combobox-selection {
                        display: table-cell;
                        border: 1px solid #ffffff;
                        outline: 0;
                        white-space: nowrap;
                        padding: 13px 0 13px 5px;
                        line-height: 1px;
                        cursor: default;
                    }
    
                    .ui-combobox-selection-selected {
                        background-color: #bbb;
                    }
                }
            }
        }
    }
    
    /*
        loading
    */
    
    .ui-loading {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 99999;
        display: block;
        text-align: center;
    
        &::before {
            content: '';
            height: 100%;
            width: 0;
            vertical-align: middle;
            display: inline-block;
        }
    
        .ui-loading-dialog {
            position: relative;
            vertical-align: middle;
            display: inline-block;
    
            .ui-loading-circle {
                position: relative;
                height: 60px;
                width: 60px;
                border-radius: 50%;
                background-color: #9D9D9D;
    
                &::before {
                    height: 4px;
                    width: 100%;
                    left: 0;
                    top: 28px;
                    z-index: 1;
                    position: absolute;
                    content: "";
                    background: #fff;
                }
    
                &::after {
                    width: 4px;
                    height: 100%;
                    top: 0;
                    right: 28px;
                    position: absolute;
                    content: "";
                    background: #ffffff;
                }
    
                .left {
                    position: absolute;
                    height: 100%;
                    width: 50%;
                    overflow: hidden;
                    left: 0;
                }
    
                .right {
                    position: absolute;
                    overflow: hidden;
                    height: 100%;
                    width: 50%;
                    left: 50%;
                }
    
                .center {
                    position: absolute;
                    top: 6px;
                    left: 6px;
                    height: 48px;
                    width: 48px;
                    background: #fff;
                    border-radius: 50%;
                }
    
                .anim {
                    position: absolute;
                    left: 100%;
                    top: 0;
                    height: 100%;
                    width: 100%;
                    border-radius: 999px;
                    background-color: #ff9900;
                    -webkit-animation: aui-circle-loading-left 2s infinite;
                    animation: aui-circle-loading-left 2s infinite;
                    -webkit-transform-origin: 0 50% 0;
                    transform-origin: 0 50% 0;
                    -webkit-animation-duration: 2s;
                    -webkit-animation-timing-function: linear;
                    animation-duration: 2s;
                    animation-timing-function: linear;
                }
    
    
                .right .anim {
                    -webkit-animation-name: aui-circle-loading-right;
                    animation-name: aui-circle-loading-right;
                }
    
                .left .anim {
                    border-bottom-left-radius: 0;
                    border-top-left-radius: 0;
                }
    
                .right .anim {
                    border-bottom-right-radius: 0;
                    border-top-right-radius: 0;
                    left: -100%;
                    -webkit-transform-origin: 100% 50% 0;
                    transform-origin: 100% 50% 0;
                }
            }
        }
    }
    
    @keyframes aui-circle-loading-left {
        0% {
            transform: rotate(0deg)
        }
    
        25% {
            transform: rotate(0deg)
        }
    
        50% {
            transform: rotate(180deg)
        }
    
        75% {
            transform: rotate(180deg)
        }
    
        100% {
            transform: rotate(360deg)
        }
    }
    
    
    @keyframes aui-circle-loading-right {
        0% {
            transform: rotate(0deg)
        }
    
        25% {
            transform: rotate(180deg)
        }
    
        50% {
            transform: rotate(180deg)
        }
    
        75% {
            transform: rotate(360deg)
        }
    
        100% {
            transform: rotate(360deg)
        }
    }
    View Code

     效果:

  • 相关阅读:
    C#枚举中使用Flags特性
    WPF 设置输入只能英文
    PHP array_merge_recursive() 函数
    PHP array_merge() 函数
    PHP array_map() 函数
    PHP array_keys() 函数
    PHP array_key_exists() 函数
    [HNOI2016]网络
    WPF 设置输入只能英文
    WPF 设置输入只能英文
  • 原文地址:https://www.cnblogs.com/moran1992/p/11073122.html
Copyright © 2011-2022 走看看