Skip to content

Commit 91b3255

Browse files
committed
Refactor array checks to use Array.isArray for consistency and clarity
1 parent 79fc944 commit 91b3255

11 files changed

Lines changed: 47 additions & 44 deletions

File tree

build/magnific-popup/magnific-popup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
// converts "mfpEventName" to "eventName" callback and triggers it if it's present
8484
e = e.charAt(0).toLowerCase() + e.slice(1);
8585
if(mfp.st.callbacks[e]) {
86-
mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
86+
mfp.st.callbacks[e].apply(mfp, Array.isArray(data) ? data : [data]);
8787
}
8888
}
8989
},
@@ -175,7 +175,7 @@
175175
}
176176
}
177177
} else {
178-
mfp.items = $.isArray(data.items) ? data.items : [data.items];
178+
mfp.items = Array.isArray(data.items) ? data.items : [data.items];
179179
mfp.index = data.index || 0;
180180
}
181181

elements/upfront-gallery/js/jquery.shuffle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Shuffle.prototype = {
283283
$items.each(function() {
284284
var $this = $(this),
285285
groups = $this.data('groups'),
286-
keys = self.delimeter && !$.isArray( groups ) ? groups.split( self.delimeter ) : groups,
286+
keys = self.delimeter && !Array.isArray( groups ) ? groups.split( self.delimeter ) : groups,
287287
passes = $.inArray(category, keys) > -1;
288288

289289
if ( passes ) {

elements/upfront-post-data/js/panel-abstractions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ define([
125125
}
126126
;
127127

128-
jQuery(window).on('resize', resize_cbk);
128+
window.addEventListener('resize', resize_cbk);
129129

130130
editor
131131
.start()

elements/upfront-slider/js/jquery.cycle.all.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
var opts = this.opts();
110110
opts.API.trigger('cycle-post-initialize', [ opts ]);
111111
var tx = $.fn.cycle.transitions[opts.fx];
112-
if (tx && $.isFunction(tx.postInit))
112+
if (tx && typeof tx.postInit === "function")
113113
tx.postInit( opts );
114114
},
115115

@@ -206,7 +206,7 @@
206206
var len;
207207

208208
if ( $.type(slides) == 'string')
209-
slides = $.trim( slides );
209+
slides = slides.trim();
210210

211211
$( slides ).each(function(i) {
212212
var slideOpts;
@@ -414,7 +414,7 @@
414414
}
415415
if ( opts.continueAuto !== undefined ) {
416416
if ( opts.continueAuto === false ||
417-
($.isFunction(opts.continueAuto) && opts.continueAuto() === false )) {
417+
(typeof opts.continueAuto === "function" && opts.continueAuto() === false )) {
418418
opts.API.log('terminating automatic transitions');
419419
opts.timeout = 0;
420420
if ( opts.timeoutId )
@@ -682,7 +682,7 @@
682682
};
683683

684684
// automatically find and run slideshows
685-
$(document).ready(function() {
685+
jQuery(function() {
686686
$( $.fn.cycle.defaults.autoSelector ).cycle();
687687
});
688688

@@ -700,7 +700,7 @@
700700

701701
$(document).on( 'cycle-initialized', function( e, opts ) {
702702
var autoHeight = opts.autoHeight;
703-
var t = $.type( autoHeight );
703+
var t = typeof autoHeight;
704704
var resizeThrottle = null;
705705
var ratio;
706706

@@ -751,7 +751,7 @@
751751
else if ( opts._autoHeightRatio ) {
752752
opts.container.height( opts.container.width() / opts._autoHeightRatio );
753753
}
754-
else if ( autoHeight === 'calc' || ( $.type( autoHeight ) == 'number' && autoHeight >= 0 ) ) {
754+
else if ( autoHeight === 'calc' || ( typeof autoHeight === 'number' && autoHeight >= 0 ) ) {
755755
if ( autoHeight === 'calc' )
756756
sentinelIndex = calcSentinelIndex( e, opts );
757757
else if ( autoHeight >= opts.slides.length )
@@ -890,7 +890,7 @@
890890
else {
891891
cmd = cmd == 'goto' ? 'jump' : cmd; // issue #3; change 'goto' to 'jump' internally
892892
cmdFn = opts.API[ cmd ];
893-
if ( $.isFunction( cmdFn )) {
893+
if ( typeof cmdFn === "function" ) {
894894
cmdArgs = $.makeArray( args );
895895
cmdArgs.shift();
896896
return cmdFn.apply( opts.API, cmdArgs );
@@ -939,7 +939,7 @@
939939
this.stop(); //#204
940940

941941
var opts = this.opts();
942-
var clean = $.isFunction( $._data ) ? $._data : $.noop; // hack for #184 and #201
942+
var clean = typeof $._data === "function" ? $._data : $.noop; // hack for #184 and #201
943943
clearTimeout(opts.timeoutId);
944944
opts.timeoutId = 0;
945945
opts.API.stop();
@@ -1123,9 +1123,9 @@
11231123

11241124
function add( slides, prepend ) {
11251125
var slideArr = [];
1126-
if ( $.type( slides ) == 'string' )
1127-
slides = $.trim( slides );
1128-
else if ( $.type( slides) === 'array' ) {
1126+
if ( typeof slides === 'string' )
1127+
slides = slides.trim();
1128+
else if ( Array.isArray(slides) ) {
11291129
for (var i=0; i < slides.length; i++ )
11301130
slides[i] = $(slides[i])[0];
11311131
}
@@ -1389,18 +1389,18 @@
13891389
var nextFn = API.next;
13901390
var prevFn = API.prev;
13911391
var prepareTxFn = API.prepareTx;
1392-
var type = $.type( opts.progressive );
1392+
var type = typeof opts.progressive;
13931393
var slides, scriptEl;
13941394

13951395
if ( type == 'array' ) {
13961396
slides = opts.progressive;
13971397
}
1398-
else if ($.isFunction( opts.progressive ) ) {
1398+
else if (typeof opts.progressive === "function") {
13991399
slides = opts.progressive( opts );
14001400
}
14011401
else if ( type == 'string' ) {
14021402
scriptEl = $( opts.progressive );
1403-
slides = $.trim( scriptEl.html() );
1403+
slides = scriptEl.html().trim();
14041404
if ( !slides )
14051405
return;
14061406
// is it json array?
@@ -1534,7 +1534,7 @@
15341534
prop = obj[str];
15351535
}
15361536

1537-
if ($.isFunction(prop))
1537+
if (typeof prop === "function")
15381538
return prop.apply(obj, args);
15391539
if (prop !== undefined && prop !== null && prop != str)
15401540
return prop;
@@ -1616,7 +1616,7 @@
16161616
opts.busy = 1;
16171617
if (opts.fxFn) // fx function provided?
16181618
opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
1619-
else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
1619+
else if (typeof $.fn.cycle[opts.fx] === "function") // fx plugin ?
16201620
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
16211621
else
16221622
$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
@@ -1741,7 +1741,7 @@ function advance(opts, moveForward) {
17411741
}
17421742

17431743
var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
1744-
if ($.isFunction(cb))
1744+
if (typeof cb === "function")
17451745
cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
17461746
go(els, opts, 1, moveForward);
17471747
return false;
@@ -1757,7 +1757,7 @@ function buildPager(els, opts) {
17571757

17581758
$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
17591759
var a;
1760-
if ($.isFunction(opts.pagerAnchorBuilder)) {
1760+
if (typeof opts.pagerAnchorBuilder === "function") {
17611761
a = opts.pagerAnchorBuilder(i,el);
17621762
debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
17631763
}
@@ -1795,7 +1795,7 @@ $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
17951795
p.cycleTimeout = 0;
17961796
}
17971797
var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
1798-
if ($.isFunction(cb))
1798+
if (typeof cb === "function")
17991799
cb(opts.nextSlide, els[opts.nextSlide]);
18001800
go(els,opts,1,opts.currSlide < i); // trigger the trans
18011801
// return false; // <== allow bubble
@@ -1931,7 +1931,7 @@ $.fn.cycle.defaults = {
19311931
backwards: false, // true to start slideshow at last slide and move backwards through the stack
19321932
before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
19331933
center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options)
1934-
cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE)
1934+
cleartype: !(typeof document.createElement('div').style.opacity !== 'undefined'), // true if clearType corrections should be applied (for IE)
19351935
cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
19361936
containerResize: 1, // resize container to fit largest slide
19371937
containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic

library/upfront_functions.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,16 @@ function upfront_get_breakpoint_property_value ($prop, $data, $breakpoint, $retu
127127
* @return array
128128
*/
129129
function upfront_set_breakpoint_property_value ($prop, $value, &$data, $breakpoint) {
130-
$model_breakpoint = upfront_get_property_value('breakpoint', $data);
131-
$breakpoint_id = is_string($breakpoint) ? $breakpoint : $breakpoint->get_id();
132-
$breakpoint_data = $model_breakpoint && !empty($model_breakpoint[$breakpoint_id]) ? $model_breakpoint[$breakpoint_id] : array();
133-
$breakpoint_data[$prop] = $value;
134-
$model_breakpoint[$breakpoint_id] = $breakpoint_data;
135-
upfront_set_property_value('breakpoint', $model_breakpoint, $data);
136-
return $data;
130+
$model_breakpoint = upfront_get_property_value('breakpoint', $data);
131+
if (!is_array($model_breakpoint)) {
132+
$model_breakpoint = []; // Stelle sicher, dass es ein Array ist
133+
}
134+
$breakpoint_id = is_string($breakpoint) ? $breakpoint : $breakpoint->get_id();
135+
$breakpoint_data = $model_breakpoint && !empty($model_breakpoint[$breakpoint_id]) ? $model_breakpoint[$breakpoint_id] : [];
136+
$breakpoint_data[$prop] = $value;
137+
$model_breakpoint[$breakpoint_id] = $breakpoint_data;
138+
upfront_set_property_value('breakpoint', $model_breakpoint, $data);
139+
return $data;
137140
}
138141

139142
/**

scripts/file_upload/jquery.fileupload.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
if ($.type(options.formData) === 'function') {
297297
return options.formData(options.form);
298298
}
299-
if ($.isArray(options.formData)) {
299+
if (Array.isArray(options.formData)) {
300300
return options.formData;
301301
}
302302
if ($.type(options.formData) === 'object') {
@@ -536,7 +536,7 @@
536536
if (!paramName.length) {
537537
paramName = [fileInput.prop('name') || 'files[]'];
538538
}
539-
} else if (!$.isArray(paramName)) {
539+
} else if (!Array.isArray(paramName)) {
540540
paramName = [paramName];
541541
}
542542
return paramName;

scripts/file_upload/jquery.iframe-transport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
counter + '"></iframe>'
7171
).on('load', function () {
7272
var fileInputClones,
73-
paramNames = $.isArray(options.paramName) ?
73+
paramNames = Array.isArray(options.paramName) ?
7474
options.paramName : [options.paramName];
7575
iframe
7676
.off('load')

scripts/magnific-popup/magnific-popup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
// converts "mfpEventName" to "eventName" callback and triggers it if it's present
8484
e = e.charAt(0).toLowerCase() + e.slice(1);
8585
if(mfp.st.callbacks[e]) {
86-
mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
86+
mfp.st.callbacks[e].apply(mfp, Array.isArray(data) ? data : [data]);
8787
}
8888
}
8989
},
@@ -175,7 +175,7 @@
175175
}
176176
}
177177
} else {
178-
mfp.items = $.isArray(data.items) ? data.items : [data.items];
178+
mfp.items = Array.isArray(data.items) ? data.items : [data.items];
179179
mfp.index = data.index || 0;
180180
}
181181

scripts/redactor/redactor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7375,7 +7375,7 @@
73757375
for (var i = 0; i < len; i++)
73767376
{
73777377
var attrs = this.tidy.settings.removeAttr[i][1];
7378-
if ($.isArray(attrs)) attrs = attrs.join(' ');
7378+
if (Array.isArray(attrs)) attrs = attrs.join(' ');
73797379

73807380
this.tidy.$div.find(this.tidy.settings.removeAttr[i][0]).removeAttr(attrs);
73817381
}
@@ -7405,7 +7405,7 @@
74057405
{
74067406
$.each($el[0].attributes, function(i, item)
74077407
{
7408-
if ($.isArray(allowed[pos]))
7408+
if (Array.isArray(allowed[pos]))
74097409
{
74107410
if ($.inArray(item.name, allowed[pos]) == -1)
74117411
{
@@ -7466,7 +7466,7 @@
74667466
if (!this.tidy.settings.removeDataAttr) return;
74677467

74687468
var tags = this.tidy.settings.removeDataAttr;
7469-
if ($.isArray(this.tidy.settings.removeDataAttr)) tags = this.tidy.settings.removeDataAttr.join(',');
7469+
if (Array.isArray(this.tidy.settings.removeDataAttr)) tags = this.tidy.settings.removeDataAttr.join(',');
74707470

74717471
this.tidy.removeAttrs(this.tidy.$div.find(tags), '^(data-)');
74727472

@@ -8445,7 +8445,7 @@
84458445
var parent = this.selection.getParent();
84468446
var current = this.selection.getCurrent();
84478447

8448-
if ($.isArray(tagName))
8448+
if (Array.isArray(tagName))
84498449
{
84508450
var matched = 0;
84518451
$.each(tagName, $.proxy(function(i, s)

scripts/spectrum/spectrum-1.1.1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
currentValue = 0,
162162
currentAlpha = 1,
163163
palette = opts.palette.slice(0),
164-
paletteArray = $.isArray(palette[0]) ? palette : [palette],
164+
paletteArray = Array.isArray(palette[0]) ? palette : [palette],
165165
selectionPalette = opts.selectionPalette.slice(0),
166166
maxSelectionSize = opts.maxSelectionSize,
167167
draggingClass = "sp-dragging",

0 commit comments

Comments
 (0)