Unloaded Heading Tag Causing Flicker - angularjs

I have the following code:
<div ng-cloak ng-init="viewAlbum()" class="ng-cloak">
<h3 ng-cloak class="ng-cloak" ng-bind="album.Title"></h3>
<table ng-cloak class="ng-cloak">
<tr>
<td class="label-col"><span class="album-label">Composer</span></td>
<td class="value-col">{{album.Composer}}</td>
</tr>
<tr>
<td class="label-col"><span class="album-label">Release Year</span></td>
<td class="value-col">{{album.ReleaseYear}}</td>
</tr>
<tr>
<td class="label-col"><span class="album-label">Rating</span></td>
<td class="value-col">{{album.Rating}}</td>
</tr>
<tr>
<td class="label-col"><span class="album-label">Reviews</span></td>
<td class="value-col">
<ol>
<li ng-repeat="review in album.Reviews">{{review.Text}}</li>
</ol>
</td>
</tr>
</table>
The problem is that I am seeing a quick flicker when the page load. I'm am not seeing raw unprocessed angular code. Instead, the entire table flickers including the static text such as the labels.
I did some experimenting - when I remove the H3 tag, I no longer see the flicker. So, I believe what is happening is the H3 tag is initially rendered with no value and therefore takes up no vertical space. When the value of the album title is rendered, the table is pushed down, and it is this "pushing down" that is causing the flicker. My theory could be wrong however.
The ng-clock attributes don't mitigate this. I tried a verbose option of surrounding the H3 tag in a container DIV and setting the height and min-height of that DIV in the css but that also isn't preventing the flicker.
As I said, if I remove the H3 tag, there is no flicker. Any suggestions please?

