mtl 1.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/mtl/clickables.coffee +25 -0
- data/app/assets/javascripts/mtl/collapsible.coffee +43 -0
- data/app/assets/javascripts/mtl/configuration.coffee.erb +1 -0
- data/app/assets/javascripts/mtl/document_modal.coffee +130 -0
- data/app/assets/javascripts/mtl/dropdown.coffee +24 -0
- data/app/assets/javascripts/mtl/hooks.coffee +14 -0
- data/app/assets/javascripts/mtl/icon.coffee.erb +17 -0
- data/app/assets/javascripts/mtl/modal.coffee +32 -0
- data/app/assets/javascripts/mtl/select.coffee +44 -0
- data/app/assets/javascripts/mtl/templates.coffee +4 -0
- data/app/assets/javascripts/mtl/toc.coffee +31 -0
- data/app/assets/javascripts/mtl.js +42 -0
- data/app/assets/stylesheets/mtl/all.scss +69 -0
- data/app/assets/stylesheets/mtl/extend/_avatars.scss +37 -0
- data/app/assets/stylesheets/mtl/extend/_buttons.scss +31 -0
- data/app/assets/stylesheets/mtl/extend/_cards.scss +21 -0
- data/app/assets/stylesheets/mtl/extend/_chips.scss +3 -0
- data/app/assets/stylesheets/mtl/extend/_collection-files.scss +108 -0
- data/app/assets/stylesheets/mtl/extend/_document-modals.scss +95 -0
- data/app/assets/stylesheets/mtl/extend/_dropdown.scss +12 -0
- data/app/assets/stylesheets/mtl/extend/_forms.scss +66 -0
- data/app/assets/stylesheets/mtl/extend/_global.scss +77 -0
- data/app/assets/stylesheets/mtl/extend/_grid.scss +25 -0
- data/app/assets/stylesheets/mtl/extend/_material-icons.scss +37 -0
- data/app/assets/stylesheets/mtl/extend/_mixins.scss +10 -0
- data/app/assets/stylesheets/mtl/extend/_roboto-rails.scss +49 -0
- data/app/assets/stylesheets/mtl/extend/_side-nav.scss +22 -0
- data/app/assets/stylesheets/mtl/extend/_toc.scss +12 -0
- data/app/assets/stylesheets/mtl/extend/_typography.scss +32 -0
- data/app/assets/stylesheets/mtl/extend/forms/_input-fields.scss +50 -0
- data/app/assets/stylesheets/mtl/layouts/_default.scss +220 -0
- data/app/assets/stylesheets/mtl/layouts/_single.scss +25 -0
- data/app/views/mtl/header.html.erb +25 -0
- data/bin/coffeelint.rb +16 -0
- data/lib/generators/mtl/install_generator.rb +20 -0
- data/lib/generators/mtl/templates/_color.scss +410 -0
- data/lib/generators/mtl/templates/_variables.scss +330 -0
- data/lib/generators/mtl/templates/mtl.scss +8 -0
- data/lib/generators/mtl/templates/simple_form.rb +211 -0
- data/lib/mtl/rails/card_file_presenter.rb +70 -0
- data/lib/mtl/rails/view_helpers.rb +412 -0
- data/lib/mtl/simple_form/suffix.rb +52 -0
- data/lib/mtl/version.rb +6 -0
- data/lib/mtl.rb +38 -0
- data/mtl.gemspec +35 -0
- data/package.json +11 -0
- data/spec/mtl/rails/card_file_presenter_spec.rb +126 -0
- data/spec/mtl/rails/view_helpers_spec.rb +193 -0
- data/spec/mtl/simple_form/suffix_spec.rb +39 -0
- data/spec/mtl_spec.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/dom.rb +15 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.eot +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ijmap +1 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.svg +2373 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/vendor/assets/javascripts/lodash.js +16607 -0
- data/vendor/assets/javascripts/materialize/animation.js +9 -0
- data/vendor/assets/javascripts/materialize/buttons.js +91 -0
- data/vendor/assets/javascripts/materialize/cards.js +26 -0
- data/vendor/assets/javascripts/materialize/carousel.js +454 -0
- data/vendor/assets/javascripts/materialize/character_counter.js +72 -0
- data/vendor/assets/javascripts/materialize/chips.js +267 -0
- data/vendor/assets/javascripts/materialize/collapsible.js +160 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.date.js +1430 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.js +1123 -0
- data/vendor/assets/javascripts/materialize/dropdown.js +265 -0
- data/vendor/assets/javascripts/materialize/forms.js +681 -0
- data/vendor/assets/javascripts/materialize/global.js +45 -0
- data/vendor/assets/javascripts/materialize/hammer.min.js +1 -0
- data/vendor/assets/javascripts/materialize/init.js +173 -0
- data/vendor/assets/javascripts/materialize/initial.js +11 -0
- data/vendor/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/materialize/jquery.hammer.js +33 -0
- data/vendor/assets/javascripts/materialize/jquery.timeago.min.js +1 -0
- data/vendor/assets/javascripts/materialize/leanModal.js +192 -0
- data/vendor/assets/javascripts/materialize/materialbox.js +269 -0
- data/vendor/assets/javascripts/materialize/parallax.js +58 -0
- data/vendor/assets/javascripts/materialize/prism.js +8 -0
- data/vendor/assets/javascripts/materialize/pushpin.js +71 -0
- data/vendor/assets/javascripts/materialize/scrollFire.js +48 -0
- data/vendor/assets/javascripts/materialize/scrollspy.js +283 -0
- data/vendor/assets/javascripts/materialize/sideNav.js +352 -0
- data/vendor/assets/javascripts/materialize/slider.js +321 -0
- data/vendor/assets/javascripts/materialize/tabs.js +148 -0
- data/vendor/assets/javascripts/materialize/toasts.js +136 -0
- data/vendor/assets/javascripts/materialize/tooltip.js +230 -0
- data/vendor/assets/javascripts/materialize/transitions.js +169 -0
- data/vendor/assets/javascripts/materialize/velocity.min.js +5 -0
- data/vendor/assets/javascripts/materialize/waves.js +338 -0
- data/vendor/assets/javascripts/pdfobject.js +254 -0
- data/vendor/assets/stylesheets/materialize/_buttons.scss +211 -0
- data/vendor/assets/stylesheets/materialize/_cards.scss +185 -0
- data/vendor/assets/stylesheets/materialize/_carousel.scss +85 -0
- data/vendor/assets/stylesheets/materialize/_chips.scss +74 -0
- data/vendor/assets/stylesheets/materialize/_collapsible.scss +90 -0
- data/vendor/assets/stylesheets/materialize/_color.scss +412 -0
- data/vendor/assets/stylesheets/materialize/_dropdown.scss +57 -0
- data/vendor/assets/stylesheets/materialize/_global.scss +781 -0
- data/vendor/assets/stylesheets/materialize/_grid.scss +147 -0
- data/vendor/assets/stylesheets/materialize/_icons-material-design.scss +5 -0
- data/vendor/assets/stylesheets/materialize/_materialbox.scss +42 -0
- data/vendor/assets/stylesheets/materialize/_mixins.scss +5 -0
- data/vendor/assets/stylesheets/materialize/_modal.scss +90 -0
- data/vendor/assets/stylesheets/materialize/_navbar.scss +182 -0
- data/vendor/assets/stylesheets/materialize/_normalize.scss +424 -0
- data/vendor/assets/stylesheets/materialize/_prefixer.scss +384 -0
- data/vendor/assets/stylesheets/materialize/_preloader.scss +334 -0
- data/vendor/assets/stylesheets/materialize/_roboto.scss +49 -0
- data/vendor/assets/stylesheets/materialize/_sideNav.scss +219 -0
- data/vendor/assets/stylesheets/materialize/_slider.scss +92 -0
- data/vendor/assets/stylesheets/materialize/_table_of_contents.scss +33 -0
- data/vendor/assets/stylesheets/materialize/_tabs.scss +56 -0
- data/vendor/assets/stylesheets/materialize/_toast.scss +65 -0
- data/vendor/assets/stylesheets/materialize/_tooltip.scss +32 -0
- data/vendor/assets/stylesheets/materialize/_typography.scss +61 -0
- data/vendor/assets/stylesheets/materialize/_variables.scss +313 -0
- data/vendor/assets/stylesheets/materialize/_waves.scss +177 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.date.scss +435 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.scss +201 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.time.scss +125 -0
- data/vendor/assets/stylesheets/materialize/forms/_checkboxes.scss +220 -0
- data/vendor/assets/stylesheets/materialize/forms/_file-input.scss +38 -0
- data/vendor/assets/stylesheets/materialize/forms/_forms.scss +22 -0
- data/vendor/assets/stylesheets/materialize/forms/_input-fields.scss +273 -0
- data/vendor/assets/stylesheets/materialize/forms/_radio-buttons.scss +119 -0
- data/vendor/assets/stylesheets/materialize/forms/_range.scss +159 -0
- data/vendor/assets/stylesheets/materialize/forms/_select.scss +116 -0
- data/vendor/assets/stylesheets/materialize/forms/_switches.scss +78 -0
- metadata +309 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d9b073c97518294bc993c6cd712fee39740397f0
|
|
4
|
+
data.tar.gz: 9d6c66b39bb9948369fbd340c98b5a4ac1a54db3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8f72c380af09be0c8bee8a8d94dd6a651d064da07e9b35018f8847a0bb5c7af4d7f506cd7dc6cb00d96b340d31d786d9a498ec00d5e6d5586715a83a538ff346
|
|
7
|
+
data.tar.gz: 8d1315bceb18bacec36926b18f42e34478ab13076f73c29d4fdfeb8b2ca1bef1792a1bf8ca217c1906ddbe5ec58ab74820cbf103a7440d8c292174215cb8476a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2016 at-point ag (Baar, Switzerland) https://at-point.ch
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# MTL: Materializer
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.org/at-point/mtl)
|
|
6
|
+
|
|
7
|
+
Welcome to **MTL: Materializer**, this is a Rails gem we use at [at-point](https://at-point.ch)
|
|
8
|
+
to simplify UI designs for back-office heavy applications by leveraging the following
|
|
9
|
+
tools:
|
|
10
|
+
|
|
11
|
+
- [Materialize CSS][materialize]
|
|
12
|
+
- [Material Icons][icons] font from Google
|
|
13
|
+
- [Rails][rails] and it's asset pipeline
|
|
14
|
+
- [Lodash][lodash] utilities
|
|
15
|
+
- Google Material Design
|
|
16
|
+
|
|
17
|
+
It requires jQuery (works very will with 3.x).
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Add this line to your Rails application's `Gemfile`, it supports Rails 4.2+
|
|
22
|
+
(including Rails 5):
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
gem 'mtl', git: 'https://github.com/at-point/mtl'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
then execute:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
$> bundle
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
And finally run the installer to copy the "base files" to your application:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
$> ./bin/rails generate mtl:install [--skip-simple-form]
|
|
38
|
+
# This copies the following files:
|
|
39
|
+
# - app/assets/stylesheets/mtl.scss
|
|
40
|
+
# - app/assets/stylesheets/mtl/_color.scss
|
|
41
|
+
# - app/assets/stylesheets/mtl/_variables.scss
|
|
42
|
+
# - config/initializers/simple_form.rb
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Last but not least change your `application.css` to include:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
//= require mtl
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Ensure it **does not contain** any reference to `require_tree .`, as this leads
|
|
52
|
+
to duplicate imports and weird asset pipeline errors.
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Customize and adapt your styling as wanted, feel free to modify things in
|
|
57
|
+
`_variables.scss` to your liking. Try to avoid changing `_color.scss` when
|
|
58
|
+
possible.
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
For development `node` and `npm` is required.
|
|
63
|
+
|
|
64
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
65
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
|
66
|
+
prompt that will allow you to experiment.
|
|
67
|
+
|
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
69
|
+
To release a new version, update the version number in `version.rb`, and then run
|
|
70
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
|
71
|
+
git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
72
|
+
|
|
73
|
+
### Update materialize-css or icons
|
|
74
|
+
|
|
75
|
+
1. Change version in `package.json`
|
|
76
|
+
2. Run `npm update` to fetch the new version
|
|
77
|
+
3. Run `./bin/pull-all`: this copies all resources to vendor/assets
|
|
78
|
+
4. Follow _NEXT STEPS_ closely as defined in output of `pull-all`
|
|
79
|
+
|
|
80
|
+
### Documentation
|
|
81
|
+
|
|
82
|
+
To generate the a browsable html documentation site, use following commands:
|
|
83
|
+
|
|
84
|
+
- `./bin/yardoc`
|
|
85
|
+
- `open doc/index.html`
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/at-point/mtl.
|
|
90
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors
|
|
91
|
+
are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
|
|
92
|
+
code of conduct.
|
|
93
|
+
|
|
94
|
+
### License
|
|
95
|
+
|
|
96
|
+
[MIT License][license]. Copyright 2016 at-point ag. https://at-point.ch
|
|
97
|
+
|
|
98
|
+
[materialize]: http://materializecss.com/
|
|
99
|
+
[icons]: https://design.google.com/icons/
|
|
100
|
+
[rails]: http://rubyonrails.org
|
|
101
|
+
[lodash]: https://lodash.com/
|
|
102
|
+
|
|
103
|
+
[header_helper.rb]: https://github.com/at-point/mtl/blob/master/lib/mtl/rails/header_helper.rb
|
|
104
|
+
[license]: https://github.com/at-point/mtl/blob/master/LICENSE.txt
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
oldHref = $.rails.href
|
|
2
|
+
$.rails.href = (element) -> element.data('mtl-href') || oldHref(element)
|
|
3
|
+
|
|
4
|
+
$(document).on 'click', '[data-mtl-href]', (e) ->
|
|
5
|
+
link = $(this)
|
|
6
|
+
method = link.data('method')
|
|
7
|
+
|
|
8
|
+
return $.rails.stopEverything(e) if !$.rails.allowAction(link)
|
|
9
|
+
|
|
10
|
+
if method
|
|
11
|
+
$.rails.handleMethod link
|
|
12
|
+
return $.rails.stopEverything(e)
|
|
13
|
+
|
|
14
|
+
if Turbolinks?.supported?
|
|
15
|
+
Turbolinks.visit($(this).data('mtl-href'))
|
|
16
|
+
else
|
|
17
|
+
window.location.href = $(this).data('mtl-href')
|
|
18
|
+
|
|
19
|
+
$(document).on 'click', '[data-mtl-href] a', (ev) ->
|
|
20
|
+
ev.stopPropagation()
|
|
21
|
+
|
|
22
|
+
$(document).on 'click', '[data-mtl-submit]', (ev) ->
|
|
23
|
+
ev.preventDefault()
|
|
24
|
+
selector = $(this).data('mtl-submit')
|
|
25
|
+
$(selector).submit()
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Hooks for collapsibles, with (external) triggers
|
|
2
|
+
|
|
3
|
+
createTrigger = ($el) ->
|
|
4
|
+
$target = $($el.data('mtl-collapsible-toggle'))
|
|
5
|
+
currentIdx = $target.find('.collapsible-header.active:first').parent().index()
|
|
6
|
+
if currentIdx == -1
|
|
7
|
+
$target.find('.collapsible-header:first').addClass('active')
|
|
8
|
+
currentIdx = 0
|
|
9
|
+
else if currentIdx > 0
|
|
10
|
+
$el.addClass('active')
|
|
11
|
+
|
|
12
|
+
# hide collapsible-header and disable initial animation
|
|
13
|
+
$target.find('.collapsible-header').hide()
|
|
14
|
+
$target.find('.collapsible-header.active:first').siblings().css('display', 'block')
|
|
15
|
+
|
|
16
|
+
# enable accordion
|
|
17
|
+
createAccordion $target
|
|
18
|
+
|
|
19
|
+
# bind events
|
|
20
|
+
$el.off '.mtl-collapsible'
|
|
21
|
+
$el.on 'click.mtl-collapsible', (e) ->
|
|
22
|
+
e.preventDefault()
|
|
23
|
+
currentIdx = if currentIdx == 0
|
|
24
|
+
$el.addClass('active')
|
|
25
|
+
$target.find('.collapsible-header:last').trigger('click').parent().index()
|
|
26
|
+
else
|
|
27
|
+
$el.removeClass('active')
|
|
28
|
+
$target.find('.collapsible-header:first').trigger('click').parent().index()
|
|
29
|
+
|
|
30
|
+
createAccordion = ($el) ->
|
|
31
|
+
$el.data('collapsible', 'accordion')
|
|
32
|
+
.collapsible(accordion: true)
|
|
33
|
+
|
|
34
|
+
createExpandable = ($el) ->
|
|
35
|
+
$el.data('collapsible', 'expandable')
|
|
36
|
+
.collapsible(accordion: false)
|
|
37
|
+
|
|
38
|
+
init = ->
|
|
39
|
+
$('[data-mtl-collapsible="accordion"]').each -> createAccordion($(this))
|
|
40
|
+
$('[data-mtl-collapsible="expandable"]').each -> createExpandable($(this))
|
|
41
|
+
$('[data-mtl-collapsible-toggle]').each -> createTrigger($(this))
|
|
42
|
+
|
|
43
|
+
if Turbolinks? then $(document).on('turbolinks:load', init) else $(init)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@MTL.fileIcons = <%= Mtl.file_icons.to_json %>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
IMAGE_EXTENSIONS = ['png', 'jpg', 'gif', 'bmp']
|
|
2
|
+
MTL.templates.document_modal = """
|
|
3
|
+
<div class="document-modal">
|
|
4
|
+
<div class="document-modal-dimmer" data-mtl-document-modal="close"></div>
|
|
5
|
+
<div class="document-modal-header">
|
|
6
|
+
<div class="document-modal-title left white-text">
|
|
7
|
+
<%= MTL.fileIcon(filename, { class: 'left' }) %>
|
|
8
|
+
<%- title %>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="document-modal-toolbar right">
|
|
11
|
+
<a href="<%- url %>" target="_blank" download="<%- filename %>">
|
|
12
|
+
<%= MTL.icon('file_download', { class: 'white-text left' }) %>
|
|
13
|
+
</a>
|
|
14
|
+
<a href="#" data-mtl-document-modal="close">
|
|
15
|
+
<%= MTL.icon('close', { class: 'white-text left' }) %>
|
|
16
|
+
</a>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div class="document-modal-content">
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<% if(hasNext) { %>
|
|
24
|
+
<div class="document-modal-next btn black">
|
|
25
|
+
<%= MTL.icon('keyboard_arrow_right', { class: 'white-text' }) %>
|
|
26
|
+
</div>
|
|
27
|
+
<% } %>
|
|
28
|
+
|
|
29
|
+
<% if(hasPrev) { %>
|
|
30
|
+
<div class="document-modal-prev btn black">
|
|
31
|
+
<%= MTL.icon('keyboard_arrow_left', { class: 'white-text' }) %>
|
|
32
|
+
</div>
|
|
33
|
+
<% } %>
|
|
34
|
+
</div>
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
MTL.templates.no_preview = """
|
|
38
|
+
<div class="no-preview">
|
|
39
|
+
<p class="center">
|
|
40
|
+
<%= MTL.icon('visibility_off', { size: 'large grey-text' }) %>
|
|
41
|
+
</p>
|
|
42
|
+
<a href="<%- url %>" target="_blank" class="btn btn-primary truncate">
|
|
43
|
+
<%= MTL.icon('file_download', { class: 'left' }) %>
|
|
44
|
+
<%- title %>
|
|
45
|
+
</a>
|
|
46
|
+
</div>
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
nextFileCard = ($fileCard) ->
|
|
50
|
+
$fileCard.next('[data-mtl-document-modal="open"]')
|
|
51
|
+
|
|
52
|
+
prevFileCard = ($fileCard) ->
|
|
53
|
+
$fileCard.prev('[data-mtl-document-modal="open"]')
|
|
54
|
+
|
|
55
|
+
hasNextFileCard = ($fileCard) ->
|
|
56
|
+
nextFileCard($fileCard).length > 0
|
|
57
|
+
|
|
58
|
+
hasPrevFileCard = ($fileCard) ->
|
|
59
|
+
prevFileCard($fileCard).length > 0
|
|
60
|
+
|
|
61
|
+
fileExtension = (filename) ->
|
|
62
|
+
String(filename).toLowerCase().split('.').pop()
|
|
63
|
+
|
|
64
|
+
isImage = (filename) ->
|
|
65
|
+
_.includes(IMAGE_EXTENSIONS, fileExtension(filename))
|
|
66
|
+
|
|
67
|
+
isPDF = (filename) ->
|
|
68
|
+
fileExtension(filename) == 'pdf'
|
|
69
|
+
|
|
70
|
+
createPreview = ($container, title, filename, url) ->
|
|
71
|
+
switch
|
|
72
|
+
when isImage(filename)
|
|
73
|
+
$container.css 'height', 'auto'
|
|
74
|
+
$container.append($('<img/>', { src: url, alt: filename }))
|
|
75
|
+
when isPDF(filename) && PDFObject.supportsPDFs
|
|
76
|
+
$container.css 'height', '100%'
|
|
77
|
+
$pdfWrapper = $('<div/>').appendTo $container
|
|
78
|
+
PDFObject.embed(url, $pdfWrapper, { width: '800px' })
|
|
79
|
+
else
|
|
80
|
+
$container.css 'height', 'auto'
|
|
81
|
+
data = { title: title, filename: filename, url: url }
|
|
82
|
+
$container.append(MTL.renderTemplate('no_preview', data))
|
|
83
|
+
|
|
84
|
+
findOrCreateDocumentModal = ->
|
|
85
|
+
return $('<div/>').appendTo('body') unless $('body > .document-modal').first().length
|
|
86
|
+
$('body > .document-modal').first()
|
|
87
|
+
|
|
88
|
+
initDocumentModal = ($fileCard) ->
|
|
89
|
+
filename = $fileCard.data('mtl-document-name')
|
|
90
|
+
title = $fileCard.prop('title')
|
|
91
|
+
url = $fileCard.prop('href')
|
|
92
|
+
$modal = $(
|
|
93
|
+
MTL.renderTemplate(
|
|
94
|
+
'document_modal',
|
|
95
|
+
filename: filename,
|
|
96
|
+
title: title,
|
|
97
|
+
url: url,
|
|
98
|
+
hasNext: hasNextFileCard($fileCard),
|
|
99
|
+
hasPrev: hasPrevFileCard($fileCard)
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
$modal.find('.document-modal-next').on('click', -> initDocumentModal(nextFileCard($fileCard)))
|
|
103
|
+
$modal.find('.document-modal-prev').on('click', -> initDocumentModal(prevFileCard($fileCard)))
|
|
104
|
+
createPreview($modal.find('.document-modal-content'), title, filename, url)
|
|
105
|
+
findOrCreateDocumentModal().replaceWith($modal)
|
|
106
|
+
$('body').addClass('no-scroll')
|
|
107
|
+
|
|
108
|
+
closeDocumentModal = ->
|
|
109
|
+
findOrCreateDocumentModal().remove()
|
|
110
|
+
$('body').removeClass('no-scroll')
|
|
111
|
+
$(document).off 'keydown.mtl-document-modal'
|
|
112
|
+
|
|
113
|
+
$(document).on 'click', '[data-mtl-document-modal="open"]', (e) ->
|
|
114
|
+
e.preventDefault()
|
|
115
|
+
initDocumentModal($(e.currentTarget))
|
|
116
|
+
$(document).on 'keydown.mtl-document-modal', (e) ->
|
|
117
|
+
switch e.keyCode
|
|
118
|
+
when 27 # esc
|
|
119
|
+
closeDocumentModal()
|
|
120
|
+
when 37 # left
|
|
121
|
+
findOrCreateDocumentModal().find('.document-modal-prev').trigger 'click'
|
|
122
|
+
when 39 # right
|
|
123
|
+
findOrCreateDocumentModal().find('.document-modal-next').trigger 'click'
|
|
124
|
+
|
|
125
|
+
$(document).on 'click', '[data-mtl-document-modal="close"]', (e) ->
|
|
126
|
+
e.preventDefault()
|
|
127
|
+
closeDocumentModal()
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
updateAttrs = ($el) ->
|
|
2
|
+
$el
|
|
3
|
+
.on('click', -> false)
|
|
4
|
+
.attr('data-constrainwidth', 'false')
|
|
5
|
+
.attr('data-beloworigin', 'true')
|
|
6
|
+
.attr('data-alignment', alignment($el))
|
|
7
|
+
.attr('data-activates', activator($el))
|
|
8
|
+
|
|
9
|
+
alignment = ($el) -> $el.data('alignment') || 'right'
|
|
10
|
+
|
|
11
|
+
activator = ($el) ->
|
|
12
|
+
id = $el.data('activates') || $el.attr('href') || $el.data('mtl-dropdown')
|
|
13
|
+
String(id).replace(/^#/, '')
|
|
14
|
+
|
|
15
|
+
init = ->
|
|
16
|
+
$('[data-mtl-dropdown]').each ->
|
|
17
|
+
$el = $(this)
|
|
18
|
+
updateAttrs($el).dropdown()
|
|
19
|
+
|
|
20
|
+
closeAll = ->
|
|
21
|
+
setTimeout -> $('[data-mtl-dropdown]').dropdown('close')
|
|
22
|
+
|
|
23
|
+
if Turbolinks? then $(document).on('turbolinks:load', init) else $(init)
|
|
24
|
+
$(window).on 'resize orientationchange', closeAll
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Hooks for Turbolinks / jQuery et all
|
|
2
|
+
|
|
3
|
+
# Hooks for data-mtl-*
|
|
4
|
+
initMtlHooks = ->
|
|
5
|
+
$('[data-mtl-nav="side"]').each -> $(this).sideNav()
|
|
6
|
+
$('[data-mtl-tabs]').tabs()
|
|
7
|
+
|
|
8
|
+
if Turbolinks? then $(document).on('turbolinks:load', initMtlHooks) else $(initMtlHooks)
|
|
9
|
+
|
|
10
|
+
# Things to run only once via on('ready') and need to be re-run in turbolinks
|
|
11
|
+
$ ->
|
|
12
|
+
$(document).on 'turbolinks:load', ->
|
|
13
|
+
Materialize.updateTextFields()
|
|
14
|
+
Waves.displayEffect()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
icon = (code, options = {}) ->
|
|
2
|
+
options.class = [<%= Mtl.icon_class.to_json %>, options.size, options.class].join ' '
|
|
3
|
+
delete options.size
|
|
4
|
+
$("<i/>", options).html(code)[0].outerHTML
|
|
5
|
+
|
|
6
|
+
fileIcon = (filename, options = {}) ->
|
|
7
|
+
extension = String(filename).toLowerCase().split('.').pop();
|
|
8
|
+
[code, icon_class] = if MTL.fileIcons.hasOwnProperty(extension)
|
|
9
|
+
MTL.fileIcons[extension]
|
|
10
|
+
else
|
|
11
|
+
MTL.fileIcons.other
|
|
12
|
+
|
|
13
|
+
options.class = [icon_class, options.class].join ' '
|
|
14
|
+
icon(code, options)
|
|
15
|
+
|
|
16
|
+
@MTL.icon = icon
|
|
17
|
+
@MTL.fileIcon = fileIcon
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
MODAL_IDS = 1
|
|
2
|
+
MODAL_TEMPLATE = '
|
|
3
|
+
<div class="modal">
|
|
4
|
+
<div class="modal-content modal-loading">
|
|
5
|
+
Loading…
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
'
|
|
9
|
+
|
|
10
|
+
initModal = ($el) ->
|
|
11
|
+
return initXhrModal($el) if $el.data('mtl-modal') == 'xhr'
|
|
12
|
+
return initDefaultModal($el) if $el.data('mtl-modal') == 'default'
|
|
13
|
+
|
|
14
|
+
initXhrModal = ($el) ->
|
|
15
|
+
modalId = 'mtl-modal-' + (MODAL_IDS++)
|
|
16
|
+
ds = $el.prop('href')
|
|
17
|
+
$modal = $(MODAL_TEMPLATE).prop('id', modalId)
|
|
18
|
+
$modal.appendTo('body')
|
|
19
|
+
$modal.addClass(modalClass) if modalClass = $el.data('mtl-modal-class')
|
|
20
|
+
$el.prop('href', "##{modalId}")
|
|
21
|
+
|
|
22
|
+
initDefaultModal $el,
|
|
23
|
+
ready: -> $modal.load(ds)
|
|
24
|
+
|
|
25
|
+
initDefaultModal = ($el, options = {}) -> $el.leanModal(options)
|
|
26
|
+
|
|
27
|
+
$(document).on 'click', '[data-mtl-modal="close"]', (e) ->
|
|
28
|
+
e.preventDefault()
|
|
29
|
+
$(this).parents('.modal:first').closeModal()
|
|
30
|
+
|
|
31
|
+
init = -> $('[data-mtl-modal]').each -> initModal($(this))
|
|
32
|
+
if Turbolinks? then $(document).on('turbolinks:load', init) else $(init)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
prepareSelect = ($el) ->
|
|
2
|
+
val = $el.val()
|
|
3
|
+
index = $el.prop('selectedIndex')
|
|
4
|
+
|
|
5
|
+
if !val || val.length == 0 || index == 0
|
|
6
|
+
$el.prop('selectedIndex', 0)
|
|
7
|
+
$el.data('mtl-select:is-all-selected', true)
|
|
8
|
+
|
|
9
|
+
$el
|
|
10
|
+
|
|
11
|
+
createSelectCallback = ($el) ->
|
|
12
|
+
->
|
|
13
|
+
return unless $el.data('mtl-select') == 'multiple'
|
|
14
|
+
|
|
15
|
+
$dropdown = $el.prev('.multiple-select-dropdown')
|
|
16
|
+
val = $el.val()
|
|
17
|
+
index = $el.prop('selectedIndex')
|
|
18
|
+
isSelected = $el.data('mtl-select:is-all-selected')
|
|
19
|
+
|
|
20
|
+
# 1: Nothing has been selected => select "all"
|
|
21
|
+
if !val || val.length == 0
|
|
22
|
+
$el.data('mtl-select:is-all-selected', true)
|
|
23
|
+
$dropdown.find('li:first').trigger('click')
|
|
24
|
+
# 2: More than one item is selected and previously "all" was selected =>
|
|
25
|
+
# disable select "all"
|
|
26
|
+
else if val.length > 1 && isSelected
|
|
27
|
+
$el.data('mtl-select:is-all-selected', false)
|
|
28
|
+
$dropdown.find('li:first').trigger('click')
|
|
29
|
+
# 3: More than one item is selected and previously "all" was not selected =>
|
|
30
|
+
# select "all" again
|
|
31
|
+
else if val.length > 1 && index == 0
|
|
32
|
+
$el.data('mtl-select:is-all-selected', true)
|
|
33
|
+
$dropdown.find('li.active:not(:first)').trigger('click')
|
|
34
|
+
|
|
35
|
+
init = ->
|
|
36
|
+
$('select[data-mtl-select], .simple_form .input-field.select > select.select').each ->
|
|
37
|
+
$this = prepareSelect $(this)
|
|
38
|
+
$this.material_select(createSelectCallback($this))
|
|
39
|
+
|
|
40
|
+
teardown = ->
|
|
41
|
+
$('select.initialized').each -> $(this).material_select('destroy')
|
|
42
|
+
|
|
43
|
+
if Turbolinks? then $(document).on('turbolinks:load', init) else $(init)
|
|
44
|
+
$(document).on 'turbolinks:before-cache', teardown
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
TEMPLATE = _.template '''
|
|
2
|
+
<li>
|
|
3
|
+
<a href="#<%- id %>"><%- title %></a>
|
|
4
|
+
</li>
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
createTocEntry = ($el) ->
|
|
8
|
+
# Ensure id and get title
|
|
9
|
+
title = $el.data('mtl-section')
|
|
10
|
+
id = $el.prop('id') || "mtl-toc-#{Materialize.guid()}"
|
|
11
|
+
$el.prop('id', id)
|
|
12
|
+
|
|
13
|
+
# Render
|
|
14
|
+
TEMPLATE(id: id, title: title)
|
|
15
|
+
|
|
16
|
+
initToc = ($wrapper) ->
|
|
17
|
+
# Clear
|
|
18
|
+
$wrapper.children().remove()
|
|
19
|
+
|
|
20
|
+
# Pin wrapper to top, if data-mtl-toc="pin"
|
|
21
|
+
$wrapper.pushpin(top: $wrapper.offset().top) if $wrapper.data('mtl-toc') == 'pin'
|
|
22
|
+
|
|
23
|
+
# Add entries
|
|
24
|
+
$sections = $('[data-mtl-section]').each ->
|
|
25
|
+
$wrapper.append createTocEntry($(this))
|
|
26
|
+
|
|
27
|
+
# Enable scrollspy
|
|
28
|
+
$sections.scrollSpy()
|
|
29
|
+
|
|
30
|
+
init = -> $('[data-mtl-toc]').each -> initToc($(this))
|
|
31
|
+
if Turbolinks? then $(document).on('turbolinks:load', init) else $(init)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//=require "materialize/jquery.easing.1.3"
|
|
2
|
+
//=require "materialize/velocity.min"
|
|
3
|
+
//=require "materialize/hammer.min"
|
|
4
|
+
//=require "materialize/jquery.hammer"
|
|
5
|
+
//=require "lodash"
|
|
6
|
+
//=require "pdfobject"
|
|
7
|
+
|
|
8
|
+
//=require "materialize/global"
|
|
9
|
+
|
|
10
|
+
//=require "materialize/collapsible"
|
|
11
|
+
//=require "materialize/dropdown"
|
|
12
|
+
//=require "materialize/leanModal"
|
|
13
|
+
//=require "materialize/materialbox"
|
|
14
|
+
//=require "materialize/parallax"
|
|
15
|
+
//=require "materialize/tabs"
|
|
16
|
+
//=require "materialize/tooltip"
|
|
17
|
+
//=require "materialize/waves"
|
|
18
|
+
//=require "materialize/toasts"
|
|
19
|
+
//=require "materialize/sideNav"
|
|
20
|
+
//=require "materialize/scrollspy"
|
|
21
|
+
//=require "materialize/forms"
|
|
22
|
+
//=require "materialize/slider"
|
|
23
|
+
//=require "materialize/date_picker/picker"
|
|
24
|
+
//=require "materialize/date_picker/picker.date"
|
|
25
|
+
//=require "materialize/pushpin"
|
|
26
|
+
|
|
27
|
+
//= require_self
|
|
28
|
+
//= require "mtl/configuration"
|
|
29
|
+
//= require "mtl/templates"
|
|
30
|
+
//= require "mtl/hooks"
|
|
31
|
+
//= require "mtl/clickables"
|
|
32
|
+
//= require "mtl/collapsible"
|
|
33
|
+
//= require "mtl/dropdown"
|
|
34
|
+
//= require "mtl/modal"
|
|
35
|
+
//= require "mtl/select"
|
|
36
|
+
//= require "mtl/toc"
|
|
37
|
+
//= require "mtl/icon"
|
|
38
|
+
//= require "mtl/document_modal"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// Export
|
|
42
|
+
window.MTL = {}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@charset 'UTF-8';
|
|
2
|
+
|
|
3
|
+
// Reset
|
|
4
|
+
@import 'materialize/normalize';
|
|
5
|
+
|
|
6
|
+
// components
|
|
7
|
+
@import 'materialize/global';
|
|
8
|
+
@import './extend/global';
|
|
9
|
+
|
|
10
|
+
@import './extend/material-icons';
|
|
11
|
+
|
|
12
|
+
@import 'materialize/grid';
|
|
13
|
+
@import './extend/grid';
|
|
14
|
+
|
|
15
|
+
@import 'materialize/navbar';
|
|
16
|
+
|
|
17
|
+
// @import 'materialize/roboto';
|
|
18
|
+
@import './extend/roboto-rails'; // using asset_url's
|
|
19
|
+
|
|
20
|
+
@import 'materialize/typography';
|
|
21
|
+
|
|
22
|
+
@import 'materialize/cards';
|
|
23
|
+
@import './extend/cards';
|
|
24
|
+
|
|
25
|
+
@import 'materialize/toast';
|
|
26
|
+
|
|
27
|
+
@import 'materialize/tabs';
|
|
28
|
+
|
|
29
|
+
@import 'materialize/tooltip';
|
|
30
|
+
@import 'materialize/buttons';
|
|
31
|
+
@import './extend/buttons';
|
|
32
|
+
@import 'materialize/dropdown';
|
|
33
|
+
@import 'extend/dropdown';
|
|
34
|
+
@import 'materialize/waves';
|
|
35
|
+
@import 'materialize/modal';
|
|
36
|
+
@import 'materialize/collapsible';
|
|
37
|
+
|
|
38
|
+
@import 'materialize/chips';
|
|
39
|
+
@import './extend/chips';
|
|
40
|
+
|
|
41
|
+
@import 'materialize/materialbox';
|
|
42
|
+
@import 'materialize/forms/forms';
|
|
43
|
+
@import './extend/forms';
|
|
44
|
+
@import './extend/forms/input-fields';
|
|
45
|
+
@import 'materialize/table_of_contents';
|
|
46
|
+
@import './extend/toc';
|
|
47
|
+
|
|
48
|
+
@import 'materialize/sideNav';
|
|
49
|
+
@import './extend/side-nav';
|
|
50
|
+
|
|
51
|
+
@import './extend/avatars';
|
|
52
|
+
|
|
53
|
+
@import 'materialize/preloader';
|
|
54
|
+
@import 'materialize/slider';
|
|
55
|
+
@import 'materialize/carousel';
|
|
56
|
+
@import 'materialize/date_picker/default';
|
|
57
|
+
@import 'materialize/date_picker/default.date';
|
|
58
|
+
@import 'materialize/date_picker/default.time';
|
|
59
|
+
|
|
60
|
+
// extending the materializer library even more
|
|
61
|
+
@import './extend/mixins';
|
|
62
|
+
@import './extend/collection-files';
|
|
63
|
+
@import './extend/typography';
|
|
64
|
+
@import './extend/document-modals';
|
|
65
|
+
|
|
66
|
+
// including layouts
|
|
67
|
+
html { height: 100%; } // yes, necessary
|
|
68
|
+
@import './layouts/default';
|
|
69
|
+
@import './layouts/single';
|