codelation_ui 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +327 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/javascripts/codelation_ui/_base_resources/app.js +91 -0
  6. data/app/assets/javascripts/codelation_ui/_base_resources/components/has_grid.js +24 -0
  7. data/app/assets/javascripts/codelation_ui/_base_resources/components/link.js +22 -0
  8. data/app/assets/javascripts/codelation_ui/_base_resources/progress_bar.js +5 -0
  9. data/app/assets/javascripts/codelation_ui/base.js +8 -0
  10. data/app/assets/javascripts/codelation_ui/extended/slider.js +654 -0
  11. data/app/assets/javascripts/codelation_ui/extended.js +1 -0
  12. data/app/assets/javascripts/codelation_ui/forms/components/input.js +497 -0
  13. data/app/assets/javascripts/codelation_ui/forms/index.js +2 -0
  14. data/app/assets/javascripts/codelation_ui/forms/interfaces/form.js +71 -0
  15. data/app/assets/javascripts/codelation_ui/forms/interfaces/form_validation.js +31 -0
  16. data/app/assets/javascripts/codelation_ui/forms.js +2 -0
  17. data/app/assets/javascripts/codelation_ui/std/index.js +2 -0
  18. data/app/assets/javascripts/codelation_ui/std/interfaces/content_formatters.js +27 -0
  19. data/app/assets/javascripts/codelation_ui/std/interfaces/content_validators.js +50 -0
  20. data/app/assets/javascripts/codelation_ui/std/interfaces/helpers.js +10 -0
  21. data/app/assets/javascripts/codelation_ui/std.js +1 -0
  22. data/app/assets/javascripts/codelation_ui/vue.js +12 -0
  23. data/app/assets/javascripts/codelation_ui/vue_pages.js +11 -0
  24. data/app/assets/javascripts/codelation_ui.js +6 -0
  25. data/app/assets/stylesheets/codelation_ui/_base_resources/_normalize.scss +427 -0
  26. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
  27. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/_bourbon.scss +87 -0
  28. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-color.scss +26 -0
  29. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-radius.scss +48 -0
  30. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-style.scss +25 -0
  31. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_border-width.scss +25 -0
  32. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_buttons.scss +64 -0
  33. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_clearfix.scss +25 -0
  34. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_ellipsis.scss +30 -0
  35. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_font-stacks.scss +31 -0
  36. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_hide-text.scss +27 -0
  37. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_margin.scss +26 -0
  38. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_padding.scss +26 -0
  39. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_position.scss +48 -0
  40. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_prefixer.scss +66 -0
  41. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_retina-image.scss +25 -0
  42. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_size.scss +51 -0
  43. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_text-inputs.scss +113 -0
  44. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_timing-functions.scss +34 -0
  45. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_triangle.scss +63 -0
  46. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/addons/_word-wrap.scss +29 -0
  47. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_animation.scss +43 -0
  48. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_appearance.scss +3 -0
  49. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_backface-visibility.scss +3 -0
  50. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background-image.scss +42 -0
  51. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_background.scss +55 -0
  52. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_border-image.scss +59 -0
  53. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_calc.scss +4 -0
  54. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_columns.scss +47 -0
  55. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_filter.scss +4 -0
  56. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_flex-box.scss +287 -0
  57. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-face.scss +24 -0
  58. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_font-feature-settings.scss +4 -0
  59. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hidpi-media-query.scss +10 -0
  60. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_hyphens.scss +4 -0
  61. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_image-rendering.scss +14 -0
  62. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_keyframes.scss +36 -0
  63. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_linear-gradient.scss +38 -0
  64. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_perspective.scss +8 -0
  65. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_placeholder.scss +8 -0
  66. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_radial-gradient.scss +39 -0
  67. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_selection.scss +42 -0
  68. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_text-decoration.scss +19 -0
  69. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transform.scss +15 -0
  70. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_transition.scss +71 -0
  71. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/css3/_user-select.scss +3 -0
  72. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_assign-inputs.scss +11 -0
  73. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains-falsy.scss +20 -0
  74. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_contains.scss +26 -0
  75. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-length.scss +11 -0
  76. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-light.scss +21 -0
  77. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-number.scss +11 -0
  78. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_is-size.scss +13 -0
  79. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_modular-scale.scss +69 -0
  80. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-em.scss +13 -0
  81. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_px-to-rem.scss +15 -0
  82. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_shade.scss +24 -0
  83. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_strip-units.scss +17 -0
  84. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_tint.scss +24 -0
  85. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_transition-property-name.scss +22 -0
  86. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/functions/_unpack.scss +27 -0
  87. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_convert-units.scss +21 -0
  88. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_directional-values.scss +96 -0
  89. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_font-source-declaration.scss +43 -0
  90. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_gradient-positions-parser.scss +13 -0
  91. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-angle-parser.scss +25 -0
  92. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-gradient-parser.scss +41 -0
  93. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-positions-parser.scss +61 -0
  94. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
  95. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-arg-parser.scss +69 -0
  96. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-gradient-parser.scss +50 -0
  97. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_radial-positions-parser.scss +18 -0
  98. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_render-gradients.scss +26 -0
  99. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_shape-size-stripper.scss +10 -0
  100. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/helpers/_str-to-num.scss +50 -0
  101. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_asset-pipeline.scss +7 -0
  102. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_prefixer.scss +9 -0
  103. data/app/assets/stylesheets/codelation_ui/_base_resources/bourbon/settings/_px-to-em.scss +1 -0
  104. data/app/assets/stylesheets/codelation_ui/_base_resources/functions/color.scss +162 -0
  105. data/app/assets/stylesheets/codelation_ui/_base_resources/functions/text_color.scss +41 -0
  106. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/button.scss +47 -0
  107. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/center_children.scss +9 -0
  108. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/col_span.scss +16 -0
  109. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_cards.scss +43 -0
  110. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_columns.scss +66 -0
  111. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/has_grid.scss +80 -0
  112. data/app/assets/stylesheets/codelation_ui/_base_resources/mixins/outer_container.scss +10 -0
  113. data/app/assets/stylesheets/codelation_ui/base.scss +27 -0
  114. data/app/assets/stylesheets/codelation_ui/extended/slider.scss +222 -0
  115. data/app/assets/stylesheets/codelation_ui/extended.scss +1 -0
  116. data/app/assets/stylesheets/codelation_ui/forms/input.scss +72 -0
  117. data/app/assets/stylesheets/codelation_ui/forms.scss +1 -0
  118. data/app/assets/stylesheets/codelation_ui/std.scss +1 -0
  119. data/app/assets/stylesheets/codelation_ui.scss +4 -0
  120. data/lib/codelation_ui.rb +7 -0
  121. data/vendor/assets/javascripts/autonumeric/autoNumeric-1.9.39.js +1465 -0
  122. data/vendor/assets/javascripts/autonumeric/autonumeric_ujs.js +94 -0
  123. data/vendor/assets/javascripts/autonumeric.js +2 -0
  124. data/vendor/assets/javascripts/awesomplete.js +392 -0
  125. data/vendor/assets/javascripts/moment.js +4301 -0
  126. data/vendor/assets/javascripts/numeral.js +679 -0
  127. data/vendor/assets/javascripts/pikaday.js +1081 -0
  128. data/vendor/assets/javascripts/summernote.js +7300 -0
  129. data/vendor/assets/javascripts/vue.js +10237 -0
  130. metadata +242 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * autonumeric_ujs.js
3
+ * @author: randoum
4
+ * @version: 1.9.39 - 2015-08-01
5
+ *
6
+ * Created by Randoum on 2013-08-15. Please report any bugs to https://github.com/randoum/autonumeric-rails
7
+ *
8
+ * Wrap-up autoNumeric.js library to be used with Rails in a UJS flavor
9
+ * All credits for autoNumeric library goes to its original creators
10
+ * Whom can be reached at https://github.com/BobKnothe/autoNumeric
11
+ *
12
+ * The MIT License (http://www.opensource.org/licenses/mit-license.php)
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person
15
+ * obtaining a copy of this software and associated documentation
16
+ * files (the "Software"), to deal in the Software without
17
+ * restriction, including without limitation the rights to use,
18
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ * copies of the Software, and to permit persons to whom the
20
+ * Software is furnished to do so, subject to the following
21
+ * conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be
24
+ * included in all copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
28
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
30
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
31
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33
+ * OTHER DEALINGS IN THE SOFTWARE.
34
+ */
35
+
36
+ var AutonumericRails;
37
+
38
+ window.AutonumericRails = AutonumericRails = (function() {
39
+ AutonumericRails.create_autonumeric_object = function(obj) {
40
+ if (!obj.data('autonumeric-initialized')) {
41
+ return new this(obj);
42
+ }
43
+ };
44
+
45
+ AutonumericRails.delete_autonumeric_object = function(obj) {
46
+ if (obj.data('autonumeric-initialized')) {
47
+ obj.removeData('autonumeric-initialized').removeData('autonumeric').removeAttr('data-autonumeric').off('keyup blur').autoNumeric('destroy');
48
+ $('input#' + obj.attr('id') + '_val[type="hidden"][name="' + obj.attr('name') + '"]').remove();
49
+ }
50
+ };
51
+
52
+ function AutonumericRails(field) {
53
+ this.field = field;
54
+ this.field.data('autonumeric-initialized', true);
55
+ this.create_hidden_field();
56
+ this.init_autonumeric();
57
+ this.sanitize_value();
58
+ this.field.on('keyup blur', $.proxy(function() {
59
+ this.sanitize_value();
60
+ }, this));
61
+ }
62
+
63
+ AutonumericRails.prototype.create_hidden_field = function() {
64
+ this.hidden = $('<input>').attr('type', 'hidden').attr('id', this.field.attr('id') + '_val').attr('name', this.field.attr('name'));
65
+ this.hidden.insertAfter(this.field);
66
+ };
67
+
68
+ AutonumericRails.prototype.init_autonumeric = function() {
69
+ this.field.autoNumeric('init', $.parseJSON(this.field.attr('data-autonumeric')));
70
+ };
71
+
72
+ AutonumericRails.prototype.sanitize_value = function() {
73
+ this.hidden.val(this.field.autoNumeric('get'));
74
+ };
75
+
76
+ return AutonumericRails;
77
+
78
+ })();
79
+
80
+ window.refresh_autonumeric = function() {
81
+ $('input[data-autonumeric]').each(function() {
82
+ AutonumericRails.create_autonumeric_object($(this));
83
+ });
84
+ };
85
+
86
+ jQuery(function() {
87
+ window.refresh_autonumeric();
88
+ $(document).on('refresh_autonumeric', function() {
89
+ window.refresh_autonumeric();
90
+ });
91
+ $(document).on('ajaxComplete', function() {
92
+ window.refresh_autonumeric();
93
+ });
94
+ });
@@ -0,0 +1,2 @@
1
+ //= require autonumeric/autoNumeric-1.9.39.js
2
+ //= require autonumeric/autonumeric_ujs.js
@@ -0,0 +1,392 @@
1
+ /**
2
+ * Simple, lightweight, usable local autocomplete library for modern browsers
3
+ * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P
4
+ * @author Lea Verou http://leaverou.github.io/awesomplete
5
+ * MIT license
6
+ */
7
+
8
+ (function () {
9
+
10
+ var _ = function (input, o) {
11
+ var me = this;
12
+
13
+ // Setup
14
+
15
+ this.input = $(input);
16
+ this.input.setAttribute("autocomplete", "off");
17
+ this.input.setAttribute("aria-autocomplete", "list");
18
+
19
+ o = o || {};
20
+
21
+ configure.call(this, {
22
+ minChars: 2,
23
+ maxItems: 10,
24
+ autoFirst: false,
25
+ filter: _.FILTER_CONTAINS,
26
+ sort: _.SORT_BYLENGTH,
27
+ item: function (text, input) {
28
+ var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
29
+ return $.create("li", {
30
+ innerHTML: html,
31
+ "aria-selected": "false"
32
+ });
33
+ },
34
+ replace: function (text) {
35
+ this.input.value = text;
36
+ }
37
+ }, o);
38
+
39
+ this.index = -1;
40
+
41
+ // Create necessary elements
42
+
43
+ this.container = $.create("div", {
44
+ className: "awesomplete",
45
+ around: input
46
+ });
47
+
48
+ this.ul = $.create("ul", {
49
+ hidden: "",
50
+ inside: this.container
51
+ });
52
+
53
+ this.status = $.create("span", {
54
+ className: "visually-hidden",
55
+ role: "status",
56
+ "aria-live": "assertive",
57
+ "aria-relevant": "additions",
58
+ inside: this.container
59
+ });
60
+
61
+ // Bind events
62
+
63
+ $.bind(this.input, {
64
+ "input": this.evaluate.bind(this),
65
+ "blur": this.close.bind(this),
66
+ "keydown": function(evt) {
67
+ var c = evt.keyCode;
68
+
69
+ // If the dropdown `ul` is in view, then act on keydown for the following keys:
70
+ // Enter / Esc / Up / Down
71
+ if(me.opened) {
72
+ if (c === 13 && me.selected) { // Enter
73
+ evt.preventDefault();
74
+ me.select();
75
+ }
76
+ else if (c === 27) { // Esc
77
+ me.close();
78
+ }
79
+ else if (c === 38 || c === 40) { // Down/Up arrow
80
+ evt.preventDefault();
81
+ me[c === 38? "previous" : "next"]();
82
+ }
83
+ }
84
+ }
85
+ });
86
+
87
+ $.bind(this.input.form, {"submit": this.close.bind(this)});
88
+
89
+ $.bind(this.ul, {"mousedown": function(evt) {
90
+ var li = evt.target;
91
+
92
+ if (li !== this) {
93
+
94
+ while (li && !/li/i.test(li.nodeName)) {
95
+ li = li.parentNode;
96
+ }
97
+
98
+ if (li && evt.button === 0) { // Only select on left click
99
+ me.select(li);
100
+ }
101
+ }
102
+ }});
103
+
104
+ if (this.input.hasAttribute("list")) {
105
+ this.list = "#" + input.getAttribute("list");
106
+ input.removeAttribute("list");
107
+ }
108
+ else {
109
+ this.list = this.input.getAttribute("data-list") || o.list || [];
110
+ }
111
+
112
+ _.all.push(this);
113
+ };
114
+
115
+ _.prototype = {
116
+ set list(list) {
117
+ if (Array.isArray(list)) {
118
+ this._list = list;
119
+ }
120
+ else if (typeof list === "string" && list.indexOf(",") > -1) {
121
+ this._list = list.split(/\s*,\s*/);
122
+ }
123
+ else { // Element or CSS selector
124
+ list = $(list);
125
+
126
+ if (list && list.children) {
127
+ this._list = slice.apply(list.children).map(function (el) {
128
+ return el.textContent.trim();
129
+ });
130
+ }
131
+ }
132
+
133
+ if (document.activeElement === this.input) {
134
+ this.evaluate();
135
+ }
136
+ },
137
+
138
+ get selected() {
139
+ return this.index > -1;
140
+ },
141
+
142
+ get opened() {
143
+ return this.ul && this.ul.getAttribute("hidden") == null;
144
+ },
145
+
146
+ close: function () {
147
+ this.ul.setAttribute("hidden", "");
148
+ this.index = -1;
149
+
150
+ $.fire(this.input, "awesomplete-close");
151
+ },
152
+
153
+ open: function () {
154
+ this.ul.removeAttribute("hidden");
155
+
156
+ if (this.autoFirst && this.index === -1) {
157
+ this.goto(0);
158
+ }
159
+
160
+ $.fire(this.input, "awesomplete-open");
161
+ },
162
+
163
+ next: function () {
164
+ var count = this.ul.children.length;
165
+
166
+ this.goto(this.index < count - 1? this.index + 1 : -1);
167
+ },
168
+
169
+ previous: function () {
170
+ var count = this.ul.children.length;
171
+
172
+ this.goto(this.selected? this.index - 1 : count - 1);
173
+ },
174
+
175
+ // Should not be used, highlights specific item without any checks!
176
+ goto: function (i) {
177
+ var lis = this.ul.children;
178
+
179
+ if (this.selected) {
180
+ lis[this.index].setAttribute("aria-selected", "false");
181
+ }
182
+
183
+ this.index = i;
184
+
185
+ if (i > -1 && lis.length > 0) {
186
+ lis[i].setAttribute("aria-selected", "true");
187
+ this.status.textContent = lis[i].textContent;
188
+ }
189
+
190
+ $.fire(this.input, "awesomplete-highlight");
191
+ },
192
+
193
+ select: function (selected) {
194
+ selected = selected || this.ul.children[this.index];
195
+
196
+ if (selected) {
197
+ var prevented;
198
+
199
+ $.fire(this.input, "awesomplete-select", {
200
+ text: selected.textContent,
201
+ preventDefault: function () {
202
+ prevented = true;
203
+ }
204
+ });
205
+
206
+ if (!prevented) {
207
+ this.replace(selected.textContent);
208
+ this.close();
209
+ $.fire(this.input, "awesomplete-selectcomplete");
210
+ }
211
+ }
212
+ },
213
+
214
+ evaluate: function() {
215
+ var me = this;
216
+ var value = this.input.value;
217
+
218
+ if (value.length >= this.minChars && this._list.length > 0) {
219
+ this.index = -1;
220
+ // Populate list with options that match
221
+ this.ul.innerHTML = "";
222
+
223
+ this._list
224
+ .filter(function(item) {
225
+ return me.filter(item, value);
226
+ })
227
+ .sort(this.sort)
228
+ .every(function(text, i) {
229
+ me.ul.appendChild(me.item(text, value));
230
+
231
+ return i < me.maxItems - 1;
232
+ });
233
+
234
+ if (this.ul.children.length === 0) {
235
+ this.close();
236
+ } else {
237
+ this.open();
238
+ }
239
+ }
240
+ else {
241
+ this.close();
242
+ }
243
+ }
244
+ };
245
+
246
+ // Static methods/properties
247
+
248
+ _.all = [];
249
+
250
+ _.FILTER_CONTAINS = function (text, input) {
251
+ return RegExp($.regExpEscape(input.trim()), "i").test(text);
252
+ };
253
+
254
+ _.FILTER_STARTSWITH = function (text, input) {
255
+ return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text);
256
+ };
257
+
258
+ _.SORT_BYLENGTH = function (a, b) {
259
+ if (a.length !== b.length) {
260
+ return a.length - b.length;
261
+ }
262
+
263
+ return a < b? -1 : 1;
264
+ };
265
+
266
+ // Private functions
267
+
268
+ function configure(properties, o) {
269
+ for (var i in properties) {
270
+ var initial = properties[i],
271
+ attrValue = this.input.getAttribute("data-" + i.toLowerCase());
272
+
273
+ if (typeof initial === "number") {
274
+ this[i] = parseInt(attrValue);
275
+ }
276
+ else if (initial === false) { // Boolean options must be false by default anyway
277
+ this[i] = attrValue !== null;
278
+ }
279
+ else if (initial instanceof Function) {
280
+ this[i] = null;
281
+ }
282
+ else {
283
+ this[i] = attrValue;
284
+ }
285
+
286
+ if (!this[i] && this[i] !== 0) {
287
+ this[i] = (i in o)? o[i] : initial;
288
+ }
289
+ }
290
+ }
291
+
292
+ // Helpers
293
+
294
+ var slice = Array.prototype.slice;
295
+
296
+ function $(expr, con) {
297
+ return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
298
+ }
299
+
300
+ function $$(expr, con) {
301
+ return slice.call((con || document).querySelectorAll(expr));
302
+ }
303
+
304
+ $.create = function(tag, o) {
305
+ var element = document.createElement(tag);
306
+
307
+ for (var i in o) {
308
+ var val = o[i];
309
+
310
+ if (i === "inside") {
311
+ $(val).appendChild(element);
312
+ }
313
+ else if (i === "around") {
314
+ var ref = $(val);
315
+ ref.parentNode.insertBefore(element, ref);
316
+ element.appendChild(ref);
317
+ }
318
+ else if (i in element) {
319
+ element[i] = val;
320
+ }
321
+ else {
322
+ element.setAttribute(i, val);
323
+ }
324
+ }
325
+
326
+ return element;
327
+ };
328
+
329
+ $.bind = function(element, o) {
330
+ if (element) {
331
+ for (var event in o) {
332
+ var callback = o[event];
333
+
334
+ event.split(/\s+/).forEach(function (event) {
335
+ element.addEventListener(event, callback);
336
+ });
337
+ }
338
+ }
339
+ };
340
+
341
+ $.fire = function(target, type, properties) {
342
+ var evt = document.createEvent("HTMLEvents");
343
+
344
+ evt.initEvent(type, true, true );
345
+
346
+ for (var j in properties) {
347
+ evt[j] = properties[j];
348
+ }
349
+
350
+ target.dispatchEvent(evt);
351
+ };
352
+
353
+ $.regExpEscape = function (s) {
354
+ return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
355
+ }
356
+
357
+ // Initialization
358
+
359
+ function init() {
360
+ $$("input.awesomplete").forEach(function (input) {
361
+ new _(input);
362
+ });
363
+ }
364
+
365
+ // Are we in a browser? Check for Document constructor
366
+ if (typeof Document !== "undefined") {
367
+ // DOM already loaded?
368
+ if (document.readyState !== "loading") {
369
+ init();
370
+ }
371
+ else {
372
+ // Wait for it
373
+ document.addEventListener("DOMContentLoaded", init);
374
+ }
375
+ }
376
+
377
+ _.$ = $;
378
+ _.$$ = $$;
379
+
380
+ // Make sure to export Awesomplete on self when in a browser
381
+ if (typeof self !== "undefined") {
382
+ self.Awesomplete = _;
383
+ }
384
+
385
+ // Expose Awesomplete as a CJS module
386
+ if (typeof exports === "object") {
387
+ module.exports = _;
388
+ }
389
+
390
+ return _;
391
+
392
+ }());