minor changes

This commit is contained in:
coderaiser 2012-09-07 11:52:32 -04:00
parent 8b507015ab
commit 02bc37cc26
2 changed files with 33 additions and 22 deletions

View file

@ -93,16 +93,19 @@ var CloudCommander, CloudFunc, $;
});
});
FancyBox.loadData = (function(pA){
/* 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 lConfig = this.getConfig();
var lThis = this;
var lLink = pA.href;
/* убираем адрес хоста*/
/* убираем адрес хоста */
lLink = '/' + lLink.replace(document.location.href,'');
if (lLink.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length)
@ -116,17 +119,24 @@ var CloudCommander, CloudFunc, $;
}),
success:function(data, textStatus, jqXHR){
/* if we got json - show it */
if(typeof data === 'object')
data = JSON.stringify(data, null, 4);
$.fancybox('<div id=CloudViewer tabindex=0>' + data + '</div>', lConfig);
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('<div id=CloudViewer tabindex=0>' + pData + '</div>', lConfig);
});
FancyBox.set = (function(){
if(Util.getByClass('fancybox').length)
@ -147,7 +157,7 @@ var CloudCommander, CloudFunc, $;
if(pA.rel)
$.fancybox(lConfig);
else
lThis.loadData(pA);
lThis.loadData(pA, lThis.onDataLoaded);
};
};
@ -180,7 +190,7 @@ var CloudCommander, CloudFunc, $;
if(lA.rel)
$.fancybox.open({ href : lA.href },
lConfig);
else this.loadData(lA);
else this.loadData(lA, this.onDataLoaded);
}
}
else {