From b68a21d4f77f7d05f12bf85068c2d0d1a0ba3a36 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 29 Jan 2010 15:43:37 +0000 Subject: Adds notice author's name to @title in Realtime response --- plugins/Realtime/realtimeupdate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 52151f9de..fb9dcdbfb 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -132,11 +132,11 @@ RealtimeUpdate = { user = data['user']; html = data['html'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); source = data['source'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); - +console.log(data); ni = "
  • "+ "
    "+ ""+ - ""+ + ""+ "\""+user['screen_name']+"\"/"+ ""+user['screen_name']+""+ ""+ -- cgit v1.2.3-54-g00ecf From 9f36c1000136a99f2b96033abcec90d54da4a4f1 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 31 Jan 2010 22:37:22 +0000 Subject: Updated XHR binded events to work better in jQuery 1.4.1. Using .live() for event delegation instead of jQuery.data() and checking to see if an element was previously binded. --- js/util.js | 76 +++++++++++++++++-------------------- plugins/Realtime/realtimeupdate.js | 4 +- plugins/UserFlag/UserFlagPlugin.php | 4 +- 3 files changed, 38 insertions(+), 46 deletions(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/js/util.js b/js/util.js index b864867fd..f2271a03f 100644 --- a/js/util.js +++ b/js/util.js @@ -143,38 +143,32 @@ var SN = { // StatusNet SN.U.Counter(form); }, - FormXHR: function(f) { - if (jQuery.data(f[0], "ElementData") === undefined) { - jQuery.data(f[0], "ElementData", {Bind:'submit'}); - f.bind('submit', function(e) { - form_id = $(this)[0].id; - $.ajax({ - type: 'POST', - dataType: 'xml', - url: $(this)[0].action, - data: $(this).serialize() + '&ajax=1', - beforeSend: function(xhr) { - $('#'+form_id).addClass(SN.C.S.Processing); - $('#'+form_id+' .submit').addClass(SN.C.S.Disabled); - $('#'+form_id+' .submit').attr(SN.C.S.Disabled, SN.C.S.Disabled); - }, - error: function (xhr, textStatus, errorThrown) { - alert(errorThrown || textStatus); - }, - success: function(data, textStatus) { - if (typeof($('form', data)[0]) != 'undefined') { - form_new = document._importNode($('form', data)[0], true); - $('#'+form_id).replaceWith(form_new); - $('#'+form_new.id).each(function() { SN.U.FormXHR($(this)); }); - } - else { - $('#'+form_id).replaceWith(document._importNode($('p', data)[0], true)); - } - } - }); - return false; - }); - } + FormXHR: function(form) { + $.ajax({ + type: 'POST', + dataType: 'xml', + url: form.attr('action'), + data: form.serialize() + '&ajax=1', + beforeSend: function(xhr) { + form + .addClass(SN.C.S.Processing) + .find('.submit') + .addClass(SN.C.S.Disabled) + .attr(SN.C.S.Disabled, SN.C.S.Disabled); + }, + error: function (xhr, textStatus, errorThrown) { + alert(errorThrown || textStatus); + }, + success: function(data, textStatus) { + if (typeof($('form', data)[0]) != 'undefined') { + form_new = document._importNode($('form', data)[0], true); + form.replaceWith(form_new); + } + else { + form.replaceWith(document._importNode($('p', data)[0], true)); + } + } + }); }, FormNoticeXHR: function(form) { @@ -281,7 +275,6 @@ var SN = { // StatusNet $('#'+notice.id).fadeIn(2500); SN.U.NoticeWithAttachment($('#'+notice.id)); SN.U.NoticeReplyTo($('#'+notice.id)); - SN.U.FormXHR($('#'+notice.id+' .form_favor')); } } else { @@ -350,14 +343,15 @@ var SN = { // StatusNet }, NoticeFavor: function() { - $('.form_favor').each(function() { SN.U.FormXHR($(this)); }); - $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); }); + $('.form_favor').live('click', function() { SN.U.FormXHR($(this)); return false; }); + $('.form_disfavor').live('click', function() { SN.U.FormXHR($(this)); return false; }); }, NoticeRepeat: function() { - $('.form_repeat').each(function() { + $('.form_repeat').live('click', function() { SN.U.FormXHR($(this)); SN.U.NoticeRepeatConfirmation($(this)); + return false; }); }, @@ -695,11 +689,11 @@ var SN = { // StatusNet EntityActions: function() { if ($('body.user_in').length > 0) { - $('.form_user_subscribe').each(function() { SN.U.FormXHR($(this)); }); - $('.form_user_unsubscribe').each(function() { SN.U.FormXHR($(this)); }); - $('.form_group_join').each(function() { SN.U.FormXHR($(this)); }); - $('.form_group_leave').each(function() { SN.U.FormXHR($(this)); }); - $('.form_user_nudge').each(function() { SN.U.FormXHR($(this)); }); + $('.form_user_subscribe').live('click', function() { SN.U.FormXHR($(this)); return false; }); + $('.form_user_unsubscribe').live('click', function() { SN.U.FormXHR($(this)); return false; }); + $('.form_group_join').live('click', function() { SN.U.FormXHR($(this)); return false; }); + $('.form_group_leave').live('click', function() { SN.U.FormXHR($(this)); return false; }); + $('.form_user_nudge').live('click', function() { SN.U.FormXHR($(this)); return false; }); SN.U.NewDirectMessage(); } diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index fb9dcdbfb..862c8b086 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -95,9 +95,7 @@ RealtimeUpdate = { $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(1000); - SN.U.FormXHR($('#'+noticeItemID+' .form_favor')); SN.U.NoticeReplyTo($('#'+noticeItemID)); - SN.U.FormXHR($('#'+noticeItemID+' .form_repeat')); SN.U.NoticeWithAttachment($('#'+noticeItemID)); }, @@ -132,7 +130,7 @@ RealtimeUpdate = { user = data['user']; html = data['html'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); source = data['source'].replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/&/g,'&'); -console.log(data); + ni = "
  • "+ "
    "+ ""+ diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index a33869c19..8728e5703 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -208,8 +208,8 @@ class UserFlagPlugin extends Plugin function onEndShowScripts($action) { $action->inlineScript('if ($(".form_entity_flag").length > 0) { '. - 'SN.U.FormXHR($(".form_entity_flag")); '. - '}'); + '$(".form_entity_flag").bind("click", function() {'. + 'SN.U.FormXHR($(this)); return false; }); }'); return true; } -- cgit v1.2.3-54-g00ecf From 0c838f82b0aff614822674de8accd4542a6a5c9e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 31 Jan 2010 23:57:35 +0100 Subject: Added missing concat of
  • in Realtime response --- plugins/Realtime/realtimeupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/Realtime/realtimeupdate.js') diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 862c8b086..7adea45a0 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -178,7 +178,7 @@ RealtimeUpdate = { ni = ni+""; - ""; + ni = ni+""; return ni; }, -- cgit v1.2.3-54-g00ecf