megatron 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +43 -2
  3. data/app/assets/javascripts/megatron/form.js +36 -0
  4. data/app/assets/javascripts/megatron/index.js +93 -0
  5. data/app/assets/javascripts/megatron/link.js +58 -0
  6. data/app/assets/javascripts/megatron/utils/auto-navigate.js +24 -0
  7. data/app/assets/javascripts/megatron/utils/form-notify.js +39 -0
  8. data/app/assets/javascripts/megatron/utils/index.js +112 -0
  9. data/app/assets/javascripts/megatron/utils/messages.js +97 -0
  10. data/app/assets/javascripts/megatron/utils/time/date-to-html.js +59 -0
  11. data/app/assets/javascripts/megatron/utils/time/time-switch.js +87 -0
  12. data/app/assets/javascripts/megatron/utils/time/timeago.js +95 -0
  13. data/app/assets/javascripts/megatron/utils/toggler.js +163 -0
  14. data/app/assets/stylesheets/_example.scss +76 -0
  15. data/app/assets/stylesheets/_grid.scss +41 -0
  16. data/app/assets/stylesheets/_typography.scss +38 -0
  17. data/app/assets/stylesheets/application.scss +19 -0
  18. data/app/assets/stylesheets/megatron/error-pages.scss +164 -0
  19. data/app/assets/stylesheets/megatron/error-pages/_animations.scss +96 -0
  20. data/app/assets/stylesheets/megatron/error-pages/_csi.scss +41 -0
  21. data/app/assets/stylesheets/megatron/error-pages/_waves.scss +36 -0
  22. data/app/assets/stylesheets/megatron/megatron.scss +3 -0
  23. data/app/assets/stylesheets/megatron/modules/_crop-height.scss +5 -0
  24. data/app/assets/stylesheets/megatron/modules/_index.scss +22 -0
  25. data/app/assets/stylesheets/megatron/modules/_logo.scss +67 -0
  26. data/app/assets/stylesheets/megatron/modules/_new-tag.scss +11 -0
  27. data/app/assets/stylesheets/megatron/modules/_progress.scss +80 -0
  28. data/app/assets/stylesheets/megatron/modules/app/_animation-classes.scss +3 -0
  29. data/app/assets/stylesheets/megatron/modules/app/_animations.scss +62 -0
  30. data/app/assets/stylesheets/megatron/modules/app/_index.scss +5 -0
  31. data/app/assets/stylesheets/megatron/modules/app/_layout.scss +261 -0
  32. data/app/assets/stylesheets/megatron/modules/app/_sizes.scss +28 -0
  33. data/app/assets/stylesheets/megatron/modules/app/_typography.scss +111 -0
  34. data/app/assets/stylesheets/megatron/modules/box/_base.scss +94 -0
  35. data/app/assets/stylesheets/megatron/modules/box/_color-box.scss +33 -0
  36. data/app/assets/stylesheets/megatron/modules/box/_deployment_box.scss +37 -0
  37. data/app/assets/stylesheets/megatron/modules/box/_index.scss +4 -0
  38. data/app/assets/stylesheets/megatron/modules/box/_placeholder.scss +6 -0
  39. data/app/assets/stylesheets/megatron/modules/buttons/_animations.scss +35 -0
  40. data/app/assets/stylesheets/megatron/modules/buttons/_buttons.scss +266 -0
  41. data/app/assets/stylesheets/megatron/modules/buttons/_index.scss +4 -0
  42. data/app/assets/stylesheets/megatron/modules/buttons/_mixins.scss +108 -0
  43. data/app/assets/stylesheets/megatron/modules/buttons/_pills.scss +44 -0
  44. data/app/assets/stylesheets/megatron/modules/code/_codemirror.scss +98 -0
  45. data/app/assets/stylesheets/megatron/modules/code/_highlighted.scss +65 -0
  46. data/app/assets/stylesheets/megatron/modules/code/_index.scss +3 -0
  47. data/app/assets/stylesheets/megatron/modules/code/_syntax.scss +18 -0
  48. data/app/assets/stylesheets/megatron/modules/core/_colored-items.scss +22 -0
  49. data/app/assets/stylesheets/megatron/modules/core/_colors.scss +163 -0
  50. data/app/assets/stylesheets/megatron/modules/core/_index.scss +3 -0
  51. data/app/assets/stylesheets/megatron/modules/core/_mixins.scss +262 -0
  52. data/app/assets/stylesheets/megatron/modules/core/_vars.scss +30 -0
  53. data/app/assets/stylesheets/megatron/modules/core/_z-index.scss +3 -0
  54. data/app/assets/stylesheets/megatron/modules/dialog/_animations.scss +48 -0
  55. data/app/assets/stylesheets/megatron/modules/dialog/_dialog.scss +81 -0
  56. data/app/assets/stylesheets/megatron/modules/dialog/_index.scss +2 -0
  57. data/app/assets/stylesheets/megatron/modules/forms/_base.scss +31 -0
  58. data/app/assets/stylesheets/megatron/modules/forms/_check-radio.scss +99 -0
  59. data/app/assets/stylesheets/megatron/modules/forms/_check-switch.scss +88 -0
  60. data/app/assets/stylesheets/megatron/modules/forms/_footer.scss +13 -0
  61. data/app/assets/stylesheets/megatron/modules/forms/_index.scss +10 -0
  62. data/app/assets/stylesheets/megatron/modules/forms/_login.scss +92 -0
  63. data/app/assets/stylesheets/megatron/modules/forms/_radio-nav.scss +62 -0
  64. data/app/assets/stylesheets/megatron/modules/forms/_select.scss +37 -0
  65. data/app/assets/stylesheets/megatron/modules/forms/_stacked-form.scss +29 -0
  66. data/app/assets/stylesheets/megatron/modules/forms/_table-form.scss +53 -0
  67. data/app/assets/stylesheets/megatron/modules/forms/_text-input.scss +118 -0
  68. data/app/assets/stylesheets/megatron/modules/grids/_alignment.scss +39 -0
  69. data/app/assets/stylesheets/megatron/modules/grids/_grid.scss +144 -0
  70. data/app/assets/stylesheets/megatron/modules/grids/_index.scss +2 -0
  71. data/app/assets/stylesheets/megatron/modules/headers/_actions.scss +10 -0
  72. data/app/assets/stylesheets/megatron/modules/headers/_base.scss +67 -0
  73. data/app/assets/stylesheets/megatron/modules/headers/_index.scss +4 -0
  74. data/app/assets/stylesheets/megatron/modules/headers/_meta.scss +10 -0
  75. data/app/assets/stylesheets/megatron/modules/headers/_site-header.scss +8 -0
  76. data/app/assets/stylesheets/megatron/modules/lib/_codemirror.scss +301 -0
  77. data/app/assets/stylesheets/megatron/modules/lists/_base.scss +13 -0
  78. data/app/assets/stylesheets/megatron/modules/lists/_box-list.scss +53 -0
  79. data/app/assets/stylesheets/megatron/modules/lists/_index.scss +2 -0
  80. data/app/assets/stylesheets/megatron/modules/messages/_index.scss +3 -0
  81. data/app/assets/stylesheets/megatron/modules/messages/_notice.scss +57 -0
  82. data/app/assets/stylesheets/megatron/modules/messages/_notifications.scss +126 -0
  83. data/app/assets/stylesheets/megatron/modules/messages/_pop-message.scss +157 -0
  84. data/app/assets/stylesheets/megatron/modules/nav/_auto-navigate.scss +7 -0
  85. data/app/assets/stylesheets/megatron/modules/nav/_breadcrumbs.scss +35 -0
  86. data/app/assets/stylesheets/megatron/modules/nav/_index.scss +8 -0
  87. data/app/assets/stylesheets/megatron/modules/nav/_main-sidebar.scss +21 -0
  88. data/app/assets/stylesheets/megatron/modules/nav/_mixins.scss +53 -0
  89. data/app/assets/stylesheets/megatron/modules/nav/_nav-toggle.scss +61 -0
  90. data/app/assets/stylesheets/megatron/modules/nav/_primary-nav.scss +120 -0
  91. data/app/assets/stylesheets/megatron/modules/nav/_secondary-nav.scss +105 -0
  92. data/app/assets/stylesheets/megatron/modules/nav/_tabs.scss +87 -0
  93. data/app/assets/stylesheets/megatron/modules/roboticons/_font.scss +62 -0
  94. data/app/assets/stylesheets/megatron/modules/roboticons/_icons.scss +219 -0
  95. data/app/assets/stylesheets/megatron/modules/roboticons/_index.scss +2 -0
  96. data/app/assets/stylesheets/megatron/modules/slider/_base.scss +49 -0
  97. data/app/assets/stylesheets/megatron/modules/slider/_index.scss +4 -0
  98. data/app/assets/stylesheets/megatron/modules/slider/_slider.scss +282 -0
  99. data/app/assets/stylesheets/megatron/modules/slider/_switch.scss +75 -0
  100. data/app/assets/stylesheets/megatron/modules/slider/_themes.scss +42 -0
  101. data/app/assets/stylesheets/megatron/modules/tables/_base.scss +170 -0
  102. data/app/assets/stylesheets/megatron/modules/tables/_border-table.scss +28 -0
  103. data/app/assets/stylesheets/megatron/modules/tables/_box-table.scss +36 -0
  104. data/app/assets/stylesheets/megatron/modules/tables/_columns.scss +8 -0
  105. data/app/assets/stylesheets/megatron/modules/tables/_doc-table.scss +22 -0
  106. data/app/assets/stylesheets/megatron/modules/tables/_icon-cell.scss +9 -0
  107. data/app/assets/stylesheets/megatron/modules/tables/_index.scss +7 -0
  108. data/app/assets/stylesheets/megatron/modules/tables/_link-cell.scss +8 -0
  109. data/app/assets/stylesheets/megatron/modules/tables/_responsive-table.scss +13 -0
  110. data/app/assets/stylesheets/megatron/modules/widgets/_index.scss +1 -0
  111. data/app/assets/stylesheets/megatron/modules/widgets/_time-switch.scss +24 -0
  112. data/lib/megatron.rb +1 -1
  113. data/lib/megatron/engine.rb +5 -0
  114. data/lib/megatron/version.rb +1 -1
  115. data/lib/tasks/megatron_tasks.rake +4 -4
  116. data/public/assets/megatron/megatron-0.0.4.css +3 -0
  117. data/public/assets/megatron/{megatron-0.0.3.css.map → megatron-0.0.4.css.map} +3 -3
  118. data/public/assets/megatron/{megatron-0.0.3.js → megatron-0.0.4.js} +1 -1
  119. data/public/assets/megatron/megatron-0.0.4.map.json +1 -0
  120. metadata +115 -6
  121. data/public/assets/megatron/megatron-0.0.3.css +0 -2
  122. data/public/assets/megatron/megatron-0.0.3.map.json +0 -1
