1XA.component.toggle = (function($) { 2 var api = { 3 4 }; 5 6 var properties, instance; 7 8 var getFlipList = function(instance) { 9 return $(instance).find('.component.flip'); 10 } 11 12 var openToggle = function(instance) { 13 var flipList = getFlipList(instance), 14 eventCalendar = $(instance).find('.event-calendar'); 15 $(instance).find('details').attr('open', 'open'); 16 if (eventCalendar.length){ 17 eventCalendar.trigger('resize') 18 } 19 if (flipList.lengt) { 20 try { 21 XA.component.flip.equalSideHeightInToggle(instance) 22 } catch (e) { 23 /* eslint-disable no-console */ 24 console.warn('Error during calculation height of Flip list in toggle'); // jshint ignore:line 25 /* eslint-enable no-console */ 26 27 } 28 } 29 30 } 31 var closeToggle = function(instance) { 32 $(instance).find('details').removeAttr('open'); 33 } 34 35 var setAnimation = function(instance) { 36 $(instance).find('details summary~.component>.component-content').css({ 37 'animation-name': properties.easing, 38 'animation-duration': (properties.speed || 500) + 'ms' 39 }) 40 } 41 var isExpandOnHover = function() { 42 return properties.expandOnHover; 43 } 44 var isExpanded = function() { 45 return properties.expandedByDefault; 46 } 47 var bindEvents = function(instance) { 48 var summary = $(instance).find('summary'); 49 if (isExpandOnHover()) { 50 summary.on('mouseenter', function() { 51 openToggle(instance); 52 }) 53 } 54 if (isExpanded()) { 55 openToggle(instance) 56 } 57 58 summary.on('click', function(event) { 59 event.preventDefault(); 60 var details = $(this).closest('details') 61 if (details.attr('open')) { 62 closeToggle(instance); 63 } else { 64 openToggle(instance); 65 } 66 67 }) 68 69 } 70 71 var initToggle = function(component) { 72 bindEvents(component) 73 setAnimation(component); 74 }; 75 76 api.initInstance=function(component) { 77 initToggle(component); 78 } 79 80 api.init = function() { 81 $('.toggle:not(.initialized)').each(function() { 82 instance = $(this); 83 properties = instance.data('properties'); 84 api.initInstance(this,properties); 85 instance.addClass('initialized'); 86 }); 87 }; 88 89 return api; 90})(jQuery); 91 92XA.register('component-toggle', XA.component.toggle);
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.