Skip to content

Commit 374b85b

Browse files
committed
Release v0.8.0-csp.1
Fixes some CSP issues. See yalabot/angular-foundation#310
1 parent f95d572 commit 374b85b

File tree

6 files changed

+70
-34
lines changed

6 files changed

+70
-34
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Pinecone, LLC"
44
},
55
"name": "angular-foundation",
6-
"version": "0.8.0",
6+
"version": "0.8.0-csp.1",
77
"main": ["./mm-foundation-tpls.js"],
88
"dependencies": {
99
"angular": ">=1.3.0"

mm-foundation-tpls.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* angular-mm-foundation
3-
* http://pineconellc.github.io/angular-foundation/
3+
* https://github.com/farrago/angular-foundation-bower
44
5-
* Version: 0.8.0 - 2015-10-13
5+
* Version: 0.8.0-csp.1 - 2016-08-25
66
* License: MIT
77
* (c) Pinecone, LLC
88
*/
@@ -958,14 +958,22 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
958958
restrict: 'EA',
959959
scope: {
960960
index: '@',
961-
animate: '='
961+
animate: '=',
962+
mmTop: '@'
962963
},
963964
replace: true,
964965
transclude: true,
965966
templateUrl: 'template/modal/window.html',
966967
link: function (scope, element, attrs) {
967968
scope.windowClass = attrs.windowClass || '';
968969

970+
// Set the `top` style using element.css to avoid Content Security Policy
971+
// issues when using inline-styles
972+
if (scope.mmTop) {
973+
element.css('top', scope.mmTop);
974+
element.css('visibility', 'visible');
975+
}
976+
969977
$timeout(function () {
970978
// trigger CSS transitions
971979
scope.animate = true;
@@ -1111,18 +1119,21 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11111119
}
11121120

11131121
// Create a faux modal div just to measure its
1114-
// distance to top
1115-
var faux = angular.element('<div class="reveal-modal" style="z-index:-1""></div>');
1122+
// distance to top. Note that we set the style using element.css()
1123+
// rather than using inline style="..." to avoid issue with Content Security Policy
1124+
var faux = angular.element('<div class="reveal-modal"></div>');
1125+
faux.css("z-index", "-1");
11161126
parent.append(faux[0]);
11171127
cssTop = parseInt($window.getComputedStyle(faux[0]).top) || 0;
11181128
var openAt = calculateModalTop(faux, cssTop);
11191129
faux.remove();
11201130

1121-
var angularDomEl = angular.element('<div modal-window style="visibility: visible; top:' + openAt +'px;"></div>')
1131+
var angularDomEl = angular.element('<div modal-window></div>')
11221132
.attr({
11231133
'window-class': modal.windowClass,
11241134
'index': openedWindows.length() - 1,
1125-
'animate': 'animate'
1135+
'animate': 'animate',
1136+
'mm-top': '' + openAt + 'px' // Pass the top position to modal-window directive
11261137
});
11271138
angularDomEl.html(modal.content);
11281139

@@ -2757,8 +2768,8 @@ angular.module("mm.foundation.topbar", ['mm.foundation.mediaQueries'])
27572768
angular.element($window).bind('scroll', onScroll);
27582769

27592770
scope.$on('$destroy', function() {
2760-
angular.element($window).unbind('scroll', onResize);
2761-
angular.element($window).unbind('resize', onScroll);
2771+
angular.element($window).unbind('resize', onResize);
2772+
angular.element($window).unbind('scroll', onScroll);
27622773
});
27632774

27642775
if (topbarContainer.hasClass('fixed')) {
@@ -3116,6 +3127,8 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
31163127

31173128
var appendToBody = attrs.typeaheadAppendToBody ? $parse(attrs.typeaheadAppendToBody) : false;
31183129

3130+
var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
3131+
31193132
//INTERNAL VARIABLES
31203133

31213134
//model setter executed upon match selection
@@ -3163,7 +3176,7 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
31633176
if (inputValue === modelCtrl.$viewValue && hasFocus) {
31643177
if (matches.length > 0) {
31653178

3166-
scope.activeIdx = 0;
3179+
scope.activeIdx = focusFirst ? 0 : -1;
31673180
scope.matches.length = 0;
31683181

31693182
//transform labels
@@ -3288,14 +3301,19 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
32883301
return;
32893302
}
32903303

3304+
// if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
3305+
if (scope.activeIdx == -1 && (evt.which === 13 || evt.which === 9)) {
3306+
return;
3307+
}
3308+
32913309
evt.preventDefault();
32923310

32933311
if (evt.which === 40) {
32943312
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
32953313
scope.$digest();
32963314

32973315
} else if (evt.which === 38) {
3298-
scope.activeIdx = (scope.activeIdx ? scope.activeIdx : scope.matches.length) - 1;
3316+
scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
32993317
scope.$digest();
33003318

33013319
} else if (evt.which === 13 || evt.which === 9) {

mm-foundation-tpls.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mm-foundation.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* angular-mm-foundation
3-
* http://pineconellc.github.io/angular-foundation/
3+
* https://github.com/farrago/angular-foundation-bower
44
5-
* Version: 0.8.0 - 2015-10-13
5+
* Version: 0.8.0-csp.1 - 2016-08-25
66
* License: MIT
77
* (c) Pinecone, LLC
88
*/
@@ -957,14 +957,22 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
957957
restrict: 'EA',
958958
scope: {
959959
index: '@',
960-
animate: '='
960+
animate: '=',
961+
mmTop: '@'
961962
},
962963
replace: true,
963964
transclude: true,
964965
templateUrl: 'template/modal/window.html',
965966
link: function (scope, element, attrs) {
966967
scope.windowClass = attrs.windowClass || '';
967968

969+
// Set the `top` style using element.css to avoid Content Security Policy
970+
// issues when using inline-styles
971+
if (scope.mmTop) {
972+
element.css('top', scope.mmTop);
973+
element.css('visibility', 'visible');
974+
}
975+
968976
$timeout(function () {
969977
// trigger CSS transitions
970978
scope.animate = true;
@@ -1110,18 +1118,21 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11101118
}
11111119

11121120
// Create a faux modal div just to measure its
1113-
// distance to top
1114-
var faux = angular.element('<div class="reveal-modal" style="z-index:-1""></div>');
1121+
// distance to top. Note that we set the style using element.css()
1122+
// rather than using inline style="..." to avoid issue with Content Security Policy
1123+
var faux = angular.element('<div class="reveal-modal"></div>');
1124+
faux.css("z-index", "-1");
11151125
parent.append(faux[0]);
11161126
cssTop = parseInt($window.getComputedStyle(faux[0]).top) || 0;
11171127
var openAt = calculateModalTop(faux, cssTop);
11181128
faux.remove();
11191129

1120-
var angularDomEl = angular.element('<div modal-window style="visibility: visible; top:' + openAt +'px;"></div>')
1130+
var angularDomEl = angular.element('<div modal-window></div>')
11211131
.attr({
11221132
'window-class': modal.windowClass,
11231133
'index': openedWindows.length() - 1,
1124-
'animate': 'animate'
1134+
'animate': 'animate',
1135+
'mm-top': '' + openAt + 'px' // Pass the top position to modal-window directive
11251136
});
11261137
angularDomEl.html(modal.content);
11271138

@@ -2756,8 +2767,8 @@ angular.module("mm.foundation.topbar", ['mm.foundation.mediaQueries'])
27562767
angular.element($window).bind('scroll', onScroll);
27572768

27582769
scope.$on('$destroy', function() {
2759-
angular.element($window).unbind('scroll', onResize);
2760-
angular.element($window).unbind('resize', onScroll);
2770+
angular.element($window).unbind('resize', onResize);
2771+
angular.element($window).unbind('scroll', onScroll);
27612772
});
27622773

27632774
if (topbarContainer.hasClass('fixed')) {
@@ -3115,6 +3126,8 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
31153126

31163127
var appendToBody = attrs.typeaheadAppendToBody ? $parse(attrs.typeaheadAppendToBody) : false;
31173128

3129+
var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
3130+
31183131
//INTERNAL VARIABLES
31193132

31203133
//model setter executed upon match selection
@@ -3162,7 +3175,7 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
31623175
if (inputValue === modelCtrl.$viewValue && hasFocus) {
31633176
if (matches.length > 0) {
31643177

3165-
scope.activeIdx = 0;
3178+
scope.activeIdx = focusFirst ? 0 : -1;
31663179
scope.matches.length = 0;
31673180

31683181
//transform labels
@@ -3287,14 +3300,19 @@ angular.module('mm.foundation.typeahead', ['mm.foundation.position', 'mm.foundat
32873300
return;
32883301
}
32893302

3303+
// if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
3304+
if (scope.activeIdx == -1 && (evt.which === 13 || evt.which === 9)) {
3305+
return;
3306+
}
3307+
32903308
evt.preventDefault();
32913309

32923310
if (evt.which === 40) {
32933311
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
32943312
scope.$digest();
32953313

32963314
} else if (evt.which === 38) {
3297-
scope.activeIdx = (scope.activeIdx ? scope.activeIdx : scope.matches.length) - 1;
3315+
scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
32983316
scope.$digest();
32993317

33003318
} else if (evt.which === 13 || evt.which === 9) {

mm-foundation.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "angular-foundation",
3-
"version": "0.8.0",
3+
"version": "0.8.0-csp.1",
44
"description": "Angular components for Foundation",
55
"author": "Pinecone, LLC",
66
"license": "MIT",
7-
"homepage": "http://pineconellc.github.io/angular-foundation/",
7+
"homepage": "https://github.com/farrago/angular-foundation",
88
"repository": {
99
"type": "git",
10-
"url": "git://github.com/pineconellc/angular-foundation.git"
10+
"url": "git@github.com:farrago/angular-foundation.git"
1111
},
1212
"keywords": [
1313
"angular",

0 commit comments

Comments
 (0)