mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(view) image was loaded twice
This commit is contained in:
parent
91a3c07e16
commit
9fbf14da4d
2 changed files with 25 additions and 4 deletions
|
|
@ -1 +1 @@
|
|||
<img src="{{ src }}" title="{{ name }}" alt="{{ name }}"></img>
|
||||
<img src="{{ src }}" alt="{{ name }}"></img>
|
||||
|
|
@ -13,13 +13,14 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
View = Util.exec.bind(Util),
|
||||
Element, TemplateAudio,
|
||||
Element, TemplateAudio, TemplateImage,
|
||||
Config = {
|
||||
beforeShow : function() {
|
||||
Images.hideLoad();
|
||||
Key.unsetBind();
|
||||
},
|
||||
beforeClose : Key.setBind,
|
||||
fitToView : true,
|
||||
loop : false,
|
||||
openEffect : 'none',
|
||||
closeEffect : 'none',
|
||||
|
|
@ -28,7 +29,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
width : '100%',
|
||||
minWidth : 0,
|
||||
minHeight : 0,
|
||||
padding : 0
|
||||
padding : 0
|
||||
};
|
||||
|
||||
View.show = show;
|
||||
|
|
@ -84,7 +85,9 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
path = CloudFunc.FS + Info.path;
|
||||
|
||||
if (isImage(path))
|
||||
$.fancybox({ href : path }, Config);
|
||||
getImageElement(path, function(element) {
|
||||
$.fancybox.open(element, Config);
|
||||
});
|
||||
else if (isMusic(path))
|
||||
getMusicElement(path, function(element) {
|
||||
$.fancybox.open(element, {
|
||||
|
|
@ -125,6 +128,24 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
return isMatch;
|
||||
}
|
||||
|
||||
function getImageElement(src, callback) {
|
||||
CloudCmd.getTemplate(TemplateImage, 'view/image', function(template) {
|
||||
var rendered, element;
|
||||
|
||||
if (!TemplateImage)
|
||||
TemplateImage = template;
|
||||
|
||||
rendered = Util.render(TemplateImage, {
|
||||
src: src,
|
||||
name: Info.name
|
||||
});
|
||||
|
||||
element = $(rendered);
|
||||
|
||||
Util.exec(callback, element);
|
||||
});
|
||||
}
|
||||
|
||||
function getMusicElement(src, callback) {
|
||||
CloudCmd.getTemplate(TemplateAudio, 'view/audio', function(template) {
|
||||
var rendered, element;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue