typedjs-rails 1.0.2 → 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1d3a0d8f97114c6c9153690899a4371ba603048d
4
+ data.tar.gz: 5468528a770860eaee5608a9623f1b0f6e533882
5
+ SHA512:
6
+ metadata.gz: 085186bd07a291006b365b14746f7fe55ca5854ab9daabf52ef5d3e8e66039845d18d7f3ee63eecd70cf9267da1f0a8dd26c31e38db3a0e3d69f08d3dff334a1
7
+ data.tar.gz: 33bf3971a5602de5bffd5611d117fc1a4f71559fff64ccbee3b0b98af4e8d0b681be2509e490000e4c5e272bbba3360cf221c0133ae24a88347012bb586423ac
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # typedjs-rails
2
2
  This gem just includes [Typed.js](https://github.com/mattboldt/typed.js) as an asset in the Rails 3.1 (or newer) asset pipeline.
3
3
 
4
+ The current version in the gem is Typed.js 1.1.1
5
+
4
6
  ## Installation
5
7
 
6
8
  Add the gem to the Gemfile
7
9
 
8
- gem "typedjs-rails", "~> 1.0.1"
10
+ gem "typedjs-rails", "~> 1.0.3"
9
11
 
10
12
  ## Usage
11
13
 
@@ -60,6 +60,9 @@
60
60
  // amount of time to wait before backspacing
61
61
  this.backDelay = this.options.backDelay;
62
62
 
63
+ // div containing strings
64
+ this.stringsElement = this.options.stringsElement;
65
+
63
66
  // input strings of text
64
67
  this.strings = this.options.strings;
65
68
 
@@ -85,6 +88,11 @@
85
88
  // custom cursor
86
89
  this.cursorChar = this.options.cursorChar;
87
90
 
91
+ // shuffle the strings
92
+ this.shuffle = this.options.shuffle;
93
+ // the order of strings
94
+ this.sequence = [];
95
+
88
96
  // All systems go!
89
97
  this.build();
90
98
  };
@@ -95,22 +103,36 @@
95
103
 
96
104
  ,
97
105
  init: function() {
98
- // begin the loop w/ first current string (global self.string)
106
+ // begin the loop w/ first current string (global self.strings)
99
107
  // current string will be passed as an argument each time after this
100
108
  var self = this;
101
109
  self.timeout = setTimeout(function() {
110
+ for (var i=0;i<self.strings.length;++i) self.sequence[i]=i;
111
+
112
+ // shuffle the array if true
113
+ if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
114
+
102
115
  // Start typing
103
- self.typewrite(self.strings[self.arrayPos], self.strPos);
116
+ self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos);
104
117
  }, self.startDelay);
105
118
  }
106
119
 
107
120
  ,
108
121
  build: function() {
122
+ var self = this;
109
123
  // Insert cursor
110
124
  if (this.showCursor === true) {
111
125
  this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
112
126
  this.el.after(this.cursor);
113
127
  }
128
+ if (this.stringsElement) {
129
+ self.strings = [];
130
+ this.stringsElement.hide();
131
+ var strings = this.stringsElement.find('p');
132
+ $.each(strings, function(key, value){
133
+ self.strings.push($(value).html());
134
+ });
135
+ }
114
136
  this.init();
115
137
  }
116
138
 
@@ -156,14 +178,21 @@
156
178
 
157
179
  if (self.contentType === 'html') {
158
180
  // skip over html tags while typing
159
- if (curString.substr(curStrPos).charAt(0) === '<') {
181
+ var curChar = curString.substr(curStrPos).charAt(0)
182
+ if (curChar === '<' || curChar === '&') {
160
183
  var tag = '';
161
- while (curString.substr(curStrPos).charAt(0) !== '>') {
184
+ var endTag = '';
185
+ if (curChar === '<') {
186
+ endTag = '>'
187
+ } else {
188
+ endTag = ';'
189
+ }
190
+ while (curString.substr(curStrPos).charAt(0) !== endTag) {
162
191
  tag += curString.substr(curStrPos).charAt(0);
163
192
  curStrPos++;
164
193
  }
165
194
  curStrPos++;
166
- tag += '>';
195
+ tag += endTag;
167
196
  }
168
197
  }
169
198
 
@@ -196,11 +225,13 @@
196
225
 
197
226
  // start typing each new char into existing string
198
227
  // curString: arg, self.el.html: original text inside element
199
- var nextString = self.elContent + curString.substr(0, curStrPos + 1);
228
+ var nextString = curString.substr(0, curStrPos + 1);
200
229
  if (self.attr) {
201
230
  self.el.attr(self.attr, nextString);
202
231
  } else {
203
- if (self.contentType === 'html') {
232
+ if (self.isInput) {
233
+ self.el.val(nextString);
234
+ } else if (self.contentType === 'html') {
204
235
  self.el.html(nextString);
205
236
  } else {
206
237
  self.el.text(nextString);
@@ -262,11 +293,13 @@
262
293
 
263
294
  // ----- continue important stuff ----- //
264
295
  // replace text with base text + typed characters
265
- var nextString = self.elContent + curString.substr(0, curStrPos);
296
+ var nextString = curString.substr(0, curStrPos);
266
297
  if (self.attr) {
267
298
  self.el.attr(self.attr, nextString);
268
299
  } else {
269
- if (self.contentType === 'html') {
300
+ if (self.isInput) {
301
+ self.el.val(nextString);
302
+ } else if (self.contentType === 'html') {
270
303
  self.el.html(nextString);
271
304
  } else {
272
305
  self.el.text(nextString);
@@ -288,15 +321,34 @@
288
321
 
289
322
  if (self.arrayPos === self.strings.length) {
290
323
  self.arrayPos = 0;
324
+
325
+ // Shuffle sequence again
326
+ if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
327
+
291
328
  self.init();
292
329
  } else
293
- self.typewrite(self.strings[self.arrayPos], curStrPos);
330
+ self.typewrite(self.strings[self.sequence[self.arrayPos]], curStrPos);
294
331
  }
295
332
 
296
333
  // humanized value for typing
297
334
  }, humanize);
298
335
 
299
336
  }
337
+ /**
338
+ * Shuffles the numbers in the given array.
339
+ * @param {Array} array
340
+ * @returns {Array}
341
+ */
342
+ ,shuffleArray: function(array) {
343
+ var tmp, current, top = array.length;
344
+ if(top) while(--top) {
345
+ current = Math.floor(Math.random() * (top + 1));
346
+ tmp = array[current];
347
+ array[current] = array[top];
348
+ array[top] = tmp;
349
+ }
350
+ return array;
351
+ }
300
352
 
301
353
  // Start & Stop currently not working
302
354
 
@@ -324,7 +376,9 @@
324
376
  var id = this.el.attr('id');
325
377
  this.el.after('<span id="' + id + '"/>')
326
378
  this.el.remove();
327
- this.cursor.remove();
379
+ if (typeof this.cursor !== 'undefined') {
380
+ this.cursor.remove();
381
+ }
328
382
  // Send the callback
329
383
  self.options.resetCallback();
330
384
  }
@@ -343,12 +397,15 @@
343
397
 
344
398
  $.fn.typed.defaults = {
345
399
  strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
400
+ stringsElement: null,
346
401
  // typing speed
347
402
  typeSpeed: 0,
348
403
  // time before typing starts
349
404
  startDelay: 0,
350
405
  // backspacing speed
351
406
  backSpeed: 0,
407
+ // shuffle the strings
408
+ shuffle: false,
352
409
  // time before backspacing
353
410
  backDelay: 500,
354
411
  // loop
@@ -1,3 +1,3 @@
1
1
  module Typedjs
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -4,7 +4,7 @@ require "typedjs/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "typedjs-rails"
7
- s.version = "1.0.2"
7
+ s.version = "1.0.3"
8
8
  s.authors = ["TheDartCode"]
9
9
  s.email = ["giorgos@thedartcode.com"]
10
10
  s.homepage = "http://www.thedartcode.com/"
metadata CHANGED
@@ -1,77 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: typedjs-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - TheDartCode
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2015-01-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: railties
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 5
29
- segments:
30
- - 3
31
- - 1
32
- version: "3.1"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
33
20
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: bundler
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
41
31
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 15
44
- segments:
45
- - 1
46
- - 0
47
- version: "1.0"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
48
34
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rails
52
35
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 5
59
- segments:
60
- - 3
61
- - 1
62
- version: "3.1"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
63
48
  type: :development
64
- version_requirements: *id003
65
- description: Gem that includes Typed.js, in the Rails Asset Pipeline introduced in Rails 3.1
66
- email:
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: Gem that includes Typed.js, in the Rails Asset Pipeline introduced in
56
+ Rails 3.1
57
+ email:
67
58
  - giorgos@thedartcode.com
68
59
  executables: []
69
-
70
60
  extensions: []
71
-
72
61
  extra_rdoc_files: []
73
-
74
- files:
62
+ files:
75
63
  - .gitignore
76
64
  - Gemfile
77
65
  - README.md
@@ -82,36 +70,25 @@ files:
82
70
  - typedjs-rails.gemspec
83
71
  homepage: http://www.thedartcode.com/
84
72
  licenses: []
85
-
73
+ metadata: {}
86
74
  post_install_message:
87
75
  rdoc_options: []
88
-
89
- require_paths:
76
+ require_paths:
90
77
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
100
- required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
109
88
  requirements: []
110
-
111
89
  rubyforge_project:
112
- rubygems_version: 1.8.15
90
+ rubygems_version: 2.4.6
113
91
  signing_key:
114
- specification_version: 3
92
+ specification_version: 4
115
93
  summary: Gem for easily adding Typed.js to the Rails Asset Pipeline
116
94
  test_files: []
117
-