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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 4b27158e09639d9e4c72e00b5bf7ae3481cf5b9e
4
- data.tar.gz: 00de2a782d9ac4ac29d339eba6229f22b134d8ec
3
+ metadata.gz: d4fb02295f2ce588d7e8d21fb71192d20d00347f
4
+ data.tar.gz: 217006ec9aac37ff106d1dbc40eb68fb7b3db211
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 0ec0c7e40485fbf1660cd073d48e1a8fe0606dc9a568a723f340c4d48375d1a7ef4eac8ebcfe4ea5b0131441f887d2d5d6f489c940b336a9d1ffadaf1fd73fe2
7
- data.tar.gz: ea849be6b0fb2234388c7c3d9e2bfc6ff3006d2f0226546274f1aa7f6580c7fb7c7c866807e470aaeff65cb5b7dadce4755c6e34ee5d744966eaffe2c22ec400
6
+ metadata.gz: ad99c45c9f0e1d34dc1a497d5fd644f608dab3f5af8239779d241cd3fbf7961fbc6a4c8da2c7067adc465981dbbd7bd812de6f5f094874d11049453fbe634f21
7
+ data.tar.gz: 11188a62718aada9a2308409c915e6d7b08cd436723bf0b13261e1477d7816cd7dd1b4cb4a384b3b5ee698ef72946a69bf74b38ff55c368645f2bcfd418d5760
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A light wrapper for using [dynamo.js](http://jordanscales.com/dynamo/) with Ruby on Rails.
4
4
 
5
+ [![Build Status](https://travis-ci.org/hstove/dynamojs_rails.png?branch=master)](https://travis-ci.org/hstove/dynamojs_rails)
6
+
5
7
  ## Installation
6
8
 
7
9
  In your `Gemfile`:
@@ -1,3 +1,3 @@
1
1
  module DynamojsRails
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,4 +1,116 @@
1
- (function($){$.fn.dynamo=function(options){return this.each(function(i,v){options=options||{};var v=$(v);if(v.data("initialized")=="true")return;var delay=options.delay||parseInt(v.data("delay"))||3e3;var speed=options.speed||parseInt(v.data("speed"))||350;var pause=options.pause||v.data("pause")||false;var lines=options.lines||v.data("lines").split(v.data("delimiter")||",");var callback=options.callback||v.data("callback")||function(){};v.html($("<span></span>").text(v.text())).data("initialized","true");var max=v.find("span:eq(0)").width();for(k in lines){var span=$("<span></span>").text(lines[k]);v.append(span);max=Math.max(max,span.width())}v.find("span").each(function(i,ele){s=$(ele).remove();d=$("<div></div>").text(s.text());if(!i){d.data("trigger","true")}d.width(max);v.append(d)});var height=v.find(">:first-child").height();v.width(max).height(height).css({display:"inline-block",position:"relative",overflow:"hidden","vertical-align":"bottom","text-align":"left"});if(v.data("center"))v.css("text-align","center");var transition=function(){v.dynamo_trigger({speed:speed,callback:callback})};if(!pause){setInterval(transition,delay)}})};$.fn.dynamo_trigger=function(options){return this.each(function(i,v){options=options||{};var speed=options.speed||$(v).data("speed")||350;var callback=options.callback||$(v).data("callback")||function(){};$(v).find("div:first").slideUp(speed,function(){$(v).append($(this).show());if($(v).find("div:first").data("trigger")=="true")eval(callback).call()})})};$(".dynamo").dynamo()})(jQuery);
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2013-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler