Skip to content

Commit f95d572

Browse files
committed
Release v0.8.0
1 parent 38f8205 commit f95d572

File tree

6 files changed

+98
-54
lines changed

6 files changed

+98
-54
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.7.0",
6+
"version": "0.8.0",
77
"main": ["./mm-foundation-tpls.js"],
88
"dependencies": {
99
"angular": ">=1.3.0"

mm-foundation-tpls.js

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* angular-mm-foundation
33
* http://pineconellc.github.io/angular-foundation/
44
5-
* Version: 0.7.0 - 2015-09-25
5+
* Version: 0.8.0 - 2015-10-13
66
* License: MIT
77
* (c) Pinecone, LLC
88
*/
@@ -439,6 +439,8 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
439439

440440
if (!elementWasOpen && !element.hasClass('disabled') && !element.prop('disabled')) {
441441
dropdown.css('display', 'block'); // We display the element so that offsetParent is populated
442+
dropdown.addClass('f-open-dropdown');
443+
442444
var offset = $position.offset(element);
443445
var parentOffset = $position.offset(angular.element(dropdown[0].offsetParent));
444446
var dropdownWidth = dropdown.prop('offsetWidth');
@@ -476,6 +478,7 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
476478
closeMenu = function (event) {
477479
$document.off('click', closeMenu);
478480
dropdown.css('display', 'none');
481+
dropdown.removeClass('f-open-dropdown');
479482
element.removeClass('expanded');
480483
closeMenu = angular.noop;
481484
openElement = null;
@@ -985,7 +988,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
985988

986989
var OPENED_MODAL_CLASS = 'modal-open';
987990

988-
var backdropDomEl, backdropScope;
991+
var backdropDomEl, backdropScope, cssTop;
989992
var openedWindows = $$stackedMap.createNew();
990993
var $modalStack = {};
991994

@@ -1007,7 +1010,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10071010
});
10081011

10091012
function removeModalWindow(modalInstance) {
1010-
var body = $document.find('body').eq(0);
1013+
var parent = $document.find(modalInstance.options.parent).eq(0);
10111014
var modalWindow = openedWindows.get(modalInstance).value;
10121015

10131016
//clean up the stack
@@ -1016,7 +1019,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10161019
//remove window DOM element
10171020
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
10181021
modalWindow.modalScope.$destroy();
1019-
body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
1022+
parent.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
10201023
checkRemoveBackdrop();
10211024
});
10221025
}
@@ -1066,6 +1069,14 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10661069
}
10671070
}
10681071

1072+
function calculateModalTop(modalElement, offset) {
1073+
if (angular.isUndefined(offset)) {
1074+
offset = 0;
1075+
}
1076+
var scrollY = $window.pageYOffset || 0;
1077+
return offset + scrollY;
1078+
}
1079+
10691080
$document.bind('keydown', function (evt) {
10701081
var modal;
10711082

@@ -1080,35 +1091,33 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10801091
});
10811092

