diff --git a/lib/client/view.js b/lib/client/view.js index 7832a556..2a76c8f8 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -19,27 +19,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; Images.hideLoad(); Key.unsetBind(); }, - beforeClose : function() { - var element, isCurrent, - overlay = DOM.getByClass('fancybox-overlay'), - inner = DOM.getByClass('fancybox-inner', overlay), - heightView = $(inner).height(), - heightWin = window.screen.height, - heightDiff = heightWin / heightView, - position = CloudCmd.MousePosition, - MAX_DIFF = 1.5; - - if (heightDiff > MAX_DIFF) { - DOM.hide(overlay); - element = DOM.getCurrentByPosition(position); - isCurrent = DOM.isCurrentFile(element); - - if (!isCurrent) - DOM.setCurrentFile(element); - } - - Key.setBind(); - }, + afterShow : onAfterShow, + beforeClose : Key.setBind, fitToView : true, loop : false, openEffect : 'none', @@ -107,14 +88,14 @@ var CloudCmd, Util, DOM, CloudFunc, $; if (isImage(path)) { config = Util.copyObj({ - autoSize: true + autoSize : true }, Config); $.fancybox.open(path, config); } else if (isMusic(path)) getMusicElement(path, function(element) { $.fancybox.open(element, { - beforeShow: musicBeforeShow + beforeShow : musicBeforeShow }); }); else @@ -187,7 +168,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; var dir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', files = [ dir + 'jquery.fancybox.css', - dir + 'jquery.fancybox.js' + //dir + 'jquery.fancybox.js' + '//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js' ]; Util.time(Name + ' load'); @@ -222,11 +204,40 @@ var CloudCmd, Util, DOM, CloudFunc, $; '}' + '.fancybox-lock .fancybox-overlay {' + 'overflow-y: hidden' + + '}' + + '.fancybox-wrap {' + + /* when search element with + * document.elementFromPoint + */ + 'z-index: 1' + '}' }); } + function onAfterShow() { + var overlay = DOM.getByClass('fancybox-overlay'), + onOverLayClick = function() { + var isCurrent, + position = CloudCmd.MousePosition, + element = document.elementFromPoint(position.x, position.y), + classList = element.classList, + isInner = classList.contains('fancybox-inner'); + + if (!isInner) { + DOM.hide(overlay); + element = DOM.getCurrentByPosition(position); + isCurrent = DOM.isCurrentFile(element); + + if (!isCurrent) + DOM.setCurrentFile(element); + } + }; + + if (overlay) + Events.addClick(onOverLayClick, overlay); + } + function listener(event) { var keyCode = event.keyCode, ESC = Key.ESC; @@ -235,7 +246,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; hide(); } - init(); return View;