As mentioned in the below link you can Just wrap your h2/h3 tag in a div with display: inline-block; like this:
<div class="header2"><h3></h3></div>
and then add this to your css:
.header2 { min-width: 100px; width: auto; min-height:45px; background-color:#333; color:#FFF; display:inline-block; padding:10px; }
Here's a jsfiddle of two h2 tags with the above properties: https://jsfiddle.net/AndrewL32/e0d8my79/21/
Check :How do I make an inline element take up space when empty?
I recommend you also to use ng-bind for all your doms and remove the ng-cloak too

Related

Bootstrap + AngularJS - Multiple page print job with common header/footer

I am using bootstrap with AngularJS and trying to ng-repeat out a table within the template I purchased and when over a certain amount is put into the orderInformation.items array I run into issues with how the print looks.
I want to be able to hit print and have a defined page heading and a defined page footer that will not change and should nest in the top and bottom of the print preview across all pages. The only content that will change is the items that AngularJS is doing an ng-repeat on.
How can this be done? I've been searching for days and days and nothing out there seems to work.
<div class="row">
<div class="col-md-12 card-box">
<table id="invoice-contents" style="width: 100%">
<thead>
<!-- This is where logo, company details, barcode go -->
</thead>
<tbody>
<table id="item-table" class="table m-t-30" style="border-bottom: 1px solid rgba(0,0,0,.1)">
<thead>
<!-- Invoice Item headers -->
</thead>
<tbody>
<tr ng-repeat="item in orderInformation.items">
<td style="text-align: center">{{$index + 1}}</td>
<td style="text-align: center">{{item.qty.ordered}}</td>
<td style="text-align: center">{{item.qty.shipped}}</td>
<td style="text-align: center">{{item.qty.backordered}}</td>
<td style="text-align: center">{{item.binLocation}}</td>
<td style="text-align: center">{{item.partNumber}} - {{item.description}}</td>
<td style="text-align: center">{{item.price.current * item.qty.shipped | number: 2}}</td>
<td style="text-align: right">{{item.price.extended * item.qty.shipped | number: 2}}</td>
</tr>
</tbody>
</table>
</tbody>
<tfoot>
<!-- Special order notes, totals, taxes, terms -->
</tfoot>
</table>
</div>
</div> <!-- end container -->
This doesn't work when I use the recommended CSS that I have found around:
thead { display: table-header-group; }
tbody { display: table-row-group; }
tfoot { display: table-footer-group; }
The documentation says a table can't have two thead so I know the problem lies there, but I can't find any other way to get a block to print top and bottom on all pages other than table-header-group.
A way round this through much trial and error was to product an onscreen display of a single invoice page with how ever many rows of data and then use display:none to hide a view that would only show during print with CSS #media print. I had to calculate how many rows would show on each page and use .splice() and nested ng-repeats to get it displaying properly.

How to perform dropdown in BMC Project using Webdriver

I am not able to automate dropdown function in my BMC project. Tried lots of options. This will help me a lot. Please help..
<div id="WIN_0_913111809" class="df arfid913111809 ardbnCustomer Char" arid="913111809" artype="Char" ardbn="Customer" arlbox="0,4,114,17" style="z-index:993;top:2px; left:12px; width:309px; height:21px;" arwindowid="0">
<label id="label913111809" class="label f9" for="x-arid_WIN_0_913111809" style="top: 4px; left: 0px; width: 114px; height: 17px;">Customer*</label>
<textarea id="arid_WIN_0_913111809" class="text sr " cols="20" maxlen="255" style="top:0px; left:119px; width:164px; height:21px;" armenu="COM:CPY:Company=Oper/Cust-Q_ForInteractionCust" mstyle="2" arautoc="2" arautocak="0" arautoctt="400" rows="1" title="" wrap="off"></textarea>
<a class="btn btn3d menu" href="javascript:" style="top:0px; left:288px; width:21px; height:21px;">
<img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="Menu for Customer*" title="">
</a>
</div>​
<div class="MenuTableContainer" style="top: 20px;">
<table class="MenuTable" style="width: 386px;" cellspacing="0" cellpadding="0">
<tbody class="MenuTableBody">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<td class="MenuEntryNameHover" nowrap="">AARADHANA</td>
<td class="MenuEntryNoSubHover" arvalue="AARADHANA"></td>
</tr>
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
<tr class="MenuTableRow">
</tbody>
</table>
My screen looks like
This is not a select tag and is not designed to be one. It's an additional drop down menu element structured with tr and td tags. So using the Select class will not work.
Sample high level structure of a select tag:
<select>
<option>first option</option>
<option>second option</option>
</select
To solve your problem, You could simply use this:
driver.findElement(By.xpath("//div[#ardbn='Customer']//textarea")).clear();
driver.findElement(By.xpath("//div[#ardbn='Customer']//textarea")).sendKeys("AARADHANA");
Keep in mind that the text you are entering should be present in the menu. Entering a value that is not present in the list would result in the menu popping up and no value stored in the field, thereby throwing errors when you click on save since this is a mandatory field.
However if you do want to open the menu and choose something from there, you would have to wait for the element to appear and use one of these:
If the click needs to be performed on the tr
driver.findElement(By.xpath("//table[#class='MenuTable']//tr[td[.='AARADHANA']]")).click();
If the click needs to be performed on the td
driver.findElement(By.xpath("//table[#class='MenuTable']//tr//td[.='AARADHANA']")).click();
Be careful with this though, because
1. There may be many elements with the class 'MenuTable' that are hidden and if they are higher up in the hierarchy the script will fail.
2. If the first issue is not present and the customer you're trying to select is not visible you will have to scroll until the element is found before performing a click.
Highly recommend using the sendKeys option. Please ensure that you include code snippets to indicate what you've tried. This seems to be an issue with understanding the structure of the element in question.

ngtable how to remove title centered

I'm trying to work on ngTable, and i find it ugly to put Title of column in midle by standard... how can we put the title to the left like the text of the row?
Here is the html code:
<table ng-table class="table">
<tr ng-repeat="survey in vm.surveys">
<td data-title="'#L("Name")'">{{survey.name}}</td>
<td data-title="'#L("CreatedDate")'">{{survey.creationTime}}</td>
<td data-title="'#L("Creator")'">{{survey.creatorUser}}</td>
</tr>
</table>
Just add the following CSS rule:
.ng-table th { text-align: left; }

How to display icons in a table depending on model in AngularJS?

I am new to AngularJS (and Javascript as well) and I try to display different icons in a table depending on a value in a field from my model.
Let's say this is my model:
$scope.MyList = [{ name: "Production", status: "Running"},
{ name: "Test", status: "Stopped"}];
This is a table for displaying the model in one of my views:
<table class="table table-striped">
<thead>
<tr>
<td>Name</td>
<td>Status</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in MyList">
<td>{{instance.name}}</td>
<td>{{instance.status}}</td>
</tr>
</tbody>
</table>
I would like to display the status using both one icon and the text. What is the recommended way of doing it? I would like to use something that feels natural with AngularJS.
Thank you.
The answer from dolgishev pointed me into the right direction.
I initialice my table elements like this:
<tr ng-repeat="item in itemList">
<td>{{item.name}}</td>
<td class="{{item.status}}">{{item.status}}</td>
</tr>
and then I use CSS for displaying the icon using a font from FontAwesome. This is for example the CSS for the state 'Running':
.Running:before {
font-family: 'FontAwesome';
font-size:1.3em;
color:green;
content: '\f00c'; /* the ok icon */
padding-right: 4px; /* plus 4px spacing */
}
This will display the ok icon in green, then 4 pixel padding and then the text for the state "Running". It is looking great!
For solve this you can use Angular's directive ng-class. It allows you to set class of element depend on expression.
Also you can do this without directive, in this way:
<div class="{{MyList.name}}">

grid focus issue in ExtJS4

We are using ExtJS4 in our application. We have a problem with grid focus.We are using grid.getView().focusEl.focus() in ExtJS3. Now it seems that this is not working.What is the replacement for this one in ExtJS4.
I have helped you checked on the differences in ExtJS3 and ExtJS4, the major changes is the focusEl has been removed from the gridView element.
In ExtJS3, focusEl is the anchor link in the view
<div class="x-grid3-scroller" id="ext-gen10" style="width: 298px; height: 174px; ">
<div class="x-grid3-body" style="width:100px;" id="ext-gen12">
<div class="x-grid3-row x-grid3-row-first x-grid3-row-last" style="width:100px;">
<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="width:100px;">
<tbody>
<tr><td class="x-grid3-col x-grid3-cell x-grid3-td-0 x-grid3-cell-first " style="width: 100px;" tabindex="0"><div class="x-grid3-cell-inner x-grid3-col-0" unselectable="on">0</div></td></tr>
</tbody>
</table>
</div>
</div>
</div>
In ExtJS4, this anchor link doesn't exist
Solution
This is a small fiddle test I have created for you. Basically what you need to change is as follow:
grid.getView().el.focus();
Instead of getting the focusEl (an anchor link), we use the whole element.
Hope this solve your problem.

Resources