10821093
$modalStack.open = function (modalInstance, modal) {
1083-
1084-
openedWindows.add(modalInstance, {
1094+
modalInstance.options = {
10851095
deferred: modal.deferred,
10861096
modalScope: modal.scope,
10871097
backdrop: modal.backdrop,
1088-
keyboard: modal.keyboard
1089-
});
1098+
keyboard: modal.keyboard,
1099+
parent: modal.parent
1100+
};
1101+
openedWindows.add(modalInstance, modalInstance.options);
10901102

1091-
var body = $document.find('body').eq(0),
1103+
var parent = $document.find(modal.parent).eq(0),
10921104
currBackdropIndex = backdropIndex();
10931105

10941106
if (currBackdropIndex >= 0 && !backdropDomEl) {
10951107
backdropScope = $rootScope.$new(true);
10961108
backdropScope.index = currBackdropIndex;
10971109
backdropDomEl = $compile('<div modal-backdrop></div>')(backdropScope);
1098-
body.append(backdropDomEl);
1110+
parent.append(backdropDomEl);
10991111
}
11001112

11011113
// Create a faux modal div just to measure its
11021114
// distance to top
11031115
var faux = angular.element('<div class="reveal-modal" style="z-index:-1""></div>');
1104-
body.append(faux[0]);
1105-
var marginTop = parseInt(getComputedStyle(faux[0]).top) || 0;
1116+
parent.append(faux[0]);
1117+
cssTop = parseInt($window.getComputedStyle(faux[0]).top) || 0;
1118+
var openAt = calculateModalTop(faux, cssTop);
11061119
faux.remove();
11071120

1108-
// Using pageYOffset instead of scrollY to ensure compatibility with IE
1109-
var scrollY = $window.pageYOffset || 0;
1110-
var openAt = scrollY + marginTop;
1111-
11121121
var angularDomEl = angular.element('<div modal-window style="visibility: visible; top:' + openAt +'px;"></div>')
11131122
.attr({
11141123
'window-class': modal.windowClass,
@@ -1119,22 +1128,31 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11191128

11201129
var modalDomEl = $compile(angularDomEl)(modal.scope);
11211130
openedWindows.top().value.modalDomEl = modalDomEl;
1122-
body.append(modalDomEl);
1123-
body.addClass(OPENED_MODAL_CLASS);
1131+
parent.append(modalDomEl);
1132+
parent.addClass(OPENED_MODAL_CLASS);
11241133
};
11251134

1126-
$modalStack.close = function (modalInstance, result) {
1135+
$modalStack.reposition = function (modalInstance) {
11271136
var modalWindow = openedWindows.get(modalInstance).value;
11281137
if (modalWindow) {
1129-
modalWindow.deferred.resolve(result);
1138+
var modalDomEl = modalWindow.modalDomEl;
1139+
var top = calculateModalTop(modalDomEl, cssTop);
1140+
modalDomEl.css('top', top + "px");
1141+
}
1142+
};
1143+
1144+
$modalStack.close = function (modalInstance, result) {
1145+
var modalWindow = openedWindows.get(modalInstance);
1146+
if (modalWindow) {
1147+
modalWindow.value.deferred.resolve(result);
11301148
removeModalWindow(modalInstance);
11311149
}
11321150
};
11331151

11341152
$modalStack.dismiss = function (modalInstance, reason) {
1135-
var modalWindow = openedWindows.get(modalInstance).value;
1153+
var modalWindow = openedWindows.get(modalInstance);
11361154
if (modalWindow) {
1137-
modalWindow.deferred.reject(reason);
1155+
modalWindow.value.deferred.reject(reason);
11381156
removeModalWindow(modalInstance);
11391157
}
11401158
};
@@ -1197,6 +1215,9 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11971215
},
11981216
dismiss: function (reason) {
11991217
$modalStack.dismiss(modalInstance, reason);
1218+
},
1219+
reposition: function () {
1220+
$modalStack.reposition(modalInstance);
12001221
}
12011222
};
12021223

@@ -1242,7 +1263,8 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
12421263
content: tplAndVars[0],
12431264
backdrop: modalOptions.backdrop,
12441265
keyboard: modalOptions.keyboard,
1245-
windowClass: modalOptions.windowClass
1266+
windowClass: modalOptions.windowClass,
1267+
parent: modalOptions.parent || 'body'
12461268
});
12471269

12481270
}, function resolveError(reason) {

mm-foundation-tpls.min.js

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

mm-foundation.js

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* angular-mm-foundation
33
* http://pineconellc.github.io/angular-foundation/
44
5-
* Version: 0.7.0 - 2015-09-25
5+
* Version: 0.8.0 - 2015-10-13
66
* License: MIT
77
* (c) Pinecone, LLC
88
*/
@@ -438,6 +438,8 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
438438

439439
if (!elementWasOpen && !element.hasClass('disabled') && !element.prop('disabled')) {
440440
dropdown.css('display', 'block'); // We display the element so that offsetParent is populated
441+
dropdown.addClass('f-open-dropdown');
442+
441443
var offset = $position.offset(element);
442444
var parentOffset = $position.offset(angular.element(dropdown[0].offsetParent));
443445
var dropdownWidth = dropdown.prop('offsetWidth');
@@ -475,6 +477,7 @@ angular.module('mm.foundation.dropdownToggle', [ 'mm.foundation.position', 'mm.f
475477
closeMenu = function (event) {
476478
$document.off('click', closeMenu);
477479
dropdown.css('display', 'none');
480+
dropdown.removeClass('f-open-dropdown');
478481
element.removeClass('expanded');
479482
closeMenu = angular.noop;
480483
openElement = null;
@@ -984,7 +987,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
984987

985988
var OPENED_MODAL_CLASS = 'modal-open';
986989

987-
var backdropDomEl, backdropScope;
990+
var backdropDomEl, backdropScope, cssTop;
988991
var openedWindows = $$stackedMap.createNew();
989992
var $modalStack = {};
990993

@@ -1006,7 +1009,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10061009
});
10071010

10081011
function removeModalWindow(modalInstance) {
1009-
var body = $document.find('body').eq(0);
1012+
var parent = $document.find(modalInstance.options.parent).eq(0);
10101013
var modalWindow = openedWindows.get(modalInstance).value;
10111014

10121015
//clean up the stack
@@ -1015,7 +1018,7 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10151018
//remove window DOM element
10161019
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
10171020
modalWindow.modalScope.$destroy();
1018-
body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
1021+
parent.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
10191022
checkRemoveBackdrop();
10201023
});
10211024
}
@@ -1065,6 +1068,14 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10651068
}
10661069
}
10671070

