semantic-ui-sass 0.0.3 → 0.8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -1
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +8 -0
  5. data/README.md +26 -1
  6. data/app/assets/javascripts/semantic-ui/accordion.js +15 -17
  7. data/app/assets/javascripts/semantic-ui/behavior/api.js +18 -22
  8. data/app/assets/javascripts/semantic-ui/behavior/form.js +18 -24
  9. data/app/assets/javascripts/semantic-ui/behavior/state.js +8 -8
  10. data/app/assets/javascripts/semantic-ui/chatroom.js +18 -14
  11. data/app/assets/javascripts/semantic-ui/checkbox.js +26 -24
  12. data/app/assets/javascripts/semantic-ui/dimmer.js +74 -47
  13. data/app/assets/javascripts/semantic-ui/dropdown.js +226 -153
  14. data/app/assets/javascripts/semantic-ui/modal.js +73 -46
  15. data/app/assets/javascripts/semantic-ui/nag.js +13 -16
  16. data/app/assets/javascripts/semantic-ui/popup.js +352 -263
  17. data/app/assets/javascripts/semantic-ui/rating.js +29 -26
  18. data/app/assets/javascripts/semantic-ui/search.js +18 -24
  19. data/app/assets/javascripts/semantic-ui/shape.js +182 -173
  20. data/app/assets/javascripts/semantic-ui/sidebar.js +66 -43
  21. data/app/assets/javascripts/semantic-ui/tab.js +49 -31
  22. data/app/assets/javascripts/semantic-ui/transition.js +24 -24
  23. data/app/assets/javascripts/semantic-ui/video.js +26 -24
  24. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +1 -1
  25. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +85 -37
  26. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +6 -7
  27. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +76 -23
  28. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +415 -241
  29. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +1 -1
  30. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +26 -24
  31. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +8 -13
  32. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +87 -5
  33. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +7 -9
  34. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +1 -2
  35. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +17 -21
  36. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +4 -27
  37. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +44 -30
  38. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +68 -9
  39. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +26 -26
  40. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +1 -1
  41. data/app/assets/stylesheets/semantic-ui/modules/_reveal.scss +1 -1
  42. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +81 -7
  43. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +129 -28
  44. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +12 -10
  45. data/app/assets/stylesheets/semantic-ui/views/_item.scss +0 -10
  46. data/app/assets/stylesheets/semantic-ui/views/_list.scss +6 -6
  47. data/app/helpers/semantic_flash_helper.rb +22 -0
  48. data/app/helpers/semantic_icon_helper.rb +5 -0
  49. data/lib/semantic/ui/sass/version.rb +2 -2
  50. data/semantic-ui-sass.gemspec +3 -0
  51. data/spec/dummy/README.rdoc +28 -0
  52. data/spec/dummy/Rakefile +6 -0
  53. data/spec/dummy/app/assets/images/.keep +0 -0
  54. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  55. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  56. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  57. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  58. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  59. data/spec/dummy/app/mailers/.keep +0 -0
  60. data/spec/dummy/app/models/.keep +0 -0
  61. data/spec/dummy/app/models/concerns/.keep +0 -0
  62. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  63. data/spec/dummy/bin/bundle +3 -0
  64. data/spec/dummy/bin/rails +4 -0
  65. data/spec/dummy/bin/rake +4 -0
  66. data/spec/dummy/config.ru +4 -0
  67. data/spec/dummy/config/application.rb +28 -0
  68. data/spec/dummy/config/boot.rb +5 -0
  69. data/spec/dummy/config/database.yml +25 -0
  70. data/spec/dummy/config/environment.rb +5 -0
  71. data/spec/dummy/config/environments/development.rb +29 -0
  72. data/spec/dummy/config/environments/production.rb +80 -0
  73. data/spec/dummy/config/environments/test.rb +36 -0
  74. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  75. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  76. data/spec/dummy/config/initializers/inflections.rb +16 -0
  77. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  78. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  79. data/spec/dummy/config/initializers/session_store.rb +3 -0
  80. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  81. data/spec/dummy/config/locales/en.yml +23 -0
  82. data/spec/dummy/config/routes.rb +2 -0
  83. data/spec/dummy/lib/assets/.keep +0 -0
  84. data/spec/dummy/log/.keep +0 -0
  85. data/spec/dummy/public/404.html +58 -0
  86. data/spec/dummy/public/422.html +58 -0
  87. data/spec/dummy/public/500.html +57 -0
  88. data/spec/dummy/public/favicon.ico +0 -0
  89. data/spec/helpers/semantic_flash_helper_spec.rb +33 -0
  90. data/spec/helpers/semantic_icon_helper_spec.rb +20 -0
  91. data/spec/spec_helper.rb +8 -0
  92. metadata +132 -4
