How to use tableEl method in ng-mocks

Best JavaScript code snippet using ng-mocks

attc.googleChart.js

Source:attc.googleChart.js Github

copy

Full Screen

1/**2 * IMPORTANT: This library was changed in the commit 472aeef to allow prices3 * and other formatted numbers to be displayed. Do not overwrite this library4 * with a newer version without merging these changes unless the updated5 * version provides the same functionality.6 */7google.load("visualization", "1", {packages:["corechart"]});8(function( $ ){9 $.fn.attc = function(options) {10 var numPattern = /[^0-9\.]/g;11 var tableEl = this;12 var dataArray=new Array();13 var numRows = tableEl.find('tbody tr').length;14 //defaults15 var settings = $.extend( {16 'location':tableEl.attr('id'),17 'hideTable' : false,18 'hideChart' : false,19 'type':'bar',20 'googleOptions':new Object(),21 'controls':{22 showHide:true,23 create:true,24 chartType:true25 },26 'controlsLabels':{27 showChart:"Show chart",28 hideChart:"Hide chart",29 showTable:"Show table",30 hideTable:"Hide table",31 createChart:"Edit chart",32 changeChart:"Change chart"33 },34 chartOptionList:'<option value="bar">Bar</option><option value="pie">Pie</option><option value="column">Column</option><option value="area">Area</option><option value="line">Line</option>'35 }, options);36 //set editing attribute to false so it can be tested:37 tableEl.attr('data-attc-editing',false);38 //function to create a table39 var CreateChart = function(type,location,tableEl)40 {41 var dataArray=new Array();42 switch(type){43 case 'pie':44 //console.log("making a pie");45 var headerValues=$('#'+tableEl.attr('data-attc-colvalues'));46 var headerDesc=tableEl.attr('data-attc-colDescription');47 if(headerDesc.split(',').length >0){48 headerDesc=$('#'+headerDesc.split(',')[0]);49 }else{50 headerDesc=$('#'+headerDesc);51 }52 var colIndexValues=headerValues.index()+1;53 var colIndexDesc=headerDesc.index()+1;54 dataArray[0]=[headerDesc.text(), headerValues.text()];55 for(i=1;i <=numRows;i++){56 //loop values and description to get array57 var value=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexValues+')').text();58 value=parseFloat(value.replace(numPattern,''));59 var description=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexDesc+')').text();60 //console.log(colIndexDesc+ ':'+description);61 dataArray[i]=[description,value];62 }63 var chart = new google.visualization.PieChart(document.getElementById(location));64 break;65 case 'bar':66 case 'column':67 case 'area':68 case 'line':69 var headerDesc=$('#'+tableEl.attr('data-attc-colDescription'));70 var colIndexDesc=headerDesc.index()+1;71 var headerValuesArray=tableEl.attr('data-attc-colvalues').split(',');72 //var headerValuesArray=$('#'+tableEl.attr('data-attc-colvalues')).split(',');73 var headerIndexArray=new Array();74 var colIndexValues=0;75 var value="";76 var description="";77 //get index for each column78 for(x=0;x<headerValuesArray.length;x++){79 headerIndexArray.push($('#'+headerValuesArray[x]).index()+1);80 }81 //console.log(headerIndexArray);82 var theadEls = tableEl.find('thead th');83 var headArray=new Array();84 description=tableEl.find('thead tr:nth-child(1) th:nth-child('+colIndexDesc+')').text();85 headArray.push(description);86 for(x=0;x<headerValuesArray.length;x++){87 colIndexValues=headerIndexArray[x];88 value=tableEl.find('thead tr:nth-child(1) th:nth-child('+colIndexValues+')').text();89 headArray.push(value);90 }91 dataArray[0]=headArray;92 for(i=1;i <=numRows;i++){93 var rowArray=new Array();94 description=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexDesc+')').text();95 rowArray.push(description);96 for(x=0;x<headerValuesArray.length;x++){97 colIndexValues=headerIndexArray[x];98 value=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexValues+')').text();99 originalValue=value;100 value=parseFloat(value.replace(numPattern,''));101 //console.log(colIndexDesc+ ':'+description);102 rowArray.push({v: value, f: originalValue});103 }104 dataArray[i]=rowArray;105 }106 switch(type){107 case 'bar':108 var chart = new google.visualization.BarChart(document.getElementById(location));109 break;110 case 'column':111 var chart = new google.visualization.ColumnChart(document.getElementById(location));112 break;113 case 'area':114 var chart = new google.visualization.AreaChart(document.getElementById(location));115 break;116 case 'line':117 var chart = new google.visualization.LineChart(document.getElementById(location));118 break;119 default:120 var chart = new google.visualization.BarChart(document.getElementById(location));121 break;122 }123 break;124 default:125 break;126 }127 var data = google.visualization.arrayToDataTable(dataArray);128 chart.draw(data, settings.googleOptions);129 };130 if(tableEl.attr('title')!='' && settings.googleOptions.title==undefined){131 settings.googleOptions.title=tableEl.attr('title');132 }133 //look for the settings in the data-attc-googleOptions134 if(tableEl.attr('data-attc-googleOptions')!=undefined){135 settings.googleOptions=jQuery.parseJSON(tableEl.attr('data-attc-googleOptions'));136 }137 //look for the settings in the data-attc-controls138 if(tableEl.attr('data-attc-controls')!=undefined){139 settings.controls=jQuery.parseJSON(tableEl.attr('data-attc-controls'));140 }141 //look for type in data-attc-type142 if(tableEl.attr('data-attc-type')!=undefined){143 settings.type=tableEl.attr('data-attc-type');144 }145 if(tableEl.attr('data-attc-hideTable')!=undefined){146 settings.hideTable=tableEl.attr('data-attc-hideTable');147 }148 if(tableEl.attr('data-attc-hideChart')!=undefined){149 settings.hideChart=tableEl.attr('data-attc-hideChart');150 }151 //look for location in data-attc-location152 if(tableEl.attr('data-attc-location')!=undefined){153 settings.location=tableEl.attr('data-attc-location');154 }155 if(tableEl.length>0 ){156 if(tableEl.get(0).tagName=='TABLE'){157 //fork depending on the setting158 CreateChart(settings.type,settings.location,tableEl);159 //hide the table160 if(settings.hideTable=="true"){161 tableEl.hide();162 }163 if(settings.hideChart=="true"){164 $('#'+settings.location).hide();165 }166 //start making the controls167 var controls='';168 if(settings.controls.showHide){169 controls+='<li><a href="#" \170 data-attc-textShow="'+settings.controlsLabels.showChart+'" \171 data-attc-textHide="'+settings.controlsLabels.hideChart+'" \172 data-attc-controls-showHide="'+settings.location+'" \173 class="attcChartIcon">'+(settings.hideChart ? settings.controlsLabels.showChart : settings.controlsLabels.hideChart)+'</a></li>';174 controls+='<li><a href="#" \175 data-attc-textShow="'+settings.controlsLabels.showTable+'" \176 data-attc-textHide="'+settings.controlsLabels.hideTable+'" \177 data-attc-controls-showHide="'+tableEl.attr('id')+'" \178 class="attcTableIcon">'+(settings.hideTable ? settings.controlsLabels.showTable : settings.controlsLabels.hideTable)+'</a></li>';179 }180 //start making the controls181 if(settings.controls.create){182 controls+='<li><a href="#" \183 data-attc-controls-addCreateOptions="'+tableEl.attr('id')+'" \184 class="attcTableIcon">'+(settings.controlsLabels.createChart)+'</a></li>'185 }186 if(settings.controls.chartType){187 controls+='<li><fieldset><label>'+settings.controlsLabels.changeChart+'</label><select data-attc-controls-updateChart="'+tableEl.attr('id')+'" class="attcUpdateChart">'+settings.chartOptionList+'</select></fieldset></li>';188 }189 //if there are any controls to show190 if(controls !=''){191 controls='<div class="attcControls"><ul>'+controls+'</ul><div>';192 var controlsEl=$(controls);193 //set the select list to show current selected chart194 controlsEl.find("select[data-attc-controls-updateChart]").val(settings.type);195 //196 controlsEl.on("click", "a[data-attc-controls-showHide]", function(e){197 e.preventDefault();198 var el=$('#'+$(this).attr('data-attc-controls-showHide'));199 el.find('tbody').show();200 el.toggle();201 $(this).text(el.is(':visible') ? $(this).attr('data-attc-textHide') : $(this).attr('data-attc-textShow'));202 });203 controlsEl.on("change", "select[data-attc-controls-updateChart]", function(){204 //update chart type for other functions205 tableEl.attr('data-attc-type',$(this).val());206 //grab the new chart and re-run the creation207 CreateChart($(this).val(),settings.location,tableEl);208 //if editing then update the editing controls209 if(tableEl.attr('data-attc-editing')=='true'){210 controlsEl.find("a[data-attc-controls-addCreateOptions]").click();211 }212 });213 controlsEl.find("a[data-attc-controls-addCreateOptions]").on("click", function(e){214 e.preventDefault();215 if(!tableEl.is(':visible')){216 //show the thead only217 tableEl.show();218 tableEl.find('tbody').hide();219 }220 //set table as editing221 tableEl.attr('data-attc-editing',true);222 //remove existing edit boxes223 tableEl.find('thead th input.attcEditCheckRadioBoxes').remove();224 //add check boxes to the th elements225 tableEl.find('thead th').each(function(index) {226 //find col type by adding all values together and checking if it's not NaN227 var items=0;228 var col=index+1;229 var inputType='checkbox';230 var inputColType='value';231 var descriptionCol=tableEl.attr('data-attc-colDescription');232 var valuesCols=tableEl.attr('data-attc-colvalues').split(',');233 valuesCols.push(descriptionCol);234 tableEl.find('tbody>tr>td:nth-child('+col+')').each( function(){235 items+=parseFloat($(this).text().replace(numPattern,''));236 });237 if(isNaN(items)){238 inputType='radio';239 inputColType='desc';240 }241 //force back to radio if pie chart242 if(tableEl.attr('data-attc-type')=='pie'){243 inputType='radio';244 }245 var appendEl='<input data-attc-colType="'+inputColType+'" type="'+inputType+'" name=attc'+inputColType+'" value="'+index+'"';246 if($.inArray($(this).attr('id'), valuesCols)>-1){247 appendEl+=' checked="checked"';248 }249 appendEl+=' class="attcEditCheckRadioBoxes"/>';250 appendEl=$(appendEl).on("click", function(){251 //give this col an id if it doesn't have one252 var myId='attcCol'+$(this).val();253 if($(this).parents('th').attr('id')!= undefined){254 myId=$(this).parents('th').attr('id');255 }else{256 $(this).parents('th').attr('id',myId);257 }258 //change the attribute to this column259 if($(this).attr('data-attc-colType')=='desc'){260 tableEl.attr('data-attc-colDescription',myId);261 }else{262 //todo remove value if unchecked263 if(tableEl.attr('data-attc-type') =='pie'){264 tableEl.attr('data-attc-colValues',myId);265 }else{266 //select all the checked inputs267 var checkedIds=tableEl.find('input[data-attc-colType=value]:checked').parents('th').map(function() { return this.id; }).get().toString();268 tableEl.attr('data-attc-colValues',checkedIds);269 }270 }271 //re-create chart272 CreateChart(tableEl.attr('data-attc-type'),settings.location,tableEl);273 });274 $(this).prepend(appendEl);275 });276 });277 //add controls above the table el278 tableEl.before(controlsEl);279 }280 }else{281 alert(tableEl.attr('id')+' is not a table it\'s a: ' + tableEl.get(0).tagName);282 }283 }else{284 //285 }286 //maintain chain287 return this288 };289})( jQuery );290$(document).ready(function(){291 $('[data-attc-createChart]').each(function() {292 $(this).attc();293 });...

Full Screen

Full Screen

attc.googleCharts.js

Source:attc.googleCharts.js Github

copy

Full Screen

1google.load("visualization", "1", {packages:["corechart"]});2(function( $ ){3 $.fn.attc = function(options) {4 var numPattern = /[^0-9\.]/g;5 var tableEl = this;6 var dataArray=new Array();7 var numRows = tableEl.find('tbody tr').length;8 //defaults9 var settings = $.extend( {10 'location':tableEl.attr('id'),11 'hideTable' : false,12 'hideChart' : false,13 'type':'bar',14 'googleOptions':new Object(),15 'controls':{16 showHide:true,17 create:true,18 chartType:true19 },20 'controlsLabels':{21 showChart:"Show chart",22 hideChart:"Hide chart",23 showTable:"Show table",24 hideTable:"Hide table",25 createChart:"Edit chart",26 changeChart:"Change chart"27 },28 chartOptionList:'<option value="bar">Bar</option><option value="pie">Pie</option><option value="column">Column</option><option value="area">Area</option><option value="line">Line</option>'29 }, options);30 //set editing attribute to false so it can be tested:31 tableEl.attr('data-attc-editing',false);32 //function to create a table33 var CreateChart = function(type,location,tableEl)34 {35 var dataArray=new Array();36 switch(type){37 case 'pie':38 //console.log("making a pie");39 var headerValues=$('#'+tableEl.attr('data-attc-colvalues'));40 var headerDesc=tableEl.attr('data-attc-colDescription');41 if(headerDesc.split(',').length >0){42 headerDesc=$('#'+headerDesc.split(',')[0]);43 }else{44 headerDesc=$('#'+headerDesc);45 }46 var colIndexValues=headerValues.index()+1;47 var colIndexDesc=headerDesc.index()+1;48 dataArray[0]=[headerDesc.text(), headerValues.text()];49 for(i=1;i <=numRows;i++){50 //loop values and description to get array51 var value=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexValues+')').text();52 value=parseFloat(value.replace(numPattern,''));53 var description=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexDesc+')').text();54 //console.log(colIndexDesc+ ':'+description);55 dataArray[i]=[description,value];56 }57 var chart = new google.visualization.PieChart(document.getElementById(location));58 break;59 60 case 'bar':61 case 'column':62 case 'area':63 case 'line':64 var headerDesc=$('#'+tableEl.attr('data-attc-colDescription'));65 var colIndexDesc=headerDesc.index()+1;66 var headerValuesArray=tableEl.attr('data-attc-colvalues').split(',');67 //var headerValuesArray=$('#'+tableEl.attr('data-attc-colvalues')).split(',');68 var headerIndexArray=new Array();69 var colIndexValues=0;70 var value="";71 var description="";72 //get index for each column73 for(x=0;x<headerValuesArray.length;x++){74 headerIndexArray.push($('#'+headerValuesArray[x]).index()+1);75 }76 //console.log(headerIndexArray);77 var theadEls = tableEl.find('thead th');78 var headArray=new Array();79 description=tableEl.find('thead tr:nth-child(1) th:nth-child('+colIndexDesc+')').text(); 80 headArray.push(description);81 for(x=0;x<headerValuesArray.length;x++){82 colIndexValues=headerIndexArray[x];83 value=tableEl.find('thead tr:nth-child(1) th:nth-child('+colIndexValues+')').text();84 headArray.push(value);85 }86 dataArray[0]=headArray;87 for(i=1;i <=numRows;i++){88 var rowArray=new Array();89 description=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexDesc+')').text();90 91 rowArray.push(description);92 for(x=0;x<headerValuesArray.length;x++){93 colIndexValues=headerIndexArray[x];94 value=tableEl.find('tbody tr:nth-child('+i+') td:nth-child('+colIndexValues+')').text();95 value=parseFloat(value.replace(numPattern,''));96 //console.log(colIndexDesc+ ':'+description);97 rowArray.push(value);98 }99 dataArray[i]=rowArray;100 101 }102 103 switch(type){104 case 'bar':105 var chart = new google.visualization.BarChart(document.getElementById(location));106 break;107 case 'column':108 var chart = new google.visualization.ColumnChart(document.getElementById(location));109 break;110 case 'area':111 var chart = new google.visualization.AreaChart(document.getElementById(location));112 break;113 case 'line':114 var chart = new google.visualization.LineChart(document.getElementById(location));115 break;116 117 default:118 var chart = new google.visualization.BarChart(document.getElementById(location));119 break;120 }121 break;122 123 default:124 break;125 }126 127 var data = google.visualization.arrayToDataTable(dataArray);128 chart.draw(data, settings.googleOptions);129 };130 131 if(tableEl.attr('title')!='' && settings.googleOptions.title==undefined){132 settings.googleOptions.title=tableEl.attr('title');133 }134 135 //look for the settings in the data-attc-googleOptions136 if(tableEl.attr('data-attc-googleOptions')!=undefined){137 settings.googleOptions=jQuery.parseJSON(tableEl.attr('data-attc-googleOptions'));138 }139 //look for the settings in the data-attc-controls140 if(tableEl.attr('data-attc-controls')!=undefined){141 settings.controls=jQuery.parseJSON(tableEl.attr('data-attc-controls'));142 }143 //look for type in data-attc-type144 if(tableEl.attr('data-attc-type')!=undefined){145 settings.type=tableEl.attr('data-attc-type');146 }147 148 if(tableEl.attr('data-attc-hideTable')!=undefined){149 settings.hideTable=tableEl.attr('data-attc-hideTable');150 }151 if(tableEl.attr('data-attc-hideChart')!=undefined){152 settings.hideChart=tableEl.attr('data-attc-hideChart');153 }154 //look for location in data-attc-location155 if(tableEl.attr('data-attc-location')!=undefined){156 settings.location=tableEl.attr('data-attc-location');157 }158159 if(tableEl.length>0 ){160 if(tableEl.get(0).tagName=='TABLE'){161 //fork depending on the setting162 CreateChart(settings.type,settings.location,tableEl);163 164 //hide the table165 if(settings.hideTable=="true"){166 tableEl.hide();167 }168 if(settings.hideChart=="true"){169 $('#'+settings.location).hide();170 }171 //start making the controls172 var controls='';173 if(settings.controls.showHide){174 controls+='<li><a href="#" \175 data-attc-textShow="'+settings.controlsLabels.showChart+'" \176 data-attc-textHide="'+settings.controlsLabels.hideChart+'" \177 data-attc-controls-showHide="'+settings.location+'" \178 class="attcChartIcon">'+(settings.hideChart ? settings.controlsLabels.showChart : settings.controlsLabels.hideChart)+'</a></li>';179 180 controls+='<li><a href="#" \181 data-attc-textShow="'+settings.controlsLabels.showTable+'" \182 data-attc-textHide="'+settings.controlsLabels.hideTable+'" \183 data-attc-controls-showHide="'+tableEl.attr('id')+'" \184 class="attcTableIcon">'+(settings.hideTable ? settings.controlsLabels.showTable : settings.controlsLabels.hideTable)+'</a></li>';185 }186 //start making the controls187 if(settings.controls.create){188 controls+='<li><a href="#" \189 data-attc-controls-addCreateOptions="'+tableEl.attr('id')+'" \190 class="attcTableIcon">'+(settings.controlsLabels.createChart)+'</a></li>'191 }192 if(settings.controls.chartType){193 controls+='<li><fieldset><label>'+settings.controlsLabels.changeChart+'</label><select data-attc-controls-updateChart="'+tableEl.attr('id')+'" class="attcUpdateChart">'+settings.chartOptionList+'</select></fieldset></li>';194 }195 //if there are any controls to show196 if(controls !=''){197 controls='<div class="attcControls"><ul>'+controls+'</ul><div>';198 var controlsEl=$(controls);199 //set the select list to show current selected chart200 controlsEl.find("select[data-attc-controls-updateChart]").val(settings.type);201 //202 controlsEl.on("click", "a[data-attc-controls-showHide]", function(e){203 e.preventDefault();204 var el=$('#'+$(this).attr('data-attc-controls-showHide'));205 el.find('tbody').show();206 el.toggle();207 $(this).text(el.is(':visible') ? $(this).attr('data-attc-textHide') : $(this).attr('data-attc-textShow'));208 });209 controlsEl.on("change", "select[data-attc-controls-updateChart]", function(){210 //update chart type for other functions211 tableEl.attr('data-attc-type',$(this).val());212 //grab the new chart and re-run the creation213 CreateChart($(this).val(),settings.location,tableEl);214 //if editing then update the editing controls215 if(tableEl.attr('data-attc-editing')=='true'){216 controlsEl.find("a[data-attc-controls-addCreateOptions]").click();217 }218 });219 controlsEl.find("a[data-attc-controls-addCreateOptions]").on("click", function(e){220 e.preventDefault();221 if(!tableEl.is(':visible')){222 //show the thead only223 tableEl.show();224 tableEl.find('tbody').hide();225 }226 //set table as editing227 tableEl.attr('data-attc-editing',true);228 //remove existing edit boxes229 tableEl.find('thead th input.attcEditCheckRadioBoxes').remove();230 //add check boxes to the th elements231 tableEl.find('thead th').each(function(index) {232 //find col type by adding all values together and checking if it's not NaN233 var items=0;234 var col=index+1;235 var inputType='checkbox';236 var inputColType='value';237 var descriptionCol=tableEl.attr('data-attc-colDescription');238 var valuesCols=tableEl.attr('data-attc-colvalues').split(',');239 valuesCols.push(descriptionCol);240 tableEl.find('tbody>tr>td:nth-child('+col+')').each( function(){241 items+=parseFloat($(this).text().replace(numPattern,'')); 242 });243 244 if(isNaN(items)){245 inputType='radio';246 inputColType='desc';247 }248 //force back to radio if pie chart249 if(tableEl.attr('data-attc-type')=='pie'){250 inputType='radio';251 }252 var appendEl='<input data-attc-colType="'+inputColType+'" type="'+inputType+'" name=attc'+inputColType+'" value="'+index+'"';253 if($.inArray($(this).attr('id'), valuesCols)>-1){254 appendEl+=' checked="checked"';255 }256 appendEl+=' class="attcEditCheckRadioBoxes"/>';257 appendEl=$(appendEl).on("click", function(){258 //give this col an id if it doesn't have one259 var myId='attcCol'+$(this).val();260 if($(this).parents('th').attr('id')!= undefined){261 myId=$(this).parents('th').attr('id');262 }else{263 $(this).parents('th').attr('id',myId);264 }265 //change the attribute to this column266 if($(this).attr('data-attc-colType')=='desc'){267 tableEl.attr('data-attc-colDescription',myId);268 }else{269 //todo remove value if unchecked270 if(tableEl.attr('data-attc-type') =='pie'){271 tableEl.attr('data-attc-colValues',myId);272 }else{273 //select all the checked inputs274 var checkedIds=tableEl.find('input[data-attc-colType=value]:checked').parents('th').map(function() { return this.id; }).get().toString();275 tableEl.attr('data-attc-colValues',checkedIds);276 }277 }278 //re-create chart279 CreateChart(tableEl.attr('data-attc-type'),settings.location,tableEl);280 });281 $(this).prepend(appendEl);282 283 284 });285 });286 //add controls above the table el287 tableEl.before(controlsEl);288 }289 }else{290 alert(tableEl.attr('id')+' is not a table it\'s a: ' + tableEl.get(0).tagName);291 }292 }else{293 //294 }295 //maintain chain296 return this297 };298})( jQuery );299300$(document).ready(function(){301 $('[data-attc-createChart]').attc(); ...

Full Screen

Full Screen

webtoolkit.scrollabletable.js

Source:webtoolkit.scrollabletable.js Github

copy

Full Screen

1/**2*3* Scrollable HTML table4* http://www.webtoolkit.info/5*6**/7function ScrollableTable (tableEl, tableHeight, tableWidth) {8 this.initIEengine = function () {9 this.containerEl.style.overflowY = 'auto';10 if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {11 this.tableEl.style.width = this.newWidth - this.scrollWidth +'px';12 } else {13 this.containerEl.style.overflowY = 'hidden';14 this.tableEl.style.width = this.newWidth +'px';15 }16 if (this.thead) {17 var trs = this.thead.getElementsByTagName('tr');18 for (x=0; x<trs.length; x++) {19 trs[x].style.position ='relative';20 trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");21 }22 }23 if (this.tfoot) {24 var trs = this.tfoot.getElementsByTagName('tr');25 for (x=0; x<trs.length; x++) {26 trs[x].style.position ='relative';27 trs[x].style.setExpression("bottom", "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");28 }29 }30 eval("window.attachEvent('onresize', function () { document.getElementById('" + this.tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + this.tableEl.id + "').style.visibility = 'visible'; } )");31 };32 this.initFFengine = function () {33 this.containerEl.style.overflow = 'hidden';34 this.tableEl.style.width = this.newWidth + 'px';35 var headHeight = (this.thead) ? this.thead.clientHeight : 0;36 var footHeight = (this.tfoot) ? this.tfoot.clientHeight : 0;37 var bodyHeight = this.tbody.clientHeight;38 var trs = this.tbody.getElementsByTagName('tr');39 if (bodyHeight >= (this.newHeight - (headHeight + footHeight))) {40 this.tbody.style.overflow = '-moz-scrollbars-vertical';41 for (x=0; x<trs.length; x++) {42 var tds = trs[x].getElementsByTagName('td');43 tds[tds.length-1].style.paddingRight += this.scrollWidth + 'px';44 }45 } else {46 this.tbody.style.overflow = '-moz-scrollbars-none';47 }48 var cellSpacing = (this.tableEl.offsetHeight - (this.tbody.clientHeight + headHeight + footHeight)) / 4;49 this.tbody.style.height = (this.newHeight - (headHeight + cellSpacing * 2) - (footHeight + cellSpacing * 2)) + 'px';50 };51 this.tableEl = tableEl;52 this.scrollWidth = 16;53 this.originalHeight = this.tableEl.clientHeight;54 this.originalWidth = this.tableEl.clientWidth;55 this.newHeight = parseInt(tableHeight);56 this.newWidth = tableWidth ? parseInt(tableWidth) : this.originalWidth;57 this.tableEl.style.height = 'auto';58 this.tableEl.removeAttribute('height');59 this.containerEl = this.tableEl.parentNode.insertBefore(document.createElement('div'), this.tableEl);60 this.containerEl.appendChild(this.tableEl);61 this.containerEl.style.height = this.newHeight + 'px';62 this.containerEl.style.width = this.newWidth + 'px';63 var thead = this.tableEl.getElementsByTagName('thead');64 this.thead = (thead[0]) ? thead[0] : null;65 var tfoot = this.tableEl.getElementsByTagName('tfoot');66 this.tfoot = (tfoot[0]) ? tfoot[0] : null;67 var tbody = this.tableEl.getElementsByTagName('tbody');68 this.tbody = (tbody[0]) ? tbody[0] : null;69 if (!this.tbody) return;70 if (document.all && document.getElementById && !window.opera) this.initIEengine();71 if (!document.all && document.getElementById && !window.opera) this.initFFengine();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { tableEl } from 'ng-mocks';2describe('AppComponent', () => {3 beforeEach(async(() => {4 TestBed.configureTestingModule({5 }).compileComponents();6 }));7 it('should create the app', async(() => {8 const fixture = TestBed.createComponent(AppComponent);9 const app = fixture.debugElement.componentInstance;10 expect(app).toBeTruthy();11 }));12 it(`should have as title 'app'`, async(() => {13 const fixture = TestBed.createComponent(AppComponent);14 const app = fixture.debugElement.componentInstance;15 expect(app.title).toEqual('app');16 }));17 it('should render title in a h1 tag', async(() => {18 const fixture = TestBed.createComponent(AppComponent);19 fixture.detectChanges();20 const compiled = fixture.debugElement.nativeElement;21 expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');22 }));23 it('should have 3 rows', async(() => {24 const fixture = TestBed.createComponent(AppComponent);25 fixture.detectChanges();26 const compiled = fixture.debugElement.nativeElement;27 expect(tableEl(compiled, 'table').rows.length).toBe(3);28 }));29});30import { Component } from '@angular/core';31@Component({32})33export class AppComponent {34 title = 'app';35}36import { Component, OnInit } from '@angular/core';37@Component({38})39export class AppHeaderComponent implements OnInit {40 constructor() { }41 ngOnInit() {42 }43}44import { async, ComponentFixture, TestBed } from '@angular/core/testing';45import { AppHeaderComponent } from './app-header.component';46describe('AppHeaderComponent', () => {47 let component: AppHeaderComponent;48 let fixture: ComponentFixture<AppHeaderComponent>;49 beforeEach(async(() => {50 TestBed.configureTestingModule({51 })52 .compileComponents();53 }));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { tableEl } from 'ng-mocks';2describe('tableEl', () => {3 it('gets the table element', () => {4 const fixture = MockRender(`5 `);6 const table = tableEl(fixture.debugElement);7 expect(table.rows.length).toBe(2);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { tableEl } from 'ng-mocks';2const table = tableEl(fixture, 'table');3expect(table).toBeDefined();4expect(table).toHaveTextContent('test');5expect(table).toHaveTextContent('test', { normalizeWhitespace: true });6expect(table).toHaveTextContent('test', 'test');7expect(table).toHaveTextContent('test', 'test', { normalizeWhitespace: true });8expect(table).toHaveTextContent(['test', 'test']);9expect(table).toHaveTextContent(['test', 'test'], { normalizeWhitespace: true });10expect(table).toHaveTextContent(['test', 'test'], 'test');11expect(table).toHaveTextContent(['test', 'test'], 'test', { normalizeWhitespace: true });12expect(table).toHaveTextContent(['test', 'test'], ['test', 'test']);13expect(table).toHaveTextContent(['test', 'test'], ['test', 'test'], { normalizeWhitespace: true });14expect(table).toHaveTextContent(['test', 'test'], ['test', 'test'], 'test');15expect(table).toHaveTextContent(['test', 'test'], ['test', 'test'], 'test', { normalizeWhitespace: true });16expect(table).toHaveTextContent(/test/);17expect(table).toHaveTextContent(/test/, { normalizeWhitespace: true });18expect(table).toHaveTextContent(/test/, 'test');19expect(table).toHaveTextContent(/test/, '

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('test', () => {3 const fixture = TestBed.createComponent(TestComponent);4 const table = fixture.debugElement.query(By.directive(MatTable)).componentInstance;5 const rows = tableEl(table).rows();6 expect(rows.length).toBe(2);7 });8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const tableEl = fixture.nativeElement.querySelector('table');2const tableBody = tableEl.querySelector('tbody');3const tableRows = tableBody.querySelectorAll('tr');4const firstRow = tableRows[0];5const cells = firstRow.querySelectorAll('td');6const firstCell = cells[0];7const text = firstCell.textContent;8const tableEl = fixture.debugElement.query(By.css('table'));9const tableBody = tableEl.query(By.css('tbody'));10const tableRows = tableBody.queryAll(By.css('tr'));11const firstRow = tableRows[0];12const cells = firstRow.queryAll(By.css('td'));13const firstCell = cells[0];14const text = firstCell.nativeElement.textContent;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { tableEl } from 'ng-mocks';2import { MyComponent } from './my.component';3describe('MyComponent', () => {4 it('should render table', () => {5 const fixture = MockRender(MyComponent);6 expect(tableEl(fixture.debugElement)).toBeDefined();7 });8});9import { tableEl } from 'ng-mocks';10import { MyComponent } from './my.component';11import { MyModule } from './my.module';12describe('MyComponent', () => {13 beforeEach(() => MockBuilder(MyComponent, MyModule));14 it('should render table', () => {15 const fixture = MockRender(MyComponent);16 expect(tableEl(fixture.debugElement)).toBeDefined();17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { tableEl } from 'ng-mocks';2const table = tableEl(fixture, 'tableId');3const rows = table.rows;4const cells = rows[0].cells;5const cellValue = cells[0].value;6expect(cellValue).toEqual('test');7const cellEl = cells[0].element;8expect(cellEl).toBeTruthy();9const cellEl = cells[0].element;10expect(cellEl).toBeTruthy();11const cellEl = cells[0].element;12expect(cellEl).toBeTruthy();13const cellEl = cells[0].element;14expect(cellEl).toBeTruthy();15const cellEl = cells[0].element;16expect(cellEl).toBeTruthy();17const cellEl = cells[0].element;18expect(cellEl).toBeTruthy();19const cellEl = cells[0].element;20expect(cellEl).toBeTruthy();21const cellEl = cells[0].element;22expect(cellEl).toBeTruthy();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful