Remove the regionfilter module

It has lot of redundant and unused code used when we had the map.
Removing it. No change in functionality is expected

Change-Id: I278ef63b7756b5061c0b6638ba4e7b7deebf5a0d
This commit is contained in:
Santhosh Thottingal
2016-05-09 17:03:37 +05:30
parent 29f28a1f50
commit 11b87cb5be
4 changed files with 31 additions and 177 deletions

View File

@@ -26,7 +26,6 @@
<script src="../src/jquery.uls.data.utils.js"></script>
<script src="../src/jquery.uls.lcd.js"></script>
<script src="../src/jquery.uls.languagefilter.js"></script>
<script src="../src/jquery.uls.regionfilter.js"></script>
<script src="../src/jquery.uls.core.js"></script>
<script>
$( document ).ready( function() {

View File

@@ -221,8 +221,7 @@
* Bind the UI elements with their event listeners
*/
listen: function () {
var lcd, columnsOptions, languagesCount,
uls = this;
var lcd, columnsOptions, languagesCount;
columnsOptions = {
wide: 4,
@@ -265,28 +264,6 @@
onSelect: $.proxy( this.select, this )
} );
// Create region selectors, one per region
this.regionFilter = new $.uls.RegionSelector( {
$target: lcd,
languages: this.languages,
success: function ( regionfilter ) {
// Deactivate search filtering
uls.$languageFilter.languagefilter( 'deactivate' );
// If it is the WW region, show the quicklist
if ( regionfilter.regionGroup === 1 ) {
lcd.quicklist();
}
// Show 'results view' if we are in no results mode
uls.success();
},
noresults: function () {
uls.$languageFilter.languagefilter( 'clear' );
}
} );
this.$languageFilter.on( 'searchclear.uls', $.proxy( this.regionFilter.show, this.regionFilter ) );
this.$languageFilter.on( 'noresults.uls', $.proxy( this.noresults, this ) );
this.$languageFilter.on( 'resultsfound.uls', $.proxy( this.success, this ) );
@@ -299,7 +276,6 @@
*/
select: function ( langCode ) {
this.hide();
this.$languageFilter.trigger( 'searchclear' );
if ( this.options.onSelect ) {
this.options.onSelect.call( this, langCode );
}

View File

@@ -35,7 +35,7 @@
this.$suggestion = this.$element.parents().find( '#' + this.$element.data( 'suggestion' ) );
this.$clear = this.$element.parents().find( '#' + this.$element.data( 'clear' ) );
this.selectedLanguage = null;
this.init();
this.listen();
};
@@ -49,6 +49,10 @@
}() );
LanguageFilter.prototype = {
init: function () {
this.search();
},
listen: function () {
this.$element.on( 'keypress', $.proxy( this.keyup, this ) )
.on( 'keyup', $.proxy( this.keyup, this ) );
@@ -143,7 +147,7 @@
*/
clear: function () {
this.deactivate();
this.$element.trigger( 'searchclear.uls' );
this.search();
},
/**
@@ -163,12 +167,16 @@
},
search: function () {
var langCode,
var langCode, scriptGroup, langNum, languagesInScript,
languages = $.uls.data.getLanguagesByScriptGroup( this.options.languages ),
query = $.trim( this.$element.val() );
this.resultCount = 0;
for ( langCode in this.options.languages ) {
for ( scriptGroup in languages ) {
languagesInScript = languages[ scriptGroup ];
languagesInScript.sort( $.uls.data.sortByAutonym );
for ( langNum = 0; langNum < languagesInScript.length; langNum++ ) {
langCode = languagesInScript[ langNum ];
if ( query === '' || this.filter( langCode, query ) ) {
if ( this.resultCount === 0 ) {
// Autofill the first result.
@@ -191,6 +199,7 @@
} else {
this.resultHandler( query );
}
}
},
searchAPI: function ( query ) {

View File

@@ -1,130 +0,0 @@
/**
* Region Filter for ULS
*
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
* Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other
* contributors. See CREDITS for a list.
*
* UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't
* have to do anything special to choose one license or the other and you don't
* have to notify anyone which license you are using. You are free to use
* UniversalLanguageSelector in commercial projects as long as the copyright
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
*
* @file
* @ingroup Extensions
* @licence GNU General Public Licence 2.0 or later
* @licence MIT License
*/
( function ( $ ) {
'use strict';
/**
* Region selector is a language selector based on regions.
* that defines the regiongroup for the selector.
*/
var RegionSelector = function ( options ) {
this.options = options;
this.regions = [];
this.cache = null;
this.init();
};
RegionSelector.prototype = {
constructor: RegionSelector,
init: function () {
this.regions = this.options.regions || $.uls.data.getAllRegions();
this.show();
},
test: function ( langCode ) {
var region, i,
langRegions = $.uls.data.getRegions( langCode );
for ( i = 0; i < this.regions.length; i++ ) {
region = this.regions[ i ];
if ( $.inArray( region, langRegions ) >= 0 ) {
this.render( langCode, region );
this.cache[ langCode ] = region;
return;
}
}
},
show: function () {
var result, languagesByScriptGroup, scriptGroup, languages, i,
$target = this.options.$target && this.options.$target.$target,
$parent = $target && $target.parent(),
$prev = $target && $target.prev();
if ( $target && $parent ) {
// Avoid reflows while adding new elements to the list
// Use .detach() to keep jQuery events and data associated with elements
$target.detach();
}
if ( this.cache ) {
// If the result cache is present, render the results from there.
//noinspection JSUnusedAssignment
result = null;
for ( result in this.cache ) {
this.render( result, this.cache[ result ] );
}
} else {
this.cache = {};
// Get the languages grouped by script group
languagesByScriptGroup = $.uls.data.getLanguagesByScriptGroup( this.options.languages );
// Make sure that we go by the original order
// of script groups
for ( scriptGroup in $.uls.data.scriptgroups ) {
// Get the languages for the script group
languages = languagesByScriptGroup[ scriptGroup ];
// It's possible that some script groups are missing
if ( !languages ) {
continue;
}
// Sort it based on autonym
languages.sort( $.uls.data.sortByAutonym );
for ( i = 0; i < languages.length; i++ ) {
// Check whether it belongs to the region
this.test( languages[ i ] );
}
}
}
if ( $target && $parent ) {
// Restore the element to where we removed it from
if ( $prev ) {
$prev.after( $target );
} else {
$parent.append( $target );
}
}
if ( this.options.success ) {
this.options.success( this );
}
},
render: function ( langCode, region ) {
var $target = this.options.$target;
if ( !$target ) {
return;
}
$target.append( langCode, region );
}
};
$.uls.RegionSelector = RegionSelector;
}( jQuery ) );