3
$.fn.TFeedback = function( options ) {
4
var opts = $.extend( {}, $.fn.TFeedback.defaults, options );
12
this.user_api = new (APIFactory.getAPIClass( 'APIUser' ))();
13
this.feedback_submitted = false;
15
this.removeMessageContainer = function() {
16
if ( Global.isSet( message_container ) ) {
17
message_container.remove();
21
this.saveIconSelection = function(){
22
if ( this.feedback_submitted == false || this.feedback_submitted == undefined ) {
23
this.feedback_submitted = true;
25
if (message_box.val().length > 0) {
26
message = message_box.val() + '\nEmail: ' + message_email.val() + "\nPhone: " + message_phone.val();
28
$this.api['setUserFeedbackRating'](feedback_rating, message, {
29
onResult: function (res) {
31
$this.parent().find('img').each(function () {
32
$(this).removeClass('current').attr('src', $(this).attr('src').replace(/^(.*\/)[^\/]+$/, '$1') + $(this).attr('alt') + '.png');
34
$this.addClass('current').attr('src', $this.attr('src').replace(/^(.*\/)[^\/]+$/, '$1') + $this.attr('alt') + '_light.png');
35
$this.removeMessageContainer();
36
$this.user_api['getUser']({filter_data: {id: LocalCacheData.getLoginUser().id}}, {
37
onResult: function (res) {
39
LocalCacheData.setLoginUser(res.getResult()[0]);
49
this.each( function() {
50
var o = $.meta ? $.extend( {}, opts, $( this ).data() ) : opts;
52
$this.api = new (APIFactory.getAPIClass( 'APIUser' ))();
54
var current_user_api = new (APIFactory.getAPIClass( 'APICurrentUser' ))();
55
var user = current_user_api.getCurrentUser({async:false});
56
user = user.getResult();
58
if ( user.work_email != false && user.work_email != '' ) {
59
user_email = user.work_email;
60
} else if ( user.home_email != false ) {
61
user_email = user.home_email;
64
if ( user.work_phone != false && user.work_phone != '' ) {
65
user_phone = user.work_phone;
66
} else if ( user.home_phone != false ) {
67
user_phone = user.home_phone;
69
message_container = Global.loadWidgetByName( FormItemType.FEEDBACK_BOX );
71
message_box = message_container.find('.feedback-messagebox');
72
message_email = message_container.find('.feedback-email');
73
message_phone = message_container.find('.feedback-phone');
75
message_email.val(user_email);
76
message_phone.val(user_phone);
78
feedback_rating = $this.attr('data-feedback');
80
if ( $(this ).attr('alt') == 'happy' ) {
81
$( message_container.find('.title' ) ).text( $.i18n._( 'Glad to hear that you are happy with your TimeTrex experience! But we don\'t want to rest on our laurels, so let us know what we are doing right, or what we can do to make further improvements, we will listen, promise.' ) )
82
} else if ( $(this ).attr('alt') == 'neutral' ) {
83
$( message_container.find('.title' ) ).text( $.i18n._( 'Sorry to hear that you are not satisfied with your TimeTrex experience, please let us know how we can improve, we will listen, promise.' ) )
84
} else if ( $(this ).attr('alt') == 'sad' ) {
85
$( message_container.find('.title' ) ).text( $.i18n._( 'Oh no! Sorry to hear that you are unhappy with your TimeTrex experience, please let us know how we can improve, we will listen, promise.' ) )
88
message_container.find('.sendButton').html($.i18n._( 'Send' ) );
89
message_container.find('.cancelButton').html($.i18n._( 'Cancel' ) );
90
message_container.find('.top-bar-title').html( $.i18n._( 'Feedback' ) );
91
message_container.find('.email-label-text').html( $.i18n._( 'Email' ) );
92
message_container.find('.phone-label-text').html( $.i18n._( 'Phone' ) );
93
message_container.find('.contact-notice-text').html( $.i18n._( 'If you would like to be contacted regarding your feedback, please provide') +':' );
95
message_container.find('.sendButton' ).bind('click', $this.saveIconSelection);
97
message_container.find('.cancelButton' ).bind('click', $this.removeMessageContainer);
99
if ( $('body' ).children('.message-container' ).length == 0 ) {
100
$('body' ).append( message_container );
109
$.fn.TFeedback.defaults = {
b'\\ No newline at end of file'