Skip to content

Commit

Permalink
Fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSaints committed Mar 9, 2014
1 parent 35269f1 commit 7fb4d6a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 56 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Usage

2. Encapsulate your rotating words in an element and separate each word with a comma or a separator of your choice:

I am a <span id="js-rotating">So Simple, Very Doge, Much Wow, Such Cool</span> Text Rotator
I am a <span id="js-rotating">So Simple, Very Doge, Much Wow, Such Cool</span> Text Rotator

3. Trigger the plugin by calling Morphext() on the element containing the rotating words:

$("#js-rotating").Morphext({
animation: "bounceIn", // Animation type (refer to Animate.css for a list of available animations)
separator: ",", // An array of words to rotate are created based on this separator. Change it if you wish to separate the words differently (e.g. So Simple | Very Doge | Much Wow | Such Cool)
speed: 2000 // The delay between each word in milliseconds
animation: "bounceIn", // Animation type (refer to Animate.css for a list of available animations)
separator: ",", // An array of words to rotate are created based on this separator. Change it if you wish to separate the words differently (e.g. So Simple | Very Doge | Much Wow | Such Cool)
speed: 2000 // The delay between each word in milliseconds
});


Expand Down
4 changes: 2 additions & 2 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</head>
<body>
<div style="text-align:center">
I am a <span id="js-rotating">So Simple, Very Doge, Much Wow, Such Cool</span> Text Rotator
</div>
I am a <span id="js-rotating">So Simple, Very Doge, Much Wow, Such Cool</span> Text Rotator
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="bower_components/jquery/jquery.min.js"><\/script>')</script>
Expand Down
2 changes: 1 addition & 1 deletion morphext.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.animated {
display: inline-block;
display: inline-block;
}
98 changes: 49 additions & 49 deletions morphext.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,64 @@
* http://ian.mit-license.org/
*/
;(function ($, window, document, undefined) {
var pluginName = "Morphext",
defaults = {
animation: "bounceIn",
separator: ",",
speed: 2000
};
var pluginName = "Morphext",
defaults = {
animation: "bounceIn",
separator: ",",
speed: 2000
};

function Plugin (element, options) {
this.element = $(element);
this.settings = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
function Plugin (element, options) {
this.element = $(element);
this.settings = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}

Plugin.prototype = {
init: function () {
var $that = this;
this.phrases = [];
Plugin.prototype = {
init: function () {
var $that = this;
this.phrases = [];

$.each(this.element.text().split(this.settings.separator), function (key, value) {
$that.phrases.push(value);
});
$.each(this.element.text().split(this.settings.separator), function (key, value) {
$that.phrases.push(value);
});

this.current = this.phrases[0];
this.current = this.phrases[0];

this.animate();
this.animate();

setInterval(function () {
$that.animate();
}, this.settings.speed);
},
animate: function () {
this._reset();
setInterval(function () {
$that.animate();
}, this.settings.speed);
},
animate: function () {
this._reset();

if (typeof this.next !== "undefined" && this.next !== null)
this.current = this.next;
if (typeof this.next !== "undefined" && this.next !== null)
this.current = this.next;

this.index = $.inArray(this.current, this.phrases);
if ((this.index + 1) == this.phrases.length) // Loop
this.index = -1;
this.index = $.inArray(this.current, this.phrases);
if ((this.index + 1) == this.phrases.length) // Loop
this.index = -1;

this.next = this.phrases[this.index + 1];
this.next = this.phrases[this.index + 1];

$("<span class='animated " + this.settings.animation + "'>" + this.current + "</span>")
.appendTo(this.element);
},
_reset: function () {
this.element.html('');
}
};
$("<span class='animated " + this.settings.animation + "'>" + this.current + "</span>")
.appendTo(this.element);
},
_reset: function () {
this.element.html('');
}
};

$.fn[pluginName] = function (options) {
return this.each(function() {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
}
});
};
$.fn[pluginName] = function (options) {
return this.each(function() {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
}
});
};
})(jQuery, window, document);

0 comments on commit 7fb4d6a

Please sign in to comment.