时间:2021-05-25
插件代码
复制代码 代码如下:
var UserGuider = new Class({
Implements: [Options, Events],
options: {
UserGuideList: new Array(),
step: 0
},
initialize: function (options) {
this.setOptions(options);
this.step = this.options.step;
},
createGuide: function () {
var self = this;
$$('.userGuide').dispose();
var UserGuideList = this.options.UserGuideList;
var config = UserGuideList[this.step];
if (config == null) {
return;
}
var ele = $$('.' + config.className)[0];
if (ele == null) {
return;
}
$$('.' + config.className + ' a').set('target', '_blank');
var top = ele.getCoordinates().top;
var right = ele.getCoordinates().right;
var bottom = ele.getCoordinates().bottom;
var left = ele.getCoordinates().left;
var width = ele.getCoordinates().width;
var height = ele.getCoordinates().height;
var x = window.getScrollSize().x;
var y = window.getScrollSize().y;
this.createShadowDiv('shadowTop', left, 0, width, top);
this.createShadowDiv('shadowRight', right, 0, x - right, y);
this.createShadowDiv('shadowButtom', left, bottom, width, y - bottom);
this.createShadowDiv('shadowLeft', 0, 0, left, y);
if (config.src != null) {
this.createUserGuideImg(left + config.imgLeft, top + config.imgTop, config.src);
}
if (config.navUrl != null) {
this.createUserGuideNavImg(right - 50, bottom, config.navUrl);
}
if (this.step > 0) {
this.createUserButton('userguide_undo', 'UserGuide/undo.png', this.step - 1);
}
if (this.step < UserGuideList.length - 1) {
this.createUserButton('userguide_next', 'UserGuide/next.png', this.step + 1);
}
this.createUserButton('userguide_finish', 'UserGuide/finish.png', 10000);
this.changeUserGuideButton();
if (config.src2 != null) {
this.createUserGuideImg(left + config.imgLeft2, top + config.imgTop2, config.src2);
}
return this;
},
createShadowDiv: function (id, left, top, width, height) {
var self = this;
var div = new Element('div');
div.set('id', id);
div.addClass('userGuide');
div.setStyles({
left: left + 'px',
top: top + 'px',
width: width + 'px',
height: height + 'px',
position: 'absolute',
'background-color': '#000',
'z-index': 100,
opacity: 0.5,
filter: 'alpha(opacity=50)'
});
$$('body').adopt(div);
return this;
},
createUserGuideNavImg: function (left, top, nav) {
var self = this;
var img = new Element('img');
img.addClass('userGuideNav');
img.addClass('userGuide');
img.setStyles({
cursor: 'pointer',
'z-index': 10000,
left: left + 'px',
top: top + 'px',
position: 'absolute'
});
img.set('src', 'userguide/nav.png');
img.addEvent('click', function () {
window.open(nav);
});
$$('body').adopt(img);
return this;
},
createUserGuideImg: function (left, top, src) {
var self = this;
var img = new Element('img');
img.addClass('userGuideImg');
img.addClass('userGuide');
img.setStyles({
'z-index': 1000,
left: left + 'px',
top: top + 'px',
position: 'absolute'
});
img.set('src', src);
$$('body').adopt(img);
return this;
},
createUserButton: function (className, src, thisStep) {
var self = this;
var img = new Element('img');
img.addClass(className);
img.addClass('userGuide');
img.setStyles({
cursor: 'pointer',
'z-index': 1000000,
position: 'absolute'
});
img.set('src', src);
img.addEvent('click', function () {
self.step = thisStep;
self.createGuide();
});
$$('body').adopt(img);
return this;
},
changeUserGuideButton: function () {
var self = this;
var size = window.getSize();
var scroll = window.getScroll();
var scrollSize = window.getScrollSize();
$$('.userguide_finish').setStyles({
left: (size.x - 220) + 'px',
top: (size.y + scroll.y - 80) + 'px'
});
$$('.userguide_next').setStyles({
left: (size.x - 420) + 'px',
top: (size.y + scroll.y - 80) + 'px'
});
$$('.userguide_undo').setStyles({
left: (size.x - 620) + 'px',
top: (size.y + scroll.y - 80) + 'px'
});
return this;
}
});
调用方式
复制代码 代码如下:
var UserGuider;
var UserGuideList = new Array({
className: 'step0',
src: 'UserGuide/step0.png',
imgTop: 50,
imgLeft: 50
}, {
className: 'step1',
src: 'UserGuide/step1.png',
imgTop: -150,
imgLeft: 0,
src2: 'UserGuide/pic/1.gif',
imgTop2: 210,
imgLeft2: 450
}, {
className: 'step2',
src: 'UserGuide/step2.png',
imgTop: 0,
imgLeft: -600,
navUrl: '/MyMessageCenter.aspx',
src2: 'UserGuide/pic/2.gif',
imgTop2: 110,
imgLeft2: 80
}, {
className: 'step3',
src: 'UserGuide/step3.png',
imgTop: -150,
imgLeft: 130,
navUrl: '/MyTaskSearch.aspx',
src2: 'UserGuide/pic/3.png',
imgTop2: -120,
imgLeft2: 250
});
window.addEvent('domready',function(){
UserGuider = new UserGuider({
UserGuideList: UserGuideList
})
UserGuider.createGuide();
});
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文内容:页面镂空遮罩层、页面镂空遮罩引导层、图片镂空遮罩常规遮罩层Title.mask{position:absolute;width:100%;height
半透明遮罩层效果基本上都是使用插件实现的,下面为大家分享下使用原生js实现半透明遮罩效果,感兴趣的朋友可以参考下哈,希望对你熟悉原生js有所帮助现在注册关闭用户
最近项目遇到了遮罩层的一些问题,总结一下:弹出遮罩层遮罩层弹出有非常多的方法,这里只写出本人用的代码,使用jq操作dom的方法进行实现的。.box{positi
【1】遮罩层:承载内容,管理样式布局。【2】内容层:控制遮罩层的显示与否。遮罩层和内容区之间应该解耦。遮罩层和内容区之间应该解耦。遮罩层和内容区之间应该解耦。遮
Jquery实现遮罩层的简单实例(就是弹出DIV周围都灰色不能操作)Jquery遮罩层#BgDiv{background-color:#e3e3e3;posit