Rearranging Files
* Seperating standalone jQuery ULS plugin and extension related code * lib/jquery.uls can be submodule, but not now. Change-Id: I7d9cb47daa88dd1a27ceda602a08cab0073caf33
This commit is contained in:
1 parent
96304a6d22
commit
878313d2ec
18 files changed
+30
-30
No files matched your search
@@ -0,0 +1,4 @@
|
||||
jQuery Universal Language Selector
|
||||
=================================
|
||||
Universal Language Selector
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
.uls-trigger {
|
||||
/* @embed */
|
||||
background: url('../images/icon-language.png') no-repeat scroll left center transparent;
|
||||
padding-left: 30px;
|
||||
}
|
||||
.uls-menu {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
min-width: 715px;
|
||||
margin-top: 1px;
|
||||
width: 45%;
|
||||
/* Styling */
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
*border-right-width: 2px;
|
||||
*border-bottom-width: 2px;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.uls-menu a {
|
||||
color: #0088CC;
|
||||
}
|
||||
.uls-menu h1 {
|
||||
font-weight: normal;
|
||||
padding-top: 1.25em;
|
||||
border: none;
|
||||
padding-bottom: 3px;
|
||||
font-size: 18pt;
|
||||
line-height: 1.25em;
|
||||
padding-left: 15px;
|
||||
color: #777;
|
||||
}
|
||||
.uls-menu h2 {
|
||||
font-size: 16pt;
|
||||
line-height: 1.5em;
|
||||
padding-left: 6px;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 15px;
|
||||
border-bottom: none;
|
||||
color: #777;
|
||||
}
|
||||
.uls-menu h3 {
|
||||
font-size: 14pt;
|
||||
line-height: 1.5em;
|
||||
padding-left: 0px;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.uls-worldmap {
|
||||
/* @embed */
|
||||
background: url('../images/world_map.png') no-repeat scroll right top transparent;
|
||||
background-size: 100%;
|
||||
}
|
||||
.uls-region {
|
||||
/* The map doesn't flip */
|
||||
/* @noflip */
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
height: 125px;
|
||||
border-bottom-color: #777;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 3px;
|
||||
}
|
||||
.uls-region a {
|
||||
bottom: 2px;
|
||||
position: absolute;
|
||||
font-size: 13px;
|
||||
}
|
||||
.uls-region:hover {
|
||||
/*Cross-browser background transparency*/
|
||||
background: #3366bb;
|
||||
background: rgba(51, 102, 187, 0.1);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#253366bb, endColorstr=#253366bb);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#253366bb, endColorstr=#253366bb)";
|
||||
border-bottom-color: #3366bb;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
.regionselector.active {
|
||||
/*Cross-browser background transparency*/
|
||||
background: #3366bb;
|
||||
background: rgba(51, 102, 187, 0.2);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#253366bb, endColorstr=#253366bb);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#253366bb, endColorstr=#253366bb)";
|
||||
border-bottom-color: #3366bb;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
#map-block {
|
||||
top: 1px;
|
||||
margin-right: 0;
|
||||
padding-right: 0px;
|
||||
float: right;
|
||||
overflow: hidden;
|
||||
}
|
||||
#map-block a {
|
||||
color: #444;
|
||||
}
|
||||
#map-block .active a {
|
||||
font-weight: bold;
|
||||
}
|
||||
.icon-close {
|
||||
/* @embed */
|
||||
background: url('../images/close.png') no-repeat scroll center center transparent;
|
||||
float: right;
|
||||
padding: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
input#languagefilter {
|
||||
border: 1px solid #c9c9c9;
|
||||
-moz-transition: all 0.15s linear 0s;
|
||||
border-radius: 2px 2px 2px 2px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
|
||||
color: #333;
|
||||
display: block;
|
||||
background-color: transparent;
|
||||
}
|
||||
input:focus#languagefilter {
|
||||
border: 1px solid #08C;
|
||||
}
|
||||
|
||||
#search {
|
||||
background-color: #f8f8f8;
|
||||
border-top-color: #777;
|
||||
border-top-style: solid;
|
||||
border-top-width: 1px;
|
||||
padding: 0.8em 0;
|
||||
}
|
||||
.search-label {
|
||||
/* @embed */
|
||||
background: url('../images/search.png') no-repeat scroll right center transparent;
|
||||
background-size: 30px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
display: inline-block;
|
||||
float: right;
|
||||
}
|
||||
span#languagefilter-clear {
|
||||
/* @embed */
|
||||
background: url('../images/clear.png') no-repeat scroll left center transparent;
|
||||
cursor: pointer;
|
||||
height: 32px;
|
||||
position: absolute;
|
||||
width: 32px;
|
||||
margin-left: -32px;
|
||||
}
|
||||
|
||||
.filterinput {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
font-size: 14px;
|
||||
height: 32px;
|
||||
padding: 6px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#filtersuggestion {
|
||||
background-color: white;
|
||||
color: #888;
|
||||
border: 1px transparent;
|
||||
border-radius: 2px 2px 2px 2px;
|
||||
box-shadow: 0 1px 2px transparent inset;
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
#search-input-block {
|
||||
position: relative;
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
/* Generated using Foundation http://foundation.zurb.com/docs/grid.php */
|
||||
/* Global Reset & Standards ---------------------- */
|
||||
.uls-menu * {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Misc ---------------------- */
|
||||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.text-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background: #ffff99;
|
||||
}
|
||||
|
||||
/* The Grid ---------------------- */
|
||||
.row {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
min-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.row .row {
|
||||
width: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
margin: 0 -5px;
|
||||
}
|
||||
.row.collapse .column, .row.collapse .columns {
|
||||
padding: 0;
|
||||
}
|
||||
.row .row {
|
||||
width: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
margin: 0 -5px;
|
||||
}
|
||||
.row .row.collapse {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.column, .columns {
|
||||
float: left;
|
||||
min-height: 1px;
|
||||
padding: 0 5px;
|
||||
position: relative;
|
||||
}
|
||||
.column.centered, .columns.centered {
|
||||
float: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.row .one {
|
||||
width: 8.333%;
|
||||
}
|
||||
|
||||
.row .two {
|
||||
width: 16.667%;
|
||||
}
|
||||
|
||||
.row .three {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.row .four {
|
||||
width: 33.333%;
|
||||
}
|
||||
|
||||
.row .five {
|
||||
width: 41.667%;
|
||||
}
|
||||
|
||||
.row .six {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.row .seven {
|
||||
width: 58.333%;
|
||||
}
|
||||
|
||||
.row .eight {
|
||||
width: 66.667%;
|
||||
}
|
||||
|
||||
.row .nine {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
.row .ten {
|
||||
width: 83.333%;
|
||||
}
|
||||
|
||||
.row .eleven {
|
||||
width: 91.667%;
|
||||
}
|
||||
|
||||
.row .twelve {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.row .offset-by-one {
|
||||
margin-left: 8.333%;
|
||||
}
|
||||
|
||||
.row .offset-by-two {
|
||||
margin-left: 16.667%;
|
||||
}
|
||||
|
||||
.row .offset-by-three {
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
||||
.row .offset-by-four {
|
||||
margin-left: 33.333%;
|
||||
}
|
||||
|
||||
.row .offset-by-five {
|
||||
margin-left: 41.667%;
|
||||
}
|
||||
|
||||
.row .offset-by-six {
|
||||
margin-left: 50%;
|
||||
}
|
||||
|
||||
.row .offset-by-seven {
|
||||
margin-left: 58.333%;
|
||||
}
|
||||
|
||||
.row .offset-by-eight {
|
||||
margin-left: 66.667%;
|
||||
}
|
||||
|
||||
.row .offset-by-nine {
|
||||
margin-left: 75%;
|
||||
}
|
||||
|
||||
.row .offset-by-ten {
|
||||
margin-left: 83.333%;
|
||||
}
|
||||
|
||||
.push-two {
|
||||
left: 16.667%;
|
||||
}
|
||||
|
||||
.pull-two {
|
||||
right: 16.667%;
|
||||
}
|
||||
|
||||
.push-three {
|
||||
left: 25%;
|
||||
}
|
||||
|
||||
.pull-three {
|
||||
right: 25%;
|
||||
}
|
||||
|
||||
.push-four {
|
||||
left: 33.333%;
|
||||
}
|
||||
|
||||
.pull-four {
|
||||
right: 33.333%;
|
||||
}
|
||||
|
||||
.push-five {
|
||||
left: 41.667%;
|
||||
}
|
||||
|
||||
.pull-five {
|
||||
right: 41.667%;
|
||||
}
|
||||
|
||||
.push-six {
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
.pull-six {
|
||||
right: 50%;
|
||||
}
|
||||
|
||||
.push-seven {
|
||||
left: 58.333%;
|
||||
}
|
||||
|
||||
.pull-seven {
|
||||
right: 58.333%;
|
||||
}
|
||||
|
||||
.push-eight {
|
||||
left: 66.667%;
|
||||
}
|
||||
|
||||
.pull-eight {
|
||||
right: 66.667%;
|
||||
}
|
||||
|
||||
.push-nine {
|
||||
left: 75%;
|
||||
}
|
||||
|
||||
.pull-nine {
|
||||
right: 75%;
|
||||
}
|
||||
|
||||
.push-ten {
|
||||
left: 83.333%;
|
||||
}
|
||||
|
||||
.pull-ten {
|
||||
right: 83.333%;
|
||||
}
|
||||
|
||||
img, object, embed {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
img {
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
|
||||
#map_canvas img, .map_canvas img {
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
/* Nicolas Gallagher's micro clearfix */
|
||||
.row {
|
||||
*zoom: 1;
|
||||
}
|
||||
.row:before, .row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
.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.
|
||||
-------------------------------------------------- */
|
||||
.block-grid {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
.block-grid > li {
|
||||
display: block;
|
||||
height: auto;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.block-grid.two-up {
|
||||
margin: 0 -15px;
|
||||
}
|
||||
|
||||
.block-grid.two-up > li {
|
||||
width: 50%;
|
||||
padding: 0 15px 15px;
|
||||
}
|
||||
|
||||
/* .block-grid.two-up>li:nth-child(2n+1) {clear: left;} */
|
||||
.block-grid.three-up {
|
||||
margin: 0 -12px;
|
||||
}
|
||||
|
||||
.block-grid.three-up > li {
|
||||
width: 33.33%;
|
||||
padding: 0 12px 12px;
|
||||
}
|
||||
|
||||
/* .block-grid.three-up>li:nth-child(3n+1) {clear: left;} */
|
||||
.block-grid.four-up {
|
||||
margin: 0 -10px;
|
||||
}
|
||||
|
||||
.block-grid.four-up > li {
|
||||
width: 25%;
|
||||
padding: 0 10px 10px;
|
||||
}
|
||||
|
||||
/* .block-grid.four-up>li:nth-child(4n+1) {clear: left;} */
|
||||
.block-grid.five-up {
|
||||
margin: 0 -8px;
|
||||
}
|
||||
|
||||
.block-grid.five-up > li {
|
||||
width: 20%;
|
||||
padding: 0 8px 8px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
.uls-lcd-region-section h3 {
|
||||
color: #999999;
|
||||
}
|
||||
.uls-lcd-region-section ul li:hover {
|
||||
background-color: #eaeff7;
|
||||
}
|
||||
/* Language list */
|
||||
.uls-language-list {
|
||||
height: 21.5em;
|
||||
overflow: auto;
|
||||
margin: 10px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.uls-language-block ul {
|
||||
margin: 0px;
|
||||
margin-bottom: 1.6em;
|
||||
}
|
||||
.uls-language-list ul li {
|
||||
font-weight: normal;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.uls-language-list strong {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.uls-language-list a {
|
||||
font-weight: normal;
|
||||
color: #0088CC;
|
||||
font-size: 14px;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
.uls-language-block .three.columns {
|
||||
width: 22%;
|
||||
}
|
||||
|
||||
.uls-language-block {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.uls-no-results-view {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
#uls-no-found-more {
|
||||
font-size: 0.9em;
|
||||
background: #F8F8F8;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
margin-top: 1.6em;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
( function ( $ ) {
|
||||
$.uls = {};
|
||||
$.uls.data = {"languages":{"aa":["Latn",["AF"]],"ab":["Cyrl",["EU"]],"ace":["Latn",["AS","PA"]],"ady-cyrl":["Cyrl",["EU"]],"ady-latn":["Latn",["EU"]],"ady":["Cyrl",["EU"]],"aeb":["Arab",["AF"]],"af":["Latn",["AF"]],"ahr":["Deva",["AS"]],"ak":["Latn",["AF"]],"akz":["Latn",["NA"]],"aln":["Latn",["EU"]],"am":["Ethi",["AF"]],"an":["Latn",["EU"]],"ang":["Latn",["EU"]],"anp":["Deva",["AS"]],"ar":["Arab",["ME"]],"arc":["Syrc",["ME"]],"arn":["Latn",["SA"]],"aro":["Latn",["LA"]],"arq":["Latn",["AF"]],"ary":["Latn",["ME"]],"arz":["Arab",["ME"]],"as":["Beng",["AS"]],"ase":["Sgnw",["NA"]],"ast":["Latn",["EU"]],"av":["Cyrl",["EU"]],"avk":["Latn",["WW"]],"ay":["Latn",["SA"]],"az":["Latn",["EU","ME"]],"ba":["Cyrl",["EU"]],"bar":["Latn",["EU"]],"bbc-latn":["Latn",["AS"]],"bbc":["Batk",["AS"]],"bcc":["Arab",["AS","ME"]],"bcl":["Latn",["AS"]],"be-tarask":["Cyrl",["EU"]],"be-x-old":["Cyrl",["EU"]],"be":["Cyrl",["EU"]],"bew":["Latn",["AS"]],"bfq":["Taml",["AS"]],"bg":["Cyrl",["EU"]],"bh":["Deva",["AS"]],"bho":["Deva",["AS"]],"bi":["Latn",["PA"]],"bjn":["Latn",["AS"]],"bm":["Latn",["AF"]],"bn":["Beng",["AS"]],"bo":["Tibt",["AS"]],"bpy":["Beng",["AS"]],"bqi":["Arab",["ME"]],"br":["Latn",["EU"]],"brh":["Latn",["ME","AS"]],"bs":["Latn",["EU"]],"bto":["Latn",["AS"]],"bug":["Bugi",["AS"]],"bxr":["Cyrl",["AS"]],"ca":["Latn",["EU"]],"cbk-zam":["Latn",["AS"]],"cdo":["Latn",["AS"]],"ce":["Cyrl",["EU"]],"ceb":["Latn",["AS"]],"ch":["Latn",["PA"]],"cho":["Latn",["NA"]],"chr":["Cher",["NA"]],"chy":["Latn",["NA"]],"ckb":["Arab",["ME"]],"co":["Latn",["EU"]],"cps":["Latn",["AS"]],"cr":["Cans",["NA"]],"crh-cyrl":["Cyrl",["EU"]],"crh-latn":["Latn",["EU"]],"crh":["Latn",["EU"]],"cs":["Latn",["EU"]],"csb":["Latn",["EU"]],"cu":["Cyrl",["EU"]],"cv":["Cyrl",["EU"]],"cy":["Latn",["EU"]],"da":["Latn",["EU"]],"de-at":["Latn",["EU"]],"de-ch":["Latn",["EU"]],"de-formal":["Latn",["EU"]],"de":["Latn",["EU"]],"diq":["Latn",["EU","AS"]],"dsb":["Latn",["EU"]],"dtp":["Latn",["AS"]],"dv":["Thaa",["AS"]],"dz":["Tibt",["AS"]],"ee":["Latn",["AF"]],"egl":["Latn",["EU"]],"el":["Grek",["EU"]],"eml":["Latn",["EU"]],"en-ca":["Latn",["NA"]],"en-gb":["Latn",["EU","AS","AU"]],"en":["Latn",["EU","NA","AU","AF","ME","AS","PA","WW"]],"eo":["Latn",["WW"]],"es-419":["Latn",["LA"]],"es-formal":["Latn",["EU","NA","LA","SA","AF","WW"]],"es":["Latn",["EU","NA","LA","SA","AF","WW"]],"esu":["Latn",["NA"]],"et":["Latn",["EU"]],"eu":["Latn",["EU"]],"ext":["Latn",["EU"]],"fa":["Arab",["ME"]],"ff":["Latn",["AF"]],"fi":["Latn",["EU"]],"fit":["Latn",["EU"]],"fj":["Latn",["PA"]],"fo":["Latn",["EU"]],"fr":["Latn",["EU"]],"frc":["Latn",["EU"]],"frp":["Latn",["EU"]],"frr":["Latn",["EU"]],"fur":["Latn",["EU"]],"fy":["Latn",["EU"]],"ga":["Latn",["EU"]],"gag":["Latn",["EU"]],"gah":["Latn",["AS"]],"gan-hans":["Hans",["AS"]],"gan-hant":["Hant",["AS"]],"gan":["Hant",["AS"]],"gbz":["Latn",["AS"]],"gcf":["Latn",["LA"]],"gd":["Latn",["EU"]],"gl":["Latn",["EU"]],"glk":["Arab",["ME"]],"gn":["Latn",["LA"]],"gom-deva":["Deva",["AS"]],"gom-latn":["Latn",["AS"]],"gom":["Deva",["AS"]],"got":["Goth",["EU"]],"grc":["Grek",["EU"]],"gsw":["Latn",["EU"]],"gu":["Gujr",["AS"]],"guc":["Latn",["LA"]],"gur":["Latn",["AF"]],"gv":["Latn",["EU"]],"ha":["Latn",["AF"]],"hak":["Latn",["AS"]],"haw":["Latn",["NA","PA"]],"he":["Hebr",["ME"]],"hi":["Deva",["AS"]],"hif-deva":["Deva",["AS"]],"hif-latn":["Latn",["PA","AU","AS"]],"hif":["Latn",["PA","AU","AS"]],"hil":["Latn",["AS"]],"hne":["Deva",["AS"]],"ho":["Latn",["PA"]],"hr":["Latn",["EU"]],"hsb":["Latn",["EU"]],"hsn":["Hans",["AS"]],"ht":["Latn",["NA"]],"hu-formal":["Latn",["EU"]],"hu":["Latn",["EU"]],"hy":["Armn",["EU","ME"]],"hz":["Latn",["AF"]],"ia":["Latn",["WW"]],"id":["Latn",["AS"]],"ie":["Latn",["WW"]],"ig":["Latn",["AF"]],"ii":["Yiii",["AS"]],"ik":["Latn",["NA"]],"ike-cans":["Cans",["NA"]],"ike-latn":["Latn",["NA"]],"ike":["Latn",["NA"]],"ilo":["Latn",["AS"]],"inh":["Cyrl",["EU"]],"io":["Latn",["WW"]],"is":["Latn",["EU"]],"it":["Latn",["EU"]],"iu":["Cans",["NA"]],"ja":["Jpan",["AS"]],"jam":["Latn",["NA"]],"jbo":["Latn",["WW"]],"jut":["Latn",["EU"]],"jv":["Latn",["AS","PA"]],"ka":["Geor",["EU"]],"kaa":["Latn",["AS"]],"kab":["Latn",["AF","EU"]],"kbd-cyrl":["Cyrl",["EU","ME"]],"kbd-latn":["Latn",["EU"]],"kbd":["Cyrl",["EU","ME"]],"kea":["Latn",["AF"]],"kg":["Latn",["AF"]],"kgp":["Latn",["LA"]],"khw":["Arab",["ME","AS"]],"ki":["Latn",["AF"]],"kiu":["Latn",["EU","ME"]],"kj":["Latn",["AF"]],"kk-arab":["Arab",["EU","AS"]],"kk-cn":["Arab",["EU","AS","ME"]],"kk-cyrl":["Cyrl",["EU","AS"]],"kk-kz":["Cyrl",["EU","AS"]],"kk-latn":["Latn",["EU","AS","ME"]],"kk-tr":["Latn",["EU","AS","ME"]],"kk":["Cyrl",["EU","AS"]],"kl":["Latn",["NA","EU"]],"km":["Khmr",["AS"]],"kn":["Knda",["AS"]],"ko-kp":["Kore",["AS"]],"ko":["Kore",["AS"]],"koi":["Cyrl",["EU"]],"kr":["Latn",["AF"]],"krc":["Cyrl",["EU"]],"kri":["Latn",["AF"]],"krj":["Latn",["ME","EU"]],"krl":["Latn",["EU"]],"ks-arab":["Arab",["AS"]],"ks-deva":["Deva",["AS"]],"ks":["Arab",["AS"]],"ksf":["Latn",["AF"]],"ksh":["Latn",["EU"]],"ku-arLine truncated
|
||||
$.uls.data.autonyms = {"qqq":"Message documentation","aa":"Qaf\u00e1r af","ab":"\u0410\u04a7\u0441\u0448\u04d9\u0430","ace":"Ac\u00e8h","af":"Afrikaans","ak":"Akan","aln":"Geg\u00eb","als":"Alemannisch","am":"\u12a0\u121b\u122d\u129b","an":"aragon\u00e9s","ang":"\u00c6nglisc","anp":"\u0905\u0919\u094d\u0917\u093f\u0915\u093e","ar":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","arc":"\u0710\u072a\u0721\u071d\u0710","arn":"mapudungun","ary":"Ma\u0121ribi","arz":"\u0645\u0635\u0631\u0649","as":"\u0985\u09b8\u09ae\u09c0\u09df\u09be","ast":"asturianu","av":"\u0410\u0432\u0430\u0440","avk":"Kotava","ay":"Aymar aru","az":"az\u0259rbaycanca","ba":"\u0411\u0430\u0448\u04a1\u043e\u0440\u0442\u0441\u0430","bar":"Boarisch","bat-smg":"\u017demait\u0117\u0161ka","bcc":"\u0628\u0644\u0648\u0686\u06cc \u0645\u06a9\u0631\u0627\u0646\u06cc","bcl":"Bikol Central","be":"\u0431\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f","be-tarask":"\u202a\u0431\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430)\u202c","be-x-old":"\u202a\u0431\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430)\u202c","bg":"\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438","bh":"\u092d\u094b\u091c\u092a\u0941\u0930\u0940","bho":"\u092d\u094b\u091c\u092a\u0941\u0930\u0940","bi":"Bislama","bjn":"Bahasa Banjar","bm":"bamanankan","bn":"\u09ac\u09be\u0982\u09b2\u09be","bo":"\u0f56\u0f7c\u0f51\u0f0b\u0f61\u0f72\u0f42","bpy":"\u09ac\u09bf\u09b7\u09cd\u09a3\u09c1\u09aa\u09cd\u09b0\u09bf\u09af\u09bc\u09be \u09ae\u09a3\u09bf\u09aa\u09c1\u09b0\u09c0","bqi":"\u0628\u062e\u062a\u064a\u0627\u0631\u064a","br":"brezhoneg","brh":"Br\u00e1hu\u00ed","bs":"bosanski","bug":"\u1a05\u1a14 \u1a15\u1a18\u1a01\u1a17","bxr":"\u0411\u0443\u0440\u044f\u0430\u0434","ca":"catal\u00e0","cbk-zam":"Chavacano de Zamboanga","cdo":"M\u00ecng-d\u0115\u0324ng-ng\u1e73\u0304","ce":"\u041d\u043e\u0445\u0447\u0438\u0439\u043d","ceb":"Cebuano","ch":"Chamoru","cho":"Choctaw","chr":"\u13e3\u13b3\u13a9","chy":"Tsets\u00eahest\u00e2hese","ckb":"\u06a9\u0648\u0631\u062f\u06cc","co":"corsu","cps":"Capice\u00f1o","cr":"N\u0113hiyaw\u0113win \/ \u14c0\u1426\u1403\u152d\u140d\u140f\u1423","crh":"Q\u0131r\u0131mtatarca","crh-latn":"\u202aQ\u0131r\u0131mtatarca (Latin)\u202c","crh-cyrl":"\u202a\u041a\u044a\u044b\u0440\u044b\u043c\u0442\u0430\u0442\u0430\u0440\u0434\u0436\u0430 (\u041a\u0438\u0440\u0438\u043b\u043b)\u202c","cs":"\u010desky","csb":"kasz\u00ebbsczi","cu":"\u0441\u043b\u043e\u0432\u0463\u0301\u043d\u044c\u0441\u043a\u044a \/ \u2c14\u2c0e\u2c11\u2c02\u2c21\u2c10\u2c20\u2c14\u2c0d\u2c1f","cv":"\u0427\u04d1\u0432\u0430\u0448\u043b\u0430","cy":"Cymraeg","da":"dansk","de":"Deutsch","de-at":"\u00d6sterreichisches Deutsch","de-ch":"Schweizer Hochdeutsch","de-formal":"\u202aDeutsch (Sie-Form)\u202c","diq":"Zazaki","dsb":"dolnoserbski","dtp":"Dusun Bundu-liwan","dv":"\u078b\u07a8\u0788\u07ac\u0780\u07a8\u0784\u07a6\u0790\u07b0","dz":"\u0f47\u0f7c\u0f44\u0f0b\u0f41","ee":"e\u028begbe","egl":"Emili\u00e0n","el":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac","eml":"emili\u00e0n e rumagn\u00f2l","en":"English","en-ca":"Canadian English","en-gb":"British English","eo":"Esperanto","es":"espa\u00f1ol","et":"eesti","eu":"euskara","ext":"estreme\u00f1u","fa":"\u0641\u0627\u0631\u0633\u06cc","ff":"Fulfulde","fi":"suomi","fit":"me\u00e4nkieli","fiu-vro":"V\u00f5ro","fj":"Na Vosa Vakaviti","fo":"f\u00f8royskt","fr":"fran\u00e7ais","frc":"fran\u00e7ais cadien","frp":"arpetan","frr":"Nordfriisk","fur":"furlan","fy":"Frysk","ga":"Gaeilge","gag":"Gagauz","gan":"\u8d1b\u8a9e","gan-hans":"\u202a\u8d63\u8bed\uff08\u7b80\u4f53\uff09\u202c","gan-hant":"\u202a\u8d1b\u8a9e\uff08\u7e41\u9ad4\uff09\u202c","gd":"G\u00e0idhlig","gl":"galego","glk":"\u06af\u06cc\u0644\u06a9\u06cc","gn":"Ava\u00f1e'\u1ebd","got":"\ud800\udf32\ud800\udf3f\ud800\udf44\ud800\udf39\ud800\udf43\ud800\udf3a","grc":"\u1f08\u03c1\u03c7\u03b1\u03af\u03b1 \u1f11\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u1f74","gsw":"Alemannisch","gu":"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0","gv":"Gaelg","ha":"\u0647\u064e\u0648\u064f\u0633\u064e","hak":"Hak-k\u00e2-fa","haw":"Hawai`i","he":"\u05e2\u05d1\u05e8\u05d9\u05ea","hi":"\u0939\u093f\u0928\u094d\u0926\u0940","hif":"Fiji Hindi","hif-latn":"Fiji Hindi","hil":"Ilonggo","ho":"Hiri Motu","hr":"hrvatski","hsb":"hornjoserbsce","ht":"Krey\u00f2l ayisyen","hu":"magyar","hy":"\u0540\u0561\u0575\u0565\u0580\u0565\u0576","hz":"Otsiherero","ia":"interlingua","id":"Bahasa Indonesia","ie":"Interlingue","ig":"Igbo","ii":"\ua187\ua259","ik":"I\u00f1upiak","ike-cans":"\u1403\u14c4\u1483\u144e\u1450\u1466","ike-latn":"inuktitut","ilo":"Ilokano","inh":"\u0413\u04c0\u0430\u043b\u0433\u04c0\u0430\u0439","io":"Ido","is":"\u00edslenska","it":"italiano","iu":"\u1403\u14c4\u1483\u144e\u1450\u1466\/inuktitut","ja":"\u65e5\u672c\u8a9e","jam":"Patois","jbo":"Lojban","jut":"jysk","jv":"Basa JLine truncated
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
|
||||
<!--
|
||||
Always force latest IE rendering engine (even in intranet) & Chrome Frame
|
||||
Remove this if you use the .htaccess
|
||||
-->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
|
||||
<title>Universal Language Selector</title>
|
||||
<!-- <link rel="shortcut icon" href="/favicon.ico"/> -->
|
||||
<!-- <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> -->
|
||||
<!-- <meta name="description" content=""/> -->
|
||||
<meta name="author" content="Santhosh Thottingal"/>
|
||||
<link href="../css/jquery.uls.css" rel="stylesheet"/>
|
||||
<link href="../css/jquery.uls.grid.css" rel="stylesheet"/>
|
||||
<link href="../css/jquery.uls.lcd.css" rel="stylesheet"/>
|
||||
<!-- demo -->
|
||||
<link href="resources/demo.css" rel="stylesheet"/>
|
||||
<!-- Libs -->
|
||||
<script src="resources/jquery.js"></script>
|
||||
<!-- Source -->
|
||||
<script src="../data/jquery.uls.data.js"></script>
|
||||
<script src="../src/jquery.uls.data.utils.js"></script>
|
||||
<script src="../src/jquery.uls.lcd.js"></script>
|
||||
<script src="../src/jquery.uls.languagefilter.js"></script>
|
||||
<script src="../src/jquery.uls.core.js"></script>
|
||||
<script>
|
||||
$( document ).ready( function() {
|
||||
$( '.uls-trigger' ).uls( {
|
||||
onSelect : function( language ) {
|
||||
var languageName = $.uls.data.autonym( language );
|
||||
$('a#pageLanguage').text( languageName );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<span class="active uls-trigger"> <a id="pageLanguage" href="#">Select Language</a> </span>
|
||||
<h1>Universal Language Selector</h1>
|
||||
<p>
|
||||
Demonstration of jquery plugin
|
||||
</p>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div data-languages="{"aa":"Afar","ab":"Abkhazian","ace":"Achinese","af":"Afrikaans","ak":"Akan","aln":"Gheg Albanian","als":"Alemannisch","am":"Amharic","an":"Aragonese","ang":"Old English","anp":"Angika","ar":"Arabic","arc":"Aramaic","arn":"Araucanian","ary":"Moroccan Spoken Arabic","arz":"Egyptian Spoken Arabic","as":"Assamese","ast":"Asturian","av":"Avaric","avk":"Kotava","ay":"Aymara","az":"Azerbaijani","ba":"Bashkir","bar":"Bavarian","bat-smg":"\u017eemait\u0117\u0161ka","bcc":"Southern Balochi","bcl":"Bikol Central","be":"Belarusian","be-tarask":"Belarusian (Tara\u0161kievica orthography)","be-x-old":"\u202a\u0431\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f (\u0442\u0430\u0440\u0430\u0448\u043a\u0435\u0432\u0456\u0446\u0430)\u202c","bg":"Bulgarian","bh":"Bihari","bho":"Bhojpuri","bi":"Bislama","bjn":"Banjar","bm":"Bambara","bn":"Bengali","bo":"Tibetan","bpy":"Bishnupria Manipuri","bqi":"Bakhtiari","br":"Breton","brh":"Brahui","bs":"Bosnian","bug":"Buginese","bxr":"\u0431\u0443\u0440\u044f\u0430\u0434","ca":"Catalan","cbk-zam":"Chavacano de Zamboanga","cdo":"Min Dong Chinese","ce":"Chechen","ceb":"Cebuano","ch":"Chamorro","cho":"Choctaw","chr":"Cherokee","chy":"Cheyenne","ckb":"Sorani Kurdish","co":"Corsican","cps":"Capiznon","cr":"Cree","crh":"Crimean Turkish","crh-latn":"Crimean Turkish (Latin script)","crh-cyrl":"Crimean Turkish (Cyrillic script)","cs":"Czech","csb":"Kashubian","cu":"Church Slavic","cv":"Chuvash","cy":"Welsh","da":"Danish","de":"German","de-at":"Austrian German","de-ch":"Swiss High German","de-formal":"German (formal address)","diq":"Zazaki","dsb":"Lower Sorbian","dtp":"Central Dusun","dv":"Divehi","dz":"Dzongkha","ee":"Ewe","egl":"Emili\u00e0n","el":"Greek","eml":"Emiliano-Romagnolo","en":"English","en-ca":"Canadian English","en-gb":"British English","eo":"Esperanto","es":"Spanish","et":"Estonian","eu":"Basque","ext":"Extremaduran","fa":"Persian","ff":"Fulah","fi":"Finnish","fit":"me\u00e4nkieli","fiu-vro":"V\u00f5ro","fj":"Fijian","fo":"Faroese","fr":"French","frc":"Cajun French","frp":"Franco-Proven\u00e7al","frr":"Northern Frisian","fur":"Friulian","fy":"Western Frisian","ga":"Irish","gag":"Gagauz","gan":"Gan","gan-hans":"Simplified Gan script","gan-hant":"Traditional Gan script","gd":"Scottish Gaelic","gl":"Galician","glk":"Gilaki","gn":"Guarani","got":"Gothic","grc":"Ancient Greek","gsw":"Swiss German","gu":"Gujarati","gv":"Manx","ha":"Hausa","hak":"Hakka","haw":"Hawaiian","he":"Hebrew","hi":"Hindi","hif":"Fiji Hindi","hif-latn":"Fiji Hindi (Latin script)","hil&quoLine truncated
|
||||
<div class="row">
|
||||
<span class="icon-close"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="four columns">
|
||||
<h1> Select language </h1>
|
||||
</div>
|
||||
<div class="three columns" id="settings-block"></div>
|
||||
<div class="five columns" id="map-block">
|
||||
<div class="row">
|
||||
<div data-regiongroup="4" id="uls-region-4" class="three columns uls-region">
|
||||
<a>Worldwide</a>
|
||||
</div>
|
||||
<div class="nine columns">
|
||||
<div class="row uls-worldmap">
|
||||
<div data-regiongroup="1" id="uls-region-1" class="four columns uls-region">
|
||||
<a>America</a>
|
||||
</div>
|
||||
<div data-regiongroup="2" id="uls-region-2" class="four columns uls-region">
|
||||
<a>Europe
|
||||
<br>
|
||||
Middle east
|
||||
<br>
|
||||
Africa</a>
|
||||
</div>
|
||||
<div data-regiongroup="3" id="uls-region-3" class="four columns uls-region">
|
||||
<a>Asia
|
||||
<br>
|
||||
Australia
|
||||
<br>
|
||||
Pacific</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="search">
|
||||
<div class="row">
|
||||
<div class="one column">
|
||||
<span class="search-label"></span>
|
||||
</div>
|
||||
<div class="ten columns">
|
||||
<div id="search-input-block">
|
||||
<input type="text" class="filterinput" id="filtersuggestion" disabled="true" autocomplete="off"/>
|
||||
<input type="text" class="filterinput" id="languagefilter" data-clear='languagefilter-clear' data-suggestion="filtersuggestion" placeholder="Language search" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="one column">
|
||||
<span id="languagefilter-clear"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row uls-language-list"></div>
|
||||
<div class="row uls-no-results-view">
|
||||
<h2 class="ten columns end offset-by-one">No results found for "<span id="uls-no-found-search-term">Esapnol</span>"</h2>
|
||||
<div id="uls-no-found-more">
|
||||
<div class="ten columns end offset-by-one">
|
||||
<p>You can search by language name, script name, ISO code of language or you can browse by region:
|
||||
<a class="uls-region-link" data-region="NA" href="#">America</a>,
|
||||
<a class="uls-region-link" data-region="EU" href="#">Europe</a>,
|
||||
<a class="uls-region-link" data-region="ME" href="#">Middle East</a>,
|
||||
<a class="uls-region-link" data-region="AF" href="#">Africa</a>,
|
||||
<a class="uls-region-link" data-region="AS" href="#">Asia</a>,
|
||||
<a class="uls-region-link" data-region="PA" href="#">Pacific</a> or
|
||||
<a class="uls-region-link" data-region="WW" href="#">Worldwide languages</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
body {
|
||||
padding-left: 10%;
|
||||
padding-right: 10%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
div.navbar {
|
||||
background-color: #333;
|
||||
color: #FFFFFF;
|
||||
padding: 20px;
|
||||
}
|
||||
span.uls-trigger {
|
||||
float: right;
|
||||
}
|
||||
span.uls-trigger a {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/*! jQuery v1.7.1 jquery.com | jquery.org/license */
|
||||
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function cb(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function ca(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bE.test(a)?d(a,e):ca(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)ca(a+"["+e+"]",b[e],c,d);else d(a,b)}function b_(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bT,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bP),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bC(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bx:by,g=0,h=e.length;if(d>0){if(c!=="border")for(;g<h;g++)c||(d-=parseFloat(f.css(a,"padding"+e[g]))||0),c==="margin"?d+=parseFloat(f.css(a,c+e[g]))||0:d-=parseFloat(f.css(a,"border"+e[g]+"Width"))||0;return d+"px"}d=bz(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0;if(c)for(;g<h;g++)d+=parseFloat(f.css(a,"padding"+e[g]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+e[g]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+e[g]))||0);return d+"px"}function bp(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c+(i[c][d].namespace?".":"")+i[c][d].namespace,i[c][d],i[c][d].data)}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;iLine truncated
|
||||
f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"events")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=[],j,k,l,m,n,o,p,q,r,s,t;g[0]=c,c.delegateTarget=this;if(e&&!c.target.disabled&&(!c.button||c.type!=="click")){m=f(this),m.context=this.ownerDocument||this;for(l=c.target;l!=this;l=l.parentNode||this){o={},q=[],m[0]=l;for(j=0;j<e;j++)r=d[j],s=r.selector,o[s]===b&&(o[s]=r.quick?H(l,r.quick):m.is(s)),o[s]&&q.push(r);q.length&&i.push({elem:l,matches:q})}}d.length>e&&i.push({elem:this,matches:d.slice(e)});for(j=0;j<i.length&&!c.isPropagationStopped();j++){p=i[j],c.currentTarget=p.elem;for(k=0;k<p.matches.length&&!c.isImmediatePropagationStopped();k++){r=p.matches[k];if(h||!c.namespace&&!r.namespace||c.namespace_re&&c.namespace_re.test(r.namespace))c.data=r.data,c.handleObj=r,n=((f.event.special[r.origType]||{}).handle||r.handler).apply(p.elem,g),n!==b&&(c.result=n,n===!1&&(c.preventDefault(),c.stopPropagation()))}}return c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pageX==null&&d.cLine truncated
|
||||
{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bp)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1></$2>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bn(k[i]);else bn(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||be.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bq=/alpha\([^)]*\)/i,br=/opacitLine truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 338 B |
Binary file not shown.
|
After Width: | Height: | Size: 347 B |
Binary file not shown.
|
After Width: | Height: | Size: 987 B |
Binary file not shown.
|
After Width: | Height: | Size: 881 B |
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
@@ -0,0 +1,197 @@
|
||||
/**
|
||||
* <explain briefly what this file is about>.
|
||||
*
|
||||
* 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";
|
||||
|
||||
var ULS = function( element, options ) {
|
||||
this.$element = $( element );
|
||||
this.options = $.extend( {}, $.fn.uls.defaults, options );
|
||||
this.$menu = $( this.options.menu );
|
||||
this.languages = this.$menu.data( 'languages' );
|
||||
for ( var code in this.languages ) {
|
||||
if ( $.uls.data.languages[code] === undefined ) {
|
||||
window.console && console.log && console.log( "ULS: Unknown language " + code + "." );
|
||||
delete this.languages[code];
|
||||
}
|
||||
}
|
||||
this.shown = false;
|
||||
this.$languageFilter = $( 'input#languagefilter' );
|
||||
this.$noResultsView = $( 'div.uls-no-results-view' );
|
||||
this.$resultsView = $( 'div.uls-language-list' );
|
||||
this.$noResultsView.hide();
|
||||
this.render();
|
||||
this.listen();
|
||||
this.ready();
|
||||
};
|
||||
|
||||
ULS.prototype = {
|
||||
constructor: ULS,
|
||||
ready: function() {
|
||||
// Initialize with a full search.
|
||||
this.$languageFilter.val( "" ).languagefilter( "search" );
|
||||
},
|
||||
show: function() {
|
||||
var pos = $.extend( {}, this.$element.offset(), {
|
||||
height: this.$element[0].offsetHeight
|
||||
} );
|
||||
this.$menu.css( {
|
||||
top: pos.top + pos.height,
|
||||
left: '25%'
|
||||
} );
|
||||
|
||||
this.$menu.show();
|
||||
this.shown = true;
|
||||
|
||||
this.$languageFilter.focus();
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$menu.hide();
|
||||
this.shown = false;
|
||||
return this;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
// Rendering stuff here
|
||||
},
|
||||
|
||||
noresults: function( search ) {
|
||||
this.$noResultsView.show();
|
||||
// FIXME i18n
|
||||
this.$noResultsView.find( 'span#uls-no-found-search-term' ).text( search );
|
||||
this.$resultsView.hide();
|
||||
},
|
||||
|
||||
success: function() {
|
||||
this.$noResultsView.hide();
|
||||
this.$resultsView.show();
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
var that = this, lcd;
|
||||
// Register all event listeners to the ULS here.
|
||||
that.$element.on( 'click', $.proxy( that.click, that ) );
|
||||
|
||||
// Handle click on close button
|
||||
$( ".icon-close" ).on( 'click', $.proxy( that.click, that ) );
|
||||
|
||||
// Handle key press events on the menu
|
||||
that.$menu.on('keypress', $.proxy(this.keypress, this) )
|
||||
.on('keyup', $.proxy(this.keyup, this) );
|
||||
if ( $.browser.webkit || $.browser.msie ) {
|
||||
this.$menu.on( 'keydown', $.proxy( this.keypress, this ) )
|
||||
}
|
||||
|
||||
lcd = that.$resultsView.lcd( {
|
||||
languages: that.languages,
|
||||
clickhandler: function( langCode ) {
|
||||
if ( that.options.onSelect ) {
|
||||
that.options.onSelect.call( this, langCode );
|
||||
}
|
||||
}
|
||||
} ).data( "lcd" );
|
||||
|
||||
that.$languageFilter.languagefilter( {
|
||||
$target: lcd,
|
||||
languages: that.languages,
|
||||
success: $.proxy( that.success, that ),
|
||||
noresults: $.proxy( that.noresults, that ),
|
||||
searchAPI: that.options.searchAPI
|
||||
} );
|
||||
|
||||
// Create region selectors, one per region
|
||||
$( '.uls-region, .uls-region-link' ).regionselector( {
|
||||
$target: lcd,
|
||||
languages: that.languages,
|
||||
success: function() {
|
||||
// clear the search field.
|
||||
that.$languageFilter.languagefilter( 'clear' );
|
||||
that.success();
|
||||
}
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
keyup: function( e ) {
|
||||
if ( !this.shown ) {
|
||||
return;
|
||||
}
|
||||
switch( e.keyCode ) {
|
||||
case 27: // escape
|
||||
this.hide();
|
||||
e.preventDefault();
|
||||
break;
|
||||
}
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
keypress: function( e ) {
|
||||
if ( !this.shown ) {
|
||||
return;
|
||||
}
|
||||
switch( e.keyCode ) {
|
||||
case 27: // escape
|
||||
this.hide();
|
||||
e.preventDefault();
|
||||
break;
|
||||
}
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
click: function( e ) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if ( !this.shown ) {
|
||||
this.show();
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* 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: '.uls-menu',
|
||||
onSelect: null, // Callback function to be called when a language is selected
|
||||
searchAPI: null // Language search API
|
||||
};
|
||||
|
||||
$.fn.uls.Constructor = ULS;
|
||||
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
/**
|
||||
* Returns the script of the language.
|
||||
* @param string language code
|
||||
* @return string
|
||||
*/
|
||||
$.uls.data.script = function( language ) {
|
||||
return $.uls.data.languages[language][0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the regions in which a language is spoken.
|
||||
* @param string language code
|
||||
* @return array of strings
|
||||
*/
|
||||
$.uls.data.regions = function( language ) {
|
||||
return ( $.uls.data.languages[language] && $.uls.data.languages[language][1] ) || 'UNKNOWN';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the autonym of the language.
|
||||
* @param string language code
|
||||
* @return string
|
||||
*/
|
||||
$.uls.data.autonym = function( language ) {
|
||||
return $.uls.data.autonyms[language];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an array of all region codes.
|
||||
* @return array
|
||||
*/
|
||||
$.uls.data.allRegions = function() {
|
||||
var allRegions = [];
|
||||
|
||||
for( var 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.languagesInScript = function( script ) {
|
||||
return $.uls.data.languagesInScripts( [ script ] );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns all languages written in the given scripts.
|
||||
* @param scripts array of strings
|
||||
* @return array of strings (languages codes)
|
||||
*/
|
||||
$.uls.data.languagesInScripts = function( scripts ) {
|
||||
var languagesInScripts = [];
|
||||
|
||||
for ( var language in $.uls.data.languages ) {
|
||||
for ( var i = 0; i < scripts.length; i++ ) {
|
||||
if ( scripts[i] === $.uls.data.script(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.languagesInRegion = function( region ) {
|
||||
return $.uls.data.languagesInRegions( [ region ] );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns all languages in given regions.
|
||||
* @param region array of strings.
|
||||
* @return array of strings (languages codes)
|
||||
*/
|
||||
$.uls.data.languagesInRegions = function( regions ) {
|
||||
var languagesInRegions = [];
|
||||
|
||||
for ( var language in $.uls.data.languages ) {
|
||||
for ( var i = 0; i < regions.length; i++ ) {
|
||||
if ( $.inArray( regions[i], $.uls.data.regions( 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.languagesInRegionGroup = function( groupNum ) {
|
||||
return $.uls.data.languagesInRegions( $.uls.data.regionsInGroup( groupNum ) );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an associative array of languages in a region,
|
||||
* grouped by script.
|
||||
* @param string region code
|
||||
* @return associative array
|
||||
*/
|
||||
$.uls.data.languagesByScriptInRegion = function( region ) {
|
||||
var languagesByScriptInRegion = {};
|
||||
|
||||
for ( var language in $.uls.data.languages ) {
|
||||
if ( $.inArray( region, $.uls.data.regions( language ) ) !== -1 ) {
|
||||
var script = $.uls.data.script( 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 string region code
|
||||
* @return associative array
|
||||
*/
|
||||
$.uls.data.languagesByScriptGroupInRegion = function( region ) {
|
||||
return $.uls.data.languagesByScriptGroupInRegions( [ region ] );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an associative array of all languages,
|
||||
* grouped by script group.
|
||||
* @return associative array
|
||||
*/
|
||||
$.uls.data.allLanguagesByScriptGroup = function() {
|
||||
return $.uls.data.languagesByScriptGroupInRegions( $.uls.data.allRegions() );
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the given list of languages sorted by script.
|
||||
* @param languages Array of language codes
|
||||
* @return {Object} Array of languages indexed by script codes
|
||||
*/
|
||||
$.uls.data.languagesByScriptGroup = function( languages ) {
|
||||
var languagesByScriptGroup = {}, scriptGroup, language, langScriptGroup;
|
||||
for ( scriptGroup in $.uls.data.scriptgroups ) {
|
||||
for ( language in languages ) {
|
||||
langScriptGroup = $.uls.data.scriptGroupOfLanguage( language );
|
||||
if( langScriptGroup !== scriptGroup ){
|
||||
continue;
|
||||
}
|
||||
if ( !languagesByScriptGroup[scriptGroup] ) {
|
||||
languagesByScriptGroup[scriptGroup] = [];
|
||||
}
|
||||
languagesByScriptGroup[scriptGroup].push( language );
|
||||
}
|
||||
}
|
||||
return languagesByScriptGroup;
|
||||
};
|
||||
/**
|
||||
* Returns an associative array of languages in several regions,
|
||||
* grouped by script group.
|
||||
* @param array of strings - region codes
|
||||
* @return associative array
|
||||
*/
|
||||
$.uls.data.languagesByScriptGroupInRegions = function( regions ) {
|
||||
var languagesByScriptGroupInRegions = {};
|
||||
|
||||
for ( var language in $.uls.data.languages ) {
|
||||
for ( var i = 0; i < regions.length; i++ ) {
|
||||
if ( $.inArray( regions[i], $.uls.data.regions( language ) ) !== -1 ) {
|
||||
var scriptGroup = $.uls.data.scriptGroupOfLanguage( 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.allLanguagesByRegionAndScript = function() {
|
||||
var allLanguagesByRegionAndScript = {},
|
||||
region,
|
||||
regionGroup;
|
||||
|
||||
for ( region in $.uls.data.regiongroups ) {
|
||||
regionGroup = $.uls.data.regiongroups[region];
|
||||
if ( allLanguagesByRegionAndScript[regionGroup] === undefined ) {
|
||||
allLanguagesByRegionAndScript[regionGroup] = {};
|
||||
}
|
||||
allLanguagesByRegionAndScript[regionGroup][region] = {};
|
||||
}
|
||||
|
||||
for ( var language in $.uls.data.languages ) {
|
||||
var script = $.uls.data.script( language );
|
||||
var scriptGroup = $.uls.data.groupOfScript( script );
|
||||
var regions = $.uls.data.regions( language );
|
||||
|
||||
for ( var 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 number groupNum
|
||||
* @return array of strings
|
||||
*/
|
||||
$.uls.data.regionsInGroup = function( groupNum ) {
|
||||
var regionsInGroup = [];
|
||||
|
||||
for ( var 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 string script code
|
||||
* @return string script group name
|
||||
*/
|
||||
$.uls.data.groupOfScript = function( script ) {
|
||||
for ( var group in $.uls.data.scriptgroups ) {
|
||||
if ( $.inArray( script, $.uls.data.scriptgroups[group] ) !== -1 ) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Other';
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the script group of a language.
|
||||
* @param string language code
|
||||
* @return string script group name
|
||||
*/
|
||||
$.uls.data.scriptGroupOfLanguage = function( language ) {
|
||||
return $.uls.data.groupOfScript( $.uls.data.script( language ) );
|
||||
};
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,338 @@
|
||||
/**
|
||||
* 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.data( 'suggestion' ) );
|
||||
this.$clear = $( '#'+ this.$element.data( 'clear' ) );
|
||||
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 ( $.browser.webkit || $.browser.msie ) {
|
||||
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();
|
||||
} else {
|
||||
this.options.$target.focus();
|
||||
}
|
||||
default:
|
||||
var that = this;
|
||||
delay( function() {
|
||||
that.options.$target.empty();
|
||||
that.search();
|
||||
}, 500 );
|
||||
this.toggleClear();
|
||||
}
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.$element.val( '' );
|
||||
this.$element.focus();
|
||||
this.toggleClear();
|
||||
this.search();
|
||||
},
|
||||
|
||||
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.languagesByScriptGroup( this.options.languages ),
|
||||
scriptGroup, langNum, langCode;
|
||||
this.resultCount = 0;
|
||||
for ( scriptGroup in languages ) {
|
||||
for ( langNum = 0; langNum < languages[scriptGroup].length; langNum++ ) {
|
||||
langCode = languages[scriptGroup][langNum];
|
||||
if ( query === "" || this.filter( langCode, query ) ) {
|
||||
if ( this.resultCount === 0 ) {
|
||||
// Autofill the first result.
|
||||
this.autofill( langCode );
|
||||
}
|
||||
this.render( langCode );
|
||||
this.resultCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Also do a search by search API
|
||||
if( this.options.searchAPI && query ) {
|
||||
this.searchAPI( query );
|
||||
} else {
|
||||
this.resultHandler( query );
|
||||
}
|
||||
},
|
||||
|
||||
searchAPI: function( query ) {
|
||||
var that = this;
|
||||
$.get( that.options.searchAPI, { search: query }, function( result ) {
|
||||
$.each( result['languagesearch'], function( code, name ) {
|
||||
that.render( code, name );
|
||||
that.resultCount++;
|
||||
} );
|
||||
that.resultHandler( query );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler method to be called once search is over.
|
||||
* Based on search result call success or noresults callbacks
|
||||
* @param String query
|
||||
*/
|
||||
resultHandler: function( query ) {
|
||||
if ( this.resultCount === 0 && this.options.noresults ) {
|
||||
this.options.noresults.call( this, query );
|
||||
} else if ( this.options.success ) {
|
||||
this.options.success( this, query, this.resultCount );
|
||||
}
|
||||
},
|
||||
|
||||
autofill: function( langCode ) {
|
||||
if ( !this.$suggestion.length ) {
|
||||
return;
|
||||
}
|
||||
if ( !this.$element.val() ) {
|
||||
this.$suggestion.val( '' );
|
||||
return;
|
||||
}
|
||||
var autonym,
|
||||
languageName = this.options.languages[langCode],
|
||||
userInput = this.$element.val(),
|
||||
suggestion = userInput + languageName.substring( userInput.length, languageName.length );
|
||||
if ( suggestion !== languageName ) {
|
||||
// see if it was autonym match
|
||||
autonym = $.uls.data.autonym( langCode );
|
||||
suggestion = userInput + autonym.substring( userInput.length, autonym.length );
|
||||
if ( suggestion !== autonym ) {
|
||||
// Give up. It may be iso/script code match.
|
||||
suggestion = "";
|
||||
}
|
||||
}
|
||||
this.$suggestion.val( suggestion );
|
||||
},
|
||||
|
||||
render: function( langCode, languageName ) {
|
||||
var $target = this.options.$target;
|
||||
if ( !$target ) {
|
||||
return;
|
||||
}
|
||||
$target.append( langCode, null, languageName );
|
||||
},
|
||||
|
||||
escapeRegex: function( value ) {
|
||||
// This is a prefix search.
|
||||
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.autonym( langCode ) ) ||
|
||||
matcher.test( langCode ) ||
|
||||
matcher.test( $.uls.data.script( langCode ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.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.
|
||||
};
|
||||
|
||||
$.fn.languagefilter.Constructor = LanguageFilter;
|
||||
|
||||
/* 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.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.regionsInGroup( this.regionGroup );
|
||||
if ( region ) {
|
||||
this.regions.push( region );
|
||||
}
|
||||
},
|
||||
|
||||
test: function( langCode ) {
|
||||
var langRegions = $.uls.data.regions( langCode ),
|
||||
region;
|
||||
for ( var i = 0; i < this.regions.length; i++ ) {
|
||||
region = this.regions[i];
|
||||
if ( $.inArray( region, langRegions ) >= 0 ) {
|
||||
this.render( langCode, region );
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
var i, regions, language, languagesByScriptGroup, scriptGroup, languages;
|
||||
// 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' );
|
||||
}
|
||||
// Re-populate the list of languages
|
||||
this.options.$target.empty();
|
||||
languagesByScriptGroup = $.uls.data.languagesByScriptGroup( this.options.languages );
|
||||
for ( scriptGroup in languagesByScriptGroup ) {
|
||||
languages = languagesByScriptGroup[scriptGroup];
|
||||
for ( i = 0; i < languages.length; i++) {
|
||||
language = languages[i];
|
||||
this.test( language );
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.options.success ) {
|
||||
this.options.success.call();
|
||||
}
|
||||
},
|
||||
|
||||
render: function( langCode, region ) {
|
||||
var $target = this.options.$target;
|
||||
if ( !$target ) {
|
||||
return;
|
||||
}
|
||||
$target.append( langCode, region );
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
this.$element.on( 'click', $.proxy( this.click, this ) );
|
||||
},
|
||||
|
||||
click: function( e ) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.show();
|
||||
}
|
||||
};
|
||||
|
||||
/* 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.
|
||||
languages: null
|
||||
};
|
||||
|
||||
$.fn.regionselector.Constructor = RegionSelector;
|
||||
|
||||
} )( jQuery );
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* <explain briefly what this file is about>.
|
||||
*
|
||||
* 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";
|
||||
|
||||
var LanguageCategoryDisplay = function( element, options ) {
|
||||
this.$element = $( element );
|
||||
this.options = $.extend( {}, $.fn.lcd.defaults, options );
|
||||
this.$element.addClass( 'lcd' );
|
||||
this.show();
|
||||
this.listen();
|
||||
};
|
||||
|
||||
LanguageCategoryDisplay.prototype = {
|
||||
constructor: LanguageCategoryDisplay,
|
||||
|
||||
append: function( langCode, regionCode, languageName ) {
|
||||
var that = this;
|
||||
this.addToRegion( langCode, regionCode, languageName );
|
||||
},
|
||||
/**
|
||||
* Check whether a language code is already displayed or not.
|
||||
* @param langCode
|
||||
* @return boolean
|
||||
*/
|
||||
exists: function( langCode ) {
|
||||
return this.$element.find( 'li' ).filter(function() {
|
||||
return $(this).data('code') === langCode;
|
||||
} ).length > 0;
|
||||
},
|
||||
/**
|
||||
* 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
|
||||
* @param languageName Optional languageName
|
||||
*/
|
||||
addToRegion: function( langCode, region, languageName) {
|
||||
var that = this;
|
||||
if ( that.exists( langCode ) ) {
|
||||
return;
|
||||
}
|
||||
var language = $.uls.data.languages[langCode],
|
||||
langName = languageName
|
||||
|| $.uls.data.autonym( langCode )
|
||||
|| that.options.languages[langCode]
|
||||
|| langCode,
|
||||
regions = [];
|
||||
if ( region ) {
|
||||
regions.push( region );
|
||||
} else {
|
||||
regions = $.uls.data.regions( langCode );
|
||||
}
|
||||
|
||||
for ( var i = 0; i < regions.length; i++ ) {
|
||||
var regionCode = regions[i];
|
||||
|
||||
var $li = $( '<li>' )
|
||||
.data( 'code', langCode )
|
||||
.append(
|
||||
$( '<a>' ).prop( 'href', '#' ).prop( 'title', language ).html( langName )
|
||||
);
|
||||
|
||||
// Append the element to the column in the list
|
||||
var column = that.getColumn( regionCode );
|
||||
column.append( $li );
|
||||
|
||||
if ( that.options.clickhandler ) {
|
||||
$li.click( function() {
|
||||
that.options.clickhandler.call( this, langCode );
|
||||
} );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getColumn: function( regionCode ) {
|
||||
var $divRegionCode = $( 'div#' + regionCode );
|
||||
var $rowDiv = $divRegionCode.find( 'div.row:last' );
|
||||
var $ul = $divRegionCode.find( 'ul:last' );
|
||||
// Each column can have maximum 10 languages.
|
||||
if ( $ul.length === 0 || $ul.find( 'li' ).length >= 10 ) {
|
||||
// Each row can have 4 columns with 10 languages.
|
||||
$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 );
|
||||
}
|
||||
$divRegionCode.show();
|
||||
return $ul;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
var that = this;
|
||||
$.each( $.uls.data.regiongroups, function( regionCode, regionIndex ) {
|
||||
var $section = $( '<div>' ).addClass( 'twelve columns uls-lcd-region-section' ).prop( 'id', regionCode );
|
||||
$section.append( $( '<h3>' ).addClass( 'eleven columns uls-lcd-region-section offset-by-one' ).html( regionCode ) );
|
||||
// FIXME this is regioncode(NA, EU etc). Should be proper localized region name.
|
||||
that.$element.append( $section );
|
||||
} );
|
||||
},
|
||||
|
||||
empty: function() {
|
||||
this.$element.find( 'div.row' ).remove();
|
||||
this.$element.find( 'div' ).hide();
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
var that = this;
|
||||
// The region section need to be in sync with the map filter.
|
||||
that.$element.scroll( function () {
|
||||
var inviewRegion = $( 'div.uls-lcd-region-section:first' ).attr( 'id' );
|
||||
var listtop = that.$element.position().top;
|
||||
$( 'div.uls-lcd-region-section' ).each( function () {
|
||||
var offset = $( this ).position().top - listtop;
|
||||
if ( offset < 0 ) {
|
||||
inviewRegion = $( this ).attr( 'id' );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
var inview = $.uls.data.regiongroups[inviewRegion];
|
||||
$( 'div.uls-region' ).removeClass( 'active' );
|
||||
$( 'div#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
|
||||
};
|
||||
|
||||
$.fn.lcd.Constructor = LanguageCategoryDisplay;
|
||||
|
||||
} )( jQuery );
|
||||
Reference in new issue
Block a user