var CloudCommander, CloudFunc, $; /* object contains viewer FancyBox * https://github.com/fancyapps/fancyBox */ (function(){ var cloudcmd = CloudCommander; var Util = CloudCommander.Util; var KeyBinding = CloudCommander.KeyBinding; cloudcmd.Viewer = { get: (function(){ return this.FancyBox; }) }; var FancyBox = {}; cloudcmd.Viewer.dir = './lib/client/viewer/'; FancyBox.dir = cloudcmd.Viewer.dir + 'fancybox/'; /* function return configureation * for FancyBox open and * onclick (it shoud be * different objects) */ FancyBox.getConfig = (function(){ return{ /* function do her work * before FauncyBox shows */ beforeShow : function(){ KeyBinding.unSet(); }, afterShow : function(){ var lEditor = Util.getById('CloudViewer'); if(lEditor) lEditor.focus(); }, beforeClose : function(){ KeyBinding.set(); }, openEffect : 'none', closeEffect : 'none', autoSize : false, height : window.innerHeight, helpers : { overlay : { css : { 'background' : 'rgba(255, 255, 255, 0.1)' } } }, padding : 0 }; }); /* function loads css and js of FancyBox * @pParent - this * @pCallBack - executes, when everything loaded */ FancyBox.load = (function(pThis, pCallBack){ var ljsLoad_f = function(){ var lSrc = pThis.dir + 'jquery.fancybox.js'; Util.jsload(lSrc,{ onload: pCallBack }); }; Util.cssSet({id:'viewer', inner : '#CloudViewer{' + 'font-size: 16px;' + 'white-space :pre' + '}' + '#CloudViewer::selection{' + /* 'background: #fe57a1;' 'color: #fff;' */ 'background: #b3d4fc;' + 'text-shadow: none;' + '}' }); var lSrc = pThis.dir +'jquery.fancybox.css'; Util.cssLoad({ src : lSrc, func : { onload: ljsLoad_f } }); }); /* function loads data an put it to pSuccess_f * @pA - link to data * @pSucces_f - function, thet process data (@data) * * Example: loadData('index.html', function(pData){console.log(pData)}); */ FancyBox.loadData = (function(pA, pSuccess_f){ Util.Images.showLoad(); var lThis = this; var lLink = pA.href; /* убираем адрес хоста */ lLink = '/' + lLink.replace(document.location.href,''); if (lLink.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length) lLink = lLink.replace(CloudFunc.NOJS, ''); Util.ajax({ url : lLink, error : (function(jqXHR, textStatus, errorThrown){ lThis.loading = false; return Util.Images.showError(jqXHR, textStatus, errorThrown); }), success:function(data, textStatus, jqXHR){ if(typeof pSuccess_f === 'function') pSuccess_f(data); Util.Images.hideLoad(); } }); }); FancyBox.onDataLoaded = (function(pData){ var lConfig = FancyBox.getConfig(); /* if we got json - show it */ if(typeof pData === 'object') pData = JSON.stringify(pData, null, 4); $.fancybox('