第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

fire 的 handlers[i](data);

https://img1.sycdn.imooc.com//5b62758e0001e54705790207.jpg

======================== win.js ==========================================

define(['jquery','jqueryUI'], function($,$UI) {

function win() {

this.cfg = {

width: 500,

height: 300,

title: '系統(tǒng)消息',

content: '',

hasClose: false, //X關(guān)閉

hasMask:true, //遮罩層

isDraggable:true, //拖動(dòng)彈框

dragHandler:null, //拖動(dòng)

skinClassName:null, //alert皮膚

alertOK:'確定',

handlerOK: null, //OK函數(shù)

handlerClose: null, //關(guān)閉函數(shù)

};

this.handlers={} //自定義事件

}


win.prototype = {

alert: function(cfg) {

var CFG = $.extend(this.cfg, cfg);?


var alertBox = $('<div class="alert-box">'+

'<div class="alert-header">'+CFG.title+'</div>'+

'<div class="alert-content">'+CFG.content+'</div>'+

'<input type="button" value="'+CFG.alertOK+'" class="alert-OK"/>'+

'</div>');

alertBox.appendTo('body');


var mask=null,

that=this;

if(CFG.hasMask){

mask=$('<div class="window-mask"></div>');

mask.appendTo('body');

}


$('.alert-OK').click(function() {

alertBox.remove();?

mask && mask.remove();

that.fire('alert');

});

if(CFG.handlerOK){

this.on('alert',CFG.handlerOK())

}


alertBox.css({

width: this.cfg.width + 'px',

height: this.cfg.height + 'px',

left: (this.cfg.x || (window.innerWidth - this.cfg.width) / 2) + 'px',

top: (this.cfg.y || (window.innerHeight - this.cfg.height) / 2) + 'px'

});


if(CFG.hasClose){

var close=$('<div class="alert-close">X</div>');

close.appendTo(alertBox);

close.click(function() {

alertBox.remove();

mask && mask.remove();

that.fire('close');

});

}

if(CFG.handlerClose){

this.on('close',CFG.handlerClose())

}


if(CFG.skinClassName){

alertBox.addClass(CFG.skinClassName)

}


if(CFG.isDraggable){

if(CFG.dragHandler){

alertBox.draggable({handle:CFG.dragHandler});

}else{

alertBox.draggable(); // draggable:jquery-ui.js

}

}

},

confirm: function() {


},

prompt: function() {


},


on: function(type, handler) {?

if (typeof this.handlers[type] == "undefined") {

this.handlers[type] = [];

}

this.handlers[type].push(handler);

},

fire: function(type, data) {?

if (this.handlers[type] instanceof Array) {

var handlers = this.handlers[type];

for (var i = 0; i < handlers.length; i++) {

handlers[i](data);

}

}

}

};


return {

win: win

}

})

============================ main.js =================================

require.config({

paths: {

jquery: 'jquery-2.1.0',

// jqueryUI:'jquery-ui',

jqueryUI:'http://code.jquery.com/ui/1.10.4/jquery-ui'

}

});


require(['jquery', 'win'], function($, w) {

$('#alertShow').click(function() {

var win=new w.win();

win.alert({

title:'提示',

content: 'hello',

width: 300,

height: 150,

hasClose:true,//X關(guān)閉(是否顯示)

alertOK:'OK',

dragHandler:'.alert-header', //拖動(dòng)

handlerOK:function() {//OK

alert('hello word');

},

handlerClose:function(){//關(guān)閉

alert('close');

},

skinClassName:'alert-box2', //皮膚

hasMask:true, //遮罩層

});


win.on('alert',function(){

alert('the second alert handler');

});

win.on('alert',function(){

alert('the third alert handler');

});

win.on('close',function(){

alert('the second alert handler');

});


});

});

======================= html ==========================

<input type="button" value="alert彈框" id="alertShow" />

<script type="text/javascript" data-main="js/main" src="js/require.js"></script>


<style>

body,html{margin: 0;padding:0;}

.window-mask{

position: absolute;

top: 0;

bottom: 0;

left: 0;

right: 0;

background-color: rgba(0,0,0,0.5);

z-index: 99;

}

.alert-box{

box-shadow: 0 0 20px rgba(0,0,0,0.5);

position: fixed;

border-radius: 10px;

z-index: 100;

background-color: #fff;

}

.alert-OK{

width:50%;

height: 36px;

line-height: 36px;

position: absolute;

left: 50%;

bottom: 10px;

transform: translateX(-50%);

}

.alert-header{

background-color: #e8e8e8;

height: 40px;

line-height: 40px;

text-align: center;

border-top-left-radius: 10px;

border-top-right-radius: 10px;

}

.alert-content{padding:0 10px;}

.alert-close{

position: absolute;

? ? right: 10px;

? ? top: 6px;

? ? font-size: 20px;

? ? color: #f00;

? ? cursor: pointer;

}


.alert-box2{border:1px solid #44b549;}

.alert-box2 .alert-close{color: #44b549}

</style>


正在回答

1 回答

也解決

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
阿當(dāng)大話西游之WEB組件
  • 參與學(xué)習(xí)       26366    人
  • 解答問(wèn)題       278    個(gè)

衡量攻城師能力是否成熟的重要指標(biāo),本課程會(huì)以彈窗組件為例

進(jìn)入課程

fire 的 handlers[i](data);

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)