common.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. $("#sideMenuButton, #closeSideMenuButton").click(function() {
  2. $(".ui.sidebar")
  3. .sidebar("setting", "transition", "overlay")
  4. .sidebar("toggle");
  5. });
  6. /* START asset search */
  7. /*
  8. $("#topMenuSearch").focus(function() {
  9. $("#topSearchContainer").animate({ width: "300px" });
  10. });
  11. $("#topMenuSearch").focusout(function() {
  12. $("#topSearchContainer").animate({ width: "150px" });
  13. });
  14. */
  15. $("#topSearchContainer").search({
  16. minCharacters: 3,
  17. searchDelay: 500,
  18. searchOnFocus: false,
  19. apiSettings: {
  20. url: "/api/search/?title={query}",
  21. onResponse: function(serverResponse) {
  22. var response = {
  23. results: []
  24. };
  25. $.each(serverResponse.content, function(index, asset) {
  26. response.results.push({
  27. title: asset.details.title,
  28. description: asset.owner.username,
  29. image: "/image/" + asset.mediaLinks.imageIds.split(",")[0],
  30. actionURL: "/" + asset.id,
  31. actionText: "asdasdasd"
  32. });
  33. });
  34. return response;
  35. }
  36. },
  37. onSelect: function(result, response) {
  38. window.location = result.actionURL;
  39. }
  40. });
  41. /* END asset search */
  42. function millisToDate(millis) {
  43. return moment(millis).format("dddd Do MMMM YYYY - HH:mm");
  44. }