rails_admin_material 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +25 -0
  4. data/Rakefile +24 -0
  5. data/lib/rails_admin_material.rb +4 -0
  6. data/lib/rails_admin_material/engine.rb +4 -0
  7. data/lib/rails_admin_material/version.rb +3 -0
  8. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/material.js +352 -0
  9. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/material.min.js +2 -0
  10. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/material.min.js.map +1 -0
  11. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/ripples.js +324 -0
  12. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/ripples.min.js +2 -0
  13. data/vendor/assets/javascripts/rails_admin/themes/material/bootstrap-material-design/ripples.min.js.map +1 -0
  14. data/vendor/assets/javascripts/rails_admin/themes/material/ui.js +6 -0
  15. data/vendor/assets/stylesheets/bootstrap/variables.scss +874 -0
  16. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_alerts.scss +19 -0
  17. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_buttons.scss +246 -0
  18. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_cards.scss +68 -0
  19. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_checkboxes.scss +272 -0
  20. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_colors-map.scss +311 -0
  21. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_colors.scss +361 -0
  22. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_core.scss +95 -0
  23. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_dialogs.scss +54 -0
  24. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_dividers.scss +73 -0
  25. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_form.scss +42 -0
  26. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_import-bs-less.scss +4 -0
  27. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_import-bs-sass.scss +1 -0
  28. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_inputs-size.scss +223 -0
  29. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_inputs.scss +354 -0
  30. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_labels.scss +6 -0
  31. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_lists.scss +104 -0
  32. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_mixins-utilities.scss +31 -0
  33. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_mixins.scss +242 -0
  34. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_navbar.scss +212 -0
  35. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_panels.scss +23 -0
  36. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_plugins.scss +7 -0
  37. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_popups.scss +20 -0
  38. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_progress.scss +12 -0
  39. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_radios.scss +117 -0
  40. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_shadows.scss +84 -0
  41. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_tabs.scss +26 -0
  42. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_themes.scss +8 -0
  43. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_togglebutton.scss +85 -0
  44. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_typography.scss +17 -0
  45. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_variables.scss +174 -0
  46. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/_welljumbo.scss +28 -0
  47. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/bootstrap-material-design.scss +6 -0
  48. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/plugins/_plugin-dropdownjs.scss +17 -0
  49. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/plugins/_plugin-nouislider.scss +112 -0
  50. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/plugins/_plugin-selectize.scss +93 -0
  51. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/plugins/_plugin-snackbarjs.scss +34 -0
  52. data/vendor/assets/stylesheets/rails_admin/themes/material/bootstrap-material-design/ripples.scss +38 -0
  53. data/vendor/assets/stylesheets/rails_admin/themes/material/mixins.scss +5 -0
  54. data/vendor/assets/stylesheets/rails_admin/themes/material/theming.scss +124 -0
  55. data/vendor/assets/stylesheets/rails_admin/themes/material/variables.scss +32 -0
  56. metadata +98 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 351331bcc877ad66187498d6615ca6997bf13543
4
+ data.tar.gz: 2f128103f0e008bee43232e93cf351aa408b41bd
5
+ SHA512:
6
+ metadata.gz: 8c177480df52e9b679e4701da0c3183212f60ae19893dfdcfa989cd12a73561888d191dab291991f4e8355857ee316fa773f323588d551b62a8d759d18d863c8
7
+ data.tar.gz: a4cc1068fdf818d509b45f27326b71a967f22cec48eae458be5ee0c71bcf15c420a1016749470efb196e1f21fe3be80176c0e47a9ea1d9c52cb03d587c4c79da
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # RailsAdminMaterial theme
2
+
3
+ A Material Design theme for rails_admin
4
+
5
+ ## Requirements
6
+
7
+ - rails_admin
8
+
9
+ ## Installation
10
+
11
+ - Add the gem to Gemfile: `gem 'rails_admin_material'`
12
+
13
+ - Execute: `bundle`
14
+
15
+ - Enable the theme in *config/application.rb*: `ENV['RAILS_ADMIN_THEME'] = 'material'`
16
+
17
+ - Edit or create `app/assets/javascripts/rails_admin/custom/ui.js` and add: `//= require rails_admin/themes/material/ui.js`
18
+
19
+ ## Preview
20
+
21
+ ![preview](preview.jpg)
22
+
23
+ ## Contributors
24
+
25
+ - [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ begin
9
+ require 'rdoc/task'
10
+ rescue LoadError
11
+ require 'rdoc/rdoc'
12
+ require 'rake/rdoctask'
13
+ RDoc::Task = Rake::RDocTask
14
+ end
15
+
16
+ RDoc::Task.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'RailsAdminMaterial'
19
+ rdoc.options << '--line-numbers'
20
+ rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,4 @@
1
+ require "rails_admin_material/engine"
2
+
3
+ module RailsAdminMaterial
4
+ end
@@ -0,0 +1,4 @@
1
+ module RailsAdminMaterial
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminMaterial
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,352 @@
1
+ /* globals jQuery */
2
+
3
+ (function ($) {
4
+ // Selector to select only not already processed elements
5
+ $.expr[":"].notmdproc = function (obj) {
6
+ if ($(obj).data("mdproc")) {
7
+ return false;
8
+ } else {
9
+ return true;
10
+ }
11
+ };
12
+
13
+ function _isChar(evt) {
14
+ if (typeof evt.which == "undefined") {
15
+ return true;
16
+ } else if (typeof evt.which == "number" && evt.which > 0) {
17
+ return (
18
+ !evt.ctrlKey
19
+ && !evt.metaKey
20
+ && !evt.altKey
21
+ && evt.which != 8 // backspace
22
+ && evt.which != 9 // tab
23
+ && evt.which != 13 // enter
24
+ && evt.which != 16 // shift
25
+ && evt.which != 17 // ctrl
26
+ && evt.which != 20 // caps lock
27
+ && evt.which != 27 // escape
28
+ );
29
+ }
30
+ return false;
31
+ }
32
+
33
+ function _addFormGroupFocus(element) {
34
+ var $element = $(element);
35
+ if (!$element.prop('disabled')) { // this is showing as undefined on chrome but works fine on firefox??
36
+ $element.closest(".form-group").addClass("is-focused");
37
+ }
38
+ }
39
+
40
+ function _toggleDisabledState($element, state) {
41
+ var $target;
42
+ if ($element.hasClass('checkbox-inline') || $element.hasClass('radio-inline')) {
43
+ $target = $element;
44
+ } else {
45
+ $target = $element.closest('.checkbox').length ? $element.closest('.checkbox') : $element.closest('.radio');
46
+ }
47
+ return $target.toggleClass('disabled', state);
48
+ }
49
+
50
+ function _toggleTypeFocus($input) {
51
+ var disabledToggleType = false;
52
+ if ($input.is($.material.options.checkboxElements) || $input.is($.material.options.radioElements)) {
53
+ disabledToggleType = true;
54
+ }
55
+ $input.closest('label').hover(function () {
56
+ var $i = $(this).find('input');
57
+ var isDisabled = $i.prop('disabled'); // hack because the _addFormGroupFocus() wasn't identifying the property on chrome
58
+ if (disabledToggleType) {
59
+ _toggleDisabledState($(this), isDisabled);
60
+ }
61
+ if (!isDisabled) {
62
+ _addFormGroupFocus($i); // need to find the input so we can check disablement
63
+ }
64
+ },
65
+ function () {
66
+ _removeFormGroupFocus($(this).find('input'));
67
+ });
68
+ }
69
+
70
+ function _removeFormGroupFocus(element) {
71
+ $(element).closest(".form-group").removeClass("is-focused"); // remove class from form-group
72
+ }
73
+
74
+ $.material = {
75
+ "options": {
76
+ // These options set what will be started by $.material.init()
77
+ "validate": true,
78
+ "input": true,
79
+ "ripples": true,
80
+ "checkbox": true,
81
+ "togglebutton": true,
82
+ "radio": true,
83
+ "arrive": true,
84
+ "autofill": false,
85
+
86
+ "withRipples": [
87
+ ".btn:not(.btn-link)",
88
+ ".card-image",
89
+ ".navbar a:not(.withoutripple)",
90
+ ".dropdown-menu a",
91
+ ".nav-tabs a:not(.withoutripple)",
92
+ ".withripple",
93
+ ".pagination li:not(.active):not(.disabled) a:not(.withoutripple)"
94
+ ].join(","),
95
+ "inputElements": "input.form-control, textarea.form-control, select.form-control",
96
+ "checkboxElements": ".checkbox > label > input[type=checkbox], label.checkbox-inline > input[type=checkbox]",
97
+ "togglebuttonElements": ".togglebutton > label > input[type=checkbox]",
98
+ "radioElements": ".radio > label > input[type=radio], label.radio-inline > input[type=radio]"
99
+ },
100
+ "checkbox": function (selector) {
101
+ // Add fake-checkbox to material checkboxes
102
+ var $input = $((selector) ? selector : this.options.checkboxElements)
103
+ .filter(":notmdproc")
104
+ .data("mdproc", true)
105
+ .after("<span class='checkbox-material'><span class='check'></span></span>");
106
+
107
+ _toggleTypeFocus($input);
108
+ },
109
+ "togglebutton": function (selector) {
110
+ // Add fake-checkbox to material checkboxes
111
+ var $input = $((selector) ? selector : this.options.togglebuttonElements)
112
+ .filter(":notmdproc")
113
+ .data("mdproc", true)
114
+ .after("<span class='toggle'></span>");
115
+
116
+ _toggleTypeFocus($input);
117
+ },
118
+ "radio": function (selector) {
119
+ // Add fake-radio to material radios
120
+ var $input = $((selector) ? selector : this.options.radioElements)
121
+ .filter(":notmdproc")
122
+ .data("mdproc", true)
123
+ .after("<span class='circle'></span><span class='check'></span>");
124
+
125
+ _toggleTypeFocus($input);
126
+ },
127
+ "input": function (selector) {
128
+ $((selector) ? selector : this.options.inputElements)
129
+ .filter(":notmdproc")
130
+ .data("mdproc", true)
131
+ .each(function () {
132
+ var $input = $(this);
133
+
134
+ // Requires form-group standard markup (will add it if necessary)
135
+ var $formGroup = $input.closest(".form-group"); // note that form-group may be grandparent in the case of an input-group
136
+ if ($formGroup.length === 0 && $input.attr('type') !== "hidden" && !$input.attr('hidden')) {
137
+ $input.wrap("<div class='form-group'></div>");
138
+ $formGroup = $input.closest(".form-group"); // find node after attached (otherwise additional attachments don't work)
139
+ }
140
+
141
+ // Legacy - Add hint label if using the old shorthand data-hint attribute on the input
142
+ if ($input.attr("data-hint")) {
143
+ $input.after("<p class='help-block'>" + $input.attr("data-hint") + "</p>");
144
+ $input.removeAttr("data-hint");
145
+ }
146
+
147
+ // Legacy - Change input-sm/lg to form-group-sm/lg instead (preferred standard and simpler css/less variants)
148
+ var legacySizes = {
149
+ "input-lg": "form-group-lg",
150
+ "input-sm": "form-group-sm"
151
+ };
152
+ $.each(legacySizes, function (legacySize, standardSize) {
153
+ if ($input.hasClass(legacySize)) {
154
+ $input.removeClass(legacySize);
155
+ $formGroup.addClass(standardSize);
156
+ }
157
+ });
158
+
159
+ // Legacy - Add label-floating if using old shorthand <input class="floating-label" placeholder="foo">
160
+ if ($input.hasClass("floating-label")) {
161
+ var placeholder = $input.attr("placeholder");
162
+ $input.attr("placeholder", null).removeClass("floating-label");
163
+ var id = $input.attr("id");
164
+ var forAttribute = "";
165
+ if (id) {
166
+ forAttribute = "for='" + id + "'";
167
+ }
168
+ $formGroup.addClass("label-floating");
169
+ $input.after("<label " + forAttribute + "class='control-label'>" + placeholder + "</label>");
170
+ }
171
+
172
+ // Set as empty if is empty (damn I must improve this...)
173
+ if ($input.val() === null || $input.val() == "undefined" || $input.val() === "") {
174
+ $formGroup.addClass("is-empty");
175
+ }
176
+
177
+ // Support for file input
178
+ if ($formGroup.find("input[type=file]").length > 0) {
179
+ $formGroup.addClass("is-fileinput");
180
+ }
181
+ });
182
+ },
183
+ "attachInputEventHandlers": function () {
184
+ var validate = this.options.validate;
185
+
186
+ $(document)
187
+ .on("keydown paste", ".form-control", function (e) {
188
+ if (_isChar(e)) {
189
+ $(this).closest(".form-group").removeClass("is-empty");
190
+ }
191
+ })
192
+ .on("keyup change", ".form-control", function () {
193
+ var $input = $(this);
194
+ var $formGroup = $input.closest(".form-group");
195
+ var isValid = (typeof $input[0].checkValidity === "undefined" || $input[0].checkValidity());
196
+
197
+ if ($input.val() === "") {
198
+ $formGroup.addClass("is-empty");
199
+ }
200
+ else {
201
+ $formGroup.removeClass("is-empty");
202
+ }
203
+
204
+ // Validation events do not bubble, so they must be attached directly to the input: http://jsfiddle.net/PEpRM/1/
205
+ // Further, even the bind method is being caught, but since we are already calling #checkValidity here, just alter
206
+ // the form-group on change.
207
+ //
208
+ // NOTE: I'm not sure we should be intervening regarding validation, this seems better as a README and snippet of code.
209
+ // BUT, I've left it here for backwards compatibility.
210
+ if (validate) {
211
+ if (isValid) {
212
+ $formGroup.removeClass("has-error");
213
+ }
214
+ else {
215
+ $formGroup.addClass("has-error");
216
+ }
217
+ }
218
+ })
219
+ .on("focus", ".form-control, .form-group.is-fileinput", function () {
220
+ _addFormGroupFocus(this);
221
+ })
222
+ .on("blur", ".form-control, .form-group.is-fileinput", function () {
223
+ _removeFormGroupFocus(this);
224
+ })
225
+ // make sure empty is added back when there is a programmatic value change.
226
+ // NOTE: programmatic changing of value using $.val() must trigger the change event i.e. $.val('x').trigger('change')
227
+ .on("change", ".form-group input", function () {
228
+ var $input = $(this);
229
+ if ($input.attr("type") == "file") {
230
+ return;
231
+ }
232
+
233
+ var $formGroup = $input.closest(".form-group");
234
+ var value = $input.val();
235
+ if (value) {
236
+ $formGroup.removeClass("is-empty");
237
+ } else {
238
+ $formGroup.addClass("is-empty");
239
+ }
240
+ })
241
+ // set the fileinput readonly field with the name of the file
242
+ .on("change", ".form-group.is-fileinput input[type='file']", function () {
243
+ var $input = $(this);
244
+ var $formGroup = $input.closest(".form-group");
245
+ var value = "";
246
+ $.each(this.files, function (i, file) {
247
+ value += file.name + ", ";
248
+ });
249
+ value = value.substring(0, value.length - 2);
250
+ if (value) {
251
+ $formGroup.removeClass("is-empty");
252
+ } else {
253
+ $formGroup.addClass("is-empty");
254
+ }
255
+ $formGroup.find("input.form-control[readonly]").val(value);
256
+ });
257
+ },
258
+ "ripples": function (selector) {
259
+ $((selector) ? selector : this.options.withRipples).ripples();
260
+ },
261
+ "autofill": function () {
262
+ // This part of code will detect autofill when the page is loading (username and password inputs for example)
263
+ var loading = setInterval(function () {
264
+ $("input[type!=checkbox]").each(function () {
265
+ var $this = $(this);
266
+ if ($this.val() && $this.val() !== $this.attr("value")) {
267
+ $this.trigger("change");
268
+ }
269
+ });
270
+ }, 100);
271
+
272
+ // After 10 seconds we are quite sure all the needed inputs are autofilled then we can stop checking them
273
+ setTimeout(function () {
274
+ clearInterval(loading);
275
+ }, 10000);
276
+ },
277
+ "attachAutofillEventHandlers": function () {
278
+ // Listen on inputs of the focused form (because user can select from the autofill dropdown only when the input has focus)
279
+ var focused;
280
+ $(document)
281
+ .on("focus", "input", function () {
282
+ var $inputs = $(this).parents("form").find("input").not("[type=file]");
283
+ focused = setInterval(function () {
284
+ $inputs.each(function () {
285
+ var $this = $(this);
286
+ if ($this.val() !== $this.attr("value")) {
287
+ $this.trigger("change");
288
+ }
289
+ });
290
+ }, 100);
291
+ })
292
+ .on("blur", ".form-group input", function () {
293
+ clearInterval(focused);
294
+ });
295
+ },
296
+ "init": function (options) {
297
+ this.options = $.extend({}, this.options, options);
298
+ var $document = $(document);
299
+
300
+ if ($.fn.ripples && this.options.ripples) {
301
+ this.ripples();
302
+ }
303
+ if (this.options.input) {
304
+ this.input();
305
+ this.attachInputEventHandlers();
306
+ }
307
+ if (this.options.checkbox) {
308
+ this.checkbox();
309
+ }
310
+ if (this.options.togglebutton) {
311
+ this.togglebutton();
312
+ }
313
+ if (this.options.radio) {
314
+ this.radio();
315
+ }
316
+ if (this.options.autofill) {
317
+ this.autofill();
318
+ this.attachAutofillEventHandlers();
319
+ }
320
+
321
+ if (document.arrive && this.options.arrive) {
322
+ if ($.fn.ripples && this.options.ripples) {
323
+ $document.arrive(this.options.withRipples, function () {
324
+ $.material.ripples($(this));
325
+ });
326
+ }
327
+ if (this.options.input) {
328
+ $document.arrive(this.options.inputElements, function () {
329
+ $.material.input($(this));
330
+ });
331
+ }
332
+ if (this.options.checkbox) {
333
+ $document.arrive(this.options.checkboxElements, function () {
334
+ $.material.checkbox($(this));
335
+ });
336
+ }
337
+ if (this.options.radio) {
338
+ $document.arrive(this.options.radioElements, function () {
339
+ $.material.radio($(this));
340
+ });
341
+ }
342
+ if (this.options.togglebutton) {
343
+ $document.arrive(this.options.togglebuttonElements, function () {
344
+ $.material.togglebutton($(this));
345
+ });
346
+ }
347
+
348
+ }
349
+ }
350
+ };
351
+
352
+ })(jQuery);