cordova: accordion list for html - html

I need a accordion list for the html code below. I just want it to be able to open (expand) when click on the 'Technical'. When click again, it will close(collapse).
This is my html code
<!-- Techincal -->
<div class="item">
<div class="row">
<div class="col boldText">Technical</div>
</div>
<!--List-->
<div class="item">
<div class="row centerized">
<div class="col col-40"></div>
<div class="col col-30">Min</div><div class="col col-30">Max</div>
</div>
<div class="row">
<div class="col col-40">Tech spec</div>
<div class="col col-30"><input type="number" placeholder="0" ng-model="searchQuery.techMin"></div>
<div class="col col-30"><input type="number" placeholder="5" ng-model="searchQuery.techMax"></div>
</div>
<div class="row">
<div class="col col-40">Radius</div>
<div class="col col-30"><input type="number" placeholder="-1000" ng-model="searchQuery.radiusMin"></div>
<div class="col col-30"><input type="number" placeholder="1000" ng-model="searchQuery.radiusMax"></div>
</div>
</div>
</div>
I have no javascript code just simple html. It is written in ionic/cordova. How make it a simple preset collapsable and expandable when click?

There are multiple methods to solve this, i find this method as per your requirement
Your HTML code
<!-- Techincal -->
<ul>
<li class="item-stable item-icon-right"
ng-click="toggleGroup(0)"
ng-class="{active: isGroupShown(0)}">
<button class="item-text-center item-text-wrap">Techincal </button>
</li>
<div class="item-accordion"
ng-show="isGroupShown(0)">
<div class="item">
<div class="row">
<!--List-->
<div class="item">
<div class="row centerized">
<div class="col col-40"></div>
<div class="col col-30">Min</div><div class="col col-30">Max</div>
</div>
<div class="row">
<div class="col col-40">Tech spec</div>
<div class="col col-30"><input type="number" placeholder="0" ng-model="searchQuery.techMin"></div>
<div class="col col-30"><input type="number" placeholder="5" ng-model="searchQuery.techMax"></div>
</div>
<div class="row">
<div class="col col-40">Radius</div>
<div class="col col-30"><input type="number" placeholder="-1000" ng-model="searchQuery.radiusMin"></div>
<div class="col col-30"><input type="number" placeholder="1000" ng-model="searchQuery.radiusMax"></div>
</div>
</div>
</div>
</div>
</div>
</ul>
Here is your js code
<script>
$scope.toggleGroup = function(group) {
if ($scope.isGroupShown(group)) {
$scope.shownGroup = null;
} else {
$scope.shownGroup = group;
}
};
$scope.isGroupShown = function(group) {
return $scope.shownGroup === group;
};
</script>

Something like this, without extra modules. Just a simple solution to toggle some content. Animation can be done using CSS if needed. This is just to get you started with your initial question.
VIEW
<!-- Techincal -->
<div class="item">
<div class="row">
<div style="padding:10px; background: gray;" class="col boldText" ng-click="vm.toggleContainer()">Technical</div>
</div>
<!--List-->
<div class="item" style="margin-top:25px;" ng-if='vm.showTechnicalDetails'>
<div class="row centerized">
<div class="col col-40"></div>
<div class="col col-30">Min</div>
<div class="col col-30">Max</div>
</div>
<div class="row">
<div class="col col-40">Tech spec</div>
<div class="col col-30">
<input type="number" placeholder="0" ng-model="searchQuery.techMin">
</div>
<div class="col col-30">
<input type="number" placeholder="5" ng-model="searchQuery.techMax">
</div>
</div>
<div class="row">
<div class="col col-40">Radius</div>
<div class="col col-30">
<input type="number" placeholder="-1000" ng-model="searchQuery.radiusMin">
</div>
<div class="col col-30">
<input type="number" placeholder="1000" ng-model="searchQuery.radiusMax">
</div>
</div>
</div>
</div>
</div>
JS Angular part (vm approach)
angular
.module('app', [])
.controller('MainController', MainController)
function MainController() {
var vm = this;
vm.toggleContainer = toggleContainer;
vm.showTechnicalDetails = false;
function toggleContainer() {
vm.showTechnicalDetails = !vm.showTechnicalDetails;
}
}
JSFiddle : https://jsfiddle.net/DaanDeSmedt/Ln2dgmer/
JS Angular part ($scopeapproach)
angular
.module('app', [])
.controller('MainController', MainController)
function MainController($scope) {
$scope.showTechnicalDetails = false;
$scope.toggleContainer = function(){
$scope.showTechnicalDetails = !$scope.showTechnicalDetails;
}
}
JSFIDDLE : https://jsfiddle.net/DaanDeSmedt/Ln2dgmer/3/

