jquery-unique-clone-rails 1.0.0

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: 8276735dad91031588cd2f7cde1995f944e7e332
4
+ data.tar.gz: 053997c8d98c9530726e45c4d933aba999dcb893
5
+ SHA512:
6
+ metadata.gz: 6459981df5dc3a5ecad4ae3927ab08924780bce4d0e5a659b20782517b098b175254d67790845ed2bb7dfbf552912a635fe90ddbb769cfbc77b30ff66cba624c
7
+ data.tar.gz: 59d35d9451b04cd7f183ba8cb23c3a1e50252dba209c53e068f62ac76ab61ffa4546346c9c954bdec5ab84e438623da5ba41124407c6f0856184bea2f49b6482
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ # jquery-unique-clone-rails
2
+
3
+ [jQuery Unique Clone](https://github.com/meowsus/jquery-unique-clone) plugin for jQuery, written by [Curt Howard](https://github.com/meowsus), packaged for the Rails asset pipeline.
4
+
5
+ ## Usage
6
+
7
+ This gem ships with with a minified version of the library. Feel free to use either of the following:
8
+
9
+ ```
10
+ //= require jquery-unique-clone.js
11
+ //= require jquery-unique-clone.min.js
12
+ ```
13
+
14
+ ## Disclaimer
15
+
16
+ This repo is a Rails gem package. All issues with the library should be reported on the library's [GitHub page](https://github.com/meowsus/jquery-unique-clone). This repo will be updated each time a new version of the library is released.
@@ -0,0 +1,8 @@
1
+ require 'jquery-unique-clone-rails/version'
2
+
3
+ module JqueryUniqueCloneRails
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module JqueryUniqueCloneRails
2
+ module Rails
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Clones an element, modifying any [id] or [for] attributes found within the
3
+ * element's scope to append a given suffix. Modeled after the core `$.clone()`
4
+ * method.
5
+ *
6
+ * @author Curt Howard <tooblies@gmail.com>
7
+ * @version 1.0.0
8
+ *
9
+ * @param {Object} $ the global jQuery object
10
+ * @param {Object} window the global window object
11
+ * @param {Object} document the global document object
12
+ * @param {undefined} undefined
13
+ */
14
+ ;(function ($, window, document, undefined) {
15
+ var pluginName = "uniqueClone";
16
+
17
+ /**
18
+ * Plugin boilerplate. Checking and setting of passed arguments.
19
+ *
20
+ * @param {Element} element the target element
21
+ * @param {Boolean} withDataAndEvents clone with data and events of element
22
+ * @param {Boolean} deepWithDataAndEvents clone with data and events of element and it's children
23
+ * @param {String} suffix the string to append to the attribute value
24
+ */
25
+ function Plugin(element, withDataAndEvents, deepWithDataAndEvents, suffix) {
26
+ this.element = element;
27
+
28
+ if (typeof withDataAndEvents === 'undefined' || withDataAndEvents === null) {
29
+ withDataAndEvents = false;
30
+ }
31
+
32
+ if (typeof deepWithDataAndEvents === 'undefined' || deepWithDataAndEvents === null) {
33
+ deepWithDataAndEvents = withDataAndEvents;
34
+ }
35
+
36
+ if (typeof suffix === 'undefined' || suffix === null) {
37
+ suffix = '-clone';
38
+ }
39
+
40
+ this._withDataAndEvents = withDataAndEvents;
41
+ this._deepWithDataAndEvents = deepWithDataAndEvents;
42
+ this._suffix = suffix;
43
+ this._name = pluginName;
44
+
45
+ this.init();
46
+ }
47
+
48
+ /**
49
+ * Clones the element, passing in the first two parameters sent to the
50
+ * Plugin. Modifies the value of any [id] or [for] attribute found to append
51
+ * the given suffix.
52
+ *
53
+ * @type {Object}
54
+ */
55
+ Plugin.prototype = {
56
+ init: function() {
57
+ var suffix = this._suffix;
58
+
59
+ this._$clone = $(this.element).clone(this._withDataAndEvents, this._deepWithDataAndEvents);
60
+
61
+ this._$clone
62
+ .find('[id]')
63
+ .addBack('[id]')
64
+ .attr('id', function (index, id) {
65
+ return id + suffix;
66
+ });
67
+
68
+ this._$clone
69
+ .find('[for]')
70
+ .addBack('[for]')
71
+ .attr('for', function (index, id) {
72
+ return id + suffix;
73
+ });
74
+ },
75
+ };
76
+
77
+ /**
78
+ * Receives three arguments in order to initialize the Plugin. Returns a
79
+ * property of the Plugin's instance representing the cloned, modified DOM.
80
+ */
81
+
82
+ /**
83
+ * Public interface for the Plugin. Receives arguments, passing them to the
84
+ * Plugin's boilerplate for initialization.
85
+ *
86
+ * @param {Boolean} withDataAndEvents clone with data and events of element
87
+ * @param {Boolean} deepWithDataAndEvents clone with data and events of element and it's children
88
+ * @param {String} suffix the string to append to the attribute value
89
+ * @return {jQuery} a collection containing a cloned, modified version of element
90
+ */
91
+ $.fn[pluginName] = function (withDataAndEvents, deepWithDataAndEvents, suffix) {
92
+ return (new Plugin(this, withDataAndEvents, deepWithDataAndEvents, suffix))._$clone;
93
+ };
94
+
95
+ })(jQuery, window, document);
@@ -0,0 +1 @@
1
+ !function(n,t,i,e){function d(n,t,i,e){this.element=n,"undefined"!=typeof t&&null!==t||(t=!1),"undefined"!=typeof i&&null!==i||(i=t),"undefined"!=typeof e&&null!==e||(e="-clone"),this._withDataAndEvents=t,this._deepWithDataAndEvents=i,this._suffix=e,this._name=o,this.init()}var o="uniqueClone";d.prototype={init:function(){var t=this._suffix;this._$clone=n(this.element).clone(this._withDataAndEvents,this._deepWithDataAndEvents),this._$clone.find("[id]").addBack("[id]").attr("id",function(n,i){return i+t}),this._$clone.find("[for]").addBack("[for]").attr("for",function(n,i){return i+t})}},n.fn[o]=function(n,t,i){return new d(this,n,t,i)._$clone}}(jQuery,window,document);
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-unique-clone-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Curt Howard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A build of the jQuery Unique Clone Plugin, written by written by Curt
14
+ Howard, packaged for the Rails asset pipeline.
15
+ email:
16
+ - choward@weblinc.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/jquery-unique-clone-rails.rb
24
+ - lib/jquery-unique-clone-rails/version.rb
25
+ - vendor/assets/javascripts/jquery-unique-clone.js
26
+ - vendor/assets/javascripts/jquery-unique-clone.min.js
27
+ homepage: https://github.com/meowsus/jquery-unique-clone-rails
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.4.5
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: A build of the jQuery Unique Clone Plugin, written by written by Curt Howard,
51
+ packaged for the Rails asset pipeline.
52
+ test_files: []