Skip to content

Commit 6cee131

Browse files
authored
Merge pull request #14 from base-apps/fix-legacy-issues
backlog of fixes for repository
2 parents cd9397e + 413aae8 commit 6cee131

File tree

18 files changed

+329
-132
lines changed

18 files changed

+329
-132
lines changed

docs/templates/action-sheet.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h3>Additional Options</h3>
8282
<hr>
8383

8484
<h3>External Triggers</h3>
85-
<p>To use an entirely different element entirely to control the action sheet, use the following markup. Make sure that the ID for the action sheet and the toggle match up. The zf-as-button element is optional here, since you're using another element to trigger the action sheet.</p>
85+
<p>To use an entirely different element to control the action sheet, use the following markup. Make sure that the ID for the action sheet and the toggle match up. The zf-as-button element is optional here, since you're using another element to trigger the action sheet.</p>
8686

8787
<hljs>
8888
<a href="#" zf-hard-toggle="separate-actionsheet">Toggle</a>
@@ -117,12 +117,10 @@ <h3>Sass Mixins</h3>
117117
// This is the action sheet itself
118118
.custom-action-sheet {
119119
// These are the core styles for the sheet menu
120-
121-
$padding: 1rem,
122-
$color: #000,
123-
$border-color,
124-
$background-hover: #ccc
125-
);
120+
$padding: 1rem,
121+
$color: #000,
122+
$border-color,
123+
$background-hover: #ccc
126124

127125
// This mixin sets up styles for the mobile action sheet
128126
@include action-sheet(

js/angular/components/common/common.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,40 @@
192192

193193
function link(scope, element, attrs) {
194194
element.on('click', function(e) {
195-
var tar = e.target;
196-
var avoid = ['zf-toggle', 'zf-hard-toggle', 'zf-open', 'zf-close'].filter(function(e, i){
195+
var tar = e.target, avoid, activeElements, closedElements, i;
196+
197+
// check if clicked target is designated to open/close another component
198+
avoid = ['zf-toggle', 'zf-hard-toggle', 'zf-open', 'zf-close'].filter(function(e){
197199
return e in tar.attributes;
198200
});
201+
if(avoid.length > 0) {
202+
// do nothing
203+
return;
204+
}
199205

200-
if(avoid.length > 0){ return; }
206+
// check if clicked element is inside active closable parent
207+
if (getParentsUntil(tar, 'zf-closable') !== false) {
208+
// do nothing
209+
return;
210+
}
201211

202-
var activeElements = document.querySelectorAll('.is-active[zf-closable]');
212+
// close all active elements
213+
activeElements = document.querySelectorAll('.is-active[zf-closable]');
214+
closedElements = 0;
215+
if(activeElements.length > 0) {
216+
for(i = 0; i < activeElements.length; i++) {
217+
if (!activeElements[i].hasAttribute('zf-ignore-all-close')) {
218+
foundationApi.publish(activeElements[i].id, 'close');
219+
closedElements++;
220+
}
221+
}
203222

204-
if(activeElements.length && !activeElements[0].hasAttribute('zf-ignore-all-close')){
205-
if(getParentsUntil(tar, 'zf-closable') === false){
223+
// if one or more elements were closed,
224+
// prevent the default action
225+
if (closedElements > 0) {
206226
e.preventDefault();
207-
foundationApi.publish(activeElements[0].id, 'close');
208227
}
209228
}
210-
return;
211229
});
212230
}
213231
/** special thanks to Chris Ferdinandi for this solution.

js/angular/components/iconic/iconic.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@
152152

153153
injectSvg(element[0]);
154154

155-
foundationApi.subscribe('resize', function () {
156-
// only run update on current element
157-
ico.update(element[0]);
155+
// subscribe for resize events
156+
foundationApi.subscribe('resize', resize);
157+
158+
scope.$on("$destroy", function() {
159+
foundationApi.unsubscribe('resize', resize);
158160
});
159161

160162
// handle dynamic updating of src
@@ -254,6 +256,11 @@
254256
}
255257
});
256258
}
259+
260+
function resize() {
261+
// run update on current element
262+
ico.update(element[0]);
263+
}
257264
}
258265

259266
function addDataDash(attr) {

js/angular/components/interchange/interchange.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,32 @@
3131

3232
var globalQueries = foundationMQ.getMediaQueries();
3333

34-
//setup
35-
foundationApi.subscribe('resize', function(msg) {
34+
// subscribe for resize events
35+
foundationApi.subscribe('resize', resize);
36+
37+
scope.$on("$destroy", function() {
38+
foundationApi.unsubscribe('resize', resize);
39+
});
40+
41+
//init
42+
foundationApi.publish('resize', 'initial resize');
43+
44+
function templateLoader(templateUrl) {
45+
return $http.get(templateUrl, {cache: $templateCache});
46+
}
47+
48+
function collectInformation(el) {
49+
var data = foundationMQ.collectScenariosFromElement(el);
50+
51+
scenarios = data.scenarios;
52+
innerTemplates = data.templates;
53+
}
54+
55+
function checkScenario(scenario) {
56+
return !current || current !== scenario;
57+
}
58+
59+
function resize(msg) {
3660
transclude(function(clone, newScope) {
3761
if(!scenarios || !innerTemplates) {
3862
collectInformation(clone);
@@ -72,25 +96,6 @@
7296
}
7397
}
7498
});
75-
76-
});
77-
78-
//init
79-
foundationApi.publish('resize', 'initial resize');
80-
81-
function templateLoader(templateUrl) {
82-
return $http.get(templateUrl, {cache: $templateCache});
83-
}
84-
85-
function collectInformation(el) {
86-
var data = foundationMQ.collectScenariosFromElement(el);
87-
88-
scenarios = data.scenarios;
89-
innerTemplates = data.templates;
90-
}
91-
92-
function checkScenario(scenario) {
93-
return !current || current !== scenario;
9499
}
95100
}
96101
}
@@ -224,17 +229,10 @@
224229

225230
function postLink(scope, element, attrs) {
226231
// subscribe for resize events
227-
foundationApi.subscribe('resize', function() {
228-
var orignalVisibilty = scope[queryResult];
229-
runQuery();
230-
if (orignalVisibilty != scope[queryResult]) {
231-
// digest if visibility changed
232-
scope.$digest();
233-
}
234-
});
232+
foundationApi.subscribe('resize', resize);
235233

236234
scope.$on("$destroy", function() {
237-
foundationApi.unsubscribe('resize');
235+
foundationApi.unsubscribe('resize', resize);
238236
});
239237

240238
// run first media query check
@@ -259,6 +257,15 @@
259257
}
260258
}
261259
}
260+
261+
function resize() {
262+
var orignalVisibilty = scope[queryResult];
263+
runQuery();
264+
if (orignalVisibilty != scope[queryResult]) {
265+
// digest if visibility changed
266+
scope.$digest();
267+
}
268+
}
262269
}
263270
}
264271
}

0 commit comments

Comments
 (0)