1jQuery.widget( 'gc.gcFileWidget', $.gc.gcFileSelectorFolder, { 2 TYPE_IMAGE: 'image', 3 TYPE_VIDEO: 'video', 4 options: { 5 owner: null, 6 width: 200, 7 height: 200, 8 autoSize: false, 9 type: this.TYPE_IMAGE, 10 accept: '', 11 isShowHint: '' 12 }, 13 _create: function() { 14 var self = this; 15 this.elBlock = $('<div class="file-widget-with-dialog"></div>') 16 this.elBlock.insertAfter( this.element ); 17 this.element.appendTo( this.elBlock ); 18 19 if ( ! this.options.autoSize ) { 20 this.elBlock.width(this.options.width); 21 } 22 23 var hash = this.element.val(); 24 this.previewEl = $( '<div class="preview-block"></div>' ); 25 this.previewEl.width( this.options.width ); 26 27 28 if ( this.options.autoSize ) { 29 this.elBlock.addClass('auto-size'); 30 } 31 else { 32 this.elBlock.height(this.options.height); 33 this.previewEl.height( this.options.height ); 34 } 35 36 37 38 39 40 41 42 this.deleteEl = $('<a class="delete-link" href="javascript:void(0)"><span class="fa fa-times"></span></a>') 43 this.deleteEl.appendTo( this.elBlock ); 44 45 this.deleteEl.click( function() { 46 self.setValue( null ) 47 }); 48 49 this.previewEl.appendTo( this.elBlock ); 50 51 this.previewEl.click( function() { 52 window.gcSelectFiles({ 53 selectedHash: hash, 54 callback: function( hash ) { 55 self.setValue( hash ); 56 }, 57 type: self.options.type, 58 accept: self.options.accept, 59 isShowHint: self.options.isShowHint 60 }); 61 }); 62 63 this.showPreview(); 64 }, 65 init: function() { 66 this.loadFiles( "favorites", this.filesEl ) 67 }, 68 showPreview: function() { 69 if ( ! this.element.val() ) { 70 this.elBlock.addClass("no-image") 71 this.elBlock.removeClass("has-image") 72 73 var labelUpload = 'ÐагÑÑзиÑÑ<br>' + (this.options.type === this.TYPE_VIDEO ? 'видео' : 'изобÑажение'); 74 75 if (window.isPageRedesigned) { 76 if (typeof Yii != 'undefined') { 77 if (this.options.type === this.TYPE_VIDEO) { 78 labelUpload = Yii.t('common', 'ÐобавиÑÑ Ð²Ð¸Ð´ÐµÐ¾'); 79 } else { 80 labelUpload = Yii.t('common', 'ÐобавиÑÑ ÐºÐ°ÑÑинкÑ'); 81 } 82 } 83 } else { 84 if (typeof Yii != 'undefined') { 85 if (this.options.type === this.TYPE_VIDEO) { 86 labelUpload = Yii.t('common', 'Upload video'); 87 } else { 88 labelUpload = Yii.t('common', 'Upload picture'); 89 } 90 } 91 } 92 93 this.previewEl.html(labelUpload); 94 this.deleteEl.hide(); 95 } 96 else { 97 this.elBlock.addClass("has-image") 98 this.elBlock.removeClass("no-image") 99 var thumbnailUrl = this.options.type === this.TYPE_VIDEO 100 ? getVideoThumbnailUrl(this.element.val(), this.options.width, this.options.height) 101 : getThumbnailUrl(this.element.val(), this.options.width, this.options.height); 102 this.previewEl.html("<img src='" + thumbnailUrl + "'>"); 103 this.deleteEl.show(); 104 } 105 }, 106 setValue: function( hash ) { 107 this.element.val( hash ) 108 this.element.trigger('change') 109 this.showPreview(); 110 } 111} );
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.