romo 0.16.1 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA512:
3
- data.tar.gz: 3007613cca8321eaf0359e5cf1e069b9486db5d134894fd286861cb40e0c58691f505f6ff62f65a0b2fd859482c846a52f7bb202c4782f4d1f6e0dc97abb82fe
4
- metadata.gz: c94483d359861e906fb0db0c8098cf6c0e5d8eb6316d9e8311f14ccb6027c1ddae8d93a87276f3c46ec6cbcfe165f0e4619c905c00a1beb94cd917804564d7b1
5
2
  SHA1:
6
- data.tar.gz: b3ec6fe84fa2aee5e7150e92db03ca4a2c5b16e5
7
- metadata.gz: 5397e3bccba301033313c4f9adac816dfc8c2b16
3
+ metadata.gz: a9a6e3ce2613489f0aa2630a85e7846cf427c8a6
4
+ data.tar.gz: d2f6680786dea0ab3f5fbe8c595951d43a35fb22
5
+ SHA512:
6
+ metadata.gz: 19f2c44434b4f3a64334447a98a6bf9821ea7976bdcbd2d74a478d16d7d00ccdc1bedfed8f241a0a27caeba5e8008c4698029f6b535778ee07f521073bcaea75
7
+ data.tar.gz: eb02c4703da3032e95b8f3e2ba8d5c36cd1c04b4b4f3eaa73f6859611591bc21861d211083b080d6c77bffc5597a75b5ca5c0ca122bb8e7910d40fc4f89e7f52
@@ -30,28 +30,28 @@
30
30
  border-style: solid;
31
31
  }
32
32
 
33
- .romo-tooltip-popup[data-romo-tooltip-position="top"] .romo-tooltip-arrow {
33
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="top"] .romo-tooltip-arrow {
34
34
  border-width: 6px 6px 0;
35
35
  bottom: -6px;
36
36
  left: 50%;
37
37
  margin-left: -6px;
38
38
  }
39
39
 
40
- .romo-tooltip-popup[data-romo-tooltip-position="right"] .romo-tooltip-arrow {
40
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="right"] .romo-tooltip-arrow {
41
41
  border-width: 6px 6px 6px 0;
42
42
  left: -6px;
43
43
  top: 50%;
44
44
  margin-top: -6px;
45
45
  }
46
46
 
47
- .romo-tooltip-popup[data-romo-tooltip-position="bottom"] .romo-tooltip-arrow {
47
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="bottom"] .romo-tooltip-arrow {
48
48
  border-width: 0 6px 6px;
49
49
  top: -6px;
50
50
  left: 50%;
51
51
  margin-left: -6px;
52
52
  }
53
53
 
54
- .romo-tooltip-popup[data-romo-tooltip-position="left"] .romo-tooltip-arrow {
54
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="left"] .romo-tooltip-arrow {
55
55
  border-width: 6px 0 6px 6px;
56
56
  right: -6px;
57
57
  top: 50%;
@@ -75,15 +75,15 @@
75
75
  color: $tooltipColor;
76
76
  }
77
77
 
78
- .romo-tooltip-popup[data-romo-tooltip-position="top"] .romo-tooltip-arrow {
78
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="top"] .romo-tooltip-arrow {
79
79
  border-top-color: $tooltipBgColor;
80
80
  }
81
- .romo-tooltip-popup[data-romo-tooltip-position="right"] .romo-tooltip-arrow {
81
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="right"] .romo-tooltip-arrow {
82
82
  border-right-color: $tooltipBgColor;
83
83
  }
84
- .romo-tooltip-popup[data-romo-tooltip-position="bottom"] .romo-tooltip-arrow {
84
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="bottom"] .romo-tooltip-arrow {
85
85
  border-bottom-color: $tooltipBgColor;
86
86
  }
