bootstrap-show-password-rails 2.0.0.r2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a39415c6e492f614bd4c2572d407e21ea24a1c1d
4
+ data.tar.gz: 54a4d6cd47e69cac330c5d8e05d021d1107c600a
5
+ SHA512:
6
+ metadata.gz: 36a5557f78c4bf698a73a160757d2bf67826e457317b468f88b37290be4b0b4d03a07bf79b0ca1ae2a7869a3eb4f5ab2339354fc76ef4d6ec79bbdf5837807a1
7
+ data.tar.gz: 1306bf67e2bbe728545a27621f3468c3871dd2982ad1fe3581f9912895aa46e3e7f0560ff815113726677ece045afe0e2348546682c65b22f9211fe632e4b9ed
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Claudio Maradonna
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Bootstrap::Show::Password::Rails
2
+ This is a simple wrapper for this jQuery Bootstrap based plugin: [bootstrap-show-password](https://github.com/UnitooTeam/bootstrap-show-password)
3
+
4
+ ## Usage
5
+ To understand how to use the library itself, check this page to avoid duplicates or outdated [documentation](https://github.com/UnitooTeam/bootstrap-show-password).
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'bootstrap-show-password-rails'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install bootstrap-show-password-rails
22
+ ```
23
+
24
+ Later add to your `application.js`:
25
+ ```javascript
26
+ //= require bootstrap-show-password-rails
27
+ ```
28
+
29
+ ## Contributing
30
+ * Fork and pull
31
+ * Respect each other
32
+
33
+ ## License
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Bootstrap::Show::Password::Rails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1,12 @@
1
+ require "rails"
2
+ require "bootstrap-show-password-rails/version"
3
+
4
+ module BoostrapShowPasswordRails
5
+ module Rails
6
+ if ::Rails.version.to_s < "3.1"
7
+ require "bootstrap-show-password-rails/railtie"
8
+ else
9
+ require "bootstrap-show-password-rails/engine"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module BootstrapShowPasswordRails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module BootstrapShowPasswordRails
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BootstrapShowPasswordRails
2
+ module Rails
3
+ VERSION = "2.0.0.r2"
4
+ end
5
+ end
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @author zhixin wen <wenzhixin2010@gmail.com>
3
+ * https://github.com/wenzhixin/bootstrap-show-password
4
+ * version: 2.0.0
5
+ */
6
+
7
+ !function ($) {
8
+
9
+ 'use strict';
10
+
11
+ // TOOLS DEFINITION
12
+ // ======================
13
+
14
+ // it only does '%s', and return '' when arguments are undefined
15
+ var sprintf = function(str) {
16
+ var args = arguments,
17
+ flag = true,
18
+ i = 1;
19
+
20
+ str = str.replace(/%s/g, function () {
21
+ var arg = args[i++];
22
+
23
+ if (typeof arg === 'undefined') {
24
+ flag = false;
25
+ return '';
26
+ }
27
+ return arg;
28
+ });
29
+ if (flag) {
30
+ return str;
31
+ }
32
+ return '';
33
+ };
34
+
35
+ // PASSWORD CLASS DEFINITION
36
+ // ======================
37
+
38
+ var Password = function(element, options) {
39
+ this.options = options;
40
+ this.$element = $(element);
41
+ this.isShown = false;
42
+
43
+ this.init();
44
+ };
45
+
46
+ Password.DEFAULTS = {
47
+ placement: 'after', // 'before' or 'after'
48
+ white: false, // v2
49
+ message: 'Click here to show/hide password',
50
+ eyeClass: 'glyphicon',
51
+ eyeOpenClass: 'glyphicon-eye-open',
52
+ eyeCloseClass: 'glyphicon-eye-close',
53
+ eyeClassPositionInside: false
54
+ };
55
+
56
+ Password.prototype.init = function() {
57
+ var placementFuc,
58
+ inputClass; // v2 class
59
+
60
+ if (this.options.placement === 'before') {
61
+ placementFuc = 'insertBefore';
62
+ inputClass = 'input-prepend';
63
+ } else {
64
+ this.options.placement = 'after'; // default to after
65
+ placementFuc = 'insertAfter';
66
+ inputClass = 'input-append';
67
+ }
68
+
69
+ // Create the text, icon and assign
70
+ this.$element.wrap(sprintf('<div class="%s input-group" />', inputClass));
71
+
72
+ this.$text = $('<input type="text" />')
73
+ [placementFuc](this.$element)
74
+ .attr('class', this.$element.attr('class'))
75
+ .attr('style', this.$element.attr('style'))
76
+ .attr('placeholder', this.$element.attr('placeholder'))
77
+ .css('display', this.$element.css('display'))
78
+ .val(this.$element.val()).hide();
79
+
80
+ // Copy readonly attribute if it's set
81
+ if (this.$element.prop('readonly'))
82
+ this.$text.prop('readonly', true);
83
+ this.$icon = $([
84
+ '<div class="input-group-append">',
85
+ '<button tabindex="100" title="' + this.options.message + '" class="btn btn-outline-secondary" type="button">',
86
+ '<i class="icon-eye-open' + (this.options.white ? ' icon-white' : '') +
87
+ ' ' + this.options.eyeClass + ' ' + (this.options.eyeClassPositionInside ? '' : this.options.eyeOpenClass) + '">' +
88
+ (this.options.eyeClassPositionInside ? this.options.eyeOpenClass : '') + '</i>',
89
+ '</button>',
90
+ '</div>'
91
+ ].join(''))[placementFuc](this.$text).css('cursor', 'pointer');
92
+
93
+ // events
94
+ this.$text.off('keyup').on('keyup', $.proxy(function() {
95
+ if (!this.isShown) return;
96
+ this.$element.val(this.$text.val()).trigger('change');
97
+ }, this));
98
+
99
+ this.$icon.off('click').on('click', $.proxy(function() {
100
+ this.$text.val(this.$element.val()).trigger('change');
101
+ this.toggle();
102
+ }, this));
103
+ };
104
+
105
+ Password.prototype.toggle = function(_relatedTarget) {
106
+ this[!this.isShown ? 'show' : 'hide'](_relatedTarget);
107
+ };
108
+
109
+ Password.prototype.show = function(_relatedTarget) {
110
+ var e = $.Event('show.bs.password', {relatedTarget: _relatedTarget});
111
+ this.$element.trigger(e);
112
+
113
+ this.isShown = true;
114
+ this.$element.hide();
115
+ this.$text.show();
116
+ if (this.options.eyeClassPositionInside) {
117
+ this.$icon.find('i')
118
+ .removeClass('icon-eye-open')
119
+ .addClass('icon-eye-close')
120
+ .html(this.options.eyeCloseClass);
121
+ } else {
122
+ this.$icon.find('i')
123
+ .removeClass('icon-eye-open ' + this.options.eyeOpenClass)
124
+ .addClass('icon-eye-close ' + this.options.eyeCloseClass);
125
+ }
126
+
127
+ // v3 input-group
128
+ this.$text[this.options.placement](this.$element);
129
+ };
130
+
131
+ Password.prototype.hide = function(_relatedTarget) {
132
+ var e = $.Event('hide.bs.password', {relatedTarget: _relatedTarget});
133
+ this.$element.trigger(e);
134
+
135
+ this.isShown = false;
136
+ this.$element.show();
137
+ this.$text.hide();
138
+ if (this.options.eyeClassPositionInside) {
139
+ this.$icon.find('i')
140
+ .removeClass('icon-eye-close')
141
+ .addClass('icon-eye-open')
142
+ .html(this.options.eyeOpenClass);
143
+ } else {
144
+ this.$icon.find('i')
145
+ .removeClass('icon-eye-close ' + this.options.eyeCloseClass)
146
+ .addClass('icon-eye-open ' + this.options.eyeOpenClass);
147
+ }
148
+
149
+ // v3 input-group
150
+ this.$element[this.options.placement](this.$text);
151
+ };
152
+
153
+ Password.prototype.val = function (value) {
154
+ if (typeof value === 'undefined') {
155
+ return this.$element.val();
156
+ } else {
157
+ this.$element.val(value).trigger('change');
158
+ this.$text.val(value);
159
+ }
160
+ };
161
+
162
+ Password.prototype.focus = function () {
163
+ this.$element.focus();
164
+ };
165
+
166
+
167
+ // PASSWORD PLUGIN DEFINITION
168
+ // =======================
169
+
170
+ var old = $.fn.password;
171
+
172
+ $.fn.password = function() {
173
+ var option = arguments[0],
174
+ args = arguments,
175
+
176
+ value,
177
+ allowedMethods = [
178
+ 'show', 'hide', 'toggle', 'val', 'focus'
179
+ ]; // public function
180
+
181
+ this.each(function() {
182
+ var $this = $(this),
183
+ data = $this.data('bs.password'),
184
+ options = $.extend({}, Password.DEFAULTS, $this.data(), typeof option === 'object' && option);
185
+
186
+ if (typeof option === 'string') {
187
+ if ($.inArray(option, allowedMethods) < 0) {
188
+ throw "Unknown method: " + option;
189
+ }
190
+ value = data[option](args[1]);
191
+ } else {
192
+ if (!data) {
193
+ data = new Password($this, options);
194
+ $this.data('bs.password', data);
195
+ } else {
196
+ data.init(options);
197
+ }
198
+ }
199
+ });
200
+
201
+ return value ? value : this;
202
+ };
203
+
204
+ $.fn.password.Constructor = Password;
205
+
206
+
207
+ // PASSWORD NO CONFLICT
208
+ // =================
209
+
210
+ $.fn.password.noConflict = function() {
211
+ $.fn.password = old;
212
+ return this;
213
+ };
214
+
215
+ $(function () {
216
+ $('[data-toggle="password"]').password();
217
+ });
218
+
219
+ }(window.jQuery);
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootstrap-show-password-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.r2
5
+ platform: ruby
6
+ authors:
7
+ - Claudio Maradonna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
42
+ email:
43
+ - claudio@unitoo.pw
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/bootstrap-show-password-rails.rb
52
+ - lib/bootstrap-show-password-rails/engine.rb
53
+ - lib/bootstrap-show-password-rails/railtie.rb
54
+ - lib/bootstrap-show-password-rails/version.rb
55
+ - vendor/assets/javascripts/bootstrap-show-password.js
56
+ homepage: https://github.com/UnitooTeam/bootstrap-show-password-rails
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">"
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.1
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.14
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Plugin to show/hide passwords from fields
80
+ test_files: []