MCPcopy Create free account
hub / github.com/JsAaron/jQuery / augmentWidthOrHeight

Function augmentWidthOrHeight

2.0.3/Css.js:345–382  ·  view source on GitHub ↗
(elem, name, extra, isBorderBox, styles)

Source from the content-addressed store, hash-verified

343 }
344
345 function augmentWidthOrHeight(elem, name, extra, isBorderBox, styles) {
346 var i = extra === (isBorderBox ? "border" : "content") ?
347 // If we already have the right measurement, avoid augmentation
348 4 :
349 // Otherwise initialize for horizontal or vertical properties
350 name === "width" ? 1 : 0,
351
352 val = 0;
353
354 for (; i < 4; i += 2) {
355 // both box models exclude margin, so add it if we want it
356 if (extra === "margin") {
357 val += jQuery.css(elem, extra + cssExpand[i], true, styles);
358 }
359
360 if (isBorderBox) {
361 // border-box includes padding, so remove it if we want content
362 if (extra === "content") {
363 val -= jQuery.css(elem, "padding" + cssExpand[i], true, styles);
364 }
365
366 // at this point, extra isn't border nor margin, so remove border
367 if (extra !== "margin") {
368 val -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
369 }
370 } else {
371 // at this point, extra isn't content, so add padding
372 val += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
373
374 // at this point, extra isn't content nor padding, so add border
375 if (extra !== "padding") {
376 val += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
377 }
378 }
379 }
380
381 return val;
382 }
383
384 function getWidthOrHeight(elem, name, extra) {
385

Callers 2

getWidthOrHeightFunction · 0.70
Css.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected