MCPcopy
hub / github.com/hakimel/Ladda / createSpinner

Function createSpinner

js/ladda.js:222–269  ·  view source on GitHub ↗
(button)

Source from the content-addressed store, hash-verified

220}
221
222function createSpinner(button) {
223 var height = button.offsetHeight,
224 spinnerColor,
225 spinnerLines;
226
227 if (height === 0) {
228 // We may have an element that is not visible so
229 // we attempt to get the height in a different way
230 height = parseFloat(window.getComputedStyle(button).height);
231 }
232
233 // If the button is tall we can afford some padding
234 if (height > 32) {
235 height *= 0.8;
236 }
237
238 // Prefer an explicit height if one is defined
239 if (button.hasAttribute('data-spinner-size')) {
240 height = parseInt(button.getAttribute('data-spinner-size'), 10);
241 }
242
243 // Allow buttons to specify the color of the spinner element
244 if (button.hasAttribute('data-spinner-color')) {
245 spinnerColor = button.getAttribute('data-spinner-color');
246 }
247
248 // Allow buttons to specify the number of lines of the spinner
249 if (button.hasAttribute('data-spinner-lines')) {
250 spinnerLines = parseInt(button.getAttribute('data-spinner-lines'), 10);
251 }
252
253 var radius = height * 0.2,
254 length = radius * 0.6,
255 width = radius < 7 ? 2 : 3;
256
257 return new Spinner({
258 color: spinnerColor || '#fff',
259 lines: spinnerLines || 12,
260 radius: radius,
261 length: length,
262 width: width,
263 animation: 'ladda-spinner-line-fade',
264 zIndex: 'auto',
265 top: 'auto',
266 left: 'auto',
267 className: ''
268 });
269}
270
271function wrapContent(node, wrapper) {
272 var r = document.createRange();

Callers 1

createFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…