Related

HTML Move elements after element deleted

As a school project I am creating an website like Google Keep where you can create and share notes. To display existing notes i use Bootstraps container, row and cards. This works fine until one element is deleted which creates a gap where the old element was. How can I remove the gap and make elements move to fill the gap?
The elements are:
<div class="col-sm-4">
</div>
Thanks in advance,
Nikita
The simplest solution might be to not wrap every n notes in a .row element. If you do this, the cards will reflow on their own.
Though it is hard to give a direct answer without an MCVE to work from.
// Demo code to illustrate card removal.
$( function () {
$( '.notes' ).on( 'click', '.card', function ( e ) {
$( this ).parent().remove();
} );
} );
.card {
margin-bottom: 1rem;
padding: 2rem 4rem;
text-align: center;
cursor: pointer;
}
.card:hover {
background-color: #eaeaea;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
<div class="container notes">
<div class="row">
<div class="col col-sm-4">
<div class="card">1</div>
</div>
<div class="col col-sm-4">
<div class="card">2</div>
</div>
<div class="col col-sm-4">
<div class="card">3</div>
</div>
<div class="col col-sm-4">
<div class="card">4</div>
</div>
<div class="col col-sm-4">
<div class="card">5</div>
</div>
<div class="col col-sm-4">
<div class="card">6</div>
</div>
<div class="col col-sm-4">
<div class="card">7</div>
</div>
<div class="col col-sm-4">
<div class="card">8</div>
</div>
<div class="col col-sm-4">
<div class="card">9</div>
</div>
<div class="col col-sm-4">
<div class="card">10</div>
</div>
</div>
</div>

Error with Angular 2 Template

I am using an Angular 2 template (which looks fine to me):
<div class="container gt-container-fluid gt-container-form">
<div class="row">
<div class="col-sm-6">
<fieldset class="gt-fieldset">
<legend class="gt-legend">Details</legend>
<div class="row gt-row">
<div class="col-6"><label for="title">Requirements Title:</label></div>
<div class="col-6"><input id="title" type="text" class="k-textbox" [(ngModel)]="Requirement.Title" /></div>
</div>
<div class="row gt-row">
<div class="col-12"><label for="details">Requirements Details:</label></div>
</div>
<div class="row gt-row">
<div class="col-12">
<textarea id="details" class="k-textbox gt-textbox" [(ngModel)]="Requirement.Details"></textarea>
</div>
</div>
<div class="row gt-row">
<div class="col-6"><label for="rating">Requirement Rating:</label></div>
<div class="col-6"><kendo-dropdownlist id="ratings" [data]="ratingsData" [textField]="'ProductName'" [valueField]="'ProductID'" [defaultItem]="ratingsPlaceHolder"></kendo-dropdownlist></div>
</div>
<div class="row gt-row">
<div class="col-6"><label for="status">Approval Status:</label></div>
<div class="col-6"><kendo-dropdownlist id="approvalStatus" [data]=""></kendo-dropdownlist></div>
</div>
</fieldset>
<fieldset class="gt-fieldset">
<legend class="gt-legend">Attachments</legend>
<div class="row gt-row">
<div class="col-12"><label for="attachments">Drag and drop files of click "Select" to browse:</label></div>
</div>
<div class="row gt-row">
<div class="col-12">
<kendo-upload id="Attachments"
[saveUrl]=""
[removeUrl]=""
[disabled]="">
</kendo-upload>
</div>
</div>
</fieldset>
</div>
<div class="col-sm-6">
<kendo-tabstrip>
<kendo-tabstrip-tab [title]="'Framework Items'" [selected]="true">
<template kendoTabContent>
<div class="row gt-row">
<div class="col-6"><label for="framework">Framework Items:</label></div>
<div class="col-6"><kendo-multiselect [data]="frameworkItems" [value]="" [placeholder]="'Framework Items'"></kendo-multiselect></div>
</div>
<div class="row gt-row">
<div class="col-12 gt-col-addremovebuttons">
<button kendoButton (click)="onButtonClick()" [primary]="true">+</button>
<button kendoButton (click)="onButtonClick()" [primary]="true">-</button>
</div>
</div>
<div class="row gt-row">
<div class="col-12">
<kendo-grid [data]="frameworkItemsData" [height]="200">
<kendo-grid-column field="FrameworkLocation" title="ID">
</kendo-grid-column>
<kendo-grid-column field="FrameworkTitle" title="Name">
</kendo-grid-column>
</kendo-grid>
</div>
</div>
</template>
</kendo-tabstrip-tab>
<kendo-tabstrip-tab [title]="'Related Actions'">
<template kendoTabContent>
<div class="row gt-row">
<div class="col-6"><label for="actions">Related Actions:</label></div>
<div class="col-6"><kendo-multiselect [data]="actionItems" [value]="" [placeholder]="'Actions'"></kendo-multiselect></div>
</div>
</template>
</kendo-tabstrip-tab>
</kendo-tabstrip>
</div>
</div>
<div class="row gt-row">
<div class="col-12 gt-col-buttons">
<button kendoButton (click)="saveChanges()" [primary]="true">Save</button>
<button kendoButton (click)="onButtonClick()" [primary]="false">Edit</button>
<button kendoButton (click)="deleteRecord()" [primary]="false">Delete</button>
<button kendoButton (click)="onButtonClick()" [primary]="false">Close</button>
</div>
</div>
</div>
However, it is throwing the following error (amongst others):
Unhandled Promise rejection: Template parse errors: Unexpected closing
tag "legend" (">\n \n
Details[ERROR ->]\n
\n \n Requirements Title:[ERROR ->]\n
\n
Interestingly the code highlighting in the code input in stack overflow shows me the same kind of errors but I can't for the life of me spot the error.
Any help much appreciated!

bootsrap 3.1 pull main content first (on TOP) when mobile

I have following grid structure
<div class="row">
<div id="A" class="col-md-3">
<div class="alert alert-info">A</div>
</div>
<div id="B" class="col-md-6">
<div class="alert alert-danger">B</div>
</div>
<div id="C" class="col-md-3">
<div class="alert alert-info">C</div>
</div>
</div>
I want to show B first when mobile (But when big device other than mobile then it should show as above) and also WHEN mobile all A,B,Cwill be in equal width. I have tried as following
<div class="col-md-3 col-md-push-6">
<div class="alert alert-info">A</div>
</div>
<div class="col-md-6 col-md-pull-3">
<div class="alert alert-danger">B</div>
</div>
<div class="col-md-3">
<div class="alert alert-info">C</div>
</div>
Also tried in many combination nothing working
WHEN big screen like desktop
When mobile
Try this one :
<div class="col-sm-6 col-sm-push-3">
<div class="alert alert-danger">B</div>
</div>
<div class="col-sm-3 col-sm-pull-6">
<div class="alert alert-info">A</div>
</div>
<div class="col-sm-3">
<div class="alert alert-info">C</div>
</div>
Or DEMO here.
I used javascript to implement this functionality. I am first finding bootstrap environment and according to it i am arranging divs.
var current='';
function findBootstrapEnvironment() {
var envs = ['xs', 'sm', 'md', 'lg'];
var $el = $('<div>');
$el.appendTo($('body'));
for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];
$el.addClass('hidden-'+env);
if ($el.is(':hidden')) {
$el.remove();
return env;
}
}
}
if(findBootstrapEnvironment()=="sm"&&findBootstrapEnvironment()!=current){
current=findBootstrapEnvironment();
var a=$('.row').children()[0];
var b=$('.row').children()[2];
$('.row').children()[0].remove();
$('.row').children()[1].remove();
$('.row').append(a);
$('.row').append(b);
console.log(current);
}
$( window ).resize(function() {
if((findBootstrapEnvironment()=="sm"||findBootstrapEnvironment()=="md")&&findBootstrapEnvironment()!=current){
current=findBootstrapEnvironment();
var a=$('.row').children()[0];
var b=$('.row').children()[2];
$('.row').children()[0].remove();
$('.row').children()[1].remove();
$('.row').append(a);
$('.row').append(b);
console.log(current);
}
});
Demo : https://jsfiddle.net/oog0gdph/
<div class="col-xs-12 col-sm-6 col-sm-push-4 " >B</div>
<div class="col-xs-12 col-sm-pull-6 col-sm-3" >A</div>
<div class="col-xs-12 col-sm-3">C</div>

