From b06051e17994e018f103ade1dc3f750cdbb3fe24 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Fri, 4 Dec 2015 08:53:46 -0600 Subject: [PATCH] added bootstrap docs sync for scss (with the exception of docs.scss which is customized). Moved the rest of application to the es6 class for uniformity --- .gitignore | 2 + Gruntfile.js | 13 +++- docs/assets/js/src/application.js | 60 +++++++++++++++- docs/assets/js/src/old/old_application.js | 83 ----------------------- docs/assets/scss/.READONLY-MOSTLY.txt | 6 ++ docs/assets/scss/_ads.scss | 2 +- docs/assets/scss/_nav.scss | 2 +- docs/assets/scss/docs.scss | 2 + 8 files changed, 83 insertions(+), 87 deletions(-) delete mode 100644 docs/assets/js/src/old/old_application.js create mode 100644 docs/assets/scss/.READONLY-MOSTLY.txt diff --git a/.gitignore b/.gitignore index c95dfeab..5cb949a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # temp during major v4 development - tired of these showing up ready to commit dist/**/* + +# Ignore docs dist files docs/dist/**/* docs/assets/css/* docs/assets/js/dist/* diff --git a/Gruntfile.js b/Gruntfile.js index 89366158..0fca1a7a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -340,6 +340,15 @@ module.exports = function (grunt) { ], dest: 'docs/dist/' }, + 'bs-docs-scss': { + expand: true, + cwd: '../bootstrap/docs/assets/scss', + src: [ + '**/*', + '!docs.scss' // keep variable customizations + ], + dest: 'docs/assets/scss/' + }, 'bs-docs-components': { expand: true, cwd: '../bootstrap/docs/components', @@ -572,7 +581,9 @@ module.exports = function (grunt) { grunt.registerTask('docs-css', ['sass:docs', 'postcss:docs', 'postcss:examples', 'csscomb:docs', 'csscomb:examples', 'cssmin:docs']); grunt.registerTask('docs-js', ['babel:docs', 'uglify:docsJs']); grunt.registerTask('lint-docs-js', ['jscs:assets']); - grunt.registerTask('docs', ['copy:bs-docs-components', 'copy:bs-docs-content', 'docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs']); + grunt.registerTask('docs-copy-bootstrap', ['copy:bs-docs-scss', 'copy:bs-docs-components', 'copy:bs-docs-content']); + + grunt.registerTask('docs', ['docs-copy-bootstrap', 'docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs']); grunt.registerTask('prep-release', ['dist', 'docs', 'jekyll:github', 'htmlmin', 'compress']); diff --git a/docs/assets/js/src/application.js b/docs/assets/js/src/application.js index 315ca27c..48bc54a1 100644 --- a/docs/assets/js/src/application.js +++ b/docs/assets/js/src/application.js @@ -1,8 +1,29 @@ import Style from './style' +import Clipboard from 'clipboard' class Application { constructor() { + + // 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 + $('.bd-example [href=#]').click((e) => { + e.preventDefault() + }) } displayTypographyProperties() { @@ -10,12 +31,49 @@ class Application { return $element.closest('tr').find('td.type-info') }) } + + clipboard() { + // Insert copy to clipboard button before .highlight + $('.highlight').each(function () { + let btnHtml = '
Copy
' + $(this).before(btnHtml) + $('.btn-clipboard').tooltip() + }) + + let clipboard = new Clipboard('.btn-clipboard', { + target: (trigger) => { + return trigger.parentNode.nextElementSibling + } + }) + + clipboard.on('success', (e) => { + $(e.triggerStart) + .attr('title', 'Copied!') + .tooltip('_fixTitle') + .tooltip('show') + .attr('title', 'Copy to clipboard') + .tooltip('_fixTitle') + + e.clearSelection() + }) + + clipboard.on('error', (e) => { + let fallbackMsg = /Mac/i.test(navigator.userAgent) ? 'Press \u2318 to copy' : 'Press Ctrl-C to copy' + + $(e.triggerStart) + .attr('title', fallbackMsg) + .tooltip('_fixTitle') + .tooltip('show') + .attr('title', 'Copy to clipboard') + .tooltip('_fixTitle') + }) + } } $(() => { let app = new Application() app.displayTypographyProperties() - + app.clipboard() // $.bootstrapMaterialDesign() }) diff --git a/docs/assets/js/src/old/old_application.js b/docs/assets/js/src/old/old_application.js deleted file mode 100644 index c0a34976..00000000 --- a/docs/assets/js/src/old/old_application.js +++ /dev/null @@ -1,83 +0,0 @@ -// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT -// IT'S ALL JUST JUNK FOR OUR DOCS! -// ++++++++++++++++++++++++++++++++++++++++++ - -/*! - * JavaScript for Bootstrap's docs (http://getbootstrap.com) - * Copyright 2011-2015 Twitter, Inc. - * Licensed under the Creative Commons Attribution 3.0 Unported License. For - * details, see https://creativecommons.org/licenses/by/3.0/. - */ - -/* global Clipboard, anchors */ - -!function ($) { - 'use strict'; - - $(function () { - - // 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 - $('.bd-example [href=#]').click(function (e) { - e.preventDefault() - }) - - // Insert copy to clipboard button before .highlight - $('.highlight').each(function () { - var btnHtml = '
Copy
' - $(this).before(btnHtml) - $('.btn-clipboard').tooltip() - }) - - var clipboard = new Clipboard('.btn-clipboard', { - target: function (trigger) { - return trigger.parentNode.nextElementSibling - } - }) - - clipboard.on('success', function (e) { - $(e.triggerStart) - .attr('title', 'Copied!') - .tooltip('_fixTitle') - .tooltip('show') - .attr('title', 'Copy to clipboard') - .tooltip('_fixTitle') - - e.clearSelection() - }) - - clipboard.on('error', function (e) { - var fallbackMsg = /Mac/i.test(navigator.userAgent) ? 'Press \u2318 to copy' : 'Press Ctrl-C to copy' - - $(e.triggerStart) - .attr('title', fallbackMsg) - .tooltip('_fixTitle') - .tooltip('show') - .attr('title', 'Copy to clipboard') - .tooltip('_fixTitle') - }) - - }) - -}(jQuery) - -;(function () { - 'use strict'; - - anchors.options.placement = 'left'; - anchors.add('.bd-content > h1, .bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5') -})(); diff --git a/docs/assets/scss/.READONLY-MOSTLY.txt b/docs/assets/scss/.READONLY-MOSTLY.txt new file mode 100644 index 00000000..8183bac9 --- /dev/null +++ b/docs/assets/scss/.READONLY-MOSTLY.txt @@ -0,0 +1,6 @@ +DO NOT edit files in this folder EXCEPT docs.scss. + +These files are copied using + grunt copy:bs-docs-scss + +This is done to keep samples in sync with the upstream bs4. diff --git a/docs/assets/scss/_ads.scss b/docs/assets/scss/_ads.scss index 4e9f3b4e..86422b87 100644 --- a/docs/assets/scss/_ads.scss +++ b/docs/assets/scss/_ads.scss @@ -13,7 +13,7 @@ line-height: 1rem !important; color: $bd-purple-light !important; text-align: left; - background-color: darken($bd-purple, 10%) !important; + background: darken($bd-purple, 10%) !important; border: 0 !important; } diff --git a/docs/assets/scss/_nav.scss b/docs/assets/scss/_nav.scss index bc1ab6cc..74610733 100644 --- a/docs/assets/scss/_nav.scss +++ b/docs/assets/scss/_nav.scss @@ -17,7 +17,7 @@ } &.active { - font-weight: 500; + color: darken($gray-dark, 25%); } } } diff --git a/docs/assets/scss/docs.scss b/docs/assets/scss/docs.scss index 280071cd..4e3dc73b 100644 --- a/docs/assets/scss/docs.scss +++ b/docs/assets/scss/docs.scss @@ -1,3 +1,5 @@ +// This is the only customized file in this directory. + /*! * Bootstrap Docs (http://getbootstrap.com) * Copyright 2011-2015 Twitter, Inc.