1 2 3jQuery().ready(function () { 4 jQuery('.mikiop-button').on('click', function (event) { 5 if (jQuery(this).hasClass('mikiop-disabled')) { 6 event.preventDefault(); 7 } 8 9 if (jQuery(this).attr('data-toggle') == 'collapse') { 10 event.preventDefault(); 11 jQuery(jQuery(this).attr('data-target')).slideToggle(); 12 } 13 }); 14 15 jQuery('.mikiop-accordian-title').on('click', function (event) { 16 event.preventDefault(); 17 18 jQuery(this).siblings('.mikiop-accordian-body').slideToggle(); 19 }); 20 21 jQuery('.mikiop-alert-close').on('click', function (event) { 22 event.preventDefault(); 23 jQuery(this).closest('.mikiop-alert').hide(); 24 }); 25 26 jQuery('.mikiop-carousel').each(function () { 27 var items = jQuery(this).find('.mikiop-carousel-item'); 28 var indicators = ''; 29 var active = false; 30 31 for (var i = 0; i < items.length; i++) { 32 if (jQuery(items[i]).hasClass('mikiop-active')) { 33 active = true; 34 indicators += '<li class="mikiop mikiop-carousel-indicator mikiop-active"></li>'; 35 } else { 36 indicators += '<li class="mikiop mikiop-carousel-indicator"></li>'; 37 } 38 }; 39 40 jQuery(this).find('.mikiop-carousel-indicators').html(indicators); 41 42 if (!active) { 43 jQuery(this).find('.mikiop-carousel-item').first().addClass('mikiop-active'); 44 jQuery(this).find('.mikiop-carousel-indicator').first().addClass('mikiop-active'); 45 } 46 47 if (jQuery(this).attr('data-auto-start') == 'true') { 48 var carousel = jQuery(this); 49 timeout = carousel.find('.mikiop-carousel-item.mikiop-active').attr('data-interval'); 50 51 if (timeout == 0) { 52 timeout = 3; 53 } 54 55 var nextSlide = function () { 56 var timeout = carouselNext(carousel); 57 58 if (timeout == 0) { 59 timeout = 3; 60 } 61 62 window.setTimeout(nextSlide, (timeout * 1000) + 500); 63 }; 64 65 window.setTimeout(nextSlide, (timeout * 1000) + 500); 66 } 67 }); 68 69 jQuery('.mikiop-carousel-control-prev').on('click', function (event) { 70 event.preventDefault(); 71 72 var parent = jQuery(this).parent(); 73 carouselPrev(parent); 74 }); 75 76 function carouselPrev(parent) { 77 78 var slides = parent.find('.mikiop-carousel-item'); 79 80 for (var i = 0; i < slides.length; i++) { 81 if (jQuery(slides[i]).hasClass('mikiop-active')) { 82 var target = null; 83 var next = 0; 84 85 if (i == 0) { 86 next = slides.length - 1; 87 } else { 88 next = i - 1; 89 } 90 target = jQuery(slides[next]); 91 92 if (jQuery(parent).hasClass('mikiop-transition-fade')) { 93 target.css('z-index', 0).addClass('mikiop-active'); 94 jQuery(slides[i]).fadeOut(function () { 95 jQuery(this).removeClass('mikiop-active').css('display', ''); 96 target.css('z-index', ''); 97 }); 98 } else if (jQuery(parent).hasClass('mikiop-transition-slide')) { 99 target.css('left', '-100%').addClass('mikiop-active'); 100 target.animate({ left: '0' }, 500); 101 jQuery(slides[i]).animate({ left: '100%' }, 500, function () { 102 jQuery(this).removeClass('mikiop-active').css('left', ''); 103 target.css('left', ''); 104 }) 105 } else { 106 target.addClass('mikiop-active'); 107 jQuery(slides[i]).removeClass('mikiop-active'); 108 } 109 110 parent.find('.mikiop-carousel-indicator').removeClass('mikiop-active'); 111 parent.find('.mikiop-carousel-indicator:nth-child(' + (next + 1) + ')').addClass('mikiop-active'); 112 113 break; 114 } 115 } 116 }; 117 118 jQuery('.mikiop-carousel-control-next').on('click', function (event) { 119 event.preventDefault(); 120 var parent = elem.parent(); 121 122 carouselNext(parent); 123 }); 124 125 function carouselNext(parent) { 126 var slides = parent.find('.mikiop-carousel-item'); 127 var delay = 0; 128 129 for (var i = 0; i < slides.length; i++) { 130 131 132 if (jQuery(slides[i]).hasClass('mikiop-active')) { 133 var target = null; 134 var next = 0; 135 136 137 if (i == slides.length - 1) { 138 next = 0; 139 } else { 140 next = i + 1; 141 } 142 target = jQuery(slides[next]); 143 144 delay = target.attr('data-interval'); 145 if (typeof delay == 'undefined') { 146 delay = 0; 147 } 148 149 if (jQuery(parent).hasClass('mikiop-transition-fade')) { 150 target.css('z-index', 0).addClass('mikiop-active'); 151 jQuery(slides[i]).fadeOut(function () { 152 jQuery(this).removeClass('mikiop-active').css('display', ''); 153 target.css('z-index', ''); 154 }); 155 } else if (jQuery(parent).hasClass('mikiop-transition-slide')) { 156 target.css('left', '100%').addClass('mikiop-active'); 157 target.animate({ left: '0' }, 500); 158 jQuery(slides[i]).animate({ left: '-100%' }, 500, function () { 159 jQuery(this).removeClass('mikiop-active').css('left', ''); 160 target.css('left', ''); 161 }) 162 } else { 163 target.addClass('mikiop-active'); 164 jQuery(slides[i]).removeClass('mikiop-active'); 165 } 166 167 parent.find('.mikiop-carousel-indicator').removeClass('mikiop-active'); 168 parent.find('.mikiop-carousel-indicator:nth-child(' + (next + 1) + ')').addClass('mikiop-active'); 169 170 break; 171 } 172 } 173 174 return(delay); 175 }; 176 177 jQuery('.mikiop-carousel-indicator').on('click', function (event) { 178 event.preventDefault(); 179 180 var parent = jQuery(this).closest('.mikiop-carousel-indicators'); 181 if (parent) { 182 var group = jQuery(this).closest('.mikiop-carousel'); 183 if (group) { 184 var items = jQuery(group).find('.mikiop-carousel-indicator'); 185 186 var item = -1; 187 var active = 0; 188 for (var i = 0; i < items.length; i++) { 189 if (jQuery(items[i]).hasClass('mikiop-active')) { 190 active = i; 191 } 192 193 if (items[i] == jQuery(this)[0]) { 194 item = i; 195 } 196 } 197 198 if (item != active) { 199 if (jQuery(group).hasClass('mikiop-transition-fade')) { 200 var target = jQuery(group).find('.mikiop-carousel-item:nth-child(' + (item + 1) + ')'); 201 202 target.css('z-index', 0).addClass('mikiop-active'); 203 jQuery(group).find('.mikiop-carousel-item:nth-child(' + (active + 1) + ')').fadeOut(function () { 204 jQuery(this).removeClass('mikiop-active').css('display', ''); 205 target.css('z-index', ''); 206 }); 207 208 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (item + 1) + ')').addClass('mikiop-active'); 209 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (active + 1) + ')').removeClass('mikiop-active'); 210 } else if (jQuery(group).hasClass('mikiop-transition-slide')) { 211 var target = jQuery(group).find('.mikiop-carousel-item:nth-child(' + (item + 1) + ')'); 212 213 if (item < active) { 214 target.css('left', '-100%').addClass('mikiop-active'); 215 target.animate({ left: '0' }, 500); 216 jQuery(group).find('.mikiop-carousel-item:nth-child(' + (active + 1) + ')').animate({ left: '100%' }, 500, function () { 217 jQuery(this).removeClass('mikiop-active').css('left', ''); 218 target.css('left', ''); 219 }); 220 } else { 221 target.css('left', '100%').addClass('mikiop-active'); 222 target.animate({ left: '0' }, 500); 223 jQuery(group).find('.mikiop-carousel-item:nth-child(' + (active + 1) + ')').animate({ left: '-100%' }, 500, function () { 224 jQuery(this).removeClass('mikiop-active').css('left', ''); 225 target.css('left', ''); 226 }); 227 } 228 229 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (item + 1) + ')').addClass('mikiop-active'); 230 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (active + 1) + ')').removeClass('mikiop-active'); 231 } else { 232 jQuery(group).find('.mikiop-carousel-item:nth-child(' + (item + 1) + ')').addClass('mikiop-active'); 233 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (item + 1) + ')').addClass('mikiop-active'); 234 jQuery(group).find('.mikiop-carousel-item:nth-child(' + (active + 1) + ')').removeClass('mikiop-active'); 235 jQuery(group).find('.mikiop-carousel-indicator:nth-child(' + (active + 1) + ')').removeClass('mikiop-active'); 236 } 237 } 238 } 239 } 240 }); 241 242 jQuery('.mikiop-tab-item a').on('click', function (event) { 243 event.preventDefault(); 244 245 var parent = jQuery(this).closest('.mikiop-tab-item'); 246 if (parent) { 247 var group = jQuery(parent).closest('.mikiop-tab-group'); 248 if (group) { 249 var items = jQuery(group).find('.mikiop-tab-item'); 250 251 var item = -1; 252 for (var i = 0; i < items.length; i++) { 253 if (items[i] == parent[0]) { 254 item = i; 255 break; 256 } 257 } 258 259 if (item != -1) { 260 var panes = jQuery(group).siblings('.mikiop-tab-content').find('.mikiop-tab-pane'); 261 262 if (panes.length > item) { 263 if (!jQuery(panes[item]).hasClass('mikiop-show')) { 264 jQuery(panes).removeClass('mikiop-show'); 265 jQuery(panes[item]).addClass('mikiop-show'); 266 267 jQuery(items).find('a').removeClass('mikiop-active'); 268 jQuery(items[item]).find('a').addClass('mikiop-active'); 269 } 270 } 271 } 272 } 273 } 274 }); 275 276 jQuery('.mikiop-box').on('mouseenter', function () { 277 jQuery(this).children('.mikiop-reveal').fadeOut(); 278 }); 279 280 jQuery('.mikiop-box').on('mouseleave', function () { 281 jQuery(this).children('.mikiop-reveal').fadeIn(); 282 }); 283 284 jQuery('.mikiop-collapse').hide(); 285 286}); 287 288 289// jQuery(function(){ 290// jQuery('[data-toggle="tooltip"]').tooltip(); 291// }); 292