metro-ui-rails 0.1.6 → 0.15.8.3

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.
@@ -2,6 +2,7 @@
2
2
  //= require metro-ui/buttonset
3
3
  //= require metro-ui/carousel
4
4
  //= require metro-ui/dropdown
5
+ //= require metro-ui/input-control
5
6
  //= require metro-ui/pagecontrol
6
7
  //= require metro-ui/rating
7
8
  //= require metro-ui/slider
@@ -0,0 +1,103 @@
1
+ /**
2
+ * jQuery plugin for input elements for Metro UI CSS framework
3
+ */
4
+ (function($) {
5
+
6
+ $.Input = function(element, options) {
7
+
8
+ var defaults = {
9
+ };
10
+
11
+ var plugin = this;
12
+ plugin.settings = {};
13
+ var $element = $(element);
14
+
15
+ plugin.init = function() {
16
+ plugin.settings = $.extend({}, defaults, options);
17
+
18
+ if ($element.hasClass('text')) {
19
+ initTextInput();
20
+ } else if ($element.hasClass('password')) {
21
+ initPasswordInput();
22
+ }
23
+ };
24
+
25
+ /**
26
+ * initialize text input element behavior
27
+ */
28
+ var initTextInput = function () {
29
+ var helper,
30
+ $helper,
31
+ input;
32
+ helper = $element.children('.helper').get(0);
33
+
34
+ if (!helper) {
35
+ return;
36
+ }
37
+
38
+ $helper = $(helper);
39
+
40
+ // clear text when clock on helper
41
+ $helper.on('click', function () {
42
+ input = $element.children('input');
43
+ input.attr('value', '');
44
+ input.focus();
45
+ });
46
+ };
47
+
48
+ /**
49
+ * initialize password input element behavior
50
+ */
51
+ var initPasswordInput = function () {
52
+ var helper,
53
+ $helper,
54
+ password,
55
+ text;
56
+ helper = $element.children('.helper').get(0);
57
+ if (!helper) {
58
+ return;
59
+ }
60
+
61
+ text = $('<input type="text" />');
62
+ password = $element.children('input');
63
+ $helper = $(helper);
64
+
65
+ // insert text element and hode password element when push helper
66
+ $helper.on('mousedown', function () {
67
+ password.hide();
68
+ text.insertAfter(password);
69
+ text.attr('value', password.attr('value'));
70
+ });
71
+
72
+ // return password and remove text element
73
+ $helper.on('mouseup, mouseout', function () {
74
+ text.detach();
75
+ password.show();
76
+ password.focus();
77
+ });
78
+ };
79
+
80
+ plugin.init();
81
+
82
+ };
83
+
84
+ $.fn.Input = function(options) {
85
+ return this.each(function() {
86
+ if (undefined == $(this).data('Input')) {
87
+ var plugin = new $.Input(this, options);
88
+ $(this).data('Input', plugin);
89
+ }
90
+ });
91
+ }
92
+
93
+ })(jQuery);
94
+
95
+ $(function(){
96
+ var allInputs = $('.input-control');
97
+ allInputs.each(function (index, input) {
98
+ var params = {};
99
+ $input = $(input);
100
+
101
+ $input.Input(params);
102
+ });
103
+ });
@@ -1,46 +1,249 @@
1
- (function($){
2
- $.fn.Rating = function( options ){
1
+ /**
2
+ * jQuery plugin for rating component of MetroUiCss framework
3
+ * use attribute data-role="rating" or class="rating" to initialize rating plugin for some element
4
+ * or use $(ratingElement).rating({parameters})
5
+ *
6
+ * available parameters (attributes):
7
+ * data-role-stars="integer" stars count for this rating element (default 5)
8
+ * data-role-rating="integer" current average rating (default 0)
9
+ * data-role-vote="string" ('on' or 'off') (default 'on')
10
+ *
11
+ * to control rating you can use:
12
+ * $('ratingID').RatingValue(float) - set rating
13
+ * $('ratingID').RatingValue() - return rating
14
+ * $('ratingID').RatingPercents(0 < float < 100) - set rating by percents
15
+ * $('ratingID').RatingPercents() - return rating percents
16
+ * $('ratingID').RatingVote(true or 'on') - set vote=on rating mode
17
+ * $('ratingID').RatingVote(false or 'off') - set vote=off rating mode
18
+ */
19
+ (function($) {
20
+
21
+ $.Rating = function(element, options) {
22
+
3
23
  var defaults = {
24
+ // stars count
25
+ stars: 5,
26
+ // init value
27
+ rating: 0,
28
+ // voting mode
29
+ vote: 'on'
30
+
4
31
  };
5
32
 
6
- var $this = $(this)
7
- ;
33
+ var plugin = this;
8
34
 
9
- var init = function(el){
10
- var a = el.find("a");
11
- var r = Math.round(el.data("rating")) || 0;
35
+ plugin.settings = {};
12
36
 
13
- a.each(function(index){
14
- console.log(index);
15
- if (index < r) {
16
- $(this).addClass("rated");
17
- }
37
+ var $element = $(element),
38
+ starElements = [],
39
+ $starElements,
40
+ $innerElement, // for vote=off mode
41
+ currentRating;
18
42
 
19
- $(this).hover(
20
- function(){
21
- $(this).prevAll().andSelf().addClass("hover");
22
- $(this).nextAll().removeClass("hover");
23
- },
24
- function(){
25
- $(this).prevAll().andSelf().removeClass("hover");
26
- }
27
- )
28
- })
43
+ plugin.init = function() {
29
44
 
30
- }
45
+ plugin.settings = $.extend({}, defaults, options);
46
+
47
+ currentRating = plugin.settings.rating;
48
+
49
+ if (plugin.settings.vote === 'on') {
50
+ voteOnInit();
51
+ } else {
52
+ voteOffInit();
53
+ }
54
+
55
+ };
56
+
57
+ /**
58
+ * public methods to set and get rating (value, percent)
59
+ * use it like this: $('#ratingElementID').data('Rating').setRating(4)
60
+ */
61
+ plugin.setRating = function (rating) {
62
+ setRating(rating);
63
+ return rating;
64
+ };
65
+ plugin.setRatingPercents = function (ratingPercents) {
66
+ setRating((ratingPercents / 100) * plugin.settings.stars);
67
+ return ratingPercents;
68
+ };
69
+ plugin.getRating = function () {
70
+ return currentRating;
71
+ };
72
+ plugin.getRatingPercents = function () {
73
+ return currentRating / plugin.settings.stars * 100;
74
+ };
75
+ /**
76
+ * public method for change vote mode
77
+ */
78
+ plugin.voteOn = function () {
79
+ plugin.settings.vote = 'on';
80
+ voteOnInit();
81
+ };
82
+ plugin.voteOff = function () {
83
+ plugin.settings.vote = 'off';
84
+ voteOffInit();
85
+ };
86
+
87
+
88
+ /**
89
+ * init vote=off mode rating
90
+ */
91
+ var voteOffInit = function () {
92
+
93
+ var width,
94
+ settings = plugin.settings;
95
+
96
+ $element.empty();
97
+
98
+ // special class for vote=off mode
99
+ $element.addClass('static-rating');
100
+
101
+ width = ($element.hasClass('small') ? '14' : '27') * settings.stars;
102
+ $element.css('width', width);
103
+
104
+ $innerElement = $('<div class="rating-value"></div>');
105
+ $innerElement.appendTo($element);
106
+
107
+ setRating(currentRating);
108
+
109
+ };
110
+
111
+ /**
112
+ * init vote=on mode rating
113
+ */
114
+ var voteOnInit = function () {
115
+ var settings = plugin.settings,
116
+ a, i;
31
117
 
32
- return this.each(function(){
33
- if ( options ) {
34
- $.extend(defaults, options)
118
+ $element.empty();
119
+ $element.removeClass('static-rating');
120
+
121
+ // create stars (count starts from 1)
122
+ for (i = 1; i <= settings.stars; i++) {
123
+ a = starElements[i] = $('<a href="javascript:void(0)"></a>');
124
+ a.data('starIndex', i);
125
+ a.appendTo($element);
126
+ }
127
+
128
+ // event handlers for voting
129
+ $starElements = $element.find('a');
130
+
131
+ $starElements.on('mouseenter', function () {
132
+ var index = $(this).data('starIndex');
133
+ lightStars(0, true);
134
+ lightStars(index);
135
+ $element.trigger('hovered', [index]);
136
+ });
137
+ $starElements.on('mouseleave', function () {
138
+ lightStars(0);
139
+ lightStars(currentRating, true);
140
+ });
141
+ $starElements.on('click', function(){
142
+ var index = $(this).data('starIndex');
143
+ currentRating = index;
144
+ $element.trigger('rated', [index]);
145
+ });
146
+
147
+ setRating(currentRating);
148
+ };
149
+
150
+ /**
151
+ * make stars fired (from first to (starIndex - 1))
152
+ * or turn off stars if starIndex = 0
153
+ * @param starIndex
154
+ * @param rated if true - add 'rated' class, else 'hover'
155
+ */
156
+ var lightStars = function (starIndex, rated) {
157
+ var class_ = rated ? 'rated' : 'hover';
158
+ starIndex = Math.round(starIndex);
159
+ $starElements.removeClass(class_);
160
+ $starElements.filter(':lt(' + starIndex + ')').addClass(class_);
161
+ };
162
+
163
+ /**
164
+ * light stars and store rating
165
+ * @param rating
166
+ */
167
+ var setRating = function (rating) {
168
+ var settings = plugin.settings,
169
+ percents;
170
+ currentRating = rating;
171
+ if (settings.vote === 'on') {
172
+ lightStars(rating, true);
173
+ } else {
174
+ percents = rating / settings.stars * 100;
175
+ $innerElement.css('width', percents + '%');
35
176
  }
36
177
 
37
- init($this);
178
+ };
179
+
180
+ plugin.init();
181
+
182
+ };
183
+
184
+ $.fn.Rating = function(options) {
185
+
186
+ return this.each(function() {
187
+ if (undefined == $(this).data('Rating')) {
188
+ var plugin = new $.Rating(this, options);
189
+ $(this).data('Rating', plugin);
190
+ }
38
191
  });
39
- }
40
-
41
- $(function () {
42
- $('[data-role="rating"]').each(function () {
43
- $(this).Rating();
44
- })
45
- })
46
- })(window.jQuery);
192
+
193
+ };
194
+
195
+ /**
196
+ * get or set rating value to/from first element in set
197
+ */
198
+ $.fn.RatingValue = function(value) {
199
+ var ratingPlugin = $(this.get(0)).data('Rating');
200
+ if (typeof ratingPlugin !== 'undefined') {
201
+ if (typeof value !== 'undefined') {
202
+ return ratingPlugin.setRating(value);
203
+ } else {
204
+ return ratingPlugin.getRating();
205
+ }
206
+ }
207
+ };
208
+ /**
209
+ * get or set rating percents to/from first element in set
210
+ */
211
+ $.fn.RatingPercents = function(value) {
212
+ var ratingPlugin = $(this.get(0)).data('Rating');
213
+ if (typeof ratingPlugin !== 'undefined') {
214
+ if (typeof value !== 'undefined') {
215
+ return ratingPlugin.setRatingPercents(value);
216
+ } else {
217
+ return ratingPlugin.getRatingPercents();
218
+ }
219
+ }
220
+ };
221
+
222
+ /**
223
+ * changes rating mode
224
+ */
225
+ $.fn.RatingVote = function(vote) {
226
+ var ratingPlugin = $(this.get(0)).data('Rating');
227
+ if (typeof ratingPlugin !== 'undefined') {
228
+ if (vote === true || vote === 'on') {
229
+ ratingPlugin.voteOn();
230
+ } else if (vote === false || vote === 'off') {
231
+ ratingPlugin.voteOff();
232
+ }
233
+ }
234
+ };
235
+
236
+ })(jQuery);
237
+
238
+ $(function(){
239
+ var allratings = $('[data-role=rating], .rating');
240
+ allratings.each(function (index, rating) {
241
+ var params = {};
242
+ $rating = $(rating);
243
+ params.stars = $rating.data('paramStars');
244
+ params.rating = $rating.data('paramRating');
245
+ params.vote = $rating.data('paramVote');
246
+
247
+ $rating.Rating(params);
248
+ });
249
+ });
@@ -38,6 +38,7 @@
38
38
  height: 150px;
39
39
  }
40
40
 
41
+ /*
41
42
  .badge {
42
43
  .brick;
43
44
  width: @subunit*7;
@@ -47,6 +48,7 @@
47
48
  color: @darken;
48
49
  text-align: center;
49
50
  }
51
+ */
50
52
 
51
53
  .square {
52
54
  display: block;
@@ -56,6 +56,7 @@ button, .button {
56
56
  vertical-align: middle;
57
57
  cursor: pointer;
58
58
  padding: 4px 10px;
59
+ position: relative;
59
60
 
60
61
  &.standart {
61
62
  min-width: 90px;
@@ -63,8 +64,8 @@ button, .button {
63
64
  }
64
65
 
65
66
  &:active, &.default:active {
66
- background-color: #000 !important;
67
- color: #fff;
67
+ top: 1px;
68
+ left: 1px;
68
69
  }
69
70
 
70
71
  &:disabled, &.disabled {
@@ -82,10 +83,12 @@ button, .button {
82
83
  outline: 0;
83
84
  border: 1px #353535 dotted;
84
85
  }
86
+ }
85
87
 
86
- &:hover {
88
+ a.button {
89
+ &:hover, &:active {
90
+ color: inherit;
87
91
  }
88
-
89
92
  }
90
93
 
91
94
  button, .button, .tool-button {
@@ -95,28 +98,15 @@ button, .button, .tool-button {
95
98
  min-width: 24px;
96
99
  height: 26px;
97
100
  font-size: .8em;
98
-
99
- [class*=icon-] {
100
-
101
- }
102
101
  }
103
102
  &.big {
104
103
  min-height: 48px;
105
104
  height: 48px;
106
105
  font-size: 1.2em;
107
-
108
- [class*=icon-] {
109
- margin-top: 6px;
110
- zoom: 1;
111
- }
112
106
  }
113
107
  }
114
108
 
115
109
  .tool-button {
116
- [class*=icon-] {
117
- margin-top: 2px !important;
118
- }
119
-
120
110
  &.mini {
121
111
  min-width: 22px;
122
112
  width: 22px;
@@ -125,11 +115,6 @@ button, .button, .tool-button {
125
115
  &.big {
126
116
  min-width: 48px;
127
117
  width: 48px;
128
-
129
- [class*=icon-] {
130
- margin-top: 2px !important;
131
- margin-left: 15px !important;
132
- }
133
118
  }
134
119
  }
135
120
 
@@ -248,3 +233,193 @@ button, .button, .tool-button {
248
233
  }
249
234
  }
250
235
 
236
+ .shortcuts {
237
+ margin-bottom: 10px;
238
+ }
239
+
240
+ .shortcut {
241
+ width: 92px;
242
+ height: 92px;
243
+ display: inline-block;
244
+ //padding: 18px 0;
245
+ margin: 0 10px 10px 0;
246
+ vertical-align: top;
247
+ text-decoration: none;
248
+ background: #F3F3F3;
249
+ text-align: center;
250
+ cursor: pointer;
251
+ border: 0;
252
+ border-bottom: 2px transparent solid;
253
+ position: relative;
254
+
255
+ &:hover {
256
+ border-color: red;
257
+ //box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
258
+ }
259
+ &:active {
260
+ //box-shadow: none;
261
+ background: #F3F3F3;
262
+ top: 1px;
263
+ left: 1px;
264
+ }
265
+
266
+ &:last-child {
267
+
268
+ }
269
+
270
+ & > .icon {
271
+ margin-top: .25em;
272
+ margin-bottom: .25em;
273
+ font-size: 32px;
274
+ color: #888;
275
+ }
276
+ & > .label {
277
+ display: block;
278
+ font-weight: 400;
279
+ color: #666;
280
+ }
281
+
282
+ & > .badge {
283
+ position: absolute;
284
+ right: 0;
285
+ top: 0;
286
+ background-color: @blue;
287
+ padding: 5px;
288
+ margin: 0 !important;
289
+ text-align: center;
290
+ display: block;
291
+ font-size: 9pt;
292
+ color: #fff;
293
+ }
294
+ }
295
+
296
+ a.shortcut {
297
+ padding: 30px 0;
298
+ .label {
299
+ font-size: 9pt;
300
+ }
301
+ }
302
+
303
+ .pagination {
304
+ width: auto;
305
+ //padding: 10px 10px 5px;
306
+ margin-bottom: 10px;
307
+
308
+ & > ul {
309
+ .unstyled;
310
+ margin: 0;
311
+
312
+ li {
313
+ display: inline-block;
314
+ margin-right: 1px;
315
+ position: relative;
316
+
317
+ a {
318
+ .tool-button;
319
+ position: relative;
320
+ display: block;
321
+ float: left;
322
+ font-size: 10pt;
323
+ padding: 5px;
324
+ min-width: 32px;
325
+ height: 32px;
326
+ text-align: center;
327
+ //background-color: #fff;
328
+ vertical-align: middle;
329
+ cursor: pointer;
330
+ //border: 1px @blue solid;
331
+ margin-right: 1px;
332
+
333
+ &:hover {
334
+ background-color: @darken;
335
+ color: @white;
336
+ }
337
+
338
+ &:active {
339
+ top: 1px;
340
+ left: 1px;
341
+ //background-color: @blueDark;
342
+ }
343
+ }
344
+
345
+ &.first, &.prev, &.next, &.last {
346
+ a {
347
+ font-size: 20pt;
348
+
349
+ &:before {
350
+ position: absolute;
351
+ left: 50%;
352
+ top: 0;
353
+ margin-left: -7px;
354
+ content: "\25C4";
355
+ font-size: 1.5em;
356
+ }
357
+ }
358
+ }
359
+
360
+ &.first {
361
+ a {
362
+ &:before {
363
+ content: "\AB";
364
+ margin-left: -10px;
365
+ }
366
+ }
367
+ }
368
+ &.prev {
369
+ a {
370
+ &:before {
371
+ content: "\2039";
372
+ }
373
+ }
374
+ }
375
+ &.next {
376
+ a {
377
+ &:before {
378
+ content: "\203A";
379
+ }
380
+ }
381
+ }
382
+ &.last {
383
+ a {
384
+ &:before {
385
+ content: "\BB";
386
+ margin-left: -10px;
387
+ }
388
+ }
389
+ }
390
+
391
+ &.active {
392
+ a {
393
+ background-color: #008287 ;
394
+ color: @white;
395
+ }
396
+ }
397
+ &.disabled, &.spaces {
398
+ a {
399
+ background-color: darken(@white, 5%);
400
+ color: #1e1e1e;
401
+ cursor: not-allowed;
402
+
403
+ &:active {
404
+ top: 0;
405
+ left: 0;
406
+ }
407
+ }
408
+ }
409
+ &.disabled {
410
+ a {
411
+ //border-color: @lighten;
412
+ color: #1e1e1e;
413
+ }
414
+ }
415
+
416
+
417
+ &.spaces {
418
+ a {
419
+ background-color: @white;
420
+ cursor: default;
421
+ }
422
+ }
423
+ }
424
+ }
425
+ }