Files
alfresco-community-repo/source/web/scripts/office/search.js
Mike Hatfield f67d1540f1 Office add-in updates. Part 2 of 2 (webscripts)
ALFCOM-2442, ALFCOM-2440, ALFCOM-597, ALFCOM-2145, ALFCOM-2768, ETHREEOH-1545, ALFCOM-2764, ALFCOM-2104, ETHREEOH-1532, ETHREEOH-543, ETHREEOH-1523, ETHREEOH-1516, ETHREEOH-1028

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14813 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2009-06-19 15:30:15 +00:00

79 lines
2.1 KiB
JavaScript

/*
* Prerequisites: mootools.v1.11.js
* office_addin.js
*/
var OfficeSearch =
{
MIN_LENGTH: 3,
init: function()
{
$('searchText').addEvent('keydown', function(event)
{
event = new Event(event);
if (event.key == 'enter')
{
$("simpleSearchButton").onclick();
}
});
$('itemsFound').innerHTML = "Results Shown Below";
$('searchText').focus();
},
itemsFound: function(shownResults, totalResults)
{
var strFound;
if (totalResults === 0)
{
strFound = "No items found";
}
else if (shownResults < totalResults)
{
strFound = "Showing first " + shownResults + " of " + totalResults + " total items found";
}
else
{
strFound = "Showing all " + shownResults + " items found";
}
$('itemsFound').innerHTML = strFound;
},
/* AJAX call to perform server-side search */
runSearch: function(useTemplate, argPath)
{
var searchString = $('searchText').value;
var maxResults = $('maxResults').value;
if (searchString.length < OfficeSearch.MIN_LENGTH)
{
OfficeAddin.showStatusText("Minimum " + OfficeSearch.MIN_LENGTH + " characters.", "info.gif", true);
return;
}
OfficeAddin.showStatusText("Searching...", "ajax_anim.gif", false);
var actionURL = useTemplate + argPath + "&search=" + encodeURIComponent(searchString) + "&maxresults=" + maxResults;
var myAjax = new Ajax(actionURL,
{
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
evalScripts: true,
onComplete: function(textResponse, xmlResponse)
{
OfficeAddin.hideStatusText();
$('searchResultsList').innerHTML = textResponse;
/* Custom tooltips
var myTips = new Tips($$(".toolTip"),
{
fixed: true,
maxTitleChars: 50
});
*/
}
});
myAjax.request();
}
};
window.addEvent('domready', OfficeSearch.init);