2015-12-04 04:09:01 +03:00
|
|
|
import Style from './style'
|
2015-12-04 17:53:46 +03:00
|
|
|
import Clipboard from 'clipboard'
|
2015-12-24 20:06:02 +03:00
|
|
|
import anchors from 'anchor'
|
2016-01-04 20:28:12 +03:00
|
|
|
|
|
|
|
// import all the mdb code
|
2016-01-05 19:50:38 +03:00
|
|
|
import '../../../../js/src/index' // eslint-disable-line no-unused-vars
|
2015-11-20 00:58:21 +03:00
|
|
|
|
2015-12-04 04:09:01 +03:00
|
|
|
class Application {
|
2015-11-20 00:58:21 +03:00
|
|
|
|
2015-12-04 04:09:01 +03:00
|
|
|
constructor() {
|
2015-12-23 19:31:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
initializeDemos() {
|
2015-12-04 17:53:46 +03:00
|
|
|
// Tooltip and popover demos
|
|
|
|
$('.tooltip-demo').tooltip({
|
|
|
|
selector: '[data-toggle="tooltip"]',
|
|
|
|
container: 'body'
|
|
|
|
})
|
|
|
|
|
|
|
|
$('[data-toggle="popover"]').popover()
|
|
|
|
|
|
|
|
// Demos within modals
|
|
|
|
$('.tooltip-test').tooltip()
|
|
|
|
$('.popover-test').popover()
|
|
|
|
|
|
|
|
// Indeterminate checkbox example
|
|
|
|
$('.bd-example-indeterminate [type="checkbox"]').prop('indeterminate', true)
|
|
|
|
|
|
|
|
// Disable empty links in docs examples
|
2016-01-22 22:43:44 +03:00
|
|
|
$('.bd-example [href="#"]').click((e) => {
|
2015-12-04 17:53:46 +03:00
|
|
|
e.preventDefault()
|
|
|
|
})
|
2015-12-24 01:25:04 +03:00
|
|
|
|
|
|
|
// Insert copy to clipboard button before .highlight
|
2015-12-24 02:53:20 +03:00
|
|
|
$('.highlight').each(function () {
|
2015-12-24 01:45:54 +03:00
|
|
|
let btnHtml = '<div class="bd-clipboard"><span class="btn-clipboard" title="Copy to clipboard">Copy</span></div>'
|
2015-12-24 01:25:04 +03:00
|
|
|
$(this).before(btnHtml)
|
|
|
|
$('.btn-clipboard').tooltip()
|
|
|
|
})
|
|
|
|
|
2015-12-24 01:45:54 +03:00
|
|
|
let clipboard = new Clipboard('.btn-clipboard', {
|
|
|
|
target: (trigger) => {
|
2015-12-24 01:25:04 +03:00
|
|
|
return trigger.parentNode.nextElementSibling
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-24 01:45:54 +03:00
|
|
|
clipboard.on('success', (e) => {
|
2015-12-24 01:25:04 +03:00
|
|
|
$(e.trigger)
|
|
|
|
.attr('title', 'Copied!')
|
|
|
|
.tooltip('_fixTitle')
|
|
|
|
.tooltip('show')
|
|
|
|
.attr('title', 'Copy to clipboard')
|
|
|
|
.tooltip('_fixTitle')
|
|
|
|
|
|
|
|
e.clearSelection()
|
|
|
|
})
|
|
|
|
|
2015-12-24 01:45:54 +03:00
|
|
|
clipboard.on('error', (e) => {
|
|
|
|
let fallbackMsg = /Mac/i.test(navigator.userAgent) ? 'Press \u2318 to copy' : 'Press Ctrl-C to copy'
|
2015-12-24 01:25:04 +03:00
|
|
|
|
|
|
|
$(e.trigger)
|
|
|
|
.attr('title', fallbackMsg)
|
|
|
|
.tooltip('_fixTitle')
|
|
|
|
.tooltip('show')
|
|
|
|
.attr('title', 'Copy to clipboard')
|
|
|
|
.tooltip('_fixTitle')
|
|
|
|
})
|
2015-12-24 20:06:02 +03:00
|
|
|
|
|
|
|
anchors.options.placement = 'left' // eslint-disable-line no-console
|
|
|
|
anchors.add('.bd-content > h1, .bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
|
2015-12-04 04:09:01 +03:00
|
|
|
}
|
2015-11-20 00:58:21 +03:00
|
|
|
|
2015-12-23 19:31:49 +03:00
|
|
|
// Add dynamic display of font properties to the existing documentation
|
2015-12-04 04:09:01 +03:00
|
|
|
displayTypographyProperties() {
|
2015-12-23 19:31:49 +03:00
|
|
|
// headings
|
2015-12-04 19:06:09 +03:00
|
|
|
Style.displayFontSizeWeightColor($('.bd-example-type td > *:not(.type-info)'), ($element, $text) => {
|
|
|
|
let $target = $element.closest('tr').find('td.type-info')
|
|
|
|
$target.text('')
|
|
|
|
$target.append($text)
|
|
|
|
}, false, true)
|
|
|
|
|
|
|
|
|
|
|
|
// display headings
|
|
|
|
Style.displayFontSizeWeightColor($('h2#display-headings').next().next().find('h1'), ($element, $text) => {
|
|
|
|
let $tr = $element.closest('tr')
|
|
|
|
let $td = $(`<td class="type-info">`)
|
|
|
|
$tr.append($td)
|
|
|
|
$td.append($text)
|
|
|
|
|
|
|
|
}, false, true)
|
|
|
|
|
|
|
|
// lead headings
|
|
|
|
Style.displayFontSizeWeightColor($('h2#lead').next().next().find('p'), ($element, $text) => {
|
|
|
|
$element.append($text)
|
|
|
|
|
|
|
|
}, false, true)
|
|
|
|
|
|
|
|
// inline text elements
|
|
|
|
Style.displayFontSizeWeightColor($(`p:contains(Styling for common inline HTML5 elements.)`).next().find('p > *'), ($element, $text) => {
|
|
|
|
|
|
|
|
let $p = $element.parent()
|
|
|
|
let $parent = $p.parent()
|
|
|
|
$p.detach()
|
|
|
|
|
|
|
|
// create a row with two columns to display the text properties
|
|
|
|
let $row = $(`<div class='row'></div>`)
|
|
|
|
$parent.append($row)
|
|
|
|
|
2015-12-23 19:31:49 +03:00
|
|
|
let $col = $(`<div class='col-sm-8'></div>`)
|
2015-12-04 19:06:09 +03:00
|
|
|
$col.append($p)
|
|
|
|
$row.append($col)
|
|
|
|
|
2015-12-23 19:31:49 +03:00
|
|
|
$col = $(`<div class='col-sm-4'></div>`)
|
2015-12-04 19:06:09 +03:00
|
|
|
$col.append($text)
|
|
|
|
$row.append($col)
|
|
|
|
}, false, true)
|
2015-12-04 04:09:01 +03:00
|
|
|
}
|
2015-12-04 17:53:46 +03:00
|
|
|
|
2015-12-04 04:09:01 +03:00
|
|
|
}
|
2015-11-26 01:01:18 +03:00
|
|
|
|
2015-12-04 04:09:01 +03:00
|
|
|
$(() => {
|
|
|
|
let app = new Application()
|
|
|
|
app.displayTypographyProperties()
|
2015-12-17 02:34:46 +03:00
|
|
|
$('.btn-clipboard').mdbRipples()
|
|
|
|
|
2015-12-06 06:24:05 +03:00
|
|
|
// FIXME: file inputs seems to be in flux, delete the offending one for now.
|
|
|
|
$('#exampleInputFile').closest('.form-group').detach()
|
|
|
|
|
2015-12-04 19:06:09 +03:00
|
|
|
$('body').bootstrapMaterialDesign()
|
2015-12-23 19:31:49 +03:00
|
|
|
|
|
|
|
app.initializeDemos()
|
2015-12-04 04:09:01 +03:00
|
|
|
})
|