less-rails-semantic_ui 2.3.0.0 → 2.3.1.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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.eot +0 -0
  3. data/assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.svg +1008 -0
  4. data/assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.ttf +0 -0
  5. data/assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.woff +0 -0
  6. data/assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  7. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.eot +0 -0
  8. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.svg +1515 -944
  9. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.ttf +0 -0
  10. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.woff +0 -0
  11. data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.woff2 +0 -0
  12. data/assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.eot +0 -0
  13. data/assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.svg +366 -0
  14. data/assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.ttf +0 -0
  15. data/assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.woff +0 -0
  16. data/assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  17. data/assets/javascripts/semantic_ui/definitions/behaviors/api.js +1 -1
  18. data/assets/javascripts/semantic_ui/definitions/behaviors/form.js +6 -6
  19. data/assets/javascripts/semantic_ui/definitions/behaviors/visibility.js +2 -2
  20. data/assets/javascripts/semantic_ui/definitions/modules/accordion.js +1 -1
  21. data/assets/javascripts/semantic_ui/definitions/modules/checkbox.js +1 -1
  22. data/assets/javascripts/semantic_ui/definitions/modules/dimmer.js +1 -1
  23. data/assets/javascripts/semantic_ui/definitions/modules/dropdown.js +11 -5
  24. data/assets/javascripts/semantic_ui/definitions/modules/embed.js +1 -1
  25. data/assets/javascripts/semantic_ui/definitions/modules/modal.js +1 -1
  26. data/assets/javascripts/semantic_ui/definitions/modules/nag.js +1 -1
  27. data/assets/javascripts/semantic_ui/definitions/modules/popup.js +1 -1
  28. data/assets/javascripts/semantic_ui/definitions/modules/progress.js +1 -1
  29. data/assets/javascripts/semantic_ui/definitions/modules/rating.js +1 -1
  30. data/assets/javascripts/semantic_ui/definitions/modules/search.js +4 -3
  31. data/assets/javascripts/semantic_ui/definitions/modules/shape.js +1 -1
  32. data/assets/javascripts/semantic_ui/definitions/modules/sidebar.js +1 -1
  33. data/assets/javascripts/semantic_ui/definitions/modules/sticky.js +1 -1
  34. data/assets/javascripts/semantic_ui/definitions/modules/tab.js +1 -1
  35. data/assets/javascripts/semantic_ui/definitions/modules/transition.js +1 -1
  36. data/assets/stylesheets/semantic_ui/definitions/collections/menu.less +2 -2
  37. data/assets/stylesheets/semantic_ui/definitions/elements/icon.less +1 -1
  38. data/assets/stylesheets/semantic_ui/definitions/elements/image.less +2 -2
  39. data/assets/stylesheets/semantic_ui/definitions/elements/reveal.less +2 -0
  40. data/assets/stylesheets/semantic_ui/definitions/modules/search.less +12 -0
  41. data/assets/stylesheets/semantic_ui/themes/basic/elements/button.variables +1 -1
  42. data/assets/stylesheets/semantic_ui/themes/basic/modules/progress.variables +2 -2
  43. data/assets/stylesheets/semantic_ui/themes/bookish/elements/header.variables +2 -2
  44. data/assets/stylesheets/semantic_ui/themes/bootstrap3/elements/button.variables +2 -2
  45. data/assets/stylesheets/semantic_ui/themes/chubby/elements/button.variables +1 -1
  46. data/assets/stylesheets/semantic_ui/themes/default/elements/icon.overrides +1082 -749
  47. data/assets/stylesheets/semantic_ui/themes/default/elements/icon.variables +39 -7
  48. data/lib/generators/semantic_ui/install/templates/semantic_ui.js +0 -3
  49. data/lib/less/rails/semantic_ui/version.rb +1 -1
  50. metadata +13 -7
  51. data/assets/javascripts/semantic_ui/definitions/behaviors/colorize.js +0 -280
  52. data/assets/javascripts/semantic_ui/definitions/behaviors/state.js +0 -708
  53. data/assets/javascripts/semantic_ui/definitions/behaviors/visit.js +0 -525
@@ -2,12 +2,11 @@
2
2
  Icon
3
3
  *******************************/
4
4
 
5
- /*-------------------
6
- Icon Variables
7
- --------------------*/
5
+ /*--------------
6
+ Font Files
7
+ ---------------*/
8
8
 
9
9
  @fontName: 'icons';
10
- @fallbackSRC: asset-url("@{fontPath}/@{fontName}.eot");
11
10
  @src:
12
11
  asset-url("@{fontPath}/@{fontName}.eot?#iefix") format('embedded-opentype'),
13
12
  asset-url("@{fontPath}/@{fontName}.woff2") format('woff2'),
@@ -15,7 +14,41 @@
15
14
  asset-url("@{fontPath}/@{fontName}.ttf") format('truetype'),
