fuelux-rails 0.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.
Files changed (50) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/lib/fuelux-rails.rb +6 -0
  5. data/lib/fuelux-rails/engine.rb +11 -0
  6. data/lib/fuelux-rails/fuelux.rb +3 -0
  7. data/lib/fuelux-rails/version.rb +3 -0
  8. data/lib/tasks/fuelux-rails_tasks.rake +4 -0
  9. data/test/dummy/README.rdoc +261 -0
  10. data/test/dummy/Rakefile +7 -0
  11. data/test/dummy/app/assets/javascripts/application.js +15 -0
  12. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/helpers/application_helper.rb +2 -0
  15. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  16. data/test/dummy/config.ru +4 -0
  17. data/test/dummy/config/application.rb +59 -0
  18. data/test/dummy/config/boot.rb +10 -0
  19. data/test/dummy/config/database.yml +25 -0
  20. data/test/dummy/config/environment.rb +5 -0
  21. data/test/dummy/config/environments/development.rb +37 -0
  22. data/test/dummy/config/environments/production.rb +67 -0
  23. data/test/dummy/config/environments/test.rb +37 -0
  24. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  25. data/test/dummy/config/initializers/inflections.rb +15 -0
  26. data/test/dummy/config/initializers/mime_types.rb +5 -0
  27. data/test/dummy/config/initializers/secret_token.rb +7 -0
  28. data/test/dummy/config/initializers/session_store.rb +8 -0
  29. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  30. data/test/dummy/config/locales/en.yml +5 -0
  31. data/test/dummy/config/routes.rb +58 -0
  32. data/test/dummy/public/404.html +26 -0
  33. data/test/dummy/public/422.html +26 -0
  34. data/test/dummy/public/500.html +25 -0
  35. data/test/dummy/public/favicon.ico +0 -0
  36. data/test/dummy/script/rails +6 -0
  37. data/test/fuelux-rails_test.rb +7 -0
  38. data/test/test_helper.rb +15 -0
  39. data/vendor/assets/javascripts/fuelux.js +5 -0
  40. data/vendor/assets/javascripts/fuelux/datagrid.js +214 -0
  41. data/vendor/assets/javascripts/fuelux/loader.js +3190 -0
  42. data/vendor/assets/javascripts/fuelux/pillbox.js +69 -0
  43. data/vendor/assets/javascripts/fuelux/search.js +100 -0
  44. data/vendor/assets/javascripts/fuelux/spinner.js +183 -0
  45. data/vendor/toolkit/fuelux.less +5 -0
  46. data/vendor/toolkit/fuelux/combobox.less +5 -0
  47. data/vendor/toolkit/fuelux/datagrid.less +98 -0
  48. data/vendor/toolkit/fuelux/pillbox.less +74 -0
  49. data/vendor/toolkit/fuelux/spinner.less +47 -0
  50. metadata +173 -0
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Fuel UX Pillbox
3
+ * https://github.com/ExactTarget/fuelux
4
+ *
5
+ * Copyright (c) 2012 ExactTarget
6
+ * Licensed under the MIT license.
7
+ */
8
+
9
+ !function ($) {
10
+
11
+ // PILLBOX CONSTRUCTOR AND PROTOTYPE
12
+
13
+ var Pillbox = function (element, options) {
14
+ this.$element = $(element);
15
+ this.options = $.extend({}, $.fn.pillbox.defaults, options);
16
+ this.$element.on('click', 'li', $.proxy(this.itemclicked, this));
17
+ };
18
+
19
+ Pillbox.prototype = {
20
+ constructor: Pillbox,
21
+
22
+ items: function() {
23
+ return this.$element.find('li').map(function() {
24
+ var $this = $(this);
25
+ return $.extend({ text: $this.text() }, $this.data());
26
+ }).get();
27
+ },
28
+
29
+ itemclicked: function (e) {
30
+ $(e.currentTarget).remove();
31
+ e.preventDefault();
32
+ }
33
+ };
34
+
35
+
36
+ // PILLBOX PLUGIN DEFINITION
37
+
38
+ $.fn.pillbox = function (option) {
39
+ var methodReturn;
40
+
41
+ var $set = this.each(function () {
42
+ var $this = $(this);
43
+ var data = $this.data('pillbox');
44
+ var options = typeof option === 'object' && option;
45
+
46
+ if (!data) $this.data('pillbox', (data = new Pillbox(this, options)));
47
+ if (typeof option === 'string') methodReturn = data[option]();
48
+ });
49
+
50
+ return (methodReturn === undefined) ? $set : methodReturn;
51
+ };
52
+
53
+ $.fn.pillbox.defaults = {};
54
+
55
+ $.fn.pillbox.Constructor = Pillbox;
56
+
57
+
58
+ // PILLBOX DATA-API
59
+
60
+ $(function () {
61
+ $('body').on('mousedown.pillbox.data-api', '.pillbox', function (e) {
62
+ var $this = $(this);
63
+ if ($this.data('pillbox')) return;
64
+ $this.pillbox($this.data());
65
+ });
66
+ });
67
+
68
+ }(window.jQuery);
69
+
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Fuel UX Search
3
+ * https://github.com/ExactTarget/fuelux
4
+ *
5
+ * Copyright (c) 2012 ExactTarget
6
+ * Licensed under the MIT license.
7
+ */
8
+
9
+ !function ($) {
10
+
11
+
12
+ // SEARCH CONSTRUCTOR AND PROTOTYPE
13
+
14
+ var Search = function (element, options) {
15
+ this.$element = $(element);
16
+ this.options = $.extend({}, $.fn.search.defaults, options);
17
+ this.$element.find('button').on('click', $.proxy(this.buttonclicked, this));
18
+ this.$input = this.$element.find('input').on('keyup', $.proxy(this.keypressed, this));
19
+ this.$icon = this.$element.find('i');
20
+ this.activeSearch = '';
21
+ };
22
+
23
+ Search.prototype = {
24
+
25
+ constructor: Search,
26
+
27
+ search: function (searchText) {
28
+ this.$icon.attr('class', 'icon-remove');
29
+ this.activeSearch = searchText;
30
+ this.$element.trigger('searched', searchText);
31
+ },
32
+
33
+ clear: function () {
34
+ this.$icon.attr('class', 'icon-search');
35
+ this.activeSearch = '';
36
+ this.$input.val('');
37
+ this.$element.trigger('cleared');
38
+ },
39
+
40
+ action: function () {
41
+ var val = this.$input.val();
42
+ var inputEmptyOrUnchanged = val === '' || val === this.activeSearch;
43
+
44
+ if (this.activeSearch && inputEmptyOrUnchanged) {
45
+ this.clear();
46
+ } else if (val) {
47
+ this.search(val);
48
+ }
49
+ },
50
+
51
+ buttonclicked: function (e) {
52
+ e.preventDefault();
53
+ this.action();
54
+ },
55
+
56
+ keypressed: function (e) {
57
+ var val, inputPresentAndUnchanged;
58
+
59
+ if (e.which === 13) {
60
+ e.preventDefault();
61
+ this.action();
62
+ } else {
63
+ val = this.$input.val();
64
+ inputPresentAndUnchanged = val && (val === this.activeSearch);
65
+ this.$icon.attr('class', inputPresentAndUnchanged ? 'icon-remove' : 'icon-search');
66
+ }
67
+ }
68
+
69
+ };
70
+
71
+
72
+ // SEARCH PLUGIN DEFINITION
73
+
74
+ $.fn.search = function (option) {
75
+ return this.each(function () {
76
+ var $this = $(this);
77
+ var data = $this.data('search');
78
+ var options = typeof option === 'object' && option;
79
+
80
+ if (!data) $this.data('search', (data = new Search(this, options)));
81
+ if (typeof option === 'string') data[option]();
82
+ });
83
+ };
84
+
85
+ $.fn.search.defaults = {};
86
+
87
+ $.fn.search.Constructor = Search;
88
+
89
+
90
+ // SEARCH DATA-API
91
+
92
+ $(function () {
93
+ $('body').on('mousedown.search.data-api', '.search', function () {
94
+ var $this = $(this);
95
+ if ($this.data('search')) return;
96
+ $this.search($this.data());
97
+ });
98
+ });
99
+
100
+ }(window.jQuery);
@@ -0,0 +1,183 @@
1
+ /*
2
+ * Fuel UX Spinner
3
+ * https://github.com/ExactTarget/fuelux
4
+ *
5
+ * Copyright (c) 2012 ExactTarget
6
+ * Licensed under the MIT license.
7
+ */
8
+
9
+ !function ($) {
10
+
11
+
12
+ // SPINNER CONSTRUCTOR AND PROTOTYPE
13
+
14
+ var Spinner = function (element, options) {
15
+ this.$element = $(element);
16
+ this.options = $.extend({}, $.fn.spinner.defaults, options);
17
+ this.$input = this.$element.find('.spinner-input');
18
+ this.$element.on('keyup', this.$input, $.proxy(this.change, this));
19
+
20
+ if (this.options.hold) {
21
+ this.$element.on('mousedown', '.spinner-up', $.proxy(function() { this.startSpin(true); } , this));
22
+ this.$element.on('mouseup', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
23
+ this.$element.on('mouseout', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
24
+ this.$element.on('mousedown', '.spinner-down', $.proxy(function() {this.startSpin(false);} , this));
25
+ } else {
26
+ this.$element.on('click', '.spinner-up', $.proxy(function() { this.step(true); } , this));
27
+ this.$element.on('click', '.spinner-down', $.proxy(function() { this.step(false); }, this));
28
+ }
29
+
30
+ this.switches = {
31
+ count: 1,
32
+ enabled: true
33
+ };
34
+
35
+ if (this.options.speed === 'medium') {
36
+ this.switches.speed = 300;
37
+ } else if (this.options.speed === 'fast') {
38
+ this.switches.speed = 100;
39
+ } else {
40
+ this.switches.speed = 500;
41
+ }
42
+
43
+ this.render();
44
+
45
+ if (this.options.disabled) {
46
+ this.disable();
47
+ }
48
+ };
49
+
50
+ Spinner.prototype = {
51
+ constructor: Spinner,
52
+
53
+ render: function () {
54
+ this.$input.val(this.options.value);
55
+ this.$input.attr('maxlength',(this.options.max + '').split('').length);
56
+ },
57
+
58
+ change: function () {
59
+ var newVal = this.$input.val();
60
+
61
+ if(newVal/1){
62
+ this.options.value = newVal/1;
63
+ }else{
64
+ newVal = newVal.replace(/[^0-9]/g,'');
65
+ this.$input.val(newVal);
66
+ this.options.value = newVal/1;
67
+ }
68
+
69
+ this.$element.trigger('change');
70
+ },
71
+
72
+ stopSpin: function () {
73
+ clearTimeout(this.switches.timeout);
74
+ this.switches.count = 1;
75
+ this.$element.trigger('change');
76
+ },
77
+
78
+ startSpin: function (type) {
79
+
80
+ if (!this.options.disabled) {
81
+ var divisor = this.switches.count;
82
+
83
+ if (divisor === 1) {
84
+ this.step(type);
85
+ divisor = 1;
86
+ } else if (divisor < 3){
87
+ divisor = 1.5;
88
+ } else if (divisor < 8){
89
+ divisor = 2.5;
90
+ } else {
91
+ divisor = 4;
92
+ }
93
+
94
+ this.switches.timeout = setTimeout($.proxy(function() {this.iterator(type);} ,this),this.switches.speed/divisor);
95
+ this.switches.count++;
96
+ }
97
+ },
98
+
99
+ iterator: function (type) {
100
+ this.step(type);
101
+ this.startSpin(type);
102
+ },
103
+
104
+ step: function (dir) {
105
+ var curValue = this.options.value;
106
+ var limValue = dir ? this.options.max : this.options.min;
107
+
108
+ if ((dir ? curValue < limValue : curValue > limValue)) {
109
+ var newVal = curValue + (dir ? 1 : -1) * this.options.step;
110
+
111
+ if (dir ? newVal > limValue : newVal < limValue) {
112
+ this.value(limValue);
113
+ } else {
114
+ this.value(newVal);
115
+ }
116
+ }
117
+ },
118
+
119
+ value: function (value) {
120
+ if (value) {
121
+ this.options.value = value;
122
+ this.$input.val(value);
123
+ return this;
124
+ } else {
125
+ return this.options.value;
126
+ }
127
+ },
128
+
129
+ disable: function () {
130
+ this.options.disabled = true;
131
+ this.$input.attr('disabled','');
132
+ this.$element.find('button').addClass('disabled');
133
+ },
134
+
135
+ enable: function () {
136
+ this.options.disabled = false;
137
+ this.$input.removeAttr("disabled");
138
+ this.$element.find('button').removeClass('disabled');
139
+ }
140
+ };
141
+
142
+
143
+ // SPINNER PLUGIN DEFINITION
144
+
145
+ $.fn.spinner = function (option,value) {
146
+ var methodReturn;
147
+
148
+ var $set = this.each(function () {
149
+ var $this = $(this);
150
+ var data = $this.data('spinner');
151
+ var options = typeof option === 'object' && option;
152
+
153
+ if (!data) $this.data('spinner', (data = new Spinner(this, options)));
154
+ if (typeof option === 'string') methodReturn = data[option](value);
155
+ });
156
+
157
+ return (methodReturn === undefined) ? $set : methodReturn;
158
+ };
159
+
160
+ $.fn.spinner.defaults = {
161
+ value: 1,
162
+ min: 1,
163
+ max: 999,
164
+ step: 1,
165
+ hold: true,
166
+ speed: 'medium',
167
+ disabled: false
168
+ };
169
+
170
+ $.fn.spinner.Constructor = Spinner;
171
+
172
+
173
+ // SPINNER DATA-API
174
+
175
+ $(function () {
176
+ $('body').on('mousedown.spinner.data-api', '.spinner', function (e) {
177
+ var $this = $(this);
178
+ if ($this.data('.spinner')) return;
179
+ $this.spinner($this.data());
180
+ });
181
+ });
182
+
183
+ }(window.jQuery);
@@ -0,0 +1,5 @@
1
+ // Fuel UX controls
2
+ @import "fuelux/combobox.less";
3
+ @import "fuelux/datagrid.less";
4
+ @import "fuelux/pillbox.less";
5
+ @import "fuelux/spinner.less";
@@ -0,0 +1,5 @@
1
+ .combobox {
2
+ a {
3
+ font-size: @baseFontSize;
4
+ }
5
+ }
@@ -0,0 +1,98 @@
1
+ @tableBackgroundAccentDark: darken(@tableBackgroundAccent, 8%);
2
+
3
+ .datagrid {
4
+
5
+ thead {
6
+
7
+ background-color: @tableBackgroundAccent;
8
+
9
+ .datagrid-header-title {
10
+ float: left;
11
+ line-height: 28px;
12
+ font-weight: normal;
13
+ font-size: 14px;
14
+ margin-right: 10px;
15
+ }
16
+
17
+ .datagrid-header-left {
18
+ float: left;
19
+ }
20
+
21
+ .datagrid-header-right {
22
+ float: right;
23
+ }
24
+
25
+ .sorted {
26
+ .gradientBar(@tableBackgroundAccent, @tableBackgroundAccentDark, @textColor, 'none');
27
+
28
+ i {
29
+ float: right;
30
+ margin-top: 2px;
31
+ }
32
+ }
33
+
34
+ .sortable {
35
+ cursor: pointer;
36
+
37
+ &:hover {
38
+ .gradientBar(@tableBackgroundAccent, @tableBackgroundAccentDark, @textColor, 'none');
39
+ }
40
+ }
41
+
42
+ }
43
+
44
+ tfoot {
45
+
46
+ background-color: @tableBackgroundAccent;
47
+
48
+ .datagrid-footer-left {
49
+
50
+ float: left;
51
+
52
+ .grid-controls {
53
+ margin-top: 7px;
54
+
55
+ select {
56
+ margin: 0 5px 1px;
57
+ width: 60px;
58
+ }
59
+
60
+ span {
61
+ font-weight: normal;
62
+ }
63
+ }
64
+
65
+ }
66
+
67
+ .datagrid-footer-right {
68
+
69
+ float: right;
70
+
71
+ .grid-pager {
72
+ > span {
73
+ font-weight: normal;
74
+ position: relative;
75
+ top: 8px;
76
+ }
77
+
78
+ .dropdown-menu {
79
+ min-width: 50px;
80
+ }
81
+
82
+ .combobox {
83
+ display: inline-block;
84
+ position: relative;
85
+ top: -2px;
86
+ }
87
+
88
+ > button {
89
+ position: relative;
90
+ top: 7px;
91
+ }
92
+ }
93
+
94
+ }
95
+
96
+ }
97
+
98
+ }