index.blade.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <div class="modal-dialog modal-lg">
  2. <div class="modal-content">
  3. <div class="modal-header">
  4. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  5. <h4 class="modal-title">{{$heading_title}} <span>{{request('directory','')}}</span> </h4>
  6. </div>
  7. <div class="modal-body">
  8. <div class="row">
  9. <p class="text-red col-sm-12">建议创建目录分类管理图片,避免图片因同名等问题被覆盖也方便后期管理维护</p>
  10. </div>
  11. <div class="row">
  12. <div class="col-sm-5">
  13. <a href="<?php echo $data['parent']; ?>" data-toggle="tooltip" title="上级" id="button-parent" class="btn btn-default"><i class="fa fa-level-up"></i></a>
  14. <a href="<?php echo $data['refresh']; ?>" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
  15. <button type="button" data-toggle="tooltip" title="上传" id="button-upload" class="btn btn-primary"><i class="fa fa-upload"></i></button>
  16. <button type="button" data-toggle="tooltip" title="新建" id="button-folder" class="btn btn-default"><i class="fa fa-folder"></i></button>
  17. <button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger"><i class="fa fa-trash-o"></i></button>
  18. <!--<button type="button" data-toggle="tooltip" title="确定" id="button-check" class="btn btn-success"><i class="fa fa-check"></i></button>-->
  19. </div>
  20. <div class="col-sm-7">
  21. <div class="input-group">
  22. <input class="form-control search-query" type="text" placeholder="搜索" value="{{request('filter_name','')}}" name="search">
  23. <span class="input-group-btn">
  24. <button id="button-search" class="btn btn-primary btn-sm" type="button">
  25. <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
  26. 搜索
  27. </button>
  28. </span>
  29. </div>
  30. </div>
  31. </div>
  32. <hr />
  33. <?php if(!empty($data['images'])){ ?>
  34. <?php foreach (array_chunk($data['images'], 4) as $image) { ?>
  35. <div class="row">
  36. <?php foreach ($image as $image) { ?>
  37. <div class="col-sm-3 text-center">
  38. <?php if ($image['type'] == 'directory') { ?>
  39. <div class="text-center"><a href="<?php echo $image['href']; ?>" class="directory" style="vertical-align: middle;"><i class="fa fa-folder fa-5x"></i></a></div>
  40. <label>
  41. <input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
  42. <?php echo $image['name']; ?></label>
  43. <?php } ?>
  44. <?php if ($image['type'] == 'image') { ?>
  45. <a class="thumbnail"><img src="<?php echo path_compat( $image['thumb']); ?>" alt="<?php echo $image['name']; ?>" title="<?php echo $image['name']; ?>" /></a>
  46. <label>
  47. <input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
  48. <?php echo $image['name']; ?></label>
  49. <?php } ?>
  50. </div>
  51. <?php } ?>
  52. </div>
  53. <br />
  54. <?php } ?>
  55. <?php } ?>
  56. </div>
  57. <div class="modal-footer"><?php echo $data['pagination']; ?></div>
  58. </div>
  59. </div>
  60. <script type="text/javascript">
  61. <?php if ($data['target']) { ?>
  62. $('a.thumbnail').on('click', function(e) {
  63. e.preventDefault();
  64. <?php if ($data['thumb']) { ?>
  65. $("#<?php echo $data['thumb']; ?>").find('img').attr('src', $(this).find('img').attr('src'));
  66. <?php } ?>
  67. $("#<?php echo $data['target']; ?>").attr('value', $(this).parent().find('input').attr('value'));
  68. $('#modal-image').modal('hide');
  69. });
  70. <?php } ?>
  71. $('a.directory').on('click', function(e) {
  72. e.preventDefault();
  73. $('#modal-image').load($(this).attr('href'));
  74. });
  75. $('.pagination a').on('click', function(e) {
  76. e.preventDefault();
  77. $('#modal-image').load($(this).attr('href'));
  78. });
  79. $('#button-parent').on('click', function(e) {
  80. e.preventDefault();
  81. $('#modal-image').load($(this).attr('href'));
  82. });
  83. $('#button-refresh').on('click', function(e) {
  84. e.preventDefault();
  85. $('#modal-image').load($(this).attr('href'));
  86. });
  87. $('input[name=\'search\']').on('keydown', function(e) {
  88. if (e.which == 13) {
  89. $('#button-search').trigger('click');
  90. }
  91. });
  92. $('#button-search').on('click', function(e) {
  93. var url = "{{$data['search_url']}}";
  94. var filter_name = $('input[name=\'search\']').val();
  95. if (filter_name) {
  96. url += '&filter_name=' + encodeURIComponent(filter_name);
  97. }
  98. <?php if (request('thumb')) { ?>
  99. url += '&thumb=' + "<?php echo request('thumb'); ?>";
  100. <?php } ?>
  101. <?php if (request('target')) { ?>
  102. url += '&target=' + "<?php echo request('target'); ?>";
  103. <?php } ?>
  104. $('#modal-image').load(url);
  105. });
  106. $('#button-upload').on('click', function() {
  107. $('#form-upload').remove();
  108. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input id="upload_img" multiple="multiple" type="file" name="file[]" value="" /></form>');
  109. $('#upload_img').trigger('click');
  110. if (typeof timer != 'undefined') {
  111. clearInterval(timer);
  112. }
  113. timer = setInterval(function() {
  114. if ($('#upload_img').val() != '') {
  115. clearInterval(timer);
  116. $.ajax({
  117. url: "<?php echo $data['upload_url']; ?>",
  118. type: 'post',
  119. dataType: 'json',
  120. data: new FormData($('#form-upload')[0]),
  121. cache: false,
  122. contentType: false,
  123. processData: false,
  124. beforeSend: function() {
  125. $('#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
  126. $('#button-upload').prop('disabled', true);
  127. },
  128. complete: function() {
  129. $('#button-upload i').replaceWith('<i class="fa fa-upload"></i>');
  130. $('#button-upload').prop('disabled', false);
  131. },
  132. success: function(json) {
  133. if (json['error']) {
  134. art.dialog({content:json['error'],lock: true,});
  135. }
  136. if (json['success']) {
  137. art.dialog({content:json['success'],lock: true,});
  138. $('#button-refresh').trigger('click');
  139. }
  140. },
  141. error: function(xhr, ajaxOptions, thrownError) {
  142. art.dialog({content:thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText,lock: true,});
  143. }
  144. });
  145. }
  146. }, 500);
  147. });
  148. $('#button-folder').popover({
  149. html: true,
  150. placement: 'bottom',
  151. trigger: 'click',
  152. title: '新建文件夹',
  153. content: function() {
  154. html = '<div class="input-group">';
  155. html += ' <input type="text" name="folder" value="" placeholder="文件夹名称" class="form-control">';
  156. html += ' <span class="input-group-btn"><button type="button" title="新建文件夹" id="button-create" class="btn btn-primary btn-sm""><i class="fa fa-plus-circle"></i></button></span>';
  157. html += '</div>';
  158. return html;
  159. }
  160. });
  161. $('#button-folder').on('shown.bs.popover', function() {
  162. $('#button-create').on('click', function() {
  163. $.ajax({
  164. url:"<?php echo $data['folder_url']; ?>",
  165. type: 'post',
  166. dataType: 'json',
  167. data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
  168. beforeSend: function() {
  169. $('#button-create').prop('disabled', true);
  170. },
  171. complete: function() {
  172. $('#button-create').prop('disabled', false);
  173. },
  174. success: function(json) {
  175. if (json['error']) {
  176. art.dialog({content:json['error'],lock: true,});
  177. }
  178. if (json['success']) {
  179. art.dialog({content:json['success'],lock: true,});
  180. $('#button-refresh').trigger('click');
  181. }
  182. },
  183. error: function(xhr, ajaxOptions, thrownError) {
  184. art.dialog({content:thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText,lock: true,});
  185. }
  186. });
  187. });
  188. });
  189. $('#modal-image #button-delete').on('click', function(e) {
  190. art.dialog({
  191. content: '是否要删除',
  192. lock: true,
  193. ok: function () {
  194. $.ajax({
  195. url: "<?php echo $data['delete_url']; ?>",
  196. type: 'post',
  197. dataType: 'json',
  198. data: $('input[name^=\'path\']:checked'),
  199. beforeSend: function() {
  200. $('#button-delete').prop('disabled', true);
  201. },
  202. complete: function() {
  203. $('#button-delete').prop('disabled', false);
  204. },
  205. success: function(json) {
  206. if (json['error']) {
  207. art.dialog({content:json['error'],lock: true,});
  208. }
  209. if (json['success']) {
  210. art.dialog({content:json['success'],lock: true,});
  211. $('#button-refresh').trigger('click');
  212. }
  213. },
  214. error: function(xhr, ajaxOptions, thrownError) {
  215. art.dialog({content:thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText,lock: true,});
  216. }
  217. });
  218. }
  219. });
  220. // input.each(function(i){
  221. // var cur_img=$(this).parent().parent().find('img').attr('src');
  222. // var cur_input=$(this).val();
  223. // $(target[i]).find('img').attr('src',cur_img);
  224. // $(target[i]).find('input').attr('value',cur_input);
  225. // });
  226. // $('#modal-image').modal('hide');
  227. });
  228. </script>