/usr/lib/R/site-library/shinydashboard/shinydashboard.js is in r-cran-shinydashboard 0.6.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | //---------------------------------------------------------------------
// Source file: ../srcjs/_start.js
$(function() {
//---------------------------------------------------------------------
// Source file: ../srcjs/tabs.js
// This function handles a special case in the AdminLTE sidebar: when there
// is a sidebar-menu with items, and one of those items has sub-items, and
// they are used for tab navigation. Normally, if one of the items is
// selected and then a sub-item is clicked, both the item and sub-item will
// retain the "active" class, so they will both be highlighted. This happens
// because they're not designed to be used together for tab panels. This
// code ensures that only one item will have the "active" class.
var deactivateOtherTabs = function() {
// Find all tab links under sidebar-menu even if they don't have a
// tabName (which is why the second selector is necessary)
var $tablinks = $(".sidebar-menu a[data-toggle='tab']," +
".sidebar-menu li.treeview > a");
// If any other items are active, deactivate them
$tablinks.not($(this)).parent("li").removeClass("active");
// Trigger event for the tabItemInputBinding
var $obj = $('.sidebarMenuSelectedTabItem');
var inputBinding = $obj.data('shiny-input-binding');
if (typeof inputBinding !== 'undefined') {
inputBinding.setValue($obj, $(this).attr('data-value'));
$obj.trigger('change');
}
};
$(document).on('shown.bs.tab', '.sidebar-menu a[data-toggle="tab"]',
deactivateOtherTabs);
// When document is ready, if there is a sidebar menu with no activated tabs,
// activate the one specified by `data-start-selected`, or if that's not
// present, the first one.
var ensureActivatedTab = function() {
var $tablinks = $(".sidebar-menu a[data-toggle='tab']");
// If there's a `data-start-selected` attribute and we can find a tab with
// that name, activate it.
var $startTab = $tablinks.filter("[data-start-selected='1']");
if ($startTab.length === 0) {
// If no tab starts selected, use the first one, if present
$startTab = $tablinks.first();
}
// If there are no tabs, $startTab.length will be 0.
if ($startTab.length !== 0) {
$startTab.tab("show");
// This is indirectly setting the value of the Shiny input by setting
// an attribute on the html element it is bound to. We cannot use the
// inputBinding's setValue() method here because this is called too
// early (before Shiny has fully initialized)
$(".sidebarMenuSelectedTabItem").attr("data-value",
$startTab.attr("data-value"));
}
};
ensureActivatedTab();
//---------------------------------------------------------------------
// Source file: ../srcjs/sidebar.js
// Optionally disable sidebar (set through the `disable` argument
// to the `dashboardSidebar` function)
if ($("section.sidebar").data("disable")) {
$("body").addClass("sidebar-collapse");
$(".navbar > .sidebar-toggle").hide();
}
// Get the correct value for `input$sidebarCollapsed`, depending on
// whether or not the left offset on the sidebar is negative (hidden
// - so `input$sidebarCollapsed` should be TRUE) or 0 (shown - so
// `input$sidebarCollapsed` should be FALSE). That we know of,
// `$(".main-sidebar").is(":visible")` is always true, so there is
// no need to check for that.
var sidebarCollapsedValue = function() {
if ($(".main-sidebar").offset().left < 0) return(true);
else return(false);
};
// Whenever the sidebar changes from collapsed to expanded and vice versa,
// call this function, so that we can trigger the resize event on the rest
// of the window and also update the value for the sidebar's input binding.
var sidebarChange = function() {
// 1) Trigger the resize event (so images are responsive and resize)
$(window).trigger("resize");
// 2) Update the value for the sidebar's input binding
var $obj = $('.main-sidebar.shiny-bound-input');
var inputBinding = $obj.data('shiny-input-binding');
inputBinding.setValue($obj, sidebarCollapsedValue());
$obj.trigger('change');
};
// Whenever the sidebar finishes a transition (which it does every time it
// changes from collapsed to expanded and vice versa), call sidebarChange()
$(".main-sidebar").on(
'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
sidebarChange);
// This fixes an edge case: when the app starts up with the sidebar already
// collapsed (either because the screen is small or because
// `dashboardSidebar(disable = TRUE`), make sure that `input$sidebarCollapsed`
// is set to `FALSE`. Whenever this is the case, `$(".main-sidebar").offset().left`
// is negative. That we know of, `$(".main-sidebar").is(":visible")` is always
// true, so there is no need to check for that.
if ($(".main-sidebar").offset().left < 0) {
// This is indirectly setting the value of the Shiny input by setting
// an attribute on the html element it is bound to. We cannot use the
// inputBinding's setValue() method here because this is called too
// early (before Shiny has fully initialized)
$(".main-sidebar").attr("data-collapsed", "true");
}
// Whenever we expand a menuItem (to be expandable, it must have children),
// update the value for the expandedItem's input binding (this is the
// tabName of the fist subMenuItem inside the menuItem that is currently
// expanded)
$(document).on("click", ".treeview > a", function() {
var $menu = $(this).next();
// If this menuItem was already open, then clicking on it again,
// should trigger the "hidden" event, so Shiny doesn't worry about
// it while it's hidden (and vice versa).
if ($menu.hasClass("menu-open")) $menu.trigger("hidden");
else if ($menu.hasClass("treeview-menu")) $menu.trigger("shown");
// need to set timeout to account for the slideUp/slideDown animation
var $obj = $('section.sidebar.shiny-bound-input');
setTimeout(function() { $obj.trigger('change'); }, 600);
});
//---------------------------------------------------------------------
// Source file: ../srcjs/output_binding_menu.js
/* global Shiny */
// menuOutputBinding
// ------------------------------------------------------------------
// Based on Shiny.htmlOutputBinding, but instead of putting the result in a
// wrapper div, it replaces the origin DOM element with the new DOM elements,
// copying over the ID and class.
var menuOutputBinding = new Shiny.OutputBinding();
$.extend(menuOutputBinding, {
find: function(scope) {
return $(scope).find('.shinydashboard-menu-output');
},
onValueError: function(el, err) {
Shiny.unbindAll(el);
this.renderError(el, err);
},
renderValue: function(el, data) {
Shiny.unbindAll(el);
var html;
var dependencies = [];
if (data === null) {
return;
} else if (typeof(data) === 'string') {
html = data;
} else if (typeof(data) === 'object') {
html = data.html;
dependencies = data.deps;
}
var $html = $($.parseHTML(html));
// Convert the inner contents to HTML, and pass to renderHtml
Shiny.renderHtml($html.html(), el, dependencies);
// Extract class of wrapper, and add them to the wrapper element
el.className = 'shinydashboard-menu-output shiny-bound-output ' +
$html.attr('class');
Shiny.initializeInputs(el);
Shiny.bindAll(el);
ensureActivatedTab(); // eslint-disable-line
}
});
Shiny.outputBindings.register(menuOutputBinding,
"shinydashboard.menuOutputBinding");
//---------------------------------------------------------------------
// Source file: ../srcjs/input_binding_tabItem.js
/* global Shiny */
// tabItemInputBinding
// ------------------------------------------------------------------
// Based on Shiny.tabItemInputBinding, but customized for tabItems in
// shinydashboard, which have a slightly different structure.
var tabItemInputBinding = new Shiny.InputBinding();
$.extend(tabItemInputBinding, {
find: function(scope) {
return $(scope).find('.sidebarMenuSelectedTabItem');
},
getValue: function(el) {
var value = $(el).attr('data-value');
if (value === "null") return null;
return value;
},
setValue: function(el, value) {
var self = this;
var anchors = $(el).parent('ul.sidebar-menu').find('li:not(.treeview)').children('a');
anchors.each(function() { // eslint-disable-line consistent-return
if (self._getTabName($(this)) === value) {
$(this).tab('show');
$(el).attr('data-value', self._getTabName($(this)));
return false;
}
});
},
receiveMessage: function(el, data) {
if (data.hasOwnProperty('value'))
this.setValue(el, data.value);
},
subscribe: function(el, callback) {
// This event is triggered by deactivateOtherTabs, which is triggered by
// shown. The deactivation of other tabs must occur before Shiny gets the
// input value.
$(el).on('change.tabItemInputBinding', function() {
callback();
});
},
unsubscribe: function(el) {
$(el).off('.tabItemInputBinding');
},
_getTabName: function(anchor) {
return anchor.attr('data-value');
}
});
Shiny.inputBindings.register(tabItemInputBinding, 'shinydashboard.tabItemInput');
//---------------------------------------------------------------------
// Source file: ../srcjs/input_binding_sidebarCollapsed.js
/* global Shiny */
// sidebarCollapsedInputBinding
// ------------------------------------------------------------------
// This keeps tracks of whether the sidebar is expanded (default)
// or collapsed
var sidebarCollapsedInputBinding = new Shiny.InputBinding();
$.extend(sidebarCollapsedInputBinding, {
find: function(scope) {
return $(scope).find('.main-sidebar').first();
},
getId: function(el) {
return "sidebarCollapsed";
},
getValue: function(el) {
return $(el).attr("data-collapsed") === "true";
},
setValue: function(el, value) {
$(el).attr("data-collapsed", value);
},
toggleValue: function(el) {
var current = this.getValue(el);
var newVal = current ? "false" : "true";
this.setValue(el, newVal);
},
receiveMessage: function(el, data) {
if (data.hasOwnProperty('value'))
this.setValue(el, data.value);
},
subscribe: function(el, callback) {
$(el).on('change.sidebarCollapsedInputBinding', function() {
callback();
});
},
unsubscribe: function(el) {
$(el).off('.sidebarCollapsedInputBinding');
}
});
Shiny.inputBindings.register(sidebarCollapsedInputBinding,
'shinydashboard.sidebarCollapsedInputBinding');
//---------------------------------------------------------------------
// Source file: ../srcjs/input_binding_sidebarmenuExpanded.js
/* global Shiny */
// sidebarmenuExpandedInputBinding
// ------------------------------------------------------------------
// This keeps tracks of what menuItem (if any) is expanded
var sidebarmenuExpandedInputBinding = new Shiny.InputBinding();
$.extend(sidebarmenuExpandedInputBinding, {
find: function(scope) {
return $(scope).find('section.sidebar');
},
getId: function(el) {
return "sidebarItemExpanded";
},
getValue: function(el) {
var $open = $(el).find('li ul.menu-open');
if ($open.length === 1) return $open.attr('data-expanded');
else return null;
},
subscribe: function(el, callback) {
$(el).on('change.sidebarmenuExpandedInputBinding', function() {
callback();
});
},
unsubscribe: function(el) {
$(el).off('.sidebarmenuExpandedInputBinding');
}
});
Shiny.inputBindings.register(sidebarmenuExpandedInputBinding,
'shinydashboard.sidebarmenuExpandedInputBinding');
//---------------------------------------------------------------------
// Source file: ../srcjs/_end.js
});
//# sourceMappingURL=shinydashboard.js.map
|