fields_serialize 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e9a2a74ef3cfff9c6ebc152e87379f0123313a8
4
+ data.tar.gz: 4e3190d821805415de94cdaf4742b0a1fbca8151
5
+ SHA512:
6
+ metadata.gz: 9c828bad7bac3e17eee18b619c732df7e1a6fbd87fdcf503c94ec1ab4b925a1354e94cf73da5ef3aa93d95d850837cce2ff5470af63f6bbba213bcd5d6149968
7
+ data.tar.gz: f27229ca33fb71745432eb64524e9b2d807cbd2b3aae28ca15b7284c4034ded60bcf220c7f60169365f47cf2924c99aa29a395f644af8f506b3a1698c0d8d326
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fields_serialize.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fernando Pereira
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.
@@ -0,0 +1,57 @@
1
+ # FieldsSerialize
2
+
3
+ An alternative to jQuery $("form").serialize() when you are not using a form tag (for AJAX and stuff).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fields_serialize'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fields_serialize
18
+
19
+ ## Usage
20
+
21
+ Add the following directive to your JavaScript manifest file (application.js):
22
+
23
+ //= require fields_serialize
24
+
25
+ ## Using it to aid an AJAX request
26
+
27
+ ### Instead of this:
28
+
29
+ $.ajax({
30
+ url: 'your-url-here',
31
+ data: {
32
+ 'key_name' : {
33
+ 'field_1' : $('#field_1').val(),
34
+ 'field_2' : $('#field_2').val(),
35
+ 'field_3' : $('#field_3').val(),
36
+ 'field_4' : $('#field_4').val(),
37
+ 'field_5' : $('#field_5').val()
38
+ }
39
+ },
40
+ type: 'POST'
41
+ });
42
+
43
+ ### You can do this:
44
+
45
+ $.ajax({
46
+ url: "your-url-here",
47
+ data: fieldsSerialize($('#your-selector'), 'key_name'),
48
+ type: 'POST'
49
+ });
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fields_serialize/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fields_serialize"
8
+ spec.version = FieldsSerialize::VERSION
9
+ spec.authors = ["Fernando Pereira", "Brunno Gomes"]
10
+ spec.email = ["fernandopereirala@gmail.com", "brunnolgp@gmail.com"]
11
+ spec.description = "An alternative to Jquery $.serialize() when you are not using a form."
12
+ spec.summary = "An alternative to Jquery $.serialize() when you are not using a form."
13
+ spec.homepage = "https://github.com/fernandopereira/fields_serialize"
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_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,8 @@
1
+ require "fields_serialize/version"
2
+
3
+ module FieldsSerialize
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module FieldsSerialize
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ function fieldsSerialize(fields, mainKeyName) {
2
+ var data = {}
3
+ var _item = {}
4
+ var tam = mainKeyName.length
5
+
6
+ $.each(fields.find('INPUT,SELECT').serializeArray(), function() {
7
+ var keyName = $(this)[0].name.substr(0,tam)
8
+ var attr = $(this)[0].name.substr(tam + 1)
9
+ var value = $(this)[0].value
10
+
11
+ if(keyName === mainKeyName) {
12
+ _item[attr] = value
13
+ } else {
14
+ data[$(this)[0].name] = value
15
+ }
16
+ });
17
+ data[mainKeyName] = _item
18
+
19
+ return data
20
+ };
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fields_serialize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Pereira
8
+ - Brunno Gomes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: An alternative to Jquery $.serialize() when you are not using a form.
43
+ email:
44
+ - fernandopereirala@gmail.com
45
+ - brunnolgp@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - fields_serialize.gemspec
56
+ - lib/fields_serialize.rb
57
+ - lib/fields_serialize/version.rb
58
+ - vendor/assets/javascripts/fields_serialize.js
59
+ homepage: https://github.com/fernandopereira/fields_serialize
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: An alternative to Jquery $.serialize() when you are not using a form.
83
+ test_files: []