some fixes in image planete

preferencesAboutTextFull
unknown 12 years ago
parent ed81281946
commit 622b4d9593
  1. 130
      resources/library/search/Image Planete.wgs/index.html

@ -22,10 +22,10 @@
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
if (i * limit < totalResults) { if (i * limit < totalResults) {
var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv); var link = $("<a class='pager_button'></a>").attr('href', 'javascript:gotoPage('+i+');').html(i+1).appendTo(pagesDiv);
if (curPage == i) { if (curPage == i) {
link.addClass('active'); link.addClass('active');
} }
} }
} }
@ -50,59 +50,65 @@
} }
function searchFail(jqXHR, textStatus, errorThrown) { function searchFail(jqXHR, textStatus, errorThrown) {
alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown); alert('Impossible to connect to Planete Sankore: ' + textStatus + ' ' + errorThrown);
} }
function searchComplete(json) { function searchComplete(json) {
// Grab our content div, clear it. // Grab our content div, clear it.
var totalResults = json.totalResults; var totalResults = json.totalResults;
var contentDiv = $('#searchResult').empty(); var contentDiv = $('#searchResult').empty();
// Loop through our results, printing them to the page. // Loop through our results, printing them to the page.
var results = json.rows; var results = json.rows;
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
// For each result write it's title and image to the screen // For each result write it's title and image to the screen
var result = results[i]; var result = results[i];
var imgContainer = $("<div class='imgContainer' draggable='true'>"); var imgContainer = $("<div class='imgContainer' draggable='true'>");
//var title = document.createElement('div'); //var title = document.createElement('div');
var iUrl = $("<input type='hidden'/>"); var iUrl = $("<input type='hidden'/>");
var iContent = $("<input type='hidden'/>"); var iContent = $("<input type='hidden'/>");
var iHeight = $("<input type='hidden'/>"); var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>"); var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>"); var iTitle = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the // We use titleNoFormatting so that no HTML tags are left in the
// title // title
//title.innerHTML = result.title; //title.innerHTML = result.title;
var newImg = document.createElement('img'); var newImg = document.createElement('img');
// There is also a result.file property which has the escaped version // There is also a result.file property which has the escaped version
if (thumbnails) { if (thumbnails) {
newImg.src = result.file; newImg.src = result.file;
} else { if(result.height >= result.width)
newImg.src = "./images/thumbnail_icon.png"; newImg.height = minHeight;
} else{
var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth; newImg.width = minWidth;
var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight; //newImg.style.margin = (120 - result.height)/2 + "px 0";
imgContainer.width(imgWidth).height(imgHeight); }
imgContainer.append($(newImg)); } else {
iUrl.attr("value", result.file); newImg.src = "./images/thumbnail_icon.png";
iContent.attr("value", result.title); }
iHeight.attr("value", result.height); var imgWidth = (result.tbWidth > minWidth)?result.tbWidth:minWidth;
iWidth.attr("value", result.width); var imgHeight = (result.tbHeight > minHeight)?result.tbHeight:minHeight;
iTitle.attr("value",result.title); imgContainer.width(imgWidth).height(imgHeight);
//imgContainer.append($(title)); imgContainer.append($(newImg));
imgContainer.append(iUrl); iUrl.attr("value", result.file);
imgContainer.append(iContent); iContent.attr("value", result.title);
imgContainer.append(iHeight); iHeight.attr("value", result.height);
imgContainer.append(iWidth); iWidth.attr("value", result.width);
imgContainer.append(iTitle); iTitle.attr("value",result.title);
//imgContainer.append($(title));
imgContainer.append(iUrl);
imgContainer.append(iContent);
imgContainer.append(iHeight);
imgContainer.append(iWidth);
imgContainer.append(iTitle);
// Put our title + image in the content // Put our title + image in the content
imgContainer.appendTo(contentDiv); imgContainer.appendTo(contentDiv);
} }
// Now add links to additional pages of search results. // Now add links to additional pages of search results.
addPaginationLinks(totalResults); addPaginationLinks(totalResults);
} }
function imageDragging(e){ function imageDragging(e){
@ -166,9 +172,9 @@
filtersDisplayed = true; filtersDisplayed = true;
} }
}); });
*/ */
/*togglePages.click(function(event){ /*togglePages.click(function(event){
if(mode){ if(mode){
hide = false; hide = false;
$("#search, #disclaimer").slideDown('slow', function(){ $("#search, #disclaimer").slideDown('slow', function(){
@ -204,10 +210,10 @@
}); });
( (
$(".imgContainer").live("click",function(){ $(".imgContainer").live("click",function(){
sankore.sendFileMetadata(createMetaData($(this))); sankore.sendFileMetadata(createMetaData($(this)));
})); }));
/*$(window).resize(function(){ /*$(window).resize(function(){
disclaimer.width($("body").width()-20); disclaimer.width($("body").width()-20);
search.width($("body").width()-20); search.width($("body").width()-20);
toggleIcon.css("margin-left",(togglePages.width()/2 - 7)); toggleIcon.css("margin-left",(togglePages.width()/2 - 7));
@ -216,21 +222,21 @@
}); });
function gotoPage(i) { function gotoPage(i) {
runSearch(currentTerm, i); runSearch(currentTerm, i);
} }
// launching the search on planete sankore // launching the search on planete sankore
function runSearch(term, index) { function runSearch(term, index) {
currentTerm = term; currentTerm = term;
currentIndex = index; currentIndex = index;
var start = index * limit; var start = index * limit;
var url = "http://planete.sankore.org/xwiki/bin/view/Search/Resources?xpage=plain&category=" + category + "&level=&sort=title&dir=ASC&terms=" + escape(term) + "&start=" + start + "&limit=" + limit; var url = "http://planete.sankore.org/xwiki/bin/view/Search/Resources?xpage=plain&category=" + category + "&level=&sort=title&dir=ASC&terms=" + escape(term) + "&start=" + start + "&limit=" + limit;
$.ajax({ $.ajax({
url: url, url: url,
success: searchComplete, success: searchComplete,
error: searchFail, error: searchFail,
dataType: "json" dataType: "json"
}); });
} }
function createMetaData(parent){ function createMetaData(parent){

Loading…
Cancel
Save