11. 2 Xây dựng chức năn kéo thả clone (ok)

C:\xampp\htdocs\test\wp-content\plugins\plugin-name\admin\js\wpf-themplate_ct.js
var WPF;
(function ($, window, document, undefined) {
// Builder Function
WPF = {
prefix: 'wpf_ct_',
template_type: false,
init: function ($options) {
$options = $.extend({
prefix: this.prefix,
template_type: this.template_type
},$options);
this.prefix = $options.prefix;
this.template_type = $options.template_type;
this.bindEvents();
},
bindEvents: function () {
this.Save();
this.InitDraggable();
this.InitSortable();
},
Save: function () {
var self = this;
$('#' + self.prefix + 'submit').click(function (event) {
event.preventDefault();
var $form = $(this).closest('form'),
$inputs = $('.' + self.prefix + 'back_builder').find('input,select,textarea');
$inputs.prop('disabled', true);
setTimeout(function () {
var $data = self.ParseData();
console.log($data);
}, 100);
});
},
ParseData: function () {
var $wrapper = $('#' + WPF.prefix + 'module_content'),
$data = {},
$modules = $wrapper.find('.' + WPF.prefix + 'back_active_module_content');
},
InitDraggable: function () {
var $this = this;
$('.' + $this.prefix + 'back_module_panel .' + $this.prefix + "back_module").draggable({
appendTo: ".wpf_ct_back_row_content",
helper: "clone",
revert: 'invalid',
snapMode: "inner",
connectToSortable: '.' + $this.prefix + "module_holder",
stop: function (event, ui) {
var $item = $(ui.helper[0]), $type = $item.data('type');
if ($('#' + $this.prefix + 'module_content').find('[data-type="' + $type + '"]').length > 0) {
}
}
});
},
InitSortable: function () {
var $this = this;
$('.' + $this.prefix + "module_holder").sortable();
}
}
}(jQuery, window, document));C:\xampp\htdocs\test\wp-content\plugins\plugin-name\admin\class-wpf-admin_ct.php
C:\xampp\htdocs\test\wp-content\plugins\plugin-name\includes\class-wpf-utils_ct.php
Last updated
Was this helpful?