Update jquery.uls and make it more modular
jquery.uls RL module split to * jquery.uls (language selector UI/UX) * jquery.uls.grid (Foundation grid framework) * jquery.uls.data (language database) * jquery.uls.compact (compact mode ULS) This contains updates from jquery.uls upstream Change-Id: Iaddb1228c076f698498d3b0554061624b6e433c6
This commit is contained in:
committed by
Niklas Laxström
parent
c4f0438597
commit
d4cea039b4
@@ -195,19 +195,58 @@ $wgResourceModules['ext.uls.inputsettings'] = array(
|
|||||||
|
|
||||||
$wgResourceModules['jquery.uls'] = array(
|
$wgResourceModules['jquery.uls'] = array(
|
||||||
'scripts' => array(
|
'scripts' => array(
|
||||||
'lib/jquery.uls/jquery.uls.js',
|
'lib/jquery.uls/src/jquery.uls.core.js',
|
||||||
|
'lib/jquery.uls/src/jquery.uls.lcd.js',
|
||||||
|
'lib/jquery.uls/src/jquery.uls.languagefilter.js',
|
||||||
|
'lib/jquery.uls/src/jquery.uls.regionfilter.js',
|
||||||
),
|
),
|
||||||
'styles' => array(
|
'styles' => array(
|
||||||
'lib/jquery.uls/css/jquery.uls.css',
|
'lib/jquery.uls/css/jquery.uls.css',
|
||||||
|
'lib/jquery.uls/css/jquery.uls.lcd.css',
|
||||||
),
|
),
|
||||||
'localBasePath' => $dir,
|
'localBasePath' => $dir,
|
||||||
'remoteExtPath' => 'UniversalLanguageSelector',
|
'remoteExtPath' => 'UniversalLanguageSelector',
|
||||||
'dependencies' => array(
|
'dependencies' => array(
|
||||||
'jquery.i18n',
|
'jquery.i18n',
|
||||||
|
'jquery.uls.grid',
|
||||||
|
'jquery.uls.data',
|
||||||
),
|
),
|
||||||
'position' => 'top',
|
'position' => 'top',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$wgResourceModules['jquery.uls.grid'] = array(
|
||||||
|
'styles' => array(
|
||||||
|
'lib/jquery.uls/css/jquery.uls.grid.css',
|
||||||
|
),
|
||||||
|
'localBasePath' => $dir,
|
||||||
|
'remoteExtPath' => 'UniversalLanguageSelector',
|
||||||
|
'position' => 'top',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$wgResourceModules['jquery.uls.compact'] = array(
|
||||||
|
'styles' => array(
|
||||||
|
'lib/jquery.uls/css/jquery.uls.compact.css',
|
||||||
|
),
|
||||||
|
'localBasePath' => $dir,
|
||||||
|
'remoteExtPath' => 'UniversalLanguageSelector',
|
||||||
|
'dependencies' => array(
|
||||||
|
'jquery.uls',
|
||||||
|
),
|
||||||
|
'position' => 'top',
|
||||||
|
);
|
||||||
|
|
||||||
|
$wgResourceModules['jquery.uls.data'] = array(
|
||||||
|
'scripts' => array(
|
||||||
|
'lib/jquery.uls/src/jquery.uls.data.js',
|
||||||
|
'lib/jquery.uls/src/jquery.uls.data.utils.js',
|
||||||
|
),
|
||||||
|
'localBasePath' => $dir,
|
||||||
|
'remoteExtPath' => 'UniversalLanguageSelector',
|
||||||
|
'position' => 'top',
|
||||||
|
);
|
||||||
|
|
||||||
$wgResourceModules['jquery.webfonts'] = array(
|
$wgResourceModules['jquery.webfonts'] = array(
|
||||||
'scripts' => 'lib/jquery.webfonts.js',
|
'scripts' => 'lib/jquery.webfonts.js',
|
||||||
'localBasePath' => $dir,
|
'localBasePath' => $dir,
|
||||||
|
|||||||
74
lib/jquery.uls/css/jquery.uls.compact.css
Normal file
74
lib/jquery.uls/css/jquery.uls.compact.css
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
.uls-compact .icon-close,
|
||||||
|
.uls-compact .uls-title,
|
||||||
|
.uls-compact .map-block {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact.uls-menu {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .search {
|
||||||
|
background: white;
|
||||||
|
border-top: none;
|
||||||
|
padding: 0.8em 0;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-color: #DDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .filterinput,
|
||||||
|
.uls-compact .filterinput:focus {
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
outline: none;
|
||||||
|
font-size: 18px;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .uls-language-list {
|
||||||
|
background: #FCFCFC;
|
||||||
|
height: 20em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .search-label {
|
||||||
|
background-size: 25px;
|
||||||
|
height: 26px;
|
||||||
|
width: 26px;
|
||||||
|
float: right;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .languagefilter-clear {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .uls-title-region a {
|
||||||
|
color: #777;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 15px 0 5px 19px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 6px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 14px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .uls-title-region a:hover {
|
||||||
|
color: #252525;
|
||||||
|
background: #F0F0F0;
|
||||||
|
border: 1px solid #DDD;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-compact .uls-title-region a:before {
|
||||||
|
display: inline-block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-right: 4px solid #777;
|
||||||
|
border-top: 4px solid transparent;
|
||||||
|
border-bottom: 4px solid transparent;
|
||||||
|
content: "";
|
||||||
|
margin: 0 6px 0 0;
|
||||||
|
}
|
||||||
@@ -258,482 +258,3 @@ div.uls-region {
|
|||||||
.uls-menu .search-input-block {
|
.uls-menu .search-input-block {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generated using Foundation http://foundation.zurb.com/docs/grid.php */
|
|
||||||
/* Global Reset & Standards ---------------------- */
|
|
||||||
.grid * {
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Misc ---------------------- */
|
|
||||||
.grid .left {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .right {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .text-left {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .text-right {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .text-center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .hide {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .highlight {
|
|
||||||
background: #ffff99;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The Grid ---------------------- */
|
|
||||||
.grid .row {
|
|
||||||
width: 100%;
|
|
||||||
max-width: none;
|
|
||||||
min-width: 600px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .row {
|
|
||||||
width: auto;
|
|
||||||
max-width: none;
|
|
||||||
min-width: 0;
|
|
||||||
margin: 0 -5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row.collapse .column,
|
|
||||||
.grid .row.collapse .columns {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .row {
|
|
||||||
width: auto;
|
|
||||||
max-width: none;
|
|
||||||
min-width: 0;
|
|
||||||
margin: 0 -5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .row.collapse {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .column, .grid .columns {
|
|
||||||
float: left;
|
|
||||||
min-height: 1px;
|
|
||||||
padding: 0 5px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .column.centered, .grid .columns.centered {
|
|
||||||
float: none;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .one {
|
|
||||||
width: 8.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .two {
|
|
||||||
width: 16.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .three {
|
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .four {
|
|
||||||
width: 33.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .five {
|
|
||||||
width: 41.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .six {
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .seven {
|
|
||||||
width: 58.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .eight {
|
|
||||||
width: 66.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .nine {
|
|
||||||
width: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .ten {
|
|
||||||
width: 83.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .eleven {
|
|
||||||
width: 91.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .twelve {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-one {
|
|
||||||
margin-left: 8.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-two {
|
|
||||||
margin-left: 16.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-three {
|
|
||||||
margin-left: 25%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-four {
|
|
||||||
margin-left: 33.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-five {
|
|
||||||
margin-left: 41.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-six {
|
|
||||||
margin-left: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-seven {
|
|
||||||
margin-left: 58.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-eight {
|
|
||||||
margin-left: 66.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-nine {
|
|
||||||
margin-left: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row .offset-by-ten {
|
|
||||||
margin-left: 83.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-two {
|
|
||||||
left: 16.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-two {
|
|
||||||
right: 16.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-three {
|
|
||||||
left: 25%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-three {
|
|
||||||
right: 25%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-four {
|
|
||||||
left: 33.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-four {
|
|
||||||
right: 33.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-five {
|
|
||||||
left: 41.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-five {
|
|
||||||
right: 41.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-six {
|
|
||||||
left: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-six {
|
|
||||||
right: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-seven {
|
|
||||||
left: 58.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-seven {
|
|
||||||
right: 58.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-eight {
|
|
||||||
left: 66.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-eight {
|
|
||||||
right: 66.667%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-nine {
|
|
||||||
left: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-nine {
|
|
||||||
right: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .push-ten {
|
|
||||||
left: 83.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .pull-ten {
|
|
||||||
right: 83.333%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Nicolas Gallagher's micro clearfix */
|
|
||||||
.grid .row {
|
|
||||||
*zoom: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row:before, .grid .row:after {
|
|
||||||
content: "";
|
|
||||||
display: table;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .row:after {
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Block Grids ---------------------- */
|
|
||||||
/* These are 2-up, 3-up, 4-up and 5-up ULs, suited
|
|
||||||
for repeating blocks of content. Add 'mobile' to
|
|
||||||
them to switch them just like the layout grid
|
|
||||||
(one item per line) on phones
|
|
||||||
|
|
||||||
For IE7/8 compatibility block-grid items need to be
|
|
||||||
the same height. You can optionally uncomment the
|
|
||||||
lines below to support arbitrary height, but know
|
|
||||||
that IE7/8 do not support :nth-child.
|
|
||||||
-------------------------------------------------- */
|
|
||||||
.grid .block-grid {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid > li {
|
|
||||||
display: block;
|
|
||||||
height: auto;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid.two-up {
|
|
||||||
margin: 0 -15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid.two-up > li {
|
|
||||||
width: 50%;
|
|
||||||
padding: 0 15px 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .block-grid.two-up>li:nth-child(2n+1) {clear: left;} */
|
|
||||||
.grid .block-grid.three-up {
|
|
||||||
margin: 0 -12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid.three-up > li {
|
|
||||||
width: 33.33%;
|
|
||||||
padding: 0 12px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .block-grid.three-up>li:nth-child(3n+1) {clear: left;} */
|
|
||||||
.grid .block-grid.four-up {
|
|
||||||
margin: 0 -10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid.four-up > li {
|
|
||||||
width: 25%;
|
|
||||||
padding: 0 10px 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .block-grid.four-up>li:nth-child(4n+1) {clear: left;} */
|
|
||||||
.grid .block-grid.five-up {
|
|
||||||
margin: 0 -8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid .block-grid.five-up > li {
|
|
||||||
width: 20%;
|
|
||||||
padding: 0 8px 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-lcd-region-section ul li:hover {
|
|
||||||
background-color: #eaeff7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-lcd-region-section {
|
|
||||||
margin-top:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Language list */
|
|
||||||
.uls-language-list {
|
|
||||||
height: 22em;
|
|
||||||
overflow: auto;
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-language-block ul {
|
|
||||||
margin: 0 0 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-language-list ul li {
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: normal;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Some languages have long names for various reasons and we still want
|
|
||||||
* them to appear on one line.
|
|
||||||
* To make it work correctly, the directionality must be set correctly
|
|
||||||
* on the item level.
|
|
||||||
*/
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The directionality (ltr/rtl) for each list item is set dynamically
|
|
||||||
* as HTML attributes in JavaScript. Setting directionality also applies
|
|
||||||
* alignment, but a list with mixed alignment is hard to read.
|
|
||||||
* All items are therefore explicitly aligned to the left, including names
|
|
||||||
* of right-to-left languages in left-to-right environment and vice versa.
|
|
||||||
* As long as the directionality of the item is set correctly, the text
|
|
||||||
* is readable.
|
|
||||||
*/
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We don't want any visible bullets in this list.
|
|
||||||
*/
|
|
||||||
list-style-image: none;
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-language-list strong {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-language-list a {
|
|
||||||
font-weight: normal;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #3366bb;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-menu .uls-language-block .columns {
|
|
||||||
width: 22%;
|
|
||||||
}
|
|
||||||
.uls-language-block {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-no-results-view {
|
|
||||||
color: #555;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-no-found-more {
|
|
||||||
font-size: 0.9em;
|
|
||||||
background: #F8F8F8;
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 1.6em;
|
|
||||||
line-height: 1.6em;
|
|
||||||
position:absolute;
|
|
||||||
bottom:0;
|
|
||||||
left:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-no-found-more a {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .icon-close,
|
|
||||||
.uls-compact .uls-title,
|
|
||||||
.uls-compact .map-block {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact.uls-menu {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .search {
|
|
||||||
background: white;
|
|
||||||
border-top: none;
|
|
||||||
padding: 0.8em 0;
|
|
||||||
border-bottom-width: 1px;
|
|
||||||
border-bottom-style: solid;
|
|
||||||
border-bottom-color: #DDD;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .filterinput,
|
|
||||||
.uls-compact .filterinput:focus {
|
|
||||||
background-color: transparent;
|
|
||||||
border: none;
|
|
||||||
box-shadow: none;
|
|
||||||
outline: none;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .uls-language-list {
|
|
||||||
background: #FCFCFC;
|
|
||||||
height: 20em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .search-label {
|
|
||||||
background-size: 25px;
|
|
||||||
height: 26px;
|
|
||||||
width: 26px;
|
|
||||||
float: right;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .languagefilter-clear {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .uls-title-region a {
|
|
||||||
color: #777;
|
|
||||||
display: inline-block;
|
|
||||||
margin: 15px 0 5px 19px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 6px;
|
|
||||||
font-size: 14px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .uls-title-region a:hover {
|
|
||||||
color: #252525;
|
|
||||||
background: #F0F0F0;
|
|
||||||
border: 1px solid #DDD;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.uls-compact .uls-title-region a:before {
|
|
||||||
display: inline-block;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-right: 4px solid #777;
|
|
||||||
border-top: 4px solid transparent;
|
|
||||||
border-bottom: 4px solid transparent;
|
|
||||||
content: "";
|
|
||||||
margin: 0 6px 0 0;
|
|
||||||
}
|
|
||||||
315
lib/jquery.uls/css/jquery.uls.grid.css
Normal file
315
lib/jquery.uls/css/jquery.uls.grid.css
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
/* Generated using Foundation http://foundation.zurb.com/docs/grid.php */
|
||||||
|
/* Global Reset & Standards ---------------------- */
|
||||||
|
.grid * {
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Misc ---------------------- */
|
||||||
|
.grid .left {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .text-left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .highlight {
|
||||||
|
background: #ffff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The Grid ---------------------- */
|
||||||
|
.grid .row {
|
||||||
|
width: 100%;
|
||||||
|
max-width: none;
|
||||||
|
min-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .row {
|
||||||
|
width: auto;
|
||||||
|
max-width: none;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0 -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row.collapse .column,
|
||||||
|
.grid .row.collapse .columns {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .row {
|
||||||
|
width: auto;
|
||||||
|
max-width: none;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0 -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .row.collapse {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .column, .grid .columns {
|
||||||
|
float: left;
|
||||||
|
min-height: 1px;
|
||||||
|
padding: 0 5px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .column.centered, .grid .columns.centered {
|
||||||
|
float: none;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .one {
|
||||||
|
width: 8.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .two {
|
||||||
|
width: 16.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .three {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .four {
|
||||||
|
width: 33.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .five {
|
||||||
|
width: 41.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .six {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .seven {
|
||||||
|
width: 58.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .eight {
|
||||||
|
width: 66.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .nine {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .ten {
|
||||||
|
width: 83.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .eleven {
|
||||||
|
width: 91.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .twelve {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-one {
|
||||||
|
margin-left: 8.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-two {
|
||||||
|
margin-left: 16.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-three {
|
||||||
|
margin-left: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-four {
|
||||||
|
margin-left: 33.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-five {
|
||||||
|
margin-left: 41.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-six {
|
||||||
|
margin-left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-seven {
|
||||||
|
margin-left: 58.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-eight {
|
||||||
|
margin-left: 66.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-nine {
|
||||||
|
margin-left: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row .offset-by-ten {
|
||||||
|
margin-left: 83.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-two {
|
||||||
|
left: 16.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-two {
|
||||||
|
right: 16.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-three {
|
||||||
|
left: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-three {
|
||||||
|
right: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-four {
|
||||||
|
left: 33.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-four {
|
||||||
|
right: 33.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-five {
|
||||||
|
left: 41.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-five {
|
||||||
|
right: 41.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-six {
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-six {
|
||||||
|
right: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-seven {
|
||||||
|
left: 58.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-seven {
|
||||||
|
right: 58.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-eight {
|
||||||
|
left: 66.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-eight {
|
||||||
|
right: 66.667%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-nine {
|
||||||
|
left: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-nine {
|
||||||
|
right: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .push-ten {
|
||||||
|
left: 83.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .pull-ten {
|
||||||
|
right: 83.333%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Nicolas Gallagher's micro clearfix */
|
||||||
|
.grid .row {
|
||||||
|
*zoom: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row:before, .grid .row:after {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .row:after {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block Grids ---------------------- */
|
||||||
|
/* These are 2-up, 3-up, 4-up and 5-up ULs, suited
|
||||||
|
for repeating blocks of content. Add 'mobile' to
|
||||||
|
them to switch them just like the layout grid
|
||||||
|
(one item per line) on phones
|
||||||
|
|
||||||
|
For IE7/8 compatibility block-grid items need to be
|
||||||
|
the same height. You can optionally uncomment the
|
||||||
|
lines below to support arbitrary height, but know
|
||||||
|
that IE7/8 do not support :nth-child.
|
||||||
|
-------------------------------------------------- */
|
||||||
|
.grid .block-grid {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid > li {
|
||||||
|
display: block;
|
||||||
|
height: auto;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid.two-up {
|
||||||
|
margin: 0 -15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid.two-up > li {
|
||||||
|
width: 50%;
|
||||||
|
padding: 0 15px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .block-grid.two-up>li:nth-child(2n+1) {clear: left;} */
|
||||||
|
.grid .block-grid.three-up {
|
||||||
|
margin: 0 -12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid.three-up > li {
|
||||||
|
width: 33.33%;
|
||||||
|
padding: 0 12px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .block-grid.three-up>li:nth-child(3n+1) {clear: left;} */
|
||||||
|
.grid .block-grid.four-up {
|
||||||
|
margin: 0 -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid.four-up > li {
|
||||||
|
width: 25%;
|
||||||
|
padding: 0 10px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .block-grid.four-up>li:nth-child(4n+1) {clear: left;} */
|
||||||
|
.grid .block-grid.five-up {
|
||||||
|
margin: 0 -8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid .block-grid.five-up > li {
|
||||||
|
width: 20%;
|
||||||
|
padding: 0 8px 8px;
|
||||||
|
}
|
||||||
89
lib/jquery.uls/css/jquery.uls.lcd.css
Normal file
89
lib/jquery.uls/css/jquery.uls.lcd.css
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.uls-lcd-region-section ul li:hover {
|
||||||
|
background-color: #eaeff7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-lcd-region-section {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Language list */
|
||||||
|
.uls-language-list {
|
||||||
|
height: 22em;
|
||||||
|
overflow: auto;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-language-block ul {
|
||||||
|
margin: 0 0 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-language-list ul li {
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: normal;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some languages have long names for various reasons and we still want
|
||||||
|
* them to appear on one line.
|
||||||
|
* To make it work correctly, the directionality must be set correctly
|
||||||
|
* on the item level.
|
||||||
|
*/
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The directionality (ltr/rtl) for each list item is set dynamically
|
||||||
|
* as HTML attributes in JavaScript. Setting directionality also applies
|
||||||
|
* alignment, but a list with mixed alignment is hard to read.
|
||||||
|
* All items are therefore explicitly aligned to the left, including names
|
||||||
|
* of right-to-left languages in left-to-right environment and vice versa.
|
||||||
|
* As long as the directionality of the item is set correctly, the text
|
||||||
|
* is readable.
|
||||||
|
*/
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't want any visible bullets in this list.
|
||||||
|
*/
|
||||||
|
list-style-image: none;
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-language-list strong {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-language-list a {
|
||||||
|
font-weight: normal;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #3366bb;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-menu .uls-language-block .columns {
|
||||||
|
width: 22%;
|
||||||
|
}
|
||||||
|
.uls-language-block {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-no-results-view {
|
||||||
|
color: #555;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-no-found-more {
|
||||||
|
font-size: 0.9em;
|
||||||
|
background: #F8F8F8;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 1.6em;
|
||||||
|
line-height: 1.6em;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-no-found-more a {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
319
lib/jquery.uls/css/jquery.uls.mobile.css
Normal file
319
lib/jquery.uls/css/jquery.uls.mobile.css
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
@media only screen and (max-width: 767px) {
|
||||||
|
|
||||||
|
.uls-mobile.uls-menu {
|
||||||
|
width: 95%;
|
||||||
|
left: 2.5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .uls-language-list {
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .uls-language-block {
|
||||||
|
padding-left: 15px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .uls-language-block ul {
|
||||||
|
min-height: 14em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .uls-language-block a {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile div.uls-region {
|
||||||
|
width: 33% !important;
|
||||||
|
float: left !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile div.map-block a,
|
||||||
|
.uls-mobile div.map-block {
|
||||||
|
opacity: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row {
|
||||||
|
width: auto;
|
||||||
|
min-width: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .column,
|
||||||
|
.uls-mobile .columns {
|
||||||
|
width: auto !important;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .column:last-child,
|
||||||
|
.uls-mobile .columns:last-child {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile [class*="column"] + [class*="column"]:last-child {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .column:before,
|
||||||
|
.uls-mobile .uls-mobile .columns:before,
|
||||||
|
.uls-mobile .column:after,
|
||||||
|
.columns:after {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .column:after,
|
||||||
|
.uls-mobile .columns:after {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .offset-by-one,
|
||||||
|
.uls-mobile .offset-by-two,
|
||||||
|
.uls-mobile .offset-by-three,
|
||||||
|
.uls-mobile .offset-by-four,
|
||||||
|
.uls-mobile .offset-by-five,
|
||||||
|
.uls-mobile .offset-by-six,
|
||||||
|
.uls-mobile .offset-by-seven,
|
||||||
|
.uls-mobile .offset-by-eight,
|
||||||
|
.uls-mobile .offset-by-nine,
|
||||||
|
.uls-mobile .offset-by-ten {
|
||||||
|
margin-left: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .push-two,
|
||||||
|
.uls-mobile .push-three,
|
||||||
|
.uls-mobile .push-four,
|
||||||
|
.uls-mobile .push-five,
|
||||||
|
.uls-mobile .push-six,
|
||||||
|
.uls-mobile .push-seven,
|
||||||
|
.uls-mobile .push-eight,
|
||||||
|
.uls-mobile .push-nine,
|
||||||
|
.uls-mobile .push-ten {
|
||||||
|
left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .pull-two,
|
||||||
|
.uls-mobile .pull-three,
|
||||||
|
.uls-mobile .pull-four,
|
||||||
|
.uls-mobile .pull-five,
|
||||||
|
.uls-mobile .pull-six,
|
||||||
|
.uls-mobile .pull-seven,
|
||||||
|
.uls-mobile .pull-eight,
|
||||||
|
.uls-mobile .pull-nine,
|
||||||
|
.uls-mobile .pull-ten {
|
||||||
|
right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile 4-column Grid */
|
||||||
|
.uls-mobile .row .mobile-one {
|
||||||
|
width: 25% !important;
|
||||||
|
float: left;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-one:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row.collapse .mobile-one {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-two {
|
||||||
|
width: 50% !important;
|
||||||
|
float: left;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-two:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row.collapse .mobile-two {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-three {
|
||||||
|
width: 75% !important;
|
||||||
|
float: left;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-three:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row.collapse .mobile-three {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-four {
|
||||||
|
width: 100% !important;
|
||||||
|
float: left;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row .mobile-four:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .row.collapse .mobile-four {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .push-one-mobile {
|
||||||
|
left: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .pull-one-mobile {
|
||||||
|
right: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .push-two-mobile {
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .pull-two-mobile {
|
||||||
|
right: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .push-three-mobile {
|
||||||
|
left: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .pull-three-mobile {
|
||||||
|
right: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Visibility Classes ---------------------- */
|
||||||
|
/* Standard (large) display targeting */
|
||||||
|
.uls-mobile .show-for-small,
|
||||||
|
.uls-mobile .show-for-medium,
|
||||||
|
.uls-mobile .show-for-medium-down,
|
||||||
|
.uls-mobile .hide-for-large,
|
||||||
|
.uls-mobile .hide-for-large-up,
|
||||||
|
.uls-mobile .show-for-xlarge {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .hide-for-xlarge,
|
||||||
|
.uls-mobile .show-for-large,
|
||||||
|
.uls-mobile .show-for-large-up,
|
||||||
|
.uls-mobile .hide-for-small,
|
||||||
|
.uls-mobile .hide-for-medium,
|
||||||
|
.uls-mobile .hide-for-medium-down {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Very large display targeting */
|
||||||
|
@media only screen and (min-width: 1441px) {
|
||||||
|
|
||||||
|
.uls-mobile .hide-for-small,
|
||||||
|
.uls-mobile .hide-for-medium,
|
||||||
|
.uls-mobile .hide-for-medium-down,
|
||||||
|
.hide-for-large, .show-for-large-up,
|
||||||
|
.show-for-xlarge {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-for-small,
|
||||||
|
.uls-mobile .show-for-medium,
|
||||||
|
.uls-mobile .show-for-medium-down,
|
||||||
|
.uls-mobile .show-for-large,
|
||||||
|
.uls-mobile .hide-for-large-up,
|
||||||
|
.uls-mobile .hide-for-xlarge {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Medium display targeting */
|
||||||
|
@media only screen and (max-width: 1279px) and (min-width: 768px) {
|
||||||
|
|
||||||
|
.uls-mobile .hide-for-small,
|
||||||
|
.uls-mobile .show-for-medium,
|
||||||
|
.uls-mobile .show-for-medium-down,
|
||||||
|
.uls-mobile .hide-for-large,
|
||||||
|
.uls-mobile .hide-for-large-up,
|
||||||
|
.uls-mobile .hide-for-xlarge {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .show-for-small,
|
||||||
|
.uls-mobile .hide-for-medium,
|
||||||
|
.uls-mobile .hide-for-medium-down,
|
||||||
|
.uls-mobile .show-for-large,
|
||||||
|
.uls-mobile .show-for-large-up,
|
||||||
|
.uls-mobile .show-for-xlarge {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Small display targeting */
|
||||||
|
@media only screen and (max-width: 767px) {
|
||||||
|
|
||||||
|
.uls-mobile .show-for-small,
|
||||||
|
.uls-mobile .hide-for-medium,
|
||||||
|
.uls-mobile .show-for-medium-down,
|
||||||
|
.uls-mobile .hide-for-large,
|
||||||
|
.uls-mobile .hide-for-large-up,
|
||||||
|
.uls-mobile .hide-for-xlarge {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
.uls-mobile .hide-for-small,
|
||||||
|
.uls-mobile .show-for-medium,
|
||||||
|
.uls-mobile .hide-for-medium-down,
|
||||||
|
.uls-mobile .show-for-large,
|
||||||
|
.uls-mobile .show-for-large-up,
|
||||||
|
.uls-mobile .show-for-xlarge {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Orientation targeting */
|
||||||
|
.uls-mobile .show-for-landscape,
|
||||||
|
.uls-mobile .hide-for-portrait {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .hide-for-landscape,
|
||||||
|
.uls-mobile .show-for-portrait {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (orientation: landscape) {
|
||||||
|
.uls-mobile .show-for-landscape,
|
||||||
|
.uls-mobile .hide-for-portrait {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
.uls-mobile .hide-for-landscape,
|
||||||
|
.uls-mobile .show-for-portrait {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (orientation: portrait) {
|
||||||
|
.uls-mobile .show-for-portrait,
|
||||||
|
.uls-mobile .hide-for-landscape {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
.uls-mobile .hide-for-portrait,
|
||||||
|
.uls-mobile .show-for-landscape {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Touch-enabled device targeting */
|
||||||
|
.uls-mobile .show-for-touch {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .hide-for-touch {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .touch .show-for-touch {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uls-mobile .touch .hide-for-touch {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
18
lib/jquery.uls/i18n/bbc-latn.json
Normal file
18
lib/jquery.uls/i18n/bbc-latn.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"uls-select-language": "Pillit hata",
|
||||||
|
"uls-region-WW": "Sude luat portibi on",
|
||||||
|
"uls-region-AM": "Amerika",
|
||||||
|
"uls-region-AF": "Afrika",
|
||||||
|
"uls-region-EU": "Eropa",
|
||||||
|
"uls-region-AS": "Asia",
|
||||||
|
"uls-region-ME": "Timur Tengah",
|
||||||
|
"uls-region-PA": "Pasifik",
|
||||||
|
"uls-no-results-found": "Ndang adong jumpang",
|
||||||
|
"uls-common-languages": "Hata na somal",
|
||||||
|
"uls-search-placeholder": "Mandiori hata",
|
||||||
|
"@metadata": {
|
||||||
|
"authors": [
|
||||||
|
"Stephensuleeman"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,11 +2,13 @@
|
|||||||
"@metadata": {
|
"@metadata": {
|
||||||
"authors": [
|
"authors": [
|
||||||
"Erdemaslancan",
|
"Erdemaslancan",
|
||||||
|
"Gorizon",
|
||||||
"Mirzali"
|
"Mirzali"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"uls-select-language": "Z\u0131wan we\u00e7ine",
|
"uls-select-language": "Z\u0131wan we\u00e7ine",
|
||||||
"uls-region-WW": "Herad\u0131nya",
|
"uls-region-WW": "Herad\u0131nya",
|
||||||
|
"uls-region-SP": "X\u0131susi",
|
||||||
"uls-region-AM": "Amerika",
|
"uls-region-AM": "Amerika",
|
||||||
"uls-region-AF": "Afriqa",
|
"uls-region-AF": "Afriqa",
|
||||||
"uls-region-EU": "Ewropa",
|
"uls-region-EU": "Ewropa",
|
||||||
|
|||||||
21
lib/jquery.uls/i18n/fo.json
Normal file
21
lib/jquery.uls/i18n/fo.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"@metadata": {
|
||||||
|
"authors": [
|
||||||
|
"EileenSanda"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"uls-select-language": "Vel m\u00e1l",
|
||||||
|
"uls-region-WW": "Alheims",
|
||||||
|
"uls-region-SP": "Serstakt",
|
||||||
|
"uls-region-AM": "Amerika",
|
||||||
|
"uls-region-AF": "Afrika",
|
||||||
|
"uls-region-EU": "Evropa",
|
||||||
|
"uls-region-AS": "Asia",
|
||||||
|
"uls-region-ME": "Mi\u00f0eystur",
|
||||||
|
"uls-region-PA": "Stillahavi\u00f0",
|
||||||
|
"uls-no-results-found": "Ongi \u00farslit funnin",
|
||||||
|
"uls-common-languages": "Vanlig m\u00e1l",
|
||||||
|
"uls-no-results-suggestion-title": "T\u00fa ert kanska \u00e1huga\u00f0\/ur \u00ed:",
|
||||||
|
"uls-search-help": "T\u00fa kanst leita eftir navni \u00e1 m\u00e1li, skriftt\u00fdpu \u00e1 m\u00e1li, ISO kotu av m\u00e1li ella kanst t\u00fa leita eftir \u00f8ki:",
|
||||||
|
"uls-search-placeholder": "Leita eftir m\u00e1li"
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
403
lib/jquery.uls/src/jquery.uls.core.js
Normal file
403
lib/jquery.uls/src/jquery.uls.core.js
Normal file
@@ -0,0 +1,403 @@
|
|||||||
|
/**
|
||||||
|
* Universal Language Selector
|
||||||
|
* ULS core component.
|
||||||
|
*
|
||||||
|
* 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 numbers in id attributes also appear in the langdb.
|
||||||
|
/*jshint multistr:true */
|
||||||
|
var template = '\
|
||||||
|
<div class="grid uls-menu uls-wide"> \
|
||||||
|
<div class="row"> \
|
||||||
|
<span id="uls-close" class="icon-close"></span> \
|
||||||
|
</div> \
|
||||||
|
<div class="row"> \
|
||||||
|
<div class="uls-title-region seven columns">\
|
||||||
|
<h1 data-i18n="uls-select-language" class="uls-title">Select Language</h1>\
|
||||||
|
</div>\
|
||||||
|
<div class="five columns map-block" id="map-block">\
|
||||||
|
<div class="row">\
|
||||||
|
<div data-regiongroup="1" id="uls-region-1" class="three columns uls-region uls-region-1">\
|
||||||
|
<a data-i18n="uls-region-WW">Worldwide</a>\
|
||||||
|
</div>\
|
||||||
|
<div class="nine columns">\
|
||||||
|
<div class="row uls-worldmap">\
|
||||||
|
<div data-regiongroup="2" id="uls-region-2" class="four columns uls-region">\
|
||||||
|
<a data-i18n="uls-region-AM">America</a>\
|
||||||
|
</div>\
|
||||||
|
<div data-regiongroup="3" id="uls-region-3" class="four columns uls-region">\
|
||||||
|
<a><span data-i18n="uls-region-EU">Europe</span><br>\
|
||||||
|
<span data-i18n="uls-region-ME">Middle East</span><br>\
|
||||||
|
<span data-i18n="uls-region-AF">Africa</span></a>\
|
||||||
|
</div>\
|
||||||
|
<div data-regiongroup="4" id="uls-region-4" class="four columns uls-region">\
|
||||||
|
<a><span data-i18n="uls-region-AS">Asia</span><br>\
|
||||||
|
<span data-i18n="uls-region-PA">Pacific</span></a>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div id="search" class="row search"> \
|
||||||
|
<div class="one column">\
|
||||||
|
<span class="search-label"></span>\
|
||||||
|
</div>\
|
||||||
|
<div class="ten columns">\
|
||||||
|
<div id="search-input-block" class="search-input-block">\
|
||||||
|
<input type="text" class="filterinput filtersuggestion" id="filtersuggestion" disabled="true"\
|
||||||
|
autocomplete="off" /> <input type="text" class="filterinput languagefilter" id="languagefilter"\
|
||||||
|
data-clear="languagefilter-clear" data-suggestion="filtersuggestion"\
|
||||||
|
placeholder="Language search" autocomplete="off" />\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="one column">\
|
||||||
|
<span id="languagefilter-clear" class="languagefilter-clear"></span>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="row uls-language-list"></div>\
|
||||||
|
<div class="row" id="settings-block"></div>\
|
||||||
|
</div> ';
|
||||||
|
/*jshint multistr:false */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ULS Public class definition
|
||||||
|
*/
|
||||||
|
var ULS = function ( element, options ) {
|
||||||
|
this.$element = $( element );
|
||||||
|
this.options = $.extend( {}, $.fn.uls.defaults, options );
|
||||||
|
this.$menu = $( template );
|
||||||
|
this.languages = this.options.languages;
|
||||||
|
|
||||||
|
for ( var code in this.languages ) {
|
||||||
|
if ( $.uls.data.languages[code] === undefined ) {
|
||||||
|
if ( window.console && window.console.log ) {
|
||||||
|
window.console.log( 'ULS: Unknown language ' + code + '.' );
|
||||||
|
}
|
||||||
|
delete this.languages[code];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.left = this.options.left;
|
||||||
|
this.top = this.options.top;
|
||||||
|
this.shown = false;
|
||||||
|
this.initialized = false;
|
||||||
|
|
||||||
|
this.$languageFilter = this.$menu.find( '#languagefilter' );
|
||||||
|
this.$regionFilters = this.$menu.find( '.uls-region' );
|
||||||
|
this.$resultsView = this.$menu.find( 'div.uls-language-list' );
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
this.listen();
|
||||||
|
this.ready();
|
||||||
|
};
|
||||||
|
|
||||||
|
ULS.prototype = {
|
||||||
|
constructor: ULS,
|
||||||
|
|
||||||
|
ready: function () {
|
||||||
|
if ( this.options.onReady ) {
|
||||||
|
this.options.onReady.call( this );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the position of ULS
|
||||||
|
* Returns an object with top and left properties.
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
position: function () {
|
||||||
|
var pos = $.extend( {}, this.$element.offset(), {
|
||||||
|
height: this.$element[0].offsetHeight
|
||||||
|
} );
|
||||||
|
return {
|
||||||
|
top: this.top || pos.top + pos.height,
|
||||||
|
left: this.left || '25%'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the ULS window
|
||||||
|
*/
|
||||||
|
show: function () {
|
||||||
|
var pos = this.position();
|
||||||
|
this.$menu.css( {
|
||||||
|
top: pos.top,
|
||||||
|
left: '25%'
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( this.options.compact ) {
|
||||||
|
this.$menu.addClass( 'uls-compact' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !this.initialized ) {
|
||||||
|
$( 'body' ).prepend( this.$menu );
|
||||||
|
this.i18n();
|
||||||
|
// Initialize with a full search.
|
||||||
|
// This happens on first time click of uls trigger.
|
||||||
|
this.defaultSearch();
|
||||||
|
this.initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide any other ULS visible
|
||||||
|
$( '.uls-menu' ).hide();
|
||||||
|
|
||||||
|
this.$menu.show();
|
||||||
|
this.shown = true;
|
||||||
|
|
||||||
|
if ( !this.isMobile() ) {
|
||||||
|
this.$languageFilter.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
i18n: function () {
|
||||||
|
if ( $.i18n ) {
|
||||||
|
this.$menu.find( '[data-i18n]' ).i18n();
|
||||||
|
this.$languageFilter.prop( 'placeholder', $.i18n( 'uls-search-placeholder' ) );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultSearch: function () {
|
||||||
|
this.$resultsView.lcd( 'empty' );
|
||||||
|
|
||||||
|
if ( this.options.lazyload ) {
|
||||||
|
this.$regionFilters.first().regionselector( 'show' );
|
||||||
|
} else {
|
||||||
|
this.$regionFilters.regionselector( 'show' );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the ULS window
|
||||||
|
*/
|
||||||
|
hide: function () {
|
||||||
|
this.$menu.hide();
|
||||||
|
this.shown = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the UI elements.
|
||||||
|
* Does nothing by default. Can be used for customization.
|
||||||
|
*/
|
||||||
|
render: function () {
|
||||||
|
// Rendering stuff here
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for no results found context.
|
||||||
|
*/
|
||||||
|
noresults: function () {
|
||||||
|
this.$resultsView.lcd( 'noResults' );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* callback for results found context.
|
||||||
|
*/
|
||||||
|
success: function () {
|
||||||
|
this.$resultsView.show();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind the UI elements with their event listeners
|
||||||
|
*/
|
||||||
|
listen: function () {
|
||||||
|
var lcd,
|
||||||
|
uls = this;
|
||||||
|
|
||||||
|
// Register all event listeners to the ULS here.
|
||||||
|
uls.$element.on( 'click', $.proxy( uls.click, uls ) );
|
||||||
|
|
||||||
|
uls.$languageFilter.on( 'searchclear', $.proxy( uls.defaultSearch, uls ) );
|
||||||
|
|
||||||
|
// Close when clicking on the close button
|
||||||
|
uls.$menu.find( '#uls-close' ).on( 'click', $.proxy( uls.cancel, uls ) );
|
||||||
|
// Don't do anything if pressing on empty space in the ULS
|
||||||
|
uls.$menu.on( 'click', function ( e ) {
|
||||||
|
e.stopPropagation();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Handle key press events on the menu
|
||||||
|
uls.$menu.on( 'keypress', $.proxy( this.keypress, this ) )
|
||||||
|
.on( 'keyup', $.proxy( this.keyup, this ) );
|
||||||
|
|
||||||
|
if ( this.eventSupported( 'keydown' ) ) {
|
||||||
|
this.$menu.on( 'keydown', $.proxy( this.keypress, this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd = uls.$resultsView.lcd( {
|
||||||
|
languages: uls.languages,
|
||||||
|
quickList: uls.options.quickList,
|
||||||
|
clickhandler: $.proxy( uls.select, uls ),
|
||||||
|
lazyload: uls.options.lazyload,
|
||||||
|
source: uls.$languageFilter,
|
||||||
|
showRegions: uls.options.showRegions
|
||||||
|
} ).data( 'lcd' );
|
||||||
|
|
||||||
|
uls.$languageFilter.languagefilter( {
|
||||||
|
$target: lcd,
|
||||||
|
languages: uls.languages,
|
||||||
|
success: function () {
|
||||||
|
$( '.regionselector' ).removeClass( 'active' );
|
||||||
|
uls.success();
|
||||||
|
},
|
||||||
|
noresults: function () {
|
||||||
|
$( '.regionselector' ).removeClass( 'active' );
|
||||||
|
uls.noresults();
|
||||||
|
},
|
||||||
|
searchAPI: uls.options.searchAPI,
|
||||||
|
onSelect: $.proxy( uls.select, uls )
|
||||||
|
} );
|
||||||
|
|
||||||
|
// Create region selectors, one per region
|
||||||
|
this.$menu.find( '.uls-region, .uls-region-link' ).regionselector( {
|
||||||
|
$target: lcd,
|
||||||
|
languages: uls.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' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
$( 'html' ).click( $.proxy( this.hide, this ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On select handler for search results
|
||||||
|
* @param langCode
|
||||||
|
*/
|
||||||
|
select: function ( langCode ) {
|
||||||
|
this.hide();
|
||||||
|
|
||||||
|
if ( this.options.onSelect ) {
|
||||||
|
this.options.onSelect.call( this, langCode );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On cancel handler for the uls menu
|
||||||
|
*/
|
||||||
|
cancel: function () {
|
||||||
|
this.hide();
|
||||||
|
|
||||||
|
if ( this.options.onCancel ) {
|
||||||
|
this.options.onCancel.call( this );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
keyup: function ( e ) {
|
||||||
|
if ( !this.shown ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( e.keyCode === 27 ) { // escape
|
||||||
|
this.cancel();
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
keypress: function ( e ) {
|
||||||
|
if ( !this.shown ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( e.keyCode === 27 ) { // escape
|
||||||
|
this.cancel();
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
click: function ( e ) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if ( this.shown ) {
|
||||||
|
this.hide();
|
||||||
|
} else {
|
||||||
|
this.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
eventSupported: function ( eventName ) {
|
||||||
|
var isSupported = eventName in this.$menu;
|
||||||
|
|
||||||
|
if ( !isSupported ) {
|
||||||
|
this.$element.setAttribute( eventName, 'return;' );
|
||||||
|
isSupported = typeof this.$element[eventName] === 'function';
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSupported;
|
||||||
|
},
|
||||||
|
|
||||||
|
isMobile: function () {
|
||||||
|
return navigator.userAgent.match( /(iPhone|iPod|iPad|Android|BlackBerry)/ );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ULS PLUGIN DEFINITION
|
||||||
|
* =========================== */
|
||||||
|
|
||||||
|
$.fn.uls = function ( option ) {
|
||||||
|
return this.each( function () {
|
||||||
|
var $this = $( this ),
|
||||||
|
data = $this.data( 'uls' ),
|
||||||
|
options = typeof option === 'object' && option;
|
||||||
|
|
||||||
|
if ( !data ) {
|
||||||
|
$this.data( 'uls', ( data = new ULS( this, options ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof option === 'string' ) {
|
||||||
|
data[option]();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.uls.defaults = {
|
||||||
|
menu: template,
|
||||||
|
onSelect: null, // Callback function to be called when a language is selected
|
||||||
|
searchAPI: null, // Language search API
|
||||||
|
languages: $.uls.data.getAutonyms(), // Languages to be used for ULS, default is all languages
|
||||||
|
quickList: null, // Array of language codes or function that returns such
|
||||||
|
lazyload: true, // Lazy load the language list when scrolled.
|
||||||
|
compact: false, // Show ULS in compact mode
|
||||||
|
showRegions: ['WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA']
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define a dummy i18n function, if jquery.i18n not integrated.
|
||||||
|
if ( !$.fn.i18n ) {
|
||||||
|
$.fn.i18n = function () {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.uls.Constructor = ULS;
|
||||||
|
} ( jQuery ) );
|
||||||
6
lib/jquery.uls/src/jquery.uls.data.js
Normal file
6
lib/jquery.uls/src/jquery.uls.data.js
Normal file
File diff suppressed because one or more lines are too long
463
lib/jquery.uls/src/jquery.uls.data.utils.js
Normal file
463
lib/jquery.uls/src/jquery.uls.data.utils.js
Normal file
@@ -0,0 +1,463 @@
|
|||||||
|
/**
|
||||||
|
* Utility functions for querying language data.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this language a redirect to another language?
|
||||||
|
* @param language string Language code
|
||||||
|
* @return Target language code if it's a redirect or false if it's not
|
||||||
|
*/
|
||||||
|
$.uls.data.isRedirect = function ( language ) {
|
||||||
|
return ( $.uls.data.languages[language] !== undefined &&
|
||||||
|
$.uls.data.languages[language].length === 1 ) ? $.uls.data.languages[language][0] : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the script of the language.
|
||||||
|
* @param language string Language code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
$.uls.data.getScript = function ( language ) {
|
||||||
|
var target = $.uls.data.isRedirect( language );
|
||||||
|
|
||||||
|
if ( target ) {
|
||||||
|
return $.uls.data.getScript( target );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $.uls.data.languages[language][0];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the regions in which a language is spoken.
|
||||||
|
* @param language string Language code
|
||||||
|
* @return array|string 'UNKNOWN'
|
||||||
|
*/
|
||||||
|
$.uls.data.getRegions = function ( language ) {
|
||||||
|
var target = $.uls.data.isRedirect( language );
|
||||||
|
|
||||||
|
if ( target ) {
|
||||||
|
return $.uls.data.getRegions( target );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( $.uls.data.languages[language] && $.uls.data.languages[language][1] ) || 'UNKNOWN';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the autonym of the language.
|
||||||
|
* @param language string Language code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
$.uls.data.getAutonym = function ( language ) {
|
||||||
|
var target = $.uls.data.isRedirect( language );
|
||||||
|
|
||||||
|
if ( target ) {
|
||||||
|
return $.uls.data.getAutonym( target );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( $.uls.data.languages[language] && $.uls.data.languages[language][2] ) || language;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all language codes and corresponding autonyms
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
$.uls.data.getAutonyms = function () {
|
||||||
|
var language,
|
||||||
|
autonymsByCode = {};
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
autonymsByCode[language] = $.uls.data.getAutonym( language );
|
||||||
|
}
|
||||||
|
|
||||||
|
return autonymsByCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of all region codes.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
$.uls.data.getAllRegions = function () {
|
||||||
|
var region,
|
||||||
|
allRegions = [];
|
||||||
|
|
||||||
|
for ( region in $.uls.data.regiongroups ) {
|
||||||
|
allRegions.push( region );
|
||||||
|
}
|
||||||
|
|
||||||
|
return allRegions;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all languages written in script.
|
||||||
|
* @param script string
|
||||||
|
* @return array of strings (languages codes)
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInScript = function ( script ) {
|
||||||
|
return $.uls.data.getLanguagesInScripts( [ script ] );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all languages written in the given scripts.
|
||||||
|
* @param scripts array of strings
|
||||||
|
* @return array of strings (languages codes)
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInScripts = function ( scripts ) {
|
||||||
|
var language, i,
|
||||||
|
languagesInScripts = [];
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < scripts.length; i++ ) {
|
||||||
|
if ( scripts[i] === $.uls.data.getScript( language ) ) {
|
||||||
|
languagesInScripts.push( language );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagesInScripts;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all languages in a given region.
|
||||||
|
* @param region string
|
||||||
|
* @return array of strings (languages codes)
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInRegion = function ( region ) {
|
||||||
|
return $.uls.data.getLanguagesInRegions( [ region ] );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all languages in given regions.
|
||||||
|
* @param regions array of strings.
|
||||||
|
* @return array of strings (languages codes)
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInRegions = function ( regions ) {
|
||||||
|
var language, i,
|
||||||
|
languagesInRegions = [];
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < regions.length; i++ ) {
|
||||||
|
if ( $.inArray( regions[i], $.uls.data.getRegions( language ) ) !== -1 ) {
|
||||||
|
languagesInRegions.push( language );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagesInRegions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all languages in a region group.
|
||||||
|
* @param groupNum number.
|
||||||
|
* @return array of strings (languages codes)
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInRegionGroup = function ( groupNum ) {
|
||||||
|
return $.uls.data.getLanguagesInRegions( $.uls.data.getRegionsInGroup( groupNum ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an associative array of languages in a region,
|
||||||
|
* grouped by script.
|
||||||
|
* @param region string Region code
|
||||||
|
* @return associative array
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesByScriptInRegion = function ( region ) {
|
||||||
|
var language, script,
|
||||||
|
languagesByScriptInRegion = {};
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $.inArray( region, $.uls.data.getRegions( language ) ) !== -1 ) {
|
||||||
|
script = $.uls.data.getScript( language );
|
||||||
|
|
||||||
|
if ( languagesByScriptInRegion[script] === undefined ) {
|
||||||
|
languagesByScriptInRegion[script] = [];
|
||||||
|
}
|
||||||
|
languagesByScriptInRegion[script].push( language );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagesByScriptInRegion;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an associative array of languages in a region,
|
||||||
|
* grouped by script group.
|
||||||
|
* @param region string Region code
|
||||||
|
* @return associative array
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesByScriptGroupInRegion = function ( region ) {
|
||||||
|
return $.uls.data.getLanguagesByScriptGroupInRegions( [ region ] );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an associative array of all languages,
|
||||||
|
* grouped by script group.
|
||||||
|
* @return associative array
|
||||||
|
*/
|
||||||
|
$.uls.data.getAllLanguagesByScriptGroup = function () {
|
||||||
|
return $.uls.data.getLanguagesByScriptGroupInRegions( $.uls.data.getAllRegions() );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the given list of languages grouped by script.
|
||||||
|
* @param languages Array of language codes
|
||||||
|
* @return {Object} Array of languages indexed by script codes
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesByScriptGroup = function ( languages ) {
|
||||||
|
var languagesByScriptGroup = {},
|
||||||
|
language, codeToAdd, langScriptGroup;
|
||||||
|
|
||||||
|
for ( language in languages ) {
|
||||||
|
codeToAdd = $.uls.data.isRedirect( language ) || language;
|
||||||
|
|
||||||
|
langScriptGroup = $.uls.data.getScriptGroupOfLanguage( codeToAdd );
|
||||||
|
|
||||||
|
if ( !languagesByScriptGroup[langScriptGroup] ) {
|
||||||
|
languagesByScriptGroup[langScriptGroup] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent duplicate adding of redirects
|
||||||
|
if ( $.inArray( codeToAdd, languagesByScriptGroup[langScriptGroup] ) === -1 ) {
|
||||||
|
languagesByScriptGroup[langScriptGroup].push( codeToAdd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagesByScriptGroup;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an associative array of languages in several regions,
|
||||||
|
* grouped by script group.
|
||||||
|
* @param regions array of strings - region codes
|
||||||
|
* @return associative array
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesByScriptGroupInRegions = function ( regions ) {
|
||||||
|
var language, i, scriptGroup,
|
||||||
|
languagesByScriptGroupInRegions = {};
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < regions.length; i++ ) {
|
||||||
|
if ( $.inArray( regions[i], $.uls.data.getRegions( language ) ) !== -1 ) {
|
||||||
|
scriptGroup = $.uls.data.getScriptGroupOfLanguage( language );
|
||||||
|
|
||||||
|
if ( languagesByScriptGroupInRegions[scriptGroup] === undefined ) {
|
||||||
|
languagesByScriptGroupInRegions[scriptGroup] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
languagesByScriptGroupInRegions[scriptGroup].push( language );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languagesByScriptGroupInRegions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of languages grouped by region group,
|
||||||
|
* region, script group and script.
|
||||||
|
* @return associative array
|
||||||
|
*/
|
||||||
|
$.uls.data.getAllLanguagesByRegionAndScript = function () {
|
||||||
|
var region, regionGroup, language,
|
||||||
|
script, scriptGroup, regions, regionNum,
|
||||||
|
allLanguagesByRegionAndScript = {};
|
||||||
|
|
||||||
|
for ( region in $.uls.data.regiongroups ) {
|
||||||
|
regionGroup = $.uls.data.regiongroups[region];
|
||||||
|
|
||||||
|
if ( allLanguagesByRegionAndScript[regionGroup] === undefined ) {
|
||||||
|
allLanguagesByRegionAndScript[regionGroup] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
allLanguagesByRegionAndScript[regionGroup][region] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( language in $.uls.data.languages ) {
|
||||||
|
if ( $.uls.data.isRedirect( language ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
script = $.uls.data.getScript( language );
|
||||||
|
scriptGroup = $.uls.data.getGroupOfScript( script );
|
||||||
|
regions = $.uls.data.getRegions( language );
|
||||||
|
|
||||||
|
for ( regionNum = 0; regionNum < regions.length; regionNum++ ) {
|
||||||
|
region = regions[regionNum];
|
||||||
|
regionGroup = $.uls.data.regiongroups[region];
|
||||||
|
|
||||||
|
if ( allLanguagesByRegionAndScript[regionGroup][region][scriptGroup] === undefined ) {
|
||||||
|
allLanguagesByRegionAndScript[regionGroup][region][scriptGroup] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( allLanguagesByRegionAndScript[regionGroup][region][scriptGroup][script] === undefined ) {
|
||||||
|
allLanguagesByRegionAndScript[regionGroup][region][scriptGroup][script] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
allLanguagesByRegionAndScript[regionGroup][region][scriptGroup][script].push( language );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allLanguagesByRegionAndScript;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all regions in a region group.
|
||||||
|
* @param groupNum int
|
||||||
|
* @return array of strings
|
||||||
|
*/
|
||||||
|
$.uls.data.getRegionsInGroup = function ( groupNum ) {
|
||||||
|
var region,
|
||||||
|
regionsInGroup = [];
|
||||||
|
|
||||||
|
for ( region in $.uls.data.regiongroups ) {
|
||||||
|
if ( $.uls.data.regiongroups[region] === groupNum ) {
|
||||||
|
regionsInGroup.push( region );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return regionsInGroup;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the script group of a script or 'Other' if it doesn't
|
||||||
|
* belong to any group.
|
||||||
|
* @param script string Script code
|
||||||
|
* @return string script group name
|
||||||
|
*/
|
||||||
|
$.uls.data.getGroupOfScript = function ( script ) {
|
||||||
|
var scriptGroup;
|
||||||
|
|
||||||
|
for ( scriptGroup in $.uls.data.scriptgroups ) {
|
||||||
|
if ( $.inArray( script, $.uls.data.scriptgroups[scriptGroup] ) !== -1 ) {
|
||||||
|
return scriptGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Other';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the script group of a language.
|
||||||
|
* @param language string Language code
|
||||||
|
* @return string script group name
|
||||||
|
*/
|
||||||
|
$.uls.data.getScriptGroupOfLanguage = function ( language ) {
|
||||||
|
return $.uls.data.getGroupOfScript( $.uls.data.getScript( language ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback for sorting languages by autonym.
|
||||||
|
* Can be used as an argument to a sort function.
|
||||||
|
* @param a string Language code
|
||||||
|
* @param b string Language code
|
||||||
|
*/
|
||||||
|
$.uls.data.sortByAutonym = function ( a, b ) {
|
||||||
|
var autonymA = $.uls.data.getAutonym( a ) || a,
|
||||||
|
autonymB = $.uls.data.getAutonym( b ) || b;
|
||||||
|
|
||||||
|
return ( autonymA.toLowerCase() < autonymB.toLowerCase() ) ? -1 : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a language is right-to-left.
|
||||||
|
* @param language string Language code
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
$.uls.data.isRtl = function ( language ) {
|
||||||
|
return $.inArray( $.uls.data.getScript( language ), $.uls.data.rtlscripts ) !== -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the direction of the language
|
||||||
|
* @param language string Language code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
$.uls.data.getDir = function ( language ) {
|
||||||
|
return $.uls.data.isRtl( language ) ? 'rtl' : 'ltr';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the languages spoken in a territory.
|
||||||
|
* @param territory string Territory code
|
||||||
|
* @return list of language codes
|
||||||
|
*/
|
||||||
|
$.uls.data.getLanguagesInTerritory = function ( territory ) {
|
||||||
|
return $.uls.data.territories[territory];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a language in run time and sets its options as provided.
|
||||||
|
* If the target option is provided, the language is defined as a redirect.
|
||||||
|
* Other possible options are script, regions and autonym.
|
||||||
|
*
|
||||||
|
* @param code string New language code.
|
||||||
|
* @param options Object Language properties.
|
||||||
|
* @return list of language codes
|
||||||
|
*/
|
||||||
|
$.uls.data.addLanguage = function( code, options ) {
|
||||||
|
if ( options.target ) {
|
||||||
|
$.uls.data.languages[code] = [options.target];
|
||||||
|
} else {
|
||||||
|
$.uls.data.languages[code] = [options.script, options.regions, options.autonym];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a language from the langdb in run time.
|
||||||
|
*
|
||||||
|
* @param code string Language code to delete.
|
||||||
|
* @return true if the language was removed, false otherwise.
|
||||||
|
*/
|
||||||
|
$.uls.data.deleteLanguage = function( code ) {
|
||||||
|
if ( $.uls.data.languages[code] ) {
|
||||||
|
delete $.uls.data.languages[code];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} ( jQuery ) );
|
||||||
345
lib/jquery.uls/src/jquery.uls.languagefilter.js
Normal file
345
lib/jquery.uls/src/jquery.uls.languagefilter.js
Normal file
@@ -0,0 +1,345 @@
|
|||||||
|
/**
|
||||||
|
* jQuery language filter plugin.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usage: $( 'inputbox' ).languagefilter();
|
||||||
|
* The values for autocompletion is from the options.languages.
|
||||||
|
* The data is in the format of languagecode:languagename.
|
||||||
|
*/
|
||||||
|
(function ( $ ) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var LanguageFilter = function( element, options ) {
|
||||||
|
this.$element = $( element );
|
||||||
|
this.options = $.extend( {}, $.fn.regionselector.defaults, options );
|
||||||
|
this.$element.addClass( 'languagefilter' );
|
||||||
|
this.resultCount = 0;
|
||||||
|
this.$suggestion = this.$element.parents().find( '#' + this.$element.data( 'suggestion' ) );
|
||||||
|
this.$clear = this.$element.parents().find( '#'+ this.$element.data( 'clear' ) );
|
||||||
|
this.selectedLanguage = null;
|
||||||
|
|
||||||
|
this.listen();
|
||||||
|
};
|
||||||
|
|
||||||
|
var delay = ( function() {
|
||||||
|
var timer = 0;
|
||||||
|
|
||||||
|
return function( callback, milliseconds ) {
|
||||||
|
clearTimeout( timer );
|
||||||
|
timer = setTimeout( callback, milliseconds );
|
||||||
|
};
|
||||||
|
} () );
|
||||||
|
|
||||||
|
LanguageFilter.prototype = {
|
||||||
|
listen: function() {
|
||||||
|
this.$element.on( 'keypress', $.proxy( this.keyup, this ) )
|
||||||
|
.on( 'keyup', $.proxy( this.keyup, this ) );
|
||||||
|
|
||||||
|
if ( this.eventSupported( 'keydown' ) ) {
|
||||||
|
this.$element.on( 'keydown', $.proxy( this.keyup, this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.$clear.length ) {
|
||||||
|
this.$clear.on( 'click' , $.proxy( this.clear, this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toggleClear();
|
||||||
|
},
|
||||||
|
|
||||||
|
keyup: function( e ) {
|
||||||
|
switch( e.keyCode ) {
|
||||||
|
case 9: // Tab -> Autocomplete
|
||||||
|
var suggestion = this.$suggestion.val();
|
||||||
|
|
||||||
|
if ( suggestion && suggestion !== this.$element.val() ) {
|
||||||
|
this.$element.val( suggestion );
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 13: // Enter
|
||||||
|
if ( !this.options.onSelect ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = $.trim( this.$element.val() ).toLowerCase();
|
||||||
|
|
||||||
|
if ( this.selectedLanguage ) {
|
||||||
|
// this.selectLanguage will be populated from a matching search
|
||||||
|
this.options.onSelect( this.selectedLanguage );
|
||||||
|
} else if ( this.options.languages[query] ) {
|
||||||
|
// Search is yet to happen (in timeout delay),
|
||||||
|
// but we have a matching language code.
|
||||||
|
this.options.onSelect( query );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
var languageFilter = this;
|
||||||
|
|
||||||
|
if ( e.which < 32 ) {
|
||||||
|
// ignore any ASCII control characters
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedLanguage = null;
|
||||||
|
|
||||||
|
delay( function() {
|
||||||
|
if ( !languageFilter.$element.val() ) {
|
||||||
|
languageFilter.clear();
|
||||||
|
} else {
|
||||||
|
languageFilter.options.$target.empty();
|
||||||
|
languageFilter.search();
|
||||||
|
}
|
||||||
|
}, 300 );
|
||||||
|
|
||||||
|
this.toggleClear();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the current search removing
|
||||||
|
* clear buttons and suggestions.
|
||||||
|
*/
|
||||||
|
deactivate: function() {
|
||||||
|
this.$element.val( '' );
|
||||||
|
|
||||||
|
if ( !$.fn.uls.Constructor.prototype.isMobile() ) {
|
||||||
|
this.$element.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.toggleClear();
|
||||||
|
this.autofill();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the search and shows all languages
|
||||||
|
*/
|
||||||
|
clear: function() {
|
||||||
|
this.deactivate();
|
||||||
|
this.$element.trigger( 'searchclear' );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the visibility of clear icon depending
|
||||||
|
* on whether there is anything to clear.
|
||||||
|
*/
|
||||||
|
toggleClear: function() {
|
||||||
|
if ( !this.$clear.length ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.$element.val() ) {
|
||||||
|
this.$clear.show();
|
||||||
|
} else {
|
||||||
|
this.$clear.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
search: function() {
|
||||||
|
var query = $.trim( this.$element.val() ),
|
||||||
|
languages = $.uls.data.getLanguagesByScriptGroup( this.options.languages ),
|
||||||
|
scriptGroup, langNum, langCode;
|
||||||
|
|
||||||
|
this.resultCount = 0;
|
||||||
|
|
||||||
|
for ( scriptGroup in languages ) {
|
||||||
|
var 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.
|
||||||
|
this.autofill( langCode );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( query.toLowerCase() === langCode ) {
|
||||||
|
this.selectedLanguage = langCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.render( langCode );
|
||||||
|
this.resultCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also do a search by search API
|
||||||
|
if( !this.resultCount && this.options.searchAPI && query ) {
|
||||||
|
this.searchAPI( query );
|
||||||
|
} else {
|
||||||
|
this.resultHandler( query );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
searchAPI: function( query ) {
|
||||||
|
var languageFilter = this;
|
||||||
|
|
||||||
|
$.get( languageFilter.options.searchAPI, { search: query }, function( result ) {
|
||||||
|
$.each( result.languagesearch, function( code, name ) {
|
||||||
|
if ( languageFilter.resultCount === 0 ) {
|
||||||
|
// Autofill the first result.
|
||||||
|
languageFilter.autofill( code, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
languageFilter.render( code );
|
||||||
|
languageFilter.resultCount++;
|
||||||
|
} );
|
||||||
|
|
||||||
|
languageFilter.resultHandler( query );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler method to be called once search is over.
|
||||||
|
* Based on search result call success or noresults callbacks
|
||||||
|
* @param query string
|
||||||
|
*/
|
||||||
|
resultHandler: function( query ) {
|
||||||
|
if ( this.resultCount === 0 && this.options.noresults ) {
|
||||||
|
this.$suggestion.val( '' );
|
||||||
|
this.options.noresults.call( this, query );
|
||||||
|
} else if ( this.options.success ) {
|
||||||
|
this.options.success( this, query, this.resultCount );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
autofill: function( langCode, languageName ) {
|
||||||
|
if ( !this.$suggestion.length ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !this.$element.val() ) {
|
||||||
|
this.$suggestion.val( '' );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedLanguage = langCode;
|
||||||
|
languageName = languageName || this.options.languages[langCode];
|
||||||
|
|
||||||
|
var autonym,
|
||||||
|
userInput = this.$element.val(),
|
||||||
|
suggestion = userInput + languageName.substring( userInput.length, languageName.length );
|
||||||
|
|
||||||
|
if ( suggestion.toLowerCase() !== languageName.toLowerCase() ) {
|
||||||
|
// see if it was autonym match
|
||||||
|
autonym = $.uls.data.getAutonym( langCode ) || '';
|
||||||
|
suggestion = userInput + autonym.substring( userInput.length, autonym.length );
|
||||||
|
|
||||||
|
if ( suggestion !== autonym ) {
|
||||||
|
// Give up. It may be an ISO/script code match.
|
||||||
|
suggestion = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that it is a visual prefix.
|
||||||
|
if ( !isVisualPrefix( userInput, suggestion ) ) {
|
||||||
|
suggestion = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$suggestion.val( suggestion );
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function( langCode ) {
|
||||||
|
var $target = this.options.$target;
|
||||||
|
|
||||||
|
if ( !$target ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$target.append( langCode, null );
|
||||||
|
},
|
||||||
|
|
||||||
|
escapeRegex: function( value ) {
|
||||||
|
return value.replace( /[\-\[\]{}()*+?.,\\\^$\|#\s]/g, '\\$&' );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A search match happens if any of the following passes:
|
||||||
|
* a) Language name in current user interface language
|
||||||
|
* 'starts with' search string.
|
||||||
|
* b) Language autonym 'starts with' search string.
|
||||||
|
* c) ISO 639 code match with search string.
|
||||||
|
* d) ISO 15924 code for the script match the search string.
|
||||||
|
*/
|
||||||
|
filter: function( langCode, searchTerm ) {
|
||||||
|
// FIXME script is ISO 15924 code. We might need actual name of script.
|
||||||
|
var matcher = new RegExp( '^' + this.escapeRegex( searchTerm ), 'i' ),
|
||||||
|
languageName = this.options.languages[langCode];
|
||||||
|
|
||||||
|
return matcher.test( languageName ) ||
|
||||||
|
matcher.test( $.uls.data.getAutonym( langCode ) ) ||
|
||||||
|
matcher.test( langCode ) ||
|
||||||
|
matcher.test( $.uls.data.getScript( langCode ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
eventSupported: function ( eventName ) {
|
||||||
|
var isSupported = eventName in this.$element;
|
||||||
|
|
||||||
|
if ( !isSupported ) {
|
||||||
|
this.$element.setAttribute( eventName, 'return;' );
|
||||||
|
isSupported = typeof this.$element[eventName] === 'function';
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSupported;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.languagefilter = function( option ) {
|
||||||
|
return this.each( function() {
|
||||||
|
var $this = $( this ),
|
||||||
|
data = $this.data( 'languagefilter' ),
|
||||||
|
options = typeof option === 'object' && option;
|
||||||
|
|
||||||
|
if ( !data ) {
|
||||||
|
$this.data( 'languagefilter', ( data = new LanguageFilter( this, options ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof option === 'string' ) {
|
||||||
|
data[option]();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.languagefilter.defaults = {
|
||||||
|
$target: null, // Where to append the results
|
||||||
|
searchAPI: null,
|
||||||
|
languages: null, // Languages as code:name format.
|
||||||
|
noresults: null, // callback for no results found case
|
||||||
|
success: null, // callback if any results found.
|
||||||
|
onSelect: null // Language select handler - like enter in filter textbox.
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.languagefilter.Constructor = LanguageFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a prefix is visually prefix of a string
|
||||||
|
* @param prefix string
|
||||||
|
* @param string string
|
||||||
|
*/
|
||||||
|
function isVisualPrefix( prefix, string ) {
|
||||||
|
// Pre-base vowel signs of Indic languages. A vowel sign is called pre-base if
|
||||||
|
// consonant + vowel becomes [vowel][consonant] when rendered. Eg: ക + െ => കെ
|
||||||
|
var prebases = 'െേൈൊോൌெேைொோௌେୈୋୌિਿिিেৈোৌෙේෛොෝෞ';
|
||||||
|
return prebases.indexOf( string[prefix.length] ) <= 0;
|
||||||
|
}
|
||||||
|
} ( jQuery ) );
|
||||||
333
lib/jquery.uls/src/jquery.uls.lcd.js
Normal file
333
lib/jquery.uls/src/jquery.uls.lcd.js
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
/**
|
||||||
|
* Universal Language Selector
|
||||||
|
* Language category display component - Used for showing the search results,
|
||||||
|
* grouped by regions, scripts
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
/*jshint multistr:true */
|
||||||
|
var noResultsTemplate = '\
|
||||||
|
<div class="twelve columns uls-no-results-view">\
|
||||||
|
<h2 data-i18n="uls-no-results-found" class="eleven columns end offset-by-one uls-no-results-found-title">\
|
||||||
|
No results found\
|
||||||
|
</h2>\
|
||||||
|
<div id="uls-no-found-more" class="uls-no-found-more">\
|
||||||
|
<div class="ten columns end offset-by-one">\
|
||||||
|
<p>\
|
||||||
|
<span data-i18n="uls-search-help">You can search by language name, \
|
||||||
|
script name, ISO code of language or \
|
||||||
|
you can browse by region:</span>\
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-AM" data-region="AM">America</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-EU" data-region="EU">Europe</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-ME" data-region="ME">Middle East</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-AF" data-region="AF">Africa</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-AS" data-region="AS">Asia</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-PA" data-region="PA">Pacific</a>, \
|
||||||
|
<a class="uls-region-link" data-i18n="uls-region-WW" data-region="WW">Worldwide</a>.\
|
||||||
|
</p>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
/*jshint multistr:false */
|
||||||
|
|
||||||
|
var LanguageCategoryDisplay = function ( element, options ) {
|
||||||
|
this.$element = $( element );
|
||||||
|
this.options = $.extend( {}, $.fn.lcd.defaults, options );
|
||||||
|
this.$element.addClass( 'lcd' );
|
||||||
|
this.regionDivs = {};
|
||||||
|
this.$element.append( $( noResultsTemplate ) );
|
||||||
|
this.$noResults = this.$element.find( 'div.uls-no-results-view' );
|
||||||
|
this.render();
|
||||||
|
this.listen();
|
||||||
|
};
|
||||||
|
|
||||||
|
LanguageCategoryDisplay.prototype = {
|
||||||
|
constructor: LanguageCategoryDisplay,
|
||||||
|
|
||||||
|
append: function ( langCode, regionCode ) {
|
||||||
|
this.addToRegion( langCode, regionCode );
|
||||||
|
this.$noResults.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the language to a region.
|
||||||
|
* If the region parameter is given, add to that region alone
|
||||||
|
* Otherwise to all regions that this language belongs.
|
||||||
|
* @param langCode
|
||||||
|
* @param region Optional region
|
||||||
|
*/
|
||||||
|
addToRegion: function ( langCode, region ) {
|
||||||
|
var lcd = this,
|
||||||
|
language = lcd.options.languages[langCode],
|
||||||
|
langName = $.uls.data.getAutonym( langCode ) || language || langCode,
|
||||||
|
regions = [];
|
||||||
|
|
||||||
|
if ( region ) {
|
||||||
|
regions.push( region );
|
||||||
|
} else {
|
||||||
|
regions = $.uls.data.getRegions( langCode );
|
||||||
|
}
|
||||||
|
|
||||||
|
// World wide languages need not be repeated in all regions.
|
||||||
|
if ( $.inArray( 'WW', regions ) > -1 ) {
|
||||||
|
regions = [ 'WW' ];
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( var i = 0; i < regions.length; i++ ) {
|
||||||
|
var regionCode = regions[i];
|
||||||
|
|
||||||
|
var $li = $( '<li>' )
|
||||||
|
.data( 'code', langCode )
|
||||||
|
.attr( {
|
||||||
|
lang: langCode,
|
||||||
|
dir: $.uls.data.getDir( langCode )
|
||||||
|
} )
|
||||||
|
.append(
|
||||||
|
$( '<a>' ).prop( 'title', language ).html( langName )
|
||||||
|
);
|
||||||
|
|
||||||
|
// Append the element to the column in the list
|
||||||
|
var $column = lcd.getColumn( regionCode );
|
||||||
|
var lastLanguage = $column.find( 'li:last' ).data( 'code' );
|
||||||
|
|
||||||
|
if ( lastLanguage ) {
|
||||||
|
var lastScriptGroup = $.uls.data.getScriptGroupOfLanguage( lastLanguage ),
|
||||||
|
currentScriptGroup = $.uls.data.getScriptGroupOfLanguage( langCode );
|
||||||
|
|
||||||
|
if ( lastScriptGroup !== currentScriptGroup ) {
|
||||||
|
if ( $column.find( 'li' ).length > 2 ) {
|
||||||
|
// If column already has 2 or more languages, add a new column
|
||||||
|
$column = lcd.getColumn( regionCode, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$column.append( $li );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a column to add language.
|
||||||
|
* @param regionCode string The region code
|
||||||
|
* @param forceNew bool whether a new column must be created or not
|
||||||
|
*/
|
||||||
|
getColumn: function ( regionCode, forceNew ) {
|
||||||
|
var $divRegionCode, $rowDiv, $ul;
|
||||||
|
|
||||||
|
forceNew = forceNew || false;
|
||||||
|
$divRegionCode = this.regionDivs[regionCode];
|
||||||
|
$rowDiv = $divRegionCode.find( 'div.row:last' );
|
||||||
|
$ul = $rowDiv.find( 'ul:last' );
|
||||||
|
|
||||||
|
// Each column can have maximum 8 languages.
|
||||||
|
if ( $ul.length === 0 || $ul.find( 'li' ).length >= 8 || forceNew ) {
|
||||||
|
$ul = $( '<ul>' ).addClass( 'three columns end' );
|
||||||
|
|
||||||
|
if ( $rowDiv.length === 0 || $rowDiv.find( 'ul' ).length >= 4 ) {
|
||||||
|
$rowDiv = $( '<div>' ).addClass( 'row uls-language-block' );
|
||||||
|
$divRegionCode.append( $rowDiv );
|
||||||
|
$ul.addClass( 'offset-by-one' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$rowDiv.append( $ul );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't show the region unless it was enabled
|
||||||
|
if ( $.inArray( regionCode, this.options.showRegions ) > -1 ) {
|
||||||
|
$divRegionCode.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ul;
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function () {
|
||||||
|
var $section, $sectionTitle,
|
||||||
|
lcd = this,
|
||||||
|
regions = {
|
||||||
|
// These are fallback text when i18n library not present
|
||||||
|
WW: 'Worldwide',
|
||||||
|
SP: 'Special',
|
||||||
|
AM: 'America',
|
||||||
|
EU: 'Europe',
|
||||||
|
ME: 'Middle East',
|
||||||
|
AS: 'Asia',
|
||||||
|
AF: 'Africa',
|
||||||
|
PA: 'Pacific'
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each( $.uls.data.regiongroups, function ( regionCode, regionIndex ) {
|
||||||
|
$section = $( '<div>' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', regionCode );
|
||||||
|
|
||||||
|
$sectionTitle = $( '<h3 data-i18n="uls-region-' + regionCode + '">' )
|
||||||
|
.addClass( 'eleven columns uls-lcd-region-section uls-lcd-region-title offset-by-one' )
|
||||||
|
.text( regions[regionCode] );
|
||||||
|
|
||||||
|
$section.append( $sectionTitle );
|
||||||
|
lcd.$element.append( $section );
|
||||||
|
$section.hide();
|
||||||
|
lcd.regionDivs[regionCode] = $section;
|
||||||
|
} );
|
||||||
|
|
||||||
|
this.$noResults.hide();
|
||||||
|
this.i18n();
|
||||||
|
},
|
||||||
|
|
||||||
|
i18n: function ( ) {
|
||||||
|
this.$element.find( '[data-i18n]' ).i18n();
|
||||||
|
},
|
||||||
|
|
||||||
|
quicklist: function () {
|
||||||
|
if ( $.isFunction( this.options.quickList ) ) {
|
||||||
|
this.options.quickList = this.options.quickList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !this.options.quickList ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pick only the first elements, because we don't have room for more
|
||||||
|
var quickList = this.options.quickList;
|
||||||
|
quickList = quickList.slice( 0, 16 );
|
||||||
|
quickList.sort( $.uls.data.sortByAutonym );
|
||||||
|
|
||||||
|
var $quickListSection = $( '<div>' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', 'uls-lcd-quicklist' );
|
||||||
|
var $quickListSectionTitle = $( '<h3 data-i18n="uls-common-languages">' )
|
||||||
|
.addClass( 'eleven columns uls-lcd-region-section uls-lcd-region-title offset-by-one' )
|
||||||
|
.text( 'Common languages' ); // This is placeholder text if jquery.i18n not present
|
||||||
|
$quickListSection.append( $quickListSectionTitle );
|
||||||
|
this.$element.prepend( $quickListSection );
|
||||||
|
this.regionDivs.quick = $quickListSection;
|
||||||
|
|
||||||
|
for ( var i = 0; i < quickList.length; i++) {
|
||||||
|
var $column = this.getColumn( 'quick', i % 4 === 0 );
|
||||||
|
var langCode = quickList[i];
|
||||||
|
var language = this.options.languages[langCode];
|
||||||
|
var langName = $.uls.data.getAutonym( langCode ) || language || langCode;
|
||||||
|
var $li = $( '<li>' )
|
||||||
|
.data( 'code', langCode )
|
||||||
|
.attr( {
|
||||||
|
lang: langCode,
|
||||||
|
dir: $.uls.data.getDir( langCode )
|
||||||
|
} )
|
||||||
|
.append(
|
||||||
|
$( '<a>' ).prop( 'title', language ).html( langName )
|
||||||
|
);
|
||||||
|
$column.append( $li );
|
||||||
|
}
|
||||||
|
|
||||||
|
$quickListSection.show();
|
||||||
|
$quickListSectionTitle.i18n();
|
||||||
|
|
||||||
|
return $quickListSection;
|
||||||
|
},
|
||||||
|
|
||||||
|
show: function () {
|
||||||
|
if ( !this.regionDivs ) {
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
empty: function () {
|
||||||
|
this.$element.find( 'div.uls-language-block' ).remove();
|
||||||
|
this.$element.find( 'div.uls-lcd-region-section' ).hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
focus: function () {
|
||||||
|
this.$element.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
noResults: function () {
|
||||||
|
this.$noResults.show();
|
||||||
|
var $suggestions = this.quicklist();
|
||||||
|
$suggestions.find( 'h3' )
|
||||||
|
.data( 'i18n', 'uls-no-results-suggestion-title' )
|
||||||
|
.text( 'You may be interested in:' )
|
||||||
|
.i18n();
|
||||||
|
this.$noResults.find( 'h2' ).after( $suggestions );
|
||||||
|
},
|
||||||
|
|
||||||
|
listen: function () {
|
||||||
|
var lcd = this;
|
||||||
|
|
||||||
|
if ( this.options.clickhandler ) {
|
||||||
|
this.$element.on( 'click', 'div.row li', function () {
|
||||||
|
lcd.options.clickhandler.call( this, $( this ).data( 'code' ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
// The region section need to be in sync with the map filter.
|
||||||
|
lcd.$element.scroll( function () {
|
||||||
|
var inview, inviewRegion,
|
||||||
|
$ulsLanguageList = $( this ),
|
||||||
|
scrollTop = $ulsLanguageList.position().top,
|
||||||
|
scrollBottom = $ulsLanguageList.height();
|
||||||
|
|
||||||
|
if ( lcd.options.lazyload && lcd.options.source.val() === '' ) {
|
||||||
|
if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) {
|
||||||
|
lcd.$element.trigger( 'scrollend' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The region section need to be in sync with the map filter.
|
||||||
|
inviewRegion = 'WW';
|
||||||
|
lcd.$element.find( 'div.uls-lcd-region-section' ).each( function () {
|
||||||
|
var $lcdRegionSection = $( this ),
|
||||||
|
top = $lcdRegionSection.position().top,
|
||||||
|
height = $lcdRegionSection.height(),
|
||||||
|
padding = 10;
|
||||||
|
|
||||||
|
if ( top - padding <= scrollTop && height > scrollBottom ) {
|
||||||
|
inviewRegion = $lcdRegionSection.attr( 'id' );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
inview = $.uls.data.regiongroups[inviewRegion];
|
||||||
|
$( '.regionselector' ).removeClass( 'active' );
|
||||||
|
$( '#uls-region-' + inview ).addClass( 'active' );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.lcd = function ( option ) {
|
||||||
|
return this.each( function () {
|
||||||
|
var $this = $( this ),
|
||||||
|
data = $this.data( 'lcd' ),
|
||||||
|
options = typeof option === 'object' && option;
|
||||||
|
|
||||||
|
if ( !data ) {
|
||||||
|
$this.data( 'lcd', ( data = new LanguageCategoryDisplay( this, options ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof option === 'string') {
|
||||||
|
data[option]();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.lcd.defaults = {
|
||||||
|
languages: null,
|
||||||
|
showRegions: ['WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA'],
|
||||||
|
lazyload: true
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.lcd.Constructor = LanguageCategoryDisplay;
|
||||||
|
|
||||||
|
} ( jQuery ) );
|
||||||
202
lib/jquery.uls/src/jquery.uls.regionfilter.js
Normal file
202
lib/jquery.uls/src/jquery.uls.regionfilter.js
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
/**
|
||||||
|
* jQuery region filter plugin.
|
||||||
|
*
|
||||||
|
* 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';
|
||||||
|
|
||||||
|
/* RegionSelector plugin definition */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Region selector is a language selector based on regions.
|
||||||
|
* Usage: $( 'jqueryselector' ).regionselector( options );
|
||||||
|
* The attached element should have data-regiongroup attribute
|
||||||
|
* that defines the regiongroup for the selector.
|
||||||
|
*/
|
||||||
|
var RegionSelector = function ( element, options ) {
|
||||||
|
this.$element = $( element );
|
||||||
|
this.options = $.extend( {}, $.fn.regionselector.defaults, options );
|
||||||
|
this.$element.addClass( 'regionselector' );
|
||||||
|
this.regions = [];
|
||||||
|
this.cache= null;
|
||||||
|
this.regionGroup = this.$element.data( 'regiongroup' );
|
||||||
|
this.init();
|
||||||
|
this.listen();
|
||||||
|
};
|
||||||
|
|
||||||
|
RegionSelector.prototype = {
|
||||||
|
constructor: RegionSelector,
|
||||||
|
|
||||||
|
init: function () {
|
||||||
|
var region = this.$element.data( 'region' );
|
||||||
|
this.regions = $.uls.data.getRegionsInGroup( this.regionGroup );
|
||||||
|
|
||||||
|
if ( region ) {
|
||||||
|
this.regions.push( region );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
test: function ( langCode ) {
|
||||||
|
var langRegions = $.uls.data.getRegions( langCode ),
|
||||||
|
region;
|
||||||
|
|
||||||
|
for ( var 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 () {
|
||||||
|
if ( this.cache ) {
|
||||||
|
// If the result cache is present, render the results from there.
|
||||||
|
//noinspection JSUnusedAssignment
|
||||||
|
var result = null;
|
||||||
|
|
||||||
|
for ( result in this.cache ) {
|
||||||
|
this.render( result, this.cache[result] );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.cache = {};
|
||||||
|
// Get the languages grouped by script group
|
||||||
|
var languagesByScriptGroup = $.uls.data.getLanguagesByScriptGroup( this.options.languages );
|
||||||
|
|
||||||
|
// Make sure that we go by the original order
|
||||||
|
// of script groups
|
||||||
|
for ( var scriptGroup in $.uls.data.scriptgroups ) {
|
||||||
|
// Get the languages for the script group
|
||||||
|
var 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 ( var i = 0; i < languages.length; i++ ) {
|
||||||
|
// Check whether it belongs to the region
|
||||||
|
this.test( languages[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.options.success ) {
|
||||||
|
this.options.success( this );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function ( langCode, region ) {
|
||||||
|
var $target = this.options.$target;
|
||||||
|
|
||||||
|
if ( !$target ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$target.append( langCode, region );
|
||||||
|
},
|
||||||
|
|
||||||
|
next: function () {
|
||||||
|
var regionSelector = this;
|
||||||
|
|
||||||
|
if ( !this.$element.hasClass( 'active' ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not respond to all scroll end events, but only after a short interval
|
||||||
|
delay( function () {
|
||||||
|
var nextRegionGroupNumber = regionSelector.$element.data( 'regiongroup' ) + 1,
|
||||||
|
$nextRegion = $( '#uls-region-' + nextRegionGroupNumber ),
|
||||||
|
nextRegionSelector = $nextRegion.length && $nextRegion.data( 'regionselector' );
|
||||||
|
|
||||||
|
// If cache is defined, then it is already rendered and there's no need
|
||||||
|
// to re-render it.
|
||||||
|
if ( nextRegionSelector && nextRegionSelector.cache === null ) {
|
||||||
|
nextRegionSelector.show();
|
||||||
|
}
|
||||||
|
}, 100 );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
listen: function () {
|
||||||
|
this.$element.on( 'click', $.proxy( this.click, this ) );
|
||||||
|
this.options.$target.$element.bind( 'scrollend', $.proxy( this.next, this ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
click: function ( e ) {
|
||||||
|
// Don't do anything if a region is selected already
|
||||||
|
if ( this.$element.hasClass( 'active' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-populate the list of languages
|
||||||
|
this.options.$target.empty();
|
||||||
|
this.show();
|
||||||
|
// Make the selected region (and it only) active
|
||||||
|
$( '.regionselector' ).removeClass( 'active' );
|
||||||
|
|
||||||
|
if ( this.regionGroup ) {
|
||||||
|
// if there is a region group, make it active.
|
||||||
|
this.$element.addClass( 'active' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* RegionSelector plugin definition */
|
||||||
|
|
||||||
|
$.fn.regionselector = function ( option ) {
|
||||||
|
return this.each( function () {
|
||||||
|
var $this = $( this ),
|
||||||
|
data = $this.data( 'regionselector' ),
|
||||||
|
options = typeof option === 'object' && option;
|
||||||
|
|
||||||
|
if ( !data ) {
|
||||||
|
$this.data( 'regionselector', ( data = new RegionSelector( this, options ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof option === 'string' ) {
|
||||||
|
data[option]();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.regionselector.defaults = {
|
||||||
|
$target: null, // Where to render the results
|
||||||
|
success: null, // callback if any results found.
|
||||||
|
noresults: null, // callback when no results to show
|
||||||
|
languages: null
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.regionselector.Constructor = RegionSelector;
|
||||||
|
|
||||||
|
var delay = ( function () {
|
||||||
|
var timer = 0;
|
||||||
|
return function ( callback, milliseconds ) {
|
||||||
|
clearTimeout( timer );
|
||||||
|
timer = setTimeout( callback, milliseconds );
|
||||||
|
};
|
||||||
|
} () );
|
||||||
|
|
||||||
|
} ( jQuery ) );
|
||||||
Reference in New Issue
Block a user