var CloudCommander, CloudFunc, $; /* object contains viewer FancyBox * https://github.com/fancyapps/fancyBox */ (function(){ CloudCommander.Viewer = { get: (function(){ return this.FancyBox; }) }; CloudCommander.Viewer.FancyBox = {}; var Util = CloudCommander.Util; CloudCommander.Viewer.dir = './lib/client/viewer/'; CloudCommander.Viewer.FancyBox.dir = CloudCommander.Viewer.dir + 'fancybox/'; /* function return configureation * for FancyBox open and * onclick (it shoud be * different objects) */ CloudCommander.Viewer.FancyBox.getConfig = (function(){ return{ /* function do her work * before FauncyBox shows */ beforeShow : function(){ CloudCommander.keyBinded = false; }, afterShow : function(){ var lEditor = Util.getById('CloudViewer'); if(lEditor) lEditor.focus(); }, beforeClose : function(){ CloudCommander.keyBinded = true; }, openEffect : 'none', closeEffect : 'none', autoSize : false, height : window.innerHeight, helpers : { overlay : { opacity: 0.1, css : { 'background-color' : '#fff' } } }, padding : 0 }; }); /* function loads css and js of FancyBox * @pParent - this * @pCallBack - executes, when everything loaded */ CloudCommander.Viewer.FancyBox.load = (function(pThis, pCallBack){ var ljsLoad_f = function(){ var lSrc = pThis.dir + 'jquery.fancybox.pack.js'; Util.jsload(lSrc,{ onload: pCallBack }); }; Util.cssSet({id:'viewer', inner : '#CloudViewer{' + 'font-size: 16px;' + 'white-space :pre' + '}' + '#CloudViewer::selection{' + 'background: #fe57a1;' + 'color: #fff;' + 'text-shadow: none;' + '}' }); var lSrc = pThis.dir +'jquery.fancybox.pack.css'; Util.cssLoad({ src : lSrc, func : { onload: ljsLoad_f } }); }); CloudCommander.Viewer.FancyBox.loadData = (function(pA){ var lThis = this; var lConfig = this.getConfig(); Util.Images.showLoad(); 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 we got json - show it */ if(typeof data === 'object') data = JSON.stringify(data, null, 4); $.fancybox('