| // Generated by CoffeeScript 1.10.0 |
| |
| /** |
| * RDInputLabel |
| * @license MIT License |
| */ |
| |
| (function() { |
| (function($, document, window) { |
| |
| /** |
| * Initial flags |
| * @public |
| */ |
| var RDInputLabel, isMobile; |
| isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); |
| |
| /** |
| * Creates a label. |
| * @class RDInputLabel. |
| * @public |
| * @param {HTMLElement} element - The element to create the label for. |
| * @param {Object} [options] - The options |
| */ |
| RDInputLabel = (function() { |
| |
| /** |
| * Default options for label. |
| * @public |
| */ |
| RDInputLabel.prototype.Defaults = { |
| callbacks: null |
| }; |
| |
| function RDInputLabel(element, options) { |
| this.options = $.extend(true, {}, this.Defaults, options); |
| this.$element = $(element).addClass('rd-input-label'); |
| this.$target = $('#' + this.$element.attr("for")); |
| this.$win = $(window); |
| this.$doc = $(document); |
| this.initialize(); |
| } |
| |
| |
| /** |
| * Initializes the Parallax. |
| * @protected |
| */ |
| |
| RDInputLabel.prototype.initialize = function() { |
| this.$target.on('input', $.proxy(this.change, this)).on('focus', $.proxy(this.focus, this)).on('blur', $.proxy(this.blur, this)).parents('form').on('reset', $.proxy(this.reset, this)); |
| this.change(); |
| return this; |
| }; |
| |
| RDInputLabel.prototype.change = function() { |
| if (this.$target.val() !== '') { |
| if (!this.$element.hasClass('focus')) { |
| this.focus(); |
| } |
| this.$element.addClass('not-empty'); |
| } else { |
| this.$element.removeClass('not-empty'); |
| } |
| return this; |
| }; |
| |
| RDInputLabel.prototype.focus = function() { |
| this.$element.addClass('focus'); |
| return this; |
| }; |
| |
| RDInputLabel.prototype.reset = function() { |
| setTimeout($.proxy(this.blur, this)); |
| return this; |
| }; |
| |
| RDInputLabel.prototype.blur = function(e) { |
| if (this.$target.val() === '') { |
| this.$element.removeClass('focus').removeClass('not-empty'); |
| } |
| return this; |
| }; |
| |
| return RDInputLabel; |
| |
| })(); |
| |
| /** |
| * The jQuery Plugin for the RD Parallax |
| * @public |
| */ |
| $.fn.extend({ |
| RDInputLabel: function(options) { |
| return this.each(function() { |
| var $this; |
| $this = $(this); |
| if (!$this.data('RDInputLabel')) { |
| return $this.data('RDInputLabel', new RDInputLabel(this, options)); |
| } |
| }); |
| } |
| }); |
| return window.RDInputLabel = RDInputLabel; |
| })(window.jQuery, document, window); |
| |
| |
| /** |
| * The Plugin AMD export |
| * @public |
| */ |
| |
| if (typeof module !== "undefined" && module !== null) { |
| module.exports = window.RDInputLabel; |
| } else if (typeof define === 'function' && define.amd) { |
| define(["jquery"], function() { |
| 'use strict'; |
| return window.RDInputLabel; |
| }); |
| } |
| |
| }).call(this); |