typing 0.1.3

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: 5e2a35ac38d6273bf3a7c5f1c92dbb9f0f9ea5ce
4
+ data.tar.gz: cbaf1dd286650a32b3a9d5ac3949bce3c0f0d4b4
5
+ SHA512:
6
+ metadata.gz: 853cf56b4b2a2fd5d8157a6b79bf629ba5ff2b22d5e459924b3ddc86b0e70d7871d36994780aa729630da770e7dbd7cb04ef3eb3d016e3c946cedffdf38bad27
7
+ data.tar.gz: d5d57ae56e2c48a677967fdf5570df85fd766f4120b2f4a07373cbae2800d31ce38cbf3c9bb3c39ebcfe71decbfad17098d6ba3f195e5a2eb7275949ea818a90
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 - 2999 Bryan Lim (@ytbryan)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Typing
2
+
3
+ ![Typing](assets/images/typing.gif)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'typing'
11
+ ```
12
+
13
+ At Application.js, add this after turbolink:
14
+ ```
15
+ //require typing
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install typing
25
+
26
+ ## Usage
27
+
28
+ At your view.
29
+
30
+ ```
31
+ <h1>I like to eat <%= typing @array %> for my dinner.</h1>
32
+ ```
33
+
34
+ At your controller, pass in the array.
35
+
36
+ ```
37
+ @array = ["Pizza","Sushi","Potato Chips"]
38
+ ```
39
+
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ytbryan/typing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
50
+
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,29 @@
1
+ module TypingHelper
2
+
3
+ def typing array
4
+ answer = "["
5
+ array.each_with_index do |value, index|
6
+ if index != array.count - 1
7
+ answer = answer + "&quot;" + "#{value}" + "&quot;" + ","
8
+ else
9
+ answer = answer + "&quot;" + "#{value}" + "&quot;"
10
+ end
11
+ end
12
+ answer = answer + "]"
13
+ return "<span class=\"typer-target\" data-typer-targets=\"{&quot;targets&quot;:#{answer}}\"> #{array[array.count-1]}</span>".html_safe
14
+ end
15
+
16
+ def fade array
17
+ answer = "["
18
+ array.each_with_index do |value, index|
19
+ if index != array.count - 1
20
+ answer = answer + "&quot;" + "#{value}" + "&quot;" + ","
21
+ else
22
+ answer = answer + "&quot;" + "#{value}" + "&quot;"
23
+ end
24
+ end
25
+ answer = answer + "]"
26
+ return "<span class=\"typer-target\" data-typer-targets=\"{&quot;targets&quot;:#{answer}}\"> #{array[array.count-1]}</span>".html_safe
27
+ end
28
+
29
+ end
@@ -0,0 +1,6 @@
1
+ require "typing/version"
2
+
3
+ module Typing
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Typing
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,91 @@
1
+ String.prototype.rightChars = function (t) {
2
+ return 0 >= t ? "" : t > this.length ? this : this.substring(this.length, this.length - t)
3
+ },
4
+ function (t) {
5
+ var n, e, r, o, a, i, p, s, u, l, d, h, g = {
6
+ highlightSpeed: 20,
7
+ typeSpeed: 100,
8
+ clearDelay: 500,
9
+ typeDelay: 200,
10
+ clearOnHighlight: !0,
11
+ typerDataAttr: "data-typer-targets",
12
+ typerInterval: 2e3
13
+ };
14
+ o = function (n, e) {
15
+ return "rgba(0, 0, 0, 0)" === n && (n = "rgb(255, 255, 255)"), t("<span></span>").css("color", n).css("background-color", e)
16
+ }, s = function (t) {
17
+ return !isNaN(parseFloat(t)) && isFinite(t)
18
+ }, p = function (t) {
19
+ t.data("typePosition", null).data("highlightPosition", null).data("leftStop", null).data("rightStop", null).data("primaryColor", null).data("backgroundColor", null).data("text", null).data("typing", null)
20
+ }, r = function (t) {
21
+ var n = t.data("text"),
22
+ e = t.data("oldLeft"),
23
+ o = t.data("oldRight");
24
+ return n && 0 !== n.length ? (t.text(e + n.charAt(0) + o), t.data("oldLeft", e + n.charAt(0)), t.data("text", n.substring(1)), setTimeout(function () {
25
+ r(t)
26
+ }, d()), void 0) : (p(t), void 0)
27
+ }, e = function (t) {
28
+ t.find("span").remove(), setTimeout(function () {
29
+ r(t)
30
+ }, i())
31
+ }, n = function (t) {
32
+ var r, i, p, u = t.data("highlightPosition");
33
+ return s(u) || (u = t.data("rightStop") + 1), u <= t.data("leftStop") ? (setTimeout(function () {
34
+ e(t)
35
+ }, a()), void 0) : (r = t.text().substring(0, u - 1), i = t.text().substring(u - 1, t.data("rightStop") + 1), p = t.text().substring(t.data("rightStop") + 1), t.html(r), t.append(o(t.data("backgroundColor"), t.data("primaryColor")).append(i)).append(p), t.data("highlightPosition", u - 1), setTimeout(function () {
36
+ return n(t)
37
+ }, l()), void 0)
38
+ }, u = function (n) {
39
+ var e;
40
+ if (!n.data("typing")) {
41
+ try {
42
+ e = JSON.parse(n.attr(t.typer.options.typerDataAttr)).targets
43
+ } catch (r) {}
44
+ "undefined" == typeof e && (e = t.map(n.attr(t.typer.options.typerDataAttr).split(","), function (n) {
45
+ return t.trim(n)
46
+ }));
47
+ var o = n.data("typeIndex"),
48
+ a = "undefined" == typeof o ? 0 : o + 1 < e.length ? o + 1 : 0;
49
+ n.data("typeIndex", a), n.typeTo(e[a])
50
+ }
51
+ }, t.typer = function () {
52
+ return {
53
+ options: g
54
+ }
55
+ }(), t.extend(t.typer, {
56
+ options: g
57
+ }), t.fn.typer = function () {
58
+ var n = t(this);
59
+ n = n.filter(function () {
60
+ return "undefined" != typeof t(this).attr(t.typer.options.typerDataAttr)
61
+ }), n.each(function () {
62
+ var n = t(this);
63
+ u(n), setInterval(function () {
64
+ u(n)
65
+ }, h())
66
+ })
67
+ }, t.fn.typeTo = function (e) {
68
+ var r = t(this),
69
+ o = r.text(),
70
+ a = 0,
71
+ i = 0;
72
+ if (o === e) return console.log("Our strings our equal, nothing to type"), void 0;
73
+ if (o !== r.html()) return console.error("Typer does not work on elements with child elements."), void 0;
74
+ for (r.data("typing", !0); o.charAt(a) === e.charAt(a);) a++;
75
+ for (; o.rightChars(i) === e.rightChars(i);) i++;
76
+ e = e.substring(a, e.length - i + 1), r.data("oldLeft", o.substring(0, a)), r.data("oldRight", o.rightChars(i - 1)), r.data("leftStop", a), r.data("rightStop", o.length - i), r.data("primaryColor", r.css("color")), r.data("backgroundColor", r.css("background-color")), r.data("text", e), n(r)
77
+ }, l = function () {
78
+ return t.typer.options.highlightSpeed
79
+ }, d = function () {
80
+ return t.typer.options.typeSpeed
81
+ }, a = function () {
82
+ return t.typer.options.clearDelay
83
+ }, i = function () {
84
+ return t.typer.options.typeDelay
85
+ }, h = function () {
86
+ return t.typer.options.typerInterval
87
+ }
88
+ }(jQuery), $(function () {
89
+ var t = $(".typer-target");
90
+ $.typer.options.highlightSpeed = 10, $.typer.options.typeSpeed = 75, $.typer.options.typeDelay = 75, t.typer()
91
+ });
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Lim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-04 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Add typing effect to rails view easily.
56
+ email:
57
+ - ytbryan@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - app/helpers/typing_helper.rb
65
+ - lib/typing.rb
66
+ - lib/typing/version.rb
67
+ - vendor/assets/javascripts/typing.js
68
+ homepage: http://www.github.com/ytbryan/typing
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.4.8
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Typing Effect on rails view
92
+ test_files: []