@@ -0,0 +1,59 @@
1
+ // Converts a simple date string into Date + Time + Timezone wrapped in HTML
2
+ //
3
+ // Input:
4
+ // - String, compatible with JS date parsing e.g. "2014-10-20" or "2014-05-21 10:63"
5
+ // - String, timezone: "UTC", "CST", etc.
6
+ //
7
+ // Returns: HTML which is "2014-01-28 18:00:00 CST", separated and wrapped with spans
8
+ // with classnames: date, time and timezone
9
+ //
10
+ var dateToHtml = function (dateString, zone) {
11
+
12
+ if(isNaN(new Date("2014-01-29T18:14:29+00:00").getDate())) {
13
+ return false
14
+ }
15
+
16
+ var date = new Date(dateString)
17
+ var zone = zone || date.getTimezoneOffset()/-60
18
+
19
+ if(zone === 'UTC') {
20
+ var y = date.getUTCFullYear()
21
+ var mo = pad(date.getUTCMonth() + 1)
22
+ var d = pad(date.getUTCDate())
23
+ var h = pad(date.getUTCHours())
24
+ var m = pad(date.getUTCMinutes())
25
+ var s = pad(date.getUTCSeconds())
26
+ } else {
27
+ var y = date.getFullYear()
28
+ var mo = pad(date.getMonth() + 1)
29
+ var d = pad(date.getDate())
30
+ var h = pad(date.getHours())
31
+ var m = pad(date.getMinutes())
32
+ var s = pad(date.getSeconds())
33
+
34
+ var tz = String(date).match(/\((.+)\)$/)
35
+
36
+ if(tz) {
37
+ var zone = tz[1]
38
+ } else {
39
+ var zone = "GMT "
40
+ zone += ((zone > 0) ? '+' : '')
41
+ zone += " "+ pad(zone*100, 4)
42
+ }
43
+ }
44
+
45
+ str = '<span class="date">'+y+'-'+mo+'-'+d+'</span>'
46
+ str += ' <span class="time">'+h+':'+m+':'+s+'</span>'
47
+ str += ' <span class="timezone">'+zone+'</span>'
48
+ return str
49
+ }
50
+
51
+ var pad = function(num, pad){
52
+ pad = pad || 2
53
+ while(String(num).length < pad) {
54
+ num = '0' + num
55
+ }
56
+ return num
57
+ }
58
+
59
+ module.exports = dateToHtml
@@ -0,0 +1,87 @@
1
+ var timeago = require('./timeago')
2
+ var dateToHtml = require('./date-to-html')
3
+ var classie = require('classie')
4
+ var bean = require('bean')
5
+
6
+ require('compose-dataset-shim')
7
+
8
+ var TimeSwitch = {
9
+
10
+ // Attach listeners, setup HTML templates
11
+ setup: function() {
12
+ if(!timeago.browserSupport()) return false
13
+ if(!this.listening) this.listen()
14
+
15
+ var timeEls = document.querySelectorAll('.time-switch[datetime]')
16
+
17
+ Array.prototype.forEach.call(timeEls, function(el) {
18
+ var datetime = el.getAttribute('datetime')
19
+ var timeagoPosition = el.dataset.timeago
20
+ var timeagoStyle = el.dataset.timeagoStyle
21
+ el.innerHTML = TimeSwitch.template(datetime, timeagoPosition, timeagoStyle)
22
+ classie.add(el, 'time-switch')
23
+ el.setAttribute('title', 'toggle timezones')
24
+ })
25
+ },
26
+
27
+ // Attach listeners to toggle time zones whine clicked
28
+ listen: function() {
29
+ bean.on(document, "click", ".time-switch", TimeSwitch.toggle)
30
+ this.listening = true
31
+ },
32
+
33
+ // Switch between UTC and local time
34
+ toggle: function(event) {
35
+ var timeEls = document.querySelectorAll('.time-switch')
36
+
37
+ Array.prototype.forEach.call(timeEls, function(el) {
38
+ classie.toggle(el, 'alt-zone')
39
+ })
40
+ },
41
+
42
+ // Supply HTML for UTC and local datetime
43
+ //
44
+ // Input:
45
+ // - date (a date object)
46
+ // - timeagoPosition, String, either 'before' or 'after'
47
+ //
48
+ template: function(date, timeagoPosition, timeagoStyle) {
49
+ var utc = dateToHtml(date, 'UTC')
50
+ var local = dateToHtml(date)
51
+ var t = '';
52
+
53
+ if (timeagoPosition === 'before') {
54
+ t += this.timeagoTemplate(date, timeagoPosition, timeagoStyle)
55
+ }
56
+
57
+ t += "<span class='utc'><span class='clock_line_icon'></span> "
58
+ t += utc + "</span>"
59
+ t += "<span class='local'><span class='clock_fill_icon'></span> "
60
+ t += local + "</span>"
61
+
62
+ if (timeagoPosition === 'after') {
63
+ t += this.timeagoTemplate(date, timeagoPosition, timeagoStyle)
64
+ }
65
+
66
+ return t
67
+ },
68
+
69
+ // Converts a date to relative time string wrapped in a span
70
+ timeagoTemplate: function(date, position, style) {
71
+ var relative = timeago.parse(date, style)
72
+ var dash = "<span class='dash'>&nbsp;-&nbsp;</span>"
73
+ var html = ''
74
+
75
+ if(relative) {
76
+ if (position === 'after') html += dash
77
+ html += "<span class='timeago'>"+ relative +"</span> "
78
+ return html
79
+ } else {
80
+ return ''
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+ module.exports = TimeSwitch
87
+
@@ -0,0 +1,95 @@
1
+ // Timeago by Brandon Mathis, based on JavaScript Pretty Date Copyright (c) 2011 John Resig
2
+ // Returns relative time
3
+
4
+ let Timeago = {
5
+ // setup HTML templates
6
+ setup: function() {
7
+
8
+ var timeEls = document.querySelectorAll('.timeago[datetime]')
9
+
10
+ Array.prototype.forEach.call(timeEls, function(el) {
11
+ var datetime = el.attributes.datetime.value
12
+ var style = el.dataset.timeagoStyle
13
+ el.innerHTML = Timeago.parse(datetime, style)
14
+ })
15
+ },
16
+
17
+ // If a browser can't handle dates, bail.
18
+ browserSupport: function() {
19
+ return !isNaN(new Date("2014-01-29T18:14:29+00:00").getDate())
20
+ },
21
+
22
+ parse: function(time, style) {
23
+
24
+ style = style || "normal"
25
+ if (typeof(time) == 'string') {
26
+ time = new Date(time)
27
+ }
28
+
29
+ if (style === 'short')
30
+ var say = {
31
+ just_now: "now",
32
+ minute_ago: "1m",
33
+ minutes_ago: "m",
34
+ hour_ago: "1h",
35
+ hours_ago: "h",
36
+ yesterday: "1d",
37
+ days_ago: "d",
38
+ last_week: "1w",
39
+ weeks_ago: "w"
40
+ }
41
+
42
+ if (style === 'normal')
43
+ var say = {
44
+ just_now: "just now",
45
+ minute_ago: "1 minute",
46
+ minutes_ago: " minutes",
47
+ hour_ago: "1 hour",
48
+ hours_ago: " hours",
49
+ yesterday: "1 day",
50
+ days_ago: " days",
51
+ last_week: "1 week",
52
+ weeks_ago: " weeks"
53
+ }
54
+
55
+ if (style === 'long')
56
+ var say = {
57
+ just_now: "just now",
58
+ minute_ago: "1 minute ago",
59
+ minutes_ago: " minutes ago",
60
+ hour_ago: "1 hour ago",
61
+ hours_ago: " hours ago",
62
+ yesterday: "1 day ago",
63
+ days_ago: " days ago",
64
+ last_week: "1 week ago",
65
+ weeks_ago: " weeks ago"
66
+ }
67
+
68
+ var secs = ((new Date().getTime() - new Date(time).getTime()) / 1000)
69
+ var mins = Math.floor(secs / 60)
70
+ var hours = Math.floor(secs / 3600)
71
+ var days = Math.floor(secs / 86400)
72
+ var weeks = Math.floor(days / 7)
73
+ var months = Math.floor(days / 30)
74
+
75
+ if(isNaN(secs) || days < 0) {
76
+ return false
77
+ }
78
+
79
+ if(days === 0) {
80
+ if (secs < 60) return say.just_now
81
+ else if(secs < 120) return say.minute_ago
82
+ else if(secs < 3600) return mins + say.minutes_ago
83
+ else if(secs < 7200) return say.hour_ago
84
+ else return hours + say.hours_ago
85
+ } else {
86
+ if(days === 1) return say.yesterday
87
+ else if(days < 7) return days + say.days_ago
88
+ else if(weeks === 1) return say.last_week
89
+ else return weeks + say.weeks_ago
90
+ }
91
+ }
92
+ }
93
+
94
+ module.exports = Timeago
95
+
@@ -0,0 +1,163 @@
1
+ var bean = require('bean')
2
+ var classie = require('classie')
3
+ var _ = require('lodash')
4
+
5
+ require('compose-tap-event')
6
+ require('compose-dataset-shim')
7
+
8
+ var Toggler = {
9
+ listen: function(){
10
+ bean.on(document, "click", "[data-toggle], [data-show], [data-hide]", Toggler.trigger)
11
+ bean.on(document, "change", ".select-toggler", Toggler.trigger)
12
+ },
13
+
14
+ refresh: function(){
15
+ Toggler.toggleRadios()
16
+ Toggler.toggleCheckboxes()
17
+ Toggler.setupSelects()
18
+ },
19
+
20
+ trigger: function(event) {
21
+
22
+ var target = event.currentTarget
23
+
24
+ if (target.tagName.toLowerCase() == 'a' && target.getAttribute('href') == "#") {
25
+ event.preventDefault()
26
+ event.stop()
27
+ }
28
+
29
+ if (target.type == 'radio') {
30
+ Toggler.toggleRadios('input[name="'+ target.name +'"]')
31
+ } else if (target.type == 'checkbox') {
32
+ Toggler.toggleCheckbox(target)
33
+ } else if (target.tagName.toLowerCase() == 'select') {
34
+ Toggler.toggleSelect(target)
35
+ } else {
36
+ Toggler.dispatch(target, 'hide')
37
+ Toggler.dispatch(target, 'toggle')
38
+ Toggler.dispatch(target, 'show')
39
+ }
40
+ },
41
+
42
+ dispatch: function(el, type, force) {
43
+ if (el.dataset[type]){
44
+ Toggler.setState(el.dataset[type], type)
45
+ }
46
+ },
47
+
48
+ setState: function(selectors, state) {
49
+ var matches = document.querySelectorAll(selectors)
50
+ if (typeof(state) == 'boolean') {
51
+ state = (state ? 'show' : 'hide')
52
+ }
53
+
54
+ Array.prototype.forEach.call(matches, function(match){
55
+ Toggler[state](match)
56
+ })
57
+ },
58
+
59
+ toggle: function(el) {
60
+
61
+ if (el.offsetParent === null) {
62
+ Toggler.show(el)
63
+ } else {
64
+ Toggler.hide(el)
65
+ }
66
+
67
+ },
68
+
69
+ show: function(el) {
70
+ classie.remove(el, 'hidden')
71
+ classie.add(el, 'visible')
72
+ var focusEl = el.querySelector('[data-focus]')
73
+
74
+ if (focusEl) {
75
+ focusEl.focus()
76
+ }
77
+ },
78
+
79
+ hide: function(el) {
80
+ classie.remove(el, 'visible')
81
+ classie.add(el, 'hidden')
82
+ },
83
+
84
+ toggleRadios: function(radios) {
85
+ var radios = radios || 'input[type=radio][data-show]'
86
+
87
+ Array.prototype.forEach.call(document.querySelectorAll(radios), function(radio) {
88
+ Toggler.setState(radio.dataset.show, radio.checked)
89
+ })
90
+ },
91
+
92
+ toggleCheckbox: function(checkbox) {
93
+ Toggler.setState(checkbox.dataset.hide, !checkbox.checked)
94
+ Toggler.setState(checkbox.dataset.toggle, 'toggle')
95
+ Toggler.setState(checkbox.dataset.show, checkbox.checked)
96
+ },
97
+
98
+ toggleSelect: function(select) {
99
+ var option = select.selectedOptions[0]
100
+ Toggler.dispatch(option, 'hide')
101
+ Toggler.dispatch(option, 'show')
102
+ },
103
+
104
+ toggleCheckboxes: function() {
105
+ var checkboxes = 'input[type=checkbox][data-toggle]'
106
+ Array.prototype.forEach.call(document.querySelectorAll(checkboxes), Toggler.toggleCheckbox)
107
+ },
108
+
109
+ // Add data-hide to each <option> containing the selectors from other
110
+ // option's data-show. This makes the toggling of elements exclusive.
111
+ //
112
+ setupSelects: function(select){
113
+ Array.prototype.forEach.call(document.querySelectorAll('option[data-show]'), function(option){
114
+ if (!option.dataset.hide) {
115
+
116
+ var select = Toggler.getSelectFromOption(option)
117
+ classie.add(select, 'select-toggler')
118
+ var options = select.querySelectorAll('option')
119
+ var selectors = Toggler.showAttributes(options)
120
+
121
+ Array.prototype.forEach.call(options, function(o) {
122
+ option.dataset.hide = _.compact(selectors.filter(function(selector){
123
+ return option.dataset.show != selector && selector != ""
124
+ })).join(',')
125
+ })
126
+
127
+ // Ensure that currently selected option is toggled properly
128
+ //
129
+ Toggler.toggleSelect(select)
130
+ }
131
+ })
132
+ },
133
+
134
+ // Find parent <select> for an option (accounts for option groups)
135
+ //
136
+ getSelectFromOption: function(el) {
137
+ var p = el.parentElement
138
+
139
+ if (p.tagName.toLowerCase() == 'select') {
140
+ return p
141
+ } else {
142
+ return Toggler.getSelectFromOption(p)
143
+ }
144
+ },
145
+
146
+ // Return an array of all data-show values from elements
147
+ //
148
+ showAttributes: function(elements) {
149
+ return Array.prototype.map.call(elements, function(el) {
150
+ return el.dataset.show
151
+ })
152
+ },
153
+
154
+ toggleSelects: function(selects) {
155
+ var selects = selects || 'option[data-show]'
156
+
157
+ Array.prototype.forEach.call(document.querySelectorAll(radios), function(radio) {
158
+ Toggler.setState(radio.dataset.show, radio.checked)
159
+ })
160
+ }
161
+ }
162
+
163
+ module.exports = Toggler
@@ -0,0 +1,76 @@
1
+ .demo {
2
+ margin: 1.6em 0;
3
+ }
4
+ .demo-header {
5
+ overflow: hidden;
6
+ margin: 1.2em 0;
7
+ }
8
+
9
+ .demo-heading {
10
+ display: inline-block;
11
+ font-weight: normal;
12
+ vertical-align: bottom;
13
+ float: left;
14
+ margin: 0;
15
+ }
16
+
17
+ .demo-source-toggle {
18
+ float: right;
19
+ vertical-align: bottom;
20
+ }
21
+
22
+ .demo-box {
23
+ list-style: none;
24
+ position: relative;
25
+ margin-bottom: $block-margin;
26
+ border: 1px solid $page-border;
27
+ background: #fafafa;
28
+ margin-top: $block-margin + 2em;
29
+
30
+ &-row {
31
+ padding: 10px;
32
+ border-bottom: 1px solid #e5e5e5;
33
+ position: relative;
34
+
35
+ &:last-child {
36
+ border-bottom: 0;
37
+ }
38
+ }
39
+
40
+ &.padded {
41
+ @include pad_box;
42
+ pre {
43
+ padding: 0;
44
+ }
45
+ }
46
+
47
+ .heading-anchor:after {
48
+ top: -.8em;
49
+ left: -.8em;
50
+ }
51
+
52
+ .demo-header {
53
+ position: absolute;
54
+ top: -30px;
55
+ left: -1px;
56
+ right: -1px;
57
+ padding: 0 1em;
58
+ margin: 0;
59
+ border: 1px solid #e5e5e5;
60
+ background: #f5f5f5;
61
+ font-family: Helvetica, Arial, sans-serif;
62
+ line-height: 30px;
63
+ font-size: 13px;
64
+ z-index: 2;
65
+ color: $light-text-color;
66
+ }
67
+
68
+ .demo-heading {
69
+ font-size: 1em;
70
+ }
71
+
72
+ pre {
73
+ border: none;
74
+ margin: 0;
75
+ }
76
+ }