diff --git a/app/assets/javascripts/behaviours/details_behavior.coffee b/app/assets/javascripts/behaviours/details_behavior.coffee new file mode 100644 index 00000000..f75284d9 --- /dev/null +++ b/app/assets/javascripts/behaviours/details_behavior.coffee @@ -0,0 +1,5 @@ +$ -> + $("body").on "click", ".js-details-target", -> + container = $(@).closest ".js-details-container" + + container.toggleClass "open" diff --git a/app/assets/javascripts/behaviours/toggler_behaviour.coffee b/app/assets/javascripts/behaviours/toggler_behaviour.coffee new file mode 100644 index 00000000..76f200d4 --- /dev/null +++ b/app/assets/javascripts/behaviours/toggler_behaviour.coffee @@ -0,0 +1,5 @@ +$ -> + $("body").on "click", ".js-toggler-target", -> + container = $(@).closest ".js-toggler-container" + + container.toggleClass "on" diff --git a/app/assets/stylesheets/behaviors.scss b/app/assets/stylesheets/behaviors.scss new file mode 100644 index 00000000..20854e7e --- /dev/null +++ b/app/assets/stylesheets/behaviors.scss @@ -0,0 +1,14 @@ +// Details +//-------- +.js-details-container .content { display: none; } +.js-details-container .content.hide { display: block; } +.js-details-container.open .content { display: block; } +.js-details-container.open .content.hide { display: none; } + + +// Toggler +//-------- +.js-toggler-container .turn-on { display: inline-block; } +.js-toggler-container .turn-off { display: none; } +.js-toggler-container.on .turn-on { display: none; } +.js-toggler-container.on .turn-off { display: inline-block; } diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index bc7a7440..98d75521 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -83,6 +83,11 @@ $baseLineHeight: 18px !default; */ @import "common.scss"; +/** + * Styles necessary to support JS behaviours. + */ +@import "behaviors.scss"; + /** * Styles related to specific part of app */