Added strict equality operator to #publisher and #stream keydown event
Added caching of the $container jQuery object Added caching of $controls and $this in the .make_profile_photo click event changed the success callback to use this.src = photo_url; instead of creating a new jQuery object
This commit is contained in:
parent
6474f5c5f3
commit
175e5bdc30
1 changed files with 15 additions and 12 deletions
|
|
@ -49,13 +49,13 @@ $(document).ready(function(){
|
|||
);
|
||||
|
||||
$("#publisher").find("textarea").keydown( function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode === 13) {
|
||||
$(this).closest("form").submit();
|
||||
}
|
||||
});
|
||||
|
||||
$("#stream").delegate("textarea.comment_box", "keydown", function(e){
|
||||
if (e.keyCode == 13) {
|
||||
if (e.keyCode === 13) {
|
||||
$(this).closest("form").submit();
|
||||
}
|
||||
});
|
||||
|
|
@ -101,26 +101,29 @@ $.fn.clearForm = function() {
|
|||
var video_active_container = null;
|
||||
|
||||
function openVideo(type, videoid, link) {
|
||||
var container = document.createElement('div');
|
||||
var container = document.createElement('div'),
|
||||
$container = $(container);
|
||||
if(type == 'youtube.com') {
|
||||
container.innerHTML = '<a href="http://www.youtube.com/watch?v='+videoid+'" target="_blank">Watch this video on Youtube</a><br><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+videoid+'?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoid+'?fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>';
|
||||
$container.html('<a href="http://www.youtube.com/watch?v='+videoid+'" target="_blank">Watch this video on Youtube</a><br><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/'+videoid+'?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+videoid+'?fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');
|
||||
} else {
|
||||
container.innerHTML = 'Invalid videotype <i>'+type+'</i> (ID: '+videoid+')';
|
||||
$container.html('Invalid videotype <i>'+type+'</i> (ID: '+videoid+')');
|
||||
}
|
||||
if(video_active_container != null) {
|
||||
video_active_container.parentNode.removeChild(video_active_container);
|
||||
}
|
||||
video_active_container = container;
|
||||
$(container).hide();
|
||||
$container.hide();
|
||||
link.parentNode.insertBefore(container, this.nextSibling);
|
||||
$(container).slideDown('fast', function() { });
|
||||
link.onclick = function() { $(container).slideToggle('fast', function() { } ); }
|
||||
$container.slideDown('fast', function() { });
|
||||
link.onclick = function() { $container.slideToggle('fast', function() { } ); }
|
||||
}
|
||||
|
||||
$(".make_profile_photo").live("click", function(){
|
||||
var user_id = $(this).closest(".controls").attr('data-actor');
|
||||
person_id = $(this).closest(".controls").attr('data-actor_person');
|
||||
photo_url = $(this).closest(".controls").attr('data-image_url');
|
||||
var $this = $(this),
|
||||
$controls = $this.closest(".controls"),
|
||||
user_id = $controls.attr('data-actor');
|
||||
person_id = $controls.attr('data-actor_person');
|
||||
photo_url = $controls(".controls").attr('data-image_url');
|
||||
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
|
|
@ -128,7 +131,7 @@ $(".make_profile_photo").live("click", function(){
|
|||
data: {"person":{"profile":{ "image_url": photo_url }}},
|
||||
success: function(){
|
||||
$("img[data-person_id='"+ person_id +"']").each( function() {
|
||||
$(this).attr('src', photo_url);
|
||||
this.src = photo_url;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue