hooch 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 537457548bc13651ff5a0cd5fdb4c289c9bed85b
4
- data.tar.gz: f740bfa709fd619d94ee26482efb03796a44fb2f
3
+ metadata.gz: f9a38d4ae28c3ecc514f90569f9ac3a2aeb2dd84
4
+ data.tar.gz: aebb4ffb7cf8b1074948882573d42a70ab0484ac
5
5
  SHA512:
6
- metadata.gz: 3f9989d68446177848eec0b53d4805abbbd5134896eac76401b5dc6ea700366f4c375aa07ae8657cf0bac1d21e350935b83e9ce293c3dceb7bbcc65faa6c3946
7
- data.tar.gz: c7fad68f89334bc300295b7abbfc0cbc450a688f9ab1f4ef4b7f656fb74141e9a5c4a8071c11d8010a7af18744499beb4eaae48c2eee215c912e71c93bae3fd3
6
+ metadata.gz: 7357e41994cd20bf8281f91f3c5a4c5c6e15423291a38cc6a41524b57640d1436db20ecc0668fb87cae770a2cfbf535848ecc459ffe9fb5f913f544dd8c102e8
7
+ data.tar.gz: 2cd39841cdc986fe739314d72a4f37dfc3fd096eb701c558beadf242dcfa33af5d7050111a3285f0e2d43a8085512c38c2fd7e7a3db4ec987e965d8e3bd73829
@@ -91,6 +91,101 @@ var initHooch = function(){
91
91
  return changed;
92
92
  }
93
93
  }),
94
+ ModalTrigger: Class.extend({
95
+ init: function($modal_trigger){
96
+ this.$modal_content = $($modal_trigger.data('content-target'))
97
+ var modal_trigger = this
98
+ $modal_trigger.on('click', function(){
99
+ new hooch.Modal(modal_trigger.$modal_content.html())
100
+ })
101
+ }
102
+ }),
103
+ ModalDismisser: Class.extend({
104
+ init: function($dismisser,modal_mask){
105
+ var dismisser = this
106
+ this.modal_mask = modal_mask
107
+ $dismisser.css({cursor: 'pointer'})
108
+ $dismisser.on('click', function(){
109
+ dismisser.modal_mask.close()
110
+ })
111
+ }
112
+ }),
113
+ Modal: Class.extend({
114
+ init: function($modal_content){
115
+ this.$modal_content = $modal_content
116
+ this.setGeometry()
117
+ this.getMask()
118
+ this.getModal()
119
+ this.getDismisser()
120
+ this.getContentWrapper()
121
+ this.disableScroll()
122
+ this.$modal_mask.show()
123
+ },
124
+ setGeometry: function(){
125
+ this.margin = 30;
126
+ this.padding = 30;
127
+ this.mask_top = $(window).scrollTop()
128
+ this.mask_height = $(window).height()
129
+ this.modal_height = this.mask_height - (this.margin*2)
130
+ },
131
+ getMask: function(){
132
+ this.$modal_mask = $('#hooch-mask')
133
+ this.$modal_mask.css({height: this.mask_height + 'px', top: this.mask_top + 'px'})
134
+ },
135
+ getModal: function(){
136
+ this.$modal_element = this.$modal_mask.find('#hooch-modal')
137
+ this.$modal_element.css({'max-height': this.modal_height, 'margin-top': this.margin, 'margin-bottom': this.margin, 'padding-bottom': this.padding, 'padding-left': this.padding, 'padding-right': this.padding})
138
+ },
139
+ getContentWrapper: function(){
140
+ this.$modal_content_wrapper = this.$modal_element.find('#hooch-content')
141
+ var content_height = this.modal_height - (this.padding*2)
142
+ this.$modal_content_wrapper.css({'overflow-y': 'scroll', 'max-height': content_height})
143
+ this.$modal_content_wrapper.html(this.$modal_content)
144
+ },
145
+ getDismisser: function(){
146
+ this.$dismisser = this.$modal_mask.find('#hooch-dismiss')
147
+ this.dismisser = new hooch.ModalDismisser(this.$dismisser,this)
148
+ },
149
+ close: function(){
150
+ this.$modal_mask.hide()
151
+ this.$modal_content_wrapper.empty()
152
+ this.enableScroll()
153
+ },
154
+ disableScroll: function(){
155
+ var modal = this
156
+ modal.old_height = $('body')[0].style.height
157
+ modal.old_overflow = $('body')[0].style.overflow
158
+ $('body').css({height: '100%',overflow: 'hidden'})
159
+ $('body').on({
160
+ 'mousewheel.hoochModalScroll DOMMouseScroll.hoochModalScroll': function(e) {
161
+ if(($(e.target).attr('id') == 'hooch-content') || ($(e.target).parents('#hooch-content').length > 0)){
162
+ var delta = e.originalEvent.wheelDelta
163
+ new_scrolltop = $('#hooch-content').scrollTop() + delta
164
+ $('#hooch-content').scrollTop(new_scrolltop)
165
+ }
166
+ e.preventDefault();
167
+ }
168
+ })
169
+ if (window.addEventListener){ // older FF
170
+ window.addEventListener('DOMMouseScroll', hooch.preventDefault, false)
171
+ }
172
+ window.onwheel = hooch.preventDefault; // modern standard
173
+ window.onmousewheel = document.onmousewheel = hooch.preventDefault; // older browsers, IE
174
+ window.ontouchmove = hooch.preventDefault; // mobile
175
+ document.onkeydown = hooch.preventDefaultForScrollKeys;
176
+ },
177
+ enableScroll: function(){
178
+ $('body').css({height: this.old_height, overflow: this.old_overflow})
179
+ $('body').off('.hoochModalScroll')
180
+ if (window.removeEventListener){
181
+ window.removeEventListener('DOMMouseScroll', hooch.preventDefault, false);
182
+ }
183
+ window.onmousewheel = document.onmousewheel = null;
184
+ window.onwheel = null;
185
+ window.ontouchmove = null;
186
+ document.onkeydown = null;
187
+ }
188
+ }),
94
189
  Expandable: Class.extend({
95
190
  init: function($expandable){
96
191
  var expandable = this;
@@ -1103,6 +1198,7 @@ var initHooch = function(){
1103
1198
  this.$sort_element.replaceWith($jq_obj)
1104
1199
  }
1105
1200
  }),
1201
+ scroll_keys: {37: 1, 38: 1, 39: 1, 40: 1},
1106
1202
  key_code_map: { // borrowed from jresig: https://github.com/jeresig/jquery.hotkeys
1107
1203
  8: "backspace",
1108
1204
  9: "tab",
@@ -1169,6 +1265,18 @@ var initHooch = function(){
1169
1265
  221: "]",
1170
1266
  222: "'"
1171
1267
  },
1268
+ preventDefault: function(e) {
1269
+ e = e || window.event;
1270
+ if (e.preventDefault)
1271
+ e.preventDefault();
1272
+ e.returnValue = false;
1273
+ },
1274
+ preventDefaultForScrollKeys: function(e) {
1275
+ if (hooch.scroll_keys[e.keyCode]) {
1276
+ hooch.preventDefault(e);
1277
+ return false;
1278
+ }
1279
+ },
1172
1280
  BindKey: Class.extend({
1173
1281
  init: function($bound_element){
1174
1282
  this.$bound_element = $bound_element
@@ -1343,7 +1451,7 @@ var initHooch = function(){
1343
1451
  ['hover_overflow','hidey_button','submit-proxy','click-proxy','field-filler','revealer',
1344
1452
  'checkbox-hidden-proxy','prevent-double-submit','prevent-double-link-click', 'tab-group',
1345
1453
  'hover-reveal', 'emptier', 'remover', 'checkbox-proxy', 'fake-select', 'select-action-changer',
1346
- 'sorter','bind-key'],'hooch');
1454
+ 'sorter','bind-key','modal-trigger'],'hooch');
1347
1455
  window.any_time_manager.load();
1348
1456
  };
1349
1457
  hooch.pauseEvent = function(e){
data/lib/hooch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hooch
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hooch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails