how to change collapse direction of a panel in bootstrap - javascript

I have a well-known basic collapsible panel which its codes mentioned belowed. I changed some properties via css sets like collapse-in and collapse height&width but could not achieve to change collapsing direction. I want to change it towards top opposite to default position. How can I do that? I assure you that I tried several ways but could not solve the issue.
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1">Collapsible panel</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">Panel Body</div>
<div class="panel-footer">Panel Footer</div>
</div>
</div>
</div>

Just interchange the positions of .panel-heading and #collapse1.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="panel-group">
<div class="panel panel-default">
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">Panel Body</div>
<div class="panel-footer">Panel Footer</div>
</div>
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1">Collapsible panel</a>
</h4>
</div>
</div>
</div>
</body>
</html>

Related

Translate Css to jQuery

I am trying to make a collapsible div/panel/rows. I want to add arrow icon (right and down arrow) using jquery/javascript. Do you have idea on how to translate my CSS code on jQuery?
Here's my jQuery code:
$(document).ready(function(){
$(".collapse").on("hide.bs.collapse", function(){
$(".arrows").after().css({"content":"\e080","font-family": "Glyphicons Halflings"});
});
$(".collapse").on("show.bs.collapse", function(){
$(".arrows").after().css({"content":"\e114","font-family": "Glyphicons Halflings"});
});
});
Here's my css code:
.arrows:after {
font-family: "Glyphicons Halflings";
content: "\e114";
}
.arrows.collapsed:after {
font-family: "Glyphicons Halflings";
content: "\e080";
}
Here's my HTML code:
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1">Collapsible panel <span class="arrows"></span></a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">Panel Body</div>
<div class="panel-footer">Panel Footer</div>
</div>
</div>
</div>
check this snipped.just toggle the class on hide and show events
$(".collapse").on("hide.bs.collapse", function() {
$(this).parent().find('.arrows').addClass('collapsed');
});
$(".collapse").on("show.bs.collapse", function() {
$(this).parent().find('.arrows').removeClass('collapsed');
});
.arrows:after {
font-family: "Glyphicons Halflings";
content: "\e114";
}
.arrows.collapsed:after {
font-family: "Glyphicons Halflings";
content: "\e080";
}
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1">Collapsible panel <span class="arrows collapsed"></span></a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">Panel Body</div>
<div class="panel-footer">Panel Footer</div>
</div>
</div>
</div>
</body>
</html>

area tag/ not clickable in firefox MAC