How to apply class to div dynamically using AngularJS

I want to switch to div with class="col-md-x" depending upon the number of student object i am receiving.
E.x: Sample
if i am getting only one JSON object then i want to a div with class should be like(class="col-md-12").
if am getting two JSON object then i want to switch to a div with class="col-md-6".
<div class="container">
<div class="row">
<div class="col-md-12">
<div clss="row">
<div ng-repeat="c in vm.students" class="col-md-12">
<div calss="thimbnail">
<div class="Option div 1">
</div>
</div>
</div>
<div ng-repeat="c in vm.students" class="col-md-6">
<div calss="thimbnail col-md-">
<div class="Option div 2">
</div>
</div>
</div>
<div ng-repeat="c in vm.students" class="col-md-4">
<div calss="thimbnail col-md-">
<div class="Option div 3">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Use ng-class like below,
ng-class="{class}[condition]"
In your case ,
ng-class="{1:'col-md-12', 2:'col-sm-6'}[vm.students.length]"
For your reference, Detailed explanation
You have calss instead of class in the example code. I hope that is a typo.
To address to your problem you can make use of ng-class where you can assign classes based on conditions
More document on ng-class
Code Snippet:
<div class="container">
<div class="row">
<div class="col-md-12">
<div clss="row">
<div ng-repeat="c in vm.students" ng-class="{col-md-12:vm.students.length === 1,col-md-6:vm.students.length === 2">
<div calss="thimbnail">
<div class="Option div 1">
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Add content to top-right area of rows

