diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index 66a6bd8ccd..09f49dda5e 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -12,9 +12,12 @@ 'use strict'; -$.isWindow = $.isWindow || function(obj) { - return obj != null && obj === obj.window; -}; + function isWindow(obj) { + return obj != null && obj === obj.window; + } + function isFunction(obj) { + return typeof obj === "function" && typeof obj.nodeType !== "number"; + } window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -27,7 +30,7 @@ $.api = $.fn.api = function(parameters) { var // use window context if none specified - $allModules = $.isFunction(this) + $allModules = isFunction(this) ? $(window) : $(this), moduleSelector = $allModules.selector || '', @@ -316,7 +319,7 @@ $.api = $.fn.api = function(parameters) { } }, validResponse: function(response) { - if( (!module.is.expectingJSON()) || !$.isFunction(settings.successTest) ) { + if( (!module.is.expectingJSON()) || !isFunction(settings.successTest) ) { module.verbose('Response is not JSON, skipping validation', settings.successTest, response); return true; } @@ -539,7 +542,7 @@ $.api = $.fn.api = function(parameters) { context = this, elapsedTime = (new Date().getTime() - requestStartTime), timeLeft = (settings.loadingDuration - elapsedTime), - translatedResponse = ( $.isFunction(settings.onResponse) ) + translatedResponse = ( isFunction(settings.onResponse) ) ? module.is.expectingJSON() && !settings.rawResponse ? settings.onResponse.call(context, $.extend(true, {}, response)) : settings.onResponse.call(context, response) @@ -683,7 +686,7 @@ $.api = $.fn.api = function(parameters) { ; if(responder) { - if( $.isFunction(responder) ) { + if( isFunction(responder) ) { module.debug('Using specified synchronous callback', responder); response = responder.call(context, requestSettings); } @@ -694,7 +697,7 @@ $.api = $.fn.api = function(parameters) { // simulating response mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]); } - else if( $.isFunction(asyncResponder) ) { + else if( isFunction(asyncResponder) ) { asyncCallback = function(response) { module.debug('Async callback returned response', response); @@ -825,7 +828,7 @@ $.api = $.fn.api = function(parameters) { var data = {} ; - if( !$.isWindow(element) ) { + if( !isWindow(element) ) { if( module.is.input() ) { data.value = $module.val(); } @@ -839,7 +842,7 @@ $.api = $.fn.api = function(parameters) { return data; }, event: function() { - if( $.isWindow(element) || settings.on == 'now' ) { + if( isWindow(element) || settings.on == 'now' ) { module.debug('API called without element, no events attached'); return false; } @@ -1046,7 +1049,7 @@ $.api = $.fn.api = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 3f856f7f2e..2f74463721 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -139,7 +139,7 @@ $.fn.form = function(parameters) { submit: function() { module.verbose('Submitting form', $module); submitting = true; - $module.submit(); + $module.trigger('submit'); }, attachEvents: function(selector, action) { @@ -538,7 +538,7 @@ $.fn.form = function(parameters) { ancillary = module.get.ancillaryValue(rule), $field = module.get.field(field.identifier), value = $field.val(), - prompt = $.isFunction(rule.prompt) + prompt = isFunction(rule.prompt) ? rule.prompt(value) : rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule, requiresValue = (prompt.search('{value}') !== -1), @@ -1146,7 +1146,7 @@ $.fn.form = function(parameters) { $field.each(function (_index, el) { var $el = $(el), - $elGroup = $(el).closest($group), + $elGroup = $el.closest($group), isCheckbox = ($el.filter(selector.checkbox).length > 0), isRequired = $el.prop('required') || $elGroup.hasClass(className.required) || $elGroup.parent().hasClass(className.required), isDisabled = $el.is(':disabled') || $elGroup.hasClass(className.disabled) || $elGroup.parent().hasClass(className.disabled), @@ -1211,21 +1211,21 @@ $.fn.form = function(parameters) { event.stopImmediatePropagation(); } if(settings.errorFocus && ignoreCallbacks !== true) { - var focusElement, hasTabIndex = true; + var $focusElement, hasTabIndex = true; if (typeof settings.errorFocus === 'string') { - focusElement = $(document).find(settings.errorFocus); - hasTabIndex = focusElement.is('[tabindex]'); + $focusElement = $(document).find(settings.errorFocus); + hasTabIndex = $focusElement.is('[tabindex]'); // to be able to focus/scroll into non input elements we need a tabindex if (!hasTabIndex) { - focusElement.attr('tabindex',-1); + $focusElement.attr('tabindex',-1); } } else { - focusElement = $group.filter('.' + className.error).first().find(selector.field); + $focusElement = $group.filter('.' + className.error).first().find(selector.field); } - focusElement.focus(); + $focusElement.trigger('focus'); // only remove tabindex if it was dynamically created above if (!hasTabIndex){ - focusElement.removeAttr('tabindex'); + $focusElement.removeAttr('tabindex'); } } if(ignoreCallbacks !== true) { @@ -1322,7 +1322,7 @@ $.fn.form = function(parameters) { return ruleFunction.call(field, value, ancillary, $module); } ; - if( !$.isFunction(ruleFunction) ) { + if( !isFunction(ruleFunction) ) { module.error(error.noRule, ruleName); return; } @@ -1481,7 +1481,7 @@ $.fn.form = function(parameters) { } }); } - if( $.isFunction( found ) ) { + if( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/behaviors/state.js b/src/definitions/behaviors/state.js index 6951875e6d..3254121390 100644 --- a/src/definitions/behaviors/state.js +++ b/src/definitions/behaviors/state.js @@ -12,9 +12,9 @@ "use strict"; -$.isFunction = $.isFunction || function(obj) { + function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -556,7 +556,7 @@ $.fn.state = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/behaviors/visibility.js b/src/definitions/behaviors/visibility.js index 3742c80ecb..0da8c25483 100755 --- a/src/definitions/behaviors/visibility.js +++ b/src/definitions/behaviors/visibility.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -243,7 +243,7 @@ $.fn.visibility = function(parameters) { handleLoad = function() { loadedCounter++; if (loadedCounter >= images.length) { - if ($.isFunction(callback)) { + if (isFunction(callback)) { callback(); } } @@ -1168,7 +1168,7 @@ $.fn.visibility = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/globals/site.js b/src/definitions/globals/site.js index 2221142641..5b5b3692ca 100644 --- a/src/definitions/globals/site.js +++ b/src/definitions/globals/site.js @@ -10,9 +10,9 @@ ;(function ($, window, document, undefined) { -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} $.site = $.fn.site = function(parameters) { var @@ -388,7 +388,7 @@ $.site = $.fn.site = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -476,17 +476,12 @@ $.site.settings = { }; // allows for selection of elements with data attributes -$.extend($.expr[ ":" ], { - data: ($.expr.createPseudo) - ? $.expr.createPseudo(function(dataName) { - return function(elem) { - return !!$.data(elem, dataName); - }; - }) - : function(elem, i, match) { - // support: jQuery < 1.8 - return !!$.data(elem, match[ 3 ]); - } +$.extend($.expr.pseudos, { + data: $.expr.createPseudo(function(dataName) { + return function(elem) { + return !!$.data(elem, dataName); + }; + }) }); diff --git a/src/definitions/modules/accordion.js b/src/definitions/modules/accordion.js index 8f9d09fc7e..468a40e155 100644 --- a/src/definitions/modules/accordion.js +++ b/src/definitions/modules/accordion.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -356,9 +356,10 @@ $.fn.accordion = function(parameters) { display: function() { module.verbose('Removing inline display from element', this); - $(this).css('display', ''); - if( $(this).attr('style') === '') { - $(this) + var $element = $(this); + $element.css('display', ''); + if($element.attr('style') === '') { + $element .attr('style', '') .removeAttr('style') ; @@ -367,9 +368,10 @@ $.fn.accordion = function(parameters) { opacity: function() { module.verbose('Removing inline opacity from element', this); - $(this).css('opacity', ''); - if( $(this).attr('style') === '') { - $(this) + var $element = $(this); + $element.css('opacity', ''); + if($element.attr('style') === '') { + $element .attr('style', '') .removeAttr('style') ; @@ -525,7 +527,7 @@ $.fn.accordion = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -615,8 +617,8 @@ $.fn.accordion.settings = { // Adds easing $.extend( $.easing, { - easeOutQuad: function (x, t, b, c, d) { - return -c *(t/=d)*(t-2) + b; + easeOutQuad: function (x) { + return 1 - (1 - x) * (1 - x);; } }); diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index 2b5f717f6d..a67fb1c719 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -479,24 +479,24 @@ $.fn.calendar = function(parameters) { var rangeDate = (updateRange ? focusDate : null) || date || (!isTouch ? focusDate : null); container.find('td').each(function () { - var cell = $(this); - var cellDate = cell.data(metadata.date); + var $cell = $(this); + var cellDate = $cell.data(metadata.date); if (!cellDate) { return; } - var disabled = cell.hasClass(className.disabledCell); - var active = cell.hasClass(className.activeCell); - var adjacent = cell.hasClass(className.adjacentCell); + var disabled = $cell.hasClass(className.disabledCell); + var active = $cell.hasClass(className.activeCell); + var adjacent = $cell.hasClass(className.adjacentCell); var focused = module.helper.dateEqual(cellDate, focusDate, mode); var inRange = !rangeDate ? false : ((!!startDate && module.helper.isDateInRange(cellDate, mode, startDate, rangeDate)) || (!!endDate && module.helper.isDateInRange(cellDate, mode, rangeDate, endDate))); - cell.toggleClass(className.focusCell, focused && (!isTouch || isTouchDown) && (!adjacent || (settings.selectAdjacentDays && adjacent)) && !disabled); + $cell.toggleClass(className.focusCell, focused && (!isTouch || isTouchDown) && (!adjacent || (settings.selectAdjacentDays && adjacent)) && !disabled); - if (module.helper.isTodayButton(cell)) { + if (module.helper.isTodayButton($cell)) { return; } - cell.toggleClass(className.rangeCell, inRange && !active && !disabled); + $cell.toggleClass(className.rangeCell, inRange && !active && !disabled); }); } }, @@ -508,13 +508,13 @@ $.fn.calendar = function(parameters) { refreshTooltips: function() { var winWidth = $(window).width(); $container.find('td[data-position]').each(function () { - var cell = $(this); - var tooltipWidth = window.getComputedStyle(cell[0], '::after').width.replace(/[^0-9\.]/g,''); - var tooltipPosition = cell.attr('data-position'); + var $cell = $(this); + var tooltipWidth = window.getComputedStyle($cell[0], '::after').width.replace(/[^0-9\.]/g,''); + var tooltipPosition = $cell.attr('data-position'); // use a fallback width of 250 (calendar width) for IE/Edge (which return "auto") - var calcPosition = (winWidth - cell.width() - (parseInt(tooltipWidth,10) || 250)) > cell.offset().left ? 'right' : 'left'; + var calcPosition = (winWidth - $cell.width() - (parseInt(tooltipWidth,10) || 250)) > $cell.offset().left ? 'right' : 'left'; if(tooltipPosition.indexOf(calcPosition) === -1) { - cell.attr('data-position',tooltipPosition.replace(/(left|right)/,calcPosition)); + $cell.attr('data-position',tooltipPosition.replace(/(left|right)/,calcPosition)); } }); }, @@ -984,16 +984,16 @@ $.fn.calendar = function(parameters) { focus: function () { if ($input.length) { - $input.focus(); + $input.trigger('focus'); } else { - $container.focus(); + $container.trigger('focus'); } }, blur: function () { if ($input.length) { - $input.blur(); + $input.trigger('blur'); } else { - $container.blur(); + $container.trigger('blur'); } }, @@ -1448,7 +1448,7 @@ $.fn.calendar = function(parameters) { } }); } - if ($.isFunction(found)) { + if (isFunction(found)) { response = found.apply(context, passedArguments); } else if (found !== undefined) { diff --git a/src/definitions/modules/checkbox.js b/src/definitions/modules/checkbox.js index a61015cc03..3e99a60f29 100644 --- a/src/definitions/modules/checkbox.js +++ b/src/definitions/modules/checkbox.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -159,7 +159,7 @@ $.fn.checkbox = function(parameters) { var $element = $(selector) ; - event = $.isFunction(module[event]) + event = isFunction(module[event]) ? module[event] : module.toggle ; @@ -200,7 +200,7 @@ $.fn.checkbox = function(parameters) { return; } module.toggle(); - $input.focus(); + $input.trigger('focus'); event.preventDefault(); }, keydown: function(event) { @@ -242,7 +242,7 @@ $.fn.checkbox = function(parameters) { shortcutPressed = false; if(key == keyCode.escape) { module.verbose('Escape key pressed blurring field'); - $input.blur(); + $input.trigger('blur'); shortcutPressed = true; event.stopPropagation(); } @@ -783,7 +783,7 @@ $.fn.checkbox = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/dimmer.js b/src/definitions/modules/dimmer.js index b3f3554d21..b8942d1cd6 100755 --- a/src/definitions/modules/dimmer.js +++ b/src/definitions/modules/dimmer.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -188,7 +188,7 @@ $.fn.dimmer = function(parameters) { }, show: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -208,7 +208,7 @@ $.fn.dimmer = function(parameters) { }, hide: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -240,7 +240,7 @@ $.fn.dimmer = function(parameters) { animate: { show: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -302,7 +302,7 @@ $.fn.dimmer = function(parameters) { } }, hide: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -628,7 +628,7 @@ $.fn.dimmer = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 93a3920af3..d0999a7714 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -429,7 +429,7 @@ $.fn.dropdown = function(parameters) { settings.forceSelection = true; } $input - .removeAttr('required') + .prop('required',false) .removeAttr('class') .detach() .prependTo($module) @@ -523,7 +523,7 @@ $.fn.dropdown = function(parameters) { }, show: function(callback, preventFocus) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -557,7 +557,7 @@ $.fn.dropdown = function(parameters) { }, hide: function(callback, preventBlur) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -568,7 +568,7 @@ $.fn.dropdown = function(parameters) { module.remove.visible(); // hiding search focus if ( module.is.focusedOnSearch() && preventBlur !== true ) { - $search.blur(); + $search.trigger('blur'); } callback.call(element); }); @@ -955,9 +955,9 @@ $.fn.dropdown = function(parameters) { .filter(function() { // First find the last divider in this divider group // Dividers which are direct siblings are considered a group - var lastDivider = $(this).nextUntil(selector.item); + var $lastDivider = $(this).nextUntil(selector.item); - return (lastDivider.length ? lastDivider : $(this)) + return ($lastDivider.length ? $lastDivider : $(this)) // Count all non-filtered items until the next divider (or end of the dropdown) .nextUntil(selector.divider) .filter(selector.item + ":not(." + className.filtered + ")") @@ -1012,18 +1012,18 @@ $.fn.dropdown = function(parameters) { if( module.has.search() && !module.is.focusedOnSearch() ) { if(skipHandler) { $module.off('focus' + eventNamespace, selector.search); - $search.focus(); + $search.trigger('focus'); $module.on('focus' + eventNamespace, selector.search, module.event.search.focus); } else { - $search.focus(); + $search.trigger('focus'); } } }, blurSearch: function() { if( module.has.search() ) { - $search.blur(); + $search.trigger('blur'); } }, @@ -1384,7 +1384,7 @@ $.fn.dropdown = function(parameters) { ; // prevents IE11 bug where menu receives focus even though `tabindex=-1` if (document.activeElement.tagName.toLowerCase() !== 'input') { - $(document.activeElement).blur(); + $(document.activeElement).trigger('blur'); } if(!isBubbledEvent && (!hasSubMenu || settings.allowCategorySelection)) { if(module.is.searchSelection()) { @@ -1585,7 +1585,7 @@ $.fn.dropdown = function(parameters) { if(module.is.searchSelection()) { module.remove.searchTerm(); if(module.is.multiple()) { - $search.focus(); + $search.trigger('focus'); } } } @@ -1741,11 +1741,11 @@ $.fn.dropdown = function(parameters) { selectAction: function(text, value) { selectActionActive = true; module.verbose('Determining action', settings.action); - if( $.isFunction( module.action[settings.action] ) ) { + if( isFunction( module.action[settings.action] ) ) { module.verbose('Triggering preset action', settings.action, text, value); module.action[ settings.action ].call(element, text, value, this); } - else if( $.isFunction(settings.action) ) { + else if( isFunction(settings.action) ) { module.verbose('Triggering user action', settings.action, text, value); settings.action.call(element, text, value, this); } @@ -1760,7 +1760,7 @@ $.fn.dropdown = function(parameters) { inDocument = ($target.closest(document.documentElement).length > 0), inModule = ($target.closest($module).length > 0) ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -1782,7 +1782,7 @@ $.fn.dropdown = function(parameters) { notOnLabel = ($module.find($label).length === 0 || !(module.is.multiple() && settings.useLabels)), notInMenu = ($target.closest($menu).length === 0) ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -2097,7 +2097,7 @@ $.fn.dropdown = function(parameters) { values.sort(function(a, b) { return (a.name.toLowerCase().localeCompare(b.name.toLowerCase())); }); - } else if($.isFunction(settings.sortSelect)) { + } else if(isFunction(settings.sortSelect)) { values.sort(settings.sortSelect); } select[fields.values] = values; @@ -2469,7 +2469,7 @@ $.fn.dropdown = function(parameters) { ; if(isMultiple && hasSearchValue) { module.verbose('Adjusting input width', searchWidth, settings.glyphWidth); - $search.css('width', searchWidth); + $search.css('width', searchWidth + 'px'); } if(hasSearchValue || (isSearchMultiple && valueIsSet)) { module.verbose('Hiding placeholder text'); @@ -3650,7 +3650,7 @@ $.fn.dropdown = function(parameters) { }, transition ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -3701,7 +3701,7 @@ $.fn.dropdown = function(parameters) { }, transition = settings.transition.hideMethod || module.get.transition($subMenu) ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -3959,7 +3959,7 @@ $.fn.dropdown = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/embed.js b/src/definitions/modules/embed.js index 471c02bc6f..96b9ffad71 100644 --- a/src/definitions/modules/embed.js +++ b/src/definitions/modules/embed.js @@ -12,9 +12,9 @@ "use strict"; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -536,7 +536,7 @@ $.fn.embed = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/flyout.js b/src/definitions/modules/flyout.js index 6ea971720f..fe7e95ef41 100644 --- a/src/definitions/modules/flyout.js +++ b/src/definitions/modules/flyout.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -105,7 +105,7 @@ $.flyout = $.fn.flyout = function(parameters) { module.create.id(); if(!isFlyoutComponent) { module.create.flyout(); - if(!$.isFunction(settings.onHidden)) { + if(!isFunction(settings.onHidden)) { settings.onHidden = function () { module.destroy(); $module.remove(); @@ -134,17 +134,19 @@ $.flyout = $.fn.flyout = function(parameters) { icon = el[fields.icon] ? '' : '', text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML), cls = module.helpers.deQuote(el[fields.class] || ''), - click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {} + click = el[fields.click] && isFunction(el[fields.click]) ? el[fields.click] : function () {} ; $actions.append($('', { html: icon + text, 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''), class: className.button + ' ' + cls, - click: function () { - if (click.call(element, $module) === false) { - return; + on: { + click: function () { + if (click.call(element, $module) === false) { + return; + } + module.hide(); } - module.hide(); } })); }); @@ -290,7 +292,7 @@ $.flyout = $.fn.flyout = function(parameters) { keyCode = event.which ; if (keyCode === settings.keys.tab && event.shiftKey) { - $inputs.last().focus(); + $inputs.last().trigger('focus'); event.preventDefault(); } }, @@ -299,7 +301,7 @@ $.flyout = $.fn.flyout = function(parameters) { keyCode = event.which ; if (keyCode === settings.keys.tab && !event.shiftKey) { - $inputs.first().focus(); + $inputs.first().trigger('focus'); event.preventDefault(); } } @@ -579,7 +581,7 @@ $.flyout = $.fn.flyout = function(parameters) { var $toggle = $(selector) ; - event = $.isFunction(module[event]) + event = isFunction(module[event]) ? module[event] : module.toggle ; @@ -595,7 +597,7 @@ $.flyout = $.fn.flyout = function(parameters) { }, show: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -634,7 +636,7 @@ $.flyout = $.fn.flyout = function(parameters) { }, hide: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -648,7 +650,7 @@ $.flyout = $.fn.flyout = function(parameters) { module.refreshFlyouts(); module.pullPage(function() { callback.call(element); - if($.isFunction(settings.onHidden)) { + if(isFunction(settings.onHidden)) { settings.onHidden.call(element); } module.restore.focus(); @@ -700,7 +702,7 @@ $.flyout = $.fn.flyout = function(parameters) { dim, transitionEnd ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -738,7 +740,7 @@ $.flyout = $.fn.flyout = function(parameters) { animate, transitionEnd ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -809,7 +811,7 @@ $.flyout = $.fn.flyout = function(parameters) { : ($inputs.length > 1 ? $inputs.filter(':not(i.close)') : $inputs).first() ; if($input.length > 0) { - $input.focus(); + $input.trigger('focus'); } }, dimmerStyles: function() { @@ -978,7 +980,7 @@ $.flyout = $.fn.flyout = function(parameters) { inCurrentFlyout = $activeElement.closest($module).length > 0 ; if(!inCurrentFlyout) { - $focusedElement = $(document.activeElement).blur(); + $focusedElement = $(document.activeElement).trigger('blur'); } }, bodyMargin: function() { @@ -1078,7 +1080,7 @@ $.flyout = $.fn.flyout = function(parameters) { restore: { focus: function() { if($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) { - $focusedElement.focus(); + $focusedElement.trigger('focus'); } }, bodyMargin: function() { @@ -1267,7 +1269,7 @@ $.flyout = $.fn.flyout = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -1289,7 +1291,7 @@ $.flyout = $.fn.flyout = function(parameters) { if(methodInvoked) { if(instance === undefined) { - if ($.isFunction(settings.templates[query])) { + if (isFunction(settings.templates[query])) { settings.autoShow = true; settings.className.flyout = settings.className.template; settings = $.extend(true, {}, settings, settings.templates[query].apply(module ,queryArguments)); @@ -1302,7 +1304,7 @@ $.flyout = $.fn.flyout = function(parameters) { } module.initialize(); } - if (!$.isFunction(settings.templates[query])) { + if (!isFunction(settings.templates[query])) { module.invoke(query); } } @@ -1452,7 +1454,7 @@ $.fn.flyout.settings.templates = { title: '' }, queryArguments[0]); } else { - if(!$.isFunction(queryArguments[queryArguments.length-1])) { + if(!isFunction(queryArguments[queryArguments.length-1])) { queryArguments.push(function() {}); } return { diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index 86b8164041..77610bf32e 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -101,7 +101,7 @@ $.modal = $.fn.modal = function(parameters) { module.create.id(); if(!isModalComponent) { module.create.modal(); - if(!$.isFunction(settings.onHidden)) { + if(!isFunction(settings.onHidden)) { settings.onHidden = function () { module.destroy(); $module.remove(); @@ -126,17 +126,19 @@ $.modal = $.fn.modal = function(parameters) { var icon = el[fields.icon] ? '' : '', text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML), cls = module.helpers.deQuote(el[fields.class] || ''), - click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {}; + click = el[fields.click] && isFunction(el[fields.click]) ? el[fields.click] : function () {}; $actions.append($('', { html: icon + text, 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''), class: className.button + ' ' + cls, - click: function () { - var button = $(this); - if (button.is(selector.approve) || button.is(selector.deny) || click.call(element, $module) === false) { - return; + on: { + click: function () { + var button = $(this); + if (button.is(selector.approve) || button.is(selector.deny) || click.call(element, $module) === false) { + return; + } + module.hide(); } - module.hide(); } })); }); @@ -299,7 +301,7 @@ $.modal = $.fn.modal = function(parameters) { var $toggle = $(selector) ; - event = $.isFunction(module[event]) + event = isFunction(module[event]) ? module[event] : module.toggle ; @@ -397,7 +399,7 @@ $.modal = $.fn.modal = function(parameters) { keyCode = event.which ; if (keyCode === settings.keys.tab && event.shiftKey) { - $inputs.last().focus(); + $inputs.last().trigger('focus'); event.preventDefault(); } }, @@ -406,7 +408,7 @@ $.modal = $.fn.modal = function(parameters) { keyCode = event.which ; if (keyCode === settings.keys.tab && !event.shiftKey) { - $inputs.first().focus(); + $inputs.first().trigger('focus'); event.preventDefault(); } } @@ -494,7 +496,7 @@ $.modal = $.fn.modal = function(parameters) { }, show: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -506,7 +508,7 @@ $.modal = $.fn.modal = function(parameters) { }, hide: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -515,7 +517,7 @@ $.modal = $.fn.modal = function(parameters) { }, showModal: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -597,7 +599,7 @@ $.modal = $.fn.modal = function(parameters) { var $previousModal = $otherModals.filter('.' + className.active).last() ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -641,7 +643,7 @@ $.modal = $.fn.modal = function(parameters) { $previousModal.find(selector.dimmer).removeClass('active'); } } - if($.isFunction(settings.onHidden)) { + if(isFunction(settings.onHidden)) { settings.onHidden.call(element); } module.remove.dimmerStyles(); @@ -693,7 +695,7 @@ $.modal = $.fn.modal = function(parameters) { var $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating) ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -717,7 +719,7 @@ $.modal = $.fn.modal = function(parameters) { var $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating) ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -755,7 +757,7 @@ $.modal = $.fn.modal = function(parameters) { inCurrentModal = $activeElement.closest($module).length > 0 ; if(!inCurrentModal) { - $focusedElement = $(document.activeElement).blur(); + $focusedElement = $(document.activeElement).trigger('blur'); } }, bodyMargin: function() { @@ -769,7 +771,7 @@ $.modal = $.fn.modal = function(parameters) { restore: { focus: function() { if($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) { - $focusedElement.focus(); + $focusedElement.trigger('focus'); } }, bodyMargin: function() { @@ -993,7 +995,7 @@ $.modal = $.fn.modal = function(parameters) { : ($inputs.length > 1 ? $inputs.filter(':not(i.close)') : $inputs).first() ; if($input.length > 0) { - $input.focus(); + $input.trigger('focus'); } }, bodyMargin: function() { @@ -1093,7 +1095,7 @@ $.modal = $.fn.modal = function(parameters) { else if(!$module.hasClass('bottom')) { module.debug('Modal is taller than page content, resizing page height'); $context - .css('height', module.cache.height + (settings.padding * 2) ) + .css('height', module.cache.height + (settings.padding * 2) + 'px') ; } }, @@ -1272,7 +1274,7 @@ $.modal = $.fn.modal = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -1293,7 +1295,7 @@ $.modal = $.fn.modal = function(parameters) { if(methodInvoked) { if(instance === undefined) { - if ($.isFunction(settings.templates[query])) { + if (isFunction(settings.templates[query])) { settings.autoShow = true; settings.className.modal = settings.className.template; settings = $.extend(true, {}, settings, settings.templates[query].apply(module ,queryArguments)); @@ -1306,7 +1308,7 @@ $.modal = $.fn.modal = function(parameters) { } module.initialize(); } - if (!$.isFunction(settings.templates[query])) { + if (!isFunction(settings.templates[query])) { module.invoke(query); } } @@ -1471,7 +1473,7 @@ $.fn.modal.settings.templates = { title: '' }, queryArguments[0]); } else { - if(!$.isFunction(queryArguments[queryArguments.length-1])) { + if(!isFunction(queryArguments[queryArguments.length-1])) { queryArguments.push(function() {}); } return { diff --git a/src/definitions/modules/nag.js b/src/definitions/modules/nag.js index 87035d7294..e7f4f58c8c 100644 --- a/src/definitions/modules/nag.js +++ b/src/definitions/modules/nag.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -435,7 +435,7 @@ $.fn.nag = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -553,8 +553,8 @@ $.fn.nag.settings = { // Adds easing $.extend( $.easing, { - easeOutQuad: function (x, t, b, c, d) { - return -c *(t/=d)*(t-2) + b; + easeOutQuad: function (x) { + return 1 - (1 - x) * (1 - x); } }); diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index 423baadb82..4cef43050c 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -429,7 +429,7 @@ $.fn.popup = function(parameters) { }, animate: { show: function(callback) { - callback = $.isFunction(callback) ? callback : function(){}; + callback = isFunction(callback) ? callback : function(){}; if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { module.set.visible(); $popup @@ -453,7 +453,7 @@ $.fn.popup = function(parameters) { } }, hide: function(callback) { - callback = $.isFunction(callback) ? callback : function(){}; + callback = isFunction(callback) ? callback : function(){}; module.debug('Hiding pop-up'); if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { $popup @@ -511,16 +511,16 @@ $.fn.popup = function(parameters) { var $popupOffsetParent = module.get.offsetParent($popup), targetElement = $target[0], - isWindow = ($boundary[0] == window), + isWindowEl = ($boundary[0] == window), targetOffset = $target.offset(), parentOffset = settings.inline || (settings.popup && settings.movePopup) ? $target.offsetParent().offset() : { top: 0, left: 0 }, - screenPosition = (isWindow) + screenPosition = (isWindowEl) ? { top: 0, left: 0 } : $boundary.offset(), calculations = {}, - scroll = (isWindow) + scroll = (isWindowEl) ? { top: $window.scrollTop(), left: $window.scrollLeft() } : { top: 0, left: 0}, screen @@ -1284,7 +1284,7 @@ $.fn.popup = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index 9852eb4448..79e4cd8b54 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -475,10 +475,10 @@ $.fn.progress = function(parameters) { values.forEach(function(_, index) { var $bar = $($bars[index]); $bar.css({ - borderTopLeftRadius: index == firstNonZeroIndex ? '' : 0, - borderBottomLeftRadius: index == firstNonZeroIndex ? '' : 0, - borderTopRightRadius: index == lastNonZeroIndex ? '' : 0, - borderBottomRightRadius: index == lastNonZeroIndex ? '' : 0 + borderTopLeftRadius: index == firstNonZeroIndex ? '' : '0', + borderBottomLeftRadius: index == firstNonZeroIndex ? '' : '0', + borderTopRightRadius: index == lastNonZeroIndex ? '' : '0', + borderBottomRightRadius: index == lastNonZeroIndex ? '' : '0' }); }); $module @@ -906,7 +906,7 @@ $.fn.progress = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/rating.js b/src/definitions/modules/rating.js index c7e9e13e96..22ac2eb691 100644 --- a/src/definitions/modules/rating.js +++ b/src/definitions/modules/rating.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -447,7 +447,7 @@ $.fn.rating = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index e4b4117b07..feb5d98db3 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -12,7 +12,7 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; }; @@ -188,7 +188,7 @@ $.fn.search = function(parameters) { $module .one('click.close' + eventNamespace, selector.results, function(event) { if(module.is.inMessage(event) || disabledBubbled) { - $prompt.focus(); + $prompt.trigger('focus'); return; } disabledBubbled = false; @@ -228,7 +228,7 @@ $.fn.search = function(parameters) { result = $result.data(metadata.result) || module.get.result(value, results) ; var oldValue = module.get.value(); - if( $.isFunction(settings.onSelect) ) { + if( isFunction(settings.onSelect) ) { if(settings.onSelect.call(element, result, results) === false) { module.debug('Custom onSelect callback cancelled default select action'); disabledBubbled = true; @@ -295,7 +295,7 @@ $.fn.search = function(parameters) { if(keyCode == keys.escape) { if(!module.is.visible()) { module.verbose('Escape key pressed, blurring search field'); - $prompt.blur(); + $prompt.trigger('blur'); } else { module.hideResults(); } @@ -557,7 +557,7 @@ $.fn.search = function(parameters) { }, query: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -623,7 +623,7 @@ $.fn.search = function(parameters) { }); }, remote: function(searchTerm, callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -956,7 +956,7 @@ $.fn.search = function(parameters) { }, addResults: function(html) { - if( $.isFunction(settings.onResultsAdd) ) { + if( isFunction(settings.onResultsAdd) ) { if( settings.onResultsAdd.call($results, html) === false ) { module.debug('onResultsAdd callback cancelled default action'); return false; @@ -980,7 +980,7 @@ $.fn.search = function(parameters) { }, showResults: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -1019,7 +1019,7 @@ $.fn.search = function(parameters) { } }, hideResults: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -1070,7 +1070,7 @@ $.fn.search = function(parameters) { response[fields.results] = response[fields.results].slice(0, settings.maxResults); } } - if($.isFunction(template)) { + if(isFunction(template)) { html = template(response, fields, settings.preserveHTML); } else { @@ -1231,7 +1231,7 @@ $.fn.search = function(parameters) { } }); } - if( $.isFunction( found ) ) { + if( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/shape.js b/src/definitions/modules/shape.js index 8f9f24020c..cc30999f48 100644 --- a/src/definitions/modules/shape.js +++ b/src/definitions/modules/shape.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -735,7 +735,7 @@ $.fn.shape = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -760,7 +760,7 @@ $.fn.shape = function(parameters) { } var $inputs = $module.find('input'); if( $inputs.length > 0) { - $inputs.blur(); + $inputs.trigger('blur'); setTimeout(function(){ module.invoke(query); }, 150); diff --git a/src/definitions/modules/sidebar.js b/src/definitions/modules/sidebar.js index 96582f7c80..a1808bbe0c 100644 --- a/src/definitions/modules/sidebar.js +++ b/src/definitions/modules/sidebar.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -361,7 +361,7 @@ $.fn.sidebar = function(parameters) { var $toggle = $(selector) ; - event = $.isFunction(module[event]) + event = isFunction(module[event]) ? module[event] : module.toggle ; @@ -392,7 +392,7 @@ $.fn.sidebar = function(parameters) { } }, show: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -435,7 +435,7 @@ $.fn.sidebar = function(parameters) { }, hide: function(callback) { - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -497,7 +497,7 @@ $.fn.sidebar = function(parameters) { dim, transitionEnd ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -543,7 +543,7 @@ $.fn.sidebar = function(parameters) { animate, transitionEnd ; - callback = $.isFunction(callback) + callback = isFunction(callback) ? callback : function(){} ; @@ -1005,7 +1005,7 @@ $.fn.sidebar = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/slider.js b/src/definitions/modules/slider.js index 4532da4436..dabf1f7510 100644 --- a/src/definitions/modules/slider.js +++ b/src/definitions/modules/slider.js @@ -12,6 +12,10 @@ "use strict"; +function isFunction(obj) { + return typeof obj === "function" && typeof obj.nodeType !== "number"; +} + window = (typeof window != 'undefined' && window.Math == Math) ? window : (typeof self != 'undefined' && self.Math == Math) @@ -23,6 +27,7 @@ $.fn.slider = function(parameters) { var $allModules = $(this), + $document = $(document), $window = $(window), moduleSelector = $allModules.selector || '', @@ -236,7 +241,7 @@ $.fn.slider = function(parameters) { $module.on('keydown' + eventNamespace, module.event.keydown); }, globalKeyboardEvents: function() { - $(document).on('keydown' + eventNamespace + documentEventID, module.event.activateFocus); + $document.on('keydown' + eventNamespace + documentEventID, module.event.activateFocus); }, mouseEvents: function() { module.verbose('Binding mouse and touch events'); @@ -264,8 +269,8 @@ $.fn.slider = function(parameters) { slidingEvents: function() { // these don't need the identifier because we only ever want one of them to be registered with document module.verbose('Binding page wide events while handle is being draged'); - $(document).on('mousemove' + eventNamespace, module.event.move); - $(document).on('mouseup' + eventNamespace, module.event.up); + $document.on('mousemove' + eventNamespace, module.event.move); + $document.on('mouseup' + eventNamespace, module.event.up); }, windowEvents: function() { $window.on('resize' + eventNamespace, module.event.resize); @@ -285,12 +290,12 @@ $.fn.slider = function(parameters) { .off('touchcancel' + eventNamespace); $module.off('keydown' + eventNamespace); $module.off('focusout' + eventNamespace); - $(document).off('keydown' + eventNamespace + documentEventID, module.event.activateFocus); + $document.off('keydown' + eventNamespace + documentEventID, module.event.activateFocus); $window.off('resize' + eventNamespace); }, slidingEvents: function() { - $(document).off('mousemove' + eventNamespace); - $(document).off('mouseup' + eventNamespace); + $document.off('mousemove' + eventNamespace); + $document.off('mouseup' + eventNamespace); }, }, @@ -406,7 +411,7 @@ $.fn.slider = function(parameters) { $currThumb = undefined; } if(module.is.focused()) { - $(document).trigger(event); + $document.trigger(event); } if(first || module.is.focused()) { var step = module.determine.keyMovement(event); @@ -433,7 +438,7 @@ $.fn.slider = function(parameters) { if(!module.is.focused() && module.is.hover() && module.determine.keyMovement(event) != NO_STEP) { event.preventDefault(); module.event.keydown(event, true); - $module.focus(); + $module.trigger('focus'); } }, resize: function(_event) { @@ -657,9 +662,9 @@ $.fn.slider = function(parameters) { }, gapRatio: function() { var gapRatio = 1; - + if( settings.autoAdjustLabels ) { - var + var numLabels = module.get.numLabels(), trackLength = module.get.trackLength(), gapCounter = 1 @@ -1236,13 +1241,13 @@ $.fn.slider = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { response = found; } - if($.isArray(returnedValue)) { + if(Array.isArray(returnedValue)) { returnedValue.push(response); } else if(returnedValue !== undefined) { diff --git a/src/definitions/modules/sticky.js b/src/definitions/modules/sticky.js index 47b0cbf0f5..539209ad83 100755 --- a/src/definitions/modules/sticky.js +++ b/src/definitions/modules/sticky.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -26,6 +26,7 @@ window = (typeof window != 'undefined' && window.Math == Math) $.fn.sticky = function(parameters) { var $allModules = $(this), + $document = $(document), moduleSelector = $allModules.selector || '', time = new Date().getTime(), @@ -53,7 +54,7 @@ $.fn.sticky = function(parameters) { $module = $(this), $window = $(window), - $scroll = [window,document].indexOf(settings.scrollContext) < 0 ? $(document).find(settings.scrollContext) : $(settings.scrollContext), + $scroll = [window,document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext), $container, $context, @@ -139,7 +140,7 @@ $.fn.sticky = function(parameters) { determineContainer: function() { if(settings.container) { - $container = [window,document].indexOf(settings.container) < 0 ? $(document).find(settings.container) : $(settings.container); + $container = [window,document].indexOf(settings.container) < 0 ? $document.find(settings.container) : $(settings.container); } else { $container = $module.offsetParent(); @@ -148,7 +149,7 @@ $.fn.sticky = function(parameters) { determineContext: function() { if(settings.context) { - $context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context); + $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context); } else { $context = $container; @@ -430,13 +431,13 @@ $.fn.sticky = function(parameters) { if( module.is.top() ) { $module .css('bottom', '') - .css('top', -scroll) + .css('top', (-scroll) + 'px') ; } if( module.is.bottom() ) { $module .css('top', '') - .css('bottom', scroll) + .css('bottom', scroll + 'px') ; } }, @@ -855,7 +856,7 @@ $.fn.sticky = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index f8458502c5..4b7c5f66b8 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -12,12 +12,12 @@ 'use strict'; -$.isWindow = $.isWindow || function(obj) { +function isWindow(obj) { return obj != null && obj === obj.window; -}; -$.isFunction = $.isFunction || function(obj) { +} +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -30,10 +30,10 @@ $.fn.tab = function(parameters) { var // use window context if none specified - $allModules = $.isFunction(this) + $allModules = isFunction(this) ? $(window) : $(this), - + $document = $(document), moduleSelector = $allModules.selector || '', time = new Date().getTime(), performance = [], @@ -135,7 +135,7 @@ $.fn.tab = function(parameters) { bind: { events: function() { // if using $.tab don't add events - if( !$.isWindow( element ) ) { + if( !isWindow( element ) ) { module.debug('Attaching tab activation events to element', $module); $module .on('click' + eventNamespace, module.event.click) @@ -162,7 +162,7 @@ $.fn.tab = function(parameters) { module.verbose('Determined parent element for creating context', $context); } else if(settings.context) { - $context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context); + $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context); module.verbose('Using selector for tab context', settings.context, $context); } else { @@ -453,7 +453,7 @@ $.fn.tab = function(parameters) { ; if(scrollOffset !== false) { module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element); - $(document).scrollTop(scrollOffset); + $document.scrollTop(scrollOffset); } }, @@ -897,7 +897,7 @@ $.fn.tab = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { diff --git a/src/definitions/modules/toast.js b/src/definitions/modules/toast.js index 0d27d98351..6d29bdf24c 100644 --- a/src/definitions/modules/toast.js +++ b/src/definitions/modules/toast.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -195,7 +195,7 @@ $.toast = $.fn.toast = function(parameters) { .addClass(settings.class + ' ' + className.toast) .append($content) ; - $toast.css('opacity', settings.opacity); + $toast.css('opacity', String(settings.opacity)); if (settings.closeIcon) { $close = $('', {class: className.close + ' ' + (typeof settings.closeIcon === 'string' ? settings.closeIcon : ''), role: 'button', tabindex: 0, 'aria-label': settings.text.close}); if($close.hasClass(className.left)) { @@ -243,17 +243,19 @@ $.toast = $.fn.toast = function(parameters) { var icon = el[fields.icon] ? '' : '', text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML), cls = module.helpers.deQuote(el[fields.class] || ''), - click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {}; + click = el[fields.click] && isFunction(el[fields.click]) ? el[fields.click] : function () {}; $actions.append($('', { html: icon + text, 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''), class: className.button + ' ' + cls, - click: function () { - var button = $(this); - if (button.is(selector.approve) || button.is(selector.deny) || click.call(element, $module) === false) { - return; + on: { + click: function () { + var $button = $(this); + if ($button.is(selector.approve) || $button.is(selector.deny) || click.call(element, $module) === false) { + return; + } + module.close(); } - module.close(); } })); }); @@ -382,7 +384,7 @@ $.toast = $.fn.toast = function(parameters) { animate: { show: function(callback) { - callback = $.isFunction(callback) ? callback : function(){}; + callback = isFunction(callback) ? callback : function(){}; if(settings.transition && module.can.useElement('transition') && $module.transition('is supported')) { module.set.visible(); $toastBox @@ -402,7 +404,7 @@ $.toast = $.fn.toast = function(parameters) { } }, close: function(callback) { - callback = $.isFunction(callback) ? callback : function(){}; + callback = isFunction(callback) ? callback : function(){}; if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { $toastBox .transition({ @@ -415,10 +417,10 @@ $.toast = $.fn.toast = function(parameters) { interval : 50, onBeforeHide: function(callback){ - callback = $.isFunction(callback)?callback : function(){}; + callback = isFunction(callback)?callback : function(){}; if(settings.transition.closeEasing !== ''){ if($toastBox) { - $toastBox.css('opacity', 0); + $toastBox.css('opacity', '0'); $toastBox.wrap('
').parent().hide(settings.transition.closeDuration, settings.transition.closeEasing, function () { if ($toastBox) { $toastBox.parent().remove(); @@ -736,7 +738,7 @@ $.toast = $.fn.toast = function(parameters) { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { @@ -906,16 +908,17 @@ $.fn.toast.settings = { }; $.extend( $.easing, { - easeOutBounce: function (x, t, b, c, d) { - if ((t/=d) < (1/2.75)) { - return c*(7.5625*t*t) + b; - } else if (t < (2/2.75)) { - return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; - } else if (t < (2.5/2.75)) { - return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; - } else { - return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; - } + easeOutBounce: function (x) { + var n1 = 7.5625, d1 = 2.75; + if (x < 1 / d1) { + return n1 * x * x; + } else if (x < 2 / d1) { + return n1 * (x -= 1.5 / d1) * x + 0.75; + } else if (x < 2.5 / d1) { + return n1 * (x -= 2.25 / d1) * x + 0.9375; + } else { + return n1 * (x -= 2.625 / d1) * x + 0.984375; + } }, easeOutCubic: function (t) { return (--t)*t*t+1; diff --git a/src/definitions/modules/transition.js b/src/definitions/modules/transition.js index 890f0baa2c..0187dfa8cb 100644 --- a/src/definitions/modules/transition.js +++ b/src/definitions/modules/transition.js @@ -12,9 +12,9 @@ 'use strict'; -$.isFunction = $.isFunction || function(obj) { +function isFunction(obj) { return typeof obj === "function" && typeof obj.nodeType !== "number"; -}; +} window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -992,7 +992,7 @@ $.fn.transition = function() { } }); } - if ( $.isFunction( found ) ) { + if ( isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) {