Hi I made a image map with 2 clickable areas. (The Netherlands and South Africa)
It works fine in Google chrome, Edge, Internet Explorere 11, Safari and mobile/tablet browser and chrome.
But if I open my page: http://www.fruitconneqt.jevdopilot.nl/index.php/teest/
in firefox on my MAC I can't click on the Netherlands or South Africa.
I really don't know why this is not working... so I hope maybe you know what I can change to make this work in mozilla firefox for MAC.
Thanks...
<!DOCTYPE HTML>
<head>
<title>relaties</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/ios-orientationchange-fix.min.js"></script>
<!--Fireworks CS5 Dreamweaver CS5 target. Created Wed Dec 02 16:20:39 GMT+0100 (CET) 2015-->
<style>
body {
font-family: Helvetica, Arial, sans-serif;
}
h1 {
font-size: 20px;
}
div {
width: 100%;
text-align: center;
}
img[usemap] {
border: none;
height: auto;
max-width: 100%;
width: auto;
}
</style>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/agency.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700' rel='stylesheet' type='text/css'>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]AFRIKA 917,563,1062,614| NL 835,161,1000,240-->
</head>
<body bgcolor="#ffffff">
<div>
<img name="relaties" src="img/relaties.jpg" width="1909" height="832" border="0" id="relaties" usemap="#m_relaties" alt="" /><map name="m_relaties" id="m_relaties">
<a data-toggle="collapse" data-target="#collapseSix" class="page-scroll" data-parent="#accordion" href="#collapseSix">
<area shape="rect" coords="896,556,1072,632" href="#collapseSix" alt="" />
</a>
<a data-toggle="collapse" data-target="#collapseOne" class="page-scroll" data-parent="#accordion" href="#collapseOne">
<area shape="rect" coords="816,155,1016,253" href="#collapseOne" alt="" />
</a>
</map>
</div>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<div id="wrap text-center">
</div>
</div>
</div>
</div>
<br><br>
<div class="container text-left">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"><strong>The Netherlands</strong><span class="caret" ></span></a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body text-left"> <p><img src="img/logo_fruitconneqt_klein.jpg" width="15%" > Fruit Conneqt - Bekijk de website</p><hr>
</div>
</div>
</div>
<!-- FRANCE -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"><strong>France</strong><span class="caret"></span></a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body text-left">
<p>Honey Crunch Learn more.</p>
</div>
</div>
</div>
<!-- ITALY -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree"><strong>Italy</strong><span class="caret"></span></a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body text-left">
<p>Mazzoni Learn more.</p>
</div>
</div>
</div>
<!-- CHILE -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseFour"><strong>Chile</strong><span class="caret"></span></a>
</h4>
</div>
<div id="collapseFour" class="panel-collapse collapse">
<div class="panel-body text-left">
<p>CopeFrut Learn more.</p>
</div>
</div>
</div>
<!-- NEW ZEALAND -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseFive"><strong>New Zealand</strong><span class="caret"></span></a>
</h4>
</div>
<div id="collapseFive" class="panel-collapse collapse">
<div class="panel-body text-left">
<p>Taylor New Zealand Learn more.</p>
</div>
</div>
</div>
<!-- SOUTH AFRICA -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title text-left">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseSix"><strong>South Africa</strong><span class="caret"></span></a>
</h4>
</div>
<div id="collapseSix" class="panel-collapse collapse">
<div class="panel-body text-left">
<p><img src="img/capesupra.jpg" width="15%"> Cape Supra - Bekijk de website</p>
</div>
</div>
</div>
<section id="services">
</section>
</div>
</div>
</div>
<script src="js/scrolling-nav.js"></script>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Plugin JavaScript -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="js/classie.js"></script>
<!-- Contact Form JavaScript -->
<script src="js/jqBootstrapValidation.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/agency.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.rwdImageMaps.min.js"></script>
<script>
$(document).ready(function(e) {
$('img[usemap]').rwdImageMaps();
});
</script>
</body>
</html>

Bootstrap + AngularJS + jQuery - Nested panels "collapse" behaviour failing

