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

Commit

Permalink
more 6.1+ work added
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalk committed Dec 21, 2015
1 parent 56b24ed commit ecbeb92
Show file tree
Hide file tree
Showing 57 changed files with 489 additions and 305 deletions.
11 changes: 10 additions & 1 deletion vendor/assets/javascripts/foundation/foundation.abide.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
this._init();
this._events();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Abide');
}

/**
Expand Down Expand Up @@ -136,6 +136,14 @@
return true;
}
break;
case 'password':
if ($el.attr('required') && !$el.val()) {
// requirement check does not pass
return false;
} else {
return true;
}
break;
case 'checkbox':
if ($el.attr('required') && !$el.is(':checked')) {
return false;
Expand Down Expand Up @@ -222,6 +230,7 @@
Abide.prototype.validateInput = function($el, $form) {
var self = this,
textInput = $form.find('input[type="text"]'),
passwordInput = $form.find('input[type="password"]'),
checkInput = $form.find('input[type="checkbox"]'),
label,
radioGroupName;
Expand Down
4 changes: 2 additions & 2 deletions vendor/assets/javascripts/foundation/foundation.accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Accordion');
Foundation.Keyboard.register('Accordion', {
'ENTER': 'toggle',
'SPACE': 'toggle',
Expand Down Expand Up @@ -106,7 +106,7 @@
_this.down($tabContent);
}
}).on('keydown.zf.accordion', function(e){
Foundation.Keyboard.handleKey(e, _this, {
Foundation.Keyboard.handleKey(e, 'Accordion', {
toggle: function() {
_this.toggle($tabContent);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'AccordionMenu');
Foundation.Keyboard.register('AccordionMenu', {
'ENTER': 'toggle',
'SPACE': 'toggle',
Expand Down Expand Up @@ -138,7 +138,7 @@
return;
}
});
Foundation.Keyboard.handleKey(e, _this, {
Foundation.Keyboard.handleKey(e, 'AccordionMenu', {
open: function() {
if ($target.is(':hidden')) {
_this.down($target);
Expand Down
89 changes: 46 additions & 43 deletions vendor/assets/javascripts/foundation/foundation.core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!function($) {
"use strict";

var FOUNDATION_VERSION = '6.0.5';
var FOUNDATION_VERSION = '6.0.6';

// Global Foundation object
// This is attached to the window, or used as a module for AMD/Browserify
Expand Down Expand Up @@ -51,21 +51,19 @@ var Foundation = {
* @param {Object} plugin - an instance of a plugin, usually `this` in context.
* @fires Plugin#init
*/
registerPlugin: function(plugin){
var pluginName = functionName(plugin.constructor).toLowerCase();

registerPlugin: function(plugin, name){
var pluginName = name ? hyphenate(name) : functionName(plugin.constructor).toLowerCase();
plugin.uuid = this.GetYoDigits(6, pluginName);

if(!plugin.$element.attr('data-' + pluginName)){
plugin.$element.attr('data-' + pluginName, plugin.uuid);
}
if(!plugin.$element.attr('data-' + pluginName)){ plugin.$element.attr('data-' + pluginName, plugin.uuid); }
if(!plugin.$element.data('zfPlugin')){ plugin.$element.data('zfPlugin', plugin); }
/**
* Fires when the plugin has initialized.
* @event Plugin#init
*/
plugin.$element.trigger('init.zf.' + pluginName);

this._activePlugins[plugin.uuid] = plugin;
this._uuids.push(plugin.uuid);

return;
},
Expand All @@ -77,16 +75,18 @@ var Foundation = {
* @fires Plugin#destroyed
*/
unregisterPlugin: function(plugin){
var pluginName = functionName(plugin.constructor).toLowerCase();
var pluginName = hyphenate(functionName(plugin.$element.data('zfPlugin').constructor));

delete this._activePlugins[plugin.uuid];
plugin.$element.removeAttr('data-' + pluginName)
this._uuids.splice(this._uuids.indexOf(plugin.uuid), 1);
plugin.$element.removeAttr('data-' + pluginName).removeData('zfPlugin')
/**
* Fires when the plugin has been destroyed.
* @event Plugin#destroyed
*/
.trigger('destroyed.zf.' + pluginName);

for(var prop in plugin){
plugin[prop] = null;//clean up script to prep for garbage collection.
}
return;
},

Expand All @@ -96,34 +96,37 @@ var Foundation = {
* @param {String} plugins - optional string of an individual plugin key, attained by calling `$(element).data('pluginName')`, or string of a plugin class i.e. `'dropdown'`
* @default If no argument is passed, reflow all currently active plugins.
*/
_reflow: function(plugins){
var actvPlugins = Object.keys(this._activePlugins);
var _this = this;

if(!plugins){
actvPlugins.forEach(function(p){
_this._activePlugins[p]._init();
});

}else if(typeof plugins === 'string'){
var namespace = plugins.split('-')[1];

if(namespace){

this._activePlugins[plugins]._init();

}else{
namespace = new RegExp(plugins, 'i');

actvPlugins.filter(function(p){
return namespace.test(p);
}).forEach(function(p){
_this._activePlugins[p]._init();
});
}
}

},
reInit: function(plugins){
var isJQ = plugins instanceof $;
try{
if(isJQ){
plugins.each(function(){
$(this).data('zfPlugin')._init();
});
}else{
var type = typeof plugins,
_this = this,
fns = {
'object': function(plgs){
plgs.forEach(function(p){
$('[data-'+ p +']').foundation('_init');
});
},
'string': function(){
$('[data-'+ plugins +']').foundation('_init');
},
'undefined': function(){
this['object'](Object.keys(_this._plugins));
}
};
fns[type](plugins);
}
}catch(err){
console.error(err);
}finally{
return plugins;
}
},

/**
* returns a random base-36 uid with namespacing
Expand Down Expand Up @@ -168,7 +171,7 @@ var Foundation = {
var $el = $(this),
opts = {};
// Don't double-dip on plugins
if ($el.data('zf-plugin')) {
if ($el.data('zfPlugin')) {
console.warn("Tried to initialize "+name+" on an element that already has a Foundation plugin.");
return;
}
Expand All @@ -180,7 +183,7 @@ var Foundation = {
});
}
try{
$el.data('zf-plugin', new plugin($(this), opts));
$el.data('zfPlugin', new plugin($(this), opts));
}catch(er){
console.error(er);
}finally{
Expand Down Expand Up @@ -363,7 +366,7 @@ function functionName(fn) {
function parseValue(str){
if(/true/.test(str)) return true;
else if(/false/.test(str)) return false;
else if(!isNaN(str * 1)/* && typeof (str * 1) === "number"*/) return parseFloat(str);
else if(!isNaN(str * 1)) return parseFloat(str);
return str;
}
// Convert PascalCase to kebab-case
Expand Down
6 changes: 3 additions & 3 deletions vendor/assets/javascripts/foundation/foundation.drilldown.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Drilldown');
Foundation.Keyboard.register('Drilldown', {
'ENTER': 'open',
'SPACE': 'open',
Expand Down Expand Up @@ -63,7 +63,7 @@
Drilldown.prototype._init = function(){
this.$submenuAnchors = this.$element.find('li.has-submenu');
this.$submenus = this.$submenuAnchors.children('[data-submenu]');
this.$menuItems = this.$element.find('li:visible').not('.js-drilldown-back').attr('role', 'menuitem');
this.$menuItems = this.$element.find('li').not('.js-drilldown-back').attr('role', 'menuitem');

this._prepareMenu();

Expand Down Expand Up @@ -157,7 +157,7 @@
return;
}
});
Foundation.Keyboard.handleKey(e, _this, {
Foundation.Keyboard.handleKey(e, 'Drilldown', {
next: function() {
if ($element.is(_this.$submenuAnchors)) {
_this._show($element);
Expand Down
45 changes: 36 additions & 9 deletions vendor/assets/javascripts/foundation/foundation.dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
this.options = $.extend({}, Dropdown.defaults, this.$element.data(), options);
this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Dropdown');
Foundation.Keyboard.register('Dropdown', {
'ENTER': 'open',
'SPACE': 'open',
Expand Down Expand Up @@ -75,7 +75,13 @@
* @option
* @example true
*/
autoFocus: false
autoFocus: false,
/**
* Allows a click on the body to close the dropdown.
* @option
* @example true
*/
closeOnClick: false
};
/**
* Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
Expand Down Expand Up @@ -234,24 +240,24 @@
var $target = $(this),
visibleFocusableElements = Foundation.Keyboard.findFocusable(_this.$element);

Foundation.Keyboard.handleKey(e, _this, {
Foundation.Keyboard.handleKey(e, 'Dropdown', {
tab_forward: function() {
if (this.$element.find(':focus').is(visibleFocusableElements.eq(-1))) { // left modal downwards, setting focus to first element
if (this.options.trapFocus) { // if focus shall be trapped
if (_this.$element.find(':focus').is(visibleFocusableElements.eq(-1))) { // left modal downwards, setting focus to first element
if (_this.options.trapFocus) { // if focus shall be trapped
visibleFocusableElements.eq(0).focus();
e.preventDefault();
} else { // if focus is not trapped, close dropdown on focus out
this.close();
_this.close();
}
}
},
tab_backward: function() {
if (this.$element.find(':focus').is(visibleFocusableElements.eq(0)) || this.$element.is(':focus')) { // left modal upwards, setting focus to last element
if (this.options.trapFocus) { // if focus shall be trapped
if (_this.$element.find(':focus').is(visibleFocusableElements.eq(0)) || _this.$element.is(':focus')) { // left modal upwards, setting focus to last element
if (_this.options.trapFocus) { // if focus shall be trapped
visibleFocusableElements.eq(-1).focus();
e.preventDefault();
} else { // if focus is not trapped, close dropdown on focus out
this.close();
_this.close();
}
}
},
Expand All @@ -269,6 +275,26 @@
});
});
};
/**
* Adds an event handler to the body to close any dropdowns on a click.
* @function
* @private
*/
Dropdown.prototype._addBodyHandler = function(){
var $body = $(document.body).not(this.$element),
_this = this;
$body.off('click.zf.dropdown')
.on('click.zf.dropdown', function(e){
if(_this.$anchor.is(e.target) || _this.$anchor.find(e.target).length) {
return;
}
if(_this.$element.find(e.target).length) {
return;
}
_this.close();
$body.off('click.zf.dropdown');
});
};
/**
* Opens the dropdown pane, and fires a bubbling event to close other dropdowns.
* @function
Expand Down Expand Up @@ -296,6 +322,7 @@
}
}

if(this.options.closeOnClick){ this._addBodyHandler(); }

/**
* Fires once the dropdown is visible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Foundation.Nest.Feather(this.$element, 'dropdown');
this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'DropdownMenu');
Foundation.Keyboard.register('DropdownMenu', {
'ENTER': 'open',
'SPACE': 'open',
Expand Down Expand Up @@ -274,7 +274,7 @@
});
}
}
Foundation.Keyboard.handleKey(e, _this, functions);
Foundation.Keyboard.handleKey(e, 'DropdownMenu', functions);

});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Equalizer');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
this._init();
this._events();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Interchange');
}

/**
Expand Down Expand Up @@ -159,6 +159,7 @@
else {
$.get(path, function(response) {
_this.$element.html(response);
$(response).foundation();
_this.$element.trigger('replaced.zf.interchange');
_this.currentPath = path;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

this._init();

Foundation.registerPlugin(this);
Foundation.registerPlugin(this, 'Magellan');
}

/**
Expand Down
Loading

0 comments on commit ecbeb92

Please sign in to comment.