Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(gridlist): update calcs for safari
Browse files Browse the repository at this point in the history
StyleString was too big for safari to parse when appending with innerHTML
Fixed typo in Grid list in safari

Closes #2066.
  • Loading branch information
JulianWielga authored and ThomasBurleson committed Apr 4, 2015
1 parent ff794ec commit 33049cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/components/gridList/gridList.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function GridListDirective($interpolate, $mdConstant, $mdGridLayout, $mdMedia) {
// The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
// The position comes the size of a 1x1 tile plus gutter for each previous tile in the
// row/column (offset).
var POSITION = $interpolate('calc( ( ({{unit}}) + {{gutter}} ) * {{offset}} ');
var POSITION = $interpolate('calc( ( {{unit}} + {{gutter}} ) * {{offset}} )');

// The actual size of a tile, e.g., width or height, taking rowSpan or colSpan into account.
// This is computed by multiplying the base unit by the rowSpan/colSpan, and then adding back
Expand Down
38 changes: 22 additions & 16 deletions src/core/services/theming/theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function ThemableDirective($mdTheming) {
return $mdTheming;
}

function parseRules(theme, colorType, rules) {
function _parseRules(theme, colorType, rules) {
checkValidPalette(theme, colorType);

rules = rules.replace(/THEME_NAME/g, theme.name);
Expand Down Expand Up @@ -402,7 +402,11 @@ function parseRules(theme, colorType, rules) {
generatedRules.push(newRule);
});

return generatedRules.join('');
return generatedRules;
}

function parseRules(theme, colorType, rules) {
return _parseRules(theme, colorType, rules).join('');
}

// Generate our themes at run time given the state of THEMES and PALETTES
Expand Down Expand Up @@ -448,29 +452,31 @@ function generateThemes($injector) {
return rulesByType[DEFAULT_COLOR_TYPE] += rule;
});

var styleString = '';

// For each theme, use the color palettes specified for `primary`, `warn` and `accent`
// to generate CSS rules.
angular.forEach(THEMES, function(theme) {
THEME_COLOR_TYPES.forEach(function(colorType) {
styleString += parseRules(theme, colorType, rulesByType[colorType] + '');
});
// Insert our newly minted styles into the DOM
if (!generationIsDone) {
var head = document.getElementsByTagName('head')[0];
var headFirstElementChild = head.firstElementChild;
THEME_COLOR_TYPES.forEach(function(colorType) {
var styleStrings = _parseRules(theme, colorType, rulesByType[colorType]);
while(styleStrings.length) {
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.appendChild(document.createTextNode(styleStrings.shift()));
head.insertBefore(style, headFirstElementChild);
}
});
generationIsDone = true;
}

if (theme.colors.primary.name == theme.colors.accent.name) {
console.warn("$mdThemingProvider: Using the same palette for primary and" +
" accent. This violates the material design spec.");
}
});

// Insert our newly minted styles into the DOM
if (!generationIsDone) {
var style = document.createElement('style');
style.innerHTML = styleString;
var head = document.getElementsByTagName('head')[0];
head.insertBefore(style, head.firstElementChild);
generationIsDone = true;
}

// The user specifies a 'default' contrast color as either light or dark,
// then explicitly lists which hues are the opposite contrast (eg. A100 has dark, A200 has light)
function sanitizePalette(palette) {
Expand Down

2 comments on commit 33049cf

@hodeyp
Copy link

@hodeyp hodeyp commented on 33049cf Apr 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit has broken defining custom themes. Any custom theme I have defined is no longer created. I have reverted this commit in my fork and themes work again.

@ThomasBurleson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hodeyp - we are investigating. Thx.

Please sign in to comment.