I am trying to nest accordion panels which works. However, I want the chevron icon to point down (fa-chevron-down) when the panel-body is collapsed and point right when the panel-body is not collapsed. I wrote a directive to get this effect and it too works.However, when I apply this directive to the nested panel, its working the effect on both the nested and parent panel-heading. What am I doing wrong? Is there a cleaner way to do this?
(function () {
'use strict';
angular
.module('myApp', [])
.directive('bsCollapse', bsCollapse);
function bsCollapse() {
var $ = window.$;
var directive = {
restrict: 'EA',
link: linkFunc,
};
return directive;
function linkFunc(scope, el, attr, ctrl) {
$(el[0])
.on('hide.bs.collapse', function (evt) {
$(evt.currentTarget)
.prev()
.children()
.children()
.removeClass('fa-chevron-down')
.addClass('fa-chevron-right');
})
.on('show.bs.collapse', function (evt) {
$(evt.currentTarget)
.prev()
.children()
.children()
.removeClass('fa-chevron-right')
.addClass('fa-chevron-down');
});
}
}
})();
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<body>
<div class="container">
<!-- PARENT PANEL GROUP -->
<div class="panel-group col-sm-6 col-sm-offset-3" id="accordion">
<!-- PARENT PANEL -->
<div class="panel panel-default">
<!-- PARENT PANEL HEADING -->
<div class="panel-heading" data-parent="#accordion" data-target="#collapseOne" data-toggle="collapse" role="button">
<h4 class="panel-title">
PARENT PANEL HEADING
<i class="fa fa-chevron-down fa pull-right"></i>
</h4>
</div>
<!-- PARENT PANEL COLLAPSE BODY -->
<div bs-collapse class="panel-collapse collapse in" id="collapseOne" role="tabpanel">
<div class="panel-body">
<!-- NESTED PANEL GROUP -->
<div class="panel-group" id="accordion2">
<!-- NESTED PANEL -->
<div class="panel panel-default">
<!-- NESTED PANEL HEADING -->
<div class="panel-heading" data-parent="#accordion2" data-target="#nestedCollapseOne" data-toggle="collapse" role="button">
<h4 class="panel-title">
NESTED PANEL HEADING
<i class="fa fa-chevron-down fa pull-right"></i>
</h4>
</div>
<!-- NESTED PANEL COLLAPSE BoDY -->
<div bs-collapse class="panel-collapse collapse in" id="nestedCollapseOne" role="tabpanel">
<div class="panel-body">
NESTED PANEL BODY....
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- JS Assets -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
</body>
</html>
I've tried the method mentioned in the answer below. scope, flag and have faced the problem that when quickly opening and closing the panel/accordion, it fails. Please see the sreenshots - they are from the plnkr you've provided. Thanks though.
The icons in both the panels are affected is because the $on event is triggered at the same time in both the elements. I have edited your code and added few lines of code in script and used angularjs' ng-class which is lot easier. Here is a plunker demo . Hope it helps.
scipt.js:
scope.flag1 = true;
scope.flag2=true;
scope.parentDiv = function() {
scope.flag1 = !scope.flag1;
};
scope.nestedDiv = function() {
scope.flag2= !scope.flag2;
};
HTML:
<h4 class="panel-title">
PARENT PANEL HEADING
<i ng-class="{'fa fa-chevron-down': flag1, 'fa fa-chevron-right': !flag1}" class="pull-right"></i>
</h4>
<h4 class="panel-title">
NESTED PANEL HEADING
<i ng-class="{'fa fa-chevron-down': flag2, 'fa fa-chevron-right': !flag2}" class="pull-right"></i>
</h4>
I've found a CSS solution to this. Thankfully, Bootstrap throws in a collapsed class to the panel-heading. From there I can add this style which adds the chevron-right to :before pseudo class.
Also, this doesn't require directive or AngularJS code.
Thank you stackoverflow for reference to this :
Use Font Awesome Icons in CSS
div.panel-heading i {
position: relative;
}
div.panel-heading.collapsed i:before {
content: "\f054";
font-family: FontAwesome;
}
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<body>
<div class="container">
<!-- PARENT PANEL GROUP -->
<div class="panel-group col-sm-6 col-sm-offset-3" id="accordion">
<!-- PARENT PANEL -->
<div class="panel panel-default">
<!-- PARENT PANEL HEADING -->
<div class="panel-heading" data-parent="#accordion" data-target="#collapseOne" data-toggle="collapse" role="button">
<h4 class="panel-title">
PARENT PANEL HEADING
<i class="fa fa-chevron-down fa pull-right"></i>
</h4>
</div>
<!-- PARENT PANEL COLLAPSE BODY -->
<div bs-collapse class="panel-collapse collapse in" id="collapseOne" role="tabpanel">
<div class="panel-body">
<!-- NESTED PANEL GROUP -->
<div class="panel-group" id="accordion2">
<!-- NESTED PANEL -->
<div class="panel panel-default">
<!-- NESTED PANEL HEADING -->
<div class="panel-heading" data-parent="#accordion2" data-target="#nestedCollapseOne" data-toggle="collapse" role="button">
<h4 class="panel-title">
NESTED PANEL HEADING
<i class="fa fa-chevron-down fa pull-right"></i>
</h4>
</div>
<!-- NESTED PANEL COLLAPSE BoDY -->
<div bs-collapse class="panel-collapse collapse in" id="nestedCollapseOne" role="tabpanel">
<div class="panel-body">
NESTED PANEL BODY....
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- JS Assets -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
</body>
</html>

