jquerypp-rails 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.document +5 -0
  2. data/.gitignore +7 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +24 -0
  6. data/Rakefile +2 -0
  7. data/jquerypp-rails.gemspec +20 -0
  8. data/lib/jquerypp/generators/jquerypp/install/install_generator.rb +49 -0
  9. data/lib/jquerypp/rails/engine.rb +8 -0
  10. data/lib/jquerypp/rails/version.rb +6 -0
  11. data/lib/jquerypp/rails.rb +8 -0
  12. data/lib/jquerypp-rails.rb +1 -0
  13. data/vendor/assets/javascripts/jquerypp.js +5419 -0
  14. data/vendor/assets/javascripts/lib/jquery.animate.js +326 -0
  15. data/vendor/assets/javascripts/lib/jquery.compare.js +75 -0
  16. data/vendor/assets/javascripts/lib/jquery.cookie.js +118 -0
  17. data/vendor/assets/javascripts/lib/jquery.dimensions.js +191 -0
  18. data/vendor/assets/javascripts/lib/jquery.event.default.js +115 -0
  19. data/vendor/assets/javascripts/lib/jquery.event.destroyed.js +23 -0
  20. data/vendor/assets/javascripts/lib/jquery.event.drag.js +727 -0
  21. data/vendor/assets/javascripts/lib/jquery.event.drop.js +457 -0
  22. data/vendor/assets/javascripts/lib/jquery.event.fastfix.js +95 -0
  23. data/vendor/assets/javascripts/lib/jquery.event.hover.js +266 -0
  24. data/vendor/assets/javascripts/lib/jquery.event.key.js +156 -0
  25. data/vendor/assets/javascripts/lib/jquery.event.livehack.js +174 -0
  26. data/vendor/assets/javascripts/lib/jquery.event.pause.js +92 -0
  27. data/vendor/assets/javascripts/lib/jquery.event.resize.js +47 -0
  28. data/vendor/assets/javascripts/lib/jquery.event.swipe.js +133 -0
  29. data/vendor/assets/javascripts/lib/jquery.fills.js +249 -0
  30. data/vendor/assets/javascripts/lib/jquery.form_params.js +167 -0
  31. data/vendor/assets/javascripts/lib/jquery.lang.json.js +196 -0
  32. data/vendor/assets/javascripts/lib/jquery.lang.vector.js +214 -0
  33. data/vendor/assets/javascripts/lib/jquery.range.js +861 -0
  34. data/vendor/assets/javascripts/lib/jquery.selection.js +232 -0
  35. data/vendor/assets/javascripts/lib/jquery.styles.js +103 -0
  36. data/vendor/assets/javascripts/lib/jquery.within.js +94 -0
  37. metadata +81 -0
