]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/components/image-manager.vue
Added custom user avatars
[bookstack] / resources / assets / js / components / image-manager.vue
index b1c805f8f5c502affe900a5b575036f4a39b2cd2..dd4a77d57855420390dd0ccb00390839e023767b 100644 (file)
@@ -7,7 +7,7 @@
                         <div v-for="image in images">
                             <img class="anim fadeIn"
                                  :class="{selected: (image==selectedImage)}"
-                                 :src="image.thumbnail" :alt="image.title" :title="image.name"
+                                 :src="image.thumbs.gallery" :alt="image.title" :title="image.name"
                                  @click="imageClick(image)"
                                  :style="{animationDelay: ($index > 26) ? '160ms' : ($index * 25) + 'ms'}">
                         </div>
             }
         },
 
+        props: {
+            imageType: {
+                type: String,
+                required: true
+            }
+        },
+
         created: function () {
             window.ImageManager = this;
         },
@@ -88,7 +95,7 @@
         methods: {
             fetchData: function () {
                 var _this = this;
-                this.$http.get('/images/all/' + _this.page, function (data) {
+                this.$http.get('/images/' + _this.imageType + '/all/' + _this.page, function (data) {
                     _this.images = _this.images.concat(data.images);
                     _this.hasMore = data.hasMore;
                     _this.page++;
             setupDropZone: function () {
                 var _this = this;
                 var dropZone = new Dropzone(_this.$els.dropZone, {
-                    url: '/upload/image',
+                    url: '/images/' + _this.imageType + '/upload',
                     init: function () {
                         var dz = this;
                         this.on("sending", function (file, xhr, data) {
                                 dz.removeFile(file);
                             });
                         });
-                        this.on('error', function(file, errorMessage, xhr) {
-                            if(errorMessage.file) {
+                        this.on('error', function (file, errorMessage, xhr) {
+                            if (errorMessage.file) {
                                 $(file.previewElement).find('[data-dz-errormessage]').text(errorMessage.file[0]);
                             }
                             console.log(errorMessage);
                 });
             },
 
+            returnCallback: function (image) {
+                this.callback(image);
+            },
+
             imageClick: function (image) {
                 var dblClickTime = 380;
                 var cTime = (new Date()).getTime();
                 if (this.cClickTime !== 0 && timeDiff < dblClickTime && this.selectedImage === image) {
                     // DoubleClick
                     if (this.callback) {
-                        this.callback(image);
+                        this.returnCallback(image);
                     }
                     this.hide();
                 } else {
 
             selectButtonClick: function () {
                 if (this.callback) {
-                    this.callback(this.selectedImage);
+                    this.returnCallback(this.selectedImage);
                 }
                 this.hide();
             },