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 = { 110 name: uploaded_media[i].name, 111 size: uploaded_media[i].size, 112 attachment_id: uploaded_media[i].attachment_id, 113 status: Dropzone.ADDED, 114 accepted: true, 115 }; 116 galleryDropzone.emit("addedfile", mockFile); 117 galleryDropzone.emit("thumbnail", mockFile, uploaded_media[i].thumb); 118 galleryDropzone.emit("complete", mockFile); 119 galleryDropzone.files.push(mockFile); 120 // If you use the maxFiles option, make sure you adjust it to the 121 // correct amount: 122 var existingFileCount = 1; // The number of files already uploaded 123 galleryDropzone.options.maxFiles = galleryDropzone.options.maxFiles - existingFileCount; 124 } 125 } 126 127 $(".dropzone").sortable({ 128 items:'.dz-preview', 129 cursor: 'move', 130 opacity: 0.5, 131 containment: '.dropzone', 132 distance: 20, 133 tolerance: 'pointer', 134 update: sortinputs 135 }).disableSelection(); 136 137 function sortinputs(){ 138 $('.dropzone .dz-preview').each(function(i, el){ 139 var p = $(el).attr('class').match(/\d+/g); 140 141 $('#media-uploader-ids input#_gallery' + p ) 142 .remove() 143 .appendTo($('#media-uploader-ids')); 144 145 }); 146 } 147} 148 149 150if($("#media-uploader._floorplans").length>0) { 151 /* Upload using dropzone */ 152 Dropzone.autoDiscover = false; 153 154 var floorDropzone = new Dropzone ("#media-uploader._floorplans", { 155 url: listeo_core.upload, 156 maxFiles:listeo_core.maxFiles, 157 maxFilesize:listeo_core.maxFilesize, 158 acceptedFiles: 'image/*', 159 init: function() { 160 161 this.on("addedfile", function(file){ 162 /* Set active thumb class to preview that is used as thumbnail*/ 163 164 }) 165 , 166 this.on("complete", function(file){ 167 file.previewElement.className += ' _gallery'+file.attachment_id; 168 }); 169 }, 170 success: function (file, response) { 171 file.previewElement.classList.add("dz-success"); 172 file['attachment_id'] = response; // push the id for future reference 173 174 $("#media-uploader-ids").append('<input id="_gallery' + file['attachment_id'] +'" type="hidden" name="_gallery[' +file['attachment_id']+ ']" value="'+file['name']+'">'); 175 176 }, 177 error: function (file, response) { 178 file.previewElement.classList.add("dz-error"); 179 }, 180 // update the following section is for removing image from library 181 addRemoveLinks: true, 182 removedfile: function(file) { 183 var attachment_id = file['attachment_id']; 184 $('input#_gallery'+attachment_id).remove(); 185 /*remove thumbnail if the image was set as it*/ 186 if($('#_thumbnail_id').val() == attachment_id){ 187 $('#_thumbnail_id').val(''); 188 } 189 $.ajax({
190 type: 'POST', 191 url: listeo_core.delete, 192 data: { 193 media_id : attachment_id 194 }, 195 success: function (result) { 196 197 console.log(result); 198 }, 199 error: function () { 200 console.log("delete error"); 201 } 202 }); 203 var _ref; 204 return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; 205 } 206 }); 207} 208 209 210 211$(document).ready(function(){ 212 213 $(document).on("click", ".listeo_core-submit-image-preview", function(){ 214 215 $('.listeo_core-submit-image-preview').removeClass('active-thumb'); 216 $(this).addClass('active-thumb'); 217 var id = $(this).data('thumb'); 218 219 $('#_thumbnail_id').val(id); 220 }); 221 222 223 /*floorplans*/ 224 225 if($("#media-uploader._floorplans").length>0) { 226 227 $(".dropzone").sortable({ 228 items:'.dz-preview', 229 cursor: 'move', 230 opacity: 0.5, 231 containment: '.dropzone', 232 distance: 20, 233 tolerance: 'pointer', 234 update: sortinputs 235 }).disableSelection(); 236 237 function sortinputs(){ 238 $('.dropzone .dz-preview').each(function(i, el){ 239 var p = $(el).attr('class').match(/\d+/g); 240 241 $('#media-uploader-ids input#_gallery' + p ) 242 .remove() 243 .appendTo($('#media-uploader-ids')); 244 245 }); 246 } 247 } 248// ------------------ End Document ------------------ // 249}); 250 251})(this.jQuery); 252/**/
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.