diff --git a/scripts/htmlDependencies.R b/scripts/htmlDependencies.R index 4b7eeb97c0..5c5d744505 100755 --- a/scripts/htmlDependencies.R +++ b/scripts/htmlDependencies.R @@ -30,14 +30,4 @@ withr::with_options( lapply(deps, copyDependencyToDir, "shiny/www/shared") ) -# For JSX based nav() implementation -bslib <- file.path(www, "shared", "bslib") -dir.create(bslib) -withr::with_tempdir({ - cmd <- paste("git clone --depth 1 --branch jsx https://github.com/rstudio/bslib") - system(cmd) - file.copy( - "bslib/inst/navs/dist", - bslib, recursive = TRUE - ) -}) +unlink("shiny/www/shared/bs3compat/", recursive = TRUE) diff --git a/shiny/ui/_html_dependencies.py b/shiny/ui/_html_dependencies.py index 44bdc43594..f10d030ea0 100644 --- a/shiny/ui/_html_dependencies.py +++ b/shiny/ui/_html_dependencies.py @@ -5,7 +5,7 @@ from ..html_dependencies import jquery_deps -def bootstrap_deps(bs3compat: bool = True) -> List[HTMLDependency]: +def bootstrap_deps() -> List[HTMLDependency]: dep = HTMLDependency( name="bootstrap", version="5.0.1", @@ -14,21 +14,9 @@ def bootstrap_deps(bs3compat: bool = True) -> List[HTMLDependency]: stylesheet={"href": "bootstrap.min.css"}, ) deps = [jquery_deps(), dep] - if bs3compat: - deps.append(bs3compat_deps()) return deps -# TODO: if we want to support glyphicons we'll need to bundle font files, too -def bs3compat_deps() -> HTMLDependency: - return HTMLDependency( - name="bs3-compat", - version="1.0", - source={"package": "shiny", "subdir": "www/shared/bs3compat/"}, - script=[{"src": "transition.js"}, {"src": "tabs.js"}, {"src": "bs3compat.js"}], - ) - - def ionrangeslider_deps() -> List[HTMLDependency]: return [ HTMLDependency( diff --git a/shiny/www/shared/bs3compat/bs3compat.js b/shiny/www/shared/bs3compat/bs3compat.js deleted file mode 100644 index 4f029dc712..0000000000 --- a/shiny/www/shared/bs3compat/bs3compat.js +++ /dev/null @@ -1,48 +0,0 @@ -// Inform the world that we have the ability to use BS3 nav/navbar markup in BS4 -window.BS3_COMPAT = true; - -// This logic needs to execute after both the BS4+ (new) as well as BS3 (legacy) -// jQuery plugins have been registered. For BS5, plugin registration happens -// after DOM content is loaded, which is why we do the same here. -// https://github.com/twbs/bootstrap/blob/08139c22/js/dist/tab.js#L87 -$(function() { - - // The legacy plugin needs to be registered after the new one - if (!$.fn.tab.Constructor.VERSION.match(/^3\./)) { - (console.warn || console.error || console.log)("bs3compat.js couldn't find bs3 tab impl; bs3 tabs will not be properly supported"); - return; - } - var legacyTabPlugin = $.fn.tab.noConflict(); - - if (!$.fn.tab || !$.fn.tab.Constructor || !$.fn.tab.noConflict) { - (console.warn || console.error || console.log)("bs3compat.js couldn't find a jQuery tab impl; bs3 tabs will not be properly supported"); - } - var newTabPlugin = $.fn.tab.noConflict(); - - // Re-define the tab click event - // https://github.com/twbs/bootstrap/blob/08139c2/js/src/tab.js#L33 - var EVENT_KEY = "click.bs.tab.data-api"; - $(document).off(EVENT_KEY); - - var SELECTOR = '[data-toggle="tab"], [data-toggle="pill"], [data-bs-toggle="tab"], [data-bs-toggle="pill"]'; - $(document).on(EVENT_KEY, SELECTOR, function(event) { - event.preventDefault(); - $(this).tab("show"); - }); - - function TabPlugin(config) { - // Legacy (bs3) tabs: li.active > a - // New (bs4+) tabs: li.nav-item > a.active.nav-link - var legacy = $(this).closest(".nav").find("li:not(.dropdown).active > a").length > 0; - var plugin = legacy ? legacyTabPlugin : newTabPlugin; - plugin.call($(this), config); - } - - var noconflict = $.fn.tab; - $.fn.tab = TabPlugin; - $.fn.tab.Constructor = newTabPlugin.Constructor; - $.fn.tab.noConflict = function() { - $.fn.tab = noconflict; - return TabPlugin; - }; -}); diff --git a/shiny/www/shared/bs3compat/tabs.js b/shiny/www/shared/bs3compat/tabs.js deleted file mode 100644 index 79825cce3e..0000000000 --- a/shiny/www/shared/bs3compat/tabs.js +++ /dev/null @@ -1,157 +0,0 @@ -/* ======================================================================== - * Bootstrap: tab.js v3.4.1 - * https://getbootstrap.com/docs/3.4/javascript/#tabs - * ======================================================================== - * Copyright 2011-2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== */ - -// Register tab plugin after DOM content loaded in order to -// override BS5's plugin -// https://github.com/twbs/bootstrap/blob/08139c22/js/dist/tab.js#L87 -$(function() { - 'use strict'; - - // TAB CLASS DEFINITION - // ==================== - - var Tab = function (element) { - // jscs:disable requireDollarBeforejQueryAssignment - this.element = $(element) - // jscs:enable requireDollarBeforejQueryAssignment - } - - Tab.VERSION = '3.4.1' - - Tab.TRANSITION_DURATION = 150 - - Tab.prototype.show = function () { - var $this = this.element - var $ul = $this.closest('ul:not(.dropdown-menu)') - var selector = $this.data('target') - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 - } - - if ($this.parent('li').hasClass('active')) return - - var $previous = $ul.find('.active:last a') - var hideEvent = $.Event('hide.bs.tab', { - relatedTarget: $this[0] - }) - var showEvent = $.Event('show.bs.tab', { - relatedTarget: $previous[0] - }) - - $previous.trigger(hideEvent) - $this.trigger(showEvent) - - if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return - - var $target = $(document).find(selector) - - this.activate($this.closest('li'), $ul) - this.activate($target, $target.parent(), function () { - $previous.trigger({ - type: 'hidden.bs.tab', - relatedTarget: $this[0] - }) - $this.trigger({ - type: 'shown.bs.tab', - relatedTarget: $previous[0] - }) - }) - } - - Tab.prototype.activate = function (element, container, callback) { - var $active = container.find('> .active') - var transition = callback - && $.support.transition - && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length) - - function next() { - $active - .removeClass('active') - .find('> .dropdown-menu > .active') - .removeClass('active') - .end() - .find('[data-toggle="tab"]') - .attr('aria-expanded', false) - - element - .addClass('active') - .find('[data-toggle="tab"]') - .attr('aria-expanded', true) - - if (transition) { - element[0].offsetWidth // reflow for transition - element.addClass('in') - } else { - element.removeClass('fade') - } - - if (element.parent('.dropdown-menu').length) { - element - .closest('li.dropdown') - .addClass('active') - .end() - .find('[data-toggle="tab"]') - .attr('aria-expanded', true) - } - - callback && callback() - } - - $active.length && transition ? - $active - .one('bsTransitionEnd', next) - .emulateTransitionEnd(Tab.TRANSITION_DURATION) : - next() - - $active.removeClass('in') - } - - - // TAB PLUGIN DEFINITION - // ===================== - - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.tab') - - if (!data) $this.data('bs.tab', (data = new Tab(this))) - if (typeof option == 'string') data[option]() - }) - } - - var old = $.fn.tab - - $.fn.tab = Plugin - $.fn.tab.Constructor = Tab - - - // TAB NO CONFLICT - // =============== - - $.fn.tab.noConflict = function () { - $.fn.tab = old - return this - } - - - // TAB DATA-API - // ============ - - var clickHandler = function (e) { - e.preventDefault() - Plugin.call($(this), 'show') - } - - $(document) - .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler) - .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler) - -}); diff --git a/shiny/www/shared/bs3compat/transition.js b/shiny/www/shared/bs3compat/transition.js deleted file mode 100644 index 81e7122c20..0000000000 --- a/shiny/www/shared/bs3compat/transition.js +++ /dev/null @@ -1,59 +0,0 @@ -/* ======================================================================== - * Bootstrap: transition.js v3.4.1 - * https://getbootstrap.com/docs/3.4/javascript/#transitions - * ======================================================================== - * Copyright 2011-2019 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/v3-dev/LICENSE) - * ======================================================================== */ - - -+function ($) { - 'use strict'; - - // CSS TRANSITION SUPPORT (Shoutout: https://modernizr.com/) - // ============================================================ - - function transitionEnd() { - var el = document.createElement('bootstrap') - - var transEndEventNames = { - WebkitTransition : 'webkitTransitionEnd', - MozTransition : 'transitionend', - OTransition : 'oTransitionEnd otransitionend', - transition : 'transitionend' - } - - for (var name in transEndEventNames) { - if (el.style[name] !== undefined) { - return { end: transEndEventNames[name] } - } - } - - return false // explicit for ie8 ( ._.) - } - - // https://blog.alexmaccaw.com/css-transitions - $.fn.emulateTransitionEnd = function (duration) { - var called = false - var $el = this - $(this).one('bsTransitionEnd', function () { called = true }) - var callback = function () { if (!called) $($el).trigger($.support.transition.end) } - setTimeout(callback, duration) - return this - } - - $(function () { - $.support.transition = transitionEnd() - - if (!$.support.transition) return - - $.event.special.bsTransitionEnd = { - bindType: $.support.transition.end, - delegateType: $.support.transition.end, - handle: function (e) { - if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) - } - } - }) - -}(jQuery);