After various attempts with pull-right, float style and row-fluid, I decided to ask here:
What I try to do is simply to have a Map appear to the right of a set of rows.
Here is how it looks right now:
Which is not too far from what I want, but the name row plus any following rows should appear below each other.
Here is how my HTML looks:
<div class="panel-body">
<div class="row-fluid">
<div class="col-lg-10 pull-right">
<google-map id="my-map" bounds="map.bounds" events="map.events"
center="map.center" zoom="map.zoom" draggable="true"
control="map.control"> <marker ng-if="positionMarker"
coords="positionMarker" icon="positionMarker.icon"> </marker> </google-map>
</div>
<div class="col-lg-4">
<div class="input-group">
<span class="input-group-addon">Number</span> <input type="number"
class="form-control" placeholder="Nr">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">Name</span> <input type="text"
class="form-control" placeholder="Name">
</div>
</div>
</div>
</div>
I bet this is a typical scenario but I have failed to find an example.
Other attempts that makes name appear below number, moves it below the map.
Is it perhaps possible to avoid having the map take up vertical space in the Bootstrap grid system?
You should use a 2-col layout :
Left column for your inputs
Right column for your Google Map
Plus, remember to put your .input-group inside a .form-group to get paddings/margins set to Bootstrap default values.
Here's a working example (click on Full page for a better view):
body {
padding-top: 25px;
}
.map {
width: 100%;
height: 150px;
background: tomato;
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Panel heading</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Number</span> <input type="number"
class="form-control" placeholder="Nr">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Name</span> <input type="text"
class="form-control" placeholder="Name">
</div>
</div>
</form>
</div>
<div class="col-xs-6">
<div class="map"></div>
</div>
</div>
</div>
</div>
</div>