jquery-serialize-object-rails 2.5.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/jquery-serialize-object-rails.gemspec +24 -0
- data/lib/jquery-serialize-object-rails.rb +12 -0
- data/lib/jquery-serialize-object-rails/version.rb +9 -0
- data/vendor/assets/javascripts/jquery.serialize-object.js +146 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7812a5e0db82bc15007b50ce13bf98900f3d0d90
|
4
|
+
data.tar.gz: 0c10f784ecf65512ffb28bb25b07f1c51daef07a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be2de08f09b891e0a6f4de3a29be01226a512810591073de199deb1ca4d13b33089cef08ee76f6ccdcb51e1ec746ccc842724bfd3fb64b04d0caaa34a2a379df
|
7
|
+
data.tar.gz: 9e5879d590f6991b0ec73716d742dba67ebb181f998f7c5505eeda3a920744277ab41ff2a9659be470c45444f8b26329e77ee0a8e7480aa29f9f7bd1eb6fc427
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012-2013 Tanguy Krotoff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# jQuery Serialize Object for Rails
|
2
|
+
|
3
|
+
jquery-serialize-object packaged for the Rails 3.1+ asset pipeline.
|
4
|
+
See the [jquery-serialize-object home page](https://github.com/macek/jquery-serialize-object) for documentation.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'jquery-serialize-object-rails'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install jquery-serialize-object-rails
|
20
|
+
|
21
|
+
Add the following JavaScript file to `app/assets/javascripts/application.js`:
|
22
|
+
|
23
|
+
//= require jquery.serialize-object
|
24
|
+
|
25
|
+
|
26
|
+
## License
|
27
|
+
|
28
|
+
jquery-serialize-object is developed by [Paul Maček](https://github.com/macek) and has a
|
29
|
+
[license](https://github.com/macek/jquery-serialize-object/blob/master/LICENSE).
|
30
|
+
|
31
|
+
This gem is licensed under the [MIT LICENSE](). This license applies only to the gem, not to
|
32
|
+
jquery-serialize-object.js.
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jquery-serialize-object-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jquery-serialize-object-rails'
|
8
|
+
spec.version = Jquery::Serialize::Object::Rails::VERSION
|
9
|
+
spec.authors = ['Justin Tomich']
|
10
|
+
spec.email = ['tomichj@gmail.com']
|
11
|
+
spec.description = %q{Adds the method serializeObject to jQuery}
|
12
|
+
spec.summary = %q{jquery-serialize-object packaged for the Rails 3.1+ asset pipeline}
|
13
|
+
spec.homepage = 'https://github.com/tomichj/jquery-serialize-object-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'railties', '>= 3.1.0'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery serializeObject
|
3
|
+
* @copyright 2014, macek <paulmacek@gmail.com>
|
4
|
+
* @link https://github.com/macek/jquery-serialize-object
|
5
|
+
* @license BSD
|
6
|
+
* @version 2.5.0
|
7
|
+
*/
|
8
|
+
(function(root, factory) {
|
9
|
+
|
10
|
+
// AMD
|
11
|
+
if (typeof define === "function" && define.amd) {
|
12
|
+
define(["exports", "jquery"], function(exports, $) {
|
13
|
+
return factory(exports, $);
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
// CommonJS
|
18
|
+
else if (typeof exports !== "undefined") {
|
19
|
+
var $ = require("jquery");
|
20
|
+
factory(exports, $);
|
21
|
+
}
|
22
|
+
|
23
|
+
// Browser
|
24
|
+
else {
|
25
|
+
factory(root, (root.jQuery || root.Zepto || root.ender || root.$));
|
26
|
+
}
|
27
|
+
|
28
|
+
}(this, function(exports, $) {
|
29
|
+
|
30
|
+
var patterns = {
|
31
|
+
validate: /^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,
|
32
|
+
key: /[a-z0-9_]+|(?=\[\])/gi,
|
33
|
+
push: /^$/,
|
34
|
+
fixed: /^\d+$/,
|
35
|
+
named: /^[a-z0-9_]+$/i
|
36
|
+
};
|
37
|
+
|
38
|
+
function FormSerializer(helper, $form) {
|
39
|
+
|
40
|
+
// private variables
|
41
|
+
var data = {},
|
42
|
+
pushes = {};
|
43
|
+
|
44
|
+
// private API
|
45
|
+
function build(base, key, value) {
|
46
|
+
base[key] = value;
|
47
|
+
return base;
|
48
|
+
}
|
49
|
+
|
50
|
+
function makeObject(root, value) {
|
51
|
+
|
52
|
+
var keys = root.match(patterns.key), k;
|
53
|
+
|
54
|
+
// nest, nest, ..., nest
|
55
|
+
while ((k = keys.pop()) !== undefined) {
|
56
|
+
// foo[]
|
57
|
+
if (patterns.push.test(k)) {
|
58
|
+
var idx = incrementPush(root.replace(/\[\]$/, ''));
|
59
|
+
value = build([], idx, value);
|
60
|
+
}
|
61
|
+
|
62
|
+
// foo[n]
|
63
|
+
else if (patterns.fixed.test(k)) {
|
64
|
+
value = build([], k, value);
|
65
|
+
}
|
66
|
+
|
67
|
+
// foo; foo[bar]
|
68
|
+
else if (patterns.named.test(k)) {
|
69
|
+
value = build({}, k, value);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
return value;
|
74
|
+
}
|
75
|
+
|
76
|
+
function incrementPush(key) {
|
77
|
+
if (pushes[key] === undefined) {
|
78
|
+
pushes[key] = 0;
|
79
|
+
}
|
80
|
+
return pushes[key]++;
|
81
|
+
}
|
82
|
+
|
83
|
+
function encode(pair) {
|
84
|
+
switch ($('[name="' + pair.name + '"]', $form).attr("type")) {
|
85
|
+
case "checkbox":
|
86
|
+
return pair.value === "on" ? true : pair.value;
|
87
|
+
default:
|
88
|
+
return pair.value;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
function addPair(pair) {
|
93
|
+
if (!patterns.validate.test(pair.name)) return this;
|
94
|
+
var obj = makeObject(pair.name, encode(pair));
|
95
|
+
data = helper.extend(true, data, obj);
|
96
|
+
return this;
|
97
|
+
}
|
98
|
+
|
99
|
+
function addPairs(pairs) {
|
100
|
+
if (!helper.isArray(pairs)) {
|
101
|
+
throw new Error("formSerializer.addPairs expects an Array");
|
102
|
+
}
|
103
|
+
for (var i=0, len=pairs.length; i<len; i++) {
|
104
|
+
this.addPair(pairs[i]);
|
105
|
+
}
|
106
|
+
return this;
|
107
|
+
}
|
108
|
+
|
109
|
+
function serialize() {
|
110
|
+
return data;
|
111
|
+
}
|
112
|
+
|
113
|
+
function serializeJSON() {
|
114
|
+
return JSON.stringify(serialize());
|
115
|
+
}
|
116
|
+
|
117
|
+
// public API
|
118
|
+
this.addPair = addPair;
|
119
|
+
this.addPairs = addPairs;
|
120
|
+
this.serialize = serialize;
|
121
|
+
this.serializeJSON = serializeJSON;
|
122
|
+
}
|
123
|
+
|
124
|
+
FormSerializer.patterns = patterns;
|
125
|
+
|
126
|
+
FormSerializer.serializeObject = function serializeObject() {
|
127
|
+
return new FormSerializer($, this).
|
128
|
+
addPairs(this.serializeArray()).
|
129
|
+
serialize();
|
130
|
+
};
|
131
|
+
|
132
|
+
FormSerializer.serializeJSON = function serializeJSON() {
|
133
|
+
return new FormSerializer($, this).
|
134
|
+
addPairs(this.serializeArray()).
|
135
|
+
serializeJSON();
|
136
|
+
};
|
137
|
+
|
138
|
+
if (typeof $.fn !== "undefined") {
|
139
|
+
$.fn.serializeObject = FormSerializer.serializeObject;
|
140
|
+
$.fn.serializeJSON = FormSerializer.serializeJSON;
|
141
|
+
}
|
142
|
+
|
143
|
+
exports.FormSerializer = FormSerializer;
|
144
|
+
|
145
|
+
return FormSerializer;
|
146
|
+
}));
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-serialize-object-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.5.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Tomich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Adds the method serializeObject to jQuery
|
56
|
+
email:
|
57
|
+
- tomichj@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- jquery-serialize-object-rails.gemspec
|
68
|
+
- lib/jquery-serialize-object-rails.rb
|
69
|
+
- lib/jquery-serialize-object-rails/version.rb
|
70
|
+
- vendor/assets/javascripts/jquery.serialize-object.js
|
71
|
+
homepage: https://github.com/tomichj/jquery-serialize-object-rails
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.5.1
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: jquery-serialize-object packaged for the Rails 3.1+ asset pipeline
|
95
|
+
test_files: []
|