mirror of
https://github.com/pi-hole/web.git
synced 2026-04-27 04:04:00 +01:00
Cleaned code
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
stack = stack.add(self);
|
||||
} else {
|
||||
stack = stack.add(self.find(handle));
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -64,12 +64,11 @@
|
||||
tidy(self, 'ifDestroyed');
|
||||
} else {
|
||||
operate(self, true, options);
|
||||
};
|
||||
|
||||
// Fire method's callback
|
||||
}
|
||||
// Fire method's callback
|
||||
if ($.isFunction(fire)) {
|
||||
fire();
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Customization
|
||||
@@ -97,14 +96,12 @@
|
||||
// Selector limit
|
||||
if (selector == _checkbox || selector == _radio) {
|
||||
handle = 'input[type="' + selector + '"]';
|
||||
};
|
||||
|
||||
// Clickable area limit
|
||||
}
|
||||
// Clickable area limit
|
||||
if (area < -50) {
|
||||
area = -50;
|
||||
};
|
||||
|
||||
// Walk around the selector
|
||||
}
|
||||
// Walk around the selector
|
||||
walker(this);
|
||||
|
||||
return stack.each(function() {
|
||||
@@ -172,9 +169,8 @@
|
||||
|
||||
parent += '"';
|
||||
});
|
||||
};
|
||||
|
||||
// Wrap input
|
||||
}
|
||||
// Wrap input
|
||||
parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
|
||||
|
||||
// Layer addition
|
||||
@@ -213,19 +209,17 @@
|
||||
} else {
|
||||
parent[_add](hoverClass);
|
||||
item[_add](labelHoverClass);
|
||||
};
|
||||
};
|
||||
|
||||
if (_mobile) {
|
||||
}
|
||||
}
|
||||
if (_mobile) {
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Input events
|
||||
}
|
||||
// Input events
|
||||
self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
|
||||
var type = event[_type],
|
||||
key = event.keyCode;
|
||||
@@ -241,10 +235,9 @@
|
||||
off(self, _checked);
|
||||
} else {
|
||||
on(self, _checked);
|
||||
};
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
// Keyup
|
||||
} else if (type == 'keyup' && node[_type] == _radio) {
|
||||
@@ -253,7 +246,7 @@
|
||||
// Focus/blur
|
||||
} else if (/us|ur/.test(type)) {
|
||||
parent[type == 'blur' ? _remove : _add](focusClass);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Helper events
|
||||
@@ -282,27 +275,25 @@
|
||||
// State is off
|
||||
} else {
|
||||
parent[_remove](toggle + ' ' + activeClass);
|
||||
};
|
||||
|
||||
// Label hover
|
||||
}
|
||||
// Label hover
|
||||
if (label.length && labelHover && toggle == hoverClass) {
|
||||
|
||||
// mouseout|touchend
|
||||
label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
|
||||
};
|
||||
};
|
||||
|
||||
if (_mobile) {
|
||||
}
|
||||
}
|
||||
if (_mobile) {
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return this;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Do something with inputs
|
||||
@@ -332,28 +323,25 @@
|
||||
on(input, state, true);
|
||||
} else {
|
||||
off(input, state, true);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} else if (!direct || method == 'toggle') {
|
||||
|
||||
// Helper or label was clicked
|
||||
if (!direct) {
|
||||
input[_callback]('ifClicked');
|
||||
};
|
||||
|
||||
// Toggle checked state
|
||||
}
|
||||
// Toggle checked state
|
||||
if (active) {
|
||||
if (node[_type] !== _radio) {
|
||||
off(input, state);
|
||||
};
|
||||
}
|
||||
} else {
|
||||
on(input, state);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Add checked, disabled or indeterminate state
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add checked, disabled or indeterminate state
|
||||
function on(input, state, keep) {
|
||||
var node = input[0],
|
||||
parent = input.parent(),
|
||||
@@ -377,11 +365,10 @@
|
||||
inputs.each(function() {
|
||||
if (this !== node && $(this).data(_iCheck)) {
|
||||
off($(this), state);
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Indeterminate state
|
||||
}
|
||||
// Indeterminate state
|
||||
if (indeterminate) {
|
||||
|
||||
// Add indeterminate state
|
||||
@@ -390,32 +377,27 @@
|
||||
// Remove checked state
|
||||
if (node[_checked]) {
|
||||
off(input, _checked, 'force');
|
||||
};
|
||||
|
||||
// Checked or disabled state
|
||||
}
|
||||
// Checked or disabled state
|
||||
} else {
|
||||
|
||||
// Add checked or disabled state
|
||||
if (!keep) {
|
||||
node[state] = true;
|
||||
};
|
||||
|
||||
// Remove indeterminate state
|
||||
}
|
||||
// Remove indeterminate state
|
||||
if (checked && node[_indeterminate]) {
|
||||
off(input, _indeterminate, false);
|
||||
};
|
||||
};
|
||||
|
||||
// Trigger callbacks
|
||||
}
|
||||
}
|
||||
// Trigger callbacks
|
||||
callbacks(input, checked, state, keep);
|
||||
};
|
||||
|
||||
// Add proper cursor
|
||||
}
|
||||
// Add proper cursor
|
||||
if (node[_disabled] && !!option(input, _cursor, true)) {
|
||||
parent.find('.' + _iCheckHelper).css(_cursor, 'default');
|
||||
};
|
||||
|
||||
// Add state class
|
||||
}
|
||||
// Add state class
|
||||
parent[_add](specific || option(input, state) || '');
|
||||
|
||||
// Set ARIA attribute
|
||||
@@ -423,9 +405,8 @@
|
||||
|
||||
// Remove regular state class
|
||||
parent[_remove](regular || option(input, callback) || '');
|
||||
};
|
||||
|
||||
// Remove checked, disabled or indeterminate state
|
||||
}
|
||||
// Remove checked, disabled or indeterminate state
|
||||
function off(input, state, keep) {
|
||||
var node = input[0],
|
||||
parent = input.parent(),
|
||||
@@ -442,18 +423,15 @@
|
||||
// Toggle state
|
||||
if (indeterminate || !keep || keep == 'force') {
|
||||
node[state] = false;
|
||||
};
|
||||
|
||||
// Trigger callbacks
|
||||
}
|
||||
// Trigger callbacks
|
||||
callbacks(input, checked, callback, keep);
|
||||
};
|
||||
|
||||
// Add proper cursor
|
||||
}
|
||||
// Add proper cursor
|
||||
if (!node[_disabled] && !!option(input, _cursor, true)) {
|
||||
parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
|
||||
};
|
||||
|
||||
// Remove state class
|
||||
}
|
||||
// Remove state class
|
||||
parent[_remove](specific || option(input, state) || '');
|
||||
|
||||
// Set ARIA attribute
|
||||
@@ -461,9 +439,8 @@
|
||||
|
||||
// Add regular state class
|
||||
parent[_add](regular || option(input, callback) || '');
|
||||
};
|
||||
|
||||
// Remove all traces
|
||||
}
|
||||
// Remove all traces
|
||||
function tidy(input, callback) {
|
||||
if (input.data(_iCheck)) {
|
||||
|
||||
@@ -473,34 +450,29 @@
|
||||
// Callback
|
||||
if (callback) {
|
||||
input[_callback](callback);
|
||||
};
|
||||
|
||||
// Unbind events
|
||||
}
|
||||
// Unbind events
|
||||
input.off('.i').unwrap();
|
||||
$(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
|
||||
};
|
||||
};
|
||||
|
||||
// Get some option
|
||||
}
|
||||
}
|
||||
// Get some option
|
||||
function option(input, state, regular) {
|
||||
if (input.data(_iCheck)) {
|
||||
return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
|
||||
};
|
||||
};
|
||||
|
||||
// Capitalize some string
|
||||
}
|
||||
}
|
||||
// Capitalize some string
|
||||
function capitalize(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
};
|
||||
|
||||
// Executable handlers
|
||||
}
|
||||
// Executable handlers
|
||||
function callbacks(input, checked, callback, keep) {
|
||||
if (!keep) {
|
||||
if (checked) {
|
||||
input[_callback]('ifToggled');
|
||||
};
|
||||
|
||||
input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
|
||||
};
|
||||
};
|
||||
}
|
||||
input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
|
||||
}
|
||||
}
|
||||
})(window.jQuery || window.Zepto);
|
||||
|
||||
Reference in New Issue
Block a user