-
-
Save sivagao/5218689 to your computer and use it in GitHub Desktop.
jquery.feedback.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| window.Feedback = (function(){ | |
| var _initialized; | |
| function Feedback(){} | |
| _initialized = false; | |
| Feedback.init = function(options){ | |
| } | |
| Feedback.prototype.default_options = { | |
| htmlTemplate = [ | |
| "", | |
| "", | |
| this.placeHolder, | |
| "" | |
| ] | |
| }; | |
| Feedback.prototype.creataFeedbackBox = function(opts){ | |
| return $('#feedback-anchor').html(opts.htmlTemplate.join(''));// 改成template array 用到placeholder, 和 thanks_message | |
| /* | |
| */ | |
| }; | |
| Feedback.prototype.bindEvents = function(opts){ | |
| $(document).on('focus', '#feedback-anchor textarea', function(){ | |
| return $(this).closest('.feedback-container').addClass('expanded'); | |
| }); | |
| $(document).mouseup(function(e){ | |
| var container, container_textarea; | |
| container = $('#feedback-anchor'); | |
| container_textarea = container.find('textarea'); | |
| if (container.has(e.target).length === 0){ | |
| container_textarea.val(""); | |
| return container.find('.expanded').removeClass('expanded success-state'); | |
| } | |
| }); | |
| return $(document).on('click', '#feedback-anchor .button', function(){ | |
| var container, container_textarea; | |
| if(container_textarea.val() !== ''){ | |
| $(this).closest('.feedback-container').addClass('success-state'); | |
| opts.send_callback(container_textarea.val()); | |
| return setTimeout(function(){ | |
| container_textarea.val(""); | |
| return container.removeClass('success-state expanded'); | |
| }, 5000); | |
| } | |
| }) | |
| } | |
| return Feedback | |
| })() | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment