C_CSSDefinition.js 7.0 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: hal
  3. // (C) Copyright IBM Corp. 2003, 2017.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. function C_CSSDefinition(_h3A1){this._hVM={};if(_h3A1){try{var _hIX=_h3A1.split(";");var _hBZ1=_hIX.length;for(var i=0;i<_hBZ1;++i){var _hZ31=_hIX[i];var _hLO1=_hZ31.indexOf(":");if(_hLO1!=-1){var _hKO1=_hZ31.substring(0, _hLO1).F_Trim().toLowerCase();var _h552=_hZ31.substr(_hLO1+1).F_Trim();if((_h552.indexOf("url(data:")==0)&&((i+1)<_hBZ1)){_h552+=(";" + _hIX[i + 1]);_hIX[i+1]="";}this.F_SetOptimizedDeclaration(_hKO1, _h552);}}}catch(e){this._hVM={};}}};C_CSSDefinition.prototype.F_Clone=function(){var o=new C_CSSDefinition();o._hVM=U_Object.F_Copy(this._hVM);return o;};C_CSSDefinition.prototype.F_SetOptimizedDeclaration=function(_hKO1,_h552){var _hWZ1=_h552.split( " " );switch(_hKO1){case "font":switch(_hWZ1.length){case 6:this.F_SetProperty("font-family", _hWZ1[5]);case 5:this.F_SetProperty("line-height", _hWZ1[4]);case 4:this.F_SetProperty("font-size", _hWZ1[3]);case 3:this.F_SetProperty("font-weight", _hWZ1[2]);case 2:case 1:this.F_SetProperty("font-style", _hWZ1[0]);}break;case "padding":case "margin":switch(_hWZ1.length){case 1:this.F_SetProperty(_hKO1+"-top", _hWZ1[0]);this.F_SetProperty(_hKO1+"-bottom", _hWZ1[0]);this.F_SetProperty(_hKO1+"-left", _hWZ1[0]);this.F_SetProperty(_hKO1+"-right", _hWZ1[0]);break;case 2:this.F_SetProperty(_hKO1+"-top", _hWZ1[0]);this.F_SetProperty(_hKO1+"-bottom", _hWZ1[0]);this.F_SetProperty(_hKO1+"-left", _hWZ1[1]);this.F_SetProperty(_hKO1+"-right", _hWZ1[1]);break;case 3:this.F_SetProperty(_hKO1+"-top", _hWZ1[0]);this.F_SetProperty(_hKO1+"-left", _hWZ1[1]);this.F_SetProperty(_hKO1+"-right", _hWZ1[1]);this.F_SetProperty(_hKO1+"-bottom", _hWZ1[2]);break;case 4:this.F_SetProperty(_hKO1+"-top", _hWZ1[0]);this.F_SetProperty(_hKO1+"-right", _hWZ1[1]);this.F_SetProperty(_hKO1+"-bottom", _hWZ1[2]);this.F_SetProperty(_hKO1+"-left", _hWZ1[3]);break;}break;case "border":switch(_hWZ1.length){case 3:this.F_SetProperty("border-top-color", _hWZ1[2]);this.F_SetProperty("border-bottom-color", _hWZ1[2]);this.F_SetProperty("border-left-color", _hWZ1[2]);this.F_SetProperty("border-right-color", _hWZ1[2]);case 2:this.F_SetProperty("border-top-style", _hWZ1[1]);this.F_SetProperty("border-bottom-style", _hWZ1[1]);this.F_SetProperty("border-left-style", _hWZ1[1]);this.F_SetProperty("border-right-style", _hWZ1[1]);case 1:this.F_SetProperty("border-top-width", _hWZ1[0]);this.F_SetProperty("border-bottom-width", _hWZ1[0]);this.F_SetProperty("border-left-width", _hWZ1[0]);this.F_SetProperty("border-right-width", _hWZ1[0]);}break;case "border-top":case "border-bottom":case "border-left":case "border-right":switch(_hWZ1.length){case 3:this.F_SetProperty(_hKO1+"-color", _hWZ1[2]);case 2:this.F_SetProperty(_hKO1+"-style", _hWZ1[1]);case 1:this.F_SetProperty(_hKO1+"-width", _hWZ1[0]);}break;default:this.F_SetProperty(_hKO1, _h552);}};C_CSSDefinition.prototype.F_SetProperty=function(_hKO1,_h552){this._hVM[_hKO1]=_h552;};C_CSSDefinition.prototype.F_SetProperties=function(_hJX){for(var _hKO1 in _hJX){this.F_SetProperty(_hKO1, _hJX[_hKO1]);}};C_CSSDefinition.prototype.F_GetProperty=function(_hKO1){return this._hVM[_hKO1]||"";};C_CSSDefinition.prototype.F_GetAllProperties=function(){var o={};for(var s in this._hVM){o[s]=this._hVM[s];}return o;};C_CSSDefinition.prototype.F_GetDeclarationMap=function(){return this._hVM;};C_CSSDefinition.prototype.F_GetProperties=function(_hWI){var _hWZ1=[];for(var i=0;i<_hWI.length;i++){_hWZ1.push(this._hVM[_hWI[i]]||"");}return _hWZ1;};C_CSSDefinition.prototype.F_Append=function(_hOR){for(var _hKO1 in _hOR._hVM){this._hVM[_hKO1]=_hOR._hVM[_hKO1];}};C_CSSDefinition.prototype.toString=function(){var _hMU1={};for(var _hKO1 in this._hVM){_hMU1[_hKO1]=this._hVM[_hKO1];}var _hIX=[];var _hNU1=[ "border-top", "border-bottom", "border-left", "border-right" ];for(var i=0;i<_hNU1.length;i++){var _hXZ1=_hNU1[i];if ((_hMU1[_hXZ1+"-width"] )&&( _hMU1[_hXZ1 + "-style"] )&&( _hMU1[_hXZ1 + "-color"] ) ){_hMU1[_hXZ1]=_hMU1[_hXZ1+"-width"] + " " + _hMU1[_hXZ1 + "-style"] + " " + _hMU1[_hXZ1 + "-color"];delete _hMU1[_hXZ1+"-width"];delete _hMU1[_hXZ1+"-style"];delete _hMU1[_hXZ1+"-color"];}}if(_hMU1[_hNU1[0]]&&_hMU1[_hNU1[1]]&&_hMU1[_hNU1[2]]&&_hMU1[_hNU1[3]]){if((_hMU1[_hNU1[0]]==_hMU1[_hNU1[1]])&&(_hMU1[_hNU1[1]]==_hMU1[_hNU1[2]])&&(_hMU1[_hNU1[2]]==_hMU1[_hNU1[3]])){_hMU1["border"]=_hMU1[_hNU1[0]];delete _hMU1[_hNU1[0]];delete _hMU1[_hNU1[1]];delete _hMU1[_hNU1[2]];delete _hMU1[_hNU1[3]];}}if(_hMU1["padding-top"]&&_hMU1["padding-right"]&&_hMU1["padding-bottom"]&&_hMU1["padding-left"]){_hIX.push("padding:");_hIX.push(_hMU1["padding-top"]);if ((_hMU1["padding-top"] != _hMU1["padding-bottom"] ) ||( _hMU1["padding-bottom"] != _hMU1["padding-left"] ) ||( _hMU1["padding-left"] != _hMU1["padding-right"] ) ){_hIX.push( " " );_hIX.push(_hMU1["padding-right"]);_hIX.push( " " );_hIX.push(_hMU1["padding-bottom"]);_hIX.push( " " );_hIX.push(_hMU1["padding-left"]);}_hIX.push(";");delete _hMU1["padding-top"];delete _hMU1["padding-right"];delete _hMU1["padding-bottom"];delete _hMU1["padding-left"];}if(_hMU1["margin-top"]&&_hMU1["margin-right"]&&_hMU1["margin-bottom"]&&_hMU1["margin-left"]){_hIX.push("margin:");_hIX.push(_hMU1["margin-top"]);if ((_hMU1["margin-top"] != _hMU1["margin-bottom"] ) ||( _hMU1["margin-bottom"] != _hMU1["margin-left"] ) ||( _hMU1["margin-left"] != _hMU1["margin-right"] ) ){_hIX.push( " " );_hIX.push(_hMU1["margin-right"]);_hIX.push( " " );_hIX.push(_hMU1["margin-bottom"]);_hIX.push( " " );_hIX.push(_hMU1["margin-left"]);}_hIX.push(";");delete _hMU1["margin-top"];delete _hMU1["margin-right"];delete _hMU1["margin-bottom"];delete _hMU1["margin-left"];}if(_hMU1["text-decoration"]){var s=_hMU1["text-decoration"];if(s.indexOf("none")!=-1){_hMU1["text-decoration"] = "none";}else{var a=[];if(s.indexOf("underline")!=-1){a.push("underline");}if(s.indexOf("overline")!=-1){a.push("overline");}if(s.indexOf("line-through")!=-1){a.push("line-through");}_hMU1["text-decoration"] = a.join( " " );}}for(var _hKO1 in _hMU1){var _h552=_hMU1[_hKO1];if(_h552){_hIX.push(_hKO1);_hIX.push(":");_hIX.push(_h552);_hIX.push(";");}}if(_hIX.F_Top()==";"){_hIX.pop();}return _hIX.join("");};C_CSSDefinition.prototype.F_RemoveStyle=function(_hH52){var _h4A1=this.F_GetAllProperties();var _h5A1=[];switch(_hH52){case "font":_h5A1=["font-family", "line-height", "font-size", "font-weight", "font-variant", "font-style"];break;case "padding":case "margin":_h5A1=[_hH52+"-top", _hH52+"-bottom", _hH52+"-left", _hH52+"-right"];break;case "border":_h5A1=["border-top-color", "border-bottom-color", "border-left-color", "border-right-color", "border-top-style", "border-bottom-style", "border-left-style", "border-right-style", "border-top-width", "border-bottom-width", "border-left-width", "border-right-width"];break;case "border-top":case "border-bottom":case "border-left":case "border-right":_h5A1=[_hH52+"-color", _hH52+"-style", _hH52+"-width"];break;default:_h5A1=[_hH52];}for(var i=0;i<_h5A1.length;i++){delete _h4A1[_h5A1[i]];}this._hVM={};this.F_SetProperties(_h4A1);};