@@ 1621-1743 (lines=123) @@ | ||
1618 | ||
1619 | })(UIkit2); |
|
1620 | ||
1621 | (function(UI){ |
|
1622 | ||
1623 | "use strict"; |
|
1624 | ||
1625 | var toggles = []; |
|
1626 | ||
1627 | UI.component('toggle', { |
|
1628 | ||
1629 | defaults: { |
|
1630 | target : false, |
|
1631 | cls : 'uk-hidden', |
|
1632 | animation : false, |
|
1633 | duration : 200 |
|
1634 | }, |
|
1635 | ||
1636 | boot: function(){ |
|
1637 | ||
1638 | // init code |
|
1639 | UI.ready(function(context) { |
|
1640 | ||
1641 | UI.$('[data-uk-toggle]', context).each(function() { |
|
1642 | var ele = UI.$(this); |
|
1643 | ||
1644 | if (!ele.data('toggle')) { |
|
1645 | var obj = UI.toggle(ele, UI.Utils.options(ele.attr('data-uk-toggle'))); |
|
1646 | } |
|
1647 | }); |
|
1648 | ||
1649 | setTimeout(function(){ |
|
1650 | ||
1651 | toggles.forEach(function(toggle){ |
|
1652 | toggle.getToggles(); |
|
1653 | }); |
|
1654 | ||
1655 | }, 0); |
|
1656 | }); |
|
1657 | }, |
|
1658 | ||
1659 | init: function() { |
|
1660 | ||
1661 | var $this = this; |
|
1662 | ||
1663 | this.aria = (this.options.cls.indexOf('uk-hidden') !== -1); |
|
1664 | ||
1665 | this.on('click', function(e) { |
|
1666 | ||
1667 | if ($this.element.is('a[href="#"]')) { |
|
1668 | e.preventDefault(); |
|
1669 | } |
|
1670 | ||
1671 | $this.toggle(); |
|
1672 | }); |
|
1673 | ||
1674 | toggles.push(this); |
|
1675 | }, |
|
1676 | ||
1677 | toggle: function() { |
|
1678 | ||
1679 | this.getToggles(); |
|
1680 | ||
1681 | if(!this.totoggle.length) return; |
|
1682 | ||
1683 | if (this.options.animation && UI.support.animation) { |
|
1684 | ||
1685 | var $this = this, animations = this.options.animation.split(','); |
|
1686 | ||
1687 | if (animations.length == 1) { |
|
1688 | animations[1] = animations[0]; |
|
1689 | } |
|
1690 | ||
1691 | animations[0] = animations[0].trim(); |
|
1692 | animations[1] = animations[1].trim(); |
|
1693 | ||
1694 | this.totoggle.css('animation-duration', this.options.duration+'ms'); |
|
1695 | ||
1696 | this.totoggle.each(function(){ |
|
1697 | ||
1698 | var ele = UI.$(this); |
|
1699 | ||
1700 | if (ele.hasClass($this.options.cls)) { |
|
1701 | ||
1702 | ele.toggleClass($this.options.cls); |
|
1703 | ||
1704 | UI.Utils.animate(ele, animations[0]).then(function(){ |
|
1705 | ele.css('animation-duration', ''); |
|
1706 | UI.Utils.checkDisplay(ele); |
|
1707 | }); |
|
1708 | ||
1709 | } else { |
|
1710 | ||
1711 | UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){ |
|
1712 | ele.toggleClass($this.options.cls).css('animation-duration', ''); |
|
1713 | UI.Utils.checkDisplay(ele); |
|
1714 | }); |
|
1715 | ||
1716 | } |
|
1717 | ||
1718 | }); |
|
1719 | ||
1720 | } else { |
|
1721 | this.totoggle.toggleClass(this.options.cls); |
|
1722 | UI.Utils.checkDisplay(this.totoggle); |
|
1723 | } |
|
1724 | ||
1725 | this.updateAria(); |
|
1726 | ||
1727 | }, |
|
1728 | ||
1729 | getToggles: function() { |
|
1730 | this.totoggle = this.options.target ? UI.$(this.options.target):[]; |
|
1731 | this.updateAria(); |
|
1732 | }, |
|
1733 | ||
1734 | updateAria: function() { |
|
1735 | if (this.aria && this.totoggle.length) { |
|
1736 | this.totoggle.not('[aria-hidden]').each(function(){ |
|
1737 | UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden')); |
|
1738 | }); |
|
1739 | } |
|
1740 | } |
|
1741 | }); |
|
1742 | ||
1743 | })(UIkit2); |
|
1744 | ||
1745 | (function(UI) { |
|
1746 |
@@ 2-124 (lines=123) @@ | ||
1 | /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ |
|
2 | (function(UI){ |
|
3 | ||
4 | "use strict"; |
|
5 | ||
6 | var toggles = []; |
|
7 | ||
8 | UI.component('toggle', { |
|
9 | ||
10 | defaults: { |
|
11 | target : false, |
|
12 | cls : 'uk-hidden', |
|
13 | animation : false, |
|
14 | duration : 200 |
|
15 | }, |
|
16 | ||
17 | boot: function(){ |
|
18 | ||
19 | // init code |
|
20 | UI.ready(function(context) { |
|
21 | ||
22 | UI.$('[data-uk-toggle]', context).each(function() { |
|
23 | var ele = UI.$(this); |
|
24 | ||
25 | if (!ele.data('toggle')) { |
|
26 | var obj = UI.toggle(ele, UI.Utils.options(ele.attr('data-uk-toggle'))); |
|
27 | } |
|
28 | }); |
|
29 | ||
30 | setTimeout(function(){ |
|
31 | ||
32 | toggles.forEach(function(toggle){ |
|
33 | toggle.getToggles(); |
|
34 | }); |
|
35 | ||
36 | }, 0); |
|
37 | }); |
|
38 | }, |
|
39 | ||
40 | init: function() { |
|
41 | ||
42 | var $this = this; |
|
43 | ||
44 | this.aria = (this.options.cls.indexOf('uk-hidden') !== -1); |
|
45 | ||
46 | this.on('click', function(e) { |
|
47 | ||
48 | if ($this.element.is('a[href="#"]')) { |
|
49 | e.preventDefault(); |
|
50 | } |
|
51 | ||
52 | $this.toggle(); |
|
53 | }); |
|
54 | ||
55 | toggles.push(this); |
|
56 | }, |
|
57 | ||
58 | toggle: function() { |
|
59 | ||
60 | this.getToggles(); |
|
61 | ||
62 | if(!this.totoggle.length) return; |
|
63 | ||
64 | if (this.options.animation && UI.support.animation) { |
|
65 | ||
66 | var $this = this, animations = this.options.animation.split(','); |
|
67 | ||
68 | if (animations.length == 1) { |
|
69 | animations[1] = animations[0]; |
|
70 | } |
|
71 | ||
72 | animations[0] = animations[0].trim(); |
|
73 | animations[1] = animations[1].trim(); |
|
74 | ||
75 | this.totoggle.css('animation-duration', this.options.duration+'ms'); |
|
76 | ||
77 | this.totoggle.each(function(){ |
|
78 | ||
79 | var ele = UI.$(this); |
|
80 | ||
81 | if (ele.hasClass($this.options.cls)) { |
|
82 | ||
83 | ele.toggleClass($this.options.cls); |
|
84 | ||
85 | UI.Utils.animate(ele, animations[0]).then(function(){ |
|
86 | ele.css('animation-duration', ''); |
|
87 | UI.Utils.checkDisplay(ele); |
|
88 | }); |
|
89 | ||
90 | } else { |
|
91 | ||
92 | UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){ |
|
93 | ele.toggleClass($this.options.cls).css('animation-duration', ''); |
|
94 | UI.Utils.checkDisplay(ele); |
|
95 | }); |
|
96 | ||
97 | } |
|
98 | ||
99 | }); |
|
100 | ||
101 | } else { |
|
102 | this.totoggle.toggleClass(this.options.cls); |
|
103 | UI.Utils.checkDisplay(this.totoggle); |
|
104 | } |
|
105 | ||
106 | this.updateAria(); |
|
107 | ||
108 | }, |
|
109 | ||
110 | getToggles: function() { |
|
111 | this.totoggle = this.options.target ? UI.$(this.options.target):[]; |
|
112 | this.updateAria(); |
|
113 | }, |
|
114 | ||
115 | updateAria: function() { |
|
116 | if (this.aria && this.totoggle.length) { |
|
117 | this.totoggle.not('[aria-hidden]').each(function(){ |
|
118 | UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden')); |
|
119 | }); |
|
120 | } |
|
121 | } |
|
122 | }); |
|
123 | ||
124 | })(UIkit2); |
|
125 |