16
15
  asset-url("@{fontPath}/@{fontName}.svg#icons") format('svg')
17
16
  ;
17
+ @fallbackSRC: asset-url("@{fontPath}/@{fontName}.eot");
18
+
19
+ /*--------------
20
+ Optional Files
21
+ ---------------*/
22
+
23
+ /* Outline Icons */
24
+ @importOutlineIcons: true;
25
+ @outlineFontName: 'outline-icons';
26
+ @outlineSrc:
27
+ asset-url("@{fontPath}/@{outlineFontName}.eot?#iefix") format('embedded-opentype'),
28
+ asset-url("@{fontPath}/@{outlineFontName}.woff2") format('woff2'),
29
+ asset-url("@{fontPath}/@{outlineFontName}.woff") format('woff'),
30
+ asset-url("@{fontPath}/@{outlineFontName}.ttf") format('truetype'),
31
+ asset-url("@{fontPath}/@{outlineFontName}.svg#icons") format('svg')
32
+ ;
33
+ @outlineFallbackSRC: asset-url("@{fontPath}/@{outlineFontName}.eot");
18
34
 
35
+ /* Brand Icons */
36
+ @importBrandIcons: true;
37
+ @brandFontName: 'brand-icons';
38
+ @brandSrc:
39
+ asset-url("@{fontPath}/@{brandFontName}.eot?#iefix") format('embedded-opentype'),
40
+ asset-url("@{fontPath}/@{brandFontName}.woff2") format('woff2'),
41
+ asset-url("@{fontPath}/@{brandFontName}.woff") format('woff'),
42
+ asset-url("@{fontPath}/@{brandFontName}.ttf") format('truetype'),
43
+ asset-url("@{fontPath}/@{brandFontName}.svg#icons") format('svg')
44
+ ;
45
+ @brandFallbackSRC: asset-url("@{fontPath}/@{brandFontName}.eot");
46
+
47
+ /*--------------
48
+ Definition
49
+ ---------------*/
50
+
51
+ /* Icon Variables */
19
52
  @opacity: 1;
20
53
  @width: @iconWidth;
21
54
  @height: 1em;
@@ -23,18 +56,17 @@
23
56
 
24
57
 
25
58
  /* Variations */
26
-
27
59
  @linkOpacity: 0.8;
28
60
  @linkDuration: 0.3s;
29
61
  @loadingDuration: 2s;
30
62
 
31
63
  @circularSize: 2em;
32
- @circularPadding: 0.5em 0.5em;
64
+ @circularPadding: 0.5em 0em;
33
65
  @circularShadow: 0em 0em 0em 0.1em rgba(0, 0, 0, 0.1) inset;
34
66
 
35
67
  @borderedSize: 2em;
36
68
  @borderedVerticalPadding: ((@borderedSize - @height) / 2);
37
- @borderedHorizontalPadding: ((@borderedSize - @width) / 2);
69
+ @borderedHorizontalPadding: 0em;
38
70
  @borderedShadow: 0em 0em 0em 0.1em rgba(0, 0, 0, 0.1) inset;
39
71
 
40
72
  @cornerIconSize: 0.45em;
@@ -5,7 +5,6 @@
5
5
  //= require semantic_ui/definitions/modules/accordion.js
6
6
  //= require semantic_ui/definitions/behaviors/api.js
7
7
  //= require semantic_ui/definitions/modules/checkbox.js
8
- //= require semantic_ui/definitions/behaviors/colorize.js
9
8
  //= require semantic_ui/definitions/modules/dimmer.js
10
9
  //= require semantic_ui/definitions/modules/dropdown.js
11
10
  //= require semantic_ui/definitions/modules/embed.js
@@ -19,9 +18,7 @@
19
18
  //= require semantic_ui/definitions/modules/shape.js
20
19
  //= require semantic_ui/definitions/modules/sidebar.js
21
20
  //= require semantic_ui/definitions/globals/site.js
22
- //= require semantic_ui/definitions/behaviors/state.js
23
21
  //= require semantic_ui/definitions/modules/sticky.js
24
22
  //= require semantic_ui/definitions/modules/tab.js
25
23
  //= require semantic_ui/definitions/modules/transition.js
26
24
  //= require semantic_ui/definitions/behaviors/visibility.js
27
- //= require semantic_ui/definitions/behaviors/visit.js
@@ -1,7 +1,7 @@
1
1
  module Less
2
2
  module Rails
3
3
  module SemanticUI
4
- VERSION = '2.3.0.0'
4
+ VERSION = '2.3.1.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less-rails-semantic_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.0
4
+ version: 2.3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Dobryakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: less-rails
@@ -179,11 +179,21 @@ files:
179
179
  - assets/fonts/semantic_ui/themes/basic/assets/fonts/icons.svg
180
180
  - assets/fonts/semantic_ui/themes/basic/assets/fonts/icons.ttf
181
181
  - assets/fonts/semantic_ui/themes/basic/assets/fonts/icons.woff
