From 5014b748e486f46a8653d1609479f8f64dc24722 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 18 Nov 2009 15:41:07 +0000 Subject: [PATCH] Added play/pause button for realtime notices. While on pause, it will store the notices and on play it will add them to the notice list --- plugins/Realtime/RealtimePlugin.php | 4 +- plugins/Realtime/icon_pause.gif | Bin 0 -> 75 bytes plugins/Realtime/icon_play.gif | Bin 0 -> 75 bytes plugins/Realtime/realtimeupdate.js | 91 ++++++++++++++++++++++++++-- 4 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 plugins/Realtime/icon_pause.gif create mode 100644 plugins/Realtime/icon_play.gif diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 0c7c1240c3..6d59bd1b12 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -101,8 +101,8 @@ class RealtimePlugin extends Plugin $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; } else { - $iconurl = common_path('plugins/Realtime/icon_external.gif'); - $realtimeUI = ' RealtimeUpdate.addPopup("'.$url.'", "'.$timeline.'", "'. $iconurl .'");'; + $pluginPath = common_path('plugins/Realtime/'); + $realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");'; } $action->elementStart('script', array('type' => 'text/javascript')); diff --git a/plugins/Realtime/icon_pause.gif b/plugins/Realtime/icon_pause.gif new file mode 100644 index 0000000000000000000000000000000000000000..ced0b6440c8fe67e6d530103d8ac1aa4b70453ca GIT binary patch literal 75 zcmZ?wbhEHb6krfwn8?KN|NsB^DFQ%}fq_BsCkrD30~3P|kPVa-0J3F5`erVB%fEOI b!yKu?3;xB=BLil1-fvm9>WGgMBZD;nY2_H} literal 0 HcmV?d00001 diff --git a/plugins/Realtime/icon_play.gif b/plugins/Realtime/icon_play.gif new file mode 100644 index 0000000000000000000000000000000000000000..794ec85b6ac815e0ca134bbc0e81872ded44cc8e GIT binary patch literal 75 zcmZ?wbhEHb6krfwn8?KN|NsB^DFQ%}fq_BsCkrD30~3P|kPVa-0J3F5`erVB%fFa8 bL@rA8T*2p;t_wRNm$oj;IuPN+$Y2csUhNo3 literal 0 HcmV?d00001 diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js index 6404cf8965..4352b45d99 100644 --- a/plugins/Realtime/realtimeupdate.js +++ b/plugins/Realtime/realtimeupdate.js @@ -37,6 +37,8 @@ RealtimeUpdate = { _maxnotices: 50, _windowhasfocus: true, _documenttitle: '', + _paused:false, + _queuedNotices:[], init: function(userid, replyurl, favorurl, deleteurl) { @@ -71,12 +73,16 @@ RealtimeUpdate = { return; } - RealtimeUpdate.purgeLastNoticeItem(); + if (RealtimeUpdate._paused === false) { + RealtimeUpdate.purgeLastNoticeItem(); - RealtimeUpdate.insertNoticeItem(data); - - RealtimeUpdate.updateWindowCounter(); + RealtimeUpdate.insertNoticeItem(data); + RealtimeUpdate.updateWindowCounter(); + } + else { + RealtimeUpdate._queuedNotices.push(data); + } }, insertNoticeItem: function(data) { @@ -183,7 +189,80 @@ RealtimeUpdate = { return dl; }, - addPopup: function(url, timeline, iconurl) + initActions: function(url, timeline, path) + { + var NP = $('#notices_primary'); + NP.prepend(''); + + RealtimeUpdate._pluginPath = path; + + RealtimeUpdate.initPlayPause(); + RealtimeUpdate.initAddPopup(url, timeline, RealtimeUpdate._pluginPath); + }, + + initPlayPause: function() + { + RealtimeUpdate.showPause(); + }, + + showPause: function() + { + RT_PP = $('#realtime_pauseplay'); + RT_PP.empty(); + RT_PP.append(''); + + RT_P = $('#realtime_pause'); + $('#realtime_pause').css({ + 'background':'url('+RealtimeUpdate._pluginPath+'icon_pause.gif) no-repeat 47% 47%', + 'width':'16px', + 'height':'16px', + 'text-indent':'-9999px', + 'border':'none', + 'cursor':'pointer' + }); + RT_P.bind('click', function() { + RealtimeUpdate._paused = true; + + RealtimeUpdate.showPlay(); + return false; + }); + }, + + showPlay: function() + { + RT_PP = $('#realtime_pauseplay'); + RT_PP.empty(); + RT_PP.append(''); + + RT_P = $('#realtime_play'); + RT_P.css({ + 'background':'url('+RealtimeUpdate._pluginPath+'icon_play.gif) no-repeat 47% 47%', + 'width':'16px', + 'height':'16px', + 'text-indent':'-9999px', + 'border':'none', + 'cursor':'pointer' + }); + RT_P.bind('click', function() { + RealtimeUpdate._paused = false; + + RealtimeUpdate.showPause(); + + RealtimeUpdate.showQueuedNotices(); + + return false; + }); + }, + + showQueuedNotices: function() { + $.each(RealtimeUpdate._queuedNotices, function(i, n) { + RealtimeUpdate.insertNoticeItem(n); + }); + + RealtimeUpdate._queuedNotices = []; + }, + + initAddPopup: function(url, timeline, path) { var NP = $('#notices_primary'); NP.css({'position':'relative'}); @@ -192,7 +271,7 @@ RealtimeUpdate = { var RT = $('#realtime_timeline'); RT.css({ 'margin':'0 0 11px 0', - 'background':'transparent url('+ iconurl + ') no-repeat 0 30%', + 'background':'transparent url('+ path + 'icon_external.gif) no-repeat 0 30%', 'padding':'0 0 0 20px', 'display':'block', 'position':'absolute', -- 2.39.5