1071+
function calculateModalTop(modalElement, offset) {
1072+
if (angular.isUndefined(offset)) {
1073+
offset = 0;
1074+
}
1075+
var scrollY = $window.pageYOffset || 0;
1076+
return offset + scrollY;
1077+
}
1078+
10681079
$document.bind('keydown', function (evt) {
10691080
var modal;
10701081

@@ -1079,35 +1090,33 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
10791090
});
10801091

10811092
$modalStack.open = function (modalInstance, modal) {
1082-
1083-
openedWindows.add(modalInstance, {
1093+
modalInstance.options = {
10841094
deferred: modal.deferred,
10851095
modalScope: modal.scope,
10861096
backdrop: modal.backdrop,
1087-
keyboard: modal.keyboard
1088-
});
1097+
keyboard: modal.keyboard,
1098+
parent: modal.parent
1099+
};
1100+
openedWindows.add(modalInstance, modalInstance.options);
10891101

1090-
var body = $document.find('body').eq(0),
1102+
var parent = $document.find(modal.parent).eq(0),
10911103
currBackdropIndex = backdropIndex();
10921104

10931105
if (currBackdropIndex >= 0 && !backdropDomEl) {
10941106
backdropScope = $rootScope.$new(true);
10951107
backdropScope.index = currBackdropIndex;
10961108
backdropDomEl = $compile('<div modal-backdrop></div>')(backdropScope);
1097-
body.append(backdropDomEl);
1109+
parent.append(backdropDomEl);
10981110
}
10991111

11001112
// Create a faux modal div just to measure its
11011113
// distance to top
11021114
var faux = angular.element('<div class="reveal-modal" style="z-index:-1""></div>');
1103-
body.append(faux[0]);
1104-
var marginTop = parseInt(getComputedStyle(faux[0]).top) || 0;
1115+
parent.append(faux[0]);
1116+
cssTop = parseInt($window.getComputedStyle(faux[0]).top) || 0;
1117+
var openAt = calculateModalTop(faux, cssTop);
11051118
faux.remove();
11061119

1107-
// Using pageYOffset instead of scrollY to ensure compatibility with IE
1108-
var scrollY = $window.pageYOffset || 0;
1109-
var openAt = scrollY + marginTop;
1110-
11111120
var angularDomEl = angular.element('<div modal-window style="visibility: visible; top:' + openAt +'px;"></div>')
11121121
.attr({
11131122
'window-class': modal.windowClass,
@@ -1118,22 +1127,31 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11181127

11191128
var modalDomEl = $compile(angularDomEl)(modal.scope);
11201129
openedWindows.top().value.modalDomEl = modalDomEl;
1121-
body.append(modalDomEl);
1122-
body.addClass(OPENED_MODAL_CLASS);
1130+
parent.append(modalDomEl);
1131+
parent.addClass(OPENED_MODAL_CLASS);
11231132
};
11241133

1125-
$modalStack.close = function (modalInstance, result) {
1134+
$modalStack.reposition = function (modalInstance) {
11261135
var modalWindow = openedWindows.get(modalInstance).value;
11271136
if (modalWindow) {
1128-
modalWindow.deferred.resolve(result);
1137+
var modalDomEl = modalWindow.modalDomEl;
1138+
var top = calculateModalTop(modalDomEl, cssTop);
1139+
modalDomEl.css('top', top + "px");
1140+
}
1141+
};
1142+
1143+
$modalStack.close = function (modalInstance, result) {
1144+
var modalWindow = openedWindows.get(modalInstance);
1145+
if (modalWindow) {
1146+
modalWindow.value.deferred.resolve(result);
11291147
removeModalWindow(modalInstance);
11301148
}
11311149
};
11321150

11331151
$modalStack.dismiss = function (modalInstance, reason) {
1134-
var modalWindow = openedWindows.get(modalInstance).value;
1152+
var modalWindow = openedWindows.get(modalInstance);
11351153
if (modalWindow) {
1136-
modalWindow.deferred.reject(reason);
1154+
modalWindow.value.deferred.reject(reason);
11371155
removeModalWindow(modalInstance);
11381156
}
11391157
};
@@ -1196,6 +1214,9 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
11961214
},
11971215
dismiss: function (reason) {
11981216
$modalStack.dismiss(modalInstance, reason);
1217+
},
1218+
reposition: function () {
1219+
$modalStack.reposition(modalInstance);
11991220
}
12001221
};
12011222

@@ -1241,7 +1262,8 @@ angular.module('mm.foundation.modal', ['mm.foundation.transition'])
12411262
content: tplAndVars[0],
12421263
backdrop: modalOptions.backdrop,
12431264
keyboard: modalOptions.keyboard,
1244-
windowClass: modalOptions.windowClass
1265+
windowClass: modalOptions.windowClass,
1266+
parent: modalOptions.parent || 'body'
12451267
});
12461268

12471269
}, function resolveError(reason) {

mm-foundation.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-foundation",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "Angular components for Foundation",
55
"author": "Pinecone, LLC",
66
"license": "MIT",

0 commit comments

Comments
 (0)