File: /www/wwwroot/www.scdc-marine.com/wp-content/plugins/Heku-Admin-Page/js/heku-setting.js
"use strict";
function add_property(e, t) {
for (var n = 0; n < t.length; n++) {
var i = t[n];
i.enumerable = i.enumerable || !1,
i.configurable = !0,
"value" in i && (i.writable = !0),
Object.defineProperty(e, i.key, i)
}
}
var r = "closed", o = "open",
a = function() {
function e(t) { !
function(e, t) {
if (! (e instanceof t)) throw new TypeError("Cannot call a class as a function")
} (this, e),
this.$el = t,
this.state = r
}
var t, n, a;
return t = e,
(n = [{
key: "bindEvents",
value: function() {
var e = this;
e.$el.find('[data-toggle="column"]').on("click", (function() {
e.toggle(e);
}));
e.$el.find(".add_column_submenu").click((function (t) {
e.addsubMenu();
}));
e.$el.find(".remove-button").click((function (t) {
e.remove();
}));
}
}, {
key: "destroy",
value: function() {
this.$el.remove()
}
}, {
key: "remove",
value: function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 350,
t = this;
this.$el.addClass("deleting").animate({
opacity: 0,
height: 0
},
e, (function() {
t.destroy()
}))
}
}, {
key: "getState",
value: function() {
return this.state
}
}, {
key: "toggle",
value: function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 150;
this.getState() === o ? this.close(e) : this.open(e)
}
}, {
key: "close",
value: function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0;
this.$el.removeClass("opened").find(".heku-column-body").slideUp(e),
this.state = r
}
}, {
key: "open",
value: function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 0;
this.$el.addClass("opened").find(".heku-column-body").slideDown(e),
this.state = o
}
}, {
key: "create",
value: function() {
return this.bindEvents(),this
}
}, {
key: "addsubMenu",
value: function() {
var sub_e = jQuery("#add_new_column_template").find(".heku-setbox-row").clone();
this.$el.find(".heku-column-settings").append(sub_e);
}
}, {
key: "name",
get: function() {
return this.$el.data("column-name")
},
set: function(e) {
this.$el.data("column-name", e)
}
}]) && add_property(t.prototype, n),
a && add_property(t, a),
e
} ();
var u = function() {
function e(t) { !
function(e, t) {
if (! (e instanceof t)) throw new TypeError("Cannot call a class as a function")
} (this, e),
this.form = t,
this.$form = jQuery(t),
this.$column_container = this.$form.find(".heku-columns"),
this.init()
}
var t, n, i;
return t = e,
(n = [{
key: "init",
value: function() {
this.initColumns(), // 初始化
this.bindOrdering(), // 拖动排序
this.bindFormEvents() // 事件触发 定义
}
}, {
key: "bindOrdering",
value: function() {
jQuery(".heku-column-settings").sortable({
connectWith:".heku-column-settings",
items: ".heku-setbox-row",
handle: ".heku-setbox-row-th"
});
this.$column_container.sortable({
items: ".heku-column",
handle: ".column_sort"
});
}
}, {
key: "initColumns",
value: function() {
this.$form.find(".heku-column").each((function() {
var t = jQuery(this),
n = new a(t);
n.bindEvents()
}))
}
}, {
key: "bindFormEvents",
value: function() {
var e = this,
heku_submit = jQuery(".sidebox a.submit, .column-footer a.submit");
heku_submit.on("click", (function() {
e.submitForm();
}));
this.$form.find(".add_column").on("click", (function() {
e.addColumn();
}));
this.$form.find(".clone_separator_button").on("click", (function() {
e.cloneSeparator();
}));
}
}, {
key: "serialize",
value: function() {
var ajax_data = {};
ajax_data['menu'] = [];
ajax_data['submenu'] = {};
ajax_data['setting'] = {};
this.$form.find(".heku-column .heku-column-body").each((function(){
var new_mn0 = [],old_mn1 = [],new_mn2 = [];
old_mn1 = Object.values(this.dataset);
jQuery(this).find(".heku-setbox-row-fields-inner3 .column-menu").each((function(){
new_mn0.push(this.value)
}));
if( old_mn1.length > 5 ){
new_mn2.push(new_mn0[1]);
new_mn2.push(old_mn1[1]);
new_mn2.push(new_mn0[2]);
new_mn2.push(old_mn1[3]);
new_mn2.push(old_mn1[4]);
new_mn2.push(old_mn1[3]);
new_mn2.push(new_mn0[0]);
}else{
new_mn2.push(this.dataset.menu0);
new_mn2.push(this.dataset.menu1);
new_mn2.push(new_mn0[0]);
new_mn2.push(this.dataset.menu3);
new_mn2.push(this.dataset.menu4);
}
ajax_data['menu'].push(new_mn2);
var sub_mn1 = [];
jQuery(this).find(".heku-setbox-row").each((function(){
var sub_mn2 = [];
jQuery(this).find(".column-submenu").each((function(){
sub_mn2.push(this.value)
}));
sub_mn1.push(sub_mn2)
}));
ajax_data['submenu'][this.dataset.menu2] = sub_mn1;
}));
this.$form.find(".heku-setbox-row .heku-setbox-row-fields-inner .menu-setting").each((function(){
ajax_data['setting'][this.name] = this.checked
}));
return ajax_data
}
}, {
key: "submitForm",
value: function() {
var e = this,
ajax_result = jQuery.post(ajaxurl, {
action: "heku_admin_page",
id: "save",
_ajax_nonce: Heku.nonce,
data: this.serialize()
}, (function(ajax_result) {
ajax_result && (ajax_result.success ? (e.showMessage(ajax_result.data, "updated")) : ajax_result.data && e.showMessage(ajax_result.data.message, "notice notice-warning")),window.location.reload();
}), "json");
return ajax_result.fail((function(ajax_result) {
e.showMessage(ajax_result, "notice notice-warning")
})), ajax_result
}
}, {
key: "showMessage",
value: function(e) {
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "updated",
n = jQuery('<div class="ac-message hidden ' + t + '"><p>' + e + "</p></div>");
this.$column_container.find(".ac-message").stop().remove(),
this.$column_container.find(".ac-admin__main").prepend(n),
n.slideDown()
}
}, {
key: "cloneSeparator",
value: function() {
var e = jQuery("#add_new_separator_template").find(".heku-column-separator").clone(),
t = new a(e).create();
return this._addColumnToForm(t)
}
}, {
key: "addColumn",
value: function() {
var e = jQuery("#add_new_column_template").find(".heku-column").clone(),
t = new a(e).create();
return this._addColumnToForm(t)
}
}, {
key: "getTitle",
value: function() {
return this.$form.find('input[name="title"]').val()
}
}, {
key: "getColumnSettings",
value: function() {
return this.$form.find('[name^="columns["]').serialize()
}
}, {
key: "_addColumnToForm",
value: function(e) {
var t = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1];
return this.$column_container.append(e.$el),
t && e.open(),
e.$el.hide().slideDown(),
jQuery("html, body").animate({
scrollTop: e.$el.offset().top - 58
},300),
e
}
}]) && add_property(t.prototype, n),
i && add_property(t, i),
e
}();
var heku_from =jQuery('#heku_listscreen_settings');
var sss = new u(heku_from);