70 lines
2.3 KiB
JavaScript
Executable File
70 lines
2.3 KiB
JavaScript
Executable File
!(function (n) {
|
|
"use strict";
|
|
wp.customize.controlConstructor["bloglo-spacing"] =
|
|
wp.customize.Control.extend({
|
|
ready: function () {
|
|
var i = this;
|
|
i.container.on("click", ".bloglo-spacing-linked", function () {
|
|
var i = n(this);
|
|
i.closest("ul").find(".spacing-input").removeClass("linked"),
|
|
i.parent(".spacing-link-values").removeClass("unlinked");
|
|
}),
|
|
i.container.on("click", ".bloglo-spacing-unlinked", function () {
|
|
var i = n(this);
|
|
i.closest("ul").find(".spacing-input").addClass("linked"),
|
|
i.parent(".spacing-link-values").addClass("unlinked");
|
|
}),
|
|
i.container.on("input", ".linked input", function () {
|
|
var i = n(this).val();
|
|
n(this)
|
|
.closest(".spacing-input")
|
|
.siblings(".linked")
|
|
.find("input")
|
|
.val(i)
|
|
.change();
|
|
}),
|
|
i.container
|
|
.find('.bloglo-control-unit input[type="radio"]')
|
|
.on("change", function () {
|
|
i.save_value();
|
|
}),
|
|
i.container.on("change input", ".spacing-input input", function () {
|
|
i.save_value();
|
|
}),
|
|
i.container.find(".reset-defaults").on("click", function () {
|
|
i.container.find('input[type="number"]').each(function () {
|
|
n(this).val(n(this).data("default"));
|
|
}),
|
|
i.save_value();
|
|
});
|
|
},
|
|
save_value: function () {
|
|
var n,
|
|
i,
|
|
t = {},
|
|
e = this.params.responsive,
|
|
a = this.params.choices,
|
|
s = this.container.find(".bloglo-control-unit");
|
|
if (void 0 === e || 0 == e.length)
|
|
for (n in a)
|
|
t[n] = this.container
|
|
.find('[data-spacing-choice="' + n + '"]')
|
|
.val();
|
|
else
|
|
for (i in e)
|
|
for (n in ((t[i] = {}), a))
|
|
t[i][n] = this.container
|
|
.find(
|
|
".control-responsive." +
|
|
i +
|
|
' [data-spacing-choice="' +
|
|
n +
|
|
'"]'
|
|
)
|
|
.val();
|
|
s.length && (t.unit = s.find('input[type="radio"]:checked').val()),
|
|
this.setting.set(t);
|
|
},
|
|
});
|
|
})(jQuery);
|