@@ -0,0 +1,232 @@
1
+ // Dependencies:
2
+ //
3
+ // - jquery.selection.js
4
+ // - jquery.range.js
5
+ // - jquery.compare.js
6
+
7
+ (function($){
8
+
9
+ var getWindow = function( element ) {
10
+ return element ? element.ownerDocument.defaultView || element.ownerDocument.parentWindow : window
11
+ },
12
+ // A helper that uses range to abstract out getting the current start and endPos.
13
+ getElementsSelection = function(el, win){
14
+ // get a copy of the current range and a range that spans the element
15
+ var current = $.Range.current(el).clone(),
16
+ entireElement = $.Range(el).select(el);
17
+ // if there is no overlap, there is nothing selected
18
+ if(!current.overlaps(entireElement)){
19
+ return null;
20
+ }
21
+ // if the current range starts before our element
22
+ if(current.compare("START_TO_START", entireElement) < 1){
23
+ // the selection within the element begins at 0
24
+ startPos = 0;
25
+ // move the current range to start at our element
26
+ current.move("START_TO_START",entireElement);
27
+ }else{
28
+ // Make a copy of the element's range.
29
+ // Move it's end to the start of the selected range
30
+ // The length of the copy is the start of the selected
31
+ // range.
32
+ fromElementToCurrent =entireElement.clone();
33
+ fromElementToCurrent.move("END_TO_START", current);
34
+ startPos = fromElementToCurrent.toString().length
35
+ }
36
+
37
+ // If the current range ends after our element
38
+ if(current.compare("END_TO_END", entireElement) >= 0){
39
+ // the end position is the last character
40
+ endPos = entireElement.toString().length
41
+ }else{
42
+ // otherwise, it's the start position plus the current range
43
+ // TODO: this doesn't seem like it works if current
44
+ // extends to the left of the element.
45
+ endPos = startPos+current.toString().length
46
+ }
47
+ return {
48
+ start: startPos,
49
+ end : endPos,
50
+ width : endPos - startPos
51
+ };
52
+ },
53
+ // Text selection works differently for selection in an input vs
54
+ // normal html elements like divs, spans, and ps.
55
+ // This function branches between the various methods of getting the selection.
56
+ getSelection = function(el){
57
+ var win = getWindow(el);
58
+
59
+ // `selectionStart` means this is an input element in a standards browser.
60
+ if (el.selectionStart !== undefined) {
61
+
62
+ if(document.activeElement
63
+ && document.activeElement != el
64
+ && el.selectionStart == el.selectionEnd
65
+ && el.selectionStart == 0){
66
+ return {start: el.value.length, end: el.value.length, width: 0};
67
+ }
68
+ return {start: el.selectionStart, end: el.selectionEnd, width: el.selectionEnd - el.selectionStart};
69
+ }
70
+ // getSelection means a 'normal' element in a standards browser.
71
+ else if(win.getSelection){
72
+ return getElementsSelection(el, win)
73
+ } else{
74
+ // IE will freak out, where there is no way to detect it, so we provide a callback if it does.
75
+ try {
76
+ // The following typically works for input elements in IE:
77
+ if (el.nodeName.toLowerCase() == 'input') {
78
+ var real = getWindow(el).document.selection.createRange(),
79
+ r = el.createTextRange();
80
+ r.setEndPoint("EndToStart", real);
81
+
82
+ var start = r.text.length
83
+ return {
84
+ start: start,
85
+ end: start + real.text.length,
86
+ width: real.text.length
87
+ }
88
+ }
89
+ // This works on textareas and other elements
90
+ else {
91
+ var res = getElementsSelection(el,win)
92
+ if(!res){
93
+ return res;
94
+ }
95
+ // we have to clean up for ie's textareas which don't count for
96
+ // newlines correctly
97
+ var current = $.Range.current().clone(),
98
+ r2 = current.clone().collapse().range,
99
+ r3 = current.clone().collapse(false).range;
100
+
101
+ r2.moveStart('character', -1)
102
+ r3.moveStart('character', -1)
103
+ // if we aren't at the start, but previous is empty, we are at start of newline
104
+ if (res.startPos != 0 && r2.text == "") {
105
+ res.startPos += 2;
106
+ }
107
+ // do a similar thing for the end of the textarea
108
+ if (res.endPos != 0 && r3.text == "") {
109
+ res.endPos += 2;
110
+ }
111
+
112
+ return res
113
+ }
114
+ }catch(e){
115
+ return {start: el.value.length, end: el.value.length, width: 0};
116
+ }
117
+ }
118
+ },
119
+ // Selects text within an element. Depending if it's a form element or
120
+ // not, or a standards based browser or not, we do different things.
121
+ select = function( el, start, end ) {
122
+ var win = getWindow(el);
123
+ // IE behaves bad even if it sorta supports
124
+ // getSelection so we have to try the IE methods first. barf.
125
+ if(el.setSelectionRange){
126
+ if(end === undefined){
127
+ el.focus();
128
+ el.setSelectionRange(start, start);
129
+ } else {
130
+ el.select();
131
+ el.selectionStart = start;
132
+ el.selectionEnd = end;
133
+ }
134
+ } else if (el.createTextRange) {
135
+ var r = el.createTextRange();
136
+ r.moveStart('character', start);
137
+ end = end || start;
138
+ r.moveEnd('character', end - el.value.length);
139
+
140
+ r.select();
141
+ } else if(win.getSelection){
142
+ var doc = win.document,
143
+ sel = win.getSelection(),
144
+ range = doc.createRange(),
145
+ ranges = [start, end !== undefined ? end : start];
146
+ getCharElement([el],ranges);
147
+ range.setStart(ranges[0].el, ranges[0].count);
148
+ range.setEnd(ranges[1].el, ranges[1].count);
149
+
150
+ // removeAllRanges is necessary for webkit
151
+ sel.removeAllRanges();
152
+ sel.addRange(range);
153
+
154
+ } else if(win.document.body.createTextRange){ //IE's weirdness
155
+ var range = document.body.createTextRange();
156
+ range.moveToElementText(el);
157
+ range.collapse()
158
+ range.moveStart('character', start)
159
+ range.moveEnd('character', end !== undefined ? end : start)
160
+ range.select();
161
+ }
162
+
163
+ },
164
+ // If one of the range values is within start and len, replace the range
165
+ // value with the element and its offset.
166
+ replaceWithLess = function(start, len, range, el){
167
+ if(typeof range[0] === 'number' && range[0] < len){
168
+ range[0] = {
169
+ el: el,
170
+ count: range[0] - start
171
+ };
172
+ }
173
+ if(typeof range[1] === 'number' && range[1] <= len){
174
+ range[1] = {
175
+ el: el,
176
+ count: range[1] - start
177
+ };;
178
+ }
179
+ },
180
+ getCharElement = function( elems , range, len ) {
181
+ var elem,
182
+ start;
183
+
184
+ len = len || 0;
185
+ for ( var i = 0; elems[i]; i++ ) {
186
+ elem = elems[i];
187
+ // Get the text from text nodes and CDATA nodes
188
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
189
+ start = len
190
+ len += elem.nodeValue.length;
191
+ //check if len is now greater than what's in counts
192
+ replaceWithLess(start, len, range, elem )
193
+ // Traverse everything else, except comment nodes
194
+ } else if ( elem.nodeType !== 8 ) {
195
+ len = getCharElement( elem.childNodes, range, len );
196
+ }
197
+ }
198
+ return len;
199
+ };
200
+ /**
201
+ * @parent jQuery.selection
202
+ * @function jQuery.fn.selection
203
+ *
204
+ * Set or retrieve the currently selected text range. It works on all elements:
205
+ *
206
+ * $('#text').selection(8, 12)
207
+ * $('#text').selection() // -> { start : 8, end : 12, width: 4 }
208
+ *
209
+ * @param {Number} [start] Start position of the selection range
210
+ * @param {Number} [end] End position of the selection range
211
+ * @return {Object|jQuery} Returns either the jQuery object when setting the selection or
212
+ * an object containing
213
+ *
214
+ * - __start__ - The number of characters from the start of the element to the start of the selection.
215
+ * - __end__ - The number of characters from the start of the element to the end of the selection.
216
+ * - __width__ - The width of the selection range.
217
+ *
218
+ * when no arguments are passed.
219
+ */
220
+ $.fn.selection = function(start, end){
221
+ if(start !== undefined){
222
+ return this.each(function(){
223
+ select(this, start, end)
224
+ })
225
+ }else{
226
+ return getSelection(this[0])
227
+ }
228
+ };
229
+ // for testing
230
+ $.fn.selection.getCharElement = getCharElement;
231
+
232
+ })(jQuery)
@@ -0,0 +1,103 @@
1
+ // - jquery.styles.js
2
+ (function( $ ) {
3
+
4
+ var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
5
+ // The following variables are used to convert camelcased attribute names
6
+ // into dashed names, e.g. borderWidth to border-width
7
+ rupper = /([A-Z])/g,
8
+ rdashAlpha = /-([a-z])/ig,
9
+ fcamelCase = function( all, letter ) {
10
+ return letter.toUpperCase();
11
+ },
12
+ // Returns the computed style for an elementn
13
+ getStyle = function( elem ) {
14
+ if ( getComputedStyle ) {
15
+ return getComputedStyle(elem, null);
16
+ }
17
+ else if ( elem.currentStyle ) {
18
+ return elem.currentStyle;
19
+ }
20
+ },
21
+ // Checks for float px and numeric values
22
+ rfloat = /float/i,
23
+ rnumpx = /^-?\d+(?:px)?$/i,
24
+ rnum = /^-?\d/;
25
+
26
+ // Returns a list of styles for a given element
27
+ $.styles = function( el, styles ) {
28
+ if (!el ) {
29
+ return null;
30
+ }
31
+ var currentS = getStyle(el),
32
+ oldName, val, style = el.style,
33
+ results = {},
34
+ i = 0,
35
+ left, rsLeft, camelCase, name;
36
+
37
+ // Go through each style
38
+ for (; i < styles.length; i++ ) {
39
+ name = styles[i];
40
+ oldName = name.replace(rdashAlpha, fcamelCase);
41
+
42
+ if ( rfloat.test(name) ) {
43
+ name = jQuery.support.cssFloat ? "float" : "styleFloat";
44
+ oldName = "cssFloat";
45
+ }
46
+
47
+ // If we have getComputedStyle available
48
+ if ( getComputedStyle ) {
49
+ // convert camelcased property names to dashed name
50
+ name = name.replace(rupper, "-$1").toLowerCase();
51
+ // use getPropertyValue of the current style object
52
+ val = currentS.getPropertyValue(name);
53
+ // default opacity is 1
54
+ if ( name === "opacity" && val === "" ) {
55
+ val = "1";
56
+ }
57
+ results[oldName] = val;
58
+ } else {
59
+ // Without getComputedStyles
60
+ camelCase = name.replace(rdashAlpha, fcamelCase);
61
+ results[oldName] = currentS[name] || currentS[camelCase];
62
+
63
+ // convert to px
64
+ if (!rnumpx.test(results[oldName]) && rnum.test(results[oldName]) ) {
65
+ // Remember the original values
66
+ left = style.left;
67
+ rsLeft = el.runtimeStyle.left;
68
+
69
+ // Put in the new values to get a computed value out
70
+ el.runtimeStyle.left = el.currentStyle.left;
71
+ style.left = camelCase === "fontSize" ? "1em" : (results[oldName] || 0);
72
+ results[oldName] = style.pixelLeft + "px";
73
+
74
+ // Revert the changed values
75
+ style.left = left;
76
+ el.runtimeStyle.left = rsLeft;
77
+ }
78
+
79
+ }
80
+ }
81
+
82
+ return results;
83
+ };
84
+
85
+ /**
86
+ * @function jQuery.fn.styles
87
+ * @parent jQuery.styles
88
+ * @plugin jQuery.styles
89
+ *
90
+ * Returns a set of computed styles. Pass the names of the styles you want to
91
+ * retrieve as arguments:
92
+ *
93
+ * $("div").styles('float','display')
94
+ * // -> { cssFloat: "left", display: "block" }
95
+ *
96
+ * @param {String} style pass the names of the styles to retrieve as the argument list
97
+ * @return {Object} an object of `style` : `value` pairs
98
+ */
99
+ $.fn.styles = function() {
100
+ // Pass the arguments as an array to $.styles
101
+ return $.styles(this[0], $.makeArray(arguments));
102
+ };
103
+ })(jQuery)
@@ -0,0 +1,94 @@
1
+ // - jquery.within.js
2
+ (function($){
3
+ // Checks if x and y coordinates are within a box with left, top, width and height
4
+ var withinBox = function(x, y, left, top, width, height ){
5
+ return (y >= top &&
6
+ y < top + height &&
7
+ x >= left &&
8
+ x < left + width);
9
+ }
10
+ /**
11
+ * @function jQuery.fn.within
12
+ * @parent jQuery.within
13
+ * @plugin jquery/dom/within
14
+ *
15
+ * Returns all elements matching the selector that touch a given point:
16
+ *
17
+ * // get all elements that touch 200x200.
18
+ * $('*').within(200, 200);
19
+ *
20
+ * @param {Number} left the position from the left of the page
21
+ * @param {Number} top the position from the top of the page
22
+ * @param {Boolean} [useOffsetCache=false] cache the dimensions and offset of the elements.
23
+ * @return {jQuery} a jQuery collection of elements whos area
24
+ * overlaps the element position.
25
+ */
26
+ $.fn.within= function(left, top, useOffsetCache) {
27
+ var ret = []
28
+ this.each(function(){
29
+ var q = jQuery(this);
30
+
31
+ if (this == document.documentElement) {
32
+ return ret.push(this);
33
+ }
34
+
35
+ // uses either the cached offset or .offset()
36
+ var offset = useOffsetCache ?
37
+ jQuery.data(this,"offsetCache") || jQuery.data(this,"offsetCache", q.offset()) :
38
+ q.offset();
39
+
40
+ // Check if the given coordinates are within the area of the current element
41
+ var res = withinBox(left, top, offset.left, offset.top,
42
+ this.offsetWidth, this.offsetHeight );
43
+
44
+ if (res) {
45
+ // Add it to the results
46
+ ret.push(this);
47
+ }
48
+ });
49
+
50
+ return this.pushStack( jQuery.unique( ret ), "within", left+","+top );
51
+ }
52
+
53
+
54
+ /**
55
+ * @function jQuery.fn.withinBox
56
+ * @parent jQuery.within
57
+ *
58
+ * Returns all elements matching the selector that have a given area in common:
59
+ *
60
+ * $('*').withinBox(200, 200, 100, 100)
61
+ *
62
+ * @param {Number} left the position from the left of the page
63
+ * @param {Number} top the position from the top of the page
64
+ * @param {Number} width the width of the area
65
+ * @param {Number} height the height of the area
66
+ * @param {Boolean} [useOffsetCache=false] cache the dimensions and offset of the elements.
67
+ * @return {jQuery} a jQuery collection of elements whos area
68
+ * overlaps the element position.
69
+ */
70
+ $.fn.withinBox = function(left, top, width, height, useOffsetCache){
71
+ var ret = []
72
+ this.each(function(){
73
+ var q = jQuery(this);
74
+
75
+ if(this == document.documentElement) return ret.push(this);
76
+
77
+ // use cached offset or .offset()
78
+ var offset = cache ?
79
+ jQuery.data(this,"offset") ||
80
+ jQuery.data(this,"offset", q.offset()) :
81
+ q.offset();
82
+
83
+
84
+ var ew = q.width(), eh = q.height(),
85
+ // Checks if the element offset is within the given box
86
+ res = !( (offset.top > top+height) || (offset.top +eh < top) || (offset.left > left+width ) || (offset.left+ew < left));
87
+
88
+ if(res)
89
+ ret.push(this);
90
+ });
91
+ return this.pushStack( jQuery.unique( ret ), "withinBox", jQuery.makeArray(arguments).join(",") );
92
+ }
93
+
94
+ })(jQuery)
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquerypp-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Tapia
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This gem provides jQuery++ for your Rails 3 application.
15
+ email:
16
+ - jonathan.tapia@crowdint.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .document
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.rdoc
26
+ - Rakefile
27
+ - jquerypp-rails.gemspec
28
+ - lib/jquerypp-rails.rb
29
+ - lib/jquerypp/generators/jquerypp/install/install_generator.rb
30
+ - lib/jquerypp/rails.rb
31
+ - lib/jquerypp/rails/engine.rb
32
+ - lib/jquerypp/rails/version.rb
33
+ - vendor/assets/javascripts/jquerypp.js
34
+ - vendor/assets/javascripts/lib/jquery.animate.js
35
+ - vendor/assets/javascripts/lib/jquery.compare.js
36
+ - vendor/assets/javascripts/lib/jquery.cookie.js
37
+ - vendor/assets/javascripts/lib/jquery.dimensions.js
38
+ - vendor/assets/javascripts/lib/jquery.event.default.js
39
+ - vendor/assets/javascripts/lib/jquery.event.destroyed.js
40
+ - vendor/assets/javascripts/lib/jquery.event.drag.js
41
+ - vendor/assets/javascripts/lib/jquery.event.drop.js
42
+ - vendor/assets/javascripts/lib/jquery.event.fastfix.js
43
+ - vendor/assets/javascripts/lib/jquery.event.hover.js
44
+ - vendor/assets/javascripts/lib/jquery.event.key.js
45
+ - vendor/assets/javascripts/lib/jquery.event.livehack.js
46
+ - vendor/assets/javascripts/lib/jquery.event.pause.js
47
+ - vendor/assets/javascripts/lib/jquery.event.resize.js
48
+ - vendor/assets/javascripts/lib/jquery.event.swipe.js
49
+ - vendor/assets/javascripts/lib/jquery.fills.js
50
+ - vendor/assets/javascripts/lib/jquery.form_params.js
51
+ - vendor/assets/javascripts/lib/jquery.lang.json.js
52
+ - vendor/assets/javascripts/lib/jquery.lang.vector.js
53
+ - vendor/assets/javascripts/lib/jquery.range.js
54
+ - vendor/assets/javascripts/lib/jquery.selection.js
55
+ - vendor/assets/javascripts/lib/jquery.styles.js
56
+ - vendor/assets/javascripts/lib/jquery.within.js
57
+ homepage: http://rubygems.org/gems/jquerypp-rails
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.6
75
+ requirements: []
76
+ rubyforge_project: jquerypp-rails
77
+ rubygems_version: 1.8.24
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Use jQuery++ with Rails 3
81
+ test_files: []