filemanager.twig (7968B)
1 <div id="filemanager" 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">×</button> 5 <h4 class="modal-title">{{ heading_title }}</h4> 6 </div> 7 <div class="modal-body"> 8 <div class="row"> 9 <div class="col-sm-5"><a href="{{ parent }}" data-toggle="tooltip" title="{{ button_parent }}" id="button-parent" class="btn btn-default"><i class="fa fa-level-up"></i></a> <a href="{{ refresh }}" data-toggle="tooltip" title="{{ button_refresh }}" id="button-refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a> 10 <button type="button" data-toggle="tooltip" title="{{ button_upload }}" id="button-upload" class="btn btn-primary"><i class="fa fa-upload"></i></button> 11 <button type="button" data-toggle="tooltip" title="{{ button_folder }}" id="button-folder" class="btn btn-default"><i class="fa fa-folder"></i></button> 12 <button type="button" data-toggle="tooltip" title="{{ button_delete }}" id="button-delete" class="btn btn-danger"><i class="fa fa-trash-o"></i></button> 13 </div> 14 <div class="col-sm-7"> 15 <div class="input-group"> 16 <input type="text" name="search" value="{{ filter_name }}" placeholder="{{ entry_search }}" class="form-control"> 17 <span class="input-group-btn"> 18 <button type="button" data-toggle="tooltip" title="{{ button_search }}" id="button-search" class="btn btn-primary"><i class="fa fa-search"></i></button> 19 </span></div> 20 </div> 21 </div> 22 <hr /> 23 {% for image in images|batch(4) %} 24 <div class="row"> 25 {% for image in image %} 26 <div class="col-sm-3 col-xs-6 text-center"> 27 {% if image.type == 'directory' %} 28 <div class="text-center"><a href="{{ image.href }}" class="directory" style="vertical-align: middle;"><i class="fa fa-folder fa-5x"></i></a></div> 29 <label> 30 <input type="checkbox" name="path[]" value="{{ image.path }}" /> 31 {{ image.name }}</label> 32 {% endif %} 33 {% if image.type == 'image' %} 34 <a href="{{ image.href }}" class="thumbnail"><img src="{{ image.thumb }}" alt="{{ image.name }}" title="{{ image.name }}" /></a> 35 <label> 36 <input type="checkbox" name="path[]" value="{{ image.path }}" /> 37 {{ image.name }}</label> 38 {% endif %} 39 </div> 40 {% endfor %} 41 </div> 42 <br /> 43 {% endfor %} 44 </div> 45 <div class="modal-footer">{{ pagination }}</div> 46 </div> 47 </div> 48 <script type="text/javascript"><!-- 49 {% if target %} 50 $('a.thumbnail').on('click', function(e) { 51 e.preventDefault(); 52 53 {% if thumb %} 54 $('#{{ thumb }}').find('img').attr('src', $(this).find('img').attr('src')); 55 {% endif %} 56 57 $('#{{ target }}').val($(this).parent().find('input').val()); 58 59 $('#modal-image').modal('hide'); 60 }); 61 {% endif %} 62 63 $('a.directory').on('click', function(e) { 64 e.preventDefault(); 65 66 $('#modal-image').load($(this).attr('href')); 67 }); 68 69 $('.pagination a').on('click', function(e) { 70 e.preventDefault(); 71 72 $('#modal-image').load($(this).attr('href')); 73 }); 74 75 $('#button-parent').on('click', function(e) { 76 e.preventDefault(); 77 78 $('#modal-image').load($(this).attr('href')); 79 }); 80 81 $('#button-refresh').on('click', function(e) { 82 e.preventDefault(); 83 84 $('#modal-image').load($(this).attr('href')); 85 }); 86 87 $('input[name=\'search\']').on('keydown', function(e) { 88 if (e.which == 13) { 89 $('#button-search').trigger('click'); 90 } 91 }); 92 93 $('#button-search').on('click', function(e) { 94 var url = 'index.php?route=common/filemanager&user_token={{ user_token }}&directory={{ directory }}'; 95 96 var filter_name = $('input[name=\'search\']').val(); 97 98 if (filter_name) { 99 url += '&filter_name=' + encodeURIComponent(filter_name); 100 } 101 102 {% if thumb %} 103 url += '&thumb=' + '{{ thumb }}'; 104 {% endif %} 105 106 {% if target %} 107 url += '&target=' + '{{ target }}'; 108 {% endif %} 109 110 $('#modal-image').load(url); 111 }); 112 //--></script> 113 <script type="text/javascript"><!-- 114 $('#button-upload').on('click', function() { 115 $('#form-upload').remove(); 116 117 $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file[]" value="" multiple="multiple" /></form>'); 118 119 $('#form-upload input[name=\'file[]\']').trigger('click'); 120 121 if (typeof timer != 'undefined') { 122 clearInterval(timer); 123 } 124 125 timer = setInterval(function() { 126 if ($('#form-upload input[name=\'file[]\']').val() != '') { 127 clearInterval(timer); 128 129 $.ajax({ 130 url: 'index.php?route=common/filemanager/upload&user_token={{ user_token }}&directory={{ directory }}', 131 type: 'post', 132 dataType: 'json', 133 data: new FormData($('#form-upload')[0]), 134 cache: false, 135 contentType: false, 136 processData: false, 137 beforeSend: function() { 138 $('#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>'); 139 $('#button-upload').prop('disabled', true); 140 }, 141 complete: function() { 142 $('#button-upload i').replaceWith('<i class="fa fa-upload"></i>'); 143 $('#button-upload').prop('disabled', false); 144 }, 145 success: function(json) { 146 if (json['error']) { 147 alert(json['error']); 148 } 149 150 if (json['success']) { 151 alert(json['success']); 152 153 $('#button-refresh').trigger('click'); 154 } 155 }, 156 error: function(xhr, ajaxOptions, thrownError) { 157 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 158 } 159 }); 160 } 161 }, 500); 162 }); 163 164 $('#button-folder').popover({ 165 html: true, 166 placement: 'bottom', 167 trigger: 'click', 168 title: '{{ entry_folder }}', 169 content: function() { 170 html = '<div class="input-group">'; 171 html += ' <input type="text" name="folder" value="" placeholder="{{ entry_folder }}" class="form-control">'; 172 html += ' <span class="input-group-btn"><button type="button" title="{{ button_folder }}" id="button-create" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></span>'; 173 html += '</div>'; 174 175 return html; 176 } 177 }); 178 179 $('#button-folder').on('shown.bs.popover', function() { 180 $('#button-create').on('click', function() { 181 $.ajax({ 182 url: 'index.php?route=common/filemanager/folder&user_token={{ user_token }}&directory={{ directory }}', 183 type: 'post', 184 dataType: 'json', 185 data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()), 186 beforeSend: function() { 187 $('#button-create').prop('disabled', true); 188 }, 189 complete: function() { 190 $('#button-create').prop('disabled', false); 191 }, 192 success: function(json) { 193 if (json['error']) { 194 alert(json['error']); 195 } 196 197 if (json['success']) { 198 alert(json['success']); 199 200 $('#button-refresh').trigger('click'); 201 } 202 }, 203 error: function(xhr, ajaxOptions, thrownError) { 204 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 205 } 206 }); 207 }); 208 }); 209 210 $('#modal-image #button-delete').on('click', function(e) { 211 if (confirm('{{ text_confirm }}')) { 212 $.ajax({ 213 url: 'index.php?route=common/filemanager/delete&user_token={{ user_token }}', 214 type: 'post', 215 dataType: 'json', 216 data: $('input[name^=\'path\']:checked'), 217 beforeSend: function() { 218 $('#button-delete').prop('disabled', true); 219 }, 220 complete: function() { 221 $('#button-delete').prop('disabled', false); 222 }, 223 success: function(json) { 224 if (json['error']) { 225 alert(json['error']); 226 } 227 228 if (json['success']) { 229 alert(json['success']); 230 231 $('#button-refresh').trigger('click'); 232 } 233 }, 234 error: function(xhr, ajaxOptions, thrownError) { 235 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 236 } 237 }); 238 } 239 }); 240 //--></script>