boletia_ui 0.1.1

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 (90) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +42 -0
  3. data/lib/boletia_ui/version.rb +3 -0
  4. data/lib/boletia_ui.rb +8 -0
  5. data/vendor/assets/boletia_ui/fonts/ss-standard.css +53 -0
  6. data/vendor/assets/boletia_ui/fonts/ss-standard.eot +0 -0
  7. data/vendor/assets/boletia_ui/fonts/ss-standard.js +84 -0
  8. data/vendor/assets/boletia_ui/fonts/ss-standard.svg +404 -0
  9. data/vendor/assets/boletia_ui/fonts/ss-standard.ttf +0 -0
  10. data/vendor/assets/boletia_ui/fonts/ss-standard.woff +0 -0
  11. data/vendor/assets/boletia_ui/images/cancel.png +0 -0
  12. data/vendor/assets/boletia_ui/images/check.png +0 -0
  13. data/vendor/assets/boletia_ui/images/default-search.png +0 -0
  14. data/vendor/assets/boletia_ui/images/download.png +0 -0
  15. data/vendor/assets/boletia_ui/images/edit.png +0 -0
  16. data/vendor/assets/boletia_ui/images/icon-logo140.png +0 -0
  17. data/vendor/assets/boletia_ui/images/logo/header-logo-black.png +0 -0
  18. data/vendor/assets/boletia_ui/images/logo/header-logo-white.png +0 -0
  19. data/vendor/assets/boletia_ui/images/logo/icon-logo140.png +0 -0
  20. data/vendor/assets/boletia_ui/images/resend.png +0 -0
  21. data/vendor/assets/boletia_ui/images/trash.png +0 -0
  22. data/vendor/assets/boletia_ui/images/trophy.png +0 -0
  23. data/vendor/assets/boletia_ui/images/white-resend.png +0 -0
  24. data/vendor/assets/boletia_ui/images/white-search.png +0 -0
  25. data/vendor/assets/boletia_ui/javascripts/boletia-ui/boletia-ui-components.js +117 -0
  26. data/vendor/assets/boletia_ui/javascripts/boletia-ui/classie.js +80 -0
  27. data/vendor/assets/boletia_ui/javascripts/boletia-ui/select_fx.js +335 -0
  28. data/vendor/assets/boletia_ui/javascripts/charts/Chart.Legend.js +56 -0
  29. data/vendor/assets/boletia_ui/javascripts/charts/chart.min.js +11 -0
  30. data/vendor/assets/boletia_ui/javascripts/charts/refundCharts.js +167 -0
  31. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.Bar.js +302 -0
  32. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.Core.js +2002 -0
  33. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.Doughnut.js +184 -0
  34. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.Line.js +374 -0
  35. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.PolarArea.js +250 -0
  36. data/vendor/assets/boletia_ui/javascripts/charts/src/Chart.Radar.js +343 -0
  37. data/vendor/assets/boletia_ui/javascripts/counter/counter.js +12 -0
  38. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  39. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  40. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_flat_55_ffffff_40x100.png +0 -0
  41. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  42. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  43. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
  44. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
  45. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  46. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-icons_0073ea_256x240.png +0 -0
  47. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
  48. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-icons_666666_256x240.png +0 -0
  49. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-icons_ff0084_256x240.png +0 -0
  50. data/vendor/assets/boletia_ui/javascripts/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  51. data/vendor/assets/boletia_ui/javascripts/jquery-ui/jquery-ui.min.js +8 -0
  52. data/vendor/assets/boletia_ui/javascripts/scrolling-header/scrolling-header.js +41 -0
  53. data/vendor/assets/boletia_ui/javascripts/styleguide/styleguide.js +87 -0
  54. data/vendor/assets/boletia_ui/javascripts/tooltips/jquery.tooltipster.min.js +1 -0
  55. data/vendor/assets/boletia_ui/javascripts/vendor/magnific-popup/core.js +966 -0
  56. data/vendor/assets/boletia_ui/javascripts/vendor/magnific-popup/fastclick.js +93 -0
  57. data/vendor/assets/boletia_ui/javascripts/vendor/magnific-popup/image.js +245 -0
  58. data/vendor/assets/boletia_ui/javascripts/vendor/magnific-popup/inline.js +66 -0
  59. data/vendor/assets/boletia_ui/stylesheets/boletia-admin.css.scss +41 -0
  60. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.css +53 -0
  61. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.eot +0 -0
  62. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.js +84 -0
  63. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.svg +404 -0
  64. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.ttf +0 -0
  65. data/vendor/assets/boletia_ui/stylesheets/fonts/ss-standard.woff +0 -0
  66. data/vendor/assets/boletia_ui/stylesheets/jquery-ui/jquery-ui.min.css +7 -0
  67. data/vendor/assets/boletia_ui/stylesheets/jquery-ui/jquery-ui.structure.min.css +5 -0
  68. data/vendor/assets/boletia_ui/stylesheets/jquery-ui/jquery-ui.theme.css +410 -0
  69. data/vendor/assets/boletia_ui/stylesheets/layouts/_event_details.scss +100 -0
  70. data/vendor/assets/boletia_ui/stylesheets/layouts/_refund-wizard.scss +290 -0
  71. data/vendor/assets/boletia_ui/stylesheets/layouts/_sales.scss +17 -0
  72. data/vendor/assets/boletia_ui/stylesheets/layouts/_style_guide.scss +216 -0
  73. data/vendor/assets/boletia_ui/stylesheets/menu/_footer.scss +117 -0
  74. data/vendor/assets/boletia_ui/stylesheets/menu/_header.scss +314 -0
  75. data/vendor/assets/boletia_ui/stylesheets/menu/_new_front_footer.scss +117 -0
  76. data/vendor/assets/boletia_ui/stylesheets/menu/_new_front_header.scss +314 -0
  77. data/vendor/assets/boletia_ui/stylesheets/partials/_alerts.scss +183 -0
  78. data/vendor/assets/boletia_ui/stylesheets/partials/_base.scss +376 -0
  79. data/vendor/assets/boletia_ui/stylesheets/partials/_boletia-cards.scss +401 -0
  80. data/vendor/assets/boletia_ui/stylesheets/partials/_buttons.scss +200 -0
  81. data/vendor/assets/boletia_ui/stylesheets/partials/_dashboard.scss +192 -0
  82. data/vendor/assets/boletia_ui/stylesheets/partials/_forms.scss +395 -0
  83. data/vendor/assets/boletia_ui/stylesheets/partials/_grid.scss +85 -0
  84. data/vendor/assets/boletia_ui/stylesheets/partials/_tables.scss +139 -0
  85. data/vendor/assets/boletia_ui/stylesheets/partials/_wizard.scss +125 -0
  86. data/vendor/assets/boletia_ui/stylesheets/vendor/_select.scss +109 -0
  87. data/vendor/assets/boletia_ui/stylesheets/vendor/magnific-popup/_magnific.scss +642 -0
  88. data/vendor/assets/boletia_ui/stylesheets/vendor/magnific-popup/_settings.scss +45 -0
  89. data/vendor/assets/boletia_ui/stylesheets/vendor/tooltipster.css +274 -0
  90. metadata +174 -0
@@ -0,0 +1,117 @@
1
+ $(document).ready(function() {
2
+
3
+
4
+ //Tooltip Initialize
5
+
6
+ $('.js-tooltip--top').tooltipster({
7
+ theme: 'o-tooltip',
8
+ position: 'top',
9
+ iconDesktop: true
10
+ });
11
+
12
+
13
+
14
+ $('.js-tooltip--right').tooltipster({
15
+ theme: 'o-tooltip',
16
+ position: 'right',
17
+ iconDesktop: true
18
+ });
19
+
20
+
21
+ $('.js-tooltip--bottom').tooltipster({
22
+ theme: 'o-tooltip',
23
+ position: 'bottom',
24
+ iconDesktop: true
25
+ });
26
+
27
+
28
+ $('.js-tooltip--left').tooltipster({
29
+ theme: 'o-tooltip',
30
+ position: 'left',
31
+ iconDesktop: true
32
+ });
33
+
34
+
35
+
36
+ //Tooltip No Icons
37
+
38
+ $('.js-tooltip__no-icon--top').tooltipster({
39
+ theme: 'o-tooltip',
40
+ position: 'top'
41
+ });
42
+
43
+
44
+
45
+ $('.js-tooltip__no-icon--right').tooltipster({
46
+ theme: 'o-tooltip',
47
+ position: 'right'
48
+ });
49
+
50
+
51
+ $('.js-tooltip__no-icon--bottom').tooltipster({
52
+ theme: 'o-tooltip',
53
+ position: 'bottom'
54
+ });
55
+
56
+
57
+ $('.js-tooltip__no-icon--left').tooltipster({
58
+ theme: 'o-tooltip',
59
+ position: 'left'
60
+ });
61
+
62
+
63
+
64
+
65
+ $('.js-tooltip__badge').tooltipster({
66
+ theme: 'o-tooltip',
67
+ position: 'top'
68
+ });
69
+
70
+
71
+ //Date Picker
72
+
73
+ $( ".js-datepicker" ).datepicker();
74
+
75
+
76
+
77
+ //Auto Complete
78
+
79
+ var availableEvents = [
80
+ "Spartan Race Monterrey",
81
+ "The Color Run",
82
+ "Festival de Bahidora",
83
+ "NRMl",
84
+ "Tough Mudder Monterrey",
85
+ "Badwater Ultramaraton",
86
+ "Carrera Brutal",
87
+ "Epic Queen: Monterrey Chapter",
88
+ "Startup Grind",
89
+ "WWE Raw"
90
+ ];
91
+
92
+
93
+ $( "#js-header-search__input" ).autocomplete({
94
+ source: availableEvents,
95
+ position: { my : "left top", at: "left top" }
96
+ }).autocomplete("widget").addClass("o-header-search__autocomplete");
97
+
98
+
99
+ // MODALS
100
+
101
+
102
+ $('.js-modal-box__action').magnificPopup({
103
+ type:'inline',
104
+ midClick: true,
105
+ closeBtnInside:true
106
+ });
107
+
108
+ //Alerts
109
+
110
+ $(".o-system-message__close").on('click', function(event) {
111
+
112
+ $(event.target).closest(".o-system-message").fadeOut("slow");
113
+
114
+ });
115
+
116
+
117
+ });
@@ -0,0 +1,80 @@
1
+ /*!
2
+ * classie - class helper functions
3
+ * from bonzo https://github.com/ded/bonzo
4
+ *
5
+ * classie.has( elem, 'my-class' ) -> true/false
6
+ * classie.add( elem, 'my-new-class' )
7
+ * classie.remove( elem, 'my-unwanted-class' )
8
+ * classie.toggle( elem, 'my-class' )
9
+ */
10
+
11
+ /*jshint browser: true, strict: true, undef: true */
12
+ /*global define: false */
13
+
14
+ ( function( window ) {
15
+
16
+ 'use strict';
17
+
18
+ // class helper functions from bonzo https://github.com/ded/bonzo
19
+
20
+ function classReg( className ) {
21
+ return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
22
+ }
23
+
24
+ // classList support for class management
25
+ // altho to be fair, the api sucks because it won't accept multiple classes at once
26
+ var hasClass, addClass, removeClass;
27
+
28
+ if ( 'classList' in document.documentElement ) {
29
+ hasClass = function( elem, c ) {
30
+ return elem.classList.contains( c );
31
+ };
32
+ addClass = function( elem, c ) {
33
+ elem.classList.add( c );
34
+ };
35
+ removeClass = function( elem, c ) {
36
+ elem.classList.remove( c );
37
+ };
38
+ }
39
+ else {
40
+ hasClass = function( elem, c ) {
41
+ return classReg( c ).test( elem.className );
42
+ };
43
+ addClass = function( elem, c ) {
44
+ if ( !hasClass( elem, c ) ) {
45
+ elem.className = elem.className + ' ' + c;
46
+ }
47
+ };
48
+ removeClass = function( elem, c ) {
49
+ elem.className = elem.className.replace( classReg( c ), ' ' );
50
+ };
51
+ }
52
+
53
+ function toggleClass( elem, c ) {
54
+ var fn = hasClass( elem, c ) ? removeClass : addClass;
55
+ fn( elem, c );
56
+ }
57
+
58
+ var classie = {
59
+ // full names
60
+ hasClass: hasClass,
61
+ addClass: addClass,
62
+ removeClass: removeClass,
63
+ toggleClass: toggleClass,
64
+ // short names
65
+ has: hasClass,
66
+ add: addClass,
67
+ remove: removeClass,
68
+ toggle: toggleClass
69
+ };
70
+
71
+ // transport
72
+ if ( typeof define === 'function' && define.amd ) {
73
+ // AMD
74
+ define( classie );
75
+ } else {
76
+ // browser global
77
+ window.classie = classie;
78
+ }
79
+
80
+ })( window );
@@ -0,0 +1,335 @@
1
+ // SELECT FX //
2
+
3
+ /**
4
+ * selectFx.js v1.0.0
5
+ * http://www.codrops.com
6
+ *
7
+ * Licensed under the MIT license.
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * Copyright 2014, Codrops
11
+ * http://www.codrops.com
12
+ */
13
+ ;( function( window ) {
14
+
15
+ 'use strict';
16
+
17
+ /**
18
+ * based on from https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js
19
+ */
20
+ function hasParent( e, p ) {
21
+ if (!e) return false;
22
+ var el = e.target||e.srcElement||e||false;
23
+ while (el && el != p) {
24
+ el = el.parentNode||false;
25
+ }
26
+ return (el!==false);
27
+ };
28
+
29
+ /**
30
+ * extend obj function
31
+ */
32
+ function extend( a, b ) {
33
+ for( var key in b ) {
34
+ if( b.hasOwnProperty( key ) ) {
35
+ a[key] = b[key];
36
+ }
37
+ }
38
+ return a;
39
+ }
40
+
41
+ /**
42
+ * SelectFx function
43
+ */
44
+ function SelectFx( el, options ) {
45
+ this.el = el;
46
+ this.options = extend( {}, this.options );
47
+ extend( this.options, options );
48
+ this._init();
49
+ }
50
+
51
+ /**
52
+ * SelectFx options
53
+ */
54
+ SelectFx.prototype.options = {
55
+ // if true all the links will open in a new tab.
56
+ // if we want to be redirected when we click an option, we need to define a data-link attr on the option of the native select element
57
+ newTab : true,
58
+ // when opening the select element, the default placeholder (if any) is shown
59
+ stickyPlaceholder : true,
60
+ // callback when changing the value
61
+ onChange : function( val ) { return false; }
62
+ }
63
+
64
+ /**
65
+ * init function
66
+ * initialize and cache some vars
67
+ */
68
+ SelectFx.prototype._init = function() {
69
+ // check if we are using a placeholder for the native select box
70
+ // we assume the placeholder is disabled and selected by default
71
+ var selectedOpt = this.el.querySelector( 'option[selected]' );
72
+ this.hasDefaultPlaceholder = selectedOpt && selectedOpt.disabled;
73
+
74
+ // get selected option (either the first option with attr selected or just the first option)
75
+ this.selectedOpt = selectedOpt || this.el.querySelector( 'option' );
76
+
77
+ // create structure
78
+ this._createSelectEl();
79
+
80
+ // all options
81
+ this.selOpts = [].slice.call( this.selEl.querySelectorAll( 'li[data-option]' ) );
82
+
83
+ // total options
84
+ this.selOptsCount = this.selOpts.length;
85
+
86
+ // current index
87
+ this.current = this.selOpts.indexOf( this.selEl.querySelector( 'li.js-custom-selected' ) ) || -1;
88
+
89
+ // placeholder elem
90
+ this.selPlaceholder = this.selEl.querySelector( 'span.cs-placeholder' );
91
+
92
+ // init events
93
+ this._initEvents();
94
+ }
95
+
96
+ /**
97
+ * creates the structure for the select element
98
+ */
99
+ SelectFx.prototype._createSelectEl = function() {
100
+ var self = this, options = '', createOptionHTML = function(el) {
101
+ var optclass = '', classes = '', link = '';
102
+
103
+ if( el.selectedOpt && !this.foundSelected && !this.hasDefaultPlaceholder ) {
104
+ classes += 'js-custom-selected ';
105
+ this.foundSelected = true;
106
+ }
107
+ // extra classes
108
+ if( el.getAttribute( 'data-class' ) ) {
109
+ classes += el.getAttribute( 'data-class' );
110
+ }
111
+ // link options
112
+ if( el.getAttribute( 'data-link' ) ) {
113
+ link = 'data-link=' + el.getAttribute( 'data-link' );
114
+ }
115
+
116
+ if( classes !== '' ) {
117
+ optclass = 'class="' + classes + '" ';
118
+ }
119
+
120
+ return '<li ' + optclass + link + ' data-option data-value="' + el.value + '"><span>' + el.textContent + '</span></li>';
121
+ };
122
+
123
+ [].slice.call( this.el.children ).forEach( function(el) {
124
+ if( el.disabled ) { return; }
125
+
126
+ var tag = el.tagName.toLowerCase();
127
+
128
+ if( tag === 'option' ) {
129
+ options += createOptionHTML(el);
130
+ }
131
+ else if( tag === 'optgroup' ) {
132
+ options += '<li class="cs-optgroup"><span>' + el.label + '</span><ul>';
133
+ [].slice.call( el.children ).forEach( function(opt) {
134
+ options += createOptionHTML(opt);
135
+ } );
136
+ options += '</ul></li>';
137
+ }
138
+ } );
139
+
140
+ var opts_el = '<div class="cs-options"><ul>' + options + '</ul></div>';
141
+ this.selEl = document.createElement( 'div' );
142
+ this.selEl.className = this.el.className;
143
+ this.selEl.tabIndex = this.el.tabIndex;
144
+ this.selEl.innerHTML = '<span class="cs-placeholder">' + this.selectedOpt.textContent + '</span>' + opts_el;
145
+ this.el.parentNode.appendChild( this.selEl );
146
+ this.selEl.appendChild( this.el );
147
+ }
148
+
149
+ /**
150
+ * initialize the events
151
+ */
152
+ SelectFx.prototype._initEvents = function() {
153
+ var self = this;
154
+
155
+ // open/close select
156
+ this.selPlaceholder.addEventListener( 'click', function() {
157
+ self._toggleSelect();
158
+ } );
159
+
160
+ // clicking the options
161
+ this.selOpts.forEach( function(opt, idx) {
162
+ opt.addEventListener( 'click', function() {
163
+ self.current = idx;
164
+ self._changeOption();
165
+ // close select elem
166
+ self._toggleSelect();
167
+ } );
168
+ } );
169
+
170
+ // close the select element if the target it´s not the select element or one of its descendants..
171
+ document.addEventListener( 'click', function(ev) {
172
+ var target = ev.target;
173
+ if( self._isOpen() && target !== self.selEl && !hasParent( target, self.selEl ) ) {
174
+ self._toggleSelect();
175
+ }
176
+ } );
177
+
178
+ // keyboard navigation events
179
+ this.selEl.addEventListener( 'keydown', function( ev ) {
180
+ var keyCode = ev.keyCode || ev.which;
181
+
182
+ switch (keyCode) {
183
+ // up key
184
+ case 38:
185
+ ev.preventDefault();
186
+ self._navigateOpts('prev');
187
+ break;
188
+ // down key
189
+ case 40:
190
+ ev.preventDefault();
191
+ self._navigateOpts('next');
192
+ break;
193
+ // space key
194
+ case 32:
195
+ ev.preventDefault();
196
+ if( self._isOpen() && typeof self.preSelCurrent != 'undefined' && self.preSelCurrent !== -1 ) {
197
+ self._changeOption();
198
+ }
199
+ self._toggleSelect();
200
+ break;
201
+ // enter key
202
+ case 13:
203
+ ev.preventDefault();
204
+ if( self._isOpen() && typeof self.preSelCurrent != 'undefined' && self.preSelCurrent !== -1 ) {
205
+ self._changeOption();
206
+ self._toggleSelect();
207
+ }
208
+ break;
209
+ // esc key
210
+ case 27:
211
+ ev.preventDefault();
212
+ if( self._isOpen() ) {
213
+ self._toggleSelect();
214
+ }
215
+ break;
216
+ }
217
+ } );
218
+ }
219
+
220
+ /**
221
+ * navigate with up/dpwn keys
222
+ */
223
+ SelectFx.prototype._navigateOpts = function(dir) {
224
+ if( !this._isOpen() ) {
225
+ this._toggleSelect();
226
+ }
227
+
228
+ var tmpcurrent = typeof this.preSelCurrent != 'undefined' && this.preSelCurrent !== -1 ? this.preSelCurrent : this.current;
229
+
230
+ if( dir === 'prev' && tmpcurrent > 0 || dir === 'next' && tmpcurrent < this.selOptsCount - 1 ) {
231
+ // save pre selected current - if we click on option, or press enter, or press space this is going to be the index of the current option
232
+ this.preSelCurrent = dir === 'next' ? tmpcurrent + 1 : tmpcurrent - 1;
233
+ // remove focus class if any..
234
+ this._removeFocus();
235
+ // add class focus - track which option we are navigating
236
+ classie.add( this.selOpts[this.preSelCurrent], 'cs-focus' );
237
+ }
238
+ }
239
+
240
+ /**
241
+ * open/close select
242
+ * when opened show the default placeholder if any
243
+ */
244
+ SelectFx.prototype._toggleSelect = function() {
245
+ // remove focus class if any..
246
+ this._removeFocus();
247
+
248
+ if( this._isOpen() ) {
249
+ if( this.current !== -1 ) {
250
+ // update placeholder text
251
+ this.selPlaceholder.textContent = this.selOpts[ this.current ].textContent;
252
+ }
253
+ classie.remove( this.selEl, 'cs-active' );
254
+ }
255
+ else {
256
+ if( this.hasDefaultPlaceholder && this.options.stickyPlaceholder ) {
257
+ // everytime we open we wanna see the default placeholder text
258
+ this.selPlaceholder.textContent = this.selectedOpt.textContent;
259
+ }
260
+ classie.add( this.selEl, 'cs-active' );
261
+ }
262
+ }
263
+
264
+ /**
265
+ * change option - the new value is set
266
+ */
267
+ SelectFx.prototype._changeOption = function() {
268
+ // if pre selected current (if we navigate with the keyboard)...
269
+ if( typeof this.preSelCurrent != 'undefined' && this.preSelCurrent !== -1 ) {
270
+ this.current = this.preSelCurrent;
271
+ this.preSelCurrent = -1;
272
+ }
273
+
274
+ // current option
275
+ var opt = this.selOpts[ this.current ];
276
+
277
+ // update current selected value
278
+ this.selPlaceholder.textContent = opt.textContent;
279
+
280
+ // change native select element´s value
281
+ this.el.value = opt.getAttribute( 'data-value' );
282
+
283
+ // remove class js-custom-selected from old selected option and add it to current selected option
284
+ var oldOpt = this.selEl.querySelector( 'li.js-custom-selected' );
285
+ if( oldOpt ) {
286
+ classie.remove( oldOpt, 'js-custom-selected' );
287
+ }
288
+ classie.add( opt, 'js-custom-selected' );
289
+
290
+ // if there´s a link defined
291
+ if( opt.getAttribute( 'data-link' ) ) {
292
+ // open in new tab?
293
+ if( this.options.newTab ) {
294
+ window.open( opt.getAttribute( 'data-link' ), '_blank' );
295
+ }
296
+ else {
297
+ window.location = opt.getAttribute( 'data-link' );
298
+ }
299
+ }
300
+
301
+ // callback
302
+ this.options.onChange( this.el.value );
303
+ }
304
+
305
+ /**
306
+ * returns true if select element is opened
307
+ */
308
+ SelectFx.prototype._isOpen = function(opt) {
309
+ return classie.has( this.selEl, 'cs-active' );
310
+ }
311
+
312
+ /**
313
+ * removes the focus class from the option
314
+ */
315
+ SelectFx.prototype._removeFocus = function(opt) {
316
+ var focusEl = this.selEl.querySelector( 'li.cs-focus' )
317
+ if( focusEl ) {
318
+ classie.remove( focusEl, 'cs-focus' );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * add to global namespace
324
+ */
325
+ window.SelectFx = SelectFx;
326
+
327
+ } )( window );
328
+
329
+
330
+
331
+ (function() {
332
+ [].slice.call( document.querySelectorAll( 'select.js-custom-select' ) ).forEach( function(el) {
333
+ new SelectFx(el);
334
+ } );
335
+ })();
@@ -0,0 +1,56 @@
1
+ function legend(parent, data) {
2
+ legend(parent, data, null);
3
+ }
4
+
5
+ function legend(parent, data, chart) {
6
+ parent.className = 'o-chart-legend';
7
+ var datas = data.hasOwnProperty('datasets') ? data.datasets : data;
8
+
9
+ // remove possible children of the parent
10
+ while(parent.hasChildNodes()) {
11
+ parent.removeChild(parent.lastChild);
12
+ }
13
+
14
+ var show = chart ? showTooltip : noop;
15
+ datas.forEach(function(d, i) {
16
+ //span to div: legend appears to all element (color-sample and text-node)
17
+ var title = document.createElement('div');
18
+ title.className = 'o-chart-legend__title';
19
+ parent.appendChild(title);
20
+
21
+ var colorSample = document.createElement('div');
22
+ colorSample.className = 'o-chart-legend__color-sample';
23
+ colorSample.style.backgroundColor = d.hasOwnProperty('strokeColor') ? d.strokeColor : d.color;
24
+ colorSample.style.borderColor = d.hasOwnProperty('fillColor') ? d.fillColor : d.color;
25
+ title.appendChild(colorSample);
26
+
27
+ var text = document.createTextNode(d.label);
28
+ text.className = 'text-node';
29
+ title.appendChild(text);
30
+
31
+ show(chart, title, i);
32
+ });
33
+ }
34
+
35
+ //add events to legend that show tool tips on chart
36
+ function showTooltip(chart, elem, indexChartSegment){
37
+ var helpers = Chart.helpers;
38
+
39
+ var segments = chart.segments;
40
+ //Only chart with segments
41
+ if(typeof segments != 'undefined'){
42
+ helpers.addEvent(elem, 'mouseover', function(){
43
+ var segment = segments[indexChartSegment];
44
+ segment.save();
45
+ segment.fillColor = segment.highlightColor;
46
+ chart.showTooltip([segment]);
47
+ segment.restore();
48
+ });
49
+
50
+ helpers.addEvent(elem, 'mouseout', function(){
51
+ chart.draw();
52
+ });
53
+ }
54
+ }
55
+
56
+ function noop() {}