2018-04-16 21:17:16 +00:00
|
|
|
$(function() {
|
2018-04-19 19:49:04 +00:00
|
|
|
/* Hero */
|
|
|
|
$("header nav *[data-hero]").hover(function() {
|
|
|
|
$(this).parents("header").attr( "data-hero", $(this).attr("data-hero") );
|
2018-04-16 21:17:16 +00:00
|
|
|
});
|
|
|
|
|
2018-04-19 19:49:04 +00:00
|
|
|
/* Paroller */
|
|
|
|
$("*[data-paroller-factor]").paroller();
|
|
|
|
|
|
|
|
/* Widget: Calculator */
|
2018-04-18 15:54:30 +00:00
|
|
|
$.each($(".widget_calculator"), function(i, calculator) {
|
|
|
|
calculator = $(calculator);
|
|
|
|
var display = calculator.find("input[type=text]");
|
|
|
|
var lhs = null, operator = null;
|
2018-04-16 21:17:16 +00:00
|
|
|
|
2018-04-18 15:54:30 +00:00
|
|
|
function calculator_apply() {
|
|
|
|
if (lhs && operator == '-')
|
|
|
|
display.val(parseInt(lhs) - parseInt(display.val()));
|
|
|
|
else if (lhs && operator == '+')
|
|
|
|
display.val(parseInt(lhs) + parseInt(display.val()));
|
|
|
|
}
|
2018-04-16 21:17:16 +00:00
|
|
|
|
2018-04-18 15:54:30 +00:00
|
|
|
calculator.find("input[type=button]").click(function() {
|
|
|
|
var value = $(this).val();
|
|
|
|
|
|
|
|
if (value == '-' || value == '+') {
|
|
|
|
if (operator == value && !display.val())
|
|
|
|
operator = null;
|
|
|
|
|
|
|
|
else {
|
|
|
|
calculator_apply();
|
|
|
|
operator = value;
|
|
|
|
lhs = display.val();
|
|
|
|
display.val('');
|
|
|
|
}
|
|
|
|
} else if (value == 'C') {
|
|
|
|
operator = null;
|
|
|
|
lhs = null;
|
2018-04-16 21:17:16 +00:00
|
|
|
display.val('');
|
2018-04-18 15:54:30 +00:00
|
|
|
} else if (value == '=')
|
|
|
|
calculator_apply();
|
|
|
|
else
|
|
|
|
display.val(display.val() + '' + value);
|
2018-04-16 21:17:16 +00:00
|
|
|
|
2018-04-18 15:54:30 +00:00
|
|
|
calculator.find("input").removeClass('selected');
|
|
|
|
if (operator)
|
|
|
|
calculator.find("input[value='" + operator + "']").addClass('selected');
|
|
|
|
});
|
2018-04-16 21:17:16 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|