1 line
5.4 KiB
JavaScript
1 line
5.4 KiB
JavaScript
(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["toggle_button-TToggleButton"],{5110:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("/* provided dependency */ var jQuery = __webpack_require__(9755);\n( function( $ ) {\n\n\t$.fn.TToggleButton = function( options ) {\n\n\t\tGlobal.addCss( 'global/widgets/toggle_button/ToggleButton.css' );\n\t\tvar opts = $.extend( {}, $.fn.TToggleButton.defaults, options );\n\n\t\tvar data_provider = [];\n\n\t\tvar $this = this;\n\n\t\tvar btn_dic = {};\n\n\t\tvar selected_btn;\n\n\t\tthis.getValue = function() {\n\t\t\treturn selected_btn ? selected_btn.val() : null;\n\t\t};\n\n\t\tthis.setValue = function( val ) {\n\t\t\tif ( selected_btn ) {\n\t\t\t\tselected_btn.removeClass( 'selected' );\n\t\t\t}\n\n\t\t\tselected_btn = btn_dic[val];\n\t\t\t//Error: TypeError: selected_btn is undefined in interface/html5/global/widgets/toggle_button/TToggleButton.js?v=9.0.4-20151123-161606 line 26\n\t\t\tselected_btn && selected_btn.addClass( 'selected' );\n\n\t\t};\n\n\t\tthis.each( function() {\n\n\t\t\tvar o = $.meta ? $.extend( {}, opts, $( this ).data() ) : opts;\n\n\t\t\tdata_provider = o.data_provider;\n\n\t\t\tbtn_dic = {};\n\n\t\t\tvar len = data_provider.length;\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar button_data = data_provider[i];\n\t\t\t\tvar btn = $( '<button></button>' );\n\t\t\t\tif ( i === 0 ) {\n\t\t\t\t\tbtn.addClass( 'toggle-button first' );\n\t\t\t\t} else if ( i === len - 1 ) {\n\t\t\t\t\tbtn.addClass( 'toggle-button last' );\n\t\t\t\t} else if ( i === 0 && i === len - 1 ) {\n\t\t\t\t\tbtn.addClass( 'toggle-button first-last' );\n\t\t\t\t} else {\n\t\t\t\t\tbtn.addClass( 'toggle-button middle' );\n\t\t\t\t}\n\n\t\t\t\tbtn_dic[button_data.value] = btn;\n\n\t\t\t\tbtn.val( button_data.value );\n\t\t\t\tbtn.text( button_data.label );\n\n\t\t\t\tbtn.click( function() {\n\t\t\t\t\t$this.setValue( $( this ).val() );\n\t\t\t\t\t$this.trigger( 'change', [$this.getValue()] );\n\t\t\t\t} );\n\n\t\t\t\t$this.append( btn );\n\t\t\t}\n\n\t\t} );\n\n\t\treturn this;\n\n\t};\n\n\t$.fn.TToggleButton.defaults = {};\n\n} )( jQuery );//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNTExMC5qcyIsIm1hcHBpbmdzIjoiO0FBQUE7O0FBRUE7O0FBRUE7QUFDQSx5QkFBeUI7O0FBRXpCOztBQUVBOztBQUVBOztBQUVBOztBQUVBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7O0FBRUE7O0FBRUEsZ0NBQWdDOztBQUVoQzs7QUFFQTs7QUFFQTtBQUNBLG9CQUFvQixTQUFTO0FBQzdCO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsTUFBTTtBQUNOO0FBQ0EsTUFBTTtBQUNOO0FBQ0EsTUFBTTtBQUNOO0FBQ0E7O0FBRUE7O0FBRUE7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQSxNQUFNOztBQUVOO0FBQ0E7O0FBRUEsSUFBSTs7QUFFSjs7QUFFQTs7QUFFQTs7QUFFQSxFQUFFLEdBQUcsTUFBTSIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2ludGVyZmFjZS9odG1sNS9nbG9iYWwvd2lkZ2V0cy90b2dnbGVfYnV0dG9uL1RUb2dnbGVCdXR0b24uanM/YWNkYyJdLCJzb3VyY2VzQ29udGVudCI6WyIoIGZ1bmN0aW9uKCAkICkge1xuXG5cdCQuZm4uVFRvZ2dsZUJ1dHRvbiA9IGZ1bmN0aW9u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