From a07dc90ddf27d913b18015e67fdf08e4551d8c2e Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Tue, 21 Aug 2012 10:05:11 +0530 Subject: [PATCH] Make the preferences singleton Renamed $.fn.uls.preferences to mw.uls.preferences since this is not a jquery function, but a singleton object per page. Change-Id: Ie6c37fb321685e927fa5197fa8a53f41bff656ef --- resources/js/ext.uls.preferences.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/js/ext.uls.preferences.js b/resources/js/ext.uls.preferences.js index 80fb01f4..e915da81 100644 --- a/resources/js/ext.uls.preferences.js +++ b/resources/js/ext.uls.preferences.js @@ -108,6 +108,18 @@ } }; - $.fn.uls.preferences = ULSPreferences; + mw.uls = mw.uls || {}; + mw.uls.preferences = function( option ) { + var data = $( 'body' ).data( "preferences" ), + options = typeof option === "object" && option; + + if ( !data ) { + $( 'body' ).data( "preferences", ( data = new ULSPreferences( options ) ) ); + } + if ( typeof option === "string" ) { + data.get(option); + } + return data; + }; }( jQuery, mediaWiki ) );