romo 0.10.0 → 0.11.0

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.
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'pry', "~> 0.9.0"
7
7
 
8
8
  gem 'rack'
9
9
  gem "deas", "~> 0.27"
10
- gem "dassets", '~> 0.9'
10
+ gem "dassets", '~> 0.11'
11
11
  gem "dassets-sass", "~> 0.3"
12
12
  gem "dassets-erb", "~> 0.1"
13
13
  gem "kramdown", "~> 1.4"
@@ -145,6 +145,8 @@
145
145
  @mixin text-border-base($i:"") { color: $baseBorderColor #{$i}; }
146
146
  @mixin text-border-alt($i:"") { color: $altBorderColor #{$i}; }
147
147
 
148
+ @mixin text-disabled($i:"") { color: $disabledColor #{$i}; }
149
+
148
150
  @mixin text-base($i:"") { color: $baseText #{$i}; }
149
151
  @mixin text-base-hover($i:"") { color: $baseTextHover #{$i}; }
150
152
  @mixin bg-base($i:"") { background-color: $baseBackground #{$i}; }
@@ -224,6 +224,7 @@ h3 { @include text1; }
224
224
 
225
225
  .romo-text-border-base { @include text-border-base(!important); }
226
226
  .romo-text-border-alt { @include text-border-alt(!important); }
227
+ .romo-text-disabled { @include text-disabled(!important); }
227
228
  .romo-text-base { @include text-base(!important); }
228
229
  .romo-text-alt { @include text-alt(!important); }
229
230
  .romo-text-muted { @include text-muted(!important); }
@@ -7,7 +7,7 @@ $.fn.romoDropdown = function() {
7
7
  var RomoDropdown = function(element) {
8
8
  this.elem = $(element);
9
9
  this.popupElem = $('<div class="romo-dropdown-popup"><div class="romo-dropdown-body"></div></div>');
10
- this.popupElem.appendTo('body');
10
+ this.popupElem.appendTo(this.elem.closest(this.elem.data('romo-dropdown-append-to-closest') || 'body'));
11
11
  this.doSetPopupZIndex(this.elem);
12
12
  this.bodyElem = this.popupElem.find('> .romo-dropdown-body');
13
13
  this.contentElem = $();
@@ -45,8 +45,8 @@ var RomoDropdown = function(element) {
45
45
  this.elem.on('invoke:loadError', $.proxy(function(e, xhr, invoke) {
46
46
  this.doLoadBodyError(xhr);
47
47
  }, this));
48
- this.elem.on('keyup', $.proxy(this.onElemKeyUp, this));
49
- this.popupElem.on('keyup', $.proxy(this.onElemKeyUp, this));
48
+
49
+ this.doBindElemKeyUp();
50
50
 
51
51
  this.doInit();
52
52
  this.doInitBody();
@@ -61,6 +61,16 @@ RomoDropdown.prototype.doInit = function() {
61
61
  RomoDropdown.prototype.doInitBody = function() {
62
62
  this.doResetBody();
63
63
 
64
+ this.popupElem.on('modal:popupOpen', $.proxy(function(e) {
65
+ this.doUnBindWindowBodyClick();
66
+ this.doUnBindWindowBodyKeyUp();
67
+ this.doUnBindElemKeyUp();
68
+ }, this));
69
+ this.popupElem.on('modal:popupClose', $.proxy(function(e) {
70
+ this.doBindWindowBodyClick();
71
+ this.doBindWindowBodyKeyUp();
72
+ this.doBindElemKeyUp();
73
+ }, this));
64
74
  this.contentElem = this.bodyElem.find('.romo-dropdown-content').last();
65
75
  if (this.contentElem.size() === 0) {
66
76
  this.contentElem = this.bodyElem;
@@ -180,10 +190,13 @@ RomoDropdown.prototype.doPopupOpen = function() {
180
190
  // event, then the toggle click will propagate which will call
181
191
  // this event and immediately close the popup.
182
192
  setTimeout($.proxy(function() {
183
- $('body').on('click', $.proxy(this.onWindowBodyClick, this));
184
- $('body').on('modal:mousedown', $.proxy(this.onWindowBodyClick, this));
193
+ this.doBindWindowBodyClick();
185
194
  }, this), 100);
186
- $('body').on('keyup', $.proxy(this.onWindowBodyKeyUp, this));
195
+
196
+ // bind "esc" keystroke to toggle close
197
+ this.doBindWindowBodyKeyUp();
198
+
199
+ // bind window resizes reposition dropdown
187
200
  $(window).on('resize', $.proxy(this.onResizeWindow, this));
188
201
 
189
202
  this.elem.trigger('dropdown:popupOpen', [this]);
@@ -205,9 +218,13 @@ RomoDropdown.prototype.onPopupClose = function(e) {
205
218
  RomoDropdown.prototype.doPopupClose = function() {
206
219
  this.popupElem.removeClass('romo-dropdown-open');
207
220
 
208
- $('body').off('click', $.proxy(this.onWindowBodyClick, this));
209
- $('body').off('modal:mousedown', $.proxy(this.onWindowBodyClick, this));
210
- $('body').off('keyup', $.proxy(this.onWindowBodyKeyUp, this));
221
+ // unbind any event to close the popup when clicking away from it
222
+ this.doUnBindWindowBodyClick();
223
+
224
+ // unbind "esc" keystroke to toggle close
225
+ this.doUnBindWindowBodyKeyUp();
226
+
227
+ // unbind window resizes reposition dropdown
211
228
  $(window).off('resize', $.proxy(this.onResizeWindow, this));
212
229
 
213
230
  // clear the content elem markup if configured to
@@ -218,6 +235,16 @@ RomoDropdown.prototype.doPopupClose = function() {
218
235
  this.elem.trigger('dropdown:popupClose', [this]);
219
236
  }
220
237
 
238
+ RomoDropdown.prototype.doBindElemKeyUp = function() {
239
+ this.elem.on('keyup', $.proxy(this.onElemKeyUp, this));
240
+ this.popupElem.on('keyup', $.proxy(this.onElemKeyUp, this));
241
+ }
242
+
243
+ RomoDropdown.prototype.doUnBindElemKeyUp = function() {
244
+ this.elem.off('keyup', $.proxy(this.onElemKeyUp, this));
245
+ this.popupElem.off('keyup', $.proxy(this.onElemKeyUp, this));
246
+ }
247
+
221
248
  RomoDropdown.prototype.onElemKeyUp = function(e) {
222
249
  if (this.elem.hasClass('disabled') === false) {
223
250
  if (this.popupElem.hasClass('romo-dropdown-open')) {
@@ -234,6 +261,16 @@ RomoDropdown.prototype.onElemKeyUp = function(e) {
234
261
  return true;
235
262
  }
236
263
 
264
+ RomoDropdown.prototype.doBindWindowBodyClick = function() {
265
+ $('body').on('click', $.proxy(this.onWindowBodyClick, this));
266
+ $('body').on('modal:mousemove', $.proxy(this.onWindowBodyClick, this));
267
+ }
268
+
269
+ RomoDropdown.prototype.doUnBindWindowBodyClick = function() {
270
+ $('body').off('click', $.proxy(this.onWindowBodyClick, this));
271
+ $('body').off('modal:mousemove', $.proxy(this.onWindowBodyClick, this));
272
+ }
273
+
237
274
  RomoDropdown.prototype.onWindowBodyClick = function(e) {
238
275
  // if not clicked on the popup elem or the elem
239
276
  var target = $(e.target);
@@ -245,6 +282,14 @@ RomoDropdown.prototype.onWindowBodyClick = function(e) {
245
282
  return true;
246
283
  }
247
284
 
285
+ RomoDropdown.prototype.doBindWindowBodyKeyUp = function() {
286
+ $('body').on('keyup', $.proxy(this.onWindowBodyKeyUp, this));
287
+ }
288
+
289
+ RomoDropdown.prototype.doUnBindWindowBodyKeyUp = function() {
290
+ $('body').off('keyup', $.proxy(this.onWindowBodyKeyUp, this));
291
+ }
292
+
248
293
  RomoDropdown.prototype.onWindowBodyKeyUp = function(e) {
249
294
  if (e.keyCode === 27 /* Esc */) {
250
295
  this.doPopupClose();
@@ -31,12 +31,6 @@ var RomoIndicator = function(element) {
31
31
  this.doInit();
32
32
  this.spinner = new Spinner(this.spinnerOpts);
33
33
 
34
- this.elemHtml = this.elem.html();
35
- this.elem.css({
36
- 'position': 'relative',
37
- 'width': this.elem.css('width'),
38
- 'height': this.elem.css('height'),
39
- });
40
34
  this.elem.on('indicator:triggerStart', $.proxy(this.onStart, this));
41
35
  this.elem.on('indicator:triggerStop', $.proxy(this.onStop, this));
42
36
 
@@ -70,6 +64,13 @@ RomoIndicator.prototype.onStop = function(e) {
70
64
  }
71
65
 
72
66
  RomoIndicator.prototype.doStart = function() {
67
+ this.elemHtml = this.elem.html();
68
+ this.elemStyle = this.elem.attr('style');
69
+ this.elem.css({
70
+ 'position': 'relative',
71
+ 'width': this.elem.css('width'),
72
+ 'height': this.elem.css('height'),
73
+ });
73
74
  this.elem.html('');
74
75
  this.spinner.spin(this.elem[0]);
75
76
  this.elem.trigger('indicator:start', [this]);
@@ -77,7 +78,17 @@ RomoIndicator.prototype.doStart = function() {
77
78
 
78
79
  RomoIndicator.prototype.doStop = function() {
79
80
  this.spinner.stop();
80
- this.elem.html(this.elemHtml);
81
+ if (this.elemHtml !== undefined) {
82
+ this.elem.html(this.elemHtml);
83
+ }
84
+ this.elem.css({
85
+ 'position': '',
86
+ 'width': '',
87
+ 'height': '',
88
+ });
89
+ if (this.elemStyle !== undefined) {
90
+ this.elem.attr('style', this.elemStyle);
91
+ }
81
92
  this.elem.trigger('indicator:stop', [this]);
82
93
  }
83
94
 
@@ -7,7 +7,7 @@ $.fn.romoModal = function() {
7
7
  var RomoModal = function(element) {
8
8
  this.elem = $(element);
9
9
  this.popupElem = $('<div class="romo-modal-popup"><div class="romo-modal-body"></div></div>');
10
- this.popupElem.appendTo('body');
10
+ this.popupElem.appendTo(this.elem.closest(this.elem.data('romo-modal-append-to-closest') || 'body'));
11
11
  this.bodyElem = this.popupElem.find('> .romo-modal-body');
12
12
  this.contentElem = $();
13
13
  this.closeElem = $();
@@ -33,6 +33,8 @@ var RomoModal = function(element) {
33
33
  this.doLoadBodyError(xhr);
34
34
  }, this));
35
35
 
36
+ this.doBindElemKeyUp();
37
+
36
38
  this.doInit();
37
39
  this.doInitBody();
38
40
 
@@ -158,11 +160,11 @@ RomoModal.prototype.doPopupOpen = function() {
158
160
  // event, then the toggle click will propagate which will call
159
161
  // this event and immediately close the popup.
160
162
  setTimeout($.proxy(function() {
161
- $('body').on('click', $.proxy(this.onWindowBodyClick, this));
163
+ this.doBindWindowBodyClick();
162
164
  }, this), 100);
163
165
 
164
166
  // bind "esc" keystroke to toggle close
165
- $('body').on('keyup', $.proxy(this.onWindowBodyKeyUp, this));
167
+ this.doBindWindowBodyKeyUp();
166
168
 
167
169
  // bind window resizes reposition modal
168
170
  $(window).on('resize', $.proxy(this.onResizeWindow, this));
@@ -187,10 +189,10 @@ RomoModal.prototype.doPopupClose = function() {
187
189
  this.popupElem.removeClass('romo-modal-open');
188
190
 
189
191
  // unbind any event to close the popup when clicking away from it
190
- $('body').off('click', $.proxy(this.onWindowBodyClick, this));
192
+ this.doUnBindWindowBodyClick();
191
193
 
192
194
  // unbind "esc" keystroke to toggle close
193
- $('body').off('keyup', $.proxy(this.onWindowBodyKeyUp, this));
195
+ this.doUnBindWindowBodyKeyUp();
194
196
 
195
197
  // unbind window resizes reposition modal
196
198
  $(window).off('resize', $.proxy(this.onResizeWindow, this));
@@ -204,7 +206,6 @@ RomoModal.prototype.doPopupClose = function() {
204
206
  }
205
207
 
206
208
  RomoModal.prototype.onMouseDown = function(e) {
207
- $('body').trigger('modal:mousedown');
208
209
  e.preventDefault();
209
210
  e.stopPropagation();
210
211
  this.doDragStart(e);
@@ -227,6 +228,7 @@ RomoModal.prototype.doDragStart = function(e) {
227
228
  }
228
229
 
229
230
  RomoModal.prototype.onMouseMove = function(e) {
231
+ $('body').trigger('modal:mousemove');
230
232
  e.preventDefault();
231
233
  e.stopPropagation();
232
234
  this.doDragMove(e.clientX, e.clientY);
@@ -262,6 +264,40 @@ RomoModal.prototype.doDragStop = function(e) {
262
264
  this.elem.trigger("modal:dragStop", [this]);
263
265
  }
264
266
 
267
+ RomoModal.prototype.doBindElemKeyUp = function() {
268
+ this.elem.on('keyup', $.proxy(this.onElemKeyUp, this));
269
+ this.popupElem.on('keyup', $.proxy(this.onElemKeyUp, this));
270
+ }
271
+
272
+ RomoModal.prototype.doUnBindElemKeyUp = function() {
273
+ this.elem.off('keyup', $.proxy(this.onElemKeyUp, this));
274
+ this.popupElem.off('keyup', $.proxy(this.onElemKeyUp, this));
275
+ }
276
+
277
+ RomoModal.prototype.onElemKeyUp = function(e) {
278
+ if (this.elem.hasClass('disabled') === false) {
279
+ if (this.popupElem.hasClass('romo-modal-open')) {
280
+ if(e.keyCode === 27 /* Esc */ ) {
281
+ this.doPopupClose();
282
+ return false;
283
+ } else {
284
+ return true;
285
+ }
286
+ } else {
287
+ return true;
288
+ }
289
+ }
290
+ return true;
291
+ }
292
+
293
+ RomoModal.prototype.doBindWindowBodyClick = function() {
294
+ $('body').on('click', $.proxy(this.onWindowBodyClick, this));
295
+ }
296
+
297
+ RomoModal.prototype.doUnBindWindowBodyClick = function() {
298
+ $('body').off('click', $.proxy(this.onWindowBodyClick, this));
299
+ }
300
+
265
301
  RomoModal.prototype.onWindowBodyClick = function(e) {
266
302
  // if not clicked on the popup elem
267
303
  if (e !== undefined && $(e.target).parents('.romo-modal-popup').size() === 0) {
@@ -270,6 +306,14 @@ RomoModal.prototype.onWindowBodyClick = function(e) {
270
306
  return true;
271
307
  }
272
308
 
309
+ RomoModal.prototype.doBindWindowBodyKeyUp = function() {
310
+ $('body').on('keyup', $.proxy(this.onWindowBodyKeyUp, this));
311
+ }
312
+
313
+ RomoModal.prototype.doUnBindWindowBodyKeyUp = function() {
314
+ $('body').off('keyup', $.proxy(this.onWindowBodyKeyUp, this));
315
+ }
316
+
273
317
  RomoModal.prototype.onWindowBodyKeyUp = function(e) {
274
318
  if (e.keyCode === 27 /* Esc */) {
275
319
  this.doPopupClose();
@@ -7,7 +7,7 @@ $.fn.romoTooltip = function() {
7
7
  var RomoTooltip = function(element) {
8
8
  this.elem = $(element);
9
9
  this.popupElem = $('<div class="romo-tooltip-popup"><div class="romo-tooltip-arrow"></div><div class="romo-tooltip-body"></div></div>');
10
- this.popupElem.appendTo('body');
10
+ this.popupElem.appendTo(this.elem.closest(this.elem.data('romo-tooltip-append-to-closest') || 'body'));
11
11
  this.doSetPopupZIndex(this.elem);
12
12
  this.arrowElem = this.popupElem.find('> .romo-tooltip-arrow');
13
13
  this.bodyElem = this.popupElem.find('> .romo-tooltip-body');
@@ -42,18 +42,17 @@ var RomoTooltip = function(element) {
42
42
  if (this.elem.data('romo-tooltip-style-class') !== undefined) {
43
43
  this.bodyElem.addClass(this.elem.data('romo-tooltip-style-class'));
44
44
  }
45
- this.contentData = this.elem.data('romo-tooltip-content');
46
- this.bodyElem.html(this.contentData || '');
47
45
 
48
46
  this.elem.on('mouseenter', $.proxy(this.onToggleEnter, this));
49
47
  this.elem.on('mouseleave', $.proxy(this.onToggleLeave, this));
50
48
  this.elem.on('tooltip:triggerPopupOpen', $.proxy(this.onPopupOpen, this));
51
49
  this.elem.on('tooltip:triggerPopupClose', $.proxy(this.onPopupClose, this));
50
+ this.elem.on('tooltip:triggerSetContent', $.proxy(this.onSetContent, this));
52
51
  $(window).on('resize', $.proxy(this.onResizeWindow, this))
53
52
 
54
53
  this.doInit();
55
54
  this.doInitBody();
56
- if (this.contentData === undefined) {
55
+ if (this.elem.data('romo-tooltip-content') === undefined) {
57
56
  this.doBindInvoke();
58
57
  }
59
58
 
@@ -104,7 +103,7 @@ RomoTooltip.prototype.doBindInvoke = function() {
104
103
  }
105
104
 
106
105
  RomoTooltip.prototype.doLoadBodyStart = function() {
107
- this.bodyElem.html('');
106
+ this._setBodyHtml('');
108
107
  this.doInitBody();
109
108
  this.doPlacePopupElem();
110
109
  this.elem.trigger('tooltip:loadBodyStart', [this]);
@@ -172,12 +171,14 @@ RomoTooltip.prototype.onPopupOpen = function(e) {
172
171
  RomoTooltip.prototype.doPopupOpen = function() {
173
172
  if (this.romoInvoke !== undefined) {
174
173
  this.romoInvoke.doInvoke();
174
+ } else {
175
+ this._setBodyHtml(this.elem.data('romo-tooltip-content'));
175
176
  }
176
177
  this.popupElem.addClass('romo-tooltip-open');
177
178
  this.doPlacePopupElem();
178
179
 
179
180
  if (this.elem.parents('.romo-modal-popup').size() !== 0) {
180
- $('body').on('modal:mousedown', $.proxy(this.onModalPopupChange, this));
181
+ $('body').on('modal:mousemove', $.proxy(this.onModalPopupChange, this));
181
182
  $('body').on('modal:popupclose', $.proxy(this.onModalPopupChange, this));
182
183
  }
183
184
  $(window).on('resize', $.proxy(this.onResizeWindow, this));
@@ -199,7 +200,7 @@ RomoTooltip.prototype.doPopupClose = function() {
199
200
  this.popupElem.removeClass('romo-tooltip-open');
200
201
 
201
202
  if (this.elem.parents('.romo-modal-popup').size() !== 0) {
202
- $('body').off('modal:mousedown', $.proxy(this.onModalPopupChange, this));
203
+ $('body').off('modal:mousemove', $.proxy(this.onModalPopupChange, this));
203
204
  $('body').off('modal:popupclose', $.proxy(this.onModalPopupChange, this));
204
205
  }
205
206
  $(window).off('resize', $.proxy(this.onResizeWindow, this));
@@ -214,6 +215,19 @@ RomoTooltip.prototype.onModalPopupChange = function(e) {
214
215
  return true;
215
216
  }
216
217
 
218
+ RomoTooltip.prototype.onSetContent = function(e, value) {
219
+ if (e !== undefined) {
220
+ e.preventDefault();
221
+ }
222
+ this.doSetContent(value);
223
+ }
224
+
225
+ RomoTooltip.prototype.doSetContent = function(value) {
226
+ this.elem.data('romo-tooltip-content', value);
227
+ this._setBodyHtml(this.elem.data('romo-tooltip-content'));
228
+ this.doPlacePopupElem();
229
+ }
230
+
217
231
  RomoTooltip.prototype.onResizeWindow = function(e) {
218
232
  this.doPlacePopupElem();
219
233
  return true;
@@ -253,6 +267,12 @@ RomoTooltip.prototype.doSetPopupZIndex = function(relativeElem) {
253
267
  this.popupElem.css({'z-index': relativeZIndex + 1100}); // see z-index.css
254
268
  }
255
269
 
270
+ // private
271
+
272
+ RomoTooltip.prototype._setBodyHtml = function(content) {
273
+ this.bodyElem.html(content || '');
274
+ }
275
+
256
276
  Romo.onInitUI(function(e) {
257
277
  Romo.initUIElems(e, '[data-romo-tooltip-auto="true"]').romoTooltip();
258
278
  });
data/lib/romo/dassets.rb CHANGED
@@ -56,7 +56,7 @@ module Romo::Dassets
56
56
  'js/romo/modal_form.js',
57
57
  'js/romo/tooltip.js',
58
58
  'js/romo/indicator.js',
59
- 'js/romo/sortable.js',
59
+ 'js/romo/sortable.js'
60
60
  ]
61
61
 
62
62
  end
data/lib/romo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Romo
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
data/romo.gemspec CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
21
  gem.require_paths = ["lib"]
22
22
 
23
- gem.add_development_dependency("assert", ["~> 2.12"])
23
+ gem.add_development_dependency("assert", ["~> 2.15"])
24
24
 
25
25
  end
@@ -58,7 +58,7 @@ module Romo::Dassets
58
58
  'js/romo/modal_form.js',
59
59
  'js/romo/tooltip.js',
60
60
  'js/romo/indicator.js',
61
- 'js/romo/sortable.js',
61
+ 'js/romo/sortable.js'
62
62
  ]
63
63
  assert_equal exp_js_sources, Dassets.config.combinations['js/romo.js']
64
64
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: romo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 10
8
+ - 11
9
9
  - 0
10
- version: 0.10.0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2015-09-18 00:00:00 Z
19
+ date: 2015-10-15 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -24,11 +24,11 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 27
27
+ hash: 29
28
28
  segments:
29
29
  - 2
30
- - 12
31
- version: "2.12"
30
+ - 15
31
+ version: "2.15"
32
32
  type: :development
33
33
  name: assert
34
34
  version_requirements: *id001