javascript bootstrap Accordion

I have looked through the numerous questions others have posed about an accordion style collapsable set of panels but I haven't been able to find one in which the panels remain separate and do not retain a header of sorts.
I am looking to have numerous buttons on one side and on the other, a panel to be displayed when a button is clicked. I want only one panel to ever be displayed at a time. I am using BootStrap CSS Framework (love it).
I would greatly appreciate it if someone could please help me fine tune my code. I do not understand where I have gone wrong.
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid main">
<div class="row">
<div class="col-md-2">
<ul class="nav nav-pills nav-stacked">
<li role="presentation" class="active"><a data-toggle="collapse" data-target="#overview" aria-expanded="true" aria-controls="overview" data-parent="#accordion">Overview</a></li>
<li role="presentation"><a data-toggle="collapse" data-target="#view1" aria-expanded="false" aria-controls="view1" data-parent="#accordion">View 1</a></li>
<li role="presentation"><a data-toggle="collapse" data-target="#view2" aria-expanded="false" aria-controls="view2" data-parent="#accordion">View 2</a></li>
</ul>
</div>
<div class="col-md-10">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default collapse in" id="overview">
<div class="panel-heading">
<h3 class="panel-title">Overview</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
<div class="panel panel-default collapse" id="view1">
<div class="panel-heading">
<h3 class="panel-title">View 1</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
<div class="panel panel-default collapse" id="view2">
<div class="panel-heading">
<h3 class="panel-title">View 2</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Just add one more layer of panels
<div class="container-fluid main">
<div class="row">
<div class="col-md-2">
<ul class="nav nav-pills nav-stacked">
<li role="presentation" class="active"><a data-toggle="collapse" data-target="#overview" aria-expanded="true" aria-controls="overview" data-parent="#accordion">Overview</a></li>
<li role="presentation"><a data-toggle="collapse" data-target="#view1" aria-expanded="false" aria-controls="view1" data-parent="#accordion">View 1</a></li>
<li role="presentation"><a data-toggle="collapse" data-target="#view2" aria-expanded="false" aria-controls="view2" data-parent="#accordion">View 2</a></li>
</ul>
</div>
<div class="col-md-10">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel">
<div class="panel panel-default collapse in" id="overview">
<div class="panel-heading">
<h3 class="panel-title">Overview</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
</div>
<div class="panel">
<div class="panel panel-default collapse" id="view1">
<div class="panel-heading">
<h3 class="panel-title">View 1</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
</div>
<div class="panel">
<div class="panel panel-default collapse" id="view2">
<div class="panel-heading">
<h3 class="panel-title">View 2</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You might have to adjust the classes for the inner content if you want to get rid of any extra padding / margin. The only thing you have to know is that bootstrap hides the children of any panels under the data-parent unless they match the data-target of what was just clicked.

Click to Call in phonegap app

I have a very simple phonegap app which consists of 2 html pages. One page is a directory listing and I want to be able to click to call or click to sms on the entries. The click to call/sms works when I serve the page from a website, but not when I include the same page in the phonegap www fold and build a simple app.
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>Mobile Group Directory</title>
</head>
<body style="background-color:#A5C1C9">
<div class ="container-fluid">
<div class="panel-group" id="directory">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a data-toggle="collapse" data-parent="#directory" href="#A"> Anteater, Alfred</a> cell:123-456-7890 Send SMS
</h3>
</div>
<div id="A1" class="panel-collapse collapse">
<div class="panel-body">
Alfred<br>123 Smart Way<br>Braintown, MO<br>anteater#yahoo.com
</div>
</div>
</div>
<br>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a data-toggle="collapse" data-parent="#directory" href="#B2"> Brown, Bob</a> cell:9876543210 Send SMS
</h3>
</div>
<div id="B2" class="panel-collapse collapse">
<div class="panel-body">
Bob<br>345 Middle Way<br>Low Risk, MO<br>bob#msn.com
</div>
</div>
</div>
</div>
</div>
</body>
Try this instead :
document.location.href = 'tel:a number'

Categories

Resources