added loadData function

This commit is contained in:
coderaiser 2012-08-17 05:22:21 -04:00
parent 0498a9bdd5
commit e3dfb6b3b9

View file

@ -66,6 +66,28 @@ CloudCommander.Viewer.FancyBox.load = (function(pParent, pCallBack){
}();
});
CloudCommander.Viewer.FancyBox.loadData = (function(pA){
var lThis = this;
var lConfig = this.getConfig();
$.ajax({
url : pA.href,
error : (function(jqXHR, textStatus, errorThrown){
lThis.loading = false;
return lThis.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);
$.funcybox('<div>' + data + '</div>', lConfig);
lThis.Images.hideLoad();
}
});
});
CloudCommander.Viewer.FancyBox.set = (function(){
if(this.getByClass('fancybox').length)
return;
@ -78,27 +100,26 @@ CloudCommander.Viewer.FancyBox.set = (function(){
var lThis = this;
var lDblClick_f = function(pHref, pIsImg){
var lDblClick_f = function(pA){
return function(){
var lConfig = lThis.getConfig();
lConfig.href = pHref;
if(pIsImg)
lConfig.href = pA.href;
if(pA.href)
$.fancybox(lConfig);
else lThis.loadData(pA);
};
};
/* first two is not files nor folders*/
for (var i=2; i < lA.length; i++) {
var lIsImg_b = false;
var lName = lA[i].title || lA[i].textContent;
lA[i].className = 'fancybox';
if(CloudFunc.checkExtension(lName, ['png','jpg', 'gif','ico'])){
lA[i].rel = 'gallery';
var lIsImg_b = true;
}
lA[i].ondblclick = lDblClick_f(lA[i].href, lIsImg_b);
lA[i].ondblclick = lDblClick_f(lA);
}
}catch(pError){
@ -115,9 +136,12 @@ CloudCommander.Viewer.FancyBox.show = (function(pParent){
var lA = this.getByClass('fancybox', lCurrent);
var lConfig = this.getConfig();
lA.length &&
$.fancybox.open({ href : lA[0].href },
lConfig);
if(lA.length){
if(lA.rel)
$.fancybox.open({ href : lA[0].href },
lConfig);
else this.loadData(lA);
}
});
CloudCommander.Viewer.Keys = (function(){