1(function($){ 2 var Expandable = function(target, options){ 3 this._init(target, options); 4 }; 5 6 Expandable.prototype = { 7 options : null, 8 target : null, 9 10 toggleButton: null, 11 expandText: null, 12 collapseText: null, 13 minHeight: null, 14 isExpanded: null, 15 16 _init : function(target, options){ 17 let defaults = { 18 }; 19 20 this.target = $(target); 21 this.options = $.extend(true, defaults, options); 22 23 this.expandText = this.target.data('expand-text'); 24 this.collapseText = this.target.data('collapse-text'); 25 this.minHeight = this.target.data('min-height'); 26 27 if(this.target.hasClass('collapsed')) { 28 this.isExpanded = false; 29 } else { 30 this.isExpanded = true; 31 } 32 33 if(this.minHeight) { 34 this.target.css('min-height', this.minHeight); 35 } 36 37 this.toggleButton = $('<a role="button" class="expandable-v2-toggle" tabindex="0" aria-expanded="' + this.isExpanded.toString() + '" aria-controls="' + target.id + '">'); 38 this.toggleButton.text(this.isExpanded ? this.collapseText : this.expandText); 39 this.target.after(this.toggleButton); 40 41 this._setupHandler(); 42 }, 43 44 _setupHandler: function () { 45 const _this = this; 46 47 this.toggleButton.on('click', function() { 48 if(_this.isExpanded) { 49 _this._collapse(); 50 } else { 51 _this._expand(); 52 } 53 }); 54 }, 55 56 _expand: function () { 57 var _this = this; 58 59 this.isExpanded = true; 60 this.toggleButton.text(this.collapseText); 61 this.toggleButton.attr('aria-expanded', 'true'); 62 this.target.stop().toggleClass('collapsed', 300); 63 }, 64 65 _collapse: function () { 66 var _this = this; 67 68 this.isExpanded = false; 69 this.toggleButton.text(this.expandText); 70 this.toggleButton.attr('aria-expanded', 'false'); 71 this.target.stop().toggleClass('collapsed', 300); 72 } 73 74 }; 75 76 $.fn.expandable = function(options){ 77 return this.each(function(){ 78 $(this).data('expandable', new Expandable(this, options)); 79 }); 80 }; 81})(jQuery);
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.