87
- .romo-tooltip-popup[data-romo-tooltip-position="left"] .romo-tooltip-arrow {
87
+ .romo-tooltip-popup[data-romo-tooltip-arrow-position="left"] .romo-tooltip-arrow {
88
88
  border-left-color: $tooltipBgColor;
89
89
  }
@@ -149,18 +149,18 @@
149
149
  // style handling
150
150
 
151
151
  Romo.prototype.parseZIndex = function(elem) {
152
- // for the case where the browser doesn't suck and can read inherited z-index
153
- var val = parseInt(elem.css('z-index'));
154
- if (!isNaN(val)) {
152
+ // for the case where z-index is set directly on the elem
153
+ var val = this.parseElemZIndex(elem);
154
+ if (val !== 0) {
155
155
  return val;
156
156
  }
157
157
 
158
- // for the case where the browser sucks and can't read inherited z-index - we'll do it for you!
158
+ // for the case where z-index is inherited from a parent elem
159
159
  var parentIndexes = $.map(elem.parents(), function(item) {
160
160
  return item; // converts the collection to an array
161
161
  }).reduce($.proxy(function(prev, curr) {
162
- var pval = parseInt($(curr).css('z-index'));
163
- if (!isNaN(pval)) {
162
+ var pval = this.parseElemZIndex($(curr));
163
+ if (pval !== 0) {
164
164
  prev.push(pval);
165
165
  }
166
166
  return prev;
@@ -169,6 +169,14 @@
169
169
  return parentIndexes[0];
170
170
  }
171
171
 
172
+ Romo.prototype.parseElemZIndex = function(elem) {
173
+ var val = parseInt(document.defaultView.getComputedStyle(elem[0], null).getPropertyValue("z-index"));
174
+ if (!isNaN(val)) {
175
+ return val;
176
+ }
177
+ return 0;
178
+ }
179
+
172
180
  // private
173
181
 
174
182
  Romo.prototype._addEventCallback = function(name, callback) {
@@ -18,7 +18,7 @@ var RomoDatepicker = function(element) {
18
18
  this.itemSelector = 'TD.romo-datepicker-day:not(.disabled)';
19
19
  this.calTable = $();
20
20
  this.date = undefined;
21
- this.today = new Date;
21
+ this.today = this._getTodaysDate();
22
22
  this.prevValue = undefined;
23
23
 
24
24
  this.doInit();
@@ -595,6 +595,15 @@ RomoDatepicker.prototype._currentYear = function() {
595
595
  return (new Date).getUTCFullYear();
596
596
  }
597
597
 
598
+ RomoDatepicker.prototype._getTodaysDate = function() {
599
+ var today = new Date();
600
+ var dd = today.getDate();
601
+ var mm = today.getMonth();
602
+ var yyyy = today.getFullYear();
603
+
604
+ return this._UTCDate(yyyy, mm, dd);
605
+ }
606
+
598
607
  RomoDatepicker.prototype._UTCDate = function(year, month, day) {
599
608
  return new Date(Date.UTC.apply(Date, [year, month, day]));
600
609
  }
@@ -5,13 +5,13 @@ $.fn.romoSelectDropdown = function(optionElemsParent) {
5
5
  }
6
6
 
7
7
  var RomoSelectDropdown = function(element, optionElemsParent) {
8
- this.elem = $(element);
8
+ this.elem = $(element);
9
9
  this.itemSelector = 'LI[data-romo-select-item="opt"]:not(.disabled)';
10
- this.prevValue = undefined;
10
+ this.prevValue = '';
11
11
 
12
- var optsParent = (optionElemsParent || this.elem.find('.romo-select-dropdown-options-parent'));
12
+ var optsParent = (optionElemsParent || this.elem.find('.romo-select-dropdown-options-parent'));
13
13
  this.optionElems = optsParent.children();
14
- this.optionList = this._buildOptionList(this.optionElems);
14
+ this.optionList = this._buildOptionList(this.optionElems);
15
15
 
16
16
  this.doInit();
17
17
  this.doBindDropdown();
@@ -88,7 +88,7 @@ RomoSelectDropdown.prototype.doBindDropdown = function() {
88
88
 
89
89
  RomoSelectDropdown.prototype.doSelectHighlightedItem = function() {
90
90
  var prevValue = this.prevValue;
91
- var newValue = this.romoDropdown.bodyElem.find('LI.romo-select-highlight').data('romo-select-option-value');
91
+ var newValue = this.romoDropdown.bodyElem.find('LI.romo-select-highlight').data('romo-select-option-value');
92
92
 
93
93
  this.romoDropdown.doPopupClose();
94
94
  this.elem.trigger('selectDropdown:itemSelected', [newValue, prevValue, this]);
@@ -232,13 +232,15 @@ RomoSelectDropdown.prototype._buildOptionList = function(optionElems, listClass)
232
232
  }
233
233
 
234
234
  RomoSelectDropdown.prototype._buildOptionListItem = function(optionElem) {
235
- var opt = $(optionElem);
236
- var item = $('<li data-romo-select-item="opt"></li>');
235
+ var opt = $(optionElem);
236
+ var item = $('<li data-romo-select-item="opt"></li>');
237
+ var value = opt.attr('value') || '';
237
238
 
238
- item.attr('data-romo-select-option-value', opt.attr('value'));
239
+ item.attr('data-romo-select-option-value', value);
239
240
  item.html(opt.text().trim() || '&nbsp;');
240
241
  if (opt.prop('selected')) {
241
242
  item.addClass('selected');
243
+ this.prevValue = value; // the last option marked selected is used
242
244
  }
243
245
  if (opt.attr('disabled') !== undefined) {
244
246
  item.addClass('disabled');
@@ -86,9 +86,17 @@ RomoTooltip.prototype.doInitBody = function() {
86
86
  'max-width': this.elem.data('romo-tooltip-max-width'),
87
87
  'width': this.elem.data('romo-tooltip-width'),
88
88
  'min-height': this.elem.data('romo-tooltip-min-height'),
89
- 'max-height': this.elem.data('romo-tooltip-max-height'),
90
89
  'height': this.elem.data('romo-tooltip-height')
91
90
  });
91
+
92
+ if (this.elem.data('romo-tooltip-max-height') === undefined) {
93
+ this.elem.attr('data-romo-tooltip-max-height', 'detect');
94
+ }
95
+ if (this.elem.data('romo-tooltip-max-height') !== 'detect') {
96
+ this.bodyElem.css({
97
+ 'max-height': this.elem.data('romo-tooltip-max-height')
98
+ });
99
+ }
92
100
  }
93
101
 
94
102
  RomoTooltip.prototype.doResetBody = function() {
@@ -262,7 +270,39 @@ RomoTooltip.prototype.doPlacePopupElem = function() {
262
270
  var pad = 6 + 1; // arrow size + spacing
263
271
  var offset = {};
264
272
 
265
- switch (this.popupPosition) {
273
+ var configHeight = this.elem.data('romo-tooltip-height') || this.elem.data('romo-tooltip-max-height');
274
+ var configPosition = this.popupPosition;
275
+
276
+ if (configHeight === 'detect' && (configPosition === 'top' || configPosition === 'bottom')) {
277
+ var popupHeight = this.popupElem.height();
278
+ var topAvailHeight = this._getPopupMaxAvailableHeight('top');
279
+ var bottomAvailHeight = this._getPopupMaxAvailableHeight('bottom');
280
+
281
+ if (popupHeight < topAvailHeight && popupHeight < bottomAvailHeight) {
282
+ // if it fits both ways, use the config position way
283
+ configHeight = this._getPopupMaxAvailableHeight(configPosition);
284
+ this.popupElem.attr('data-romo-tooltip-arrow-position', configPosition);
285
+ } else if (topAvailHeight > bottomAvailHeight) {
286
+ configPosition = 'top';
287
+ configHeight = topAvailHeight;
288
+ this.popupElem.attr('data-romo-tooltip-arrow-position', 'top');
289
+ } else {
290
+ configPosition = 'bottom';
291
+ configHeight = bottomAvailHeight;
292
+ this.popupElem.attr('data-romo-tooltip-arrow-position', 'bottom');
293
+ }
294
+
295
+ this.bodyElem.css({'max-height': configHeight.toString() + 'px'});
296
+ } else {
297
+ this.popupElem.attr('data-romo-tooltip-arrow-position', configPosition);
298
+ }
299
+
300
+
301
+ if(h > configHeight) {
302
+ h = configHeight;
303
+ }
304
+
305
+ switch (configPosition) {
266
306
  case 'top':
267
307
  $.extend(offset, { top: pos.top - h - pad, left: pos.left + pos.width / 2 - w / 2 });
268
308
  break;
@@ -287,6 +327,27 @@ RomoTooltip.prototype.doSetPopupZIndex = function(relativeElem) {
287
327
 
288
328
  // private
289
329
 
330
+ RomoTooltip.prototype._getPopupMaxAvailableHeight = function(position) {
331
+ var maxHeight = undefined;
332
+
333
+ switch (position) {
334
+ case 'top':
335
+ var elemTop = this.elem[0].getBoundingClientRect().top;
336
+ maxHeight = elemTop - this._getPopupMaxHeightDetectPad(position);
337
+ break;
338
+ case 'bottom':
339
+ var elemBottom = this.elem[0].getBoundingClientRect().bottom;
340
+ maxHeight = $(window).height() - elemBottom - this._getPopupMaxHeightDetectPad(position);
341
+ break;
342
+ }
343
+
344
+ return maxHeight;
345
+ }
346
+
347
+ RomoTooltip.prototype._getPopupMaxHeightDetectPad = function(position) {
348
+ return this.elem.data('romo-tooltip-max-height-detect-pad-'+position) || this.elem.data('romo-tooltip-max-height-detect-pad') || 10;
349
+ }
350
+
290
351
  RomoTooltip.prototype._setBodyHtml = function(content) {
291
352
  this.bodyElem.html(content || '');
292
353
  }
data/lib/romo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Romo
2
- VERSION = "0.16.1"
2
+ VERSION = "0.16.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: romo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2016-10-04 00:00:00 Z
13
+ date: 2016-10-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: assert