feature(view) use own overlay

This commit is contained in:
coderaiser 2014-04-24 06:56:03 -04:00
parent 38c6bd37f0
commit 587906a0dc

View file

@ -13,23 +13,16 @@ var CloudCmd, Util, DOM, CloudFunc, $;
Key = CloudCmd.Key,
Images = DOM.Images,
View = Util.exec.bind(Util),
Element, TemplateAudio,
Element, TemplateAudio, Overlay,
Config = {
beforeShow : function() {
var $overlay = $('.fancybox-overlay'),
$wrap = $('.fancybox-wrap'),
children = $overlay.children(),
length = children.length;
if (!length)
$overlay.append($wrap);
Images.hide();
Key.unsetBind();
addOverLayClick();
DOM.show(Overlay);
},
beforeClose : function() {
Key.setBind();
DOM.hide(Overlay);
},
fitToView : true,
loop : false,
@ -46,9 +39,8 @@ var CloudCmd, Util, DOM, CloudFunc, $;
mouseWheel : false,
arrows : false,
helpers : {
overlay : {
closeClick: false
}
overlay : null,
title : null
}
};
@ -66,6 +58,13 @@ var CloudCmd, Util, DOM, CloudFunc, $;
func
]);
Config.parent = Overlay = DOM.anyload({
id : 'js-view',
name : 'div',
className : 'fancybox-overlay fancybox-overlay-fixed'
});
Events.addClick(Util.bind(onOverLayClick, Overlay), Overlay);
Events.addKey(listener);
}
@ -108,6 +107,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
onKey = Util.bind(onMusicKey, audio);
$.fancybox.open(element, {
parent : Overlay,
beforeShow : function() {
Config.beforeShow();
musicBeforeShow();
@ -116,6 +116,10 @@ var CloudCmd, Util, DOM, CloudFunc, $;
beforeClose : function() {
Config.beforeClose();
Events.rmKey(onKey);
},
helpers: {
overlay : null,
title : null
}
});
});
@ -229,7 +233,8 @@ var CloudCmd, Util, DOM, CloudFunc, $;
'height: 0' +
'}' +
'.fancybox-overlay {' +
'background: rgba(255, 255, 255, 0.1)' +
'background: rgba(255, 255, 255, 0.1);' +
'display: block;' +
'}' +
'.fancybox-lock .fancybox-overlay {' +
'overflow-y: hidden' +
@ -244,34 +249,32 @@ var CloudCmd, Util, DOM, CloudFunc, $;
}
function addOverLayClick() {
var NAME = 'fancybox-overlay',
overlay = DOM.getByClass(NAME),
onOverLayClick = function() {
var isCurrent,
position = CloudCmd.MousePosition,
element = document.elementFromPoint(position.x, position.y),
classList = element.classList,
isOverlay = classList.contains(NAME);
if (isOverlay) {
DOM.hide(overlay);
element = DOM.getCurrentByPosition(position);
DOM.show(overlay);
function onOverLayClick(overlay) {
var isCurrent, isFiles, isFilesPassive,
files = Util.slice(Info.files),
filesPassive= Util.slice(Info.filesPassive),
position = CloudCmd.MousePosition,
element = document.elementFromPoint(position.x, position.y),
isOverlay = element === overlay;
if (isOverlay) {
DOM.hide(overlay);
element = DOM.getCurrentByPosition(position);
if (element) {
isFiles = files.indexOf(element) > 0;
isFilesPassive = filesPassive.indexOf(element) > 0;
if (isFiles || isFilesPassive) {
isCurrent = DOM.isCurrentFile(element);
if (element) {
isCurrent = DOM.isCurrentFile(element);
if (!isCurrent)
DOM.setCurrentFile(element);
}
View.hide();
if (!isCurrent)
DOM.setCurrentFile(element);
}
};
if (overlay)
Events.addClick(onOverLayClick, overlay);
}
View.hide();
}
}
function listener(event) {