182
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.eot
183
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.svg
184
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.ttf
185
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.woff
186
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/brand-icons.woff2
182
187
  - assets/fonts/semantic_ui/themes/default/assets/fonts/icons.eot
183
188
  - assets/fonts/semantic_ui/themes/default/assets/fonts/icons.svg
184
189
  - assets/fonts/semantic_ui/themes/default/assets/fonts/icons.ttf
185
190
  - assets/fonts/semantic_ui/themes/default/assets/fonts/icons.woff
186
191
  - assets/fonts/semantic_ui/themes/default/assets/fonts/icons.woff2
192
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.eot
193
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.svg
194
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.ttf
195
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.woff
196
+ - assets/fonts/semantic_ui/themes/default/assets/fonts/outline-icons.woff2
187
197
  - assets/fonts/semantic_ui/themes/github/assets/fonts/octicons-local.ttf
188
198
  - assets/fonts/semantic_ui/themes/github/assets/fonts/octicons.svg
189
199
  - assets/fonts/semantic_ui/themes/github/assets/fonts/octicons.ttf
@@ -195,11 +205,8 @@ files:
195
205
  - assets/fonts/semantic_ui/themes/material/assets/fonts/icons.woff2
196
206
  - assets/images/semantic_ui/themes/default/assets/images/flags.png
197
207
  - assets/javascripts/semantic_ui/definitions/behaviors/api.js
198
- - assets/javascripts/semantic_ui/definitions/behaviors/colorize.js
199
208
  - assets/javascripts/semantic_ui/definitions/behaviors/form.js
200
- - assets/javascripts/semantic_ui/definitions/behaviors/state.js
201
209
  - assets/javascripts/semantic_ui/definitions/behaviors/visibility.js
202
- - assets/javascripts/semantic_ui/definitions/behaviors/visit.js
203
210
  - assets/javascripts/semantic_ui/definitions/globals/site.js
204
211
  - assets/javascripts/semantic_ui/definitions/modules/accordion.js
205
212
  - assets/javascripts/semantic_ui/definitions/modules/checkbox.js
@@ -2466,7 +2473,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2466
2473
  version: '0'
2467
2474
  requirements: []
2468
2475
  rubyforge_project:
2469
- rubygems_version: 2.6.13
2476
+ rubygems_version: 2.7.6
2470
2477
  signing_key:
2471
2478
  specification_version: 4
2472
2479
  summary: Semantic UI assets for Rails
@@ -2477,4 +2484,3 @@ test_files:
2477
2484
  - spec/dummy_app/init.rb
2478
2485
  - spec/generators/install_generator_spec.rb
2479
2486
  - spec/spec_helper.rb
