formSP.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <div class="modal" tabindex="-1" data-show="false" id="sphoto" data-backdrop="static" data-keyboard="false">
  2. <div class="modal-dialog modal-lg modal-dialog-scrollable">
  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 id="gallery" class="gallery">
  15. <div class="row" id="result"></div>
  16. </div>
  17. </div>
  18. <div class="modal-footer">
  19. <button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <script>
  25. const Item = ({ url, img, title, active, id, titles }) => `
  26. <div class="carousel-item ${active}" onclick="javascript:selectphoto( ${id}, '${titles}');">
  27. <img src="${img}" class="d-block w-100">
  28. <div class="carousel-caption d-none d-md-block">
  29. <h5 class="titles"><div class="title" onclick="javascript:selectphoto( ${id}, '${titles}');">${title}</div></h5>
  30. </div>
  31. `;
  32. const Itema = ({ url, img, title, active, id, titles }) => `
  33. <div class="col-4" data-key="${id}">
  34. <div class="card mb-2 bg-gradient-dark">
  35. <div class="pics animation all 1" data-key="${id}" onclick="javascript:selectphoto( ${id}, '${titles}');">
  36. <img class="img-fluid card-img-top" src="${img}" alt="">
  37. <div class="card-img-overlay d-flex flex-column justify-content-end cdark">
  38. <span class="titles"><div class="title" onclick="javascript:selectphoto( ${id}, '${titles}');">${title}</div></span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. `;
  44. function go(){
  45. let s = $('#psearch').val();
  46. $.getJSON( "/manager/sphoto/search?search="+s, function( data ) {
  47. //$('#result').html(data.data);
  48. $( "#result" ).empty();
  49. if(data.status == 'ok'){
  50. $.each( data.data, function( i, item ) {
  51. let img = '/images/news/news/'+item.id+'_size3.jpg';
  52. var avtive = (i == 1)?'active':'';
  53. $('#result').append([
  54. { 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+"');
  55. ].map(Itema).join(''));
  56. });
  57. $('#scarusel').carousel('pause');
  58. }
  59. });
  60. return false;
  61. }
  62. $("#psearch").keyup(function(event){
  63. if(event.keyCode == 13){
  64. event.preventDefault();
  65. go();
  66. }
  67. });
  68. function selectphoto(id, title){
  69. let img = '/images/news/news/'+id+'_size2.jpg';
  70. $('#image').attr('src', img);
  71. $('#title-photo').text(title);
  72. $('#sphoto').modal('hide');
  73. $('#photo_name').val(id);
  74. }
  75. </script>
  76. <style>
  77. span.titles{
  78. text-shadow: 1px 1px 2px black;
  79. font-weight: bold;
  80. }
  81. .cdark{
  82. background: linear-gradient(#0000, #000a);
  83. }
  84. .cdark:hover{
  85. background: linear-gradient(#0000, #0000);
  86. }
  87. </style>