Added filters for image type, and french/english locales

preferencesAboutTextFull
Craig Watson 9 years ago
parent 6d5f44b348
commit 2c484ae4a3
  1. 51
      resources/library/search/Pixabay.wgs/index.html
  2. 8
      resources/library/search/Pixabay.wgs/locales/locales.js

@ -5,6 +5,7 @@
<title>Pixabay Image Search</title>
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="locales/locales.js"></script>
</head>
<body>
@ -36,6 +37,9 @@
// Default language to search in, if the application can't return a suitable one
var searchLanguage = "en";
// Language for the widget
var locale = "en";
// Fetch 960px images instead of the default 640px. However the API doesn't
// provide size information in this case, so it is disabled by default.
var fetchMediumResImages = false;
@ -45,6 +49,7 @@
// ---------------------
var currentIndex = 0;
var currentTerm = "";
var filtersDisplayed = false;
// Pixabay's supported search languages
var availableLanguages = ['cs', 'da', 'de', 'en', 'es', 'fr', 'id', 'it', 'hu', 'nl', 'no',
@ -60,8 +65,13 @@
// Get OpenBoard's current language
var appLanguage = window.sankore ? sankore.locale().substr(0,2) : searchLanguage;
// Set it as search language, if possible
if (availableLanguages.indexOf(appLanguage) > -1)
searchLanguage = appLanguage
searchLanguage = appLanguage;
// And as the widget's language
if (locales[searchLanguage] != undefined)
locale = locales[searchLanguage];
var mode = false; //search or view mode
var hide = false; //hide or no main panel
@ -76,12 +86,24 @@
var searchInput = $("<input id='searchInput' class='searchInput' type='text'/>").appendTo(subSearchInput);
var searchButton = $("<div id='searchButton' class='searchButton'>").appendTo(subSearchInput);
var toggleFilters = $("<div id='toggleFilters' class='toggleFilters'>").appendTo(subSearchInput);
var selectFilter = $("<select id='typeFilter' class='filterSelect'>")
.append($("<option value='all'>"+locale.def_opts_val_image+"</option>"))
.append($("<option value='photo'>"+locale.image_type_photo+"</option>"))
.append($("<option value='illustration'>"+locale.image_type_illustration+"</option>"))
.append($("<option value='vector'>"+locale.image_type_vector+"</option>"))
$("<div class='filterContainer'>").append("<span>"+locale.image_type_title+":</span><br/>").append(selectFilter).appendTo(subSearchFilter);
var searchResult = $("<div id='searchResult'>").appendTo("body");
var disc_nav_cont = $("<div id='disc_nav_cont' class='disc_nav_cont'>").appendTo("body");
var disclaimer = $("<div id='disclaimer' class='disclaimer'>Pixabay.com image search<div>").appendTo(disc_nav_cont);
var disclaimer = $("<div id='disclaimer' class='disclaimer'>"+locale.disclaimer_title+"<div>").appendTo(disc_nav_cont);
// Functions
searchButton.click(function(){
if(!hide){
runSearch(searchInput.val(), 0);
@ -93,17 +115,36 @@
if((event.keyCode == 0xA)||(event.keyCode == 0xD)){
runSearch(searchInput.val(), 0);
}
}
});
(
$(".imgContainer").live("click",function(){
($(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this)));
}));
toggleFilters.click(function(){
if(filtersDisplayed){
subSearchFilter.hide();
toggleFilters.css("background-image","url(images/down.png)");
filtersDisplayed = false;
} else {
subSearchFilter.css("display","inline-block");
toggleFilters.css("background-image","url(images/up.png)");
filtersDisplayed = true;
}
});
}
function updateFilters() {
var value = $("#typeFilter option:selected").val();
imageType = value;
}
function runSearch(term, index) {
updateFilters();
currentTerm = term;
currentIndex = index;
var page = index+1; // Page numbers start at 1 on Pixabay

@ -29,6 +29,8 @@ var locales = {
'image_type_title': 'Image type',
'image_type_faces': 'Faces',
'image_type_photo': 'Photo',
'image_type_illustration': 'Illustration',
'image_type_vector': 'Vector',
'image_type_clipart': 'Clipart',
'image_type_lineart': 'Lineart',
'image_license_title': 'Licence',
@ -36,7 +38,7 @@ var locales = {
'image_license_comm_reuse': 'Commercial reuse',
'image_license_modif': 'Modification',
'image_license_comm_modif': 'Commercial modification',
'disclaimer_title': 'This API is based on Google Image. Please refer to terms of use of this service.'
'disclaimer_title': 'Pixabay image search'
},
'fr': {
'def_opts_val_size': 'Toutes',
@ -68,6 +70,8 @@ var locales = {
'image_type_title': 'Types d\'image',
'image_type_faces': 'Visages',
'image_type_photo': 'Photo',
'image_type_illustration': 'Illustration',
'image_type_vector': 'Vectoriel',
'image_type_clipart': 'Images clipart',
'image_type_lineart': 'Dessins au trait',
'image_license_title': 'Droits d\'usage',
@ -75,6 +79,6 @@ var locales = {
'image_license_comm_reuse': 'Usage, distribution, commercial',
'image_license_modif': 'Usage, distribution, modification',
'image_license_comm_modif': 'Usage, distribution, modification, commercial',
'disclaimer_title': 'Cette recherche utilise les services de Google Images. Veuillez vous référer aux conditions d\'utilisation de ce service.'
'disclaimer_title': 'Recherche d\'images sur Pixabay'
}
};

Loading…
Cancel
Save