For information about cards please refer to Bootstrap's documentation.
Inside .card-header you can have one or more .card-toolbars:
<div class="card-header">
<h5 class="card-title"> ... </h5>
<div class="card-toolbar">
<button type="button" class="btn btn-info">Button</button>
</div>
</div>
- It can also be
.card-header-lgand.card-header-smfor larger and smaller sizes. - Add
.no-borderto.card-toolbarto hide the separator line.
The progress bar in the "Big Header with Progress" card is a custom DIV with a CSS animation that you can see in:
views/pages/cards/@page-style.css
You can add data-action attribute to a button inside card toolbar for following actions:
togglehides/shows.card-bodyexpandmakes the.cardfullscreenreloadsends a.reload.ace.widgetevent to the.cardand display anoverlay. You should later callstopLoadingto remove the overlay.closecloses (and removes) the.card
<div class="card-toolbar">
<a href="#" data-action="close" class="card-toolbar-btn text-danger-m1">
<i class="fa fa-times"></i>
</a>
</div>
.card-toolbar-btn adds some styling to the button.
For toggle button you can have an -up or -down icon which will be flipped or you can use dynamic styles to show/hide icons:
<div class="card-toolbar">
<a href="#" data-action="toggle" class="d-style card-toolbar-btn text-grey">
<i class="fa fa-minus d-n-collapsed"></i><!-- displayed this when NOT collapsed -->
<i class="fa fa-plus d-collapsed"></i><!-- displayed this when collapsed -->
</a>
</div>
Same is true for expand button:
<div class="card-toolbar">
<a href="#" data-action="expand" class="d-style card-toolbar-btn text-orange">
<i class="fa fa-expand d-n-active"></i><!-- displayed this when NOT active (not fullscreen) -->
<i class="fa fa-compress d-active"></i><!-- displayed this when active (fullscreen) -->
</a>
</div>
Toggles the widget
Toggles the widget without animation
Shows the widget
Shows the widget without animation
Hides the widget
Hides the widget without animation
Closest and removes the widget
Removes the widget without animation
Expands the widget to become fullscreen
Expands the widget without animation
Restores the widget
Restores the widget without animation
Display a blocking layer over widget and it will be displayed until you call stopLoading:
// User wants to reload widget data, etc
$('#my-widget').aceWidget('startLoading')//or $('#my-widget').aceWidget('startLoading', 'Custom loading text or html')
//then load data
...
...
//when data is ready
$('#my-widget').aceWidget('stopLoading')
Triggered when widget body is to be collapsed
Triggered after widget body is collapsed
Triggered when widget body is to be shown
Triggered after widget body is shown
Triggered when widget is to be closed and removed
Triggered after widget is closed and removed
Triggered when widget is to be expanded
Triggered after widget is expanded
Triggered when widget is to be restored
Triggered after widget is restored
Triggered when widget is to be reloaded
$('#card-1').on('hide.ace.widget', function(e) {
e.preventDefault()
}).on('expanded.ace.widget', function(e) {
//do something
})
$('#card-1').on('hide.ace.widget', function(e) {
e.preventDefault()
}).on('expanded.ace.widget', function(e) {
//do something
})
SortableJS plugin is used to enable drag and drop in Widgets page.
First of all we assign an optional .cards-container class to each .col-* or element that contains .card elements:
<div class="col-12 col-sm-6 cards-container">
<div class="card">
...
</div>
<div class="card">
...
</div>
</div>
You should also assign an ID attribute to both .cards-container and .cards elements so they can be saved/restore to storage.
In this demo I do that in Javascript.
// assign an ID to containers & cards to easily save/restore data to localStorage
$('.cards-container')
.each(function(index) {
this.setAttribute('id', 'card-container-' + (index+1))
})
$('.card')
.each(function(index) {
this.setAttribute('id', 'card-' + (index+1))
})
// enable sortable plugin for each container
$('.cards-container').each(function() {
Sortable.create(this, {
// give them a common name, so `.card` elements can be drag & dropped between different `.cards-containers`
group: 'mycards',
draggable: '> .card',// we are interested in dragging/sorting `.card` elements that are direct children of `.cards-container` elements
animation: 200,
ghostClass: 'brc-grey-m1',
chosenClass: '',
dragClass: 'bgc-yellow-m3',// the highlight
// maybe in touch devices, only allow dragging for .card-header
handle: ('ontouchstart' in window ? '.card-header' : null),
onEnd: function (evt) {
// when a drag & drop has ended
// first get our previously saved `containers` data
var containers = _getData('card-containers')
// clear our `from` and `to` card-containers (i.e set to empty array)
containers[evt.to.id] = []
containers[evt.from.id] = []
// now find all the `.card` children and add them to the the relevant .cards-container array
$('#' + evt.to.id)
.find('> .card')
.each(function() {
containers[evt.to.id].push(this.id)
})
$('#' + evt.from.id)
.find('> .card')
.each(function() {
containers[evt.from.id].push(this.id)
})
// now save them back again
_saveData('card-containers', containers);
}
})
})
Using local storage you can easily save and restore the position and state of cards.
As you saw in the above example, we update the order of .card elements in onEnd function.
Later on page load we can restore the order like this:
// load are previously saved data (using _saveData in above)
var containers = _getData('card-containers')
for(var containerId in containers) {
// retrieve the array containting ".card" IDs in a container
var cards = containers[containerId]
// a reference to the container
var containerEl = document.getElementById(containerId)
if (!containerEl) continue
// add each card to the container
for(var i = 0; i < cards.length; i++) {
var card = document.getElementById(cards[i])
if (card) {
containerEl.appendChild( card )
}
}//for
}//for
You can do the same thing for saving/restoring card states such as collapsed, closed, etc.
See views/pages/cards/@page-script.js for more details.
You can hide the entire cards area, restore positions and states and then show the cards area again:
<div id="cards-area" class="invisible">
<!-- cards and containers here -->
</div>
// restoring positions and states
// when finished
$('#cards-area').removeClass('invisible')
However this is not needed if you do that on the server side
_saveData and _getData are simple functions defined in views/pages/cards/@page-script.js
for easier reading from and writing to localStorage