2480
- has_rdoc:
@@ -1,280 +0,0 @@
1
- /*!
2
- * # Semantic UI - Colorize
3
- * http://github.com/semantic-org/semantic-ui/
4
- *
5
- *
6
- * Released under the MIT license
7
- * http://opensource.org/licenses/MIT
8
- *
9
- */
10
-
11
- ;(function ($, window, document, undefined) {
12
-
13
- "use strict";
14
-
15
- window = (typeof window != 'undefined' && window.Math == Math)
16
- ? window
17
- : (typeof self != 'undefined' && self.Math == Math)
18
- ? self
19
- : Function('return this')()
20
- ;
21
-
22
- $.fn.colorize = function(parameters) {
23
- var
24
- settings = ( $.isPlainObject(parameters) )
25
- ? $.extend(true, {}, $.fn.colorize.settings, parameters)
26
- : $.extend({}, $.fn.colorize.settings),
27
- // hoist arguments
28
- moduleArguments = arguments || false
29
- ;
30
- $(this)
31
- .each(function(instanceIndex) {
32
-
33
- var
34
- $module = $(this),
35
-
36
- mainCanvas = $('<canvas />')[0],
37
- imageCanvas = $('<canvas />')[0],
38
- overlayCanvas = $('<canvas />')[0],
39
-
40
- backgroundImage = new Image(),
41
-
42
- // defs
43
- mainContext,
44
- imageContext,
45
- overlayContext,
46
-
47
- image,
48
- imageName,
49
-
50
- width,
51
- height,
52
-
53
- // shortcuts
54
- colors = settings.colors,
55
- paths = settings.paths,
56
- namespace = settings.namespace,
57
- error = settings.error,
58
-
59
- // boilerplate
60
- instance = $module.data('module-' + namespace),
61
- module
62
- ;
63
-
64
- module = {
65
-
66
- checkPreconditions: function() {
67
- module.debug('Checking pre-conditions');
68
-
69
- if( !$.isPlainObject(colors) || $.isEmptyObject(colors) ) {
70
- module.error(error.undefinedColors);
71
- return false;
72
- }
73
- return true;
74
- },
75
-
76
- async: function(callback) {
77
- if(settings.async) {
78
- setTimeout(callback, 0);
79
- }
80
- else {
81
- callback();
82
- }
83
- },
84
-
85
- getMetadata: function() {
86
- module.debug('Grabbing metadata');
87
- image = $module.data('image') || settings.image || undefined;
88
- imageName = $module.data('name') || settings.name || instanceIndex;
89
- width = settings.width || $module.width();
90
- height = settings.height || $module.height();
91
- if(width === 0 || height === 0) {
92
- module.error(error.undefinedSize);
93
- }
94
- },
95
-
96
- initialize: function() {
97
- module.debug('Initializing with colors', colors);
98
- if( module.checkPreconditions() ) {
99
-
100
- module.async(function() {
101
- module.getMetadata();
102
- module.canvas.create();
103
-
104
- module.draw.image(function() {
105
- module.draw.colors();
106
- module.canvas.merge();
107
- });
108
- $module
109
- .data('module-' + namespace, module)
110
- ;
111
- });
112
- }
113
- },
114
-
115
- redraw: function() {
116
- module.debug('Redrawing image');
117
- module.async(function() {
118
- module.canvas.clear();
119
- module.draw.colors();
120
- module.canvas.merge();
121
- });
122
- },
123
-
124
- change: {
125
- color: function(colorName, color) {
126
- module.debug('Changing color', colorName);
127
- if(colors[colorName] === undefined) {
128
- module.error(error.missingColor);
129
- return false;
130
- }
131
- colors[colorName] = color;
132
- module.redraw();
133
- }
134
- },
135
-
136
- canvas: {
137
- create: function() {
138
- module.debug('Creating canvases');
139
-
140
- mainCanvas.width = width;
141
- mainCanvas.height = height;
142
- imageCanvas.width = width;
143
- imageCanvas.height = height;
144
- overlayCanvas.width = width;
145
- overlayCanvas.height = height;
146
-
147
- mainContext = mainCanvas.getContext('2d');
148
- imageContext = imageCanvas.getContext('2d');
149
- overlayContext = overlayCanvas.getContext('2d');
150
-
151
- $module
152
- .append( mainCanvas )
153
- ;
154
- mainContext = $module.children('canvas')[0].getContext('2d');
155
- },
156
- clear: function(context) {
157
- module.debug('Clearing canvas');
158
- overlayContext.fillStyle = '#FFFFFF';
159
- overlayContext.fillRect(0, 0, width, height);
160
- },
161
- merge: function() {
162
- if( !$.isFunction(mainContext.blendOnto) ) {
163
- module.error(error.missingPlugin);
164
- return;
165
- }
166
- mainContext.putImageData( imageContext.getImageData(0, 0, width, height), 0, 0);
167
- overlayContext.blendOnto(mainContext, 'multiply');
168
- }
169
- },
170
-
171
- draw: {
172
-
173
- image: function(callback) {
174
- module.debug('Drawing image');
175
- callback = callback || function(){};
176
- if(image) {
177
- backgroundImage.src = image;
178
- backgroundImage.onload = function() {
179
- imageContext.drawImage(backgroundImage, 0, 0);
180
- callback();
181
- };
182
- }
183
- else {
184
- module.error(error.noImage);
185
- callback();
186
- }
187
- },
188
-
189
- colors: function() {
190
- module.debug('Drawing color overlays', colors);
191
- $.each(colors, function(colorName, color) {
192
- settings.onDraw(overlayContext, imageName, colorName, color);
193
- });
194
- }
195
-
196
- },
197
-
198
- debug: function(message, variableName) {
199
- if(settings.debug) {
200
- if(variableName !== undefined) {
201
- console.info(settings.name + ': ' + message, variableName);
202
- }
203
- else {
204
- console.info(settings.name + ': ' + message);
205
- }
206
- }
207
- },
208
- error: function(errorMessage) {
209
- console.warn(settings.name + ': ' + errorMessage);
210
- },
211
- invoke: function(methodName, context, methodArguments) {
212
- var
213
- method
214
- ;
215
- methodArguments = methodArguments || Array.prototype.slice.call( arguments, 2 );
216
-
217
- if(typeof methodName == 'string' && instance !== undefined) {
218
- methodName = methodName.split('.');
219
- $.each(methodName, function(index, name) {
220
- if( $.isPlainObject( instance[name] ) ) {
221
- instance = instance[name];
222
- return true;
223
- }
224
- else if( $.isFunction( instance[name] ) ) {
225
- method = instance[name];
226
- return true;
227
- }
228
- module.error(settings.error.method);
229
- return false;
230
- });
231
- }
232
- return ( $.isFunction( method ) )
233
- ? method.apply(context, methodArguments)
234
- : false
235
- ;
236
- }
237
-
238
- };
239
- if(instance !== undefined && moduleArguments) {
240
- // simpler than invoke realizing to invoke itself (and losing scope due prototype.call()
241
- if(moduleArguments[0] == 'invoke') {
242
- moduleArguments = Array.prototype.slice.call( moduleArguments, 1 );
243
- }
244
- return module.invoke(moduleArguments[0], this, Array.prototype.slice.call( moduleArguments, 1 ) );
245
- }
246
- // initializing
247
- module.initialize();
248
- })
249
- ;
250
- return this;
251
- };
252
-
253
- $.fn.colorize.settings = {
254
- name : 'Image Colorizer',
255
- debug : true,
256
- namespace : 'colorize',
257
-
258
- onDraw : function(overlayContext, imageName, colorName, color) {},
259
-
260
- // whether to block execution while updating canvas
261
- async : true,
262
- // object containing names and default values of color regions
263
- colors : {},
264
-
265
- metadata: {
266
- image : 'image',
267
- name : 'name'
268
- },
269
-
270
- error: {
271
- noImage : 'No tracing image specified',
272
- undefinedColors : 'No default colors specified.',
273
- missingColor : 'Attempted to change color that does not exist',
274
- missingPlugin : 'Blend onto plug-in must be included',
275
- undefinedHeight : 'The width or height of image canvas could not be automatically determined. Please specify a height.'
276
- }
277
-
278
- };
279
-
280
- })( jQuery, window, document );
@@ -1,708 +0,0 @@
1
- /*!
2
- * # Semantic UI - State
3
- * http://github.com/semantic-org/semantic-ui/
4
- *
5
- *
6
- * Released under the MIT license
7
- * http://opensource.org/licenses/MIT
8
- *
9
- */
10
-
11
- ;(function ($, window, document, undefined) {
12
-
13
- "use strict";
14
-
15
- window = (typeof window != 'undefined' && window.Math == Math)
16
- ? window
17
- : (typeof self != 'undefined' && self.Math == Math)
18
- ? self
19
- : Function('return this')()
20
- ;
21
-
22
- $.fn.state = function(parameters) {
23
- var
24
- $allModules = $(this),
25
-
26
- moduleSelector = $allModules.selector || '',
27
-
28
- hasTouch = ('ontouchstart' in document.documentElement),
29
- time = new Date().getTime(),
30
- performance = [],
31
-
32
- query = arguments[0],
33
- methodInvoked = (typeof query == 'string'),
34
- queryArguments = [].slice.call(arguments, 1),
35
-
36
- returnedValue
37
- ;
38
- $allModules
39
- .each(function() {
40
- var
41
- settings = ( $.isPlainObject(parameters) )
42
- ? $.extend(true, {}, $.fn.state.settings, parameters)
43
- : $.extend({}, $.fn.state.settings),
44
-
45
- error = settings.error,
46
- metadata = settings.metadata,
47
- className = settings.className,
48
- namespace = settings.namespace,
49
- states = settings.states,
50
- text = settings.text,
51
-
52
- eventNamespace = '.' + namespace,
53
- moduleNamespace = namespace + '-module',
54
-
55
- $module = $(this),
56
-
57
- element = this,
58
- instance = $module.data(moduleNamespace),
59
-
60
- module
61
- ;
62
- module = {
63
-
64
- initialize: function() {
65
- module.verbose('Initializing module');
66
-
67
- // allow module to guess desired state based on element
68
- if(settings.automatic) {
69
- module.add.defaults();
70
- }
71
-
72
- // bind events with delegated events
73
- if(settings.context && moduleSelector !== '') {
74
- $(settings.context)
75
- .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
76
- .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
77
- .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
78
- ;
79
- }
80
- else {
81
- $module
82
- .on('mouseenter' + eventNamespace, module.change.text)
83
- .on('mouseleave' + eventNamespace, module.reset.text)
84
- .on('click' + eventNamespace, module.toggle.state)
85
- ;
86
- }
87
- module.instantiate();
88
- },
89
-
90
- instantiate: function() {
91
- module.verbose('Storing instance of module', module);
92
- instance = module;
93
- $module
94
- .data(moduleNamespace, module)
95
- ;
96
- },
97
-
98
- destroy: function() {
99
- module.verbose('Destroying previous module', instance);
100
- $module
101
- .off(eventNamespace)
102
- .removeData(moduleNamespace)
103
- ;
104
- },
105
-
106
- refresh: function() {
107
- module.verbose('Refreshing selector cache');
108
- $module = $(element);
109
- },
110
-
111
- add: {
112
- defaults: function() {
113
- var
114
- userStates = parameters && $.isPlainObject(parameters.states)
115
- ? parameters.states
116
- : {}
117
- ;
118
- $.each(settings.defaults, function(type, typeStates) {
119
- if( module.is[type] !== undefined && module.is[type]() ) {
120
- module.verbose('Adding default states', type, element);
121
- $.extend(settings.states, typeStates, userStates);
122
- }
123
- });
124
- }
125
- },
126
-
127
- is: {
128
-
129
- active: function() {
130
- return $module.hasClass(className.active);
131
- },
132
- loading: function() {
133
- return $module.hasClass(className.loading);
134
- },
135
- inactive: function() {
136
- return !( $module.hasClass(className.active) );
137
- },
138
- state: function(state) {
139
- if(className[state] === undefined) {
140
- return false;
141
- }
142
- return $module.hasClass( className[state] );
143
- },
144
-
145
- enabled: function() {
146
- return !( $module.is(settings.filter.active) );
147
- },
148
- disabled: function() {
149
- return ( $module.is(settings.filter.active) );
150
- },
151
- textEnabled: function() {
152
- return !( $module.is(settings.filter.text) );
153
- },
154
-
155
- // definitions for automatic type detection
156
- button: function() {
157
- return $module.is('.button:not(a, .submit)');
158
- },
159
- input: function() {
160
- return $module.is('input');
161
- },
162
- progress: function() {
163
- return $module.is('.ui.progress');
164
- }
165
- },
166
-
167
- allow: function(state) {
168
- module.debug('Now allowing state', state);
169
- states[state] = true;
170
- },
171
- disallow: function(state) {
172
- module.debug('No longer allowing', state);
173
- states[state] = false;
174
- },
175
-
176
- allows: function(state) {
177
- return states[state] || false;
178
- },
179
-
180
- enable: function() {
181
- $module.removeClass(className.disabled);
182
- },
183
-
184
- disable: function() {
185
- $module.addClass(className.disabled);
186
- },
187
-
188
- setState: function(state) {
189
- if(module.allows(state)) {
190
- $module.addClass( className[state] );
191
- }
192
- },
193
-
194
- removeState: function(state) {
195
- if(module.allows(state)) {
196
- $module.removeClass( className[state] );
197
- }
198
- },
199
-
200
- toggle: {
201
- state: function() {
202
- var
203
- apiRequest,
204
- requestCancelled
205
- ;
206
- if( module.allows('active') && module.is.enabled() ) {
207
- module.refresh();
208
- if($.fn.api !== undefined) {
209
- apiRequest = $module.api('get request');
210
- requestCancelled = $module.api('was cancelled');
211
- if( requestCancelled ) {
212
- module.debug('API Request cancelled by beforesend');
213
- settings.activateTest = function(){ return false; };
214
- settings.deactivateTest = function(){ return false; };
215
- }
216
- else if(apiRequest) {
217
- module.listenTo(apiRequest);
218
- return;
219
- }
220
- }
221
- module.change.state();
222
- }
223
- }
224
- },
225
-
226
- listenTo: function(apiRequest) {
227
- module.debug('API request detected, waiting for state signal', apiRequest);
228
- if(apiRequest) {
229
- if(text.loading) {
230
- module.update.text(text.loading);
231
- }
232
- $.when(apiRequest)
233
- .then(function() {
234
- if(apiRequest.state() == 'resolved') {
235
- module.debug('API request succeeded');
236
- settings.activateTest = function(){ return true; };
237
- settings.deactivateTest = function(){ return true; };
238
- }
239
- else {
240
- module.debug('API request failed');
241
- settings.activateTest = function(){ return false; };
242
- settings.deactivateTest = function(){ return false; };
243
- }
244
- module.change.state();
245
- })
246
- ;
247
- }
248
- },
249
-
250
- // checks whether active/inactive state can be given
251
- change: {
252
-
253
- state: function() {
254
- module.debug('Determining state change direction');
255
- // inactive to active change
256
- if( module.is.inactive() ) {
257
- module.activate();
258
- }
259
- else {
260
- module.deactivate();
261
- }
262
- if(settings.sync) {
263
- module.sync();
264
- }
265
- settings.onChange.call(element);
266
- },
267
-
268
- text: function() {
269
- if( module.is.textEnabled() ) {
270
- if(module.is.disabled() ) {
271
- module.verbose('Changing text to disabled text', text.hover);
272
- module.update.text(text.disabled);
273
- }
274
- else if( module.is.active() ) {
275
- if(text.hover) {
276
- module.verbose('Changing text to hover text', text.hover);
277
- module.update.text(text.hover);
278
- }
279
- else if(text.deactivate) {
280
- module.verbose('Changing text to deactivating text', text.deactivate);
281
- module.update.text(text.deactivate);
282
- }
283
- }
284
- else {
285
- if(text.hover) {
286
- module.verbose('Changing text to hover text', text.hover);
287
- module.update.text(text.hover);
288
- }
289
- else if(text.activate){
290
- module.verbose('Changing text to activating text', text.activate);
291
- module.update.text(text.activate);
292
- }
293
- }
294
- }
295
- }
296
-
297
- },
298
-
299
- activate: function() {
300
- if( settings.activateTest.call(element) ) {
301
- module.debug('Setting state to active');
302
- $module
303
- .addClass(className.active)
304
- ;
305
- module.update.text(text.active);
306
- settings.onActivate.call(element);
307
- }
308
- },
309
-
310
- deactivate: function() {
311
- if( settings.deactivateTest.call(element) ) {
312
- module.debug('Setting state to inactive');
313
- $module
314
- .removeClass(className.active)
315
- ;
316
- module.update.text(text.inactive);
317
- settings.onDeactivate.call(element);
318
- }
319
- },
320
-
321
- sync: function() {
322
- module.verbose('Syncing other buttons to current state');
323
- if( module.is.active() ) {
324
- $allModules
325
- .not($module)
326
- .state('activate');
327
- }
328
- else {
329
- $allModules
330
- .not($module)
331
- .state('deactivate')
332
- ;
333
- }
334
- },
335
-
336
- get: {
337
- text: function() {
338
- return (settings.selector.text)
339
- ? $module.find(settings.selector.text).text()
340
- : $module.html()
341
- ;
342
- },
343
- textFor: function(state) {
344
- return text[state] || false;
345
- }
346
- },
347
-
348
- flash: {
349
- text: function(text, duration, callback) {
350
- var
351
- previousText = module.get.text()
352
- ;
353
- module.debug('Flashing text message', text, duration);
354
- text = text || settings.text.flash;
355
- duration = duration || settings.flashDuration;
356
- callback = callback || function() {};
357
- module.update.text(text);
358
- setTimeout(function(){
359
- module.update.text(previousText);
360
- callback.call(element);
361
- }, duration);
362
- }
363
- },
364
-
365
- reset: {
366
- // on mouseout sets text to previous value
367
- text: function() {
368
- var
369
- activeText = text.active || $module.data(metadata.storedText),
370
- inactiveText = text.inactive || $module.data(metadata.storedText)
371
- ;
372
- if( module.is.textEnabled() ) {
373
- if( module.is.active() && activeText) {
374
- module.verbose('Resetting active text', activeText);
375
- module.update.text(activeText);
376
- }
377
- else if(inactiveText) {
378
- module.verbose('Resetting inactive text', activeText);
379
- module.update.text(inactiveText);
380
- }
381
- }
382
- }
383
- },
384
-
385
- update: {
386
- text: function(text) {
387
- var
388
- currentText = module.get.text()
389
- ;
390
- if(text && text !== currentText) {
391
- module.debug('Updating text', text);
392
- if(settings.selector.text) {
393
- $module
394
- .data(metadata.storedText, text)
395
- .find(settings.selector.text)
396
- .text(text)
397
- ;
398
- }
399
- else {
400
- $module
401
- .data(metadata.storedText, text)
402
- .html(text)
403
- ;
404
- }
405
- }
406
- else {
407
- module.debug('Text is already set, ignoring update', text);
408
- }
409
- }
410
- },
411
-
412
- setting: function(name, value) {
413
- module.debug('Changing setting', name, value);
414
- if( $.isPlainObject(name) ) {
415
- $.extend(true, settings, name);
416
- }
417
- else if(value !== undefined) {
418
- if($.isPlainObject(settings[name])) {
419
- $.extend(true, settings[name], value);
420
- }
421
- else {
422
- settings[name] = value;
423
- }
424
- }
425
- else {
426
- return settings[name];
427
- }
428
- },
429
- internal: function(name, value) {
430
- if( $.isPlainObject(name) ) {
431
- $.extend(true, module, name);
432
- }
433
- else if(value !== undefined) {
434
- module[name] = value;
435
- }
436
- else {
437
- return module[name];
438
- }
439
- },
440
- debug: function() {
441
- if(!settings.silent && settings.debug) {
442
- if(settings.performance) {
443
- module.performance.log(arguments);
444
- }
445
- else {
446
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
447
- module.debug.apply(console, arguments);
448
- }
449
- }
450
- },
451
- verbose: function() {
452
- if(!settings.silent && settings.verbose && settings.debug) {
453
- if(settings.performance) {
454
- module.performance.log(arguments);
455
- }
456
- else {
457
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
458
- module.verbose.apply(console, arguments);
459
- }
460
- }
461
- },
462
- error: function() {
463
- if(!settings.silent) {
464
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
465
- module.error.apply(console, arguments);
466
- }
467
- },
468
- performance: {
469
- log: function(message) {
470
- var
471
- currentTime,
472
- executionTime,
473
- previousTime
474
- ;
475
- if(settings.performance) {
476
- currentTime = new Date().getTime();
477
- previousTime = time || currentTime;
478
- executionTime = currentTime - previousTime;
479
- time = currentTime;
480
- performance.push({
481
- 'Name' : message[0],
482
- 'Arguments' : [].slice.call(message, 1) || '',
483
- 'Element' : element,
484
- 'Execution Time' : executionTime
485
- });
486
- }
487
- clearTimeout(module.performance.timer);
488
- module.performance.timer = setTimeout(module.performance.display, 500);
489
- },
490
- display: function() {
491
- var
492
- title = settings.name + ':',
493
- totalTime = 0
494
- ;
495
- time = false;
496
- clearTimeout(module.performance.timer);
497
- $.each(performance, function(index, data) {
498
- totalTime += data['Execution Time'];
499
- });
500
- title += ' ' + totalTime + 'ms';
501
- if(moduleSelector) {
502
- title += ' \'' + moduleSelector + '\'';
503
- }
504
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
505
- console.groupCollapsed(title);
506
- if(console.table) {
507
- console.table(performance);
508
- }
509
- else {
510
- $.each(performance, function(index, data) {
511
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
512
- });
513
- }
514
- console.groupEnd();
515
- }
516
- performance = [];
517
- }
518
- },
519
- invoke: function(query, passedArguments, context) {
520
- var
521
- object = instance,
522
- maxDepth,
523
- found,
524
- response
525
- ;
526
- passedArguments = passedArguments || queryArguments;
527
- context = element || context;
528
- if(typeof query == 'string' && object !== undefined) {
529
- query = query.split(/[\. ]/);
530
- maxDepth = query.length - 1;
531
- $.each(query, function(depth, value) {
532
- var camelCaseValue = (depth != maxDepth)
533
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
534
- : query
535
- ;
536
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
537
- object = object[camelCaseValue];
538
- }
539
- else if( object[camelCaseValue] !== undefined ) {
540
- found = object[camelCaseValue];
541
- return false;
542
- }
543
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
544
- object = object[value];
545
- }
546
- else if( object[value] !== undefined ) {
547
- found = object[value];
548
- return false;
549
- }
550
- else {
551
- module.error(error.method, query);
552
- return false;
553
- }
554
- });
555
- }
556
- if ( $.isFunction( found ) ) {
557
- response = found.apply(context, passedArguments);
558
- }
559
- else if(found !== undefined) {
560
- response = found;
561
- }
562
- if($.isArray(returnedValue)) {
563
- returnedValue.push(response);
564
- }
565
- else if(returnedValue !== undefined) {
566
- returnedValue = [returnedValue, response];
567
- }
568
- else if(response !== undefined) {
569
- returnedValue = response;
570
- }
571
- return found;
572
- }
573
- };
574
-
575
- if(methodInvoked) {
576
- if(instance === undefined) {
577
- module.initialize();
578
- }
579
- module.invoke(query);
580
- }
581
- else {
582
- if(instance !== undefined) {
583
- instance.invoke('destroy');
584
- }
585
- module.initialize();
586
- }
587
- })
588
- ;
589
-
590
- return (returnedValue !== undefined)
591
- ? returnedValue
592
- : this
593
- ;
594
- };
595
-
596
- $.fn.state.settings = {
597
-
598
- // module info
599
- name : 'State',
600
-
601
- // debug output
602
- debug : false,
603
-
604
- // verbose debug output
605
- verbose : false,
606
-
607
- // namespace for events
608
- namespace : 'state',
609
-
610
- // debug data includes performance
611
- performance : true,
612
-
613
- // callback occurs on state change
614
- onActivate : function() {},
615
- onDeactivate : function() {},
616
- onChange : function() {},
617
-
618
- // state test functions
619
- activateTest : function() { return true; },
620
- deactivateTest : function() { return true; },
621
-
622
- // whether to automatically map default states
623
- automatic : true,
624
-
625
- // activate / deactivate changes all elements instantiated at same time
626
- sync : false,
627
-
628
- // default flash text duration, used for temporarily changing text of an element
629
- flashDuration : 1000,
630
-
631
- // selector filter
632
- filter : {
633
- text : '.loading, .disabled',
634
- active : '.disabled'
635
- },
636
-
637
- context : false,
638
-
639
- // error
640
- error: {
641
- beforeSend : 'The before send function has cancelled state change',
642
- method : 'The method you called is not defined.'
643
- },
644
-
645
- // metadata
646
- metadata: {
647
- promise : 'promise',
648
- storedText : 'stored-text'
649
- },
650
-
651
- // change class on state
652
- className: {
653
- active : 'active',
654
- disabled : 'disabled',
655
- error : 'error',
656
- loading : 'loading',
657
- success : 'success',
658
- warning : 'warning'
659
- },
660
-
661
- selector: {
662
- // selector for text node
663
- text: false
664
- },
665
-
666
- defaults : {
667
- input: {
668
- disabled : true,
669
- loading : true,
670
- active : true
671
- },
672
- button: {
673
- disabled : true,
674
- loading : true,
675
- active : true,
676
- },
677
- progress: {
678
- active : true,
679
- success : true,
680
- warning : true,
681
- error : true
682
- }
683
- },
684
-
685
- states : {
686
- active : true,
687
- disabled : true,
688
- error : true,
689
- loading : true,
690
- success : true,
691
- warning : true
692
- },
693
-
694
- text : {
695
- disabled : false,
696
- flash : false,
697
- hover : false,
698
- active : false,
699
- inactive : false,
700
- activate : false,
701
- deactivate : false
702
- }
703
-
704
- };
705
-
706
-
707
-
708
- })( jQuery, window, document );