1/* ----------------- Start Document ----------------- */ 2(function($){ 3"use strict"; 4 5 6if($("#media-uploader._gallery").length>0) { 7 var gallery_limit = $("#media-uploader._gallery").data('maxfiles'); 8 if(!gallery_limit){ 9 gallery_limit = listeo_core.maxFiles; 10 11 } 12 13 console.log('gallery_limit'+gallery_limit) 14 /* Upload using dropzone */ 15 Dropzone.autoDiscover = false; 16 17 var galleryDropzone = new Dropzone ("#media-uploader._gallery", { 18 url: listeo_core.upload, 19 timeout: 999999, 20 maxFiles:gallery_limit, 21 acceptedFiles: 'image/*', 22 maxFilesize:listeo_core.maxFilesize, 23 dictMaxFilesExceeded: listeo_core.dictMaxFilesExceeded, 24 dictDefaultMessage: listeo_core.dictDefaultMessage, 25 dictFallbackMessage: listeo_core.dictFallbackMessage, 26 dictFallbackText: listeo_core.dictFallbackText, 27 dictFileTooBig: listeo_core.dictFileTooBig, 28 dictInvalidFileType: listeo_core.dictInvalidFileType, 29 dictResponseError: listeo_core.dictResponseError, 30 dictCancelUpload: listeo_core.dictCancelUpload, 31 dictCancelUploadConfirmation: listeo_core.dictCancelUploadConfirmation, 32 dictRemoveFile: listeo_core.dictRemoveFile, 33 init: function() { 34 this.on("sending", function(file, xhr, formData) { 35 var id = $('input[name=property_id]').val(); 36 formData.append("data", id); 37 }); 38 this.on("addedfile", function(file){ 39 /* Set active thumb class to preview that is used as thumbnail*/ 40 41 if(file['attachment_id'] === parseInt($('#_thumbnail_id').val())) { 42 file.previewElement.className += ' active-thumb _gallery'+file['attachment_id']; 43 } else { 44 file.previewElement.className += ' _gallery'+ parseInt(file['attachment_id']); 45 } 46 file.previewElement.addEventListener("click", function() { 47 $('.dz-preview').removeClass('active-thumb'); 48 $(this).addClass('active-thumb'); 49 50 var id = file['attachment_id']; 51 $('#_thumbnail_id').val(id); 52 }); 53 }) 54 , 55 this.on("complete", function(file){ 56 file.previewElement.className += ' _gallery'+file.attachment_id; 57 }); 58 this.on("queuecomplete", function (file) { 59 60 $('.dz-image-preview:first').trigger('click'); //file.previewElement.click(); 61 }); 62 }, 63 success: function (file, response) { 64 file.previewElement.classList.add("dz-success"); 65 response = response.replace(/(\r\n|\n|\r)/gm, ""); 66 file['attachment_id'] = response; // push the id for future reference 67 68 $("#media-uploader-ids").append('<input id="_gallery' + file['attachment_id'] +'" type="hidden" name="_gallery[' +file['attachment_id']+ ']" value="'+file['name']+'">'); 69 70 71 }, 72 error: function (file, response) { 73 file.previewElement.classList.add("dz-error"); 74 $(file.previewElement).find('.dz-error-message').text(response); 75 }, 76 // update the following section is for removing image from library 77 addRemoveLinks: true, 78 removedfile: function(file) { 79 var attachment_id = file['attachment_id']; 80 $('input#_gallery'+attachment_id).remove(); 81 /*remove thumbnail if the image was set as it*/ 82 if($('#_thumbnail_id').val() == attachment_id){ 83 $('#_thumbnail_id').val(''); 84 } 85 $.ajax({
86 type: 'POST', 87 url: listeo_core.delete, 88 data: { 89 media_id : attachment_id 90 }, 91 success: function (result) { 92 93 console.log(result); 94 }, 95 error: function () { 96 console.log("delete error"); 97 } 98 }); 99 var _ref; 100 return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; 101 } 102 }); 103 104 if (typeof images !== typeof undefined && images !== false) { 105 106 var uploaded_media = jQuery.parseJSON(images); 107 for (var i = 0; i < uploaded_media.length; ++i) { 108 109 var mockFile = { name: uploaded_media[i].name, size: uploaded_media[i].size, attachment_id: uploaded_media[i].attachment_id }; 110 galleryDropzone.emit("addedfile", mockFile); 111 galleryDropzone.emit("thumbnail", mockFile, uploaded_media[i].thumb); 112 galleryDropzone.emit("complete", mockFile); 113 galleryDropzone.files.push(mockFile); 114 // If you use the maxFiles option, make sure you adjust it to the 115 // correct amount: 116 var existingFileCount = 1; // The number of files already uploaded 117 galleryDropzone.options.maxFiles = galleryDropzone.options.maxFiles - existingFileCount; 118 } 119 } 120 121 $(".dropzone").sortable({ 122 items:'.dz-preview', 123 cursor: 'move', 124 opacity: 0.5, 125 containment: '.dropzone', 126 distance: 20, 127 tolerance: 'pointer', 128 update: sortinputs 129 }).disableSelection(); 130 131 function sortinputs(){ 132 $('.dropzone .dz-preview').each(function(i, el){ 133 var p = $(el).attr('class').match(/\d+/g); 134 135 $('#media-uploader-ids input#_gallery' + p ) 136 .remove() 137 .appendTo($('#media-uploader-ids')); 138 139 }); 140 } 141} 142 143 144if($("#media-uploader._floorplans").length>0) { 145 /* Upload using dropzone */ 146 Dropzone.autoDiscover = false; 147 148 var floorDropzone = new Dropzone ("#media-uploader._floorplans", { 149 url: listeo_core.upload, 150 maxFiles:listeo_core.maxFiles, 151 maxFilesize:listeo_core.maxFilesize, 152 acceptedFiles: 'image/*', 153 init: function() { 154 155 this.on("addedfile", function(file){ 156 /* Set active thumb class to preview that is used as thumbnail*/ 157 158 }) 159 , 160 this.on("complete", function(file){ 161 file.previewElement.className += ' _gallery'+file.attachment_id; 162 }); 163 }, 164 success: function (file, response) { 165 file.previewElement.classList.add("dz-success"); 166 file['attachment_id'] = response; // push the id for future reference 167 168 $("#media-uploader-ids").append('<input id="_gallery' + file['attachment_id'] +'" type="hidden" name="_gallery[' +file['attachment_id']+ ']" value="'+file['name']+'">'); 169 170 }, 171 error: function (file, response) { 172 file.previewElement.classList.add("dz-error"); 173 }, 174 // update the following section is for removing image from library 175 addRemoveLinks: true, 176 removedfile: function(file) { 177 var attachment_id = file['attachment_id']; 178 $('input#_gallery'+attachment_id).remove(); 179 /*remove thumbnail if the image was set as it*/ 180 if($('#_thumbnail_id').val() == attachment_id){ 181 $('#_thumbnail_id').val(''); 182 } 183 $.ajax({
184 type: 'POST', 185 url: listeo_core.delete, 186 data: { 187 media_id : attachment_id 188 }, 189 success: function (result) { 190 191 console.log(result); 192 }, 193 error: function () { 194 console.log("delete error"); 195 } 196 }); 197 var _ref; 198 return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; 199 } 200 }); 201} 202 203 204 205$(document).ready(function(){ 206 207 $(document).on("click", ".listeo_core-submit-image-preview", function(){ 208 209 $('.listeo_core-submit-image-preview').removeClass('active-thumb'); 210 $(this).addClass('active-thumb'); 211 var id = $(this).data('thumb'); 212 213 $('#_thumbnail_id').val(id); 214 }); 215 216 217 /*floorplans*/ 218 219 if($("#media-uploader._floorplans").length>0) { 220 221 $(".dropzone").sortable({ 222 items:'.dz-preview', 223 cursor: 'move', 224 opacity: 0.5, 225 containment: '.dropzone', 226 distance: 20, 227 tolerance: 'pointer', 228 update: sortinputs 229 }).disableSelection(); 230 231 function sortinputs(){ 232 $('.dropzone .dz-preview').each(function(i, el){ 233 var p = $(el).attr('class').match(/\d+/g); 234 235 $('#media-uploader-ids input#_gallery' + p ) 236 .remove() 237 .appendTo($('#media-uploader-ids')); 238 239 }); 240 } 241 } 242// ------------------ End Document ------------------ // 243}); 244 245})(this.jQuery); 246/**/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.