@@ -22,7 +22,7 @@ $.fn.dimmer = function(parameters) {
22
22
  methodInvoked = (typeof query == 'string'),
23
23
  queryArguments = [].slice.call(arguments, 1),
24
24
 
25
- invokedResponse
25
+ returnedValue
26
26
  ;
27
27
 
28
28
  $allModules
@@ -30,7 +30,7 @@ $.fn.dimmer = function(parameters) {
30
30
  var
31
31
  settings = ( $.isPlainObject(parameters) )
32
32
  ? $.extend(true, {}, $.fn.dimmer.settings, parameters)
33
- : $.fn.dimmer.settings,
33
+ : $.extend({}, $.fn.dimmer.settings),
34
34
 
35
35
  selector = settings.selector,
36
36
  namespace = settings.namespace,
@@ -111,6 +111,9 @@ $.fn.dimmer = function(parameters) {
111
111
 
112
112
  destroy: function() {
113
113
  module.verbose('Destroying previous module', $dimmer);
114
+ $module
115
+ .removeData(moduleNamespace)
116
+ ;
114
117
  $dimmable
115
118
  .off(eventNamespace)
116
119
  ;
@@ -147,13 +150,21 @@ $.fn.dimmer = function(parameters) {
147
150
 
148
151
  animate: {
149
152
  show: function(callback) {
150
- callback = callback || function(){};
153
+ callback = $.isFunction(callback)
154
+ ? callback
155
+ : function(){}
156
+ ;
151
157
  module.set.dimmed();
152
158
  if($.fn.transition !== undefined) {
153
159
  $dimmer
154
- .transition(settings.transition + ' in', module.get.duration(), function() {
155
- module.set.active();
156
- callback();
160
+ .transition({
161
+ animation : settings.transition + ' in',
162
+ queue : true,
163
+ duration : module.get.duration(),
164
+ complete : function() {
165
+ module.set.active();
166
+ callback();
167
+ },
157
168
  })
158
169
  ;
159
170
  }
@@ -175,14 +186,22 @@ $.fn.dimmer = function(parameters) {
175
186
  }
176
187
  },
177
188
  hide: function(callback) {
178
- callback = callback || function(){};
179
- module.remove.dimmed();
189
+ callback = $.isFunction(callback)
190
+ ? callback
191
+ : function(){}
192
+ ;
180
193
  if($.fn.transition !== undefined) {
181
194
  module.verbose('Hiding dimmer with css');
182
195
  $dimmer
183
- .transition(settings.transition + ' out', module.get.duration(), function() {
184
- module.remove.active();
185
- callback();
196
+ .transition({
197
+ animation : settings.transition + ' out',
198
+ duration : module.get.duration(),
199
+ queue : true,
200
+ complete : function() {
201
+ module.remove.dimmed();
202
+ module.remove.active();
203
+ callback();
204
+ }
186
205
  })
187
206
  ;
188
207
  }
@@ -192,6 +211,7 @@ $.fn.dimmer = function(parameters) {
192
211
  .stop()
193
212
  .fadeOut(module.get.duration(), function() {
194
213
  $dimmer.removeAttr('style');
214
+ module.remove.dimmed();
195
215
  module.remove.active();
196
216
  callback();
197
217
  })
@@ -224,27 +244,30 @@ $.fn.dimmer = function(parameters) {
224
244
  },
225
245
 
226
246
  is: {
227
- dimmer: function() {
228
- return $module.is(selector.dimmer);
229
- },
230
- dimmable: function() {
231
- return $module.is(selector.dimmable);
232
- },
233
247
  active: function() {
234
248
  return $dimmer.hasClass(className.active);
235
249
  },
236
250
  animating: function() {
237
251
  return ( $dimmer.is(':animated') || $dimmer.hasClass(className.transition) );
238
252
  },
239
- page: function () {
240
- return $dimmable.is('body');
253
+ dimmer: function() {
254
+ return $module.is(selector.dimmer);
241
255
  },
242
- enabled: function() {
243
- return !$dimmable.hasClass(className.disabled);
256
+ dimmable: function() {
257
+ return $module.is(selector.dimmable);
258
+ },
259
+ dimmed: function() {
260
+ return $dimmable.hasClass(className.dimmed);
244
261
  },
245
262
  disabled: function() {
246
263
  return $dimmable.hasClass(className.disabled);
247
264
  },
265
+ enabled: function() {
266
+ return !module.is.disabled();
267
+ },
268
+ page: function () {
269
+ return $dimmable.is('body');
270
+ },
248
271
  pageDimmer: function() {
249
272
  return $dimmer.hasClass(className.pageDimmer);
250
273
  }
@@ -258,6 +281,7 @@ $.fn.dimmer = function(parameters) {
258
281
 
259
282
  set: {
260
283
  active: function() {
284
+ module.set.dimmed();
261
285
  $dimmer
262
286
  .removeClass(className.transition)
263
287
  .addClass(className.active)
@@ -293,8 +317,12 @@ $.fn.dimmer = function(parameters) {
293
317
  },
294
318
 
295
319
  show: function(callback) {
320
+ callback = $.isFunction(callback)
321
+ ? callback
322
+ : function(){}
323
+ ;
296
324
  module.debug('Showing dimmer', $dimmer, settings);
297
- if( !(module.is.active() || module.is.animating() ) && module.is.enabled() ) {
325
+ if( !module.is.active() && module.is.enabled() ) {
298
326
  module.animate.show(callback);
299
327
  $.proxy(settings.onShow, element)();
300
328
  $.proxy(settings.onChange, element)();
@@ -305,7 +333,11 @@ $.fn.dimmer = function(parameters) {
305
333
  },
306
334
 
307
335
  hide: function(callback) {
308
- if( module.is.active() && !module.is.animating() ) {
336
+ callback = $.isFunction(callback)
337
+ ? callback
338
+ : function(){}
339
+ ;
340
+ if( module.is.active() || module.is.animating() ) {
309
341
  module.debug('Hiding dimmer', $dimmer);
310
342
  module.animate.hide(callback);
311
343
  $.proxy(settings.onHide, element)();
@@ -318,7 +350,7 @@ $.fn.dimmer = function(parameters) {
318
350
 
319
351
  toggle: function() {
320
352
  module.verbose('Toggling dimmer visibility', $dimmer);
321
- if( !module.is.active() ) {
353
+ if( !module.is.dimmed() ) {
322
354
  module.show();
323
355
  }
324
356
  else {
@@ -327,26 +359,22 @@ $.fn.dimmer = function(parameters) {
327
359
  },
328
360
 
329
361
  setting: function(name, value) {
330
- if(value !== undefined) {
331
- if( $.isPlainObject(name) ) {
332
- $.extend(true, settings, name);
333
- }
334
- else {
335
- settings[name] = value;
336
- }
362
+ if( $.isPlainObject(name) ) {
363
+ $.extend(true, settings, name);
364
+ }
365
+ else if(value !== undefined) {
366
+ settings[name] = value;
337
367
  }
338
368
  else {
339
369
  return settings[name];
340
370
  }
341
371
  },
342
372
  internal: function(name, value) {
343
- if(value !== undefined) {
344
- if( $.isPlainObject(name) ) {
345
- $.extend(true, module, name);
346
- }
347
- else {
348
- module[name] = value;
349
- }
373
+ if( $.isPlainObject(name) ) {
374
+ $.extend(true, module, name);
375
+ }
376
+ else if(value !== undefined) {
377
+ module[name] = value;
350
378
  }
351
379
  else {
352
380
  return module[name];
@@ -474,14 +502,14 @@ $.fn.dimmer = function(parameters) {
474
502
  else if(found !== undefined) {
475
503
  response = found;
476
504
  }
477
- if($.isArray(invokedResponse)) {
478
- invokedResponse.push(response);
505
+ if($.isArray(returnedValue)) {
506
+ returnedValue.push(response);
479
507
  }
480
- else if(typeof invokedResponse == 'string') {
481
- invokedResponse = [invokedResponse, response];
508
+ else if(returnedValue !== undefined) {
509
+ returnedValue = [returnedValue, response];
482
510
  }
483
511
  else if(response !== undefined) {
484
- invokedResponse = response;
512
+ returnedValue = response;
485
513
  }
486
514
  return found;
487
515
  }
@@ -504,8 +532,8 @@ $.fn.dimmer = function(parameters) {
504
532
  })
505
533
  ;
506
534
 
507
- return (invokedResponse !== undefined)
508
- ? invokedResponse
535
+ return (returnedValue !== undefined)
536
+ ? returnedValue
509
537
  : this
510
538
  ;
511
539
  };
@@ -515,12 +543,11 @@ $.fn.dimmer.settings = {
515
543
  name : 'Dimmer',
516
544
  namespace : 'dimmer',
517
545
 
518
- verbose : true,
519
546
  debug : true,
547
+ verbose : true,
520
548
  performance : true,
521
549
 
522
550
  transition : 'fade',
523
-
524
551
  on : false,
525
552
  closable : true,
526
553
  duration : {
@@ -11,19 +11,20 @@
11
11
  ;(function ( $, window, document, undefined ) {
12
12
 
13
13
  $.fn.dropdown = function(parameters) {
14
- var
15
- $allModules = $(this),
16
- $document = $(document),
14
+ var
15
+ $allModules = $(this),
16
+ $document = $(document),
17
17
 
18
- moduleSelector = $allModules.selector || '',
18
+ moduleSelector = $allModules.selector || '',
19
19
 
20
- time = new Date().getTime(),
21
- performance = [],
20
+ hasTouch = ('ontouchstart' in document.documentElement),
21
+ time = new Date().getTime(),
22
+ performance = [],
22
23
 
23
- query = arguments[0],
24
- methodInvoked = (typeof query == 'string'),
25
- queryArguments = [].slice.call(arguments, 1),
26
- invokedResponse
24
+ query = arguments[0],
25
+ methodInvoked = (typeof query == 'string'),
26
+ queryArguments = [].slice.call(arguments, 1),
27
+ returnedValue
27
28
  ;
28
29
 
29
30
  $allModules
@@ -31,28 +32,27 @@ $.fn.dropdown = function(parameters) {
31
32
  var
32
33
  settings = ( $.isPlainObject(parameters) )
33
34
  ? $.extend(true, {}, $.fn.dropdown.settings, parameters)
34
- : $.fn.dropdown.settings,
35
+ : $.extend({}, $.fn.dropdown.settings),
35
36
 
36
- className = settings.className,
37
- metadata = settings.metadata,
38
- namespace = settings.namespace,
39
- selector = settings.selector,
40
- error = settings.error,
37
+ className = settings.className,
38
+ metadata = settings.metadata,
39
+ namespace = settings.namespace,
40
+ selector = settings.selector,
41
+ error = settings.error,
41
42
 
42
- eventNamespace = '.' + namespace,
43
- dropdownNamespace = 'module-' + namespace,
44
- isTouchDevice = ('ontouchstart' in document.documentElement),
43
+ eventNamespace = '.' + namespace,
44
+ moduleNamespace = 'module-' + namespace,
45
45
 
46
- $module = $(this),
47
- $item = $module.find(selector.item),
48
- $text = $module.find(selector.text),
49
- $input = $module.find(selector.input),
46
+ $module = $(this),
47
+ $item = $module.find(selector.item),
48
+ $text = $module.find(selector.text),
49
+ $input = $module.find(selector.input),
50
50
 
51
- $menu = $module.children(selector.menu),
51
+ $menu = $module.children(selector.menu),
52
52
 
53
53
 
54
- element = this,
55
- instance = $module.data(dropdownNamespace),
54
+ element = this,
55
+ instance = $module.data(moduleNamespace),
56
56
  module
57
57
  ;
58
58
 
@@ -60,42 +60,22 @@ $.fn.dropdown = function(parameters) {
60
60
 
61
61
  initialize: function() {
62
62
  module.debug('Initializing dropdown', settings);
63
- if(isTouchDevice) {
64
- $module
65
- .on('touchstart' + eventNamespace, module.event.test.toggle)
66
- ;
67
- }
68
- else if(settings.on == 'click') {
69
- $module
70
- .on('click' + eventNamespace, module.event.test.toggle)
71
- ;
72
- }
73
- else if(settings.on == 'hover') {
74
- $module
75
- .on('mouseenter' + eventNamespace, module.delay.show)
76
- .on('mouseleave' + eventNamespace, module.delay.hide)
77
- ;
78
- }
79
- else {
80
- $module
81
- .on(settings.on + eventNamespace, module.toggle)
82
- ;
83
- }
84
- if(settings.action == 'updateForm') {
85
- module.set.selected();
63
+
64
+ module.set.selected();
65
+
66
+ if(hasTouch) {
67
+ module.bind.touchEvents();
86
68
  }
87
- $item
88
- .on('mouseenter' + eventNamespace, module.event.item.mouseenter)
89
- .on('mouseleave' + eventNamespace, module.event.item.mouseleave)
90
- .on(module.get.selectEvent() + eventNamespace, module.event.item.click)
91
- ;
69
+ // no use detecting mouse events because touch devices emulate them
70
+ module.bind.mouseEvents();
92
71
  module.instantiate();
93
72
  },
94
73
 
95
74
  instantiate: function() {
96
75
  module.verbose('Storing instance of dropdown', module);
76
+ instance = module;
97
77
  $module
98
- .data(dropdownNamespace, module)
78
+ .data(moduleNamespace, module)
99
79
  ;
100
80
  },
101
81
 
@@ -106,20 +86,93 @@ $.fn.dropdown = function(parameters) {
106
86
  ;
107
87
  $module
108
88
  .off(eventNamespace)
109
- .removeData(dropdownNamespace)
89
+ .removeData(moduleNamespace)
110
90
  ;
111
91
  },
112
92
 
113
- event: {
93
+ bind: {
94
+ touchEvents: function() {
95
+ module.debug('Touch device detected binding touch events');
96
+ $module
97
+ .on('touchstart' + eventNamespace, module.event.test.toggle)
98
+ ;
99
+ $item
100
+ .on('touchstart' + eventNamespace, module.event.item.mouseenter)
101
+ .on('touchstart' + eventNamespace, module.event.item.click)
102
+ ;
103
+ },
104
+ mouseEvents: function() {
105
+ module.verbose('Mouse detected binding mouse events');
106
+ if(settings.on == 'click') {
107
+ $module
108
+ .on('click' + eventNamespace, module.event.test.toggle)
109
+ ;
110
+ }
111
+ else if(settings.on == 'hover') {
112
+ $module
113
+ .on('mouseenter' + eventNamespace, module.delay.show)
114
+ .on('mouseleave' + eventNamespace, module.delay.hide)
115
+ ;
116
+ }
117
+ else {
118
+ $module
119
+ .on(settings.on + eventNamespace, module.toggle)
120
+ ;
121
+ }
122
+ $item
123
+ .on('mouseenter' + eventNamespace, module.event.item.mouseenter)
124
+ .on('mouseleave' + eventNamespace, module.event.item.mouseleave)
125
+ .on('click' + eventNamespace, module.event.item.click)
126
+ ;
127
+ },
128
+ intent: function() {
129
+ module.verbose('Binding hide intent event to document');
130
+ if(hasTouch) {
131
+ $document
132
+ .on('touchstart' + eventNamespace, module.event.test.touch)
133
+ .on('touchmove' + eventNamespace, module.event.test.touch)
134
+ ;
135
+ }
136
+ $document
137
+ .on('click' + eventNamespace, module.event.test.hide)
138
+ ;
139
+ }
140
+ },
141
+
142
+ unbind: {
143
+ intent: function() {
144
+ module.verbose('Removing hide intent event from document');
145
+ if(hasTouch) {
146
+ $document
147
+ .off('touchstart' + eventNamespace)
148
+ ;
149
+ }
150
+ $document
151
+ .off('click' + eventNamespace)
152
+ ;
153
+ }
154
+ },
114
155
 
156
+ event: {
115
157
  test: {
116
158
  toggle: function(event) {
117
- module.determine.intent(event, module.toggle);
118
- event.stopImmediatePropagation();
159
+ if( module.determine.intent(event, module.toggle) ) {
160
+ event.preventDefault();
161
+ }
162
+ },
163
+ touch: function(event) {
164
+ module.determine.intent(event, function() {
165
+ if(event.type == 'touchstart') {
166
+ module.timer = setTimeout(module.hide, settings.delay.touch);
167
+ }
168
+ else if(event.type == 'touchmove') {
169
+ clearTimeout(module.timer);
170
+ }
171
+ });
172
+ event.stopPropagation();
119
173
  },
120
174
  hide: function(event) {
121
175
  module.determine.intent(event, module.hide);
122
- event.stopPropagation();
123
176
  }
124
177
  },
125
178
 
@@ -137,6 +190,7 @@ $.fn.dropdown = function(parameters) {
137
190
  module.verbose('Showing sub-menu', $currentMenu);
138
191
  module.animate.show(false, $currentMenu);
139
192
  }, settings.delay.show * 2);
193
+ event.preventDefault();
140
194
  }
141
195
  },
142
196
 
@@ -160,13 +214,6 @@ $.fn.dropdown = function(parameters) {
160
214
  value = $choice.data(metadata.value) || text.toLowerCase()
161
215
  ;
162
216
  if( $choice.find(selector.menu).size() === 0 ) {
163
- module.verbose('Adding active state to selected item');
164
- $item
165
- .removeClass(className.active)
166
- ;
167
- $choice
168
- .addClass(className.active)
169
- ;
170
217
  module.determine.selectAction(text, value);
171
218
  $.proxy(settings.onChange, element)(value, text);
172
219
  }
@@ -183,26 +230,16 @@ $.fn.dropdown = function(parameters) {
183
230
  determine: {
184
231
  selectAction: function(text, value) {
185
232
  module.verbose('Determining action', settings.action);
186
- if(settings.action == 'auto') {
187
- if(module.is.selection()) {
188
- module.debug('Selection dropdown used updating form', text, value);
189
- module.updateForm(text, value);
190
- }
191
- else {
192
- module.debug('No action specified hiding dropdown', text, value);
193
- module.hide();
194
- }
195
- }
196
- else if( $.isFunction( module[settings.action] ) ) {
233
+ if( $.isFunction( module.action[settings.action] ) ) {
197
234
  module.verbose('Triggering preset action', settings.action, text, value);
198
- module[ settings.action ](text, value);
235
+ module.action[ settings.action ](text, value);
199
236
  }
200
237
  else if( $.isFunction(settings.action) ) {
201
238
  module.verbose('Triggering user action', settings.action, text, value);
202
239
  settings.action(text, value);
203
240
  }
204
241
  else {
205
- module.error(error.action);
242
+ module.error(error.action, settings.action);
206
243
  }
207
244
  },
208
245
  intent: function(event, callback) {
@@ -211,51 +248,68 @@ $.fn.dropdown = function(parameters) {
211
248
  if( $(event.target).closest($menu).size() === 0 ) {
212
249
  module.verbose('Triggering event', callback);
213
250
  callback();
251
+ return true;
214
252
  }
215
253
  else {
216
254
  module.verbose('Event occurred in dropdown, canceling callback');
255
+ return false;
217
256
  }
218
257
  }
219
258
  },
220
259
 
221
- bind: {
222
- intent: function() {
223
- module.verbose('Binding hide intent event to document');
224
- $document
225
- .on(module.get.selectEvent(), module.event.test.hide)
260
+ action: {
261
+
262
+ nothing: function() {},
263
+
264
+ hide: function() {
265
+ module.hide();
266
+ },
267
+
268
+ activate: function(text, value) {
269
+ value = (value !== undefined)
270
+ ? value
271
+ : text
226
272
  ;
227
- }
228
- },
273
+ module.set.selected(value);
274
+ module.set.value(value);
275
+ module.hide();
276
+ },
229
277
 
230
- unbind: {
231
- intent: function() {
232
- module.verbose('Removing hide intent event from document');
233
- $document
234
- .off(module.get.selectEvent())
278
+ /* Deprecated */
279
+ auto: function(text, value) {
280
+ value = (value !== undefined)
281
+ ? value
282
+ : text
235
283
  ;
236
- }
237
- },
284
+ module.set.selected(value);
285
+ module.set.value(value);
286
+ module.hide();
287
+ },
238
288
 
239
- nothing: function() {},
289
+ /* Deprecated */
290
+ changeText: function(text, value) {
291
+ value = (value !== undefined)
292
+ ? value
293
+ : text
294
+ ;
295
+ module.set.selected(value);
296
+ module.hide();
297
+ },
240
298
 
241
- changeText: function(text, value) {
242
- module.set.text(text);
243
- module.hide();
244
- },
299
+ /* Deprecated */
300
+ updateForm: function(text, value) {
301
+ value = (value !== undefined)
302
+ ? value
303
+ : text
304
+ ;
305
+ module.set.selected(value);
306
+ module.set.value(value);
307
+ module.hide();
308
+ }
245
309
 
246
- updateForm: function(text, value) {
247
- module.set.text(text);
248
- module.set.value(value);
249
- module.hide();
250
310
  },
251
311
 
252
312
  get: {
253
- selectEvent: function() {
254
- return (isTouchDevice)
255
- ? 'touchstart'
256
- : 'click'
257
- ;
258
- },
259
313
  text: function() {
260
314
  return $text.text();
261
315
  },
@@ -266,14 +320,28 @@ $.fn.dropdown = function(parameters) {
266
320
  var
267
321
  $selectedItem
268
322
  ;
269
- value = value || $input.val();
270
- $item
271
- .each(function() {
272
- if( $(this).data(metadata.value) == value ) {
273
- $selectedItem = $(this);
274
- }
275
- })
323
+ value = (value !== undefined)
324
+ ? value
325
+ : ( module.get.value() || module.get.text() )
276
326
  ;
327
+ if(value) {
328
+ $item
329
+ .each(function() {
330
+ var
331
+ $choice = $(this),
332
+ optionText = $choice.data(metadata.text) || $choice.text(),
333
+ optionValue = $choice.data(metadata.value) || optionText.toLowerCase()
334
+ ;
335
+ if( optionValue == value || optionText == value ) {
336
+ $selectedItem = $(this);
337
+ return false;
338
+ }
339
+ })
340
+ ;
341
+ }
342
+ else {
343
+ value = module.get.text();
344
+ }
277
345
  return $selectedItem || false;
278
346
  }
279
347
  },
@@ -326,23 +394,29 @@ $.fn.dropdown = function(parameters) {
326
394
  selection: function() {
327
395
  return $module.hasClass(className.selection);
328
396
  },
397
+ animated: function($subMenu) {
398
+ return ($subMenu)
399
+ ? $subMenu.is(':animated') || $subMenu.transition('is animating')
400
+ : $menu.is(':animated') || $menu.transition('is animating')
401
+ ;
402
+ },
329
403
  visible: function($subMenu) {
330
404
  return ($subMenu)
331
- ? $subMenu.is(':animated, :visible')
332
- : $menu.is(':animated, :visible')
405
+ ? $subMenu.is(':visible')
406
+ : $menu.is(':visible')
333
407
  ;
334
408
  },
335
409
  hidden: function($subMenu) {
336
410
  return ($subMenu)
337
- ? $subMenu.is(':not(:animated, :visible)')
338
- : $menu.is(':not(:animated, :visible)')
411
+ ? $subMenu.is(':not(:visible)')
412
+ : $menu.is(':not(:visible)')
339
413
  ;
340
414
  }
341
415
  },
342
416
 
343
417
  can: {
344
418
  click: function() {
345
- return (isTouchDevice || settings.on == 'click');
419
+ return (hasTouch || settings.on == 'click');
346
420
  },
347
421
  show: function() {
348
422
  return !$module.hasClass(className.disabled);
@@ -397,7 +471,7 @@ $.fn.dropdown = function(parameters) {
397
471
  ;
398
472
  }
399
473
  else {
400
- module.error(error.transition);
474
+ module.error(error.transition, settings.transition);
401
475
  }
402
476
  }
403
477
  },
@@ -459,16 +533,18 @@ $.fn.dropdown = function(parameters) {
459
533
  if( module.is.hidden() ) {
460
534
  module.hideOthers();
461
535
  module.set.active();
462
- module.animate.show(module.set.visible);
463
- if( module.can.click() ) {
464
- module.bind.intent();
465
- }
536
+ module.animate.show(function() {
537
+ if( module.can.click() ) {
538
+ module.bind.intent();
539
+ }
540
+ module.set.visible();
541
+ });
466
542
  $.proxy(settings.onShow, element)();
467
543
  }
468
544
  },
469
545
 
470
546
  hide: function() {
471
- if( module.is.visible() ) {
547
+ if( !module.is.animated() && module.is.visible() ) {
472
548
  module.debug('Hiding dropdown');
473
549
  if( module.can.click() ) {
474
550
  module.unbind.intent();
@@ -512,26 +588,22 @@ $.fn.dropdown = function(parameters) {
512
588
  },
513
589
 
514
590
  setting: function(name, value) {
515
- if(value !== undefined) {
516
- if( $.isPlainObject(name) ) {
517
- $.extend(true, settings, name);
518
- }
519
- else {
520
- settings[name] = value;
521
- }
591
+ if( $.isPlainObject(name) ) {
592
+ $.extend(true, settings, name);
593
+ }
594
+ else if(value !== undefined) {
595
+ settings[name] = value;
522
596
  }
523
597
  else {
524
598
  return settings[name];
525
599
  }
526
600
  },
527
601
  internal: function(name, value) {
528
- if(value !== undefined) {
529
- if( $.isPlainObject(name) ) {
530
- $.extend(true, module, name);
531
- }
532
- else {
533
- module[name] = value;
534
- }
602
+ if( $.isPlainObject(name) ) {
603
+ $.extend(true, module, name);
604
+ }
605
+ else if(value !== undefined) {
606
+ module[name] = value;
535
607
  }
536
608
  else {
537
609
  return module[name];
@@ -656,14 +728,14 @@ $.fn.dropdown = function(parameters) {
656
728
  else if(found !== undefined) {
657
729
  response = found;
658
730
  }
659
- if($.isArray(invokedResponse)) {
660
- invokedResponse.push(response);
731
+ if($.isArray(returnedValue)) {
732
+ returnedValue.push(response);
661
733
  }
662
- else if(typeof invokedResponse == 'string') {
663
- invokedResponse = [invokedResponse, response];
734
+ else if(returnedValue !== undefined) {
735
+ returnedValue = [returnedValue, response];
664
736
  }
665
737
  else if(response !== undefined) {
666
- invokedResponse = response;
738
+ returnedValue = response;
667
739
  }
668
740
  return found;
669
741
  }
@@ -684,8 +756,8 @@ $.fn.dropdown = function(parameters) {
684
756
  })
685
757
  ;
686
758
 
687
- return (invokedResponse)
688
- ? invokedResponse
759
+ return (returnedValue)
760
+ ? returnedValue
689
761
  : this
690
762
  ;
691
763
  };
@@ -700,11 +772,12 @@ $.fn.dropdown.settings = {
700
772
  performance : true,
701
773
 
702
774
  on : 'click',
703
- action : 'auto',
775
+ action : 'activate',
704
776
 
705
777
  delay: {
706
- show: 200,
707
- hide: 300
778
+ show : 200,
779
+ hide : 300,
780
+ touch : 50
708
781
  },
709
782
 
710
783
  transition : 'slide down',
@@ -721,8 +794,8 @@ $.fn.dropdown.settings = {
721
794
  },
722
795
 
723
796
  metadata: {
724
- text : 'text',
725
- value : 'value'
797
+ text : 'text',
798
+ value : 'value'
726
799
  },
727
800
 
728
801
  selector : {