http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98080
Revision: 98080
Author: catrope
Date: 2011-09-25 19:58:16 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
MoodBar: Write the filter state to a cookie and read it on page load. This
still needs AJAX filtering to be implemented and the on-page-load state to
actually take effect.
Modified Paths:
--------------
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
Modified:
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
===================================================================
---
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
2011-09-25 19:40:13 UTC (rev 98079)
+++
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
2011-09-25 19:58:16 UTC (rev 98080)
@@ -1,10 +1,48 @@
jQuery( function( $ ) {
+ function getSelectedTypes() {
+ var types = [];
+ $( '#fbd-filters-type-praise, #fbd-filters-type-confusion,
#fbd-filters-type-issues' ).each( function() {
+ if ( $(this).prop( 'checked' ) ) {
+ types.push( $(this).val() );
+ }
+ } );
+ return types;
+ }
+
+ function setCookies() {
+ $.cookie( 'moodbar-feedback-types', getSelectedTypes().join(
'|' ), { 'path': '/', 'expires': 7 } );
+ $.cookie( 'moodbar-feedback-username', $(
'#fbd-filters-username' ).val(), { 'path': '/', 'expires': 7 } );
+ }
+
+ function loadFromCookies() {
+ var cookieTypes = $.cookie( 'moodbar-feedback-types' );
+ $username = $( '#fbd-filters-username' );
+ if ( $username.val() == '' ) {
+ var cookieUsername = $.cookie(
'moodbar-feedback-username' );
+ if ( cookieUsername != '' ) {
+ $username.val( cookieUsername );
+ }
+ }
+
+ if ( cookieTypes ) {
+ cookieTypes = '|' + cookieTypes;
+ $( '#fbd-filters-type-praise,
#fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() {
+ if ( !$(this).prop( 'checked' ) &&
cookieTypes.indexOf( '|' + $(this).val() ) != -1 ) {
+ $(this).prop( 'checked', true );
+ }
+ } );
+ }
+ }
+
+ $( '#fbd-filters-set' ).click( setCookies );
+ loadFromCookies();
+
$( '#fbd-list-more').children( 'a' ).click( function( e ) {
e.preventDefault();
var limit = 20,
username = $( '#fbd-filters-username' ).val(),
- types = [],
+ types = getSelectedTypes(),
reqData;
// Hide the "More" link and put in a spinner
@@ -22,11 +60,6 @@
'mbclimit': limit + 2, // we drop the first and last
result
'mbccontinue': $( '#fbd-list').find( 'li:last' ).data(
'mbccontinue' )
};
- $( '#fbd-filters-type-praise, #fbd-filters-type-confusion,
#fbd-filters-type-issues' ).each( function() {
- if ( $(this).prop( 'checked' ) ) {
- types.push( $(this).val() );
- }
- } );
if ( types.length ) {
reqData['mbctype'] = types.join( '|' );
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs