hooch 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d46b1d125a54db65d38c774891a6d280606dc2
4
- data.tar.gz: f09246082764875128292c08efe811899139a95d
3
+ metadata.gz: e56e7102014803050f4adfd86a6516888c892ad9
4
+ data.tar.gz: d79a2c3b4b0a82e92ebf00a002f9a629e65b2cae
5
5
  SHA512:
6
- metadata.gz: 5a3e9cbf2b5949b6d5be9e222a3062c7e1b2473911a623bb09a40ce1ea7bdf3ee2a0d3d5933056ce43b0138812f1852227f37f08562aee37fda7f97501373de2
7
- data.tar.gz: 26856ff5a52020117659dfe543e89be1bb360dd035fbeee9c09ce3bf9c660f24146b96003dd9edbeed06d029399bc19d0c7480b358ba082b227bebf90c82ddf2
6
+ metadata.gz: ae3a9d1b3402d667845c9fe62400da0159fdd3f0b2f9116427a2ce69b0e35bc56c4667b5007b78b2ba59efea4b0a26246303385ff6a2256c85affa65b4ea7338
7
+ data.tar.gz: 22dd95cf4abfddd15cead157b953218af99911f9a025becc867da5ed491d71abcf125220931a93cd7d3fa522ac5262e65201a1b7f7889a2fdde8ab84b0c0bd77
data/.gitignore CHANGED
@@ -12,3 +12,38 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.rbc
16
+ capybara-*.html
17
+ .rspec
18
+ /log
19
+ /tmp
20
+ /db/*.sqlite3
21
+ /db/*.sqlite3-journal
22
+ /public/system
23
+ /coverage/
24
+ /spec/tmp
25
+ **.orig
26
+ rerun.txt
27
+ pickle-email-*.html
28
+
29
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
30
+ config/initializers/secret_token.rb
31
+ config/secrets.yml
32
+
33
+ ## Environment normalisation:
34
+ /.bundle
35
+ /vendor/bundle
36
+
37
+ # these should all be checked in to normalise the environment:
38
+ # Gemfile.lock, .ruby-version, .ruby-gemset
39
+
40
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
41
+ .rvmrc
42
+
43
+ # if using bower-rails ignore default bower_components path bower.json files
44
+ /vendor/assets/bower_components
45
+ *.bowerrc
46
+ bower.json
47
+
48
+ # Ignore pow environment settings
49
+ .powenv
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Eric Draut
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,642 @@
1
+ var Toggler = Class.extend({
2
+ init: function(jq_obj){
3
+ this.jq_obj = jq_obj;
4
+ this.label = jq_obj.data('toggler');
5
+ this.value = jq_obj.val();
6
+ this.targets = $('[data-toggle_trigger="' + this.label + '"]');
7
+ this.targets.hide();
8
+ this.targets.filter('[data-toggle_value="' + this.value + '"]').show();
9
+ }
10
+ });
11
+
12
+ var HoverOverflow = Class.extend({
13
+ init: function(jq_obj){
14
+ this.old_border = jq_obj.css('border-right');
15
+ this.old_z_index = jq_obj.css('z-index');
16
+ var hoverable = this;
17
+ jq_obj.bind('mouseover',function(){
18
+ hoverable.jq_obj.css({'overflow':'visible','z-index':'10000','border-right':'1px solid white'});
19
+ });
20
+ jq_obj.bind('mouseout',function(){
21
+ hoverable.jq_obj.css({'overflow':'hidden','z-index':hoverable.old_z_index,'border-right':hoverable.old_border});
22
+ });
23
+ }
24
+ })
25
+
26
+ var HoverReveal = Class.extend({
27
+ init: function($hover_revealer){
28
+ $revealable = $hover_revealer.data('revealable')
29
+ jq_obj.bind('mouseover',function(){
30
+ $revealable.show();
31
+ });
32
+ jq_obj.bind('mouseout',function(){
33
+ $revealable.hide();
34
+ });
35
+
36
+ }
37
+ })
38
+
39
+ var HideyButton = Class.extend({
40
+ init: function($hidey_button){
41
+ $hidey_button.hide();
42
+ this.form = $hidey_button.parents('form');
43
+ this.$hidey_button = $hidey_button;
44
+ this.bindInputs();
45
+ },
46
+ bindInputs: function(){
47
+ this.inputs = this.form.find('input,select,textarea');
48
+ var hidey_button = this;
49
+ this.cache_input_values();
50
+ this.inputs.each(function(){
51
+ $(this).bind("propertychange keyup input paste datechange change",function(){
52
+ if(hidey_button.form_changed()){
53
+ hidey_button.$hidey_button.show();
54
+ } else {
55
+ hidey_button.$hidey_button.hide();
56
+ }
57
+ })
58
+ });
59
+ },
60
+ cache_input_values: function(){
61
+ this.inputs.each(function(){
62
+ if($(this).is(":checkbox")){
63
+ $(this).data('oldstate',$(this).is(':checked'));
64
+ } else {
65
+ $(this).data('oldval',$(this).val());
66
+ }
67
+ })
68
+ },
69
+ form_changed: function(){
70
+ var changed = false;
71
+ this.inputs.each(function(){
72
+ if($(this).is(":checkbox")){
73
+ if($(this).data('oldstate') != $(this).is(':checked')){
74
+ changed = true;
75
+ return false;
76
+ }
77
+ }else{
78
+ if($(this).data('oldval') != $(this).val()){
79
+ changed = true;
80
+ return false;
81
+ }
82
+ }
83
+ })
84
+ return changed;
85
+ }
86
+ })
87
+ var Expandable = Class.extend({
88
+ init: function($expandable){
89
+ this.$expandable = $expandable;
90
+ $expandable.data('expandable',this);
91
+ $collapser = $('[data-expand-id="' + $expandable.data('expand-id') + '"][data-collapser]');
92
+ if($collapser.length > 0){
93
+ this.collapser = new Collapser($collapser,this);
94
+ }
95
+ this.$expander = $('[data-expand-id="' + $expandable.data('expand-id') + '"][data-expander]');
96
+ this.expander = new Expander(this.$expander,this);
97
+ this.initial_state = $expandable.data('expand-state');
98
+ if(this.initial_state == 'expanded'){
99
+ this.expand();
100
+ } else {
101
+ this.collapse();
102
+ }
103
+ },
104
+ expand: function(){
105
+ if(this.collapser){
106
+ this.expander.hide();
107
+ this.collapser.show();
108
+ }
109
+ this.$expandable.show(10);
110
+ },
111
+ collapse: function(){
112
+ if(this.collapser){
113
+ this.collapser.hide();
114
+ this.expander.show();
115
+ }
116
+ this.$expandable.hide(10);
117
+ },
118
+ toggle: function(){
119
+ this.$expandable.toggle(10);
120
+ }
121
+ });
122
+ var AjaxExpandable = Expandable.extend({
123
+ expand: function(){
124
+ if(!this.ajax_loaded){
125
+ this.ajax_loaded = true;
126
+ new AjaxLinkSubmission(this.$expander);
127
+ }
128
+ this._super();
129
+ }
130
+ });
131
+ var Expander = Class.extend({
132
+ init: function($expander,target){
133
+ this.$expander = $expander;
134
+ if($expander.data('fake-dropdown')){
135
+ target.$expandable.on('click',function(){
136
+ target.toggle();
137
+ })
138
+ target.$expandable.on('mouseleave',function(){
139
+ target.collapse();
140
+ })
141
+ }
142
+ $expander.bind('click',function(){
143
+ if(target.collapser){
144
+ target.expand();
145
+ } else {
146
+ target.toggle();
147
+ }
148
+ })
149
+ },
150
+ hide: function(){
151
+ this.$expander.hide();
152
+ },
153
+ show: function(){
154
+ this.$expander.show();
155
+ }
156
+ });
157
+ var Collapser = Class.extend({
158
+ init: function($collapser,target){
159
+ this.$collapser = $collapser;
160
+ $collapser.bind('click',function(){
161
+ target.collapse();
162
+ })
163
+ },
164
+ hide: function(){
165
+ this.$collapser.hide();
166
+ },
167
+ show: function(){
168
+ this.$collapser.show();
169
+ }
170
+ })
171
+ var DisableForms = Class.extend({
172
+ init: function($disable_container){
173
+ $disable_container.find('input, select').each(function(){
174
+ $(this).prop('disabled',true);
175
+ });
176
+ }
177
+ })
178
+
179
+ // Note: the method and variable names in this class are somehow creepy
180
+
181
+ var Revealer = Class.extend({
182
+ init: function($revealer){
183
+ var revealer = this;
184
+ this.$revealer = $revealer;
185
+ this.children_id = this.$revealer.data('revealer-children-id');
186
+ this.$all_children = $('[data-revealer_id="' + this.children_id + '"]');
187
+ $revealer.bind('change',function(){
188
+ revealer.reveal();
189
+ });
190
+ revealer.reveal();
191
+ },
192
+ reveal: function(){
193
+ var sanitized_value = this.$revealer.val();
194
+ this.$children = [];
195
+ var revealer = this;
196
+ this.$all_children.each(function(){
197
+ var triggers = $(this).data('revealer-triggers');
198
+ if(triggers){
199
+ var revelation_triggers = eval('(' + triggers + ')');
200
+ if($.inArray(sanitized_value,revelation_triggers) > -1){
201
+ revealer.$children.push($(this));
202
+ }
203
+ } else {
204
+ if(sanitized_value == $(this).data('revealer-trigger')){
205
+ revealer.$children.push($(this));
206
+ }
207
+ }
208
+ })
209
+ this.hideChildren();
210
+ this.revealChosenOnes();
211
+ },
212
+ hideChildren: function(){
213
+ this.$all_children.hide();
214
+ },
215
+ revealChosenOnes: function(){
216
+ $.each(this.$children,function(){ $(this).show(); });
217
+ }
218
+ });
219
+
220
+ var FormFieldRevealer = Revealer.extend({
221
+ init: function($revealer){
222
+ this.children_id = $revealer.data('revealer-children-id');
223
+ this.$revelation_target = $('[data-revealer-target="' + this.children_id + '"]');
224
+ this._super($revealer);
225
+ },
226
+ hideChildren: function(){
227
+ this._super();
228
+ this.$form = this.$revealer.parents('form:first')
229
+ if(this.$form.length > 0){
230
+ this.$form.after(this.$all_children)
231
+ }
232
+ },
233
+ revealChosenOnes: function(){
234
+ this.$revelation_target.html(this.$children);
235
+ this._super();
236
+ }
237
+ });
238
+
239
+ var TabGroup = Class.extend({
240
+ init: function($tab_group){
241
+ this.$tab_group = $tab_group;
242
+ this.getName();
243
+ this.tab_triggers = [];
244
+ this.tab_triggers_by_id = {};
245
+ this.getTabTriggerClass();
246
+ this.createTabs();
247
+ this.getConentParent();
248
+ this.hideAll();
249
+ this.handleDefault();
250
+ TabGroup.addGroup(this);
251
+ },
252
+ createTabs: function(){
253
+ var tab_group = this;
254
+ this.$tab_group.find("[data-tab-trigger]").each(function(){
255
+ var new_tab = new tab_group.tab_trigger_class($(this),tab_group);
256
+ tab_group.tab_triggers.push(new_tab);
257
+ tab_group.tab_triggers_by_id[new_tab.tab_id] = new_tab;
258
+ })
259
+ },
260
+ getTabByPushState: function(state_value){
261
+ var selected_tab = null;
262
+ $.each(this.tab_triggers,function(index,trigger){
263
+ if(trigger.push_state == state_value){
264
+ selected_tab = trigger;
265
+ }
266
+ })
267
+ return selected_tab;
268
+ },
269
+ getName: function(){
270
+ this.name = this.$tab_group.data('tab-group');
271
+ },
272
+ getConentParent: function(){
273
+ this.$content_parent = this.tab_triggers[0].getParent();
274
+ },
275
+ handleDefault: function(){
276
+ if(this.$tab_group.data('default-tab')){
277
+ this.default_tab = this.tab_triggers_by_id[this.$tab_group.data('default-tab')];
278
+ this.default_tab.toggleTarget('replace');
279
+ }
280
+ },
281
+ hideAll: function(trigger){
282
+ $.each(this.tab_triggers,function(){
283
+ this.hideTarget();
284
+ })
285
+ },
286
+ getTabTriggerClass: function(){
287
+ this.tab_trigger_class = TabTrigger;
288
+ },
289
+ deactivateTabTriggers: function(){
290
+ $.each(this.tab_triggers,function(){
291
+ this.$tab_trigger.removeClass('active');
292
+ })
293
+ },
294
+ setActiveTab: function(tab_trigger){
295
+ if(this.active_tab){
296
+ var parent_height = this.$content_parent.height();
297
+ this.$content_parent.css({'height': parent_height, 'overflow': 'hidden'});
298
+ }
299
+ this.hideAll();
300
+ this.deactivateTabTriggers();
301
+ this.active_tab = tab_trigger;
302
+ tab_trigger.revealTarget();
303
+ },
304
+ resize: function(){
305
+ this.$content_parent.css({'height': 'auto', 'overflow': 'visible'});
306
+ },
307
+ getActiveTab: function(){
308
+ return this.active_tab;
309
+ }
310
+ })
311
+ TabGroup.addGroup = function(group){
312
+ if(!TabGroup.all_groups){
313
+ TabGroup.all_groups = [];
314
+ }
315
+ TabGroup.all_groups.push(group);
316
+ }
317
+ TabGroup.find = function(name){
318
+ var selected_group = null;
319
+ $.each(TabGroup.all_groups,function(index,group){
320
+ if(group.name == name){
321
+ selected_group = group;
322
+ }
323
+ });
324
+ return selected_group;
325
+ }
326
+ var AjaxTabGroup = TabGroup.extend({
327
+ getTabTriggerClass: function(){
328
+ this.tab_trigger_class = AjaxTabTrigger;
329
+ }
330
+ })
331
+ var TabTrigger = Class.extend({
332
+ init: function($tab_trigger,tab_group){
333
+ this.$tab_trigger = $tab_trigger;
334
+ this.tab_group = tab_group;
335
+ this.tab_group_name = tab_group.name;
336
+ this.tab_id = $tab_trigger.data('tab-target-id');
337
+ this.getPushState();
338
+ this.getTarget();
339
+ var tab_trigger = this;
340
+ $tab_trigger.on('click', function(e){
341
+ e.preventDefault();
342
+ tab_trigger.toggleTarget()
343
+ })
344
+ },
345
+ getTarget: function(){
346
+ this.$target = $('[data-tab-id="' + this.tab_id + '"]');
347
+ },
348
+ getPushState: function(){
349
+ if(this.$tab_trigger.data('push-state') != null && this.$tab_trigger.data('push-state') != ""){
350
+ this.push_state = this.$tab_trigger.data('push-state')
351
+ }
352
+ },
353
+ toggleTarget: function(state_behavior){
354
+ var was_visible = this.$target.is(':visible');
355
+ if(!was_visible){
356
+ this.tab_group.setActiveTab(this);
357
+ this.resize();
358
+ var change_history = true;
359
+ var history_method = 'pushState'
360
+ if('no history' == state_behavior){
361
+ change_history = false
362
+ } else if('replace' == state_behavior){
363
+ history_method = 'replaceState'
364
+ }
365
+ if (this.push_state && change_history) {
366
+ var current_state = new IhHistoryState(history.state)
367
+ current_state.addState(this.tab_group_name, this.push_state);
368
+ history[history_method](current_state.state, null, current_state.toUrl());
369
+ }
370
+ }
371
+ },
372
+ hideTarget: function(){
373
+ this.$target.hide();
374
+ },
375
+ revealTarget: function(){
376
+ this.$target.show();
377
+ this.$tab_trigger.addClass('active');
378
+ },
379
+ getParent: function(){
380
+ return this.$target.parent();
381
+ },
382
+ resize: function(){
383
+ this.tab_group.resize();
384
+ }
385
+ })
386
+
387
+ var AjaxTabTrigger = TabTrigger.extend({
388
+ toggleTarget: function(pop){
389
+ var tab_group = this.tab_group;
390
+ if(!this.ajax_loaded){
391
+ this.ajax_loaded = true;
392
+ this.$tab_trigger.data('ajax-target','[data-tab-id="' + this.tab_id + '"]')
393
+ new AjaxLinkSubmission(this.$tab_trigger,{'on_complete': function(){tab_group.resize()}});
394
+ this._super(pop);
395
+ } else {
396
+ this._super(pop);
397
+ tab_group.resize()
398
+ }
399
+ },
400
+ resize: function(){
401
+ // noop
402
+ }
403
+ })
404
+ var IhHistoryState = Class.extend({
405
+ init: function(state){
406
+ this.state = jQuery.extend(true, {}, state);
407
+ },
408
+ toQueryString: function(){
409
+ return $.param(this.state)
410
+ },
411
+ toUrl: function(){
412
+ return [location.protocol, '//', location.host, location.pathname, '?', this.toQueryString()].join('');
413
+ },
414
+ addState: function(key,value){
415
+ var new_state = {}
416
+ new_state[key] = value
417
+ this.state = $.extend(true, this.state, new_state);
418
+ }
419
+ })
420
+ var ReplaceDelete = DeleteLink.extend({
421
+ ajaxSuccess: function(data,textStatus,jqXHR){
422
+ this.target[this.insert_method](data);
423
+ },
424
+ ajaxBefore: function(jqXHR){
425
+ //noop
426
+ }
427
+ })
428
+ var GoProxy = Class.extend({
429
+ init: function($proxy){
430
+ this.first_submit = true;
431
+ var go_proxy = this;
432
+ go_proxy.$proxy = $proxy;
433
+ go_proxy.target = go_proxy.getTarget();
434
+ go_proxy.prevent_double_submit = $proxy.data('prevent-double-submit')
435
+ switch($proxy.get(0).nodeName.toLowerCase()){
436
+ case 'input':
437
+ switch($proxy.attr('type')){
438
+ case 'checkbox':
439
+ default:
440
+ $proxy.on('change',function(){
441
+ go_proxy.doItNow();
442
+ })
443
+ break;
444
+ }
445
+ break;
446
+ case 'select':
447
+ $proxy.on('change',function(){
448
+ go_proxy.doItNow();
449
+ })
450
+ break;
451
+ case 'a':
452
+ default:
453
+ $proxy.on('click',function(e){
454
+ e.preventDefault();
455
+ go_proxy.doItNow();
456
+ return false;
457
+ });
458
+ break;
459
+ }
460
+ },
461
+ doable: function(){
462
+ return(this.first_submit || !this.prevent_double_submit)
463
+ }
464
+ });
465
+ var ClickProxy = GoProxy.extend({
466
+ getTarget: function(){
467
+ if(this.$proxy.data('target')){
468
+ return $(this.$proxy.data('target'));
469
+ } else {
470
+ return this.$proxy.siblings('a');
471
+ }
472
+ },
473
+ doItNow: function(){
474
+ if(this.doable) {
475
+ this.target.click();
476
+ this.first_submit = false;
477
+ }
478
+ }
479
+ });
480
+
481
+ var SubmitProxy = GoProxy.extend({
482
+ getTarget: function(){
483
+ if(this.$proxy.data('target')){
484
+ return $(this.$proxy.data('target'));
485
+ } else {
486
+ return this.$proxy.parents('form:first');
487
+ }
488
+ },
489
+ doItNow: function(){
490
+ if(this.doable) {
491
+ this.target.submit();
492
+ this.first_submit = false;
493
+ }
494
+ }
495
+ });
496
+
497
+ var FieldFiller = Class.extend({
498
+ init: function($field_filler){
499
+ this.$field_filler = $field_filler
500
+ this.value = $field_filler.data('value');
501
+ this.target = $($field_filler.data('target'));
502
+ var field_filler = this
503
+ this.$field_filler.bind('click', function(e){field_filler.fill(e)})
504
+ },
505
+ fill: function(e){
506
+ e.preventDefault();
507
+ this.target.val(this.value);
508
+ return false;
509
+ }
510
+ });
511
+
512
+ var Emptier = Class.extend({
513
+ init: function($emptier){
514
+ $target = $($emptier.data('target'));
515
+ $emptier.click(function(e){
516
+ $target.empty();
517
+ })
518
+ }
519
+ });
520
+
521
+ var Remover = Class.extend({
522
+ init: function($remover){
523
+ $target = $($remover.data('target'));
524
+ $remover.click(function(e){
525
+ $target.remove();
526
+ })
527
+ }
528
+ });
529
+
530
+ var Link = Class.extend({
531
+ init: function($link){
532
+ $link.click(function(){
533
+ window.location = $link.attr('href');
534
+ })
535
+ }
536
+ });
537
+
538
+ var CheckboxHiddenProxy = Class.extend({
539
+ init: function($checkbox){
540
+ this.checked_value = $checkbox.data('checked-value');
541
+ this.unchecked_value = $checkbox.data('unchecked-value');
542
+ var target_selector = $checkbox.data('target');
543
+ this.target = $(target_selector);
544
+ var checkbox = this;
545
+ $checkbox.click(function(){
546
+ if ($(this).is(':checked')) {
547
+ checkbox.target.val(checkbox.checked_value);
548
+ } else {
549
+ checkbox.target.val(checkbox.unchecked_value);
550
+ }
551
+ })
552
+ }
553
+ });
554
+
555
+ var PreventDoubleSubmit = Class.extend({
556
+ init: function($clickable){
557
+ this.$clickable = $clickable;
558
+ var double_click_preventer = this;
559
+ switch($clickable.get(0).nodeName.toLowerCase()){
560
+ case 'form':
561
+ $clickable.submit(function(e){ double_click_preventer.preventItNow(); });
562
+ break;
563
+ case 'input':
564
+ $clickable.click(function() {
565
+ setTimeout(function(){
566
+ $clickable.attr("disabled", "disabled");
567
+ }, 10);
568
+ });
569
+ break;
570
+ }
571
+ },
572
+ preventItNow: function(){
573
+ this.$clickable.submit(function(e){ e.preventDefault(); return false; });
574
+ }
575
+ });
576
+
577
+ var PreventDoubleLinkClick = Class.extend({
578
+ init: function($clickable){
579
+ $clickable.click(function(e) {
580
+ if($clickable.data('clicked')) {
581
+ e.preventDefault();
582
+ return false;
583
+ } else {
584
+ $clickable.data('clicked',true);
585
+ return true;
586
+ }
587
+ });
588
+ }
589
+ });
590
+
591
+ var ReloadPage = Class.extend({
592
+ init: function(reload_page){
593
+ window.location.href = reload_page;
594
+ }
595
+ })
596
+
597
+ $(window).bind("popstate", function(e){
598
+ var previous_state = new IhHistoryState(e.originalEvent.state)
599
+ $.each(previous_state.state, function(key,value){
600
+ var tab_group = TabGroup.find(key)
601
+ if(tab_group){
602
+ var tab_trigger = tab_group.getTabByPushState(value)
603
+ if(tab_trigger){
604
+ tab_trigger.toggleTarget('no history');
605
+ }
606
+ }
607
+ })
608
+ });
609
+ $(document).ready(function(){
610
+ $('[data-default_tab="true"]').tab('show');
611
+ $(document).on('change','[data-toggler]',function(){
612
+ new Toggler($(this));
613
+ })
614
+ $('[data-toggler]').each(function(){
615
+ new Toggler($(this));
616
+ })
617
+ $('[data-zendesk_opener]').click(function(){
618
+ $("#zenbox_tab").click();
619
+ })
620
+ $('[data-disable_forms]').each(function(){
621
+ new DisableForms($(this));
622
+ })
623
+ $('[data-link]').each(function(){
624
+ new Link($(this));
625
+ })
626
+ // Initailizes auto complete for select inputs
627
+ $("[data-autocomplete='full_width']").chosen({
628
+ width: "100%"
629
+ });
630
+ $("[data-autocomplete]").chosen();
631
+
632
+ $('[data-redirect-path]:first').each(function(){
633
+ var redirect_seconds = $(this).data('redirect-seconds') * 1000;
634
+ var redirect_path = $(this).data('redirect-path');
635
+ setTimeout(function(){window.location = redirect_path},redirect_seconds);
636
+ })
637
+ $('input,select,textarea').filter(':visible:enabled:first').each(function(){
638
+ if(!$(this).data('date-picker')){
639
+ $(this).focus();
640
+ }
641
+ });
642
+ });
@@ -0,0 +1,49 @@
1
+ module Hooch
2
+ module HoochHelper
3
+ def tab_set(name, type: nil, default_tab: nil)
4
+ if :ajax == type
5
+ type = 'AjaxTabGroup'
6
+ end
7
+ attrs = 'data-tab-group=' + name
8
+ attrs += ' data-sub-type=' + type if type.present?
9
+ attrs += ' data-default-tab=' + default_tab if default_tab.present?
10
+ attrs
11
+ end
12
+
13
+ def tab_trigger(target_id, push_state: nil)
14
+ attrs = 'data-tab-trigger=true data-tab-target-id=' + target_id
15
+ attrs += ' data-push-state=' + push_state if push_state.present?
16
+ attrs
17
+ end
18
+
19
+ def tab_content(id)
20
+ attrs = 'data-tab-id=' + id
21
+ end
22
+
23
+ def expander(id)
24
+ attrs = "data-expander=true data-expand-id=" + id
25
+ end
26
+
27
+ def collapser(id)
28
+ attrs = "data-collapser=true data-expand-id=" + id
29
+ end
30
+
31
+ def collapsed(id, type: nil)
32
+ if :ajax == type
33
+ type = 'AjaxExpandable'
34
+ end
35
+ attrs = "data-expand-state=collapsed data-expand-id=" + id
36
+ attrs += " data-sub-type=" + type if type.present?
37
+ attrs
38
+ end
39
+
40
+ def expanded(id, type: nil)
41
+ if :ajax == type
42
+ type = 'AjaxExpandable'
43
+ end
44
+ attrs = "data-expand-state=expanded data-expand-id=" + id
45
+ attrs += " data-sub-type=" + type if type.present?
46
+ attrs
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ require 'hooch/hooch_helper'
2
+ module Hooch
3
+ class Railtie < Rails::Railtie
4
+ initializer "hooch.hooch_helper" do
5
+ ActionView::Base.send :include, HoochHelper
6
+ end
7
+ end
8
+ end
data/lib/hooch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hooch
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hooch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -49,11 +49,15 @@ extra_rdoc_files: []
49
49
  files:
50
50
  - ".gitignore"
51
51
  - Gemfile
52
+ - LICENSE
52
53
  - LICENSE.txt
53
54
  - README.md
54
55
  - Rakefile
56
+ - app/assets/javascripts/hooch.js
55
57
  - hooch.gemspec
56
58
  - lib/hooch.rb
59
+ - lib/hooch/hooch_helper.rb
60
+ - lib/hooch/railtie.rb
57
61
  - lib/hooch/version.rb
58
62
  homepage: ''
59
63
  licenses: