hooch 0.7.2 → 0.8.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: 5461b89c043f14cd4d087320e0591a565ab53ffa
4
- data.tar.gz: 0cfe8a173eec53e574078854574a763a18a878a3
3
+ metadata.gz: 0c92813e77c493bb42d1d5c0bc0800ee1d8e1834
4
+ data.tar.gz: a058ced5416ddd9b7a6e14fa5575ff000f6e51fc
5
5
  SHA512:
6
- metadata.gz: 111548b3eac2609c26e29d6d989a488d9aef85611aa13c5733af49440e8ba2b21c782958a9edd49aa3bb0b1cf30a88501b22a79fd89944a18084ff29dec7ad6c
7
- data.tar.gz: 30015846fa8cb5d19036f97cb789aea9da3cbcab4024ad605e524399e4d40b8f80ffad3e234c31fe1a16e1a4043ca7440be4f1077c80c6bc60da1952db2c65a8
6
+ metadata.gz: 333e657decbee392ddf437eae2ea5defcd912c2011d3b1b454f5834819b30009083c950b53bdbd5594a66413b474a24c3174ae957e81d6558e746a031581f341
7
+ data.tar.gz: d256173242f5a45f00733e45c619394924fc53ae938face381007c6f27825124cde94b45bc332f97d48dc5b5473cdef59c10c516f8ff0bad18978e94630470cf
@@ -1088,6 +1088,114 @@ var initHooch = function(){
1088
1088
  replaceWith: function($jq_obj){
1089
1089
  this.$sort_element.replaceWith($jq_obj)
1090
1090
  }
1091
+ }),
1092
+ key_code_map: { // borrowed from jresig: https://github.com/jeresig/jquery.hotkeys
1093
+ "backspace": 8,
1094
+ "tab": 9,
1095
+ "return": 10,
1096
+ "return": 13,
1097
+ "shift": 16,
1098
+ "ctrl": 17,
1099
+ "alt": 18,
1100
+ "pause": 19,
1101
+ "capslock": 20,
1102
+ "esc": 27,
1103
+ "space": 32,
1104
+ "pageup": 33,
1105
+ "pagedown": 34,
1106
+ "end": 35,
1107
+ "home": 36,
1108
+ "left": 37,
1109
+ "up": 38,
1110
+ "right": 39,
1111
+ "down": 40,
1112
+ "insert": 45,
1113
+ "del": 46,
1114
+ ";": 59,
1115
+ "=": 61,
1116
+ "0": 96,
1117
+ "1": 97,
1118
+ "2": 98,
1119
+ "3": 99,
1120
+ "4": 100,
1121
+ "5": 101,
1122
+ "6": 102,
1123
+ "7": 103,
1124
+ "8": 104,
1125
+ "9": 105,
1126
+ "*": 106,
1127
+ "+": 107,
1128
+ "-": 109,
1129
+ ".": 110,
1130
+ "/": 111,
1131
+ "f1": 112,
1132
+ "f2": 113,
1133
+ "f3": 114,
1134
+ "f4": 115,
1135
+ "f5": 116,
1136
+ "f6": 117,
1137
+ "f7": 118,
1138
+ "f8": 119,
1139
+ "f9": 120,
1140
+ "f10": 121,
1141
+ "f11": 122,
1142
+ "f12": 123,
1143
+ "numlock": 144,
1144
+ "scroll": 145,
1145
+ "-": 173,
1146
+ ";": 186,
1147
+ "=": 187,
1148
+ ",": 188,
1149
+ "-": 189,
1150
+ ".": 190,
1151
+ "/": 191,
1152
+ "`": 192,
1153
+ "[": 219,
1154
+ "\\": 220,
1155
+ "]": 221,
1156
+ "'": 222
1157
+ },
1158
+ BindKey: Class.extend({
1159
+ init: function($bound_element){
1160
+ this.$bound_element = $bound_element
1161
+ this.element_type = $bound_element.get(0).nodeName.toLowerCase()
1162
+ this.key_name = $bound_element.data('bind-key')
1163
+ if(!this.key_name){
1164
+ console.log("Warning! Hooch key binder couldn't find a key name to bind")
1165
+ return
1166
+ }
1167
+ this.key_code = hooch.key_code_map[this.key_name]
1168
+ if(!this.key_code){
1169
+ console.log('Warning! Hooch key binder could not find a key to bind for the key name ' + this.key_name)
1170
+ return
1171
+ }
1172
+ var key_binder = this
1173
+ $(window).on('keyup', function(e){key_binder.do_it_now(e)} )
1174
+ },
1175
+ do_it_now: function(e){
1176
+ if(this.key_code == e.keyCode){
1177
+ e.preventDefault
1178
+ switch(this.element_type){
1179
+ case 'a':
1180
+ if(this.$bound_element.data('ajax-target')){
1181
+ this.$bound_element.click()
1182
+ } else {
1183
+ window.location = this.$bound_element.attr('href')
1184
+ }
1185
+ break;
1186
+ case 'form':
1187
+ this.$bound_element.submit()
1188
+ break;
1189
+ case 'input':
1190
+ if('submit' == $this.$bound_element.prop('type')){
1191
+ this.$bound_element.click()
1192
+ }
1193
+ default:
1194
+ break;
1195
+ }
1196
+ return false
1197
+ }
1198
+ }
1091
1199
  })
1092
1200
  };
1093
1201
  hooch.SortPlaceholder = hooch.SortElement.extend({
@@ -1213,7 +1321,7 @@ var initHooch = function(){
1213
1321
  ['hover_overflow','hidey_button','submit-proxy','click-proxy','field-filler','revealer',
1214
1322
  'checkbox-hidden-proxy','prevent-double-submit','prevent-double-link-click', 'tab-group',
1215
1323
  'hover-reveal', 'emptier', 'remover', 'checkbox-proxy', 'fake-select', 'select-action-changer',
1216
- 'sorter'],'hooch');
1324
+ 'sorter','bind-key'],'hooch');
1217
1325
  window.any_time_manager.load();
1218
1326
  };
1219
1327
  hooch.pauseEvent = function(e){
@@ -167,5 +167,13 @@ module Hooch
167
167
  def prevent_double_click_hash
168
168
  {"data-prevent-double-click" => true}
169
169
  end
170
+
171
+ def bind_key(key_name)
172
+ {"data-bind-key" => key_name}
173
+ end
174
+
175
+ def bind_key_attrs(key_name)
176
+ "data-bind-key=#{key_name}"
177
+ end
170
178
  end
171
179
  end
@@ -2,7 +2,6 @@ require 'hooch/hooch_helper'
2
2
  module Hooch
3
3
  class Railtie < Rails::Railtie
4
4
  initializer "hooch.hooch_helper" do
5
- puts "initializing hooch helpers"
6
5
  ActionView::Base.send :include, HoochHelper
7
6
  end
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module Hooch
2
- VERSION = "0.7.2"
2
+ VERSION = "0.8.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.7.2
4
+ version: 0.8.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-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails