jabs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,152 @@
1
+ /*
2
+ * jquery.simulate - simulate browser mouse and keyboard events
3
+ *
4
+ * Copyright (c) 2007 Eduardo Lundgren (eduardolundgren@gmail.com)
5
+ * and Richard D. Worth (rdworth@gmail.com)
6
+ *
7
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
8
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
9
+ *
10
+ */
11
+
12
+ ;(function($) {
13
+
14
+ $.fn.extend({
15
+ simulate: function(type, options) {
16
+ return this.each(function() {
17
+ var opt = $.extend({}, $.simulate.defaults, options || {});
18
+ new $.simulate(this, type, opt);
19
+ });
20
+ }
21
+ });
22
+
23
+ $.simulate = function(el, type, options) {
24
+ this.target = el;
25
+ this.options = options;
26
+
27
+ if (/^drag$/.test(type)) {
28
+ this[type].apply(this, [this.target, options]);
29
+ } else {
30
+ this.simulateEvent(el, type, options);
31
+ }
32
+ }
33
+
34
+ $.extend($.simulate.prototype, {
35
+ simulateEvent: function(el, type, options) {
36
+ var evt = this.createEvent(type, options);
37
+ this.dispatchEvent(el, type, evt, options);
38
+ return evt;
39
+ },
40
+ createEvent: function(type, options) {
41
+ if (/^mouse(over|out|down|up|move)|(dbl)?click$/.test(type)) {
42
+ return this.mouseEvent(type, options);
43
+ } else if (/^key(up|down|press)$/.test(type)) {
44
+ return this.keyboardEvent(type, options);
45
+ }
46
+ },
47
+ mouseEvent: function(type, options) {
48
+ var evt;
49
+ var e = $.extend({
50
+ bubbles: true, cancelable: (type != "mousemove"), view: window, detail: 0,
51
+ screenX: 0, screenY: 0, clientX: 0, clientY: 0,
52
+ ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
53
+ button: 0, relatedTarget: undefined
54
+ }, options);
55
+
56
+ var relatedTarget = $(e.relatedTarget)[0];
57
+
58
+ if ($.isFunction(document.createEvent)) {
59
+ evt = document.createEvent("MouseEvents");
60
+ evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail,
61
+ e.screenX, e.screenY, e.clientX, e.clientY,
62
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
63
+ e.button, e.relatedTarget || document.body.parentNode);
64
+ } else if (document.createEventObject) {
65
+ evt = document.createEventObject();
66
+ $.extend(evt, e);
67
+ evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button;
68
+ }
69
+ return evt;
70
+ },
71
+ keyboardEvent: function(type, options) {
72
+ var evt;
73
+
74
+ var e = $.extend({ bubbles: true, cancelable: true, view: window,
75
+ ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
76
+ keyCode: 0, charCode: 0
77
+ }, options);
78
+
79
+ if ($.isFunction(document.createEvent)) {
80
+ try {
81
+ evt = document.createEvent("KeyEvents");
82
+ evt.initKeyEvent(type, e.bubbles, e.cancelable, e.view,
83
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
84
+ e.keyCode, e.charCode);
85
+ } catch(err) {
86
+ evt = document.createEvent("Events");
87
+ evt.initEvent(type, e.bubbles, e.cancelable);
88
+ $.extend(evt, { view: e.view,
89
+ ctrlKey: e.ctrlKey, altKey: e.altKey, shiftKey: e.shiftKey, metaKey: e.metaKey,
90
+ keyCode: e.keyCode, charCode: e.charCode
91
+ });
92
+ }
93
+ } else if (document.createEventObject) {
94
+ evt = document.createEventObject();
95
+ $.extend(evt, e);
96
+ }
97
+ if ($.browser.msie || $.browser.opera) {
98
+ evt.keyCode = (e.charCode > 0) ? e.charCode : e.keyCode;
99
+ evt.charCode = undefined;
100
+ }
101
+ return evt;
102
+ },
103
+
104
+ dispatchEvent: function(el, type, evt) {
105
+ if (el.dispatchEvent) {
106
+ el.dispatchEvent(evt);
107
+ } else if (el.fireEvent) {
108
+ el.fireEvent('on' + type, evt);
109
+ }
110
+ return evt;
111
+ },
112
+
113
+ drag: function(el) {
114
+ var self = this, center = this.findCenter(this.target),
115
+ options = this.options, x = Math.floor(center.x), y = Math.floor(center.y),
116
+ dx = options.dx || 0, dy = options.dy || 0, target = this.target;
117
+ var coord = { clientX: x, clientY: y };
118
+ this.simulateEvent(target, "mousedown", coord);
119
+ coord = { clientX: x + 1, clientY: y + 1 };
120
+ this.simulateEvent(document, "mousemove", coord);
121
+ coord = { clientX: x + dx, clientY: y + dy };
122
+ this.simulateEvent(document, "mousemove", coord);
123
+ this.simulateEvent(document, "mousemove", coord);
124
+ this.simulateEvent(target, "mouseup", coord);
125
+ },
126
+ findCenter: function(el) {
127
+ var el = $(this.target), o = el.offset();
128
+ return {
129
+ x: o.left + el.outerWidth() / 2,
130
+ y: o.top + el.outerHeight() / 2
131
+ };
132
+ }
133
+ });
134
+
135
+ $.extend($.simulate, {
136
+ defaults: {
137
+ speed: 'sync'
138
+ },
139
+ VK_TAB: 9,
140
+ VK_ENTER: 13,
141
+ VK_ESC: 27,
142
+ VK_PGUP: 33,
143
+ VK_PGDN: 34,
144
+ VK_END: 35,
145
+ VK_HOME: 36,
146
+ VK_LEFT: 37,
147
+ VK_UP: 38,
148
+ VK_RIGHT: 39,
149
+ VK_DOWN: 40
150
+ });
151
+
152
+ })(jQuery);
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Collin Miller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: fold
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.5.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: johnson
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: colored
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: "1.1"
44
+ version:
45
+ description: Inspiredby HAML, SASS and JABL by mr Hampton Catlin
46
+ email: collintmiller@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README
53
+ files:
54
+ - .gitignore
55
+ - .gitmodules
56
+ - README
57
+ - Rakefile.rb
58
+ - VERSION
59
+ - build
60
+ - examples/editor.html
61
+ - examples/editor.js
62
+ - examples/input_with_default.html
63
+ - examples/input_with_default.js
64
+ - examples/src/editor.html.haml
65
+ - examples/src/editor.js.jabs
66
+ - examples/src/input_with_default.html.haml
67
+ - examples/src/input_with_default.js.jabs
68
+ - lib/jabs.rb
69
+ - lightning.jabs
70
+ - rspec/fixtures/example.js
71
+ - rspec/fixtures/example.js.jabs
72
+ - rspec/fixtures/mephisto.js
73
+ - rspec/fixtures/mephisto.js.jabl
74
+ - rspec/jabs/jabs_engine_spec.rb
75
+ - rspec/jabs/jabs_precompiler_spec.rb
76
+ - rspec/jabs_spec.rb
77
+ - rspec/jabs_spec_helper.rb
78
+ - vendor/jquery/jquery-1.2.6.pack.js.gz
79
+ - vendor/jquery/jquery-1.3.1.js
80
+ - vendor/jquery/jquery.simulate.js
81
+ has_rdoc: true
82
+ homepage: http://github.com/collin/jabs
83
+ licenses: []
84
+
85
+ post_install_message:
86
+ rdoc_options:
87
+ - --charset=UTF-8
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ version:
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.5
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Javascript Abstract Behavior Syntax
109
+ test_files: []
110
+