formSP_.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <div class="modal" tabindex="-1" data-show="false" id="sphoto" data-backdrop="static" data-keyboard="false">
  2. <div class="modal-dialog modal-lg">
  3. <div class="modal-content">
  4. <div class="modal-header">
  5. <h5 class="modal-title">Выбор всегда есть</h5>
  6. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  7. <span aria-hidden="true">&times;</span>
  8. </button>
  9. </div>
  10. <div class="modal-body">
  11. <div class="input-group mb-3">
  12. <input class="form-control" type="search" placeholder="Искатель" aria-label="Search" name="psearch" id="psearch" aria-describedby="btngo"><div class="input-group-append"><button type="button" id="btngo" class="btn btn-primary" onclick="javascript:return go();" tabindex="0">Go</button>
  13. </div></div>
  14. <div class="carousel slide" data-ride="carousel" id="scarusel">
  15. <div class="carousel-inner" id="result"></div>
  16. <a class="carousel-control-prev" href="#scarusel" role="button" data-slide="prev">
  17. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  18. <span class="sr-only">Предыдущий</span>
  19. </a>
  20. <a class="carousel-control-next" href="#scarusel" role="button" data-slide="next">
  21. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  22. <span class="sr-only">Следующий</span>
  23. </a>
  24. </div>
  25. </div>
  26. <div class="modal-footer">
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <script>
  32. const Item = ({ url, img, title, active, id, titles }) => `
  33. <div class="carousel-item ${active}" onclick="javascript:selectphoto( ${id}, '${titles}');">
  34. <img src="${img}" class="d-block w-100">
  35. <div class="carousel-caption d-none d-md-block">
  36. <h5 class="titles"><div class="title" onclick="javascript:selectphoto( ${id}, '${titles}');">${title}</div></h5>
  37. </div>
  38. `;
  39. function go(){
  40. let s = $('#psearch').val();
  41. $.getJSON( "/manager/sphoto/search?search="+s, function( data ) {
  42. //$('#result').html(data.data);
  43. $( "#result" ).empty();
  44. if(data.status == 'ok'){
  45. $.each( data.data, function( i, item ) {
  46. let img = '/images/news/news/'+item.id+'_size3.jpg';
  47. var avtive = (i == 1)?'active':'';
  48. $('#result').append([
  49. { url: '/manager/sphoto/show?id='+item.id, img: img, title: item.photo_title, active:avtive, id: item.id, titles: item.photo_title.replace(/"/g, '&quot;') } //javascript:selectphoto('+item.id+", '"+item.photo_title+"');
  50. ].map(Item).join(''));
  51. });
  52. $('#scarusel').carousel('pause');
  53. }
  54. });
  55. return false;
  56. }
  57. $("#psearch").keyup(function(event){
  58. if(event.keyCode == 13){
  59. event.preventDefault();
  60. go();
  61. }
  62. });
  63. function selectphoto(id, title){
  64. let img = '/images/news/news/'+id+'_size2.jpg';
  65. $('#image').attr('src', img);
  66. $('#title-photo').text(title);
  67. $('#sphoto').modal('hide');
  68. $('#photo_name').val(id);
  69. }
  70. </script>