Sha256: 33fbc08d5313f7137fbeffebceb09ed1843e4f2d7959f2288977ff4e03c1268a
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
/* ======================================================================== * Ratchet: segmented-controllers.js v2.0.2 * http://goratchet.com/components#segmentedControls * ======================================================================== * Copyright 2014 Connor Sears * Licensed under MIT (https://github.com/twbs/ratchet/blob/master/LICENSE) * ======================================================================== */ !(function () { 'use strict'; var getTarget = function (target) { var i; var segmentedControls = document.querySelectorAll('.segmented-control .control-item'); for (; target && target !== document; target = target.parentNode) { for (i = segmentedControls.length; i--;) { if (segmentedControls[i] === target) { return target; } } } }; window.addEventListener('touchend', function (e) { var activeTab; var activeBodies; var targetBody; var targetTab = getTarget(e.target); var className = 'active'; var classSelector = '.' + className; if (!targetTab) { return; } activeTab = targetTab.parentNode.querySelector(classSelector); if (activeTab) { activeTab.classList.remove(className); } targetTab.classList.add(className); if (!targetTab.hash) { return; } targetBody = document.querySelector(targetTab.hash); if (!targetBody) { return; } activeBodies = targetBody.parentNode.querySelectorAll(classSelector); for (var i = 0; i < activeBodies.length; i++) { activeBodies[i].classList.remove(className); } targetBody.classList.add(className); }); window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} }); }());
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
twitter_ratchet_rails-0.0.2 | app/assets/javascripts/twitter_ratchet_rails/segmented-controllers.js |
ratchet-sass-2.0.2 | vendor/assets/javascripts/segmented-controllers.js |