1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- define( function() {
- "use strict";
- function Control()
- {
- };
- Control.prototype.draw = function( oControlHost )
- {
- var o = oControlHost.configuration || {};
- var el = oControlHost.container;
- var v_iHeight = ( o.Height || el.offsetHeight );
- var v_iWidth = ( o.Width || el.offsetWidth );
- var v_bPositionOnTheRight = ( o.Position == "Right" );
- var sSourceType = o["Source Type"] || "Text";
- var sSelector = "#" + el.id;
- var sStyle =
- '<style>' +
- sSelector + ' svg' +
- '{' +
- 'fill:' + ( o["Fill"] || "#6D7777" ) + ';' +
- '}' +
- sSelector + ' svg:hover' +
- '{' +
- 'fill:' + ( o["Hover Fill"] || "#4178BE" ) + ';' +
- '}' +
- sSelector + ' DIV' +
- '{' +
- 'cursor: default;' +
- 'visibility: hidden;' +
- 'position: absolute;' +
- ( ( o["Box Shadow"] !== false ) ? 'box-shadow:0 1px 5px rgba(0, 0, 0, 0.25);' : '' ) +
- 'margin: ' + ( v_bPositionOnTheRight ? '0' : v_iHeight ) + 'px 0 0 ' + ( v_bPositionOnTheRight ? v_iWidth : '0' ) + 'px;';
- if ( sSourceType == "Text" )
- {
- sStyle +=
- 'max-width: ' + ( o["Max Width"] || 300 ) + 'px;' +
- 'padding: 2px 4px 2px 4px;' +
- 'border-radius: 2px;' +
- 'border: 1px solid ' + ( o["Border Color"] || '#E6E7E8' ) + ';' +
- 'color: ' + ( o["Font Color"] || '#444444' ) + ';' +
- 'background-color: ' + ( o["Background Color"] || '#F2F2F2' ) + ';' +
- ( o["Font Family"] ? ( 'font-family:' + o["Font Family"] + ';' ) : '' ) +
- ( o["Font Size"] ? ( 'font-size:' + o["Font Size"] + ';' ) : '' );
- }
- sStyle +=
- '}' +
- sSelector + ':hover DIV { visibility:visible; }' +
- '</style>';
- var sSvgIcon = o["SVG Icon"] || '<svg xmlns="http://www.w3.org/2000/svg" width="' + v_iWidth + 'px" height="' + v_iHeight + 'px" viewBox="0 0 32 32"><use xlink:href="#common-information"/></svg>';
- var sSource = o.Text || "";
- if ( !sSource && this.m_oDataStore )
- {
- sSource = this.m_oDataStore.getFormattedCellValue( 0, 0 );
- }
- switch ( sSourceType )
- {
- case "Text":
- sSource = this.HTMLEncode( sSource );
- break;
- case "URL":
- sSource = '<img src="' + sSource + '"/>';
- break;
- }
- el.innerHTML = sStyle + '<DIV>' + sSource + '</DIV>' + sSvgIcon;
- };
- Control.prototype.setData = function( oControlHost, oDataStore )
- {
- this.m_oDataStore = oDataStore;
- };
- Control.prototype.HTMLEncode = function( s )
- {
- return String( s ).replace( /&/g, "&" ).replace( /</g, "<" ).replace( />/g, ">" );
- };
- return Control;
- });
|