Tweichart has uploaded a new change for review.
https://gerrit.wikimedia.org/r/151818
Change subject: Shoutbox Trigger + Counter
......................................................................
Shoutbox Trigger + Counter
* added a sup counter element to the shoutbox tab to display the shouts beeing
made in the shoutbox
* added 4 new hooks before/after update/archive
* some cc
Change-Id: Iabd571f95874a18f17c6ee5c0bfaab9de5fc5653
---
M ShoutBox/resources/bluespice.shoutBox.css
M ShoutBox/resources/bluespice.shoutBox.js
2 files changed, 77 insertions(+), 54 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions
refs/changes/18/151818/1
diff --git a/ShoutBox/resources/bluespice.shoutBox.css
b/ShoutBox/resources/bluespice.shoutBox.css
index 2e038e4..c5308b1 100644
--- a/ShoutBox/resources/bluespice.shoutBox.css
+++ b/ShoutBox/resources/bluespice.shoutBox.css
@@ -108,4 +108,8 @@
margin-right:10px;
font-size:10px;
color:#999999;
+}
+
+.bs-sb-tab-counter{
+ margin-left: 5px;
}
\ No newline at end of file
diff --git a/ShoutBox/resources/bluespice.shoutBox.js
b/ShoutBox/resources/bluespice.shoutBox.js
index 500d622..54faff5 100644
--- a/ShoutBox/resources/bluespice.shoutBox.js
+++ b/ShoutBox/resources/bluespice.shoutBox.js
@@ -60,40 +60,55 @@
*/
characterCounter: null,
/**
+ * Reference to the jQuery Tab
+ * @var jQuery
+ */
+ shoutboxTab: null,
+ /**
+ * Sup Element for the ShoutboxTab
+ * @var jQuery
+ */
+ shoutboxTabCounter: null,
+ /**
* Load and display a current list of shouts from server
* @param sblimit int Maximum number of shouts before more link is
displayed
*/
- updateShoutbox: function(sblimit) {
+ updateShoutbox: function( sblimit ) {
if ( typeof sblimit == 'undefined' )
sblimit = 0;
+ $( document ).trigger( "onBsShoutboxBeforeUpdated", [
BsShoutBox ] );
BsShoutBox.ajaxLoader.fadeIn();
this.msgList.load(
- bs.util.getAjaxDispatcherUrl( 'ShoutBox::getShouts', [
wgArticleId, sblimit ] ),
- function( data ) {
- BsShoutBox.msgList.slideDown();
- BsShoutBox.btnSend.blur().removeAttr(
'disabled' ); //reactivate the send button
- BsShoutBox.textField.val(
BsShoutBox.defaultMessage );
- BsShoutBox.textField.blur().removeAttr(
'disabled' );
- BsShoutBox.ajaxLoader.fadeOut();
- BsShoutBox.characterCounter.text( mw.message(
'bs-shoutbox-charactersleft', BsShoutBox.textField.attr( 'maxlength' ) ).text()
);
- }
+ bs.util.getAjaxDispatcherUrl(
'ShoutBox::getShouts', [ wgArticleId, sblimit ] ),
+ function( data ) {
+ BsShoutBox.msgList.slideDown();
+ BsShoutBox.btnSend.blur().removeAttr(
'disabled' ); //reactivate the send button
+ BsShoutBox.textField.val(
BsShoutBox.defaultMessage );
+ BsShoutBox.textField.blur().removeAttr(
'disabled' );
+ BsShoutBox.ajaxLoader.fadeOut();
+ BsShoutBox.characterCounter.text(
mw.message( 'bs-shoutbox-charactersleft', BsShoutBox.textField.attr(
'maxlength' ) ).text() );
+ BsShoutBox.shoutboxTabCounter.text( $(
"#bs-sb-content li" ).length );
+ $( document ).trigger(
"onBsShoutboxAfterUpdated", [ BsShoutBox ] );
+ }
);
},
archiveEntry: function( iShoutID ) {
$( "#bs-sb-error" ).empty();
+ $( document ).trigger( "onBsShoutboxBeforeArchived", [
BsShoutBox ] );
BsShoutBox.ajaxLoader.fadeIn();
$.post(
- bs.util.getAjaxDispatcherUrl( 'ShoutBox::archiveShout',
[ iShoutID, wgArticleId ] ),
- function( data ) {
- BsShoutBox.updateShoutbox();
-
$("#bs-sb-error").html(data).fadeIn().delay("1500").fadeOut();
- }
+ bs.util.getAjaxDispatcherUrl(
'ShoutBox::archiveShout', [ iShoutID, wgArticleId ] ),
+ function( data ) {
+ BsShoutBox.updateShoutbox();
+ $( "#bs-sb-error" ).html( data
).fadeIn().delay( "1500" ).fadeOut();
+ $( document ).trigger(
"onBsShoutboxAfterArchived", [ BsShoutBox ] );
+ }
);
}
};
-mw.loader.using('ext.bluespice', function() {
+mw.loader.using( 'ext.bluespice', function() {
$( "#bs-sb-content" ).before( $( "<div id='bs-sb-error'></div>" ) );
BsShoutBox.textField = $( "#bs-sb-message" );
BsShoutBox.btnSend = $( "#bs-sb-send" );
@@ -101,75 +116,79 @@
BsShoutBox.ajaxLoader = $( "#bs-sb-loading" );
BsShoutBox.defaultMessage = BsShoutBox.textField.val();
BsShoutBox.characterCounter = $( '#bs-sb-charactercounter' );
+ BsShoutBox.shoutboxTab = $( "#bs-data-after-content-tabs
a[href='#bs-shoutbox']" );
+ BsShoutBox.shoutboxTabCounter = $( "<sup class='bs-sb-tab-counter'>" );
+ if ( typeof ( BsShoutBox.shoutboxTab ) !== "undefined" )
+ BsShoutBox.shoutboxTab.after( BsShoutBox.shoutboxTabCounter );
BsShoutBox.updateShoutbox();
//HTML5 like placeholder effect.
BsShoutBox.textField
- .focus(function() {
- if ($(this).val() == BsShoutBox.defaultMessage)
- $(this).val('');
+ .focus( function() {
+ if ( $( this ).val() ==
BsShoutBox.defaultMessage )
+ $( this ).val( '' );
}
- ).blur(function() {
- if ($(this).val() == '') {
- $(this).val(BsShoutBox.defaultMessage);
+ ).blur( function() {
+ if ( $( this ).val() == '' ) {
+ $( this ).val( BsShoutBox.defaultMessage );
}
- });
+ } );
- BsShoutBox.textField.bind("input propertychange", function (e) {
+ BsShoutBox.textField.bind( "input propertychange", function( e ) {
var currCharLen = $( this ).attr( 'maxlength' ) - $( this
).val().length;
BsShoutBox.characterCounter.text( mw.message(
'bs-shoutbox-charactersleft', currCharLen ).text() );
- });
+ } );
$( "#bs-sb-form" ).submit( function() {
var sMessage = BsShoutBox.textField.val();
if ( sMessage == '' || sMessage == BsShoutBox.defaultMessage ) {
bs.util.alert(
- 'bs-shoutbox-alert',
- {
- textMsg: 'bs-shoutbox-entermessage'
- }
+ 'bs-shoutbox-alert',
+ {
+ textMsg:
'bs-shoutbox-entermessage'
+ }
);
return false;
}
//we deactivate submit button while sending
- BsShoutBox.btnSend.blur().attr('disabled', 'disabled');
- BsShoutBox.textField.blur().attr('disabled', 'disabled');
+ BsShoutBox.btnSend.blur().attr( 'disabled', 'disabled' );
+ BsShoutBox.textField.blur().attr( 'disabled', 'disabled' );
$.post(
- bs.util.getAjaxDispatcherUrl( 'ShoutBox::insertShout',
[ wgArticleId, sMessage ] ),
- function( data ) {
- var responseObj = $.parseJSON( data );
- if ( responseObj.success === false ) {
- bs.util.alert(
- 'bs-shoutbox-alert',
- {
- textMsg: responseObj.msg
- }
- );
+ bs.util.getAjaxDispatcherUrl(
'ShoutBox::insertShout', [ wgArticleId, sMessage ] ),
+ function( data ) {
+ var responseObj = $.parseJSON( data );
+ if ( responseObj.success === false ) {
+ bs.util.alert(
+
'bs-shoutbox-alert',
+ {
+
textMsg: responseObj.msg
+ }
+ );
+ }
+ BsShoutBox.updateShoutbox();
}
- BsShoutBox.updateShoutbox();
- }
);
//we prevent the refresh of the page after submitting the form
return false;
- });
+ } );
- $(document).on( 'click', '.bs-sb-archive', function() {
- var iShoutID = $(this).parent().attr('id');
+ $( document ).on( 'click', '.bs-sb-archive', function() {
+ var iShoutID = $( this ).parent().attr( 'id' );
bs.util.confirm(
- 'bs-shoutbox-confirm',
- {
- titleMsg: 'bs-shoutbox-confirm-title',
- textMsg: 'bs-shoutbox-confirm-text'
- },
+ 'bs-shoutbox-confirm',
+ {
+ titleMsg: 'bs-shoutbox-confirm-title',
+ textMsg: 'bs-shoutbox-confirm-text'
+ },
{
ok: function() {
BsShoutBox.archiveEntry( iShoutID.replace(
/bs-sb-/, "" ) );
}
- });
- });
-});
\ No newline at end of file
+ } );
+ } );
+} );
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/151818
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iabd571f95874a18f17c6ee5c0bfaab9de5fc5653
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Tweichart <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits