Fixed a bug in the browser template.

This commit is contained in:
Raoul Snyman 2010-06-06 22:10:03 +02:00
parent e3836b5a41
commit 5268a19a48
3 changed files with 9 additions and 5 deletions

View File

@ -46,17 +46,16 @@ ScribeEngine.Namespace.create("ScribeEngine.Media", {
.append( .append(
$("<a>").attr("href", "#").attr("class", "file") $("<a>").attr("href", "#").attr("class", "file")
.html("<img src=\""+ file.type +"\" />") .html("<img src=\""+ file.type +"\" />")
.click(ScribeEngine.Media.selectFile)
) )
.append( .append(
$("<a>").attr("href", "#").attr("class", "caption") $("<a>").attr("href", "#").attr("class", "caption")
.attr("title", file.name).text(file.name) .attr("title", file.name).text(file.name)
.click(ScribeEngine.Media.selectFile)
) )
); );
}); });
} }
); );
return false;
}, },
selectFile: function (e) selectFile: function (e)
{ {
@ -67,10 +66,12 @@ ScribeEngine.Namespace.create("ScribeEngine.Media", {
} }
li.parent().children("li").children(".selected").removeClass("selected"); li.parent().children("li").children(".selected").removeClass("selected");
li.children("a").addClass("selected").blur(); li.children("a").addClass("selected").blur();
return false;
} }
}); });
ScribeEngine.Events.load(function () { ScribeEngine.Events.load(function () {
ScribeEngine.Events.click("#new-directory", ScribeEngine.Media.newDirectory); ScribeEngine.Events.click("#new-directory", ScribeEngine.Media.newDirectory);
ScribeEngine.Events.click("#file-select", ScribeEngine.Media.closeWindow); ScribeEngine.Events.click("#file-select", ScribeEngine.Media.closeWindow);
ScribeEngine.Events.liveClick("#file-list > ul > li > a", ScribeEngine.Media.selectFile);
}); });

View File

@ -90,6 +90,9 @@ ScribeEngine.Namespace.create("ScribeEngine.Events", {
keypress: function (selector, func) { keypress: function (selector, func) {
$(selector).bind("keypress", func); $(selector).bind("keypress", func);
}, },
liveClick: function (selector, func) {
$(selector).live("click", func);
},
getElement: function(event) { getElement: function(event) {
var targ; var targ;
if (!event) { if (!event) {

View File

@ -31,11 +31,11 @@
<ul> <ul>
% for file in c.files: % for file in c.files:
<li> <li>
<a href="#" class="file"><img src="${file[u'type']}" /></div> <a href="#" class="file"><img src="${file[u'type']}" /></a>
% if len(file[u'name']) > 15: % if len(file[u'name']) > 15:
<a href="#" class="caption" title="${file[u'name']}">${file[u'name'][:12]}...</div> <a href="#" class="caption" title="${file[u'name']}">${file[u'name'][:12]}...</a>
% else: % else:
<a href="#" class="caption">${file[u'name']}</div> <a href="#" class="caption">${file[u'name']}</a>
% endif % endif
</li> </li>
% endfor % endfor