File: /home/elrashedytravel/www/wp-content/themes/bloglo/inc/customizer/controls/gallery/gallery.min.js
!(function (t, e) {
"use strict";
(t.ImageGalleryControl = t.Control.extend({
initialize: function (a, n) {
var r;
(r = n || {}).params.file_type || (r.params.file_type = "image"),
r.params.type || (r.params.type = "bloglo-gallery"),
r.params.content ||
((r.params.content = e("<li></li>")),
r.params.content.attr(
"id",
"customize-control-" + a.replace(/]/g, "").replace(/\[/g, "-")
),
r.params.content.attr(
"class",
"customize-control customize-control-" + r.params.type
)),
r.params.attachments || (r.params.attachments = []),
t.Control.prototype.initialize.call(this, a, r);
},
ready: function () {
var t = this;
function e() {
var e = t.setting.get();
t.setAttachmentsData(e).done(function () {
t.renderContent(), t.setupSortable();
});
}
_.bindAll(t, "openFrame", "select"),
e(),
t.setting.bind(e),
t.container.on("click keydown", ".upload-button", t.openFrame);
},
setAttachmentsData: function (t) {
var a = this,
n = [];
return (
(a.params.attachments = []),
_.each(t, function (t, r) {
var i = new e.Deferred();
wp.media
.attachment(t)
.fetch()
.done(function () {
(a.params.attachments[r] = this.attributes), i.resolve();
}),
n.push(i);
}),
e.when.apply(void 0, n).promise()
);
},
openFrame: function (t) {
t.preventDefault(), this.frame || this.initFrame(), this.frame.open();
},
initFrame: function () {
var t,
e = this;
(this.frame = wp.media({
button: { text: e.params.button_labels.frame_button },
states: [
new wp.media.controller.Library({
title: e.params.button_labels.frame_title,
library: wp.media.query({ type: e.params.file_type }),
multiple: !0,
}),
],
})),
(t = function () {
var t, a, n, r;
(r = e.frame.state().get("library")),
(t = e.frame.state().get("selection")),
(a = e.setting.get()),
(r.comparator = function (t, e) {
var a = !0 === this.mirroring.get(t.cid),
n = !0 === this.mirroring.get(e.cid);
return !a && n ? -1 : a && !n ? 1 : 0;
}),
_.each(a, function (e) {
(n = wp.media.attachment(e)),
t.add(n ? [n] : []),
r.add(n ? [n] : []);
});
}),
e.frame.on("open", t),
e.frame.on("select", e.select);
},
select: function () {
var t, e;
(t = this.frame.state().get("selection").toJSON()),
(this.params.attachments = t),
(e = this.getAttachmentIds(t)),
this.setSettingValues(e);
},
getAttachmentIds: function (t) {
var e,
a = [];
for (e in t) a.push(t[e].id);
return a;
},
setSettingValues: function (t) {
this.setting.set(t);
},
setupSortable: function () {
var t = this,
a = e(".image-gallery-attachments");
a.sortable({
items: ".image-gallery-thumbnail-wrapper",
tolerance: "pointer",
stop: function () {
var n = [];
a.find(".image-gallery-thumbnail-wrapper").each(function () {
var t;
(t = parseInt(e(this).data("postId"), 10)), n.push(t);
}),
t.setSettingValues(n);
},
});
},
})),
(t.controlConstructor["bloglo-gallery"] = t.ImageGalleryControl);
})(wp.customize, jQuery);