Skip to content

Commit

Permalink
Merge pull request #10 from zurb/master
Browse files Browse the repository at this point in the history
Update Foundation
  • Loading branch information
winghouchan committed May 14, 2014
2 parents 460573d + e31a88f commit 82bbd1c
Show file tree
Hide file tree
Showing 30 changed files with 287 additions and 212 deletions.
2 changes: 1 addition & 1 deletion doc/layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script src="{{assets}}/js/modernizr.js"></script>
</head>
<body class="antialiased hide-extras">
<div class="marketing off-canvas-wrap">
<div class="marketing off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">

{{> topbar}}
Expand Down
5 changes: 3 additions & 2 deletions doc/pages/components/equalizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ <h4>Rendered HTML</h4>
{{#markdown}}
```js
$(document).foundation({
equalizer:
// specify if Equalizer should make elements equal height once they become stacked
equalizer : {
// Specify if Equalizer should make elements equal height once they become stacked.
equalize_on_stack: false
}
});
```
{{/markdown}}
Expand Down
39 changes: 39 additions & 0 deletions doc/pages/components/offcanvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,45 @@ <h4>SCSS</h4>

{{> examples_offcanvas_javascript_options}}

### Event Bindings

There are a series of events that you can bind to for triggering callbacks:

```js
$(document).on('open', '[data-offcanvas]', function () {
var off_canvas_wrap = $(this);
});

$(document).on('close', '[data-offcanvas]', function () {
var off_canvas_wrap = $(this);
});

```

For example, to freeze scrolling when active:

```js
$(document)
.on('open', '[data-offcanvas]', function() {
$('html').css('overflow', 'hidden');
})
.on('close', '[data-offcanvas]', function() {
$('html').css('overflow', 'auto');
})

```

### Programmatic open / close / toggle

The `.off-canvas-wrap` container can be targeted for javascript methods. At this time, the presentational open class needs to be included: either `move-right`, `move-left`, or `offcanvas-overlap`.

```js
$('.off-canvas-wrap').foundation('offcanvas', 'open', 'move-right');
$('.off-canvas-wrap').foundation('offcanvas', 'close', 'move-right');
$('.off-canvas-wrap').foundation('offcanvas', 'toggle', 'move-right');

```

***

### Sass Errors?
Expand Down
2 changes: 1 addition & 1 deletion humans.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Foundation was made by ZURB, an interaction design and design strategy firm in Campbell, CA */
/* zurb.com */
/* zurb.com */
/* humanstxt.org */

/* SITE */
Expand Down
2 changes: 1 addition & 1 deletion js/foundation/foundation.abide.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@

valid_radio : function (el, required) {
var name = el.getAttribute('name'),
group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name="+name+"]"),
group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='"+name+"']"),
count = group.length,
valid = false;

Expand Down
2 changes: 1 addition & 1 deletion js/foundation/foundation.interchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
var split = raw_arr[i].split(/\((.*?)(\))$/);

if (split.length > 1) {
var cached_split = split[0].split(','),
var cached_split = split[0].split(/\, /),
params = this.parse_params(cached_split[0],
cached_split[1], split[1]);

Expand Down
2 changes: 1 addition & 1 deletion js/foundation/foundation.joyride.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
$('.joyride-modal-bg').hide();
this.settings.$current_tip.hide();

if (typeof abort === 'undefined') {
if (typeof abort === 'undefined' || abort === false) {
this.settings.post_step_callback(this.settings.$li.index(), this.settings.$current_tip);
this.settings.post_ride_callback(this.settings.$li.index(), this.settings.$current_tip);
}
Expand Down
117 changes: 69 additions & 48 deletions js/foundation/foundation.offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,92 @@

events : function () {
var self = this,
S = self.S;

if (this.settings.open_method === 'move'){
S(this.scope).off('.offcanvas')
.on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
self.click_toggle_class(e, 'move-right');
})
.on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
var settings = self.get_settings(e)
if (settings.close_on_click)
S(".off-canvas-wrap").removeClass("move-right");
})
.on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
self.click_toggle_class(e, 'move-left');
})
.on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
var settings = self.get_settings(e)
if (settings.close_on_click)
S(".off-canvas-wrap").removeClass("move-left");
})
.on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
self.click_remove_class(e, 'move-left');
self.click_remove_class(e, 'move-right');
})
S = self.S,
move_class = '',
right_postfix = '',
left_postfix = '';

if (this.settings.open_method === 'move') {
move_class = 'move-';
right_postfix = 'right';
left_postfix = 'left';
} else if (this.settings.open_method === 'overlap') {
S(this.scope).off('.offcanvas')
.on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
self.click_toggle_class(e, 'offcanvas-overlap');
})
.on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
var settings = self.get_settings(e)
if (settings.close_on_click)
S(".off-canvas-wrap").removeClass("offcanvas-overlap");
})
.on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
self.click_toggle_class(e, 'offcanvas-overlap');
})
.on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
var settings = self.get_settings(e)
if (settings.close_on_click)
S(".off-canvas-wrap").removeClass("offcanvas-overlap");
})
.on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
self.click_remove_class(e, 'offcanvas-overlap');
})
move_class = 'offcanvas-overlap';
}

S(this.scope).off('.offcanvas')
.on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
self.click_toggle_class(e, move_class + right_postfix);
})
.on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
var settings = self.get_settings(e);
if (settings.close_on_click) {
self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
}
})
.on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
self.click_toggle_class(e, move_class + left_postfix);
})
.on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
var settings = self.get_settings(e);
if (settings.close_on_click) {
self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
}
})
.on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
self.click_remove_class(e, move_class + left_postfix);
if (right_postfix) self.click_remove_class(e, move_class + right_postfix);
});

},

toggle: function(class_name, $off_canvas) {
$off_canvas = $off_canvas || this.get_wrapper();
if ($off_canvas.is('.' + class_name)) {
this.hide(class_name, $off_canvas);
} else {
return;
this.show(class_name, $off_canvas);
}
},

show: function(class_name, $off_canvas) {
$off_canvas = $off_canvas || this.get_wrapper();
$off_canvas.trigger('open');
$off_canvas.addClass(class_name);
},

hide: function(class_name, $off_canvas) {
$off_canvas = $off_canvas || this.get_wrapper();
$off_canvas.trigger('close');
$off_canvas.removeClass(class_name);
},

click_toggle_class: function(e, class_name) {
e.preventDefault();
this.S(e.target).closest('.off-canvas-wrap').toggleClass(class_name);
var $off_canvas = this.get_wrapper(e);
this.toggle(class_name, $off_canvas);
},

click_remove_class: function(e, class_name) {
e.preventDefault();
this.S('.off-canvas-wrap').removeClass(class_name);
var $off_canvas = this.get_wrapper(e);
this.hide(class_name, $off_canvas);
},

get_settings: function(e) {
var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']')
var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']');
return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
},

get_wrapper: function(e) {
var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap');

if ($off_canvas.length === 0) {
$off_canvas = this.S('.off-canvas-wrap');
}
return $off_canvas;
},

reflow : function () {}
};
}(jQuery, window, window.document));
2 changes: 1 addition & 1 deletion js/foundation/foundation.reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
close : function (modal) {
var modal = modal && modal.length ? modal : this.S(this.scope),
open_modals = this.S('[' + this.attr_name() + '].open'),
settings = modal.data(this.attr_name(true) + '-init');
settings = modal.data(this.attr_name(true) + '-init') || this.settings;

if (open_modals.length > 0) {
this.locked = true;
Expand Down

0 comments on commit 82bbd1c

Please sign in to comment.