TimeTrex/interface/html5/dist/feedback-TFeedback.bundle.js

1 line
36 KiB
JavaScript
Raw Permalink Normal View History

2022-12-13 07:10:06 +01:00
(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["feedback-TFeedback"],{8218:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("/* provided dependency */ var jQuery = __webpack_require__(9755);\n( function( $ ) {\n\n\t$.fn.TFeedback = function( _options ) {\n\t\tvar options = $.extend( {\n\t\t\tsource: '',\n\t\t\tforce_source: false, // does not prepend viewId to source value\n\t\t\tdelay: 0,\n\t\t\tmanual_trigger: false,\n\t\t\tprompt_for_feedback: false, // Default is false so that only manual trigger, custom functions, or server input will make the feedback popup appear.\n\t\t\treview_link: 'https://www.timetrex.com/r?id=review&product_edition_id=' + Global.getProductEdition()\n\t\t}, _options );\n\n\t\t// DOM references for containers and pages\n\t\tvar feedback_container = Global.loadWidgetByName( FormItemType.FEEDBACK_BOX ); // Note: There is a .feedback-overlay div at the root of feedback_container controlled by CSS.\n\t\tvar page_title = feedback_container.find( '.top-bar-title' );\n\t\tvar all_pages = feedback_container.find( '.feedback-page' );\n\t\tvar default_page = feedback_container.find( '.feedback-page.default' );\n\t\tvar positive_page = feedback_container.find( '.feedback-page.positive' );\n\t\tvar negative_page = feedback_container.find( '.feedback-page.negative' );\n\n\t\tvar api = TTAPI.APIUser;\n\n\t\tvar feedback = {\n\t\t\tPOSITIVE: 'postitive',\n\t\t\tNEUTRAL: 'neutral',\n\t\t\tNEGATIVE: 'negative'\n\t\t};\n\n\t\tfunction init() {\n\n\t\t\t// check the feedback prompt status set by API\n\t\t\tif ( LocalCacheData.getLoginUser() && LocalCacheData.getLoginUser().prompt_for_feedback == true ) {\n\t\t\t\toptions.prompt_for_feedback = true;\n\t\t\t\tLocalCacheData.getLoginUser().prompt_for_feedback = false;\n\t\t\t\t// TODO: API Call to save the new value\n\t\t\t}\n\n\t\t\tif ( options.prompt_for_feedback ) {\n\t\t\t\t// Append current view id to the source\n\t\t\t\tif ( !options.force_source ) {\n\t\t\t\t\toptions.source = LocalCacheData.current_open_view_id + '@' + options.source;\n\t\t\t\t}\n\n\t\t\t\t// Initialise the default page (not visible until showFeedbackContainer() is triggered.\n\t\t\t\tshowPage( 'default' );\n\n\t\t\t\t// Display feedback dialog either immediately or with a delay\n\t\t\t\tif ( options.delay && options.delay > 0 ) {\n\t\t\t\t\tdelayShowFeedbackContainer( options.delay );\n\t\t\t\t} else {\n\t\t\t\t\tshowFeedbackContainer();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction getFeedbackType() {\n\t\t\tif ( options.manual_trigger ) {\n\t\t\t\treturn 'click';\n\t\t\t} else {\n\t\t\t\treturn 'popup';\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t *\n\t\t * @param {number} duration - number of milliseconds to delay the feedback popup from showing.\n\t\t */\n\t\tfunction delayShowFeedbackContainer( duration ) {\n\t\t\tduration = duration || 0;\n\t\t\tDebug.Text( 'Setting feedback display delay to ' + duration, 'TFeedback.js', 'TFeedback', 'initDefaultPage', 10 );\n\t\t\tsetTimeout( function() {\n\t\t\t\tDebug.Text( 'Triggering delayed feedback display', 'TFeedback.js', 'TFeedback', 'initDefaultPage', 10 );\n\t\t\t\tshowFeedbackContainer();\n\t\t\t}, duration );\n\t\t}\n\n\t\tfunction showFeedbackContainer() {\n\t\t\tif ( $( '.feedback-container' ).length == 0 ) {\n\t\t\t\t$( 'body' ).append( feedback_container );\n\t\t\t} else {\n\t\t\t\tDebug.Text( 'ERROR: Feedback container already exists, halting to prevent duplicate popups.', 'TFeedback.js', 'TFeedback', 'initDefaultPage', 1 );\n\t\t\t}\n\t\t}\n\n\t\tfunction removeFeedbackContainer() {\n\t\t\tif ( Global.isSet( feedback_container ) ) {\n\t\t\t\tfeedback_container.remove();\n\t\t\t}\n\t\t}\n\n\t\tfunction initDefaultPage() {\n\t\t\tpage_title.html( $.i18n._( 'Feedback' ) );\n\t\t\tdefault_page.find( '.page-text' ).text( $.i18n._( 'Tell us what you think about TimeTrex?' ) );\n\n\t\t\tdefault_page.find( '.positive-button' )\n\t\t\t\t.html( $.i18n._( 'It\\'s great!' ) )\n\t\t\t\t.bind( 'click', function() {\n\t\t\t\t\tshowPage( 'positive' );\n\t\t\t\t\tDebug.Text( 'Feedback Analytics: Category: feedback,