dynamojs_rails 0.0.1 → 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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/dynamojs_rails/version.rb +1 -1
- data/vendor/assets/javascripts/dynamo.js +113 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4fb02295f2ce588d7e8d21fb71192d20d00347f
|
4
|
+
data.tar.gz: 217006ec9aac37ff106d1dbc40eb68fb7b3db211
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad99c45c9f0e1d34dc1a497d5fd644f608dab3f5af8239779d241cd3fbf7961fbc6a4c8da2c7067adc465981dbbd7bd812de6f5f094874d11049453fbe634f21
|
7
|
+
data.tar.gz: 11188a62718aada9a2308409c915e6d7b08cd436723bf0b13261e1477d7816cd7dd1b4cb4a384b3b5ee698ef72946a69bf74b38ff55c368645f2bcfd418d5760
|
data/README.md
CHANGED
@@ -1,4 +1,116 @@
|
|
1
|
-
|
1
|
+
/*!
|
2
|
+
* dynamo.js
|
3
|
+
* http://prezjordan.github.io/dynamo.js
|
4
|
+
*
|
5
|
+
* Copyright 2013 Jordan Scales (http://jordanscales.com)
|
6
|
+
* Released under the MIT license
|
7
|
+
* See LICENSE.txt
|
8
|
+
*
|
9
|
+
* Date: 2013-05-04
|
10
|
+
*/
|
11
|
+
|
12
|
+
(function($) {
|
13
|
+
|
14
|
+
$.fn.dynamo = function(options) {
|
15
|
+
|
16
|
+
return this.each(function(i, v) {
|
17
|
+
options = options || {};
|
18
|
+
|
19
|
+
// select the element v
|
20
|
+
var v$ = $(v);
|
21
|
+
|
22
|
+
// we mark launched dynamos as "intialized" then check so we don't initialize them twice
|
23
|
+
if (v$.data('initialized') == 'true')
|
24
|
+
return;
|
25
|
+
|
26
|
+
var delay = options.delay || parseInt(v$.data('delay')) || 3000;
|
27
|
+
var speed = options.speed || parseInt(v$.data('speed')) || 350;
|
28
|
+
var pause = options.pause || v$.data('pause') || false;
|
29
|
+
var lines = options.lines || v$.data('lines').split(v$.data('delimiter') || ',');
|
30
|
+
var callback = options.callback || v$.data('callback') || function() {};
|
31
|
+
var centered = options.centered || v$.data('center') || false;
|
32
|
+
|
33
|
+
// wrap the original contents in a span
|
34
|
+
v$.html($('<span></span>').html(v$.html())).data('initialized', 'true');
|
35
|
+
|
36
|
+
// grab the width of the span
|
37
|
+
var max = v$.find('span:eq(0)').width();
|
38
|
+
|
39
|
+
// for each item in data-lines, create a span with item as its content
|
40
|
+
// compare the width of this span with the max
|
41
|
+
for (k in lines) {
|
42
|
+
var span = $('<span></span>').html(lines[k]);
|
43
|
+
|
44
|
+
v$.append(span);
|
45
|
+
max = Math.max(max, span.width());
|
46
|
+
}
|
47
|
+
|
48
|
+
// replace all the spans with inline-div$'s
|
49
|
+
v$.find('span').each(function(i, ele) {
|
50
|
+
var old$ = $(ele).remove();
|
51
|
+
var div$ = $('<div></div>').html(old$.html());
|
52
|
+
|
53
|
+
if (!i) {
|
54
|
+
// our last element gets tagged
|
55
|
+
div$.data('trigger', 'true');
|
56
|
+
}
|
57
|
+
|
58
|
+
div$.width(max);
|
59
|
+
v$.append(div$);
|
60
|
+
});
|
61
|
+
|
62
|
+
// set the height of the dynamo container
|
63
|
+
var height = v$.find('>:first-child').height();
|
64
|
+
|
65
|
+
// style
|
66
|
+
v$.width(max)
|
67
|
+
.height(height)
|
68
|
+
.css({
|
69
|
+
'display' : 'inline-block',
|
70
|
+
'position' : 'relative',
|
71
|
+
'overflow' : 'hidden',
|
72
|
+
'vertical-align' : 'bottom',
|
73
|
+
'text-align' : 'left'
|
74
|
+
});
|
75
|
+
|
76
|
+
// manually center it if we need to
|
77
|
+
if (centered)
|
78
|
+
v$.css('text-align', 'center');
|
79
|
+
|
80
|
+
// now, animate it
|
81
|
+
var transition = function() {
|
82
|
+
v$.dynamo_trigger({ speed: speed, callback: callback });
|
83
|
+
};
|
84
|
+
|
85
|
+
if (!pause) {
|
86
|
+
setInterval(transition, delay);
|
87
|
+
}
|
88
|
+
});
|
89
|
+
};
|
90
|
+
|
91
|
+
$.fn.dynamo_trigger = function(options) {
|
92
|
+
|
93
|
+
return this.each(function(i, v) {
|
94
|
+
options = options || {}
|
95
|
+
|
96
|
+
var v$ = $(v);
|
97
|
+
var speed = options.speed || v$.data('speed') || 350;
|
98
|
+
var callback = options.callback || v$.data('callback') || function() {};
|
99
|
+
|
100
|
+
v$.find('div:first').slideUp(speed, function() {
|
101
|
+
v$.append($(this).show());
|
102
|
+
|
103
|
+
// check if the first item has made its way to the top again
|
104
|
+
if (v$.find('div:first').data('trigger') == 'true')
|
105
|
+
eval(callback).call();
|
106
|
+
});
|
107
|
+
});
|
108
|
+
};
|
109
|
+
|
110
|
+
// automatically initiate cycles on elements of class 'dynamo'
|
111
|
+
$('.dynamo').dynamo();
|
112
|
+
|
113
|
+
})(jQuery);
|
2
114
|
|
3
115
|
$(document).ready(function(){
|
4
116
|
$('.dynamo').dynamo();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamojs_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hank Stoever
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|