I have 3 tabs which are created using li...when I click cancel in addform tab I must redirected to home page..But the add form tab is highlighted even it is redirected to homepage.I want to redirect to home page and home tab must be redirected.I am unable how to do it on click event..
My code is mentioned below :
//when cancel button is clicked
$scope.cancelbtn=function(){
$window.location.href="#Home"
ngDialog.closeAll();
};
//html
<div id="header">
<div id="header_name" style="padding-top:25px"><center><h1 class="hh"><a>Dynamic Creation of Forms</a></h1></center></div>
<div id="nav-masthead" role="navigation">
<ul style="padding-top: 38px;padding-left:113px">
<li >
<span class="glyphicon glyphicon-home">Home</span>
</li>
<li>
<span class=" glyphicon glyphicon-plus-sign ">Add Form</span>
</li>
<li>
View Form
</li>
</ul>
</div>
</div>
<div style="color:#0d7dc1;padding: 51px;padding-left: 120px;"><ng-view></ng-view></div>
//css
#header {
background-image: url(//www.drupal.org/sites/all/themes/bluecheese/images/sprites-horizontal.png);
background-color: #56b3e6;
height:141px;
background-position: 0 -1088px;
}
.hh{
margin-top:0;
}
#nav-header {
overflow:hidden;
font-size:0.923076em;
min-height:1.5em;
}
#header_name a{
background-position: 0 -467px;
background-repeat: no-repeat;
color:white;
text-decoration:none;
height: 63px;
overflow: hidden;
text-indent: -999em;
width: 181px;
}
#nav-masthead{
width:100%;
float:right;
margin-right: 0;
display: inline;
position: relative;
z-index: 1;
min-height: 0.69231em;
}
ul{
list-style: none;
font: inherit;
font-size: 100%;
}
#nav-masthead ul li{
list-style: none;
float: left;
font-size: 0.923076em;
margin-right: 0.615384em;
}
#nav-masthead ul li a {
background-color: #0d7dc1;
border-radius: 10px 10px 0 0;
color: white;
float: left;
padding: 0.416666em .75em 0.416666em 0.615384em;
text-decoration: none;
}
#nav-masthead ul li:hover a {
background-color: white;
color:black;
}
#nav-masthead li a.col {
color: black;
background-color: white;
}
//script
$(document).ready(function() {
$('#nav-masthead li a').click(function() {
$('#nav-masthead li a').removeClass("col");
$(this).addClass("col");
});
});
Can anyone solve this.When I redirected to home page I need to get home highlighted instead of add form.
reference: How to set bootstrap navbar active class with Angular JS?
essentially if you have a MainCtrl that encapsulates everything you'll be able to keep track of which active state is currently being active.
angular.module('app').controller('MainCtrl', ['$scope', '$location', function($scope, $location) {
$scope.isActive = function('viewLocation') { //pass in the current location
return viewLocation === $location.path(); //class becomes active if the pathing is corret
}
}]);
and then have your html include the ng-class calling that function
<li ng-class="{ active: isActive('/home')}">
<span class="glyphicon glyphicon-home">Home</span>
</li>
<li ng-class="{ active: isActive('/add')}">
<span class=" glyphicon glyphicon-plus-sign ">Add Form</span>
</li>
<li ng-class="{ active: isActive('/view')}">
View Form
</li>
unless I'm miss understanding your question, hope it helps.
I have got the answer ..Just to redirect to home page when click eventi have just used the below code.
$scope.cancelbtn=function(){
$('#home').trigger('click');
ngDialog.closeAll();
};
By using above code i have solved it.i am posting my answer because it may helpful to others.
Thank You.
Related
I am using Kendo Grid to display Grid view of data. I have a column with button that, when clicked, shows a list of options on top of the page and left to the button.
I am not using Kendo Popup or context menu, but just using ng-template with structural directive logic.
What i look for?
What i get?
This is my Kendo grid column:
<div style="position: relative">
<kendo-grid>
...
<kendo-grid-column title="SAMPLE">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
<div class="context-dropdown-menu" *ngIf="showIndex === rowIndex && showDialog" style="position: absolute;">
<ul>
<li> <i class="fa fa-envelope"></i> Item2.1 </li>
<li> <i class="fa fa-envelope"></i> Item2.2 </li>
<li> <i class="fa fa-envelope"></i> Item2.3 </li>
</ul>
<div>
<button type="button" (click)="clicked(rowIndex)"> Click </button>
</ng-template>
</kendo-grid-column>
...
</kendo-grid>
</div>
Thanks in advance!
Replace below style in your stackblitz example it will work fine.
.context-dropdown-menu {
margin: 0 -10.75rem;
padding: 0px;
width: 170px;
z-index: 999999;
}
.context-dropdown-menu ul {
margin: 0px;
padding: 0px;
list-style: none;
background: #e4e4e4
}
.context-dropdown-menu ul li {
font-size: 13px;
padding: 7px 10px;
border-bottom: 1px solid #efefef;
color: #617189;
cursor: pointer;
}
.context-dropdown-menu ul li:hover {
background: #f5f5f5;
}
I'm working on a site that needs to (a) work without JavaScript and (b) be keyboard-accessible.
I have used the label target trick to build a tab view (https://css-tricks.com/functional-css-tabs-revisited/), but I've noticed that it relies on the label being clicked. I can't figure out how to make it work with the keyboard. Is this possible?
.tabs {
background-color: #eee;
min-height: 400px;
}
.tabs__list {
border-bottom: 1px solid black;
display: flex;
flex-direction: row;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.tabs__tab {
padding: 0.5rem;
}
.tabs__content {
display: none;
left: 0;
padding: 0.5rem;
position: absolute;
top: 100%;
}
.tabs__input {
display: none;
}
.tabs__input+label {
cursor: pointer;
}
.tabs__input:focus,
.tabs__input:hover {
color: red;
}
.tabs__input:checked+label {
color: red;
}
.tabs__input:checked~.tabs__content {
display: block;
}
<div class="tabs">
<ul class="tabs__list">
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-0" name="tab-group" checked>
<label for="tab-0" class="tabs__label" tabindex="0" role="button">Tab 0</label>
<div class="tabs__content">
Tab 0 content
</div>
</li>
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-1" name="tab-group">
<label for="tab-1" class="tabs__label" tabindex="0" role="button">Tab 1</label>
<div class="tabs__content">
Tab 1 content
</div>
</li>
</ul>
</div>
Accepted answer is not an accessible solution.
I have made some corrections and some observations here. Do not use the accepted answer in production if you stumble across this question in the future. It is an awful experience with a keyboard.
The answer below fixes some of the CSS issues to make it more accessible.
However I would recommend you reconsider the no JavaScript requirement.
I can understand having a good fall-back (which the example I give below with the fixes is) but there is no way you can make a fully accessible set of CSS only tabs.
Firstly you should use WAI-ARIA to complement your HTML to make things even more clear for screen readers. See the tabs examples on W3C to see what WAI-ARIA roles you should be using. This is NOT possible without JavaScript as states need to change (aria-hidden for example should change).
Secondly, you should be able to use certain shortcut keys. Press the home key for example in order to return to the first tab, something you can only do with a little JS help.
With that being said here are a few things I fixed with the accepted answer to at least give you a good starting point as your 'no JavaScript fallback'.
Problem 1 - tabindex on the label.
By adding this you are creating a focusable element that cannot be activated via keyboard (you cannot press space or Enter on the label to change selection, unless you use JavaScript).
In order to fix this I simply removed the tabindex from the labels.
Problem 2 - no focus indicators when navigating via keyboard.
In the example the tabs only work when you are focused on the radio buttons (which are hidden). However at this point there is no focus indicator as the styling is applying styling to the checkbox when it is focused and not to its label.
In order to fix this I adjusted the CSS with the following
/*make it so when the checkbox is focused we add a focus indicator to the label.*/
.tabs__input:focus + label {
outline: 2px solid #333;
}
Problem 3 - using the same state for :hover and :focus states.
This is another bad practice that needs to go away, always have a different way of showing hover and focus states. Some screen reader and screen magnifier users will use their mouse to check they have the correct item focused and orientate themselves on a page. Without a separate hover state it is difficult to check you are hovered over a focused item.
/*use a different colour background on hover, you should not use the same styling for hover and focus states*/
.tabs__label:hover{
background-color: #ccc;
}
Example
In the example I have added a hyperlink at the top so you can see where your focus indicator is when using a keyboard.
When your focus indicator is on one of the two tabs you can press the arrow keys to change tab (which is expected behaviour) and the focus indicator will adjust accordingly to make it clear which tab was selected.
.tabs {
background-color: #eee;
min-height: 400px;
}
.tabs__list {
border-bottom: 1px solid black;
display: flex;
flex-direction: row;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.tabs__tab {
padding: 0.5rem;
}
.tabs__content {
display: none;
left: 0;
padding: 0.5rem;
position: absolute;
top: 100%;
}
.tabs__input {
position: fixed;
top:-100px;
}
.tabs__input+label {
cursor: pointer;
}
.tabs__label:hover{
background-color: #ccc;
}
.tabs__input:focus + label {
outline: 2px solid #333;
}
.tabs__input:checked+label {
color: red;
}
.tabs__input:checked~.tabs__content {
display: block;
}
A link so you can see where your focus indicator is
<div class="tabs">
<ul class="tabs__list">
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-0" name="tab-group" checked>
<label for="tab-0" class="tabs__label" role="button">Tab 0</label>
<div class="tabs__content">
Tab 0 content
</div>
</li>
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-1" name="tab-group">
<label for="tab-1" class="tabs__label" role="button">Tab 1</label>
<div class="tabs__content">
Tab 1 content
</div>
</li>
</ul>
</div>
It is just radio buttons... Keyboard can be used to navigate through them using tab and space bar to check them.
I'd use :focus to highlight the chosen tab and the tabindex property to make it work as I wanted.
Please provide more dept if you have problem with a SPECIFIC problem related to it, and provide a basic code example here, no linking.
Since hidden inputs cannot be selected through keyboard, make them visible...
.tabs {
background-color: #eee;
min-height: 400px;
}
.tabs__list {
border-bottom: 1px solid black;
display: flex;
flex-direction: row;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.tabs__tab {
padding: 0.5rem;
}
.tabs__content {
display: none;
left: 0;
padding: 0.5rem;
position: absolute;
top: 100%;
}
.tabs__input {
position: fixed;
top:-100px;
}
.tabs__input+label {
cursor: pointer;
}
.tabs__input:focus
.tabs__input:hover {
color: red;
}
.tabs__input:checked+label {
color: red;
}
.tabs__input:checked~.tabs__content {
display: block;
}
<div class="tabs">
<ul class="tabs__list">
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-0" name="tab-group" checked>
<label for="tab-0" class="tabs__label" tabindex="0" role="button">Tab 0</label>
<div class="tabs__content">
Tab 0 content
</div>
</li>
<li class="tabs__tab">
<input class="tabs__input" type="radio" id="tab-1" name="tab-group">
<label for="tab-1" class="tabs__label" tabindex="0" role="button">Tab 1</label>
<div class="tabs__content">
Tab 1 content
</div>
</li>
</ul>
</div>
I'm trying to build a basic bar that contains 5 buttons, every button is consist of an icon and below text that describes the icon.
I want that all the images will be on the same line and the descriptions will be underneath.
<img src=phone.png />call office
<img src=circle.png />link to website
<img src=book.png />add to contacts
in this code for example, "call office" should be below the first img, "link to website" below the second and so on but it writes the description but the description appears in the same line with the icons, every description next to itws icon.
can you help?
thx
Do it like this:
The icons/links are placed in a list, the HTML is cleaned up, and I've added a bit of CSS to show how it can look
ul {
list-style-type: none;
}
li {
display: inline-block;
margin: 1em;
}
li a {
display: block;
text-align: center;
}
li a img {
margin: 0 auto;
display: block;
width: 3em;
height: 3em;
}
<ul>
<li><img src=phone.png><br>call office</li>
<li><img src=circle.png><br>link to website</li>
<li><img src=book.png><br>add to contacts</li>
</ul>
I would change the HTML as well. Put just the text in there, because the images have no semantic value. Using CSS you can show the icons, and you don't even need an element for that. Just use the ::before pseudo-element.
nav.social {
text-align: center;
}
nav.social a {
display: inline-block;
padding: 3px;
}
nav.social a::before {
content: "";
display: block;
height: 32px;
background: url(http://www.phonebook.com/favicon.ico) top center no-repeat;
}
nav.social a.website::before {
background-image: url(http://stackoverflow.com/favicon.ico);
}
nav.social a.vcard::before {
background-image: url(https://en.wikipedia.org/favicon.ico);
}
<nav class="social">
<a class="phone" href="tel:036781223333" title="call us">call office</a>
<a class="website" href="http://www.bgasgdhen.com/" title="website">link to website </a>
<a class="vcard" href="advbagsgadron.vcf" title="add to contacts">add to contacts </a>
</nav>
I've got some Bootstrap css styling issues on several Kendo TreeView widgets I'm rendering.
Basically, I have a wizard which the user will navigate through, and on one of the pages I'm display two Kendo TreeView widgets. The user will be able to drag items from the left "source" tree onto their own customized data tree.
Right now the datasource is the same, but that doesn't matter.
The important thing is that the sprite folder image on my left navbar tree is getting hidden every time I navigate to my wizard page which contains the dual treeviews.
I'd like to style of the TreeView so it doesn't interfere with another tree widget in my sidebar. The sprite folder icon is getting hidden in my sidebar tree once I click on the "+" icon which changes my page.
Here is the reportmaint.html page which renders when I click on the "+" icon in sidebar.html (see screen image below). Keep in mind that the reportmaint view contains the left and right TreeViews:
<section data-report-wizard id="reportmaint-view" class="mainbar" data-ng-controller="reportmaint as vm">
<section class="matter">
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-12">
<div class="widget wlightblue">
<div data-cc-widget-header title="{{vm.wizardStep}}" subtitle="" allow-collapse="true"></div>
<div class="widget-content">
<div class="clearfix">
<!-- Wizard steps 1 thru 4 omiteed for brevity -->
<div id="wizard4" class="reportwizard">
<div class="row-fluid">
<h3>Choose KRIs</h3>
<h4>Selected: {{vm.selectedItem.text}}</h4>
<div class="col-sm-6"> <!-- kendo TreeView widgets -->
<span id="treeview-left" kendo-tree-view="tree"
k-options="vm.treeOptions"
k-datasource="vm.kriDataSource1"
k-on-change="vm.onTreeSelect(kendoEvent)"
</span>
</div>
<div class="col-sm-6">
<span id="treeview-right" kendo-tree-view="tree"
k-options="vm.treeOptions"
k-data-source="vm.kriDataSource2"
k-on-change="vm.onTreeSelect(kendoEvent)">
</span>
</div>
</div>
<div class="buttons">
<button class="goto5" ng-click="vm.wizardStep='Report Dimensions'">Next</button>
<button class="cancel-btn backto3" ng-click="vm.wizardStep='Report Dimensions'">Back</button>
<button class="cancel-btn close-popup">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
css code in reportmaint.html :
<style scoped>
#treeview-left, #treeview-right {
color:#000;
}
.k-textbox {
width: 11.8em;
}
.demo-section {
width: 700px;
}
.reportwizard {
width: 510px;
height: 323px;
margin: 0 auto;
padding: 10px 20px 20px 170px;
}
.reportwizard h3 {
font-weight: normal;
font-size: 1.4em;
border-bottom: 1px solid #ccc;
}
.reportwizard ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.reportwizard li {
margin: 7px 0 0 0;
}
textarea {
vertical-align: top;
}
label {
display: inline-block;
width: 90px;
text-align: right;
}
.required {
font-weight: bold;
}
.accept, .status {
padding-left: 90px;
}
.valid {
color: green;
}
.invalid {
color: red;
}
span.k-tooltip {
margin-left: 6px;
}
</style>
and my sidebar.html with css code which styles the left TreeView "reports" menu :
<div style="float:left;">
<span id="treeview" kendo-tree-view="tree"
k-options="vm.treeOptions"
k-data-source="vm.reportsTree"
k-on-change="vm.onTreeSelect(kendoEvent)">
</span>
</div>
<style scoped>
.k-treeview .k-plus, .k-treeview .k-minus, .k-treeview .k-plus-disabled, .k-treeview .k-minus-disabled {
background-image: url("../../Content/kendo/2014.1.624/Uniform/sprite.png");
background-position: -161px -192px;
width: 10px;
height: 11px;
cursor: pointer;
margin-left:-10px;
}
#treeview_tv_active > div > span.k-icon.k-plus {
background-image: url("../../Content/kendo/2014.1.624/Uniform/sprite.png");
background-position: -176px -192px;
width: 10px;
height: 11px;
}
#treeview_tv_active > div > span.k-icon.k-minus {
background-image:url("../../Content/kendo/2014.1.624/Uniform/sprite.png");
background-position: -177px -211px;
width: 10px;
height: 11px;
}
#treeview {
color: #fff; /* white */
}
</style>
Again, once I click on the "+" sign I navigate to reportmain.html. This is when the sidebar treeview styling inadvertently changes; and the background-image folder icon gets hidden.
thanks.
Bob
i don't want to flood my visitors display with all news, so i want to use expanders for each news. But i want to support vistors with JavaScript disabled too.
My try:
#news > .panel > .panel-heading > .panel-title > .label{
float: right;
}
#news > .panel > .panel-body {
display: none;
}
#news > .panel > panel-heading > panel-title > a:visited < .panel-title < .panel-heading < .panel > .panel-body {
display: block;
}
<div id="news" class="tab-pane active">
{% for announcement in server.announcements.all %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ announcement.title }} <span class="label label-default">By {{ announcement.writer.get_username }} at {{ announcement.date_created }}</span></h3>
</div>
<div class="panel-body">
{{ announcement.content|safe_html }}
</div>
</div>
{% endfor %}
</div>
You need to make some changes
First, you will never (at current CSS3 capablity) be able to get what you desire using pure CSS using the :visited psuedo-class for two reasons: (1) the a element is not at the sibling level of the .panel-body, so it cannot control .panel-body through css, and (2) the :visited pseudo-class has severe restrictions on what it allows a designer to control (for privacy reasons).
So what can you do? Use :target instead.
But that will (1) limit you to allowing only one news item open at a time, and (2) requires you to set id properties on your .panel-body elements to match the href of the a tag controlling it. So you would need html structure like this:
<div id="news" class="tab-pane active">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Title 1
<span class="label label-default">By writer name</span>
</h3>
</div>
<div class="panel-body" id="Item1">
Panel 1 body
</div>
</div>
</div>
Where each a has a unique href that is tied to the id of the .panel-body of the item. Then you can get the functionality similar to what you seek by this CSS for the display:
#news > .panel > .panel-body {
display: none;
}
#news > .panel > .panel-body:target {
display: block;
}
You can see how this works in this fiddle example, and to see how it would work with multiple news items, take a look at this fiddle example.
This solution is only CSS3 compatible, so older browsers with javascript disabled would not be able to see any news items (with javascript you can use that to expand)
Graceful degradation:
I would show all news in a container with internal scrollbar (constrained in height) as in : http://jsfiddle.net/Py2HU/1/
And when JS available would add a Show/Hide button, hide N last news and show/hide them after a click (or add Previous/Next buttons to allow scrolling news one by one)
CSS
.news-wrapper {
width: 300px;
max-height: 400px;
overflow: auto;
border: 1px solid #000;
}
HTML
<div class="news-wrapper">
<ul class="news">
<li class="news-item">Lorem ipsum </li>
<li class="news-item">Lorem ipsum </li>
<li class="news-item">Lorem ipsum </li>
<li class="news-item">Lorem ipsum </li>
</ul>
</div>
Compatibility: IE7+ and easily with IE6 (as simple as .ie6 .news-wrapper { height: 400px } if anyone cares)
This answer is for people who are looking for Single expander only with CSS3.
Bootstrap reference is given only to use Glyph-icons(Up/Down).
check Plunker
HTML
<div class="expandercheckbox">
<input id="e1" type="checkbox" checked="checked" />
<label for="e1" class="expanderheader">Click me to Expand/Collpase</label>
<div class="expandercontainer">
I am in container. I am visible. Click above to make be collpase.
</div>
</div>
CSS
body{
padding:50px;
background: #484848;
color:#fff;
}
.expandercheckbox input[type="checkbox"] {
display: none;
}
.expandercheckbox .expanderheader {
cursor: pointer;
}
.expandercheckbox input[type="checkbox"] + .expanderheader {
color: #fff;
font-weight: bold;
font-size: 12px;
white-space: nowrap;
user-select:none;
-webkit-user-select:none;
}
.expandercheckbox input[type="checkbox"] + .expanderheader:before {
content: "\e113";
display: inline-block;
font: 14px/1em Glyphicons Halflings;
height: 20px;
width: 20px;
border-radius: 20px;
margin: -2px 0.25em 0 0;
padding: 1.5px 3.5px;
vertical-align: top;
background: #717171;
/* Old browsers */
}
.expandercheckbox input[type="checkbox"]:checked + .expanderheader:before {
content: "\e114";
padding: 2.5px;
}
.expandercheckbox input[type="checkbox"]:checked + .expanderheader:after {
font-weight: bold;
color:#000;
}
.expandercontainer{
background:#000;
padding:15px;
}
.expandercheckbox input[type="checkbox"]:checked ~ .expandercontainer {
display: block;
}
.expandercheckbox input[type="checkbox"]:not(:checked) ~ .expandercontainer {
display: none;
}