plugin updates

This commit is contained in:
Tony Volpe
2024-07-16 13:57:46 +00:00
parent 41f50eacc4
commit 8f93917880
1529 changed files with 259452 additions and 25451 deletions
@@ -0,0 +1,399 @@
(function ($) {
wpmfAssignModule = {
options: {},
files_selected: [],
/**
* Initialize module related things
*/
initModule: function ($current_frame) {
wpmfAssignModule.options = {
'root': '/',
'showroot': wpmf.l18n.assign_tree_label,
'onclick': function (elem, type, file) {
},
'oncheck': function (elem, checked, type, file) {
},
'usecheckboxes': true, //can be true files dirs or false
'expandSpeed': 500,
'collapseSpeed': 500,
'expandEasing': null,
'collapseEasing': null,
'canselect': true
};
// add Media folder selection button on toolbar
if (!$current_frame.find('.open-popup-tree-multiple').length) {
$current_frame.find('.media-frame-content .media-toolbar-secondary .delete-selected-button').after('<button class="button open-popup-tree-multiple media-button button-large"><span class="material-icons-outlined"> snippet_folder </span>' + wpmf.l18n.assign_tree_label + '</button>');
wpmfAssignModule.treeshowdialog();
if (typeof wpmfFoldersModule.categories[wpmfFoldersModule.last_selected_folder].drive_type !== "undefined" && wpmfFoldersModule.categories[wpmfFoldersModule.last_selected_folder].drive_type !== "") {
$('.open-popup-tree-multiple').addClass('hide');
} else {
$('.open-popup-tree-multiple').removeClass('hide');
}
wpmfFoldersModule.on('changeFolder', function (folder_id) {
if (typeof wpmfFoldersModule.categories[folder_id] !== "undefined" && typeof wpmfFoldersModule.categories[folder_id].drive_type !== "undefined" && wpmfFoldersModule.categories[folder_id].drive_type !== "") {
$('.open-popup-tree-multiple').addClass('hide');
} else {
$('.open-popup-tree-multiple').removeClass('hide');
}
});
}
},
initTree: function () {
$assignimagetree = $('#wpmfjaoassign');
if (!$assignimagetree) {
return;
}
if (wpmfAssignModule.options.showroot !== '') {
var tree_init = '';
tree_init += '<ul class="jaofiletree">';
tree_init += '<li data-id="0" class="directory collapsed selected" data-group="' + wpmf.vars.wpmf_current_userid + '">';
tree_init += '<div class="pure-checkbox">';
tree_init += '<input type="checkbox" id="/" class="wpmf_checkbox_tree" value="wpmf_' + wpmf.vars.root_media_root + '" data-id="' + wpmf.vars.root_media_root + '">';
tree_init += '<label class="checked" for="/">';
tree_init += '<a class="title-folder title-root" data-id="0">' + wpmfAssignModule.options.showroot + '</a>';
tree_init += '</label>';
tree_init += '</div>';
tree_init += '</li>';
tree_init += '</ul>';
tree_init += '<input type="hidden" class="folder_selections_input">';
$assignimagetree.html(tree_init);
}
wpmfAssignModule.openfolderassign(0);
},
/**
* open folder tree by dir name
*/
openfolderassign: function (id) {
if (typeof $assignimagetree === "undefined")
return;
if ($assignimagetree.find('a[data-id="' + id + '"]').closest('li').hasClass('expanded') || $assignimagetree.find('a[data-id="' + id + '"]').closest('li').hasClass('wait')) {
if (typeof callback === 'function')
callback();
return;
}
/* ajax get tree assign */
var ret;
ret = $.ajax({
method: 'POST',
url: ajaxurl,
data: {
id: id,
attachment_id: wpmfFoldersModule.editFileId,
action: 'wpmf',
task: 'get_assign_tree',
wpmf_nonce: wpmf.vars.wpmf_nonce
},
context: $assignimagetree,
dataType: 'json',
beforeSend: function () {
this.find('a[data-id="' + id + '"]').closest('li').addClass('wait');
}
}).done(function (res) {
var selectedId = $('#wpmfjaoassign').find('.directory.selected').data('id');
ret = '<ul class="jaofiletree">';
if (res.status) {
if (typeof res.folders !== "undefined") {
$('.folder_selections_input').val(res.folders);
}
var datas = res.dirs;
if ((!$('.media-frame').hasClass('mode-select') && $('body').hasClass('upload-php')) || !$('body').hasClass('upload-php')) {
if (res.root_check) {
$('.wpmf_checkbox_tree[data-id="' + wpmf.vars.root_media_root + '"]').prop('checked', true);
}
}
for (var ij = 0; ij < datas.length; ij++) {
if (wpmf.vars.root_media_root !== datas[ij].id) {
var classe = 'directory collapsed';
if (parseInt(datas[ij].id) === parseInt(selectedId)) {
classe += ' selected';
}
ret += '<li class="' + classe + '" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" data-group="' + datas[ij].term_group + '">';
if (datas[ij].count_child > 0) {
ret += '<div class="icon-open-close" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '"></div>';
} else {
ret += '<div class="icon-open-close" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" style="opacity:0"></div>';
}
ret += '<div class="pure-checkbox">';
if ($('.media-frame').hasClass('mode-select') && $('body').hasClass('upload-php')) {
ret += '<input type="checkbox" id="wpmf_folder_selection' + datas[ij].id + '" class="wpmf_checkbox_tree" value="wpmf_' + datas[ij].id + '" data-id="' + datas[ij].id + '">';
} else {
if (datas[ij].checked) {
ret += '<input type="checkbox" checked id="wpmf_folder_selection' + datas[ij].id + '" class="wpmf_checkbox_tree" value="wpmf_' + datas[ij].id + '" data-id="' + datas[ij].id + '">';
} else {
ret += '<input type="checkbox" id="wpmf_folder_selection' + datas[ij].id + '" class="wpmf_checkbox_tree" value="wpmf_' + datas[ij].id + '" data-id="' + datas[ij].id + '">';
}
}
if (datas[ij].checked) {
ret += '<label class="check" for="wpmf_folder_selection' + datas[ij].id + '">';
} else {
if (datas[ij].pchecked) {
ret += '<label class="pchecked" for="wpmf_folder_selection' + datas[ij].id + '">';
ret += '<span class="ppp"></span>'
} else {
ret += '<label for="wpmf_folder_selection' + datas[ij].id + '">';
}
}
if (parseInt(datas[ij].id) === parseInt(selectedId)) {
ret += '<i class="zmdi wpmf-zmdi-folder-open"></i>';
} else {
ret += '<i class="zmdi zmdi-folder-outline"></i>';
}
ret += '<a class="title-folder" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '">' + datas[ij].name + '</a>';
ret += '</label>';
ret += '</div';
ret += '</li>';
}
}
}
ret += '</ul>';
this.find('a[data-id="' + id + '"]').closest('li').removeClass('wait').removeClass('collapsed').addClass('expanded');
this.find('a[data-id="' + id + '"]').closest('li').append(ret);
this.find('a[data-id="' + id + '"]').closest('li').children('.jaofiletree').slideDown(wpmfAssignModule.options.expandSpeed, wpmfAssignModule.options.expandEasing,
function () {
$assignimagetree.trigger('afteropen');
$assignimagetree.trigger('afterupdate');
if (typeof callback === 'function')
callback();
});
wpmfAssignModule.seteventsassign();
}).done(function () {
$assignimagetree.trigger('afteropen');
$assignimagetree.trigger('afterupdate');
});
},
/**
* close folder tree by dir name
* @param id
*/
closedirassign: function (id) {
if (typeof $assignimagetree === "undefined") {
return;
}
$assignimagetree.find('a[data-id="' + id + '"]').closest('li').children('.jaofiletree').slideUp(wpmfAssignModule.options.collapseSpeed, wpmfAssignModule.options.collapseEasing, function () {
$(this).remove();
});
$assignimagetree.find('a[data-id="' + id + '"]').closest('li').removeClass('expanded').addClass('collapsed');
wpmfAssignModule.seteventsassign();
/* Trigger custom event */
$assignimagetree.trigger('afterclose');
$assignimagetree.trigger('afterupdate');
},
/**
* init event click to open/close folder tree
*/
seteventsassign: function () {
var $assignimagetree = $('#wpmfjaoassign');
$assignimagetree.find('li a,li .icon-open-close').unbind('click');
//Bind for collapse or expand elements
$assignimagetree.find('li.directory a').bind('click', function (e) {
e.preventDefault();
$assignimagetree.find('li').removeClass('selected');
$assignimagetree.find('i.zmdi').removeClass('wpmf-zmdi-folder-open').addClass("zmdi-folder-outline");
$(this).closest('li').addClass("selected");
$(this).closest('li').find(' > .pure-checkbox i.zmdi').removeClass("zmdi-folder-outline").addClass("wpmf-zmdi-folder-open");
wpmfAssignModule.openfolderassign($(this).attr('data-id'));
});
/* open folder tree use icon */
$assignimagetree.find('li.directory.collapsed .icon-open-close').bind('click', function () {
wpmfAssignModule.openfolderassign($(this).attr('data-id'));
});
/* close folder tree use icon */
$assignimagetree.find('li.directory.expanded .icon-open-close').bind('click', function () {
wpmfAssignModule.closedirassign($(this).attr('data-id'));
});
/* Check/uncheck folder */
$assignimagetree.find('li.directory.expanded .wpmf_checkbox_tree').bind('click', function () {
if ($(this).is(':checked')) {
$(this).closest('.pure-checkbox').find('label').removeClass('pchecked').addClass('checked');
} else {
$(this).closest('.pure-checkbox').find('label').removeClass('checked');
}
});
/* Check/uncheck folder */
$assignimagetree.find('li.directory .wpmf_checkbox_tree').bind('click', function () {
var folders = $('.folder_selections_input').val();
var folders_number;
if (folders != '') {
folders_number = folders.split(',').map(function(item) {
return parseInt(item, 10);
});
} else {
folders_number = [];
}
var id = $(this).data('id');
if ($(this).is(':checked')) {
if (folders_number.indexOf(id) == -1) {
folders_number.push(id);
}
} else {
var index = folders_number.indexOf(id);
if (index > -1) {
folders_number.splice(index, 1);
}
}
$('.folder_selections_input').val(folders_number.join());
});
},
/**
* showdialog
*/
showdialog: function (type) {
showDialog({
title: wpmf.l18n.label_assign_tree,
id: 'ju-dialog',
text: '<div id="wpmfjaoassign" class="wpmflocaltree"></div>',
negative: {
title: wpmf.l18n.cancel
},
positive: {
title: wpmf.l18n.label_apply,
onClick: function () {
wpmfAssignModule.wpmf_set_term(type);
}
}
});
},
/**
* Show dialog for tree
*/
treeshowdialog: function () {
$(document).on('click', '.open-popup-tree, .open-popup-tree-multiple', function () {
var $this = $(this);
if ($('.wpmf-folder_selection').length === 0) {
$('body').append('<div class="wpmf-folder_selection" data-wpmftype="folder_selection" data-timeout="3000" data-html-allowed="true" data-content="' + wpmf.l18n.folder_selection + '"></div>');
}
if ($this.hasClass('open-popup-tree')) {
wpmfAssignModule.showdialog('one');
} else {
wpmfAssignModule.showdialog('multiple');
}
wpmfFoldersModule.editFileId = $('.wpmf_attachment_id').val();
if (typeof wpmfFoldersModule.editFileId === "undefined")
wpmfFoldersModule.editFileId = $('#post_ID').val();
wpmfAssignModule.initTree();
});
},
/**
* Set files to folder
*/
wpmf_set_term: function (type) {
var wpmf_term_ids_check = $('.folder_selections_input').val();
var attachment_ids = [];
if (type === 'multiple') {
attachment_ids = [];
wpmfFoldersModule.getFrame().find('.attachments-browser .attachment.selected').each(function (i, v) {
attachment_ids.push($(v).data('id'));
});
} else {
attachment_ids.push(wpmfFoldersModule.editFileId);
}
$.ajax({
url: ajaxurl,
method: 'POST',
dataType: 'json',
data: {
action: 'wpmf',
task: 'set_object_term',
wpmf_term_ids_check: wpmf_term_ids_check,
attachment_ids: attachment_ids.join(),
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (response) {
if (!response.status) {
return;
}
let snack_msg = wpmf.l18n.folder_selection;
if (wpmf_term_ids_check.length) {
let folders = wpmf_term_ids_check.slice(0, 2);
let fnames = [];
$.each(folders, function () {
if (parseInt(wpmf.vars.root_media_root) !== parseInt(this)) {
fnames.push(wpmfFoldersModule.categories[this].label);
}
});
if (wpmf_term_ids_check.length > 2) {
snack_msg = attachment_ids.length + ' files has moved to "' + fnames.join() + '..."';
} else {
snack_msg = attachment_ids.length + ' files has moved to "' + fnames.join() + '"';
}
}
// Show snackbar
wpmfSnackbarModule.show({
id: 'move_to_multiple_folders',
content: snack_msg,
icon: '<span class="material-icons-outlined wpmf-snack-icon"> snippet_folder </span>',
});
if (response.folders_count.length) {
$.each(response.folders_count, function (i, folders_count) {
var folder_count = folders_count.split('-');
wpmfFoldersModule.categories[folder_count[0]].files_count = parseInt(folder_count[1]);
});
wpmfFoldersModule.trigger('foldersSelection', wpmfFoldersModule.last_selected_folder);
}
if (type === 'multiple') {
$('.mode-select .select-mode-toggle-button').click();
}
wpmfFoldersModule.reloadAttachments();
// Reload the folders to update
wpmfFoldersModule.renderFolders();
}
});
}
};
// Let's initialize WPMF folder tree features
$(document).ready(function () {
// only run in list view and grid view in upload.php page
if (typeof wp === "undefined") {
return;
}
if ((wpmf.vars.wpmf_pagenow === 'upload.php' && !wpmfFoldersModule.page_type) || typeof wp.media === "undefined") {
return;
}
wpmfAssignModule.treeshowdialog();
if (wpmfFoldersModule.page_type !== 'upload-list') {
// Wait for the main wpmf module to be ready
wpmfFoldersModule.on('ready', function ($current_frame) {
wpmfAssignModule.initModule($current_frame);
});
}
});
}(jQuery));
@@ -0,0 +1,133 @@
(function ($) {
$(document).ready(function () {
function wpmfFusionClickHandle() {
$(document).on("click", '.fusion-wpmf-gallery-remove-image', function (e) {
var id = $(this).closest('.wpmf-fusion-image-child').data('id');
var ids = $('.wpmf_fusion_gallery #items').val();
ids = ids.split(',');
var index = ids.indexOf(id);
if (index === -1) {
index = ids.indexOf(id.toString());
}
if (index > -1) {
ids.splice(index, 1);
}
$(this).closest('.wpmf-fusion-image-child').remove();
$('.wpmf_fusion_gallery #items').val(ids.join()).change();
});
$('.wpmf-fusion-images').sortable({
//placeholder: "sortable-placeholder",
update: function () {
var order = [];
$.each($('.wpmf-fusion-image-child'), function (i, val) {
var id = $(this).data('id');
if (order.indexOf(id) === -1) {
order.push(id);
}
});
$('.wpmf_fusion_gallery #items').val(order.join()).change();
}
});
$( ".wpmf-fusion-images" ).disableSelection();
}
wpmfFusionClickHandle();
function wpmf_fusion_gallery_get_images(wrap, params) {
$.ajax({
method: "POST",
dataType: 'json',
url: (typeof fusionAppConfig.ajaxurl !== "undefined") ? fusionAppConfig.ajaxurl : ajaxurl,
data: {
action: "wpmf_fusion_gallery_get_images",
items: params.items
},
beforeSend: function () {
wrap.find('.wpmf-fusion-images').addClass('wpmf-fusion-loading');
},
success: function (res) {
wrap.find('.wpmf-fusion-images').removeClass('wpmf-fusion-loading').html(res.html);
wpmfFusionClickHandle();
}
});
}
$(document).on("click", '.wpmf_avada_select_images', function (e) {
if (typeof frame !== "undefined") {
frame.open();
return;
}
// Create the media frame.
var frame = wp.media({
// Tell the modal to show only images.
library: {
type: 'image'
},
multiple: true,
});
// When an image is selected, run a callback.
frame.on('select', function () {
// Grab the selected attachment.
var attachments = frame.state().get('selection').toJSON();
var old_items = $('.wpmf_fusion_gallery #items').val();
var ids = [];
old_items = old_items.split(',');
if (old_items.length !== 0) {
ids = old_items;
}
$.each(attachments, function (i, v) {
if (ids.indexOf(v.id) === -1) {
ids.push(v.id);
}
});
if (!$('.fusion-builder-live').length) {
var params = {items: ids.join(), orderby: 'post__in', order: 'ASC'};
wpmf_fusion_gallery_get_images($('.wpmf_gallery_select'), params);
}
$('.wpmf_fusion_gallery #items').val(ids.join()).change();
});
frame.open();
});
var wpmfElementSettingsView = FusionPageBuilder.ElementSettingsView;
FusionPageBuilder.ElementSettingsView = FusionPageBuilder.ElementSettingsView.extend({
/**
* Renders the view.
*
* @since 2.0.0
* @return {Object} this
*/
render: function () {
wpmfElementSettingsView.prototype.render.apply(this, arguments);
var element_type = this.model.attributes.element_type;
var params = this.model.attributes.params;
var wrap = this.$el;
if (element_type === 'wpmf_fusion_gallery' && params.items !== '') {
wpmf_fusion_gallery_get_images(wrap, params);
}
return this;
},
optionChanged: function(event) {
wpmfElementSettingsView.prototype.optionChanged.apply(this, arguments);
var wrap = this.$el;
var element_type = this.model.attributes.element_type;
var params = this.model.attributes.params;
var $target = jQuery( event.target ),
$option = $target.closest( '.fusion-builder-option' ),
paramName;
paramName = this.getParamName( $target, $option );
if (element_type === 'wpmf_fusion_gallery') {
if (paramName === 'items' || paramName === 'orderby' || paramName === 'order' ) {
wpmf_fusion_gallery_get_images(wrap, params);
}
}
}
});
});
}(jQuery));
@@ -0,0 +1,27 @@
(function ($) {
$(document).ready(function () {
$(document).on("click", '.wpmf_avada_select_pdf', function (e) {
if (typeof frame !== "undefined") {
frame.open();
return;
}
// Create the media frame.
var frame = wp.media({
// Tell the modal to show only images.
library: {
type: 'application/pdf'
}
});
// When an image is selected, run a callback.
frame.on('select', function () {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first().toJSON();
$('.wpmf_avada_pdf_embed input[name="url"]').val(attachment.url).change();
});
frame.open();
});
});
}(jQuery));
@@ -0,0 +1,25 @@
(function ($) {
$(document).ready(function () {
$(document).on("click", '.wpmf_avada_select_file', function (e) {
if (typeof frame !== "undefined") {
frame.open();
return;
}
// Create the media frame.
var frame = wp.media({
library: {
type: '*'
}
});
// When an image is selected, run a callback.
frame.on('select', function () {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first().toJSON();
$('.wpmf_avada_single_file input[name="url"]').val(attachment.url).change();
});
frame.open();
});
});
}(jQuery));
@@ -0,0 +1,431 @@
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpBlockEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpBlockEditor.InspectorControls,
MediaUpload = wpBlockEditor.MediaUpload,
BlockControls = wpBlockEditor.BlockControls;
var mediaUpload = wpEditor.mediaUpload;
var PanelBody = wpComponents.PanelBody,
SelectControl = wpComponents.SelectControl,
ToolbarGroup = wpComponents.ToolbarGroup,
Button = wpComponents.Button,
IconButton = wpComponents.IconButton,
FormFileUpload = wpComponents.FormFileUpload,
Placeholder = wpComponents.Placeholder;
var wpmfFileDesign = function (_Component) {
_inherits(wpmfFileDesign, _Component);
function wpmfFileDesign() {
_classCallCheck(this, wpmfFileDesign);
var _this = _possibleConstructorReturn(this, (wpmfFileDesign.__proto__ || Object.getPrototypeOf(wpmfFileDesign)).apply(this, arguments));
_this.addFiles = _this.addFiles.bind(_this);
_this.uploadFromFiles = _this.uploadFromFiles.bind(_this);
return _this;
}
/**
* Upload files
*/
_createClass(wpmfFileDesign, [{
key: "uploadFromFiles",
value: function uploadFromFiles(event) {
this.addFiles(event.target.files);
}
/**
* Add files
*/
}, {
key: "addFiles",
value: function addFiles(files) {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
mediaUpload({
filesList: files,
onFileChange: function onFileChange(file) {
if (file.length && file[0] !== null && typeof file[0].id !== "undefined") {
var f = {};
f.title = file[0].title;
f.mime = file[0].mime_type;
f.filesizeInBytes = file[0].media_details.filesize;
f.url = file[0].url;
setAttributes({
id: file[0].id,
file: f
});
}
}
});
}
}, {
key: "render",
value: function render() {
var _props2 = this.props,
attributes = _props2.attributes,
setAttributes = _props2.setAttributes,
className = _props2.className;
var id = attributes.id,
file = attributes.file,
target = attributes.target,
cover = attributes.cover;
var controls = React.createElement(
BlockControls,
null,
id !== 0 && React.createElement(
ToolbarGroup,
null,
React.createElement(MediaUpload, {
onSelect: function onSelect(file) {
return setAttributes({ id: file.id, file: file });
},
render: function render(_ref) {
var open = _ref.open;
return React.createElement(IconButton, {
className: "components-toolbar__control",
label: __('Edit File', 'wpmf'),
icon: "edit",
onClick: open
});
}
})
)
);
var mime = '';
var size = 0;
if (id !== 0) {
var mimetype = file.url.split('.');
var index = mimetype.length - 1;
if (mimetype[index].length > 10) {
mimetype = file.mime.split('/');
index = mimetype.length - 1;
}
if (typeof mimetype !== "undefined" && typeof mimetype[index] !== "undefined") {
mime = mimetype[index].toUpperCase();
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB';
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB';
}
}
if (typeof cover === "undefined" && id == 0) {
return React.createElement(
Placeholder,
{
icon: "media-archive",
label: __('WPMF Media Download', 'wpmf'),
instructions: wpmf.l18n.media_download_desc,
className: className
},
React.createElement(
FormFileUpload,
{
islarge: "true",
className: "is-primary editor-media-placeholder__button wpmf_btn_upload_img",
onChange: this.uploadFromFiles,
accept: "*"
},
wpmf.l18n.upload
),
React.createElement(MediaUpload, {
onSelect: function onSelect(file) {
return setAttributes({ id: file.id, file: file });
},
accept: "*",
allowedTypes: "*",
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(
Button,
{
islarge: "true",
className: "is-tertiary editor-media-placeholder__button wpmfLibrary",
onClick: open
},
wpmf.l18n.media_folder
);
}
})
);
}
return React.createElement(
Fragment,
null,
typeof cover !== "undefined" && React.createElement(
"div",
{ className: "wpmf-cover" },
React.createElement("img", { src: cover })
),
controls,
typeof cover === "undefined" && id !== 0 && React.createElement(
"div",
{ className: "wp-block-shortcode" },
React.createElement(
"div",
{ className: "wpmf-file-design-block" },
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('File Design Settings', 'wpmf') },
React.createElement(SelectControl, {
label: __('Target', 'wpmf'),
value: target,
options: [{ label: __('Same Window', 'wpmf'), value: '' }, { label: __('New Window', 'wpmf'), value: '_blank' }],
onChange: function onChange(value) {
return setAttributes({ target: value });
}
})
)
),
React.createElement(
"div",
{ "data-id": id },
React.createElement(
"a",
{
className: "wpmf-defile",
href: file.url,
download: true,
rel: "noopener noreferrer",
target: target, "data-id": id },
React.createElement(
"div",
{ className: "wpmf-defile-title" },
React.createElement(
"b",
null,
file.title
)
),
React.createElement(
"span",
{ className: "wpmf-single-infos" },
React.createElement(
"b",
null,
__('Size: ', 'wpmf'),
" "
),
size,
React.createElement(
"b",
null,
__(' Format: ', 'wpmf'),
" "
)
),
mime
)
)
)
)
);
}
}]);
return wpmfFileDesign;
}(Component);
var fileDesignAttrs = {
id: {
type: 'number',
default: 0
},
file: {
type: 'object',
default: {}
},
target: {
type: 'string',
default: ''
},
cover: {
type: 'string',
source: 'attribute',
selector: 'img',
attribute: 'src'
}
};
registerBlockType('wpmf/filedesign', {
title: __('WPMF Media Download', 'wpmf'),
icon: 'media-archive',
category: 'wp-media-folder',
example: {
attributes: {
cover: wpmf_filedesign_blocks.vars.block_cover
}
},
attributes: fileDesignAttrs,
edit: wpmfFileDesign,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var id = attributes.id,
file = attributes.file,
target = attributes.target;
var mime = '';
var size = 0;
if (id !== 0) {
var mimetype = file.url.split('.');
var index = mimetype.length - 1;
if (mimetype[index].length > 10) {
mimetype = file.mime.split('/');
index = mimetype.length - 1;
}
if (typeof mimetype !== "undefined" && typeof mimetype[index] !== "undefined") {
mime = mimetype[index].toUpperCase();
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB';
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB';
}
}
return React.createElement(
"div",
{ "data-id": id },
React.createElement(
"a",
{
className: "wpmf-defile",
href: file.url,
download: true,
rel: "noopener noreferrer",
target: target, "data-id": id },
React.createElement(
"div",
{ className: "wpmf-defile-title" },
React.createElement(
"b",
null,
file.title
)
),
React.createElement(
"span",
{ className: "wpmf-single-infos" },
React.createElement(
"b",
null,
__('Size: ', 'wpmf'),
" "
),
size,
React.createElement(
"b",
null,
__(' Format: ', 'wpmf'),
" "
)
),
mime
)
);
},
deprecated: [{
attributes: fileDesignAttrs,
save: function save(_ref4) {
var attributes = _ref4.attributes;
var id = attributes.id,
file = attributes.file,
target = attributes.target;
var mime = '';
var size = 0;
if (id !== 0) {
var mimetype = file.mime.split('/');
if (typeof mimetype !== "undefined" && typeof mimetype[1] !== "undefined") {
mime = mimetype[1].toUpperCase();
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB';
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB';
}
}
return React.createElement(
"div",
{ "data-id": id },
React.createElement(
"a",
{
className: "wpmf-defile",
href: file.url,
download: true,
target: target, "data-id": id },
React.createElement(
"div",
{ className: "wpmf-defile-title" },
React.createElement(
"b",
null,
file.title
)
),
React.createElement(
"span",
{ className: "wpmf-single-infos" },
React.createElement(
"b",
null,
__('Size: ', 'wpmf'),
" "
),
size,
React.createElement(
"b",
null,
__(' Format: ', 'wpmf'),
" "
)
),
mime
)
);
}
}]
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.blockEditor, wp.components);
@@ -0,0 +1,285 @@
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpBlockEditor, wpComponents) {
const {__} = wpI18n;
const {Component, Fragment} = wpElement;
const {registerBlockType} = wpBlocks;
const {InspectorControls, MediaUpload, BlockControls} = wpBlockEditor;
const {mediaUpload} = wpEditor;
const {PanelBody, SelectControl, ToolbarGroup, Button, IconButton, FormFileUpload, Placeholder} = wpComponents;
class wpmfFileDesign extends Component {
constructor() {
super(...arguments);
this.addFiles = this.addFiles.bind(this);
this.uploadFromFiles = this.uploadFromFiles.bind(this);
}
/**
* Upload files
*/
uploadFromFiles(event) {
this.addFiles(event.target.files);
}
/**
* Add files
*/
addFiles(files) {
const {attributes, setAttributes} = this.props;
mediaUpload({
filesList: files,
onFileChange: (file) => {
if (file.length && file[0] !== null && typeof file[0].id !== "undefined") {
let f = {};
f.title = file[0].title;
f.mime = file[0].mime_type;
f.filesizeInBytes = file[0].media_details.filesize;
f.url = file[0].url;
setAttributes({
id: file[0].id,
file: f
});
}
}
});
}
render() {
const {attributes, setAttributes, className} = this.props;
const {id, file, target, cover} = attributes;
const controls = (
<BlockControls>
{id !== 0 && (
<ToolbarGroup>
<MediaUpload
onSelect={(file) => setAttributes({id: file.id, file: file})}
render={({open}) => (
<IconButton
className="components-toolbar__control"
label={__('Edit File', 'wpmf')}
icon="edit"
onClick={open}
/>
)}
/>
</ToolbarGroup>
)}
</BlockControls>
);
let mime = '';
let size = 0;
if (id !== 0) {
let mimetype = file.url.split('.');
let index = mimetype.length - 1;
if (mimetype[index].length > 10) {
mimetype = file.mime.split('/');
index = mimetype.length - 1;
}
if (typeof mimetype !== "undefined" && typeof mimetype[index] !== "undefined") {
mime = mimetype[index].toUpperCase()
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB'
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB'
}
}
if (typeof cover === "undefined" && id == 0) {
return (
<Placeholder
icon="media-archive"
label={__('WPMF Media Download', 'wpmf')}
instructions={wpmf.l18n.media_download_desc}
className={className}
>
<FormFileUpload
islarge="true"
className="is-primary editor-media-placeholder__button wpmf_btn_upload_img"
onChange={this.uploadFromFiles}
accept="*"
>
{wpmf.l18n.upload}
</FormFileUpload>
<MediaUpload
onSelect={(file) => setAttributes({id: file.id, file: file})}
accept="*"
allowedTypes="*"
render={({open}) => (
<Button
islarge="true"
className="is-tertiary editor-media-placeholder__button wpmfLibrary"
onClick={open}
>
{wpmf.l18n.media_folder}
</Button>
)}
/>
</Placeholder>
);
}
return (
<Fragment>
{
typeof cover !== "undefined" && <div className="wpmf-cover"><img src={cover} /></div>
}
{controls}
{
(typeof cover === "undefined" && id !== 0) && <div className="wp-block-shortcode">
<div className="wpmf-file-design-block">
<InspectorControls>
<PanelBody title={__('File Design Settings', 'wpmf')}>
<SelectControl
label={__('Target', 'wpmf')}
value={target}
options={[
{label: __('Same Window', 'wpmf'), value: ''},
{label: __('New Window', 'wpmf'), value: '_blank'}
]}
onChange={(value) => setAttributes({target: value})}
/>
</PanelBody>
</InspectorControls>
<div data-id={id}>
<a
className="wpmf-defile"
href={file.url}
download
rel="noopener noreferrer"
target={target} data-id={id}>
<div className="wpmf-defile-title"><b>{file.title}</b></div>
<span className="wpmf-single-infos">
<b>{__('Size: ', 'wpmf')} </b>{size}
<b>{__(' Format: ', 'wpmf')} </b></span>{mime}
</a>
</div>
</div>
</div>
}
</Fragment>
);
}
}
const fileDesignAttrs = {
id: {
type: 'number',
default: 0
},
file: {
type: 'object',
default: {},
},
target: {
type: 'string',
default: '',
},
cover: {
type: 'string',
source: 'attribute',
selector: 'img',
attribute: 'src',
}
};
registerBlockType(
'wpmf/filedesign', {
title: __('WPMF Media Download', 'wpmf'),
icon: 'media-archive',
category: 'wp-media-folder',
example: {
attributes: {
cover: wpmf_filedesign_blocks.vars.block_cover
}
},
attributes: fileDesignAttrs,
edit: wpmfFileDesign,
save: ({attributes}) => {
const {id, file, target} = attributes;
let mime = '';
let size = 0;
if (id !== 0) {
let mimetype = file.url.split('.');
let index = mimetype.length - 1;
if (mimetype[index].length > 10) {
mimetype = file.mime.split('/');
index = mimetype.length - 1;
}
if (typeof mimetype !== "undefined" && typeof mimetype[index] !== "undefined") {
mime = mimetype[index].toUpperCase()
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB'
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB'
}
}
return <div data-id={id}>
<a
className="wpmf-defile"
href={file.url}
download
rel="noopener noreferrer"
target={target} data-id={id}>
<div className="wpmf-defile-title"><b>{file.title}</b></div>
<span className="wpmf-single-infos">
<b>{__('Size: ', 'wpmf')} </b>{size}
<b>{__(' Format: ', 'wpmf')} </b></span>{mime}
</a>
</div>;
},
deprecated: [
{
attributes: fileDesignAttrs,
save: ({attributes}) => {
const {id, file, target} = attributes;
let mime = '';
let size = 0;
if (id !== 0) {
let mimetype = file.mime.split('/');
if (typeof mimetype !== "undefined" && typeof mimetype[1] !== "undefined") {
mime = mimetype[1].toUpperCase()
}
if (file.filesizeInBytes < 1024 * 1024) {
size = file.filesizeInBytes / 1024;
size = size.toFixed(1);
size += ' kB'
} else if (file.filesizeInBytes > 1024 * 1024) {
size = file.filesizeInBytes / (1024 * 1024);
size = size.toFixed(1);
size += ' MB'
}
}
return <div data-id={id}>
<a
className="wpmf-defile"
href={file.url}
download
target={target} data-id={id}>
<div className="wpmf-defile-title"><b>{file.title}</b></div>
<span className="wpmf-single-infos">
<b>{__('Size: ', 'wpmf')} </b>{size}
<b>{__(' Format: ', 'wpmf')} </b></span>{mime}
</a>
</div>;
},
}
]
}
);
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.blockEditor, wp.components);
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@@ -0,0 +1,238 @@
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpEditor.InspectorControls,
MediaUpload = wpEditor.MediaUpload,
BlockControls = wpEditor.BlockControls,
BlockAlignmentToolbar = wpEditor.BlockAlignmentToolbar;
var PanelBody = wpComponents.PanelBody,
SelectControl = wpComponents.SelectControl,
Toolbar = wpComponents.Toolbar,
Button = wpComponents.Button,
IconButton = wpComponents.IconButton;
var wpmfImageLightbox = function (_Component) {
_inherits(wpmfImageLightbox, _Component);
function wpmfImageLightbox() {
_classCallCheck(this, wpmfImageLightbox);
return _possibleConstructorReturn(this, (wpmfImageLightbox.__proto__ || Object.getPrototypeOf(wpmfImageLightbox)).apply(this, arguments));
}
_createClass(wpmfImageLightbox, [{
key: "render",
value: function render() {
var _props = this.props,
attributes = _props.attributes,
setAttributes = _props.setAttributes;
var image = attributes.image,
id = attributes.id,
size = attributes.size,
url = attributes.url,
lightbox_size = attributes.lightbox_size,
lightbox_url = attributes.lightbox_url,
align = attributes.align;
var list_sizes = Object.keys(wpmf_lightbox_blocks.vars.sizes).map(function (key, label) {
return {
label: wpmf_lightbox_blocks.vars.sizes[key],
value: key
};
});
var controls = React.createElement(
BlockControls,
null,
id !== 0 && React.createElement(
Toolbar,
null,
React.createElement(BlockAlignmentToolbar, { value: align,
onChange: function onChange(align) {
return setAttributes({ align: align });
} }),
React.createElement(MediaUpload, {
onSelect: function onSelect(img) {
setAttributes({
id: parseInt(img.id),
image: img,
url: img.url,
lightbox_url: img.url
});
},
accept: "image/*",
allowedTypes: 'image',
render: function render(_ref) {
var open = _ref.open;
return React.createElement(IconButton, {
className: "components-toolbar__control",
label: __('Change Image', 'wpmf'),
icon: "edit",
onClick: open
});
}
})
)
);
return React.createElement(
Fragment,
null,
controls,
React.createElement(
"div",
{ className: "wp-block-shortcode" },
id !== 0 && React.createElement(
"div",
{ className: "wpmf-image-lightbox-block" },
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('PDF Settings', 'wpmf') },
React.createElement(SelectControl, {
label: __('Image size', 'wpmf'),
value: size,
options: list_sizes,
onChange: function onChange(value) {
setAttributes({ size: value, url: image.sizes[value].url });
}
}),
React.createElement(SelectControl, {
label: __('Lightbox size', 'wpmf'),
value: lightbox_size,
options: list_sizes,
onChange: function onChange(value) {
return setAttributes({
lightbox_size: value,
lightbox_url: image.sizes[value].url
});
}
})
)
),
React.createElement(
"a",
null,
React.createElement("img", { src: url, "data-wpmflightbox": "1",
className: "align" + align + " size-" + size + " wp-image-" + id,
"data-wpmf_size_lightbox": lightbox_size,
"data-wpmf_image_lightbox": lightbox_url })
)
),
id === 0 && React.createElement(MediaUpload, {
onSelect: function onSelect(img) {
setAttributes({
id: parseInt(img.id),
image: img,
url: img.url,
lightbox_url: img.url
});
},
accept: "image/*",
allowedTypes: 'image',
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(
Button,
{
isLarge: true,
className: "editor-media-placeholder__button wpmf-pdf-button",
onClick: open
},
__('Add image', 'wpmf')
);
}
})
)
);
}
}]);
return wpmfImageLightbox;
}(Component);
registerBlockType('wpmf/image-lightbox', {
title: wpmf_lightbox_blocks.l18n.block_image_lightbox_title,
icon: 'format-image',
category: 'wp-media-folder',
attributes: {
image: {
type: 'object',
default: {}
},
link_to: {
type: 'string',
default: 'full'
},
id: {
type: 'number',
default: 0
},
size: {
type: 'string',
default: 'full'
},
url: {
type: 'string',
default: ''
},
lightbox_size: {
type: 'string',
default: 'full'
},
lightbox_url: {
type: 'string',
default: ''
},
align: {
type: 'string',
default: 'center'
}
},
edit: wpmfImageLightbox,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var id = attributes.id,
size = attributes.size,
url = attributes.url,
lightbox_size = attributes.lightbox_size,
lightbox_url = attributes.lightbox_url,
align = attributes.align;
return React.createElement(
"a",
{className: "align" + align},
React.createElement("img", { src: url, "data-wpmflightbox": "1", className: "align" + align + " size-" + size + " wp-image-" + id,
"data-wpmf_size_lightbox": lightbox_size,
"data-wpmf_image_lightbox": lightbox_url })
);
},
getEditWrapperProps: function getEditWrapperProps(attributes) {
var align = attributes.align;
var props = { 'data-resized': true };
if ('left' === align || 'right' === align || 'center' === align) {
props['data-align'] = align;
}
return props;
}
});
})(wp.i18n, wp.blocks, wp.element, wp.blockEditor, wp.components);
@@ -0,0 +1,182 @@
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpComponents) {
const {__} = wpI18n;
const {Component, Fragment} = wpElement;
const {registerBlockType} = wpBlocks;
const {InspectorControls, MediaUpload, BlockControls, BlockAlignmentToolbar} = wpEditor;
const {PanelBody, SelectControl, Toolbar, Button, IconButton} = wpComponents;
class wpmfImageLightbox extends Component {
constructor() {
super(...arguments);
}
render() {
const {attributes, setAttributes} = this.props;
const {image, id, size, url, lightbox_size, lightbox_url, align} = attributes;
const list_sizes = Object.keys(wpmf_lightbox_blocks.vars.sizes).map((key, label) => {
return {
label: wpmf_lightbox_blocks.vars.sizes[key],
value: key
}
});
const controls = (
<BlockControls>
{(id !== 0) && (
<Toolbar>
<BlockAlignmentToolbar value={align}
onChange={(align) => setAttributes({align: align})}/>
<MediaUpload
onSelect={(img) => {
setAttributes({
id: parseInt(img.id),
image: img,
url: img.url,
lightbox_url: img.url
})
}}
accept="image/*"
allowedTypes={'image'}
render={({open}) => {
return (
<IconButton
className="components-toolbar__control"
label={__('Change Image', 'wpmf')}
icon="edit"
onClick={open}
/>
)
}}
/>
</Toolbar>
)}
</BlockControls>
);
return (
<Fragment>
{controls}
<div className="wp-block-shortcode">
{
(id !== 0) && <div className="wpmf-image-lightbox-block">
<InspectorControls>
<PanelBody title={__('PDF Settings', 'wpmf')}>
<SelectControl
label={__('Image size', 'wpmf')}
value={size}
options={list_sizes}
onChange={(value) => {
setAttributes({size: value, url: image.sizes[value].url})
}}
/>
<SelectControl
label={__('Lightbox size', 'wpmf')}
value={lightbox_size}
options={list_sizes}
onChange={(value) => setAttributes({
lightbox_size: value,
lightbox_url: image.sizes[value].url
})}
/>
</PanelBody>
</InspectorControls>
<a className={`align${align}`}>
<img src={url} data-wpmflightbox="1"
className={`align${align} size-${size} wp-image-${id}`}
data-wpmf_size_lightbox={lightbox_size}
data-wpmf_image_lightbox={lightbox_url}/>
</a>
</div>
}
{
(id === 0) && <MediaUpload
onSelect={(img) => {
setAttributes({
id: parseInt(img.id),
image: img,
url: img.url,
lightbox_url: img.url
})
}}
accept="image/*"
allowedTypes={'image'}
render={({open}) => {
return (
<Button
isLarge
className="editor-media-placeholder__button wpmf-pdf-button"
onClick={open}
>
{__('Add image', 'wpmf')}
</Button>
)
}}
/>
}
</div>
</Fragment>
);
}
}
registerBlockType(
'wpmf/image-lightbox', {
title: wpmf_lightbox_blocks.l18n.block_image_lightbox_title,
icon: 'format-image',
category: 'wp-media-folder',
attributes: {
image: {
type: 'object',
default: {}
},
link_to: {
type: 'string',
default: 'full',
},
id: {
type: 'number',
default: 0
},
size: {
type: 'string',
default: 'full',
},
url: {
type: 'string',
default: '',
},
lightbox_size: {
type: 'string',
default: 'full',
},
lightbox_url: {
type: 'string',
default: '',
},
align: {
type: 'string',
default: 'center'
}
},
edit: wpmfImageLightbox,
save: ({attributes}) => {
const {id, size, url, lightbox_size, lightbox_url, align} = attributes;
return <a className={`align${align}`}><img src={url} data-wpmflightbox="1" className={`align${align} size-${size} wp-image-${id}`}
data-wpmf_size_lightbox={lightbox_size}
data-wpmf_image_lightbox={lightbox_url}/></a>;
},
getEditWrapperProps(attributes) {
const {align} = attributes;
const props = {'data-resized': true};
if ('left' === align || 'right' === align || 'center' === align) {
props['data-align'] = align;
}
return props;
}
}
);
})(wp.i18n, wp.blocks, wp.element, wp.blockEditor, wp.components);
@@ -0,0 +1,277 @@
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpBlockEditor, wpComponents) {
var __ = wpI18n.__;
var Component = wpElement.Component,
Fragment = wpElement.Fragment;
var registerBlockType = wpBlocks.registerBlockType;
var InspectorControls = wpBlockEditor.InspectorControls,
MediaUpload = wpBlockEditor.MediaUpload,
BlockControls = wpBlockEditor.BlockControls;
var PanelBody = wpComponents.PanelBody,
SelectControl = wpComponents.SelectControl,
ToolbarGroup = wpComponents.ToolbarGroup,
TextControl = wpComponents.TextControl,
Button = wpComponents.Button,
IconButton = wpComponents.IconButton,
Placeholder = wpComponents.Placeholder;
var $ = jQuery;
var wpmfPdfEmbed = function (_Component) {
_inherits(wpmfPdfEmbed, _Component);
function wpmfPdfEmbed() {
_classCallCheck(this, wpmfPdfEmbed);
return _possibleConstructorReturn(this, (wpmfPdfEmbed.__proto__ || Object.getPrototypeOf(wpmfPdfEmbed)).apply(this, arguments));
}
_createClass(wpmfPdfEmbed, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _props = this.props,
attributes = _props.attributes,
clientId = _props.clientId;
var id = attributes.id,
embed = attributes.embed,
target = attributes.target,
width = attributes.width,
height = attributes.height;
this.doPdfEmbed(id, embed, target, width, height, clientId);
}
}, {
key: 'componentDidUpdate',
value: function componentDidUpdate(prevProps) {
var _props2 = this.props,
attributes = _props2.attributes,
clientId = _props2.clientId;
var id = attributes.id,
embed = attributes.embed,
target = attributes.target,
width = attributes.width,
height = attributes.height;
if (attributes.embed != prevProps.attributes.embed || attributes.id != prevProps.attributes.id || attributes.width != prevProps.attributes.width || attributes.height != prevProps.attributes.height) {
this.doPdfEmbed(id, embed, target, width, height, clientId);
}
}
}, {
key: 'doPdfEmbed',
value: function doPdfEmbed(id, embed, target, width, height, clientId) {
var $container = $('#block-' + clientId + ' .wpmf_block_pdf_wrap');
fetch(wpmf_pdf_blocks.vars.ajaxurl + ('?action=wpmf_load_pdf_embed&id=' + id + '&embed=' + embed + '&target=' + target + '&width=' + width + '&height=' + height + '&wpmf_nonce=' + wpmf_pdf_blocks.vars.wpmf_nonce)).then(function (res) {
return res.json();
}).then(function (result) {
if (result.status) {
$container.html(result.html);
}
},
// errors
function (error) {});
}
}, {
key: 'render',
value: function render() {
var _props3 = this.props,
attributes = _props3.attributes,
setAttributes = _props3.setAttributes,
className = _props3.className;
var id = attributes.id,
embed = attributes.embed,
target = attributes.target,
width = attributes.width,
height = attributes.height;
var controls = React.createElement(
BlockControls,
null,
id !== 0 && React.createElement(
ToolbarGroup,
null,
React.createElement(MediaUpload, {
onSelect: function onSelect(file) {
return setAttributes({ id: parseInt(file.id) });
},
accept: 'application/pdf',
allowedTypes: 'application/pdf',
render: function render(_ref) {
var open = _ref.open;
return React.createElement(IconButton, {
className: 'components-toolbar__control wpmf-pdf-button',
label: __('Edit', 'wpmf'),
icon: 'edit',
onClick: open
});
}
})
)
);
var pdf_shortcode = '[wpmfpdf';
pdf_shortcode += ' id="' + id + '"';
pdf_shortcode += ' embed="' + embed + '"';
pdf_shortcode += ' target="' + target + '"';
if (width !== '') {
pdf_shortcode += ' width="' + width + '"';
}
if (height !== '') {
pdf_shortcode += ' height="' + height + '"';
}
pdf_shortcode += ']';
if (id == 0) {
return React.createElement(
Placeholder,
{
icon: 'pdf',
label: __('WP Media Folder PDF Embed', 'wpmf'),
instructions: __('Select a PDF file from your media library.', 'wpmf'),
className: className
},
React.createElement(MediaUpload, {
onSelect: function onSelect(file) {
return setAttributes({ id: parseInt(file.id) });
},
accept: 'application/pdf',
allowedTypes: 'application/pdf',
render: function render(_ref2) {
var open = _ref2.open;
return React.createElement(
Button,
{
islarge: 'true',
className: 'is-tertiary editor-media-placeholder__button wpmfLibrary',
onClick: open
},
__('Add PDF', 'wpmf')
);
}
})
);
}
return React.createElement(
Fragment,
null,
React.createElement(
'div',
{ className: 'wp-block-shortcode' },
id !== 0 && React.createElement(
'div',
{ className: 'wpmf-pdf-block' },
React.createElement(
InspectorControls,
null,
React.createElement(
PanelBody,
{ title: __('PDF Settings', 'wpmf') },
React.createElement(SelectControl, {
label: __('Embed', 'wpmf'),
value: embed,
options: [{ label: __('On', 'wpmf'), value: 1 }, { label: __('Off', 'wpmf'), value: 0 }],
onChange: function onChange(value) {
return setAttributes({ embed: parseInt(value) });
}
}),
React.createElement(SelectControl, {
label: __('Target', 'wpmf'),
value: target,
options: [{ label: __('Same Window', 'wpmf'), value: '' }, { label: __('New Window', 'wpmf'), value: '_blank' }],
onChange: function onChange(value) {
return setAttributes({ target: value });
}
}),
React.createElement(TextControl, {
label: __('Width', 'wpmf'),
value: width,
onChange: function onChange(value) {
return setAttributes({ width: value });
}
}),
React.createElement(TextControl, {
className: 'wpmf_pdf_embed_shortcode_input',
label: __('Height', 'wpmf'),
value: height,
onChange: function onChange(value) {
return setAttributes({ height: value });
}
})
)
),
React.createElement(TextControl, {
value: pdf_shortcode,
className: 'wpmf_pdf_value',
autoComplete: 'off',
readOnly: true
}),
id !== 0 && React.createElement('div', { className: 'wpmf_block_pdf_wrap' })
)
),
controls
);
}
}]);
return wpmfPdfEmbed;
}(Component);
registerBlockType('wpmf/pdfembed', {
title: wpmf_pdf_blocks.l18n.block_pdf_title,
icon: 'media-code',
category: 'wp-media-folder',
attributes: {
id: {
type: 'number',
default: 0
},
embed: {
type: 'number',
default: 1
},
target: {
type: 'string',
default: ''
},
width: {
type: 'string',
default: ''
},
height: {
type: 'string',
default: ''
}
},
edit: wpmfPdfEmbed,
save: function save(_ref3) {
var attributes = _ref3.attributes;
var id = attributes.id,
embed = attributes.embed,
target = attributes.target,
width = attributes.width,
height = attributes.height;
var pdf_shortcode = '[wpmfpdf';
pdf_shortcode += ' id="' + id + '"';
pdf_shortcode += ' embed="' + embed + '"';
pdf_shortcode += ' target="' + target + '"';
if (width !== '') {
pdf_shortcode += ' width="' + width + '"';
}
if (height !== '') {
pdf_shortcode += ' height="' + height + '"';
}
pdf_shortcode += ']';
return pdf_shortcode;
}
});
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.blockEditor, wp.components);
@@ -0,0 +1,210 @@
(function (wpI18n, wpBlocks, wpElement, wpEditor, wpBlockEditor, wpComponents) {
const {__} = wpI18n;
const {Component, Fragment} = wpElement;
const {registerBlockType} = wpBlocks;
const {InspectorControls, MediaUpload, BlockControls} = wpBlockEditor;
const {PanelBody, SelectControl, ToolbarGroup, TextControl, Button, IconButton, Placeholder} = wpComponents;
const $ = jQuery;
class wpmfPdfEmbed extends Component {
constructor() {
super(...arguments);
}
componentDidMount() {
const {attributes, clientId} = this.props;
const {id, embed, target, width, height} = attributes;
this.doPdfEmbed(id, embed, target, width, height, clientId);
}
componentDidUpdate(prevProps) {
const {attributes, clientId} = this.props;
const {id, embed, target, width, height} = attributes;
if (attributes.embed != prevProps.attributes.embed || attributes.id != prevProps.attributes.id || attributes.width != prevProps.attributes.width || attributes.height != prevProps.attributes.height) {
this.doPdfEmbed(id, embed, target, width, height, clientId);
}
}
doPdfEmbed(id, embed, target, width, height, clientId) {
let $container = $(`#block-${clientId} .wpmf_block_pdf_wrap`);
fetch(wpmf_pdf_blocks.vars.ajaxurl + `?action=wpmf_load_pdf_embed&id=${id}&embed=${embed}&target=${target}&width=${width}&height=${height}&wpmf_nonce=${wpmf_pdf_blocks.vars.wpmf_nonce}`)
.then(res => res.json())
.then(
(result) => {
if (result.status) {
$container.html(result.html);
}
},
// errors
(error) => {
}
);
}
render() {
const {attributes, setAttributes, className} = this.props;
const {id, embed, target, width, height} = attributes;
const controls = (
<BlockControls>
{id !== 0 && (
<ToolbarGroup>
<MediaUpload
onSelect={(file) => setAttributes({id: parseInt(file.id)})}
accept="application/pdf"
allowedTypes={'application/pdf'}
render={({open}) => (
<IconButton
className="components-toolbar__control wpmf-pdf-button"
label={__('Edit', 'wpmf')}
icon="edit"
onClick={open}
/>
)}
/>
</ToolbarGroup>
)}
</BlockControls>
);
let pdf_shortcode = '[wpmfpdf';
pdf_shortcode += ' id="' + id + '"';
pdf_shortcode += ' embed="' + embed + '"';
pdf_shortcode += ' target="' + target + '"';
if (width !== '') {
pdf_shortcode += ' width="' + width + '"';
}
if (height !== '') {
pdf_shortcode += ' height="' + height + '"';
}
pdf_shortcode += ']';
if (id == 0) {
return (
<Placeholder
icon="pdf"
label={__('WP Media Folder PDF Embed', 'wpmf')}
instructions={__('Select a PDF file from your media library.', 'wpmf')}
className={className}
>
<MediaUpload
onSelect={(file) => setAttributes({id: parseInt(file.id)})}
accept="application/pdf"
allowedTypes={'application/pdf'}
render={({open}) => (
<Button
islarge="true"
className="is-tertiary editor-media-placeholder__button wpmfLibrary"
onClick={open}
>
{__('Add PDF', 'wpmf')}
</Button>
)}
/>
</Placeholder>
);
}
return (
<Fragment>
<div className="wp-block-shortcode">
{
(id !== 0) && <div className="wpmf-pdf-block">
<InspectorControls>
<PanelBody title={__('PDF Settings', 'wpmf')}>
<SelectControl
label={__('Embed', 'wpmf')}
value={embed}
options={[
{label: __('On', 'wpmf'), value: 1},
{label: __('Off', 'wpmf'), value: 0}
]}
onChange={(value) => setAttributes({embed: parseInt(value)})}
/>
<SelectControl
label={__('Target', 'wpmf')}
value={target}
options={[
{label: __('Same Window', 'wpmf'), value: ''},
{label: __('New Window', 'wpmf'), value: '_blank'}
]}
onChange={(value) => setAttributes({target: value})}
/>
<TextControl
label={__('Width', 'wpmf')}
value={ width }
onChange={ ( value ) => setAttributes({width: value})}
/>
<TextControl
className="wpmf_pdf_embed_shortcode_input"
label={__('Height', 'wpmf')}
value={ height }
onChange={ ( value ) => setAttributes({height: value})}
/>
</PanelBody>
</InspectorControls>
<TextControl
value={pdf_shortcode}
className="wpmf_pdf_value"
autoComplete="off"
readOnly
/>
{
(id !== 0) && <div className="wpmf_block_pdf_wrap"></div>
}
</div>
}
</div>
{controls}
</Fragment>
);
}
}
registerBlockType(
'wpmf/pdfembed', {
title: wpmf_pdf_blocks.l18n.block_pdf_title,
icon: 'media-code',
category: 'wp-media-folder',
attributes: {
id: {
type: 'number',
default: 0
},
embed: {
type: 'number',
default: 1,
},
target: {
type: 'string',
default: '',
},
width: {
type: 'string',
default: ''
},
height: {
type: 'string',
default: ''
}
},
edit: wpmfPdfEmbed,
save: ({attributes}) => {
const {id, embed, target, width, height} = attributes;
let pdf_shortcode = '[wpmfpdf';
pdf_shortcode += ' id="' + id + '"';
pdf_shortcode += ' embed="' + embed + '"';
pdf_shortcode += ' target="' + target + '"';
if (width !== '') {
pdf_shortcode += ' width="' + width + '"';
}
if (height !== '') {
pdf_shortcode += ' height="' + height + '"';
}
pdf_shortcode += ']';
return pdf_shortcode;
}
}
);
})(wp.i18n, wp.blocks, wp.element, wp.editor, wp.blockEditor, wp.components);
@@ -0,0 +1,774 @@
.wpmfLibrary {
margin-right: 6px !important;
}
.wpmf-gallery-list-items {
display: flex;
flex-wrap: wrap;
list-style: none !important;
margin: 0 auto !important;
}
.wpmf-gallery-block {
position: relative !important;
margin-bottom: 25px;
width: 100%;
}
.alignleft .wpmf-gallery-block, .alignright .wpmf-gallery-block, .aligncenter .wpmf-gallery-block {
width: 620px!important;
}
.aligncenter .wpmf-gallery-block {
margin-right: auto!important;
margin-left: auto!important;
}
.wpmf-gallery-block-item.is-transient img {
opacity: 0.3;
}
.wpmf-gallery-block-item.is-transient .spinner {
position: absolute;
top: 50%;
left: 50%;
margin-top: -9px !important;
margin-left: -9px !important;
visibility: visible !important;
}
.gallery-columns-1 .wpmf-gallery-block-item {
width: 100%;
}
.gallery-columns-2 .wpmf-gallery-block-item {
width: 50%;
}
.gallery-columns-3 .wpmf-gallery-block-item {
width: calc(100%/3);
}
.gallery-columns-4 .wpmf-gallery-block-item {
width: 25%;
}
.gallery-columns-5 .wpmf-gallery-block-item {
width: 20%;
}
.gallery-columns-6 .wpmf-gallery-block-item {
width: calc(100%/6);
}
.gallery-columns-7 .wpmf-gallery-block-item {
width: calc(100%/7);
}
.gallery-columns-8 .wpmf-gallery-block-item {
width: 12.5%
}
.gallery-columns-9 .wpmf-gallery-block-item {
width: calc(100%/9);
}
.wpmf-gallery-list-items .wpmf-gallery-block-item img {
display: block;
cursor: pointer;
width: 100%;
}
.wpmf-gallery-list-items .wpmf-gallery-block-item {
text-align: center;
box-sizing: border-box;
}
.wpmf-cover {
width: 100%;
display: inline-block;
}
.wpmf-cover img {
width: 100%;
}
.wpmfDefault .wpmf-gallery-list-items {
display: flex;
flex-wrap: wrap;
}
.wpmf-gallery-list-items {
padding: 0 !important;
}
.wpmfDefault .wpmf-gallery-list-items .wpmf-gallery-block-item {
display: inherit;
}
.wpmf-gallery-block-item-infos {
position: relative;
}
.wpmfslick .wpmf-gallery-block-item {
position: relative;
}
.wpmf-slick-crop-1 .wpmfslick .wpmf-gallery-block-item-infos:before {
padding-top: 100%;
content: "";
display: block;
}
.wpmf-slick-crop-1 .wpmfslick .wpmf-gallery-block-item-infos:after {
content: '' !important;
position: absolute !important;
bottom: 0 !important;
left: 0 !important;
width: 160% !important;
height: 100% !important;
transform: scale3d(1.9, 1.4, 1) rotate3d(0, 0, 1,
45deg
) translate3d(0, -120%, 0) !important;
-webkit-transform: scale3d(1.9, 1.4, 1) rotate3d(0, 0, 1,
45deg
) translate3d(0, -120%, 0) !important;
-webkit-transition: transform 0.7s ease 0s !important;
transition: transform 0.7s ease 0s !important;
z-index: 1 !important;
}
.wpmf-slick-crop-1 .wpmfslick .wpmf-gallery-block-item-infos.is-selected::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
-webkit-box-shadow: inset 0 0 0 4px #49bf88;
box-shadow: inset 0 0 0 4px #49bf88;
content: "";
}
.wpmf-slick-crop-1 .wpmfslick .square_thumbnail {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 1;
transition: opacity .1s;
}
.wpmf-slick-crop-1 .wpmfslick .square_thumbnail:after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
}
.wpmf-slick-crop-1 .wpmfslick .square_thumbnail .img_centered {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: translate(50%, 50%);
}
.wpmf-slick-crop-1 .wpmfslick .square_thumbnail .img_centered img {
transform: translate(-50%, -50%) !important;
position: absolute;
top: 0;
left: 0;
max-height: 100%;
max-width: 100% !important;
width: 100% !important;
height: 100% !important;
object-fit: cover;
padding: 0 !important;
transition: ease all 500ms !important;
}
.wpmf-slick-text {
color: #ffffff;
position: absolute;
bottom: 0;
left: 0;
right: 0;
box-sizing: border-box;
display: block;
clear: left;
opacity: 0;
width: 90%;
margin: 0 auto;
border-bottom: #eee 1px solid;
z-index: 999;
text-overflow: ellipsis;
overflow: hidden;
}
.wpmf-slick-text span {
color: #ffffff;
bottom: 5px;
font-size: 11px;
transition: all 0.15s linear;
padding-bottom: 7px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 100%;
text-align: center;
}
.wpmfslick .wpmf-gallery-item:hover .wpmf-slick-text {
opacity: 1;
bottom: 15px;
transition-duration: 0.3s;
}
.wpmfDefault .wpmf-gallery-block-item-infos,
.wpmfDefault .wpmf-gallery-block-item-infos img {
width: 100%;
}
.wpmf-gallery-list-items .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
position: absolute;
top: 5px;
right: 5px;
color: #fff;
background-color: #ff0000;
border-radius: 4px;
padding: 2px;
z-index: 999;
width: 30px;
height: 30px;
min-width: 30px;
}
.wpmf-gallery-list-items .wpmf-gallery-block-item .wpmf-gallery-block-item-remove .dashicon {
margin: 0 auto;
}
.wpmf-gallery-block-item-remove svg {
margin: 0 !important;
}
.save_img_action span {
float: none;
}
.save_img_action span.visible {
visibility: visible;
}
.wpmf-pdf-block {
width: 100%;
padding-right: 10px;
margin-top: -1px;
}
.wpmf-pdf-block input {
margin: 0;
}
.wpmf-pdf-button {
margin: 0 4px;
height: 31px;
}
.aligncenter .wpmf-image-lightbox-block, .alignright .wpmf-image-lightbox-block, .alignleft .wpmf-image-lightbox-block {
max-width: 620px;
}
.aligncenter .wpmf-image-lightbox-block {
margin: 0 auto;
}
.wpmf-image-lightbox-block {
width: 100%;
}
.wpmf-pdf-button {
margin: 0 4px;
}
/* Border radius for image */
.wpmf-has-border-radius-1 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-1 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-1 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 1px
}
.wpmf-has-border-radius-2 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-2 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-2 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 2px
}
.wpmf-has-border-radius-3 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-3 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-3 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 3px
}
.wpmf-has-border-radius-4 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-4 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 4px
}
.wpmf-has-border-radius-5 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-5 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-5 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 5px
}
.wpmf-has-border-radius-6 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-6 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-6 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 6px
}
.wpmf-has-border-radius-7 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-7 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-7 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 7px
}
.wpmf-has-border-radius-8 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-8 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-8 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 8px
}
.wpmf-has-border-radius-9 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-9 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-9 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 9px
}
.wpmf-has-border-radius-10 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-10 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-10 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 10px
}
.wpmf-has-border-radius-11 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-11 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-11 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 11px
}
.wpmf-has-border-radius-12 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-12 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-12 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 12px
}
.wpmf-has-border-radius-13 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-13 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-13 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 13px
}
.wpmf-has-border-radius-14 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-14 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-14 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 14px
}
.wpmf-has-border-radius-15 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-15 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-15 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 15px
}
.wpmf-has-border-radius-16 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-16 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-16 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 16px
}
.wpmf-has-border-radius-17 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-17 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-17 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 17px
}
.wpmf-has-border-radius-18 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-18 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-18 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 18px
}
.wpmf-has-border-radius-19 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-19 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-19 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 19px
}
.wpmf-has-border-radius-20 .wpmf-gallery-block-item img,
.wpmf-has-border-radius-20 .wpmf-gallery-block-item .wpmf_overlay,
.wpmf-has-border-radius-20 .wpmf-gallery-block-item .wpmf-gallery-block-item-remove {
border-radius: 20px
}
.wpmfslick .slick-dots {
padding: 0 !important;
}
.wpmfslick .wpmf-gallery-block-item {
margin: 0;
box-sizing: border-box;
}
.wpmf-has-gutter-width-5 .wpmfslick .wpmf-gallery-block-item {
padding: 2.5px;
}
.wpmf-has-gutter-width-10 .wpmfslick .wpmf-gallery-block-item {
padding: 5px;
}
.wpmf-has-gutter-width-15 .wpmfslick .wpmf-gallery-block-item {
padding: 7.5px;
}
.wpmf-has-gutter-width-20 .wpmfslick .wpmf-gallery-block-item {
padding: 10px;
}
.wpmf-has-gutter-width-25 .wpmfslick .wpmf-gallery-block-item {
padding: 12.5px;
}
.wpmf-has-gutter-width-30 .wpmfslick .wpmf-gallery-block-item {
padding: 15px;
}
.wpmf-has-gutter-width-35 .wpmfslick .wpmf-gallery-block-item {
padding: 17.5px;
}
.wpmf-has-gutter-width-40 .wpmfslick .wpmf-gallery-block-item {
padding: 20px;
}
.wpmf-has-gutter-width-45 .wpmfslick .wpmf-gallery-block-item {
padding: 22.5px;
}
.wpmf-has-gutter-width-50 .wpmfslick .wpmf-gallery-block-item {
padding: 25px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-5 .wpmf-gallery-block-item-infos {
margin: 2.5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-10 .wpmf-gallery-block-item-infos {
margin: 5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-15 .wpmf-gallery-block-item-infos {
margin: 7.5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-20 .wpmf-gallery-block-item-infos {
margin: 10px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-25 .wpmf-gallery-block-item-infos {
margin: 12.5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-30 .wpmf-gallery-block-item-infos {
margin: 15px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-35 .wpmf-gallery-block-item-infos {
margin: 17.5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-40 .wpmf-gallery-block-item-infos {
margin: 20px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-45 .wpmf-gallery-block-item-infos {
margin: 22.5px;
}
.wpmfBlockMasonry .wpmf-has-gutter-width-50 .wpmf-gallery-block-item-infos {
margin: 25px;
}
.wpmfDefault .wpmf-has-gutter-width-5 li {
padding: 2.5px;
}
.wpmfDefault .wpmf-has-gutter-width-10 li {
padding: 5px;
}
.wpmfDefault .wpmf-has-gutter-width-15 li {
padding: 7.5px;
}
.wpmfDefault .wpmf-has-gutter-width-20 li {
padding: 10px;
}
.wpmfDefault .wpmf-has-gutter-width-25 li {
padding: 12.5px;
}
.wpmfDefault .wpmf-has-gutter-width-30 li {
padding: 15px;
}
.wpmfDefault .wpmf-has-gutter-width-35 li {
padding: 17.5px;
}
.wpmfDefault .wpmf-has-gutter-width-40 li {
padding: 20px;
}
.wpmfDefault .wpmf-has-gutter-width-45 li {
padding: 22.5px;
}
.wpmfDefault .wpmf-has-gutter-width-50 li {
padding: 25px;
}
.wpmf-has-columns-1 > li {
margin: 0;
}
.wpmf_sl_gallery_folders {
width: 100%;
display: inline-block;
margin-bottom: 10px;
}
.wpmf_sl_gallery_folders select {
width: 100%;
min-height: 120px;
max-height: 300px;
overflow: auto;
border: none;
box-shadow: 1px 1px 12px #ccc;
padding: 5px !important;
}
.wpmf_sl_gallery_folders, .wpmf_btn_upload_img {
margin-right: 5px;
}
.wpmf_spiner_block_gallery_loading {
position: absolute !important;
left: calc(50% - 10px) !important;
top: calc(50% - 10px) !important;
visibility: visible !important;
}
.wpmf-has-gutter-width-10 .wpmf-viewport,
.wpmf-has-gutter-width-15 .wpmf-viewport,
.wpmf-has-gutter-width-20 .wpmf-viewport,
.wpmf-has-gutter-width-25 .wpmf-viewport,
.wpmf-has-gutter-width-30 .wpmf-viewport,
.wpmf-has-gutter-width-35 .wpmf-viewport,
.wpmf-has-gutter-width-40 .wpmf-viewport,
.wpmf-has-gutter-width-45 .wpmf-viewport,
.wpmf-has-gutter-width-50 .wpmf-viewport {
padding: 10px;
}
.wpmf_overlay {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 888;
background: rgba(10,6,6,0.75);
display: none;
}
.portfolio_lightbox {
position: absolute;
top:50%;
left: 50%;
margin-top: -18px;
margin-left: -18px;
display: none !important;
width: 36px;
height: 36px;
text-align: center;
vertical-align: middle;
line-height: 36px;
color: #393939 !important;
background-color: #fff;
border: 1px solid transparent;
border-radius: 2em;
z-index: 999;
transition: opacity .3s ease-in-out,color .3s ease-in-out,background-color .3s ease-in-out,border-color .3s ease-in-out;
}
.wpmfBlockMasonry .wpmf-gallery-block-item-infos:hover > .wpmf_overlay,
.wpmfBlockMasonry .wpmf-gallery-block-item-infos:hover > .portfolio_lightbox{
display: block !important;
opacity: 1 !important;
}
.wpmf-gallery-caption {
padding: 5px 10px;
}
.wpmf-gallery-caption .title {
color: #393939;
font-family: Raleway;
font-size: 13px !important;
font-weight: 700;
letter-spacing: 2px;
display: inline-block;
word-break: break-all;
vertical-align: middle;
width: 100%;
}
.wpmf-gallery-caption .excerpt{
color: #9a9a9a;
font-family: Raleway;
font-size: 12px !important;
font-style: normal;
font-weight: 500;
letter-spacing: 1px;
display: inline-block;
word-break: break-all;
vertical-align: middle;
width: 100%;
}
.wpmf_gallery_img_msg {
color: #ff8800;
font-size: 14px;
font-style: italic;
display: inline-block;
width: 100%;
padding: 5px 10px;
}
.wpmf-gallery-list-items:not(.wpmfslick.wpmf-slick-crop-0) .square_thumbnail,
.wpmf_square_thumbnail {
/*overflow: hidden;*/
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 1;
transition: opacity .1s;
}
.wpmf-gallery-list-items:not(.wpmfslick.wpmf-slick-crop-0) .square_thumbnail:after,
.wpmf_square_thumbnail:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
}
.wpmf-gallery-list-items:not(.wpmfslick.wpmf-slick-crop-0) .square_thumbnail .img_centered,
.wpmf_square_thumbnail .img_centered {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: translate(50%, 50%);
}
.wpmf-gallery-list-items:not(.wpmfslick.wpmf-slick-crop-0) .square_thumbnail .img_centered img,
.wpmf_square_thumbnail .img_centered img {
transform: translate(-50%, -50%) !important;
position: absolute;
top: 0;
left: 0;
max-height: 100%;
max-width: 100% !important;
width: 100% !important;
height: 100% !important;
object-fit: cover;
padding: 0 !important;
/*transition: ease all 500ms !important;*/
}
.wpmf-gallery-list-items.ratio_default .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: 100%;
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_1_1 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before,
.gallery_comments_item .img_box_box {
padding-top: 100%;
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_3_2 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/3*2);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_2_3 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/2*3);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_4_3 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/4*3);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_3_4 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/3*4);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_16_9 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/16*9);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_9_16 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/9*16);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_21_9 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/21*9);
content: "";
display: block;
}
.wpmf-gallery-list-items.ratio_9_21 .wpmf-gallery-block-item .wpmf-gallery-block-item-infos:before {
padding-top: calc(100%/9*21);
content: "";
display: block;
}
@@ -0,0 +1,117 @@
(function ($) {
"use strict";
if ('undefined' === typeof (wp) || 'undefined' === typeof (wp.media)) {
return;
}
var media = wp.media;
var setTime;
if (typeof media.view.Settings !== "undefined") {
media.view.Settings.Gallery = media.view.Settings.Gallery.extend({
render: function () {
var $el = this.$el;
if (typeof wpmfFoldersModule === "undefined") {
return this;
}
var id_folder = wpmfFoldersModule.last_selected_folder;
media.view.Settings.prototype.render.apply(this, arguments);
$el.find('[data-setting="size"]').parent('label').remove();
$el.find('[data-setting="link"]').parent('label').remove();
$el.find('[data-setting="columns"]').parent('label').remove();
$el.find('[data-setting="_orderbyRandom"]').parent('label').remove();
try {
$el.append(media.template('wpmf-gallery-settings'));
} catch(err) {
return this;
}
media.gallery.defaults.display = 'default';
media.gallery.defaults.targetsize = 'large';
media.gallery.defaults.wpmf_folder_id = '';
media.gallery.defaults.wpmf_autoinsert = '0';
media.gallery.defaults.wpmf_orderby = 'post__in';
media.gallery.defaults.wpmf_order = 'ASC';
this.update.apply(this, ['link']);
this.update.apply(this, ['columns']);
this.update.apply(this, ['size']);
this.update.apply(this, ['display']);
this.update.apply(this, ['targetsize']);
this.update.apply(this, ['wpmf_folder_id']);
this.update.apply(this, ['wpmf_orderby']);
this.update.apply(this, ['wpmf_order']);
if (typeof id_folder !== "undefined") {
if ($el.find('.wpmf_folder_id').length) {
var oldfIds = $el.find('.wpmf_folder_id').val();
var oldfIds_array = oldfIds.split(",").map(Number);
if (oldfIds !== '') {
if (oldfIds_array.indexOf(id_folder) < 0) {
$el.find('.wpmf_folder_id').val(oldfIds + ',' + id_folder).change();
}
} else {
$el.find('.wpmf_folder_id').val(id_folder).change();
}
}
}
this.update.apply(this, ['wpmf_autoinsert']);
return this;
}
});
}
/* when click Create a gallery from folder button */
var selectallGallery = function () {
$('.media-menu-item:nth-child(2)').click();
var $li_attm = $('li.attachment:not(.wpmf-attachment)');
$li_attm.find('.thumbnail').click();
if ($('.button.media-button.button-primary.button-large.media-button-gallery').attr('disabled') === undefined) {
$('.button.media-button.button-primary.button-large.media-button-gallery').click();
}
if ($li_attm.find('.thumbnail').length === 0) {
setTime = setTimeout(function () {
selectallGallery();
}, 100);
}
};
/* change gallery theme */
$(document).on('change', '.wpmf_display', function () {
var theme = $(this).val();
$('.wpmf_columns').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].columns);
$('.wpmf_size').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].size);
$('.wpmf_targetsize').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].targetsize);
$('.wpmf_link-to').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].link);
$('.wpmf_orderby').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].orderby);
$('.wpmf_order').val(wpmf.vars.gallery_configs.theme[theme + '_theme'].order);
});
/* sort image gallery */
$(document).on('change', '.wpmf_orderby', function () {
$('.media-button-wpmf_reverse_gallery').click();
if ($(this).val() === 'title' || $(this).val() === 'date') {
$(this).closest('.attachments-browser').find('.media-button-reverse').hide();
} else {
$(this).closest('.attachments-browser').find('.media-button-reverse').show();
}
});
/* sort image gallery */
$(document).on('change', '.wpmf_order', function () {
$('.media-button-wpmf_reverse_gallery').click();
});
/* when change category */
$(document).on('change', '.wpmf-categories', function () {
clearTimeout(setTime);
});
/* when click Create a gallery from folder button */
$(document).on('click', 'a.btn-selectall,a.btn-selectall-gallery', function () {
selectallGallery();
});
})(jQuery);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,412 @@
(function ($) {
"use strict";
var body = $('body'),
_window = $(window);
/**
* get column width, gutter width, count columns
* @param $container
* @returns {{columnWidth: number, gutterWidth, columns: Number}}
*/
var calculateGrid = function ($container) {
var columns = parseInt($container.data('wpmfcolumns'));
var gutterWidth = $container.data('gutterWidth');
var containerWidth = $container.width();
if (isNaN(gutterWidth)) {
gutterWidth = 5;
} else if (gutterWidth > 500 || gutterWidth < 0) {
gutterWidth = 5;
}
gutterWidth = parseInt(gutterWidth);
if (parseInt(columns) > 2 && containerWidth <= 450) {
columns = 2;
} else if (parseInt(columns) > 4 && containerWidth <= 1024) {
columns = 4;
}
var allGutters = gutterWidth * (columns - 1);
var contentWidth = containerWidth - allGutters;
var columnWidth = Math.floor(contentWidth / columns);
return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns};
};
/**
* Run masonry gallery
* @param duration
* @param $container
*/
var runMasonry = function (duration, $container) {
var $postBox = $container.children('.wpmf-gallery-item');
var o = calculateGrid($container);
$postBox.css({'width': o.columnWidth + 'px', 'margin-bottom': o.gutterWidth + 'px'});
$container.masonry({
itemSelector: '.wpmf-gallery-item',
columnWidth: o.columnWidth,
gutter: o.gutterWidth,
isAnimated: true,
animationOptions: {
duration: duration,
easing: 'linear',
queue: false
},
isFitWidth: true
});
if ($($container).hasClass('gallery-portfolio')) {
var w = $($container).find('.attachment-thumbnail').width();
$($container).find('.wpmf-caption-text.wpmf-gallery-caption , .wpmf-gallery-icon').css('max-width', w + 'px');
}
$container.find('.wpmf-gallery-item').css('opacity', 1);
};
var wpmfCallPopup = function () {
/* check Enable the gallery lightbox feature option */
$('.wpmf-gallerys-life .wpmf-gallery-icon a, .portfolio_lightbox, .wpmf_overlay').each(function () {
var href = $(this).data('href');
if (typeof href !== "undefined" && href !== '') {
$(this).attr('href', href);
}
});
if (typeof wpmfggr !== "undefined" && typeof wpmfggr.wpmf_lightbox_gallery !== "undefined" && parseInt(wpmfggr.wpmf_lightbox_gallery) === 1) {
if ($().magnificPopup) {
$('.wpmf-gallerys-life').each(function (i, wrap) {
var items = [];
$(wrap).find('.wpmf-gallery-icon a[data-lightbox="1"]:not(.portfolio_lightbox, .wpmf_overlay)').each(function (j, item) {
var href = $(this).attr('href');
var title = $(this).attr('title');
if (typeof $(wrap).data('items') !== "undefined") {
items = $(wrap).data('items');
} else {
if ($(item).hasClass('isvideo')) {
items.push({src: href, title: title, type: 'iframe'});
} else {
items.push({src: href, title: title, type: 'image'});
}
}
});
$(wrap).find('.wpmf-gallery-icon').on('click', function (e) {
if ($(this).find('a[data-lightbox="1"]').length) {
e.preventDefault();
var index = $(this).find('a[data-lightbox="1"]').data('index');
$.magnificPopup.open({
items: items,
gallery: {
enabled: true,
tCounter: '<span class="mfp-counter">%curr% / %total%</span>',
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>'
},
showCloseBtn: true,
removalDelay: 300,
mainClass: 'wpmf-mfp-zoom-in',
callbacks: {
open: function (e) {
//overwrite default prev + next function. Add timeout for css3 crossfade animation
$.magnificPopup.instance.next = function () {
var self = this;
self.wrap.removeClass('mfp-image-loaded');
setTimeout(function () {
$.magnificPopup.proto.next.call(self);
}, 120);
};
$.magnificPopup.instance.prev = function () {
var self = this;
self.wrap.removeClass('mfp-image-loaded');
setTimeout(function () {
$.magnificPopup.proto.prev.call(self);
}, 120);
};
},
imageLoadComplete: function () {
var self = this;
setTimeout(function () {
self.wrap.addClass('mfp-image-loaded');
}, 16);
}
}
});
$.magnificPopup.instance.goTo(index);
}
});
});
}
}
};
/**
* Init gallery
*/
var initGallery = function (action = '') {
$('.gallery_life.gallery-masonry').each(function () {
var $container = $(this);
if ($container.is(':hidden')) {
return;
}
if ($container.hasClass('masonry')) {
if (action === 'resize') {
$container.masonry('destroy');
} else {
return;
}
}
if (typeof wpmfggr !== "undefined" && wpmfggr.smush_lazyload && !$container.closest('.dd-popup-c').length) {
$(document).on('lazyloaded', function (e) {
imagesLoaded($container, function () {
runMasonry(0, $container);
$container.css('visibility', 'visible');
wpmfCallPopup();
});
});
} else {
if (!$container.find('.wpmf_loader_gallery').length) {
$container.prepend('<img class="wpmf_loader_gallery" src="' + wpmfggr.img_url + 'balls.gif' + '">');
}
imagesLoaded($container, function () {
$container.find('.wpmf_loader_gallery').hide();
runMasonry(0, $container);
$container.css('visibility', 'visible');
wpmfCallPopup();
});
}
});
wpmfCallPopup();
$(window).on('load', function () {
/* fix height for slide theme when load */
$('.flex-viewport').each(function () {
$(this).css('height', '10px !important');
})
});
/* init slider theme */
if (jQuery().slick) {
$('.wpmfslick_life').each(function () {
var $this = $(this);
var id = $this.data('id');
if ($this.is(':hidden')) {
return;
}
if ($this.hasClass('slick-initialized') || $this.hasClass('wpmfslick_addon')) {
return;
}
var columns = parseInt($this.data('wpmfcolumns'));
var container_width = $this.width();
if (parseInt(columns) >= 4 && container_width <= 450) {
columns = 2;
}
var auto_animation = parseInt($this.data('auto_animation'));
var duration = parseInt($this.data('duration'));
imagesLoaded($('#' + id), function () {
var slick_args = {
infinite: true,
slidesToShow: parseInt(columns),
slidesToScroll: parseInt(columns),
pauseOnHover: true,
autoplay: (auto_animation === 1),
adaptiveHeight: (parseInt(columns) === 1),
autoplaySpeed: parseInt(duration),
rows: 1,
dots: (parseInt(columns) > 1),
fade: (typeof wpmfggr !== "undefined" && wpmfggr.slider_animation === 'fade' && parseInt(columns) === 1),
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
};
if (!$('#' + id).hasClass('slick-initialized')) {
$('#' + id).slick(slick_args);
}
wpmfCallPopup();
});
});
}
};
$(document).ready(function () {
if (typeof wpmfggr !== "undefined" && wpmfggr.wpmf_current_theme === 'Gleam' || wpmfggr.wpmf_current_theme === 'Betheme') {
setTimeout(function () {
initGallery();
}, 1000);
} else {
setTimeout(function () {
initGallery();
}, 500);
}
/*$(window).on('resize', function () {
initGallery('resize');
});*/
jQuery('.vc_tta-tab').on('click', function () {
var id = jQuery(this).data('vc-target-model-id');
if (typeof id === "undefined") {
id = jQuery(this).find('a').attr('href');
if (typeof id !== "undefined") {
setTimeout(function () {
var bodyContainers = jQuery('.vc_tta-panel' + id);
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
}
} else {
setTimeout(function () {
var bodyContainers = jQuery('.vc_tta-panel[data-model-id="' + id + '"]');
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
}
});
$('.pp-tabs-labels .pp-tabs-label').on('click', function () {
initGallery();
});
// click to tab of advanced tab Blocks
$('.advgb-tab').on('click', function (event) {
event.preventDefault();
var bodyContainers = $(this).closest('.advgb-tabs-wrapper').find('.advgb-tab-body-container');
setTimeout(function () {
var currentTabActive = $(event.target).closest('.advgb-tab');
var href = currentTabActive.find('a').attr('href');
if (bodyContainers.find('.advgb-tab-body[aria-labelledby="' + href.replace(/^#/, "") + '"] .wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
// click to tab of Kadence Blocks
$('.kt-tabs-title-list .kt-title-item').on('click', function (event) {
event.preventDefault();
var href = $(this).attr('id');
var bodyContainers = $(this).closest('.kt-tabs-wrap').find('.kt-tabs-content-wrap');
setTimeout(function () {
if (bodyContainers.find('.kt-tab-inner-content[aria-labelledby="' + href + '"] .wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
// click to Divi tab
$('.et_pb_tabs_controls li').on('click', function () {
var cl = $(this).attr('class');
cl = cl.replace(' et_pb_tab_active', '');
var bodyContainers = $(this).closest('.et_pb_tabs');
setTimeout(function () {
if (bodyContainers.find('.et_pb_tab.'+ cl +' .wpmf-gallerys').length) {
initGallery();
}
}, 800);
});
// click to tab of Ultimate Blocks
$('.wp-block-ub-tabbed-content-tab-title-wrap').on('click', function () {
setTimeout(function () {
var bodyContainers = $('.wp-block-ub-tabbed-content-tab-content-wrap.active');
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
$('.plgs-archive-menu__item').on('click', function () {
var id = $(this).data('item-id');
setTimeout(function () {
var bodyContainers = $('.plgs-archive-item-wrapper[data-item-id="' + id + '"]');
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
$('.accordion .panel-title a[aria-expanded="false"]').on('click', function () {
var id = $(this).attr('href');
setTimeout(function () {
var bodyContainers = $(id);
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
$('.elementor-tab-title').on('click', function () {
var id = $(this).attr('aria-controls');
setTimeout(function () {
var bodyContainers = $('#' + id);
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
$('.dd-modal').on('click', function () {
var myInterval = setInterval(function () {
var bodyContainers = $('.dd-popup-c.open');
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
clearInterval(myInterval);
}
}, 500);
});
$('.plgs-archive-menu__options').on('change', function () {
var id = $(this).val();
setTimeout(function () {
var bodyContainers = $('.plgs-archive-item-wrapper[data-item-id="' + id + '"]');
if (bodyContainers.find('.wpmf-gallerys').length) {
initGallery();
}
}, 200);
});
});
$(document).on('fusion-element-render-fusion_tab fusion-element-render-fusion_tabs fusion-element-render-fusion_toggle fusion-element-render-fusion_tagline_box fusion-element-render-fusion_text', function ($, cid) {
if (jQuery('div[data-cid="' + cid + '"]').find('.wpmf-gallerys').length) {
initGallery();
}
});
$(document.body).on('post-load', function () {
initGallery();
});
$(document.body).on('wpmfs-toggled', function () {
initGallery();
});
})(jQuery);
@@ -0,0 +1,173 @@
var wpmfDuplicateModule;
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmf.vars.ajaxurl;
}
wpmfDuplicateModule = {
/**
* init event
*/
doEvent: function () {
/* Click duplicate file button */
$('.wpmf_btn_duplicate').off('click').on('click', function () {
var attachmentID = $('.wpmf_attachment_id').val();
wpmfDuplicateModule.doDuplicate(attachmentID);
});
},
/**
* Duplicate attachment
* @param id
*/
doDuplicate: function (id) {
if (typeof id !== 'undefined') {
$.ajax({
method: 'post',
url: ajaxurl,
dataType: 'json',
data: {
action: 'wpmf_duplicate_file',
id: id,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
beforeSend: function () {
$('.wpmf_spinner').show();
$('.wpmf_message_duplicate').html(null);
},
success: function (res) {
$('.wpmf_spinner').hide();
if (res.status) {
wpmfFoldersModule.trigger('duplicateFile', wpmfFoldersModule.last_selected_folder);
$('.wpmf_message_duplicate').html('<div class="updated">' + res.message + '</div>');
} else {
$('.wpmf_message_duplicate').html('<div class="error">' + res.message + '</div>');
}
/* reset iframe after duplicate */
if (!$('body.upload-php table.media').length && wpmf.vars.wpmf_pagenow !== 'upload.php') {
setTimeout(function () {
wp.Uploader.queue.reset();
}, 1000);
}
wpmfFoldersModule.reloadAttachments();
wpmfFoldersModule.renderFolders();
}
});
}
}
};
$(document).ready(function () {
if (typeof wpmfFoldersModule === "undefined" || typeof wp === "undefined") {
return;
}
if ((wpmf.vars.wpmf_pagenow === 'upload.php' && !wpmfFoldersModule.page_type) || typeof wp.media === "undefined") {
return;
}
if (wpmfFoldersModule.page_type !== 'upload-list') {
/* base on /wp-includes/js/media-views.js */
var myduplicateForm = wp.media.view.AttachmentsBrowser;
var form_uplicate = '<button type="button" class="button wpmf_btn_duplicate">' + wpmf.l18n.duplicate_text + '<span class="wpmf_spinner"></span></button><p class="wpmf_message_duplicate"></p>';
if (typeof myduplicateForm !== "undefined") {
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
createSingle: function () {
/* Create duplicate button setting */
myduplicateForm.prototype.createSingle.apply(this, arguments);
var sidebar = this.sidebar;
if (wpmf.vars.wpmf_pagenow !== 'upload.php') {
if (typeof wpmf.vars.duplicate !== 'undefined' && parseInt(wpmf.vars.duplicate) === 1) {
$('.wpmf_btn_duplicate, .wpmf_spinner, .wpmf_message_duplicate').remove();
$(sidebar.$el).find('.attachment-info .details').append(form_uplicate);
wpmfDuplicateModule.doEvent();
}
}
}
});
}
/* Create duplicate button when wp smush plugin active*/
if (wpmf.vars.get_plugin_active.indexOf('wp-smush.php') !== -1) {
if( 'undefined' !== typeof wp.media.view &&
'undefined' !== typeof wp.media.view.Attachment.Details.TwoColumn ) {
// Local instance of the Attachment Details TwoColumn used in the edit attachment modal view
var wpmfAssignMediaTwoColumn = wp.media.view.Attachment.Details.TwoColumn;
/**
* Add Smush details to attachment.
*/
if (typeof wpmfAssignMediaTwoColumn !== "undefined") {
wp.media.view.Attachment.Details.TwoColumn = wp.media.view.Attachment.Details.TwoColumn.extend({
render: function () {
// Get Smush status for the image
wpmfAssignMediaTwoColumn.prototype.render.apply(this);
$( document ).ajaxComplete(function( event, xhr, settings ) {
var data = settings.data;
if (typeof data === 'string') {
if (data.indexOf('smush_get_attachment_details') !== -1) {
$('.wpmf_btn_duplicate, .wpmf_spinner, .wpmf_message_duplicate').remove();
$('.details').append(form_uplicate);
wpmfDuplicateModule.doEvent();
}
}
});
}
});
}
}
}
/* base on /wp-includes/js/media-views.js */
var myDuplicate = wp.media.view.Modal;
if (typeof myDuplicate !== "undefined") {
wp.media.view.Modal = wp.media.view.Modal.extend({
open: function () {
/* Create duplicate button setting */
myDuplicate.prototype.open.apply(this, arguments);
if (wpmf.vars.wpmf_pagenow === 'upload.php') {
if (typeof wpmf.vars.duplicate !== 'undefined' && parseInt(wpmf.vars.duplicate) === 1) {
setTimeout(function(){
$('.wpmf_btn_duplicate, .wpmf_spinner, .wpmf_message_duplicate').remove();
$('.attachment-details .details').append(form_uplicate);
wpmfDuplicateModule.doEvent();
},150);
}
}
}
});
}
if (wpmf.vars.wpmf_pagenow === 'upload.php') {
// create duplicate button when next and prev media items
var myEditAttachments = wp.media.view.MediaFrame.EditAttachments;
if (typeof myEditAttachments !== "undefined") {
wp.media.view.MediaFrame.EditAttachments = wp.media.view.MediaFrame.EditAttachments.extend({
previousMediaItem: function () {
/* Create duplicate button setting */
myEditAttachments.prototype.previousMediaItem.apply(this, arguments);
if (typeof wpmf.vars.duplicate !== 'undefined' && parseInt(wpmf.vars.duplicate) === 1) {
$('.wpmf_btn_duplicate, .wpmf_spinner, .wpmf_message_duplicate').remove();
$('.attachment-details .details').append(form_uplicate);
wpmfDuplicateModule.doEvent();
}
},
nextMediaItem: function () {
/* Create duplicate button setting */
myEditAttachments.prototype.nextMediaItem.apply(this, arguments);
if (typeof wpmf.vars.duplicate !== 'undefined' && parseInt(wpmf.vars.duplicate) === 1) {
$('.wpmf_btn_duplicate, .wpmf_spinner, .wpmf_message_duplicate').remove();
$('.attachment-details .details').append(form_uplicate);
wpmfDuplicateModule.doEvent();
}
}
});
}
}
}
});
}(jQuery));
@@ -0,0 +1,376 @@
/**
* Folder tree for WP Media Folder
*/
var wpmfFoldersTreeExportModule;
(function ($) {
wpmfFoldersTreeExportModule = {
categories: [], // categories
folders_states: [], // Contains open or closed status of folders
/**
* Retrieve the Jquery tree view element
* of the current frame
* @return jQuery
*/
getTreeElement: function () {
return $('.export_tree_folders').find('.wpmf-folder-tree');
},
/**
* Initialize module related things
*/
initModule: function () {
// Import categories from wpmf main module
wpmfFoldersTreeExportModule.importCategories();
// Add the tree view to the main content
$('<div class="wpmf-folder-tree wpmf-no-margin wpmf-no-padding"></div>').appendTo($('.export_tree_folders'));
// Render the tree view
wpmfFoldersTreeExportModule.loadTreeView();
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_get_export_folders',
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (res) {
$.each(res.folders, function (i, v) {
$('.export_tree_folders .media_checkbox[value="' + v + '"]').prop('checked', true).change();
});
}
});
$('.save_export_folders').on('click', function () {
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_set_export_folders',
wpmf_export_folders: $('.wpmf_export_folders').val(),
wpmf_nonce: wpmf.vars.wpmf_nonce
},
beforeSend: function () {
$('.save_export_folders_spinner').show().css('visibility', 'visible');
},
success: function () {
$('.save_export_folders_spinner').hide();
$.magnificPopup.close();
}
});
});
// set watermark exclude folders
$('.export_tree_folders .media_checkbox').on('click, change', function () {
var excludes = [];
$('.export_tree_folders .media_checkbox').each(function (i, v) {
var val = $(v).val();
if ($(v).is(':checked')) {
excludes.push(val);
} else {
var index = excludes.indexOf(val);
if (index > -1) {
excludes.splice(index, 1);
}
}
});
$('[name="wpmf_export_folders"]').val(excludes.join()).change();
});
},
/**
* Import categories from wpmf main module
*/
importCategories: function () {
var folders_ordered = [];
// Add each category
$(wpmf.vars.wpmf_categories_order).each(function () {
folders_ordered.push(wpmf.vars.wpmf_categories[this]);
});
// Reorder array based on children
var folders_ordered_deep = [];
var processed_ids = [];
var loadChildren = function (id) {
if (processed_ids.indexOf(id) < 0) {
processed_ids.push(id);
for (var ij = 0; ij < folders_ordered.length; ij++) {
if (folders_ordered[ij].parent_id === id) {
folders_ordered_deep.push(folders_ordered[ij]);
loadChildren(folders_ordered[ij].id);
}
}
}
};
loadChildren(parseInt(wpmf.vars.term_root_id));
// Finally save it to the global var
wpmfFoldersTreeExportModule.categories = folders_ordered_deep;
},
/**
* Render tree view inside content
*/
loadTreeView: function () {
wpmfFoldersTreeExportModule.getTreeElement().html(wpmfFoldersTreeExportModule.getRendering());
},
/**
* Get the html resulting tree view
* @return {string}
*/
getRendering: function () {
var ij = 0;
var content = ''; // Final tree view content
/**
* Recursively print list of folders
* @return {boolean}
*/
var generateList = function generateList() {
content += '<ul>';
while (ij < wpmfFoldersTreeExportModule.categories.length) {
var className = 'closed';
if (typeof wpmfFoldersTreeExportModule.categories[ij].drive_type !== "undefined" && wpmfFoldersTreeExportModule.categories[ij].drive_type !== '') {
className += ' hide';
}
// Open li tag
content += '<li class="' + className + '" data-id="' + wpmfFoldersTreeExportModule.categories[ij].id + '" >';
var a_tag = '<a data-id="' + wpmfFoldersTreeExportModule.categories[ij].id + '">';
// get color folder
var bgcolor = '';
if (typeof wpmf.vars.colors !== 'undefined' && typeof wpmf.vars.colors[wpmfFoldersTreeExportModule.categories[ij].id] !== 'undefined') {
bgcolor = 'color: ' + wpmf.vars.colors[wpmfFoldersTreeExportModule.categories[ij].id];
} else {
bgcolor = 'color: #8f8f8f';
}
if (wpmfFoldersTreeExportModule.categories[ij + 1] && wpmfFoldersTreeExportModule.categories[ij + 1].depth > wpmfFoldersTreeExportModule.categories[ij].depth) { // The next element is a sub folder
content += '<a onclick="wpmfFoldersTreeExportModule.toggle(' + wpmfFoldersTreeExportModule.categories[ij].id + ')"><i class="material-icons wpmf-arrow">keyboard_arrow_down</i></a>';
content += a_tag;
// Add folder icon
content += '<i class="material-icons" style="' + bgcolor + '">folder</i>';
} else {
content += a_tag;
// Add folder icon
content += '<i class="material-icons wpmf-no-arrow" style="' + bgcolor + '">folder</i>';
}
content += '<input type="checkbox" class="media_checkbox" value="' + wpmfFoldersTreeExportModule.categories[ij].id + '" data-id="' + wpmfFoldersTreeExportModule.categories[ij].id + '" />';
// Add current category name
if (wpmfFoldersTreeExportModule.categories[ij].id === 0) {
// If this is the root folder then rename it
content += '<span onclick="wpmfFoldersTreeExportModule.changeFolder(0)">' + wpmf.l18n.media_folder + '</span>';
} else {
content += '<span onclick="wpmfFoldersTreeExportModule.changeFolder(' + wpmfFoldersTreeExportModule.categories[ij].id + ')">' + wpmfFoldersTreeExportModule.categories[ij].label + '</span>';
}
content += '</a>';
// This is the end of the array
if (wpmfFoldersTreeExportModule.categories[ij + 1] === undefined) {
// var's close all opened tags
for (var ik = wpmfFoldersTreeExportModule.categories[ij].depth; ik >= 0; ik--) {
content += '</li>';
content += '</ul>';
}
// We are at the end don't continue to process array
return false;
}
if (wpmfFoldersTreeExportModule.categories[ij + 1].depth > wpmfFoldersTreeExportModule.categories[ij].depth) { // The next element is a sub folder
// Recursively list it
ij++;
if (generateList() === false) {
// We have reached the end, var's recursively end
return false;
}
} else if (wpmfFoldersTreeExportModule.categories[ij + 1].depth < wpmfFoldersTreeExportModule.categories[ij].depth) { // The next element don't have the same parent
// var's close opened tags
for (var ik1 = wpmfFoldersTreeExportModule.categories[ij].depth; ik1 > wpmfFoldersTreeExportModule.categories[ij + 1].depth; ik1--) {
content += '</li>';
content += '</ul>';
}
// We're not at the end of the array var's continue processing it
return true;
}
// Close the current element
content += '</li>';
ij++;
}
};
// Start generation
generateList();
return content;
},
/**
* Change the selected folder in tree view
* @param folder_id
*/
changeFolder: function (folder_id) {
// Remove previous selection
wpmfFoldersTreeExportModule.getTreeElement().find('li').removeClass('selected');
// Select the folder
wpmfFoldersTreeExportModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('selected').// Open parent folders
parents('.wpmf-folder-tree li.closed').removeClass('closed');
},
/**
* Toggle the open / closed state of a folder
* @param folder_id
*/
toggle: function (folder_id) {
// Check is folder has closed class
if (wpmfFoldersTreeExportModule.getTreeElement().find('li[data-id="' + folder_id + '"]').hasClass('closed')) {
// Open the folder
wpmfFoldersTreeExportModule.openFolder(folder_id);
} else {
// Close the folder
wpmfFoldersTreeExportModule.closeFolder(folder_id);
// close all sub folder
$('li[data-id="' + folder_id + '"]').find('li').addClass('closed');
}
},
/**
* Open a folder to show children
*/
openFolder: function (folder_id) {
wpmfFoldersTreeExportModule.getTreeElement().find('li[data-id="' + folder_id + '"]').removeClass('closed');
wpmfFoldersTreeExportModule.folders_states[folder_id] = 'open';
},
/**
* Close a folder and hide children
*/
closeFolder: function (folder_id) {
wpmfFoldersTreeExportModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('closed');
wpmfFoldersTreeExportModule.folders_states[folder_id] = 'close';
},
importFilesFromJson: function (page = 1) {
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_import_files_from_json',
page: page,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (res) {
if (typeof res.msg !== "undefined") {
$('.import_error_message_wrap').html('<div class="import_error_message">' + res.msg + '</div>');
}
if (res.status) {
wpmfFoldersTreeExportModule.importFilesFromJson(parseInt(page) + 1);
}
}
});
}
};
// var's initialize WPMF folder tree features
$(document).ready(function () {
var path = $('.import_folder_btn').data('path');
var id = $('.import_folder_btn').data('id');
var import_only_folder = $('.import_folder_btn').data('import_only_folder');
if (path !== '' && id !== '') {
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_import_folders',
path: path,
id: id,
import_only_folder: (import_only_folder !== '') ? 1 : 0,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
beforeSend: function () {
if (import_only_folder !== '') {
$('#import-attachments').prop('checked', true);
} else {
$('#import-attachments').prop('checked', false);
}
wpmfSnackbarModule.show({
id: 'import_library_folders',
content: wpmfoption.l18n.import_library_folders,
auto_close: false,
is_progress: true
});
},
success: function (res) {
wpmfSnackbarModule.close('import_library_folders');
$('.import_error_message_wrap').html('<div class="import_error_message">' + res.msg + '</div>');
if (res.status) {
if (res.import_files) {
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_prepare_import_files',
id: id,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
beforeSend: function () {
$('.import_error_message_wrap').html('<div class="import_error_message">' + wpmfoption.l18n.prepare_import_files + '</div>');
},
success: function (res) {
if (res.status) {
wpmfFoldersTreeExportModule.importFilesFromJson(1);
}
}
});
}
}
}
});
}
$('.export_folder_type').on('change', function () {
var type = $(this).val();
$.ajax({
type: "POST",
url: ajaxurl,
data: {
action: 'wpmf_set_export_folder_type',
type: type,
wpmf_nonce: wpmf.vars.wpmf_nonce
}
});
if (type === 'selection_folder') {
$('.open_export_tree_folders').addClass('show').removeClass('hide');
} else {
$('.open_export_tree_folders').addClass('hide').removeClass('show');
}
});
$('.open_export_tree_folders').magnificPopup({
type:'inline',
midClick: true,
callbacks: {
open: function () {
if (!$('.export_tree_folders .wpmf-folder-tree').length) {
wpmfFoldersTreeExportModule.initModule();
}
}
}
});
});
})(jQuery);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,80 @@
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
*/
/*
Basic Usage:
============
$('#el').spin(); // Creates a default Spinner using the text color of #el.
$('#el').spin({ ... }); // Creates a Spinner using the provided options.
$('#el').spin(false); // Stops and removes the spinner.
Using Presets:
==============
$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
Adding a custom preset:
=======================
$.fn.spin.presets.flower = {
lines: 9
length: 10
width: 20
radius: 0
}
$('#el').spin('flower', 'red');
*/
(function (factory) {
if (typeof exports == 'object') {
// CommonJS
factory(require('jquery'), require('spin'))
}
else if (typeof define == 'function' && define.amd) {
// AMD, register as anonymous module
define(['jquery', 'spin'], factory)
}
else {
// Browser globals
if (!window.Spinner) throw new Error('Spin.js not present')
factory(window.jQuery, window.Spinner)
}
}(function ($, Spinner) {
$.fn.spin = function (opts, color) {
return this.each(function () {
var $this = $(this),
data = $this.data();
if (data.spinner) {
data.spinner.stop();
delete data.spinner;
}
if (opts !== false) {
opts = $.extend(
{color: color || $this.css('color')},
$.fn.spin.presets[opts] || opts
)
data.spinner = new Spinner(opts).spin(this)
}
})
}
$.fn.spin.presets = {
tiny: {lines: 8, length: 2, width: 2, radius: 3},
small: {lines: 8, length: 4, width: 3, radius: 5},
large: {lines: 10, length: 8, width: 4, radius: 8}
}
}));
@@ -0,0 +1,179 @@
/*
WP Gif Player, an easy to use GIF Player for Wordpress
Copyright (C) 2016 David Bedenknecht (http://www.sketchmouse.com/page/contact)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
jQuery(function () {
//gifs HAVE to be preloaded, otherwise nothing happens for ages when user clicks play!
var gifs = []; //Array that will hold all gifs as Images
var gif_urls = [];//array holds all GIF Urls
var player_wrap = jQuery('.gif_wrap');
var showing_btn = jQuery('span.play_gif'); //Play "Button" - purely css
var playing = false;
var first_load = true;
var stop_load = false;
var last_viewed = null; //index of gif that was last played
//first spinner which is shown before the window has fully loaded
var spinnerPreload;
var spinnerLoading;
var spinnerOptions = {
lines: 13,
length: 12,
width: 8,
radius: 18,
trail: 100,
speed: 1.3,
color: '#fff',
className: 'gif_spinner'
};
spinnerPreload = new Spinner(spinnerOptions);
spinnerLoading = new Spinner(spinnerOptions);
//Preloads one gif as an image object
function preload_gif(url, idx) {
if (!gifs[idx]) {//if there not already an image at that idx in gifs, create one
var img = new Image();
img.src = url;
img.className = '_showing';
gifs[idx] = img;
first_load = true;
return img;
} else {
first_load = false;
return gifs[idx];
}
}
//Save all GIF urls
jQuery('._showing.frame').each(function () {
var s = jQuery(this);
if (s.attr('src')) {
if (s.attr('data-lazy-src')) {//unfassbar.es -> lazy load enabled
gif_urls.push(s.attr('data-lazy-src').replace('_still_tmp.jpeg', '.gif'));
} else {
if (typeof s.attr('src') !== 'undefined' && s.attr('src') !== false) {
gif_urls.push(s.attr('src').replace('_still_tmp.jpeg', '.gif'));
} else {
gif_urls.push(s.src.replace('_still_tmp.jpeg', '.gif'));
}
}
} else if (s.data('cfsrc')) { //CloudFlare sets the "src" as 'data-cfsrc="..."'
gif_urls.push(s.data('cfsrc').replace('_still_tmp.jpeg', '.gif'));
}
});
jQuery(document).ready(function () {
//start preloading spinner
spinnerPreload.spin();//start Spinner
if (jQuery('.gif_wrap').length) {
jQuery('.gif_wrap')[0].appendChild(spinnerPreload.el);//only show on first gif (if we wanted to show it on all gifs, we'd have to instantiate a new spinner for each)
}
});
jQuery(window).on('load', function () {
spinnerPreload.stop(); //stop spinner when all images have loaded and play button should be clickable
var showing_btn_idx = "";
var gif_img;
var displayedImgSrc;
var hiddenImgSrc;
//Button is hidden before whole DOM tree is loaded, otherwise it jumps from top to center of .gif_wrap
showing_btn.css('visibility', 'visible'); //show GIF Play Button
function play(idx) {
//Img / GIF sources
displayedImgSrc = jQuery('._showing')[idx].src;
hiddenImgSrc = jQuery('._hidden')[idx].src;
//Index of last played element
last_viewed = idx;
showing_btn_idx = showing_btn[idx]; //specific GIF Button for this clicked element
if (playing == false) { //hide first frame and GIF button
playing = true;
showing_btn_idx.style.visibility = 'hidden';
} else { //display first frame and GIF button
playing = false;
showing_btn_idx.style.visibility = 'visible';
}
if (displayedImgSrc == gifs[idx].src && !first_load) { //if the gif is already showing
displayedImgSrc = hiddenImgSrc;
hiddenImgSrc = gifs[idx].src;
if (playing == false) //if the the gif that was played is clicked again and stops last_view has to be set to null, otherwise two gifs start at the same time
last_viewed = null;
else
last_viewed = idx;
} else if (hiddenImgSrc == gifs[idx].src) { // if still is showing
hiddenImgSrc = displayedImgSrc;
displayedImgSrc = gifs[idx].src;
}
jQuery('._showing')[idx].src = displayedImgSrc;
jQuery('._hidden')[idx].src = hiddenImgSrc;
}
jQuery('.gif_wrap').click(function (event) {
var self = this;
var idx = jQuery('.gif_wrap').index(this); //returns index of clicked div
if (!gifs[idx]) {
first_load = true;
//target is gif_wrap
spinnerLoading.spin();//start Spinner
self.appendChild(spinnerLoading.el);
}
//This is to check if the user clicked again before the gif was fully loaded.
//If so, we need to stop the onload Event for the image by setting first_load to false.
//Preload the gif onclick
if (first_load) {
stop_load = true;
gif_img = preload_gif(gif_urls[idx], idx);
gif_img.onload = function () { //could possibly cause errors (asynch. http://stackoverflow.com/questions/20613984/jquery-or-javascript-check-if-image-loaded)
spinnerLoading.stop();
first_load = false; //set first_load to false, otherwise, if a gif is clicked twice the src of the still is overwritten.
};
//append gif as img src
jQuery(self).children('img').attr('src', gif_img.src);
}
if (!last_viewed && last_viewed != 0) {
last_viewed = idx; //last_viewed != 0 has to be included because !0 is true
}
if (idx == last_viewed) { //the index of the gif_wrap element that's just been clicked is the same as idx of last click
play(idx);
} else { //idx of element that's just been clicked differs from element that's last been clicked
if (playing) {
showing_btn_idx = showing_btn[last_viewed]; //play button of last played gif
showing_btn_idx.style.visibility = 'visible';
if (jQuery('._showing')[last_viewed].src == gifs[last_viewed].src) { //if the gif is already showing
var tmpSrc = jQuery('._showing')[last_viewed].src;
jQuery('._showing')[last_viewed].src = jQuery('._hidden')[last_viewed].src;
jQuery('._hidden')[last_viewed].src = tmpSrc;
}
playing = false;
play(idx);
}
}
});
player_wrap.mouseenter(function () {
player_wrap.css('cursor', 'pointer');
}); //change mouse on enter, when leaving mouse changes on default
});
});
@@ -0,0 +1,357 @@
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
*/
(function (root, factory) {
/* CommonJS */
if (typeof exports == 'object') module.exports = factory()
/* AMD module */
else if (typeof define == 'function' && define.amd) define(factory)
/* Browser global */
else root.Spinner = factory()
}
(this, function () {
"use strict";
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
, animations = {} /* Animation rules keyed by their name */
, useCssAnimations
/* Whether to use CSS animations or setTimeout */
/**
* Utility function to create elements. If no tag name is given,
* a DIV is created. Optionally properties can be passed.
*/
function createEl(tag, prop) {
var el = document.createElement(tag || 'div')
, n
for (n in prop) el[n] = prop[n]
return el
}
/**
* Appends children and returns the parent.
*/
function ins(parent /* child1, child2, ...*/) {
for (var i = 1, n = arguments.length; i < n; i++)
parent.appendChild(arguments[i])
return parent
}
/**
* Insert a new stylesheet to hold the @keyframe or VML rules.
*/
var sheet = (function () {
var el = createEl('style', {type: 'text/css'})
ins(document.getElementsByTagName('head')[0], el)
return el.sheet || el.styleSheet
}())
/**
* Creates an opacity keyframe animation rule and returns its name.
* Since most mobile Webkits have timing issues with animation-delay,
* we create separate rules for each line/segment.
*/
function addAnimation(alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha * 100), i, lines].join('-')
, start = 0.01 + i / lines * 100
, z = Math.max(1 - (1 - alpha) / trail * (100 - start), alpha)
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
, pre = prefix && '-' + prefix + '-' || ''
if (!animations[name]) {
sheet.insertRule(
'@' + pre + 'keyframes ' + name + '{' +
'0%{opacity:' + z + '}' +
start + '%{opacity:' + alpha + '}' +
(start + 0.01) + '%{opacity:1}' +
(start + trail) % 100 + '%{opacity:' + alpha + '}' +
'100%{opacity:' + z + '}' +
'}', sheet.cssRules.length)
animations[name] = 1
}
return name
}
/**
* Tries various vendor prefixes and returns the first supported property.
*/
function vendor(el, prop) {
var s = el.style
, pp
, i
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
for (i = 0; i < prefixes.length; i++) {
pp = prefixes[i] + prop
if (s[pp] !== undefined) return pp
}
if (s[prop] !== undefined) return prop
}
/**
* Sets multiple style properties at once.
*/
function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n) || n] = prop[n]
return el
}
/**
* Fills in default values.
*/
function merge(obj) {
for (var i = 1; i < arguments.length; i++) {
var def = arguments[i]
for (var n in def)
if (obj[n] === undefined) obj[n] = def[n]
}
return obj
}
/**
* Returns the absolute page-offset of the given element.
*/
function pos(el) {
var o = {x: el.offsetLeft, y: el.offsetTop}
while ((el = el.offsetParent))
o.x += el.offsetLeft, o.y += el.offsetTop
return o
}
/**
* Returns the line color from the given string or array.
*/
function getColor(color, idx) {
return typeof color == 'string' ? color : color[idx % color.length]
}
// Built-in defaults
var defaults = {
lines: 12, // The number of lines to draw
length: 7, // The length of each line
width: 5, // The line thickness
radius: 10, // The radius of the inner circle
rotate: 0, // Rotation offset
corners: 1, // Roundness (0..1)
color: '#000', // #rgb or #rrggbb
direction: 1, // 1: clockwise, -1: counterclockwise
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
opacity: 1 / 4, // Opacity of the lines
fps: 20, // Frames per second when using setTimeout()
zIndex: 2e9, // Use a high z-index by default
className: 'spinner', // CSS class to assign to the element
top: '50%', // center vertically
left: '50%', // center horizontally
position: 'absolute' // element position
}
/** The constructor */
function Spinner(o) {
this.opts = merge(o || {}, Spinner.defaults, defaults)
}
// Global defaults that override the built-ins:
Spinner.defaults = {}
merge(Spinner.prototype, {
/**
* Adds the spinner to the given target element. If this instance is already
* spinning, it is automatically removed from its previous target b calling
* stop() internally.
*/
spin: function (target) {
this.stop()
var self = this
, o = self.opts
, el = self.el = css(createEl(0, {className: o.className}), {
position: o.position,
width: 0,
zIndex: o.zIndex
})
, mid = o.radius + o.length + o.width
css(el, {
left: o.left,
top: o.top
})
if (target) {
target.insertBefore(el, target.firstChild || null)
}
el.setAttribute('role', 'progressbar')
self.lines(el, self.opts)
if (!useCssAnimations) {
// No CSS animation support, use setTimeout() instead
var i = 0
, start = (o.lines - 1) * (1 - o.direction) / 2
, alpha
, fps = o.fps
, f = fps / o.speed
, ostep = (1 - o.opacity) / (f * o.trail / 100)
, astep = f / o.lines
;(function anim() {
i++;
for (var j = 0; j < o.lines; j++) {
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
self.opacity(el, j * o.direction + start, alpha, o)
}
self.timeout = self.el && setTimeout(anim, ~~(1000 / fps))
})()
}
return self
},
/**
* Stops and removes the Spinner.
*/
stop: function () {
var el = this.el
if (el) {
clearTimeout(this.timeout)
if (el.parentNode) el.parentNode.removeChild(el)
this.el = undefined
}
return this
},
/**
* Internal method that draws the individual lines. Will be overwritten
* in VML fallback mode below.
*/
lines: function (el, o) {
var i = 0
, start = (o.lines - 1) * (1 - o.direction) / 2
, seg
function fill(color, shadow) {
return css(createEl(), {
position: 'absolute',
width: (o.length + o.width) + 'px',
height: o.width + 'px',
background: color,
boxShadow: shadow,
transformOrigin: 'left',
transform: 'rotate(' + ~~(360 / o.lines * i + o.rotate) + 'deg) translate(' + o.radius + 'px' + ',0)',
borderRadius: (o.corners * o.width >> 1) + 'px'
})
}
for (; i < o.lines; i++) {
seg = css(createEl(), {
position: 'absolute',
top: 1 + ~(o.width / 2) + 'px',
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
})
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2 + 'px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
}
return el
},
/**
* Internal method that adjusts the opacity of a single line.
* Will be overwritten in VML fallback mode below.
*/
opacity: function (el, i, val) {
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
}
})
function initVML() {
/* Utility function to create a VML tag */
function vml(tag, attr) {
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
}
// No CSS transforms but VML support, add a CSS rule for VML elements:
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
Spinner.prototype.lines = function (el, o) {
var r = o.length + o.width
, s = 2 * r
function grp() {
return css(
vml('group', {
coordsize: s + ' ' + s,
coordorigin: -r + ' ' + -r
}),
{width: s, height: s}
)
}
var margin = -(o.width + o.length) * 2 + 'px'
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
, i
function seg(i, dx, filter) {
ins(g,
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
ins(css(vml('roundrect', {arcsize: o.corners}), {
width: r,
height: o.width,
left: o.radius,
top: -o.width >> 1,
filter: filter
}),
vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
)
)
)
}
if (o.shadow)
for (i = 1; i <= o.lines; i++)
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
for (i = 1; i <= o.lines; i++) seg(i)
return ins(el, g)
}
Spinner.prototype.opacity = function (el, i, val, o) {
var c = el.firstChild
o = o.shadow && o.lines || 0
if (c && i + o < c.childNodes.length) {
c = c.childNodes[i + o];
c = c && c.firstChild;
c = c && c.firstChild
if (c) c.opacity = val
}
}
}
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
if (!vendor(probe, 'transform') && probe.adj) initVML()
else useCssAnimations = vendor(probe, 'animation')
return Spinner
}));
@@ -0,0 +1,42 @@
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmfimport.vars.ajaxurl;
}
$(document).ready(function () {
/**
* Import category
* @param doit true or false
* @param button
*/
var importWpmfTaxonomy = function (doit, button) {
jQuery(button).find(".spinner").show().css({"visibility": "visible"});
jQuery.post(
ajaxurl,
{
action: "wpmf",
task: "import",
doit: doit,
wpmf_nonce: wpmfimport.vars.wpmf_nonce
},
function (response) {
jQuery(button).closest("div#wpmf_error").hide();
if (doit === true) {
jQuery("#wpmf_error").after("<div class='updated'> <p><strong>Categories imported into WP Media Folder. Enjoy!!!</strong></p></div>");
}
});
};
/* Click import button */
$('.wmpf_import_category').on('click', function () {
var $this = $(this);
importWpmfTaxonomy(true, $this);
});
/* Click no import button */
$('.wmpfNoImportBtn').on('click', function () {
var $this = $(this);
importWpmfTaxonomy(false, $this);
});
});
}(jQuery));
@@ -0,0 +1,451 @@
(function ($) {
wpmfImportCloudModule = {
categories: [], // categories
folders_states: [], // Contains open or closed status of folders
/**
* Retrieve the Jquery tree view element
* of the current frame
* @return jQuery
*/
getTreeElement: function () {
return $('.librarytree_cloudimport');
},
initModule: function () {
if ($('.librarytree_cloudimport').length === 0) {
return;
}
// Import categories from wpmf main module
wpmfImportCloudModule.importCategories();
wpmfImportCloudModule.loadTreeView();
},
/**
* Render tree view inside content
*/
loadTreeView: function () {
wpmfImportCloudModule.getTreeElement().append(wpmfImportCloudModule.getRendering());
},
/**
* Import categories from wpmf main module
*/
importCategories: function () {
let folders_ordered = [];
// Add each category
$(wpmfFoldersModule.categories_order).each(function () {
folders_ordered.push(wpmfFoldersModule.categories[this]);
});
// Order the array depending on main ordering
switch (wpmfFoldersModule.folder_ordering) {
default:
case 'name-ASC':
folders_ordered = Object.values(folders_ordered).sort(function (a, b) {
if (a.id === 0) return -1; // Root folder is always first
if (b.id === 0) return 1; // Root folder is always first
return a.label.localeCompare(b.label);
});
break;
case 'name-DESC':
folders_ordered = Object.values(folders_ordered).sort(function (a, b) {
if (a.id === 0) return -1; // Root folder is always first
if (b.id === 0) return 1; // Root folder is always first
return b.label.localeCompare(a.label);
});
break;
case 'id-ASC':
folders_ordered = Object.values(folders_ordered).sort(function (a, b) {
if (a.id === 0) return -1; // Root folder is always first
if (b.id === 0) return 1; // Root folder is always first
return a.id - b.id;
});
break;
case 'id-DESC':
folders_ordered = Object.values(folders_ordered).sort(function (a, b) {
if (a.id === 0) return -1; // Root folder is always first
if (b.id === 0) return 1; // Root folder is always first
return b.id - a.id;
});
break;
case 'custom':
folders_ordered = Object.values(folders_ordered).sort(function (a, b) {
if (a.id === 0) return -1; // Root folder is always first
if (b.id === 0) return 1; // Root folder is always first
return a.order - b.order;
});
break;
}
// Reorder array based on children
let folders_ordered_deep = [];
let processed_ids = [];
const loadChildren = function (id) {
if (processed_ids.indexOf(id) < 0) {
processed_ids.push(id);
for (let ij = 0; ij < folders_ordered.length; ij++) {
if (folders_ordered[ij].parent_id === id) {
folders_ordered_deep.push(folders_ordered[ij]);
loadChildren(folders_ordered[ij].id);
}
}
}
};
loadChildren(parseInt(wpmf.vars.term_root_id));
// Finally save it to the global var
wpmfImportCloudModule.categories = folders_ordered_deep;
},
/**
* open folder tree by dir name
*/
getRendering: function () {
var ij = 0;
var content = '';
var generateList = function (tree_class = '') {
content += '<ul class="' + tree_class + '">';
while (ij < wpmfImportCloudModule.categories.length) {
var className = '';
if (typeof wpmfImportCloudModule.categories[ij].drive_type !== "undefined" && wpmfImportCloudModule.categories[ij].drive_type !== "") {
className += ' hide';
}
// get color folder
var bgcolor = '';
if (typeof wpmf.vars.colors !== 'undefined' && typeof wpmf.vars.colors[wpmfImportCloudModule.categories[ij].id] !== 'undefined') {
bgcolor = 'color: ' + wpmf.vars.colors[wpmfImportCloudModule.categories[ij].id];
} else {
bgcolor = 'color: #8f8f8f';
}
className += ' closed';
// Open li tag
content += '<li class="' + className + '" data-id="' + wpmfImportCloudModule.categories[ij].id + '" >';
const a_tag = '<a data-id="' + wpmfImportCloudModule.categories[ij].id + '">';
if (wpmfImportCloudModule.categories[ij + 1] && wpmfImportCloudModule.categories[ij + 1].depth > wpmfImportCloudModule.categories[ij].depth) { // The next element is a sub folder
// Add folder icon
content += '<a onclick="wpmfImportCloudModule.toggle(' + wpmfImportCloudModule.categories[ij].id + ')"><i class="material-icons wpmf-arrow">keyboard_arrow_down</i></a>';
content += a_tag;
content += '<input type="radio" name="selection_folder_import" class="wpmf_checkbox_tree selection_folder_import" value="'+ wpmfImportCloudModule.categories[ij].id +'" data-id="' + wpmfImportCloudModule.categories[ij].id + '">';
content += '<i class="material-icons-outlined folder-tree-icon" style="' + bgcolor + '">folder</i>';
} else {
content += a_tag;
// Add folder icon
content += '<span class="wpmf-no-arrow"><input type="radio" name="selection_folder_import" class="wpmf_checkbox_tree selection_folder_import" value="'+ wpmfImportCloudModule.categories[ij].id +'" data-id="' + wpmfImportCloudModule.categories[ij].id + '"><i class="material-icons-outlined folder-tree-icon" style="' + bgcolor + '">folder</i></span>';
}
// Add current category name
if (wpmfImportCloudModule.categories[ij].id === 0) {
// If this is the root folder then rename it
content += wpmf.l18n.media_folder;
} else {
content += '<span>' + wpmfImportCloudModule.categories[ij].label + '</span>';
}
content += '</a>';
// This is the end of the array
if (wpmfImportCloudModule.categories[ij + 1] === undefined) {
// Let's close all opened tags
for (let ik = wpmfImportCloudModule.categories[ij].depth; ik >= 0; ik--) {
content += '</li>';
content += '</ul>';
}
// We are at the end don't continue to process array
return false;
}
if (wpmfImportCloudModule.categories[ij + 1].depth > wpmfImportCloudModule.categories[ij].depth) { // The next element is a sub folder
// Recursively list it
ij++;
if (generateList() === false) {
// We have reached the end, let's recursively end
return false;
}
} else if (wpmfImportCloudModule.categories[ij + 1].depth < wpmfImportCloudModule.categories[ij].depth) { // The next element don't have the same parent
// Let's close opened tags
for (let ik = wpmfImportCloudModule.categories[ij].depth; ik > wpmfImportCloudModule.categories[ij + 1].depth; ik--) {
content += '</li>';
content += '</ul>';
}
// We're not at the end of the array let's continue processing it
return true;
}
// Close the current element
content += '</li>';
ij++;
}
};
generateList('wpmf_media_library');
return content;
},
/**
* Toggle the open / closed state of a folder
* @param folder_id
*/
toggle: function (folder_id) {
// get last status folder tree
let lastStatusTree = [];
// Check is folder has closed class
if (wpmfImportCloudModule.getTreeElement().find('li[data-id="' + folder_id + '"]').hasClass('closed')) {
// Open the folder
wpmfImportCloudModule.openFolder(folder_id);
$('#librarytree li[data-id="'+ folder_id +'"] > a >.folder-tree-icon').html('folder_open');
} else {
// Close the folder
wpmfImportCloudModule.closeFolder(folder_id);
// close all sub folder
$('li[data-id="' + folder_id + '"]').find('li').addClass('closed');
$('#librarytree li[data-id="'+ folder_id +'"] > a >.folder-tree-icon').html('folder')
}
},
/**
* Open a folder to show children
*/
openFolder: function (folder_id) {
wpmfImportCloudModule.getTreeElement().find('li[data-id="' + folder_id + '"]').removeClass('closed');
wpmfImportCloudModule.folders_states[folder_id] = 'open';
},
/**
* Close a folder and hide children
*/
closeFolder: function (folder_id) {
wpmfImportCloudModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('closed');
wpmfImportCloudModule.folders_states[folder_id] = 'close';
},
showdialog: function (is_multiple, library_type = 'cloud-library-files', files = [], mimeTypes = [], filenames = [], source = 'photos') {
var text = '';
text += '<div id="librarytree" class="librarytree librarytree_cloudimport"></div>';
if (library_type === 'google-photo' && source === 'album') {
var albumTitle = $('.photo-album-item.selected .album-title span').text();
text += '<div class="import_album_as_new_folder">';
text += '<label>'+ wpmf.l18n.import_album_as_new_folder +'</label>';
text += '<input type="checkbox" checked class="enable_import_album_as_new_folder">';
text += '<input type="text" class="album-title-input" value="'+ albumTitle +'">';
text += '</div>';
}
showDialog({
title: (library_type === 'cloud-library-files') ? wpmf.l18n.import_cloud_title : wpmf.l18n.import_google_photo_title,
id: (library_type === 'google-photo') ? 'wpmf-google-photo-dialog' : 'wpmf-cloud-dialog',
text: text,
negative: {
title: wpmf.l18n.cancel
},
positive: {
title: wpmf.l18n.import,
onClick: function () {
if (!$('.selection_folder_import:checked').length) {
return;
}
var folder = $('.selection_folder_import:checked').val();
if (library_type === 'cloud-library-files') {
var filesselected;
if (is_multiple) {
filesselected = [];
$('.attachment.selected').each(function (i, v) {
var id = $(v).data('id');
if (filesselected.indexOf(id) == -1) {
filesselected.push(id);
}
});
} else {
filesselected = [];
filesselected.push(wpmfFoldersModule.editFileId);
}
var ids = filesselected.join();
wpmfImportCloudModule.importCloud(ids, folder);
} else if (library_type === 'google-photo') {
if (source === 'album') {
var albumId = $('.photo-album-item.selected').data('id');
var album_title = $('.album-title-input').val();
if (album_title === '') {
album_title = $('.photo-album-item.selected .album-title span').text();
}
wpmfImportCloudModule.importGooglePhotoAlbum(albumId, album_title, folder);
} else {
wpmfImportCloudModule.importGooglePhoto(files, mimeTypes, filenames, folder);
}
}
}
}
});
},
importGooglePhotoAlbum: function(albumId, album_title, folder, pageToken = '', created_album = false) {
var datas = {
action: 'wpmf_google_photo_album_import',
albumId: albumId,
pageToken: pageToken,
folder: folder,
wpmf_nonce: wpmf.vars.wpmf_nonce
};
if ($('.enable_import_album_as_new_folder').is(':checked')) {
datas.album_title = album_title;
datas.created_album = (created_album) ? 1 : 0;
} else {
datas.created_album = 1;
}
$.ajax({
url: ajaxurl,
method: 'POST',
dataType: 'json',
data: datas,
beforeSend: function () {
if (!$('.wpmf-snackbar[data-id="importing_cloud_file"]').length) {
wpmfSnackbarModule.show({
id: 'importing_cloud_file',
content: wpmf.l18n.importing_goolge_photo_album,
auto_close: false,
is_progress: true
});
}
},
success: function (res) {
if (res.status) {
if (res.continue) {
wpmfImportCloudModule.importGooglePhotoAlbum(albumId, album_title, res.albumCreatedId, res.pageToken, true);
} else {
wpmfSnackbarModule.close('importing_cloud_file');
}
} else {
wpmfSnackbarModule.close('importing_cloud_file');
}
},
});
},
importGooglePhoto: function (files, mimeTypes, filenames, folder, page = 0) {
$.ajax({
url: ajaxurl,
method: 'POST',
dataType: 'json',
data: {
action: 'wpmf_google_photo_import',
files: files.join(),
mimeTypes: mimeTypes.join(),
filenames: filenames.join(),
page: page,
folder: folder,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
beforeSend: function () {
if (!$('.wpmf-snackbar[data-id="importing_cloud_file"]').length) {
wpmfSnackbarModule.show({
id: 'importing_cloud_file',
content: wpmf.l18n.importing_goolge_photo,
auto_close: false,
is_progress: true
});
}
},
success: function (res) {
if (res.status) {
if (res.continue) {
page++;
wpmfImportCloudModule.importGooglePhoto(files, mimeTypes, filenames, folder, page);
} else {
wpmfSnackbarModule.close('importing_cloud_file');
}
} else {
wpmfSnackbarModule.close('importing_cloud_file');
}
},
});
},
importCloud: function (ids, folder) {
$.ajax({
url: ajaxurl,
method: 'POST',
dataType: 'json',
data: {
action: 'wpmf_cloud_import',
ids: ids,
folder: folder,
wpmf_nonce: wpmf.vars.wpmf_nonce
}, beforeSend: function () {
if (!$('.wpmf-snackbar[data-id="importing_cloud_file"]').length) {
wpmfSnackbarModule.show({
id: 'importing_cloud_file',
content: wpmf.l18n.importing_cloud_file,
icon: '<span class="material-icons-outlined wpmf-snack-icon wpmf-snack-loader">sync</span>',
auto_close: false,
is_progress: true
});
}
},
success: function (res) {
if (res.status) {
if (res.continue) {
wpmfImportCloudModule.importCloud(res.ids, folder);
} else {
wpmfSnackbarModule.close('importing_cloud_file');
if ($('.media-frame').hasClass('mode-select')) {
$('.select-mode-toggle-button').click();
}
wpmfFoldersModule.reloadAttachments();
}
}
},
});
}
};
// Let's initialize WPMF folder tree features
$(document).ready(function () {
if (typeof wp === "undefined") {
return;
}
if ((wpmf.vars.wpmf_pagenow === 'upload.php' && !wpmfFoldersModule.page_type) || typeof wp.media === "undefined") {
return;
}
if (wpmfFoldersModule.page_type !== 'upload-list') {
// Wait for the main wpmf module to be ready
wpmfFoldersModule.on('ready', function ($current_frame) {
if (!$('.upload-php .open-cloud-import').length) {
$('.upload-php .media-frame-content .media-toolbar-secondary').append('<button class="button open-cloud-import media-button button-large">' + wpmf.l18n.import_cloud_btn + '</button>');
$('.open-cloud-import').on('click', function () {
wpmfImportCloudModule.showdialog(true);
wpmfImportCloudModule.initModule();
wpmfFoldersModule.houtside();
});
if (typeof wpmfFoldersModule.categories[wpmfFoldersModule.last_selected_folder].drive_type !== "undefined" && wpmfFoldersModule.categories[wpmfFoldersModule.last_selected_folder].drive_type !== "") {
$('.open-cloud-import ').removeClass('hide');
} else {
$('.open-cloud-import ').addClass('hide');
}
wpmfFoldersModule.on('changeFolder', function (folder_id) {
if (typeof wpmfFoldersModule.categories[folder_id].drive_type !== "undefined" && wpmfFoldersModule.categories[folder_id].drive_type !== "") {
$('.open-cloud-import').removeClass('hide');
} else {
$('.open-cloud-import ').addClass('hide');
}
});
}
});
}
});
}(jQuery));
@@ -0,0 +1,34 @@
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmf.vars.ajaxurl;
}
var current_import_page = 0;
$(document).ready(function () {
/**
* Import order
* @param current_import_page
*/
var wpmfImportOrder = function (current_import_page) {
/* Ajax import */
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: "wpmf",
task: 'import_order',
current_import_page: current_import_page,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (res) {
if (!res.status) {
current_import_page++;
wpmfImportOrder(current_import_page);
}
}
});
};
wpmfImportOrder(current_import_page);
});
}(jQuery));
@@ -0,0 +1,396 @@
var wpmfExternalCatsImportModule;
(function ($) {
wpmfExternalCatsImportModule = {
category_name: '',
categories: [],
categories_order: [],
init: function () {
$('.open_import_external_cats').on('click', function () {
wpmfExternalCatsImportModule.category_name = $(this).data('cat-name');
var title = '';
switch (wpmfExternalCatsImportModule.category_name) {
case "rml_category":
title = import_external_cats_objects.l18n.rml_label_dialog;
break;
case "media_category":
title = import_external_cats_objects.l18n.eml_label_dialog;
break;
case "happyfiles_category":
title = import_external_cats_objects.l18n.happyfiles_label_dialog;
break;
case "media_folder":
title = import_external_cats_objects.l18n.mf_label_dialog;
break;
case "filebird":
title = import_external_cats_objects.l18n.fbv_label_dialog;
break
}
var button = '<div class="wpmfexternal_cats_action">';
button += '<button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect wpmfexternal_cats_button wpmfexternal_cats_import_all_btn">'+ import_external_cats_objects.l18n.import_all_label +'</button>';
button += '<button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect wpmfexternal_cats_button wpmfexternal_cats_import_selected_btn">'+ import_external_cats_objects.l18n.import_selected_label +'</button>';
button += '<button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect wpmfexternal_cats_button wpmfexternal_cats_cancel_btn">'+ import_external_cats_objects.l18n.cancel_label +'</button>';
button += '<span class="spinner" style="margin: 8px"></span>';
button += '</div>';
showDialog({
title: title,
id: 'import-external_cats-dialog',
text: '<div class="wpmfexternal_cats_categories_tree"></div>' + button
});
switch (wpmfExternalCatsImportModule.category_name) {
case "rml_category":
wpmfExternalCatsImportModule.categories_order = import_external_cats_objects.vars.rml_categories_order;
wpmfExternalCatsImportModule.categories = import_external_cats_objects.vars.rml_categories;
break;
case "media_category":
wpmfExternalCatsImportModule.categories_order = import_external_cats_objects.vars.media_category_categories_order;
wpmfExternalCatsImportModule.categories = import_external_cats_objects.vars.media_category_categories;
break;
case "happyfiles_category":
wpmfExternalCatsImportModule.categories_order = import_external_cats_objects.vars.happy_categories_order;
wpmfExternalCatsImportModule.categories = import_external_cats_objects.vars.happy_categories;
break;
case "media_folder":
wpmfExternalCatsImportModule.categories_order = import_external_cats_objects.vars.mf_categories_order;
wpmfExternalCatsImportModule.categories = import_external_cats_objects.vars.mf_categories;
break;
case "filebird":
wpmfExternalCatsImportModule.categories_order = import_external_cats_objects.vars.filebird_categories_order;
wpmfExternalCatsImportModule.categories = import_external_cats_objects.vars.filebird_categories;
break
}
wpmfExternalCatsImportModule.importCategories();
// Render the tree view
wpmfExternalCatsImportModule.loadTreeView();
wpmfExternalCatsImportModule.handleClick();
});
$('.wpmfexternal_cats_notice .wpmf-notice-dismiss').unbind('click').bind('click', function () {
$.ajax({
type: 'POST',
url: import_external_cats_objects.vars.ajaxurl,
data: {
action: "wpmf_update_external_cats_notice_flag",
wpmf_nonce: import_external_cats_objects.vars.wpmf_nonce
},
beforeSend: function () {
$('.wpmfexternal_cats_notice').remove();
},
success: function (res) {}
});
});
},
handleClick: function () {
$('.wpmfexternal_cats-check').unbind('click').bind('click', function () {
if ($(this).closest('.wpmfexternal_cats-item-check').hasClass('wpmfexternal_cats_checked')) {
$(this).closest('.wpmfexternal_cats-item-check').removeClass('wpmfexternal_cats_checked').addClass('wpmfexternal_cats_notchecked');
$(this).closest('li').find('ul .wpmfexternal_cats-item-check').removeClass('wpmfexternal_cats_checked').addClass('wpmfexternal_cats_notchecked');
} else {
$(this).closest('.wpmfexternal_cats-item-check').addClass('wpmfexternal_cats_checked').removeClass('wpmfexternal_cats_notchecked');
$(this).closest('li').find('ul .wpmfexternal_cats-item-check').addClass('wpmfexternal_cats_checked').removeClass('wpmfexternal_cats_notchecked');
}
var parents = $(this).parents('li');
$.each(parents, function (i, parent) {
var checked_length = $(parent).find(' > .wpmfexternal_cats_trees > li > .wpmfexternal_cats-item .wpmfexternal_cats_checked').length;
var not_checked_length = $(parent).find(' > .wpmfexternal_cats_trees > li > .wpmfexternal_cats-item .wpmfexternal_cats_notchecked').length;
if (checked_length && not_checked_length) {
$(parent).find('> .wpmfexternal_cats-item .wpmfexternal_cats-item-check').removeClass('wpmfexternal_cats_checked wpmfexternal_cats_notchecked').addClass('wpmfexternal_cats_part_checked');
}
if (checked_length && !not_checked_length) {
$(parent).find('> .wpmfexternal_cats-item .wpmfexternal_cats-item-check').removeClass('wpmfexternal_cats_part_checked wpmfexternal_cats_notchecked').addClass('wpmfexternal_cats_checked');
}
if (!checked_length && not_checked_length) {
$(parent).find('> .wpmfexternal_cats-item .wpmfexternal_cats-item-check').removeClass('wpmfexternal_cats_part_checked wpmfexternal_cats_checked').addClass('wpmfexternal_cats_notchecked');
}
});
if ($('.wpmfexternal_cats_checked').length) {
$('.wpmfexternal_cats_import_selected_btn').show();
$('.wpmfexternal_cats_import_all_btn').hide();
} else {
$('.wpmfexternal_cats_import_selected_btn').hide();
$('.wpmfexternal_cats_import_all_btn').show();
}
});
$('.wpmfexternal_cats_cancel_btn').unbind('click').bind('click', function () {
var dialod = $('#import-external_cats-dialog');
hideDialog(dialod);
});
$('.wpmfexternal_cats_import_all_btn').unbind('click').bind('click', function () {
wpmfExternalCatsImportModule.getAndInsertAllExternalCatsCategories(1);
});
$('.wpmfexternal_cats_import_selected_btn').unbind('click').bind('click', function () {
var ids = [];
$('.wpmfexternal_cats_checked').each(function (i, checkbox) {
var id = $(checkbox).closest('.wpmfexternal_cats-item').data('id');
if (parseInt(id) !== 0) {
ids.push(id);
}
});
if (ids.length) {
wpmfExternalCatsImportModule.getAndInsertAllExternalCatsCategories(1, 'selected', ids);
}
});
},
getAndInsertAllExternalCatsCategories: function (paged, type = 'all', ids = []) {
var data = {
paged: paged,
wpmf_nonce: import_external_cats_objects.vars.wpmf_nonce
};
switch (wpmfExternalCatsImportModule.category_name) {
case "rml_category":
data.action = 'wpmf_get_insert_rml_categories';
break;
case "media_category":
data.action = 'wpmf_get_insert_eml_categories';
break;
case "happyfiles_category":
data.action = 'wpmf_get_insert_happyfiles_categories';
break;
case "media_folder":
data.action = 'wpmf_get_insert_mf_categories';
break;
case "filebird":
data.action = 'wpmf_get_insert_fbv_categories';
break
}
if (type === 'selected') {
data.type = 'selected';
data.ids = ids.join();
}
$.ajax({
type: 'POST',
url: import_external_cats_objects.vars.ajaxurl,
data: data,
beforeSend: function () {
$('.wpmfexternal_cats_action .spinner').css('visibility', 'visible').show();
},
success: function (res) {
if (res.status) {
if (res.continue) {
wpmfExternalCatsImportModule.getAndInsertAllExternalCatsCategories(parseInt(paged) + 1, type, ids);
} else {
// update parent and add object
wpmfExternalCatsImportModule.updateParentForImportedExternalCatsFolder(1)
}
}
}
});
},
updateParentForImportedExternalCatsFolder: function (paged) {
var data = {
paged: paged,
wpmf_nonce: import_external_cats_objects.vars.wpmf_nonce
};
switch (wpmfExternalCatsImportModule.category_name) {
case "rml_category":
data.action = 'wpmf_update_rml_categories';
break;
case "media_category":
data.action = 'wpmf_update_eml_categories';
break;
case "happyfiles_category":
data.action = 'wpmf_update_happyfiles_categories';
break;
case "media_folder":
data.action = 'wpmf_update_mf_categories';
break;
case "filebird":
data.action = 'wpmf_update_fbv_categories';
break
}
$.ajax({
type: 'POST',
url: import_external_cats_objects.vars.ajaxurl,
data: data,
success: function (res) {
if (res.status) {
if (res.continue) {
wpmfExternalCatsImportModule.updateParentForImportedExternalCatsFolder(parseInt(paged) + 1)
} else {
$('.wpmfexternal_cats_action .spinner').hide();
$('.wpmfexternal_cats_notice').remove();
var dialod = $('#import-external_cats-dialog');
hideDialog(dialod);
if (import_external_cats_objects.vars.pagenow === 'upload.php') {
location.reload();
}
}
}
}
});
},
importCategories: function () {
var folders_ordered = [];
// Add each category
$(wpmfExternalCatsImportModule.categories_order).each(function () {
folders_ordered.push(wpmfExternalCatsImportModule.categories[this]);
});
// Reorder array based on children
var folders_ordered_deep = [];
var processed_ids = [];
var loadChildren = function loadChildren(id) {
if (processed_ids.indexOf(id) < 0) {
processed_ids.push(id);
for (var ij = 0; ij < folders_ordered.length; ij++) {
if (parseInt(folders_ordered[ij].parent_id) === parseInt(id)) {
folders_ordered_deep.push(folders_ordered[ij]);
loadChildren(folders_ordered[ij].id);
}
}
}
};
loadChildren(0);
// Finally save it to the global var
wpmfExternalCatsImportModule.categories = folders_ordered_deep;
},
/**
* Render tree view inside content
*/
loadTreeView: function () {
$('.wpmfexternal_cats_categories_tree').html(wpmfExternalCatsImportModule.getRendering());
},
/**
* Get the html resulting tree view
* @return {string}
*/
getRendering: function () {
var ij = 0;
var content = '';
/**
* Recursively print list of folders
* @return {boolean}
*/
var generateList = function () {
content += '<ul class="wpmfexternal_cats_trees">';
while (ij < wpmfExternalCatsImportModule.categories.length) {
var className = 'closed ';
// Open li tag
content += '<li class="' + className + '" data-id="' + wpmfExternalCatsImportModule.categories[ij].id + '">';
content += '<div class="wpmfexternal_cats-item" data-id="' + wpmfExternalCatsImportModule.categories[ij].id + '">';
content += '<div class="wpmfexternal_cats-item-inside" data-id="' + wpmfExternalCatsImportModule.categories[ij].id + '">';
var a_tag = '<a class="wpmfexternal_cats-text-item" data-id="' + wpmfExternalCatsImportModule.categories[ij].id + '">';
if (wpmfExternalCatsImportModule.categories[ij + 1] && wpmfExternalCatsImportModule.categories[ij + 1].depth > wpmfExternalCatsImportModule.categories[ij].depth) {
// The next element is a sub folder
content += '<a class="wpmfexternal_cats-toggle-icon" onclick="wpmfExternalCatsImportModule.toggle(' + wpmfExternalCatsImportModule.categories[ij].id + ')"><i class="material-icons wpmfexternal_cats-arrow">arrow_right</i></a>';
} else {
content += '<a class="wpmfexternal_cats-toggle-icon wpmfexternal_cats-notoggle-icon"><i class="material-icons wpmfexternal_cats-arrow">arrow_right</i></a>';
}
if (parseInt(wpmfExternalCatsImportModule.categories[ij].id) !== 0) {
content += '<a class="wpmfexternal_cats-item-check wpmfexternal_cats_notchecked"><span class="material-icons wpmfexternal_cats-check wpmfexternal_cats-item-checkbox-checked"> check_box </span><span class="material-icons wpmfexternal_cats-check wpmfexternal_cats-item-checkbox"> check_box_outline_blank </span><span class="material-icons wpmfexternal_cats-check wpmfexternal_cats-item-part-checkbox"> indeterminate_check_box </span></a>';
}
content += a_tag;
if (parseInt(wpmfExternalCatsImportModule.categories[ij].id) === 0) {
content += '<i class="wpmfexternal_cats-icon-root"></i>';
} else {
content += '<i class="material-icons wpmfexternal_cats-item-icon">folder</i>';
}
content += '<span class="wpmfexternal_cats-item-title" data-id="'+ wpmfExternalCatsImportModule.categories[ij].id +'">' + wpmfExternalCatsImportModule.categories[ij].label + '</span>';
content += '</a>';
content += '</div>';
content += '</div>';
// This is the end of the array
if (wpmfExternalCatsImportModule.categories[ij + 1] === undefined) {
// Let's close all opened tags
for (var ik = wpmfExternalCatsImportModule.categories[ij].depth; ik >= 0; ik--) {
content += '</li>';
content += '</ul>';
}
// We are at the end don't continue to process array
return false;
}
if (wpmfExternalCatsImportModule.categories[ij + 1].depth > wpmfExternalCatsImportModule.categories[ij].depth) {
// The next element is a sub folder
// Recursively list it
ij++;
if (generateList() === false) {
// We have reached the end, let's recursively end
return false;
}
} else if (wpmfExternalCatsImportModule.categories[ij + 1].depth < wpmfExternalCatsImportModule.categories[ij].depth) {
// The next element don't have the same parent
// Let's close opened tags
for (var _ik = wpmfExternalCatsImportModule.categories[ij].depth; _ik > wpmfExternalCatsImportModule.categories[ij + 1].depth; _ik--) {
content += '</li>';
content += '</ul>';
}
// We're not at the end of the array let's continue processing it
return true;
}
// Close the current element
content += '</li>';
ij++;
}
};
// Start generation
generateList();
return content;
},
/**
* Toggle the open / closed state of a folder
* @param folder_id
*/
toggle: function (folder_id) {
// Check is folder has closed class
if ($('.wpmfexternal_cats_categories_tree').find('li[data-id="' + folder_id + '"]').hasClass('closed')) {
// Open the folder
wpmfExternalCatsImportModule.openFolder(folder_id);
} else {
// Close the folder
wpmfExternalCatsImportModule.closeFolder(folder_id);
// close all sub folder
$('li[data-id="' + folder_id + '"]').find('li').addClass('closed');
}
},
/**
* Open a folder to show children
*/
openFolder: function (folder_id) {
$('.wpmfexternal_cats_categories_tree').find('li[data-id="' + folder_id + '"]').removeClass('closed');
},
/**
* Close a folder and hide children
*/
closeFolder: function (folder_id) {
$('.wpmfexternal_cats_categories_tree').find('li[data-id="' + folder_id + '"]').addClass('closed');
}
};
$(document).ready(function () {
wpmfExternalCatsImportModule.init();
});
})(jQuery);
@@ -0,0 +1,50 @@
(function ($) {
if (typeof wpmfImportGallery === "undefined") {
return;
}
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmfImportGallery.vars.ajaxurl;
}
$(document).ready(function () {
/**
* Import nextgen gallery
* @param doit true or false
* @param button
*/
var importWpmfgallery = function (doit, button) {
jQuery(button).closest("p").find(".spinner").show().css({"visibility": "visible"});
jQuery.post(ajaxurl, {
action: "import_gallery",
doit: doit,
wpmf_nonce: wpmfImportGallery.vars.wpmf_nonce
}, function (response) {
if (response === "error time") {
jQuery("#wmpfImportgallery").click();
} else {
jQuery(button).closest("div#wpmf_error").hide();
if (doit === true) {
jQuery("#wpmf_error").after("<div class='updated'> <p><strong>NextGEN galleries successfully imported in WP Media Folder</strong></p></div>");
}
}
});
};
/**
* import nextgen gallery
*/
$('#wmpfImportgallery').on('click', function () {
var $this = $(this);
importWpmfgallery(true, $this);
});
/**
* cancel import gallery button
*/
$('.wmpfNoImportgallery').on('click', function () {
var $this = $(this);
importWpmfgallery(false, $this);
});
});
}(jQuery));
@@ -0,0 +1,39 @@
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmfimport.vars.ajaxurl;
}
$(document).ready(function () {
/**
* Import size and filetype
* @param page
*/
var wpmfimport_meta_size = function (page) {
var $this = jQuery('#wmpfImportsize');
$this.find(".spinner").show().css({"visibility": "visible"});
/* Ajax import */
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: "wpmf_import_size_filetype",
wpmf_current_page: page,
wpmf_nonce: wpmfimport.vars.wpmf_nonce
},
success: function (res) {
if (res.status) {
if (res.continue) {
wpmfimport_meta_size(parseInt(page) + 1)
} else {
$this.closest("div#wpmf_error").hide();
}
}
}
});
};
$('#wmpfImportsize').on('click', function () {
wpmfimport_meta_size(0);
});
});
}(jQuery));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,162 @@
function showLoading() {
// remove existing loaders
jQuery('.wpmf-loading-container').remove();
jQuery('<div id="orrsLoader" class="wpmf-loading-container"><div><div class="mdl-spinner mdl-js-spinner is-active"></div></div></div>').appendTo("body");
componentHandler.upgradeElements(jQuery('.mdl-spinner').get());
setTimeout(function () {
jQuery('#orrsLoader').css({opacity: 1});
}, 1);
}
function hideLoading() {
jQuery('#orrsLoader').css({opacity: 0});
setTimeout(function () {
jQuery('#orrsLoader').remove();
}, 400);
}
function showDialog(options) {
options = jQuery.extend({
id: 'orrsDiag',
title: null,
text: null,
neutral: false,
negative: false,
positive: false,
cancelable: true,
contentStyle: null,
onLoaded: false,
hideOther: true,
closeicon:false,
question: false,
question_text: ''
}, options);
if (options.hideOther) {
// remove existing dialogs
jQuery('.wpmf-dialog-container').remove();
jQuery(document).unbind("keyup.dialog");
}
jQuery('<div id="' + options.id + '" class="wpmf-dialog-container"><div class="mdl-card mdl-shadow--16dp" id="' + options.id + '_content"></div></div>').appendTo("body");
var dialog = jQuery('#' + options.id);
var content = dialog.find('.mdl-card');
if(options.closeicon){
jQuery('<i class="material-icons wpmfclosedlg">clear</i>').appendTo(content);
}
if (options.contentStyle != null) content.css(options.contentStyle);
var header = '<div class="mdl-header">';
if (options.title != null) {
header += '<h5>' + options.title + '</h5>';
}
if (options.help_icon != null) {
header += options.help_icon;
}
header += '</div>';
if (options.title != null || options.help_icon != null) {
jQuery(header).appendTo(content);
}
if (options.text != null) {
jQuery('<div class="wpmf-dialog-text">' + options.text + '</div>').appendTo(content);
}
if (options.neutral || options.negative || options.positive) {
var buttonBar = jQuery('<div class="mdl-card__actions dialog-button-bar"></div>');
if (options.neutral) {
options.neutral = jQuery.extend({
id: 'neutral',
title: 'Neutral',
onClick: null
}, options.neutral);
var neuButton = jQuery('<button class="mdl-button mdl-js-button mdl-js-ripple-effect" id="' + options.neutral.id + '">' + options.neutral.title + '</button>');
neuButton.click(function (e) {
e.preventDefault();
if (options.neutral.onClick == null || !options.neutral.onClick(e))
hideDialog(dialog)
});
neuButton.appendTo(buttonBar);
}
if (options.negative) {
options.negative = jQuery.extend({
id: 'negative',
title: 'Cancel',
onClick: null
}, options.negative);
var negButton = jQuery('<button class="mdl-button mdl-js-button mdl-js-ripple-effect" id="' + options.negative.id + '">' + options.negative.title + '</button>');
negButton.click(function (e) {
e.preventDefault();
if (options.negative.onClick == null || !options.negative.onClick(e))
hideDialog(dialog)
});
negButton.appendTo(buttonBar);
}
if (options.positive) {
options.positive = jQuery.extend({
id: 'positive',
title: 'OK',
onClick: null
}, options.positive);
var posButton = jQuery('<button class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect" id="' + options.positive.id + '">' + options.positive.title + '</button>');
posButton.click(function (e) {
e.preventDefault();
if (options.positive.onClick == null || !options.positive.onClick(e))
hideDialog(dialog)
});
posButton.appendTo(buttonBar);
}
buttonBar.appendTo(content);
}
componentHandler.upgradeDom();
if (options.cancelable) {
dialog.click(function () {
hideDialog(dialog, options.question, options.question_text);
});
jQuery(document).bind("keyup.dialog", function (e) {
if (e.which == 27)
hideDialog(dialog);
});
content.click(function (e) {
e.stopPropagation();
});
}
jQuery('.wpmfclosedlg').click(function () {
hideDialog(dialog);
});
setTimeout(function () {
dialog.css({opacity: 1});
if (options.onLoaded)
options.onLoaded();
}, 1);
}
function hideDialog(dialog, question = false, text = '') {
jQuery(document).unbind("keyup.dialog");
if (!question) {
dialog.css({opacity: 0});
setTimeout(function () {
dialog.remove();
}, 400);
} else {
showDialog({
id: 'question-dialog',
text: text,
hideOther: false,
negative: {
title: 'No'
},
positive: {
title: 'Yes',
onClick: function () {
dialog.css({opacity: 0});
setTimeout(function () {
dialog.remove();
}, 400);
}
}
});
}
}
@@ -0,0 +1,62 @@
(function ($) {
"use strict";
$(document).ready(function () {
/* open wordpress link dialog */
$(document).on('click', '#link-btn', function () {
if (typeof wpLink !== "undefined") {
wpLink.open('link-btn');
/* Bind to open link editor! */
$('#wp-link-backdrop').show();
$('#wp-link-wrap').show();
$('#url-field, #wp-link-url').closest('div').find('span').html(wpmf.l18n.link_to);
$('#link-title-field').closest('div').hide();
$('.wp-link-text-field').hide();
$('#url-field, #wp-link-url').val($('.compat-field-wpmf_gallery_custom_image_link input.text').val());
if ($('.compat-field-gallery_link_target select').val() === '_blank') {
$('#link-target-checkbox,#wp-link-target').prop('checked', true);
} else {
$('#link-target-checkbox,#wp-link-target').prop('checked', false);
}
}
});
/* Update link for file */
$(document).on('click', '#wp-link-submit', function () {
var attachment_id = $('.wpmf_attachment_id').val();
var link = $('#url-field').val();
if (typeof link === "undefined") {
link = $('#wp-link-url').val();
} // version 4.2+
var link_target = $('#link-target-checkbox:checked').val();
if (typeof link_target === "undefined") {
link_target = $('#wp-link-target:checked').val();
} // version 4.2+
if (link_target === 'on') {
link_target = '_blank';
} else {
link_target = '';
}
$.ajax({
url: ajaxurl,
method: "POST",
dataType: 'json',
data: {
action: 'wpmf',
task: "update_link",
id: attachment_id,
link: link,
link_target: link_target,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (response) {
$('.compat-field-wpmf_gallery_custom_image_link input.text').val(response.link);
$('.compat-field-gallery_link_target select option[value="' + response.target + '"]').prop('selected', true).change();
}
});
});
});
})(jQuery);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,596 @@
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals VBArray, PDFJS */
(function compatibilityWrapper() {
'use strict';
// Initializing PDFJS global object here, it case if we need to change/disable
// some PDF.js features, e.g. range requests
if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
// Checking if the typed arrays are supported
// Support: iOS<6.0 (subarray), IE<10, Android<4.0
(function checkTypedArrayCompatibility() {
if (typeof Uint8Array !== 'undefined') {
// Support: iOS<6.0
if (typeof Uint8Array.prototype.subarray === 'undefined') {
Uint8Array.prototype.subarray = function subarray(start, end) {
return new Uint8Array(this.slice(start, end));
};
Float32Array.prototype.subarray = function subarray(start, end) {
return new Float32Array(this.slice(start, end));
};
}
// Support: Android<4.1
if (typeof Float64Array === 'undefined') {
window.Float64Array = Float32Array;
}
return;
}
function subarray(start, end) {
return new TypedArray(this.slice(start, end));
}
function setArrayOffset(array, offset) {
if (arguments.length < 2) {
offset = 0;
}
for (var i = 0, n = array.length; i < n; ++i, ++offset) {
this[offset] = array[i] & 0xFF;
}
}
function TypedArray(arg1) {
var result, i, n;
if (typeof arg1 === 'number') {
result = [];
for (i = 0; i < arg1; ++i) {
result[i] = 0;
}
} else if ('slice' in arg1) {
result = arg1.slice(0);
} else {
result = [];
for (i = 0, n = arg1.length; i < n; ++i) {
result[i] = arg1[i];
}
}
result.subarray = subarray;
result.buffer = result;
result.byteLength = result.length;
result.set = setArrayOffset;
if (typeof arg1 === 'object' && arg1.buffer) {
result.buffer = arg1.buffer;
}
return result;
}
window.Uint8Array = TypedArray;
window.Int8Array = TypedArray;
// we don't need support for set, byteLength for 32-bit array
// so we can use the TypedArray as well
window.Uint32Array = TypedArray;
window.Int32Array = TypedArray;
window.Uint16Array = TypedArray;
window.Float32Array = TypedArray;
window.Float64Array = TypedArray;
})();
// URL = URL || webkitURL
// Support: Safari<7, Android 4.2+
(function normalizeURLObject() {
if (!window.URL) {
window.URL = window.webkitURL;
}
})();
// Object.defineProperty()?
// Support: Android<4.0, Safari<5.1
(function checkObjectDefinePropertyCompatibility() {
if (typeof Object.defineProperty !== 'undefined') {
var definePropertyPossible = true;
try {
// some browsers (e.g. safari) cannot use defineProperty() on DOM objects
// and thus the native version is not sufficient
Object.defineProperty(new Image(), 'id', { value: 'test' });
// ... another test for android gb browser for non-DOM objects
var Test = function Test() {};
Test.prototype = { get id() { } };
Object.defineProperty(new Test(), 'id',
{ value: '', configurable: true, enumerable: true, writable: false });
} catch (e) {
definePropertyPossible = false;
}
if (definePropertyPossible) {
return;
}
}
Object.defineProperty = function objectDefineProperty(obj, name, def) {
delete obj[name];
if ('get' in def) {
obj.__defineGetter__(name, def['get']);
}
if ('set' in def) {
obj.__defineSetter__(name, def['set']);
}
if ('value' in def) {
obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
this.__defineGetter__(name, function objectDefinePropertyGetter() {
return value;
});
return value;
});
obj[name] = def.value;
}
};
})();
// No XMLHttpRequest#response?
// Support: IE<11, Android <4.0
(function checkXMLHttpRequestResponseCompatibility() {
var xhrPrototype = XMLHttpRequest.prototype;
var xhr = new XMLHttpRequest();
if (!('overrideMimeType' in xhr)) {
// IE10 might have response, but not overrideMimeType
// Support: IE10
Object.defineProperty(xhrPrototype, 'overrideMimeType', {
value: function xmlHttpRequestOverrideMimeType(mimeType) {}
});
}
if ('responseType' in xhr) {
return;
}
// The worker will be using XHR, so we can save time and disable worker.
PDFJS.disableWorker = true;
Object.defineProperty(xhrPrototype, 'responseType', {
get: function xmlHttpRequestGetResponseType() {
return this._responseType || 'text';
},
set: function xmlHttpRequestSetResponseType(value) {
if (value === 'text' || value === 'arraybuffer') {
this._responseType = value;
if (value === 'arraybuffer' &&
typeof this.overrideMimeType === 'function') {
this.overrideMimeType('text/plain; charset=x-user-defined');
}
}
}
});
// Support: IE9
if (typeof VBArray !== 'undefined') {
Object.defineProperty(xhrPrototype, 'response', {
get: function xmlHttpRequestResponseGet() {
if (this.responseType === 'arraybuffer') {
return new Uint8Array(new VBArray(this.responseBody).toArray());
} else {
return this.responseText;
}
}
});
return;
}
Object.defineProperty(xhrPrototype, 'response', {
get: function xmlHttpRequestResponseGet() {
if (this.responseType !== 'arraybuffer') {
return this.responseText;
}
var text = this.responseText;
var i, n = text.length;
var result = new Uint8Array(n);
for (i = 0; i < n; ++i) {
result[i] = text.charCodeAt(i) & 0xFF;
}
return result.buffer;
}
});
})();
// window.btoa (base64 encode function) ?
// Support: IE<10
(function checkWindowBtoaCompatibility() {
if ('btoa' in window) {
return;
}
var digits =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
window.btoa = function windowBtoa(chars) {
var buffer = '';
var i, n;
for (i = 0, n = chars.length; i < n; i += 3) {
var b1 = chars.charCodeAt(i) & 0xFF;
var b2 = chars.charCodeAt(i + 1) & 0xFF;
var b3 = chars.charCodeAt(i + 2) & 0xFF;
var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
var d4 = i + 2 < n ? (b3 & 0x3F) : 64;
buffer += (digits.charAt(d1) + digits.charAt(d2) +
digits.charAt(d3) + digits.charAt(d4));
}
return buffer;
};
})();
// window.atob (base64 encode function)?
// Support: IE<10
(function checkWindowAtobCompatibility() {
if ('atob' in window) {
return;
}
// https://github.com/davidchambers/Base64.js
var digits =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
window.atob = function (input) {
input = input.replace(/=+$/, '');
if (input.length % 4 === 1) {
throw new Error('bad atob input');
}
for (
// initialize result and counters
var bc = 0, bs, buffer, idx = 0, output = '';
// get next character
buffer = input.charAt(idx++);
// character found in table?
// initialize bit storage and add its ascii value
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
// and if not first of each 4 characters,
// convert the first 8 bits to one ascii character
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
) {
// try to find character in table (0-63, not found => -1)
buffer = digits.indexOf(buffer);
}
return output;
};
})();
// Function.prototype.bind?
// Support: Android<4.0, iOS<6.0
(function checkFunctionPrototypeBindCompatibility() {
if (typeof Function.prototype.bind !== 'undefined') {
return;
}
Function.prototype.bind = function functionPrototypeBind(obj) {
var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
var bound = function functionPrototypeBindBound() {
var args = headArgs.concat(Array.prototype.slice.call(arguments));
return fn.apply(obj, args);
};
return bound;
};
})();
// HTMLElement dataset property
// Support: IE<11, Safari<5.1, Android<4.0
(function checkDatasetProperty() {
var div = document.createElement('div');
if ('dataset' in div) {
return; // dataset property exists
}
Object.defineProperty(HTMLElement.prototype, 'dataset', {
get: function() {
if (this._dataset) {
return this._dataset;
}
var dataset = {};
for (var j = 0, jj = this.attributes.length; j < jj; j++) {
var attribute = this.attributes[j];
if (attribute.name.substring(0, 5) !== 'data-') {
continue;
}
var key = attribute.name.substring(5).replace(/\-([a-z])/g,
function(all, ch) {
return ch.toUpperCase();
});
dataset[key] = attribute.value;
}
Object.defineProperty(this, '_dataset', {
value: dataset,
writable: false,
enumerable: false
});
return dataset;
},
enumerable: true
});
})();
// HTMLElement classList property
// Support: IE<10, Android<4.0, iOS<5.0
(function checkClassListProperty() {
var div = document.createElement('div');
if ('classList' in div) {
return; // classList property exists
}
function changeList(element, itemName, add, remove) {
var s = element.className || '';
var list = s.split(/\s+/g);
if (list[0] === '') {
list.shift();
}
var index = list.indexOf(itemName);
if (index < 0 && add) {
list.push(itemName);
}
if (index >= 0 && remove) {
list.splice(index, 1);
}
element.className = list.join(' ');
return (index >= 0);
}
var classListPrototype = {
add: function(name) {
changeList(this.element, name, true, false);
},
contains: function(name) {
return changeList(this.element, name, false, false);
},
remove: function(name) {
changeList(this.element, name, false, true);
},
toggle: function(name) {
changeList(this.element, name, true, true);
}
};
Object.defineProperty(HTMLElement.prototype, 'classList', {
get: function() {
if (this._classList) {
return this._classList;
}
var classList = Object.create(classListPrototype, {
element: {
value: this,
writable: false,
enumerable: true
}
});
Object.defineProperty(this, '_classList', {
value: classList,
writable: false,
enumerable: false
});
return classList;
},
enumerable: true
});
})();
// Check console compatibility
// In older IE versions the console object is not available
// unless console is open.
// Support: IE<10
(function checkConsoleCompatibility() {
if (!('console' in window)) {
window.console = {
log: function() {},
error: function() {},
warn: function() {}
};
} else if (!('bind' in console.log)) {
// native functions in IE9 might not have bind
console.log = (function(fn) {
return function(msg) { return fn(msg); };
})(console.log);
console.error = (function(fn) {
return function(msg) { return fn(msg); };
})(console.error);
console.warn = (function(fn) {
return function(msg) { return fn(msg); };
})(console.warn);
}
})();
// Check onclick compatibility in Opera
// Support: Opera<15
(function checkOnClickCompatibility() {
// workaround for reported Opera bug DSK-354448:
// onclick fires on disabled buttons with opaque content
function ignoreIfTargetDisabled(event) {
if (isDisabled(event.target)) {
event.stopPropagation();
}
}
function isDisabled(node) {
return node.disabled || (node.parentNode && isDisabled(node.parentNode));
}
if (navigator.userAgent.indexOf('Opera') !== -1) {
// use browser detection since we cannot feature-check this bug
document.addEventListener('click', ignoreIfTargetDisabled, true);
}
})();
// Checks if possible to use URL.createObjectURL()
// Support: IE
(function checkOnBlobSupport() {
// sometimes IE loosing the data created with createObjectURL(), see #3977
if (navigator.userAgent.indexOf('Trident') >= 0) {
PDFJS.disableCreateObjectURL = true;
}
})();
// Checks if navigator.language is supported
(function checkNavigatorLanguage() {
if ('language' in navigator) {
return;
}
PDFJS.locale = navigator.userLanguage || 'en-US';
})();
(function checkRangeRequests() {
// Safari has issues with cached range requests see:
// https://github.com/mozilla/pdf.js/issues/3260
// Last tested with version 6.0.4.
// Support: Safari 6.0+
var isSafari = Object.prototype.toString.call(
window.HTMLElement).indexOf('Constructor') > 0;
// Older versions of Android (pre 3.0) has issues with range requests, see:
// https://github.com/mozilla/pdf.js/issues/3381.
// Make sure that we only match webkit-based Android browsers,
// since Firefox/Fennec works as expected.
// Support: Android<3.0
var regex = /Android\s[0-2][^\d]/;
var isOldAndroid = regex.test(navigator.userAgent);
// Range requests are broken in Chrome 39 and 40, https://crbug.com/442318
var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent);
if (isSafari || isOldAndroid || isChromeWithRangeBug) {
PDFJS.disableRange = true;
PDFJS.disableStream = true;
}
})();
// Check if the browser supports manipulation of the history.
// Support: IE<10, Android<4.2
(function checkHistoryManipulation() {
// Android 2.x has so buggy pushState support that it was removed in
// Android 3.0 and restored as late as in Android 4.2.
// Support: Android 2.x
if (!history.pushState || navigator.userAgent.indexOf('Android 2.') >= 0) {
PDFJS.disableHistory = true;
}
})();
// Support: IE<11, Chrome<21, Android<4.4, Safari<6
(function checkSetPresenceInImageData() {
// IE < 11 will use window.CanvasPixelArray which lacks set function.
if (window.CanvasPixelArray) {
if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
window.CanvasPixelArray.prototype.set = function(arr) {
for (var i = 0, ii = this.length; i < ii; i++) {
this[i] = arr[i];
}
};
}
} else {
// Old Chrome and Android use an inaccessible CanvasPixelArray prototype.
// Because we cannot feature detect it, we rely on user agent parsing.
var polyfill = false, versionMatch;
if (navigator.userAgent.indexOf('Chrom') >= 0) {
versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
// Chrome < 21 lacks the set function.
polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
} else if (navigator.userAgent.indexOf('Android') >= 0) {
// Android < 4.4 lacks the set function.
// Android >= 4.4 will contain Chrome in the user agent,
// thus pass the Chrome check above and not reach this block.
polyfill = /Android\s[0-4][^\d]/g.test(navigator.userAgent);
} else if (navigator.userAgent.indexOf('Safari') >= 0) {
versionMatch = navigator.userAgent.
match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
// Safari < 6 lacks the set function.
polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
}
if (polyfill) {
var contextPrototype = window.CanvasRenderingContext2D.prototype;
var createImageData = contextPrototype.createImageData;
contextPrototype.createImageData = function(w, h) {
var imageData = createImageData.call(this, w, h);
imageData.data.set = function(arr) {
for (var i = 0, ii = this.length; i < ii; i++) {
this[i] = arr[i];
}
};
return imageData;
};
// this closure will be kept referenced, so clear its vars
contextPrototype = null;
}
}
})();
// Support: IE<10, Android<4.0, iOS
(function checkRequestAnimationFrame() {
function fakeRequestAnimationFrame(callback) {
window.setTimeout(callback, 20);
}
var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
if (isIOS) {
// requestAnimationFrame on iOS is broken, replacing with fake one.
window.requestAnimationFrame = fakeRequestAnimationFrame;
return;
}
if ('requestAnimationFrame' in window) {
return;
}
window.requestAnimationFrame =
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
fakeRequestAnimationFrame;
})();
(function checkCanvasSizeLimitation() {
var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
var isAndroid = /Android/g.test(navigator.userAgent);
if (isIOS || isAndroid) {
// 5MP
PDFJS.maxCanvasPixels = 5242880;
}
})();
// Disable fullscreen support for certain problematic configurations.
// Support: IE11+ (when embedded).
(function checkFullscreenSupport() {
var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 &&
window.parent !== window);
if (isEmbeddedIE) {
PDFJS.disableFullscreen = true;
}
})();
// Provides document.currentScript support
// Support: IE, Chrome<29.
(function checkCurrentScript() {
if ('currentScript' in document) {
return;
}
Object.defineProperty(document, 'currentScript', {
get: function () {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
},
enumerable: true,
configurable: true
});
})();
}).call((typeof window === 'undefined') ? this : window);
@@ -0,0 +1,611 @@
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { OPS } = globalThis.pdfjsLib || (await import("pdfjs-lib"));
const opMap = Object.create(null);
for (const key in OPS) {
opMap[OPS[key]] = key;
}
const FontInspector = (function FontInspectorClosure() {
let fonts;
let active = false;
const fontAttribute = "data-font-name";
function removeSelection() {
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (const div of divs) {
div.className = "";
}
}
function resetSelection() {
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (const div of divs) {
div.className = "debuggerHideText";
}
}
function selectFont(fontName, show) {
const divs = document.querySelectorAll(
`span[${fontAttribute}=${fontName}]`
);
for (const div of divs) {
div.className = show ? "debuggerShowText" : "debuggerHideText";
}
}
function textLayerClick(e) {
if (
!e.target.dataset.fontName ||
e.target.tagName.toUpperCase() !== "SPAN"
) {
return;
}
const fontName = e.target.dataset.fontName;
const selects = document.getElementsByTagName("input");
for (const select of selects) {
if (select.dataset.fontName !== fontName) {
continue;
}
select.checked = !select.checked;
selectFont(fontName, select.checked);
select.scrollIntoView();
}
}
return {
// Properties/functions needed by PDFBug.
id: "FontInspector",
name: "Font Inspector",
panel: null,
manager: null,
init() {
const panel = this.panel;
const tmp = document.createElement("button");
tmp.addEventListener("click", resetSelection);
tmp.textContent = "Refresh";
panel.append(tmp);
fonts = document.createElement("div");
panel.append(fonts);
},
cleanup() {
fonts.textContent = "";
},
enabled: false,
get active() {
return active;
},
set active(value) {
active = value;
if (active) {
document.body.addEventListener("click", textLayerClick, true);
resetSelection();
} else {
document.body.removeEventListener("click", textLayerClick, true);
removeSelection();
}
},
// FontInspector specific functions.
fontAdded(fontObj, url) {
function properties(obj, list) {
const moreInfo = document.createElement("table");
for (const entry of list) {
const tr = document.createElement("tr");
const td1 = document.createElement("td");
td1.textContent = entry;
tr.append(td1);
const td2 = document.createElement("td");
td2.textContent = obj[entry].toString();
tr.append(td2);
moreInfo.append(tr);
}
return moreInfo;
}
const moreInfo = properties(fontObj, ["name", "type"]);
const fontName = fontObj.loadedName;
const font = document.createElement("div");
const name = document.createElement("span");
name.textContent = fontName;
const download = document.createElement("a");
if (url) {
url = /url\(['"]?([^)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
download.href = URL.createObjectURL(
new Blob([fontObj.data], { type: fontObj.mimetype })
);
}
download.textContent = "Download";
const logIt = document.createElement("a");
logIt.href = "";
logIt.textContent = "Log";
logIt.addEventListener("click", function (event) {
event.preventDefault();
console.log(fontObj);
});
const select = document.createElement("input");
select.setAttribute("type", "checkbox");
select.dataset.fontName = fontName;
select.addEventListener("click", function () {
selectFont(fontName, select.checked);
});
font.append(select, name, " ", download, " ", logIt, moreInfo);
fonts.append(font);
// Somewhat of a hack, should probably add a hook for when the text layer
// is done rendering.
setTimeout(() => {
if (this.active) {
resetSelection();
}
}, 2000);
},
};
})();
// Manages all the page steppers.
const StepperManager = (function StepperManagerClosure() {
let steppers = [];
let stepperDiv = null;
let stepperControls = null;
let stepperChooser = null;
let breakPoints = Object.create(null);
return {
// Properties/functions needed by PDFBug.
id: "Stepper",
name: "Stepper",
panel: null,
manager: null,
init() {
const self = this;
stepperControls = document.createElement("div");
stepperChooser = document.createElement("select");
stepperChooser.addEventListener("change", function (event) {
self.selectStepper(this.value);
});
stepperControls.append(stepperChooser);
stepperDiv = document.createElement("div");
this.panel.append(stepperControls, stepperDiv);
if (sessionStorage.getItem("pdfjsBreakPoints")) {
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
}
},
cleanup() {
stepperChooser.textContent = "";
stepperDiv.textContent = "";
steppers = [];
},
enabled: false,
active: false,
// Stepper specific functions.
create(pageIndex) {
const debug = document.createElement("div");
debug.id = "stepper" + pageIndex;
debug.hidden = true;
debug.className = "stepper";
stepperDiv.append(debug);
const b = document.createElement("option");
b.textContent = "Page " + (pageIndex + 1);
b.value = pageIndex;
stepperChooser.append(b);
const initBreakPoints = breakPoints[pageIndex] || [];
const stepper = new Stepper(debug, pageIndex, initBreakPoints);
steppers.push(stepper);
if (steppers.length === 1) {
this.selectStepper(pageIndex, false);
}
return stepper;
},
selectStepper(pageIndex, selectPanel) {
pageIndex |= 0;
if (selectPanel) {
this.manager.selectPanel(this);
}
for (const stepper of steppers) {
stepper.panel.hidden = stepper.pageIndex !== pageIndex;
}
for (const option of stepperChooser.options) {
option.selected = (option.value | 0) === pageIndex;
}
},
saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem("pdfjsBreakPoints", JSON.stringify(breakPoints));
},
};
})();
// The stepper for each page's operatorList.
class Stepper {
// Shorter way to create element and optionally set textContent.
#c(tag, textContent) {
const d = document.createElement(tag);
if (textContent) {
d.textContent = textContent;
}
return d;
}
#simplifyArgs(args) {
if (typeof args === "string") {
const MAX_STRING_LENGTH = 75;
return args.length <= MAX_STRING_LENGTH
? args
: args.substring(0, MAX_STRING_LENGTH) + "...";
}
if (typeof args !== "object" || args === null) {
return args;
}
if ("length" in args) {
// array
const MAX_ITEMS = 10,
simpleArgs = [];
let i, ii;
for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
simpleArgs.push(this.#simplifyArgs(args[i]));
}
if (i < args.length) {
simpleArgs.push("...");
}
return simpleArgs;
}
const simpleObj = {};
for (const key in args) {
simpleObj[key] = this.#simplifyArgs(args[key]);
}
return simpleObj;
}
constructor(panel, pageIndex, initialBreakPoints) {
this.panel = panel;
this.breakPoint = 0;
this.nextBreakPoint = null;
this.pageIndex = pageIndex;
this.breakPoints = initialBreakPoints;
this.currentIdx = -1;
this.operatorListIdx = 0;
this.indentLevel = 0;
}
init(operatorList) {
const panel = this.panel;
const content = this.#c("div", "c=continue, s=step");
const table = this.#c("table");
content.append(table);
table.cellSpacing = 0;
const headerRow = this.#c("tr");
table.append(headerRow);
headerRow.append(
this.#c("th", "Break"),
this.#c("th", "Idx"),
this.#c("th", "fn"),
this.#c("th", "args")
);
panel.append(content);
this.table = table;
this.updateOperatorList(operatorList);
}
updateOperatorList(operatorList) {
const self = this;
function cboxOnClick() {
const x = +this.dataset.idx;
if (this.checked) {
self.breakPoints.push(x);
} else {
self.breakPoints.splice(self.breakPoints.indexOf(x), 1);
}
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
}
const MAX_OPERATORS_COUNT = 15000;
if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
return;
}
const chunk = document.createDocumentFragment();
const operatorsToDisplay = Math.min(
MAX_OPERATORS_COUNT,
operatorList.fnArray.length
);
for (let i = this.operatorListIdx; i < operatorsToDisplay; i++) {
const line = this.#c("tr");
line.className = "line";
line.dataset.idx = i;
chunk.append(line);
const checked = this.breakPoints.includes(i);
const args = operatorList.argsArray[i] || [];
const breakCell = this.#c("td");
const cbox = this.#c("input");
cbox.type = "checkbox";
cbox.className = "points";
cbox.checked = checked;
cbox.dataset.idx = i;
cbox.onclick = cboxOnClick;
breakCell.append(cbox);
line.append(breakCell, this.#c("td", i.toString()));
const fn = opMap[operatorList.fnArray[i]];
let decArgs = args;
if (fn === "showText") {
const glyphs = args[0];
const charCodeRow = this.#c("tr");
const fontCharRow = this.#c("tr");
const unicodeRow = this.#c("tr");
for (const glyph of glyphs) {
if (typeof glyph === "object" && glyph !== null) {
charCodeRow.append(this.#c("td", glyph.originalCharCode));
fontCharRow.append(this.#c("td", glyph.fontChar));
unicodeRow.append(this.#c("td", glyph.unicode));
} else {
// null or number
const advanceEl = this.#c("td", glyph);
advanceEl.classList.add("advance");
charCodeRow.append(advanceEl);
fontCharRow.append(this.#c("td"));
unicodeRow.append(this.#c("td"));
}
}
decArgs = this.#c("td");
const table = this.#c("table");
table.classList.add("showText");
decArgs.append(table);
table.append(charCodeRow, fontCharRow, unicodeRow);
} else if (fn === "restore" && this.indentLevel > 0) {
this.indentLevel--;
}
line.append(this.#c("td", " ".repeat(this.indentLevel * 2) + fn));
if (fn === "save") {
this.indentLevel++;
}
if (decArgs instanceof HTMLElement) {
line.append(decArgs);
} else {
line.append(this.#c("td", JSON.stringify(this.#simplifyArgs(decArgs))));
}
}
if (operatorsToDisplay < operatorList.fnArray.length) {
const lastCell = this.#c("td", "...");
lastCell.colspan = 4;
chunk.append(lastCell);
}
this.operatorListIdx = operatorList.fnArray.length;
this.table.append(chunk);
}
getNextBreakPoint() {
this.breakPoints.sort(function (a, b) {
return a - b;
});
for (const breakPoint of this.breakPoints) {
if (breakPoint > this.currentIdx) {
return breakPoint;
}
}
return null;
}
breakIt(idx, callback) {
StepperManager.selectStepper(this.pageIndex, true);
this.currentIdx = idx;
const listener = evt => {
switch (evt.keyCode) {
case 83: // step
document.removeEventListener("keydown", listener);
this.nextBreakPoint = this.currentIdx + 1;
this.goTo(-1);
callback();
break;
case 67: // continue
document.removeEventListener("keydown", listener);
this.nextBreakPoint = this.getNextBreakPoint();
this.goTo(-1);
callback();
break;
}
};
document.addEventListener("keydown", listener);
this.goTo(idx);
}
goTo(idx) {
const allRows = this.panel.getElementsByClassName("line");
for (const row of allRows) {
if ((row.dataset.idx | 0) === idx) {
row.style.backgroundColor = "rgb(251,250,207)";
row.scrollIntoView();
} else {
row.style.backgroundColor = null;
}
}
}
}
const Stats = (function Stats() {
let stats = [];
function clear(node) {
node.textContent = ""; // Remove any `node` contents from the DOM.
}
function getStatIndex(pageNumber) {
for (const [i, stat] of stats.entries()) {
if (stat.pageNumber === pageNumber) {
return i;
}
}
return false;
}
return {
// Properties/functions needed by PDFBug.
id: "Stats",
name: "Stats",
panel: null,
manager: null,
init() {},
enabled: false,
active: false,
// Stats specific functions.
add(pageNumber, stat) {
if (!stat) {
return;
}
const statsIndex = getStatIndex(pageNumber);
if (statsIndex !== false) {
stats[statsIndex].div.remove();
stats.splice(statsIndex, 1);
}
const wrapper = document.createElement("div");
wrapper.className = "stats";
const title = document.createElement("div");
title.className = "title";
title.textContent = "Page: " + pageNumber;
const statsDiv = document.createElement("div");
statsDiv.textContent = stat.toString();
wrapper.append(title, statsDiv);
stats.push({ pageNumber, div: wrapper });
stats.sort(function (a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (const entry of stats) {
this.panel.append(entry.div);
}
},
cleanup() {
stats = [];
clear(this.panel);
},
};
})();
// Manages all the debugging tools.
class PDFBug {
static #buttons = [];
static #activePanel = null;
static tools = [FontInspector, StepperManager, Stats];
static enable(ids) {
const all = ids.length === 1 && ids[0] === "all";
const tools = this.tools;
for (const tool of tools) {
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
}
if (!all) {
// Sort the tools by the order they are enabled.
tools.sort(function (a, b) {
let indexA = ids.indexOf(a.id);
indexA = indexA < 0 ? tools.length : indexA;
let indexB = ids.indexOf(b.id);
indexB = indexB < 0 ? tools.length : indexB;
return indexA - indexB;
});
}
}
static init(container, ids) {
this.loadCSS();
this.enable(ids);
/*
* Basic Layout:
* PDFBug
* Controls
* Panels
* Panel
* Panel
* ...
*/
const ui = document.createElement("div");
ui.id = "PDFBug";
const controls = document.createElement("div");
controls.setAttribute("class", "controls");
ui.append(controls);
const panels = document.createElement("div");
panels.setAttribute("class", "panels");
ui.append(panels);
container.append(ui);
container.style.right = "var(--panel-width)";
// Initialize all the debugging tools.
for (const tool of this.tools) {
const panel = document.createElement("div");
const panelButton = document.createElement("button");
panelButton.textContent = tool.name;
panelButton.addEventListener("click", event => {
event.preventDefault();
this.selectPanel(tool);
});
controls.append(panelButton);
panels.append(panel);
tool.panel = panel;
tool.manager = this;
if (tool.enabled) {
tool.init();
} else {
panel.textContent =
`${tool.name} is disabled. To enable add "${tool.id}" to ` +
"the pdfBug parameter and refresh (separate multiple by commas).";
}
this.#buttons.push(panelButton);
}
this.selectPanel(0);
}
static loadCSS() {
const { url } = import.meta;
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = url.replace(/.js$/, ".css");
document.head.append(link);
}
static cleanup() {
for (const tool of this.tools) {
if (tool.enabled) {
tool.cleanup();
}
}
}
static selectPanel(index) {
if (typeof index !== "number") {
index = this.tools.indexOf(index);
}
if (index === this.#activePanel) {
return;
}
this.#activePanel = index;
for (const [j, tool] of this.tools.entries()) {
const isActive = j === index;
this.#buttons[j].classList.toggle("active", isActive);
tool.active = isActive;
tool.panel.hidden = !isActive;
}
}
}
globalThis.FontInspector = FontInspector;
globalThis.StepperManager = StepperManager;
globalThis.Stats = Stats;
export { PDFBug };
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,75 @@
(function ($) {
var status_regenthumbs = false;
var current_page_regenthumbs = 1;
$(document).ready(function ($) {
/* click 'Regenerate all image thumbnails' button */
$('.btn_regenerate_thumbnails').on('click', function () {
status_regenthumbs = true;
if (status_regenthumbs) {
$(this).html(wpmfoption.l18n.continue).hide();
$('.btn_stop_regenerate_thumbnails').show();
wpmf_regenthumbs(current_page_regenthumbs);
}
});
/* stop regenerate thumbnails */
$('.btn_stop_regenerate_thumbnails').on('click', function () {
status_regenthumbs = false;
$('.btn_regenerate_thumbnails').show();
$(this).hide();
});
/**
* Regenerate thumbnails
* @param paged current page
*/
var wpmf_regenthumbs = function (paged) {
if (!status_regenthumbs) {
return;
}
$('.process_gennerate_thumb_full').show();
$('.img_thumbnail').show();
$('.right_wrap_render_thumbnail').removeClass('wpmf_width_100 wpmf-no-margin');
$('.btn_regenerate_thumbnails ').removeClass('wpmf_width_100');
$.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: "wpmf_regeneratethumbnail",
paged: paged,
wpmf_nonce: wpmf.vars.wpmf_nonce
},
success: function (res) {
var w = $('.process_gennerate_thumb').data('w');
/* Check status and set progress bar */
if (res.status === 'ok') {
current_page_regenthumbs = 1;
$('.btn_regenerate_thumbnails').html(wpmfoption.l18n.regenerate_all_image_lb).show();
$('.process_gennerate_thumb').data('w', 0).css('width', '100%');
$('.process_gennerate_thumb_full span').html('100%');
$('.btn_stop_regenerate_thumbnails').hide();
}
/* Check status and set progress bar */
if (res.status === 'limit') {
current_page_regenthumbs = parseInt(paged) + 1;
if (typeof res.percent !== "undefined") {
var new_w = parseFloat(w) + parseFloat(res.percent);
if (new_w > 100)
new_w = 100;
$('.process_gennerate_thumb_full').show();
$('.process_gennerate_thumb').data('w', new_w).css('width', new_w + '%');
$('.process_gennerate_thumb_full span').html(parseInt(new_w) + '%');
}
wpmf_regenthumbs(current_page_regenthumbs);
}
if (typeof res.url !== "undefined" && typeof res.url[0] !== "undefined") {
$('.img_thumbnail').attr('src', res.url[0]);
}
$('.result_gennerate_thumb').show().append(res.success);
}
});
};
});
})(jQuery);
@@ -0,0 +1,391 @@
var wpmfReplaceModule;
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmfParams.vars.ajaxurl;
}
wpmfReplaceModule = {
/**
* Init event
*/
doEvent: function () {
/* When change input file value */
$('#wpmf_upload_input_version').off('change').on('change', function (event) {
/* submit form upload */
$('#wpmf_form_upload').submit();
});
/* submit form upload */
$('.wpmf_submit_upload').off('click').on('click', function (event) {
$('#wpmf_upload_input_version').click();
});
},
/**
* Create form replace
* @param id id of attachment
* @returns {string}
*/
genFormReplace: function (id) {
$('.replace_wrap').remove();
var form_replace = '<div class="replace_wrap">';
form_replace += '<form id="wpmf_form_upload" method="post" action="' + wpmfParams.vars.ajaxurl + '" enctype="multipart/form-data">';
form_replace += '<input type="hidden" name="wpmf_nonce" value="' + wpmfParams.vars.wpmf_nonce + '">';
form_replace += '<input class="hide" type="file" name="wpmf_replace_file" id="wpmf_upload_input_version" style="display: none"><input type="button" value="' + wpmfParams.l18n.replace + '" class="button-primary wpmf_submit_upload" id="submit-upload"/>';
form_replace += '<input type="hidden" name="action" value="wpmf_replace_file">';
form_replace += '<input type="hidden" name="post_selected" value="' + id + '">';
form_replace += '</form>';
form_replace += '</div>';
form_replace += '<style>#post ~ .replace_wrap {display: none}</style>';
return form_replace;
},
/**
* Replace attachment
* @param attachmentID
*/
replace_attachment: function (attachmentID) {
var $snack = '';
$('#wpmf_form_upload').ajaxForm({
uploadProgress: function (event, position, total, wpmf_percentComplete) {
if (!$('.wpmf_replace_process').length) {
$snack = wpmfSnackbarModule.show({
id : 'wpmf_replace_process',
content : wpmfParams.l18n.file_uploading,
auto_close : false,
is_progress : true
});
}
},
success: function () {
wpmfSnackbarModule.close('wpmf_replace_process');
},
complete: function (xhr) {
$('#wpmf_progress').hide();
var ob = JSON.parse(xhr.responseText);
if (typeof xhr.responseText !== "undefined") {
if (ob.status) {
$('.file-size').html('<strong>' + wpmfParams.l18n.filesize_label + ' ' + ob.size + '</strong>');
if (typeof ob.dimensions !== "undefined") {
$('.dimensions').html('<strong>' + wpmfParams.l18n.dimensions_label + ' ' + ob.dimensions + '</strong>');
}
var d = new Date();
var n = d.getTime();
if (wpmfParams.vars.wpmf_pagenow !== 'post.php') {
if (typeof wpmfFoldersModule.hover_images[attachmentID] !== "undefined") {
var url = wpmfFoldersModule.hover_images[attachmentID].wpmfurl;
wpmfFoldersModule.hover_images[attachmentID].wpmfurl = url + '?ver=' + n;
}
}
// Show snackbar
wpmfSnackbarModule.show({
id: 'replace_file',
content: wpmfParams.l18n.wpmf_file_replace
});
var $thumb;
if (wpmfParams.vars.wpmf_pagenow !== 'post.php') {
$thumb = $('.attachment[data-id="' + attachmentID + '"] .thumbnail').find('img');
} else {
$thumb = $('#thumbnail-head-' + attachmentID + ' img');
}
if (wpmfParams.vars.wpmf_pagenow === 'post.php') {
var old_url = $thumb.attr('src');
$('#thumbnail-head-' + attachmentID + ' img').attr('src', old_url + '?ver=' + n);
} else {
var src_thumbnail = $thumb.attr('src');
$thumb.attr('src', src_thumbnail + '?ver=' + n);
var $img = $('.attachment-details').find('.thumbnail img');
var src_detail = $img.attr('src');
$img.attr('src', src_detail + '?ver=' + n);
/* clear cache img */
wpmfReplaceModule.forceImgReload(src_thumbnail, false, null, false);
wpmfReplaceModule.forceImgReload(src_detail, false, null, false);
}
} else {
alert(ob.msg);
}
}
}
});
},
/**
* read http://stackoverflow.com/questions/1077041/refresh-image-with-a-new-one-at-the-same-url#answer-22429796
* @param src
* @returns {Array}
*/
imgReloadBlank: function (src) {
// ##### Everything here is provisional on the way the pages are designed, and what images they contain; what follows is for example purposes only!
// ##### For really simple pages containing just a single image that's always the one being refreshed, this function could be as simple as just the one line:
// ##### document.getElementById("myImage").src = "/img/1x1blank.gif";
var blankList = [],
fullSrc = src /* Fully qualified (absolute) src - i.e. prepend protocol, server/domain, and path if not present in src */,
imgs, img, i;
//foreach (/* window accessible from this one, i.e. this window, and child frames/iframes, the parent window, anything opened via window.open(), and anything recursively reachable from there */)
//{
// get list of matching images:
imgs = window.document.body.getElementsByTagName("img");
for (i = imgs.length; i--;) // could instead use body.querySelectorAll(), to check both tag name and src attribute, which would probably be more efficient, where supported
{
if ((img = imgs[i]).src === fullSrc) {
img.src = "/img/1x1blank.gif"; // blank them
blankList.push(img); // optionally, save list of blanked images to make restoring easy later on
}
}
//}
// ##### If necessary, do something here that tells all accessible windows not to create any *new* images with src===fullSrc, until further notice,
// ##### (or perhaps to create them initially blank instead and add them to blankList).
// ##### For example, you might have (say) a global object window.top.blankedSrces as a propery of your topmost window, initially set = {}. Then you could do:
// #####
// ##### var bs = window.top.blankedSrces;
// ##### if (bs.hasOwnProperty(src)) bs[src]++; else bs[src] = 1;
// #####
// ##### And before creating a new image using javascript, you'd first ensure that (blankedSrces.hasOwnProperty(src)) was false...
// ##### Note that incrementing a counter here rather than just setting a flag allows for the possibility that multiple forced-reloads of the same image are underway at once, or are overlapping.
return blankList; // optional - only if using blankList for restoring back the blanked images! This just gets passed in to imgReloadRestore(), it isn't used otherwise.
},
/**
* This function restores all blanked images, that were blanked out by imgReloadBlank(src) for the matching src argument.
* You should code the actual contents of this function according to your page design, and what images there are on them, as well as how/if images are dimensioned, etc!!! #####
* @param src
* @param blankList
* @param imgDim
* @param loadError
*/
imgReloadRestore: function (src, blankList, imgDim, loadError) {
// ##### Everything here is provisional on the way the pages are designed, and what images they contain; what follows is for example purposes only!
// ##### For really simple pages containing just a single image that's always the one being refreshed, this function could be as simple as just the one line:
// ##### document.getElementById("myImage").src = src;
// ##### if in imgReloadBlank() you did something to tell all accessible windows not to create any *new* images with src===fullSrc until further notice, retract that setting now!
// ##### For example, if you used the global object window.top.blankedSrces as described there, then you could do:
// #####
// ##### var bs = window.top.blankedSrces;
// ##### if (bs.hasOwnProperty(src)&&--bs[src]) return; else delete bs[src]; // return here means don't restore until ALL forced reloads complete.
var i, img, width = imgDim && imgDim[0], height = imgDim && imgDim[1];
if (width) width += "px";
if (height) height += "px";
if (loadError) {/* If you want, do something about an image that couldn't load, e.g: src = "/img/brokenImg.jpg"; or alert("Couldn't refresh image from server!"); */
}
// If you saved & returned blankList in imgReloadBlank(), you can just use this to restore:
for (i = blankList.length; i--;) {
(img = blankList[i]).src = src;
if (width) img.style.width = width;
if (height) img.style.height = height;
}
},
/**
* Force an image to be reloaded from the server, bypassing/refreshing the cache.
* due to limitations of the browser API, this actually requires TWO load attempts - an initial load into a hidden iframe, and then a call to iframe.contentWindow.location.reload(true);
* If image is from a different domain (i.e. cross-domain restrictions are in effect, you must set isCrossDomain = true, or the script will crash!
* imgDim is a 2-element array containing the image x and y dimensions, or it may be omitted or null; it can be used to set a new image size at the same time the image is updated, if applicable.
* if "twostage" is true, the first load will occur immediately, and the return value will be a function
* that takes a boolean parameter (true to proceed with the 2nd load (including the blank-and-reload procedure), false to cancel) and an optional updated imgDim.
* This allows you to do the first load early... for example during an upload (to the server) of the image you want to (then) refresh.
* @param src
* @param isCrossDomain
* @param imgDim
* @param twostage
* @returns {*}
*/
forceImgReload: function (src, isCrossDomain, imgDim, twostage) {
var blankList, step = 0, // step: 0 - started initial load, 1 - wait before proceeding (twostage mode only), 2 - started forced reload, 3 - cancelled
iframe = window.document.createElement("iframe"), // Hidden iframe, in which to perform the load+reload.
loadCallback = function (e) // Callback function, called after iframe load+reload completes (or fails).
{ // Will be called TWICE unless twostage-mode process is cancelled. (Once after load, once after reload).
if (!step) // initial load just completed. Note that it doesn't actually matter if this load succeeded or not!
{
if (twostage) step = 1; // wait for twostage-mode proceed or cancel; don't do anything else just yet
else {
step = 2;
blankList = wpmfReplaceModule.imgReloadBlank(src);
iframe.contentWindow.location.reload(true);
} // initiate forced-reload
}
else if (step === 2) // forced re-load is done
{
wpmfReplaceModule.imgReloadRestore(src, blankList, imgDim, (e || window.event).type === "error"); // last parameter checks whether loadCallback was called from the "load" or the "error" event.
if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
}
};
iframe.style.display = "none";
window.parent.document.body.appendChild(iframe); // NOTE: if this is done AFTER setting src, Firefox MAY fail to fire the load event!
iframe.addEventListener("load", loadCallback, false);
iframe.addEventListener("error", loadCallback, false);
iframe.src = (isCrossDomain ? "/echoimg.php?src=" + encodeURIComponent(src) : src); // If src is cross-domain, script will crash unless we embed the image in a same-domain html page (using server-side script)!!!
return (twostage
? function (proceed, dim) {
if (!twostage) return;
twostage = false;
if (proceed) {
imgDim = (dim || imgDim); // overwrite imgDim passed in to forceImgReload() - just in case you know the correct img dimensions now, but didn't when forceImgReload() was called.
if (step === 1) {
step = 2;
blankList = wpmfReplaceModule.imgReloadBlank(src);
iframe.contentWindow.location.reload(true);
}
}
else {
step = 3;
if (iframe.contentWindow.stop) iframe.contentWindow.stop();
if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
}
}
: null);
}
};
$(document).ready(function () {
if (wpmfParams.vars.wpmf_pagenow === 'post.php') {
if (!$('.wpmf_replace_btn').length) {
$('.wp_attachment_image').append('<p><input type="button" value="'+ wpmfParams.l18n.replace +'" class="button-primary wpmf_replace_btn"></p>');
$('.wpmf_replace_btn').on('click', function () {
$('.wpmf_submit_upload').click();
});
var attachmentID = $('#post_ID').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
$('#post').after(form_replace);
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}
return;
}
if (typeof wp === "undefined") {
return
}
if ((wpmfParams.vars.wpmf_pagenow === 'upload.php' && !wpmfFoldersModule.page_type) || typeof wp.media === "undefined") {
return;
}
if (wpmfFoldersModule.page_type !== 'upload-list') {
var myreplaceForm = wp.media.view.AttachmentsBrowser;
if (typeof myreplaceForm !== "undefined") {
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
createSingle: function () {
myreplaceForm.prototype.createSingle.apply(this, arguments);
var sidebar = this.sidebar;
var attachmentID = $('.wpmf_attachment_id').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
if (wpmfParams.vars.wpmf_pagenow !== 'upload.php') {
if (typeof wpmfParams.vars.override !== 'undefined' && parseInt(wpmfParams.vars.override) === 1) {
$('.replace_wrap').remove();
$(sidebar.$el).find('.attachment-info .details').append(form_replace);
}
}
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}
});
}
/* Create replace button when wp smush plugin active */
if (wpmfParams.vars.get_plugin_active.indexOf('wp-smush.php') !== -1) {
if( 'undefined' !== typeof wp.media.view &&
'undefined' !== typeof wp.media.view.Attachment.Details.TwoColumn ) {
// Local instance of the Attachment Details TwoColumn used in the edit attachment modal view
var wpmfAssignMediaTwoColumn = wp.media.view.Attachment.Details.TwoColumn;
/**
* Add Smush details to attachment.
*/
if (typeof wpmfAssignMediaTwoColumn !== "undefined") {
wp.media.view.Attachment.Details.TwoColumn = wp.media.view.Attachment.Details.TwoColumn.extend({
render: function () {
// Get Smush status for the image
wpmfAssignMediaTwoColumn.prototype.render.apply(this);
$( document ).ajaxComplete(function( event, xhr, settings ) {
var data = settings.data;
if (typeof data === 'string') {
if (data.indexOf('smush_get_attachment_details') !== -1) {
var attachmentID = $('.wpmf_attachment_id').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
$('.replace_wrap').remove();
$('.details').append(form_replace);
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}
}
});
}
});
}
}
}
var myReplace = wp.media.view.Modal;
if (typeof myReplace !== "undefined") {
wp.media.view.Modal = wp.media.view.Modal.extend({
open: function () {
myReplace.prototype.open.apply(this, arguments);
if (wpmfParams.vars.wpmf_pagenow === 'upload.php') {
if (typeof wpmfParams.vars.override !== 'undefined' && parseInt(wpmfParams.vars.override) === 1) {
setTimeout(function () {
var attachmentID = $('.wpmf_attachment_id').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
$('.replace_wrap').remove();
$('.attachment-details .details').append(form_replace);
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}, 150);
}
}
}
});
}
if (wpmfParams.vars.wpmf_pagenow === 'upload.php') {
// create replace button when next and prev media items
var myReplaceEditAttachments = wp.media.view.MediaFrame.EditAttachments;
if (typeof myReplaceEditAttachments !== "undefined") {
wp.media.view.MediaFrame.EditAttachments = wp.media.view.MediaFrame.EditAttachments.extend({
previousMediaItem: function () {
/* Create duplicate button setting */
myReplaceEditAttachments.prototype.previousMediaItem.apply(this, arguments);
if (typeof wpmfParams.vars.override !== 'undefined' && parseInt(wpmfParams.vars.override) === 1) {
var attachmentID = $('.wpmf_attachment_id').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
$('.replace_wrap').remove();
$('.attachment-details .details').append(form_replace);
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}
},
nextMediaItem: function () {
/* Create duplicate button setting */
myReplaceEditAttachments.prototype.nextMediaItem.apply(this, arguments);
if (typeof wpmfParams.vars.override !== 'undefined' && parseInt(wpmfParams.vars.override) === 1) {
var attachmentID = $('.wpmf_attachment_id').val();
var form_replace = wpmfReplaceModule.genFormReplace(attachmentID);
$('.replace_wrap').remove();
$('.attachment-details .details').append(form_replace);
wpmfReplaceModule.doEvent();
wpmfReplaceModule.replace_attachment(attachmentID);
}
}
});
}
}
}
});
}(jQuery));
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,904 @@
/*************** SCROLLBAR BASE CSS ***************/
.scroll-wrapper {
overflow: hidden !important;
padding: 0 !important;
position: relative;
}
.scroll-wrapper > .scroll-content {
border: none !important;
box-sizing: content-box !important;
height: auto;
left: 0;
margin: 0;
max-height: none;
max-width: none !important;
overflow: scroll !important;
padding: 0;
position: relative !important;
top: 0;
width: auto !important;
}
.scroll-wrapper > .scroll-content::-webkit-scrollbar {
height: 0;
width: 0;
}
.scroll-wrapper.scroll--rtl {
direction: rtl;
}
.scroll-element {
box-sizing: content-box;
display: none;
}
.scroll-element div {
box-sizing: content-box;
}
.scroll-element .scroll-bar,
.scroll-element .scroll-arrow {
cursor: default;
}
.scroll-element.scroll-x.scroll-scrollx_visible, .scroll-element.scroll-y.scroll-scrolly_visible {
display: block;
}
.scroll-textarea {
border: 1px solid #cccccc;
border-top-color: #999999;
}
.scroll-textarea > .scroll-content {
overflow: hidden !important;
}
.scroll-textarea > .scroll-content > textarea {
border: none !important;
box-sizing: border-box;
height: 100% !important;
margin: 0;
max-height: none !important;
max-width: none !important;
overflow: scroll !important;
outline: none;
padding: 2px;
position: relative !important;
top: 0;
width: 100% !important;
}
.scroll-textarea > .scroll-content > textarea::-webkit-scrollbar {
height: 0;
width: 0;
}
/*************** SIMPLE INNER SCROLLBAR ***************/
.scrollbar-inner > .scroll-element,
.scrollbar-inner > .scroll-element div {
border: none;
margin: 0;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-inner > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-inner > .scroll-element.scroll-x {
bottom: 2px;
height: 8px;
left: 0;
width: 100%;
}
.scrollbar-inner > .scroll-element.scroll-y {
height: 100%;
right: 2px;
top: 0;
width: 8px;
}
.scrollbar-inner > .scroll-element .scroll-element_outer {
overflow: hidden;
}
.scrollbar-inner > .scroll-element .scroll-element_outer,
.scrollbar-inner > .scroll-element .scroll-element_track,
.scrollbar-inner > .scroll-element .scroll-bar {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
.scrollbar-inner > .scroll-element .scroll-element_track,
.scrollbar-inner > .scroll-element .scroll-bar {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";
filter: alpha(opacity=40);
opacity: 0.4;
}
.scrollbar-inner > .scroll-element .scroll-element_track {
background-color: #e0e0e0;
}
.scrollbar-inner > .scroll-element .scroll-bar {
background-color: #c2c2c2;
}
.scrollbar-inner > .scroll-element:hover .scroll-bar {
background-color: #919191;
}
.scrollbar-inner > .scroll-element.scroll-draggable .scroll-bar {
background-color: #919191;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-inner > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_track {
left: -12px;
}
.scrollbar-inner > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_track {
top: -12px;
}
.scrollbar-inner > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -12px;
}
.scrollbar-inner > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -12px;
}
/*************** SIMPLE OUTER SCROLLBAR ***************/
.scrollbar-outer > .scroll-element,
.scrollbar-outer > .scroll-element div {
border: none;
margin: 0;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-outer > .scroll-element {
background-color: #ffffff;
}
.scrollbar-outer > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-outer > .scroll-element.scroll-x {
bottom: 0;
height: 12px;
left: 0;
width: 100%;
}
.scrollbar-outer > .scroll-element.scroll-y {
height: 100%;
right: 0;
top: 0;
width: 12px;
}
.scrollbar-outer > .scroll-element.scroll-x .scroll-element_outer {
height: 8px;
top: 2px;
}
.scrollbar-outer > .scroll-element.scroll-y .scroll-element_outer {
left: 2px;
width: 8px;
}
.scrollbar-outer > .scroll-element .scroll-element_outer {
overflow: hidden;
}
.scrollbar-outer > .scroll-element .scroll-element_track {
background-color: #eeeeee;
}
.scrollbar-outer > .scroll-element .scroll-element_outer,
.scrollbar-outer > .scroll-element .scroll-element_track,
.scrollbar-outer > .scroll-element .scroll-bar {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
.scrollbar-outer > .scroll-element .scroll-bar {
background-color: #d9d9d9;
}
.scrollbar-outer > .scroll-element .scroll-bar:hover {
background-color: #c2c2c2;
}
.scrollbar-outer > .scroll-element.scroll-draggable .scroll-bar {
background-color: #919191;
}
/* scrollbar height/width & offset from container borders */
.scrollbar-outer > .scroll-content.scroll-scrolly_visible {
left: -12px;
margin-left: 12px;
}
.scrollbar-outer > .scroll-content.scroll-scrollx_visible {
top: -12px;
margin-top: 12px;
}
.scrollbar-outer > .scroll-element.scroll-x .scroll-bar {
min-width: 10px;
}
.scrollbar-outer > .scroll-element.scroll-y .scroll-bar {
min-height: 10px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-outer > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_track {
left: -14px;
}
.scrollbar-outer > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_track {
top: -14px;
}
.scrollbar-outer > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -14px;
}
.scrollbar-outer > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -14px;
}
/*************** SCROLLBAR MAC OS X ***************/
.scrollbar-macosx > .scroll-element,
.scrollbar-macosx > .scroll-element div {
background: none;
border: none;
margin: 0;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-macosx > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-macosx > .scroll-element .scroll-element_track {
display: none;
}
.scrollbar-macosx > .scroll-element .scroll-bar {
background-color: #6C6E71;
display: block;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
-ms-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.scrollbar-macosx:hover > .scroll-element .scroll-bar,
.scrollbar-macosx > .scroll-element.scroll-draggable .scroll-bar {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
filter: alpha(opacity=70);
opacity: 0.7;
}
.scrollbar-macosx > .scroll-element.scroll-x {
bottom: 0px;
height: 0px;
left: 0;
min-width: 100%;
overflow: visible;
width: 100%;
}
.scrollbar-macosx > .scroll-element.scroll-y {
height: 100%;
min-height: 100%;
right: 0px;
top: 0;
width: 0px;
}
/* scrollbar height/width & offset from container borders */
.scrollbar-macosx > .scroll-element.scroll-x .scroll-bar {
height: 7px;
min-width: 10px;
top: -9px;
}
.scrollbar-macosx > .scroll-element.scroll-y .scroll-bar {
left: -9px;
min-height: 10px;
width: 7px;
}
.scrollbar-macosx > .scroll-element.scroll-x .scroll-element_outer {
left: 2px;
}
.scrollbar-macosx > .scroll-element.scroll-x .scroll-element_size {
left: -4px;
}
.scrollbar-macosx > .scroll-element.scroll-y .scroll-element_outer {
top: 2px;
}
.scrollbar-macosx > .scroll-element.scroll-y .scroll-element_size {
top: -4px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-macosx > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -11px;
}
.scrollbar-macosx > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -11px;
}
/*************** SCROLLBAR LIGHT ***************/
.scrollbar-light > .scroll-element,
.scrollbar-light > .scroll-element div {
border: none;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-light > .scroll-element {
background-color: #ffffff;
}
.scrollbar-light > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-light > .scroll-element .scroll-element_outer {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.scrollbar-light > .scroll-element .scroll-element_size {
background: #dbdbdb;
background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2RiZGJkYiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlOGU4ZTgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+");
background: -moz-linear-gradient(left, #dbdbdb 0%, #e8e8e8 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, #dbdbdb), color-stop(100%, #e8e8e8));
background: -webkit-linear-gradient(left, #dbdbdb 0%, #e8e8e8 100%);
background: -o-linear-gradient(left, #dbdbdb 0%, #e8e8e8 100%);
background: -ms-linear-gradient(left, #dbdbdb 0%, #e8e8e8 100%);
background: linear-gradient(to right, #dbdbdb 0%, #e8e8e8 100%);
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.scrollbar-light > .scroll-element.scroll-x {
bottom: 0;
height: 17px;
left: 0;
min-width: 100%;
width: 100%;
}
.scrollbar-light > .scroll-element.scroll-y {
height: 100%;
min-height: 100%;
right: 0;
top: 0;
width: 17px;
}
.scrollbar-light > .scroll-element .scroll-bar {
background: #fefefe;
background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZlZmVmZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmNWY1ZjUiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+");
background: -moz-linear-gradient(left, #fefefe 0%, #f5f5f5 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, #fefefe), color-stop(100%, #f5f5f5));
background: -webkit-linear-gradient(left, #fefefe 0%, #f5f5f5 100%);
background: -o-linear-gradient(left, #fefefe 0%, #f5f5f5 100%);
background: -ms-linear-gradient(left, #fefefe 0%, #f5f5f5 100%);
background: linear-gradient(to right, #fefefe 0%, #f5f5f5 100%);
border: 1px solid #dbdbdb;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
/* scrollbar height/width & offset from container borders */
.scrollbar-light > .scroll-content.scroll-scrolly_visible {
left: -17px;
margin-left: 17px;
}
.scrollbar-light > .scroll-content.scroll-scrollx_visible {
top: -17px;
margin-top: 17px;
}
.scrollbar-light > .scroll-element.scroll-x .scroll-bar {
height: 10px;
min-width: 10px;
top: 0px;
}
.scrollbar-light > .scroll-element.scroll-y .scroll-bar {
left: 0px;
min-height: 10px;
width: 10px;
}
.scrollbar-light > .scroll-element.scroll-x .scroll-element_outer {
height: 12px;
left: 2px;
top: 2px;
}
.scrollbar-light > .scroll-element.scroll-x .scroll-element_size {
left: -4px;
}
.scrollbar-light > .scroll-element.scroll-y .scroll-element_outer {
left: 2px;
top: 2px;
width: 12px;
}
.scrollbar-light > .scroll-element.scroll-y .scroll-element_size {
top: -4px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-light > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -19px;
}
.scrollbar-light > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -19px;
}
.scrollbar-light > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_track {
left: -19px;
}
.scrollbar-light > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_track {
top: -19px;
}
/*************** SCROLLBAR RAIL ***************/
.scrollbar-rail > .scroll-element,
.scrollbar-rail > .scroll-element div {
border: none;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-rail > .scroll-element {
background-color: #ffffff;
}
.scrollbar-rail > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-rail > .scroll-element .scroll-element_size {
background-color: #999;
background-color: rgba(0, 0, 0, 0.3);
}
.scrollbar-rail > .scroll-element .scroll-element_outer:hover .scroll-element_size {
background-color: #666;
background-color: rgba(0, 0, 0, 0.5);
}
.scrollbar-rail > .scroll-element.scroll-x {
bottom: 0;
height: 12px;
left: 0;
min-width: 100%;
padding: 3px 0 2px;
width: 100%;
}
.scrollbar-rail > .scroll-element.scroll-y {
height: 100%;
min-height: 100%;
padding: 0 2px 0 3px;
right: 0;
top: 0;
width: 12px;
}
.scrollbar-rail > .scroll-element .scroll-bar {
background-color: #d0b9a0;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}
.scrollbar-rail > .scroll-element .scroll-element_outer:hover .scroll-bar {
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}
/* scrollbar height/width & offset from container borders */
.scrollbar-rail > .scroll-content.scroll-scrolly_visible {
left: -17px;
margin-left: 17px;
}
.scrollbar-rail > .scroll-content.scroll-scrollx_visible {
margin-top: 17px;
top: -17px;
}
.scrollbar-rail > .scroll-element.scroll-x .scroll-bar {
height: 10px;
min-width: 10px;
top: 1px;
}
.scrollbar-rail > .scroll-element.scroll-y .scroll-bar {
left: 1px;
min-height: 10px;
width: 10px;
}
.scrollbar-rail > .scroll-element.scroll-x .scroll-element_outer {
height: 15px;
left: 5px;
}
.scrollbar-rail > .scroll-element.scroll-x .scroll-element_size {
height: 2px;
left: -10px;
top: 5px;
}
.scrollbar-rail > .scroll-element.scroll-y .scroll-element_outer {
top: 5px;
width: 15px;
}
.scrollbar-rail > .scroll-element.scroll-y .scroll-element_size {
left: 5px;
top: -10px;
width: 2px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-rail > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -25px;
}
.scrollbar-rail > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -25px;
}
.scrollbar-rail > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_track {
left: -25px;
}
.scrollbar-rail > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_track {
top: -25px;
}
/*************** SCROLLBAR DYNAMIC ***************/
.scrollbar-dynamic > .scroll-element,
.scrollbar-dynamic > .scroll-element div {
background: none;
border: none;
margin: 0;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-dynamic > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-dynamic > .scroll-element.scroll-x {
bottom: 2px;
height: 7px;
left: 0;
min-width: 100%;
width: 100%;
}
.scrollbar-dynamic > .scroll-element.scroll-y {
height: 100%;
min-height: 100%;
right: 2px;
top: 0;
width: 7px;
}
.scrollbar-dynamic > .scroll-element .scroll-element_outer {
opacity: 0.3;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
}
.scrollbar-dynamic > .scroll-element .scroll-element_size {
background-color: #cccccc;
opacity: 0;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-webkit-transition: opacity 0.2s;
-moz-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
transition: opacity 0.2s;
}
.scrollbar-dynamic > .scroll-element .scroll-bar {
background-color: #6c6e71;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
}
/* scrollbar height/width & offset from container borders */
.scrollbar-dynamic > .scroll-element.scroll-x .scroll-bar {
bottom: 0;
height: 7px;
min-width: 24px;
top: auto;
}
.scrollbar-dynamic > .scroll-element.scroll-y .scroll-bar {
left: auto;
min-height: 24px;
right: 0;
width: 7px;
}
.scrollbar-dynamic > .scroll-element.scroll-x .scroll-element_outer {
bottom: 0;
top: auto;
left: 2px;
-webkit-transition: height 0.2s;
-moz-transition: height 0.2s;
-o-transition: height 0.2s;
-ms-transition: height 0.2s;
transition: height 0.2s;
}
.scrollbar-dynamic > .scroll-element.scroll-y .scroll-element_outer {
left: auto;
right: 0;
top: 2px;
-webkit-transition: width 0.2s;
-moz-transition: width 0.2s;
-o-transition: width 0.2s;
-ms-transition: width 0.2s;
transition: width 0.2s;
}
.scrollbar-dynamic > .scroll-element.scroll-x .scroll-element_size {
left: -4px;
}
.scrollbar-dynamic > .scroll-element.scroll-y .scroll-element_size {
top: -4px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-dynamic > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -11px;
}
.scrollbar-dynamic > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -11px;
}
/* hover & drag */
.scrollbar-dynamic > .scroll-element:hover .scroll-element_outer,
.scrollbar-dynamic > .scroll-element.scroll-draggable .scroll-element_outer {
overflow: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
filter: alpha(opacity=70);
opacity: 0.7;
}
.scrollbar-dynamic > .scroll-element:hover .scroll-element_outer .scroll-element_size,
.scrollbar-dynamic > .scroll-element.scroll-draggable .scroll-element_outer .scroll-element_size {
opacity: 1;
}
.scrollbar-dynamic > .scroll-element:hover .scroll-element_outer .scroll-bar,
.scrollbar-dynamic > .scroll-element.scroll-draggable .scroll-element_outer .scroll-bar {
height: 100%;
width: 100%;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
}
.scrollbar-dynamic > .scroll-element.scroll-x:hover .scroll-element_outer,
.scrollbar-dynamic > .scroll-element.scroll-x.scroll-draggable .scroll-element_outer {
height: 20px;
min-height: 7px;
}
.scrollbar-dynamic > .scroll-element.scroll-y:hover .scroll-element_outer,
.scrollbar-dynamic > .scroll-element.scroll-y.scroll-draggable .scroll-element_outer {
min-width: 7px;
width: 20px;
}
/*************** SCROLLBAR GOOGLE CHROME ***************/
.scrollbar-chrome > .scroll-element,
.scrollbar-chrome > .scroll-element div {
border: none;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
z-index: 10;
}
.scrollbar-chrome > .scroll-element {
background-color: #ffffff;
}
.scrollbar-chrome > .scroll-element div {
display: block;
height: 100%;
left: 0;
top: 0;
width: 100%;
}
.scrollbar-chrome > .scroll-element .scroll-element_track {
background: #f1f1f1;
border: 1px solid #dbdbdb;
}
.scrollbar-chrome > .scroll-element.scroll-x {
bottom: 0;
height: 16px;
left: 0;
min-width: 100%;
width: 100%;
}
.scrollbar-chrome > .scroll-element.scroll-y {
height: 100%;
min-height: 100%;
right: 0;
top: 0;
width: 16px;
}
.scrollbar-chrome > .scroll-element .scroll-bar {
background-color: #d9d9d9;
border: 1px solid #bdbdbd;
cursor: default;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.scrollbar-chrome > .scroll-element .scroll-bar:hover {
background-color: #c2c2c2;
border-color: #a9a9a9;
}
.scrollbar-chrome > .scroll-element.scroll-draggable .scroll-bar {
background-color: #919191;
border-color: #7e7e7e;
}
/* scrollbar height/width & offset from container borders */
.scrollbar-chrome > .scroll-content.scroll-scrolly_visible {
left: -16px;
margin-left: 16px;
}
.scrollbar-chrome > .scroll-content.scroll-scrollx_visible {
top: -16px;
margin-top: 16px;
}
.scrollbar-chrome > .scroll-element.scroll-x .scroll-bar {
height: 8px;
min-width: 10px;
top: 3px;
}
.scrollbar-chrome > .scroll-element.scroll-y .scroll-bar {
left: 3px;
min-height: 10px;
width: 8px;
}
.scrollbar-chrome > .scroll-element.scroll-x .scroll-element_outer {
border-left: 1px solid #dbdbdb;
}
.scrollbar-chrome > .scroll-element.scroll-x .scroll-element_track {
height: 14px;
left: -3px;
}
.scrollbar-chrome > .scroll-element.scroll-x .scroll-element_size {
height: 14px;
left: -4px;
}
.scrollbar-chrome > .scroll-element.scroll-y .scroll-element_outer {
border-top: 1px solid #dbdbdb;
}
.scrollbar-chrome > .scroll-element.scroll-y .scroll-element_track {
top: -3px;
width: 14px;
}
.scrollbar-chrome > .scroll-element.scroll-y .scroll-element_size {
top: -4px;
width: 14px;
}
/* update scrollbar offset if both scrolls are visible */
.scrollbar-chrome > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_size {
left: -19px;
}
.scrollbar-chrome > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_size {
top: -19px;
}
.scrollbar-chrome > .scroll-element.scroll-x.scroll-scrolly_visible .scroll-element_track {
left: -19px;
}
.scrollbar-chrome > .scroll-element.scroll-y.scroll-scrollx_visible .scroll-element_track {
top: -19px;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
tinymce.PluginManager.add('wpmf_mce', function (editor) {
editor.on('init', function () {
editor.on('mousedown mouseup click touchend', function (event) {
/* remove element in editor */
jQuery('.mce-ico.mce-i-dashicon.dashicons-no').on('click', function () {
if (event.target.nodeName !== "IMG" && jQuery(event.target).hasClass('wpmf_mce-single-child')) {
editor.dom.remove(jQuery(event.target).closest('.wpmf_mce-wrap'));
}
});
});
});
});
@@ -0,0 +1,12 @@
jQuery(document).ready(function ($) {
$('.wpmf-defile').on('click', function (e) {
e.preventDefault();
var id = $(this).data('id');
var href = $(this).attr('href');
if (href.indexOf('docs.google.com') != -1) {
window.open(href);
} else {
window.location.href = wpmf_single.vars.site_url + '?act=wpmf_download_file&id=' + id + '&wpmf_nonce=' + wpmf_single.vars.wpmf_nonce;
}
});
});
@@ -0,0 +1,22 @@
(function ($) {
$(document).ready(function () {
if (typeof wp !== "undefined" && typeof wp.media !== "undefined") {
var myEmbedImage = wp.media.view.ImageDetails;
if (typeof myEmbedImage !== 'undefined') {
wp.media.view.ImageDetails = wp.media.view.ImageDetails.extend({
initialize: function() {
myEmbedImage.prototype.initialize.apply(this, arguments);
this.on('post-render', this.add_settings);
},
// To add the Settings
add_settings: function() {
var $el = this.$el;
$el.find('.embed-media-settings .column-settings .setting.link-to').after(wp.media.template('image-wpmf'));
//this.controller.image.set({"data-settings": 'wpmf_size_lightbox'})
$el.find('.wpmf_size_lightbox option[value="'+ this.controller.image.attributes.wpmf_size_lightbox +'"]').prop('selected',true).change();
}
});
}
}
});
})(jQuery);
@@ -0,0 +1,59 @@
(function ($) {
$(document).ready(function () {
if (jQuery().magnificPopup) {
/* open lightbox when click to image */
if ($('.wpmf_image_lightbox, .open-lightbox-feature-image').length) {
$('.wpmf_image_lightbox, .open-lightbox-feature-image').magnificPopup({
gallery: {
enabled: true,
tCounter: '<span class="mfp-counter">%curr% / %total%</span>',
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>' // markup of an arrow button
},
callbacks: {
elementParse: function (q) {
if (q.el.closest('a').length) {
q.src = q.el.closest('a').attr('href');
} else {
q.src = q.el.attr('src');
}
}
},
type: 'image',
showCloseBtn: false,
image: {
titleSrc: 'title'
}
});
}
/* open lightbox when click to image */
$('body a').each(function(i,v){
if($(v).find('img[data-wpmflightbox="1"]').length !== 0){
$(v).magnificPopup({
delegate: 'img',
gallery: {
enabled: true,
tCounter: '<span class="mfp-counter">%curr% / %total%</span>',
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>' // markup of an arrow button
},
callbacks: {
elementParse: function(q) {
var wpmf_lightbox = q.el.data('wpmf_image_lightbox');
if(typeof wpmf_lightbox === "undefined"){
q.src = q.el.attr('src');
}else{
q.src = wpmf_lightbox;
}
}
},
type: 'image',
showCloseBtn : false,
image: {
titleSrc: 'title'
}
});
}
});
}
});
})(jQuery);
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@@ -0,0 +1,14 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by Fontastic.me</metadata>
<defs>
<font id="slick" horiz-adv-x="512">
<font-face font-family="slick" units-per-em="512" ascent="480" descent="-32"/>
<missing-glyph horiz-adv-x="512" />
<glyph unicode="&#8594;" d="M241 113l130 130c4 4 6 8 6 13 0 5-2 9-6 13l-130 130c-3 3-7 5-12 5-5 0-10-2-13-5l-29-30c-4-3-6-7-6-12 0-5 2-10 6-13l87-88-87-88c-4-3-6-8-6-13 0-5 2-9 6-12l29-30c3-3 8-5 13-5 5 0 9 2 12 5z m234 143c0-40-9-77-29-110-20-34-46-60-80-80-33-20-70-29-110-29-40 0-77 9-110 29-34 20-60 46-80 80-20 33-29 70-29 110 0 40 9 77 29 110 20 34 46 60 80 80 33 20 70 29 110 29 40 0 77-9 110-29 34-20 60-46 80-80 20-33 29-70 29-110z"/>
<glyph unicode="&#8592;" d="M296 113l29 30c4 3 6 7 6 12 0 5-2 10-6 13l-87 88 87 88c4 3 6 8 6 13 0 5-2 9-6 12l-29 30c-3 3-8 5-13 5-5 0-9-2-12-5l-130-130c-4-4-6-8-6-13 0-5 2-9 6-13l130-130c3-3 7-5 12-5 5 0 10 2 13 5z m179 143c0-40-9-77-29-110-20-34-46-60-80-80-33-20-70-29-110-29-40 0-77 9-110 29-34 20-60 46-80 80-20 33-29 70-29 110 0 40 9 77 29 110 20 34 46 60 80 80 33 20 70 29 110 29 40 0 77-9 110-29 34-20 60-46 80-80 20-33 29-70 29-110z"/>
<glyph unicode="&#8226;" d="M475 256c0-40-9-77-29-110-20-34-46-60-80-80-33-20-70-29-110-29-40 0-77 9-110 29-34 20-60 46-80 80-20 33-29 70-29 110 0 40 9 77 29 110 20 34 46 60 80 80 33 20 70 29 110 29 40 0 77-9 110-29 34-20 60-46 80-80 20-33 29-70 29-110z"/>
<glyph unicode="&#97;" d="M475 439l0-128c0-5-1-9-5-13-4-4-8-5-13-5l-128 0c-8 0-13 3-17 11-3 7-2 14 4 20l40 39c-28 26-62 39-100 39-20 0-39-4-57-11-18-8-33-18-46-32-14-13-24-28-32-46-7-18-11-37-11-57 0-20 4-39 11-57 8-18 18-33 32-46 13-14 28-24 46-32 18-7 37-11 57-11 23 0 44 5 64 15 20 9 38 23 51 42 2 1 4 3 7 3 3 0 5-1 7-3l39-39c2-2 3-3 3-6 0-2-1-4-2-6-21-25-46-45-76-59-29-14-60-20-93-20-30 0-58 5-85 17-27 12-51 27-70 47-20 19-35 43-47 70-12 27-17 55-17 85 0 30 5 58 17 85 12 27 27 51 47 70 19 20 43 35 70 47 27 12 55 17 85 17 28 0 55-5 81-15 26-11 50-26 70-45l37 37c6 6 12 7 20 4 8-4 11-9 11-17z"/>
</font></defs></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

@@ -0,0 +1,204 @@
@charset 'UTF-8';
/* Slider */
.slick-loading .slick-list
{
background: #fff url('./ajax-loader.gif') center center no-repeat;
}
/* Icons */
@font-face
{
font-family: 'slick';
font-weight: normal;
font-style: normal;
src: url('./fonts/slick.eot');
src: url('./fonts/slick.eot?#iefix') format('embedded-opentype'), url('./fonts/slick.woff') format('woff'), url('./fonts/slick.ttf') format('truetype'), url('./fonts/slick.svg#slick') format('svg');
}
/* Arrows */
.slick-prev,
.slick-next
{
font-size: 0;
line-height: 0;
position: absolute;
top: 50%;
display: block;
width: 20px;
height: 20px;
padding: 0;
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
cursor: pointer;
color: transparent;
border: none;
outline: none;
background: transparent;
}
.slick-prev:hover,
.slick-prev:focus,
.slick-next:hover,
.slick-next:focus
{
color: transparent;
outline: none;
background: transparent;
}
.slick-prev:hover:before,
.slick-prev:focus:before,
.slick-next:hover:before,
.slick-next:focus:before
{
opacity: 1;
}
.slick-prev.slick-disabled:before,
.slick-next.slick-disabled:before
{
opacity: .25;
}
.slick-prev:before,
.slick-next:before
{
font-family: 'slick';
font-size: 20px;
line-height: 1;
opacity: .75;
color: white;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.slick-prev
{
left: -25px;
}
[dir='rtl'] .slick-prev
{
right: -25px;
left: auto;
}
.slick-prev:before
{
content: '←';
}
[dir='rtl'] .slick-prev:before
{
content: '→';
}
.slick-next
{
right: -25px;
}
[dir='rtl'] .slick-next
{
right: auto;
left: -25px;
}
.slick-next:before
{
content: '→';
}
[dir='rtl'] .slick-next:before
{
content: '←';
}
/* Dots */
.slick-dotted.slick-slider
{
margin-bottom: 20px;
}
.slick-dots
{
position: absolute;
bottom: -25px;
display: block;
width: 100%;
padding: 0;
margin: 0;
list-style: none;
text-align: center;
}
.slick-dots li
{
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li button
{
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus
{
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before
{
opacity: 1;
}
.slick-dots li button:before
{
font-family: 'slick';
font-size: 6px;
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 20px;
height: 20px;
content: '•';
text-align: center;
opacity: .25;
color: black;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.slick-dots li.slick-active button:before
{
opacity: .75;
color: black;
}
@@ -0,0 +1,119 @@
/* Slider */
.slick-slider
{
position: relative;
display: block;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list
{
position: relative;
display: block;
overflow: hidden;
margin: 0;
padding: 0;
}
.slick-list:focus
{
outline: none;
}
.slick-list.dragging
{
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-track,
.slick-slider .slick-list
{
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track
{
position: relative;
top: 0;
left: 0;
display: block;
margin-left: auto;
margin-right: auto;
}
.slick-track:before,
.slick-track:after
{
display: table;
content: '';
}
.slick-track:after
{
clear: both;
}
.slick-loading .slick-track
{
visibility: hidden;
}
.slick-slide
{
display: none;
float: left;
height: 100%;
min-height: 1px;
}
[dir='rtl'] .slick-slide
{
float: right;
}
.slick-slide img
{
display: block;
}
.slick-slide.slick-loading img
{
display: none;
}
.slick-slide.dragging img
{
pointer-events: none;
}
.slick-initialized .slick-slide
{
display: block;
}
.slick-loading .slick-slide
{
visibility: hidden;
}
.slick-vertical .slick-slide
{
display: block;
height: auto;
border: 1px solid transparent;
}
.slick-arrow.slick-hidden {
display: none;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,171 @@
/**
* Snackbar main module
*/
let wpmfSnackbarModule;
(function($) {
wpmfSnackbarModule = {
snackbar_ids : [],
$snackbar_wrapper : null, // Snackbar jQuery wrapper
snackbar_defaults : {
onClose : function(){}, // Callback function when snackbar is closed
is_undoable : false, // Show or not the undo button
onUndo : function(){}, // Callback function when snackbar is undoed
icon: '<span class="material-icons-outlined wpmf-snack-icon"> campaign </span>',
is_closable : true, // Can this snackbar be closed by user
auto_close : true, // Do the snackbar close automatically
auto_close_delay : 6000, // Time to wait before closing automatically
is_progress : false, // Do we show the progress bar
percentage : null // Percentage of the progress bar
},
/**
* Initialize snackbar module
*/
initModule : function() {
wpmfSnackbarModule.$snackbar_wrapper = $(`<div class="wpmf-snackbar-wrapper"></div>`).appendTo('body');
},
/**
* Display a new snackbar
* @param options
* @return HTMLElement the snackbar generated
*/
show : function(options) {
if (options === undefined) {
options = {};
}
// Set default values
options = $.extend(
{},wpmfSnackbarModule.snackbar_defaults,
options
);
// If an id is set save it
if (typeof options.id === "undefined") {
options.id = options.content;
}
if (options.id !== undefined) {
wpmfSnackbarModule.snackbar_ids[options.id] = options;
}
return wpmfSnackbarModule.renderSnack(options);
},
renderSnack: function(notification_options) {
let notification_class = 'wpmf-snackbar-wrap';
if (typeof notification_options !== "undefined" && typeof notification_options.error !== "undefined" && notification_options.error) {
notification_class += ' wpmf-snackbar-error'
}
let snack = `<div class="${notification_class}">`;
let snack_count = 0;
Object.keys(wpmfSnackbarModule.snackbar_ids).map(function(snack_id, index) {
snack_count ++;
let options = wpmfSnackbarModule.snackbar_ids[snack_id];
// Generate undo html if needed
let undo = '';
if(options.is_undoable) {
undo = '<a href="#" class="wpmf-snackbar-undo">'+wpmf.l18n.wpmf_undo+'</a>';
}
let id = '';
if(options.id) {
id = 'data-id="'+options.id+'"';
}
snack += `<div ${id} class="wpmf-snackbar">
${options.icon}
<div class="wpmf-snackbar-content">${options.content}</div>
${undo}
</div>`;
});
snack += '<a class="wpmf-snackbar-close" href="#"><i class="material-icons">close</i></a>';
snack += '</div>';
// Add element to the DOM
$('.wpmf-snackbar-wrap').remove();
if (snack_count > 0) {
let $snack = $(snack).prependTo(wpmfSnackbarModule.$snackbar_wrapper);
// Initialize undo function
$snack.find('.wpmf-snackbar-undo').click(function(e){
let snack_id = $(this).closest('.wpmf-snackbar').data('id');
e.preventDefault();
wpmfSnackbarModule.snackbar_ids[snack_id].onUndo();
// Reset the close function as we've done an undo
wpmfSnackbarModule.snackbar_ids[snack_id].onClose = function(){};
// Finally close the snackbar
wpmfSnackbarModule.snackbar_ids[snack_id].close(snack_id);
});
Object.keys(wpmfSnackbarModule.snackbar_ids).map(function(snack_id, index) {
// Initialize autoclose feature
let options = wpmfSnackbarModule.snackbar_ids[snack_id];
if(options.auto_close) {
setTimeout(function(){
wpmfSnackbarModule.close(options.id)
}, options.auto_close_delay);
}
});
// Initialize close button
$snack.find('.wpmf-snackbar-close').click(function(e){
$(this).closest('.wpmf-snackbar-wrap').remove();
wpmfSnackbarModule.snackbar_ids = [];
});
}
},
/**
* Remove a snackbar and call onClose callback if needed
* @param snack_id snackbar element
*/
close : function(snack_id){
// Remove the id if exists
if (snack_id !== undefined) {
delete wpmfSnackbarModule.snackbar_ids[snack_id];
}
wpmfSnackbarModule.renderSnack();
},
/**
* Retrieve an existing snackbar from its id
* @param id
* @return {null|object}
*/
getFromId : function(id) {
if (wpmfSnackbarModule.snackbar_ids[id] === undefined) {
return null;
}
return id;
},
/**
* Set the snackbar progress bar width
* @param $snack jQuery element representing a snackbar
* @param percentage int
*/
setProgress : function($snack, percentage) {
if ($snack===null) {
return;
}
let $progress = $snack.find('.wpmfliner_progress > div');
if(percentage !== undefined) {
$progress.addClass('determinate').removeClass('indeterminate');
$progress.css('width', percentage+'%');
} else {
$progress.addClass('indeterminate').removeClass('determinate');
}
}
};
// Let's initialize WPMF features
$(document).ready(function () {
wpmfSnackbarModule.initModule();
});
})(jQuery);
@@ -0,0 +1,165 @@
'use strict';
/**
* Snackbar main module
*/
var wpmfSnackbarModule = void 0;
(function ($) {
wpmfSnackbarModule = {
snackbar_ids: [],
$snackbar_wrapper: null, // Snackbar jQuery wrapper
snackbar_defaults: {
onClose: function onClose() {}, // Callback function when snackbar is closed
is_undoable: false, // Show or not the undo button
onUndo: function onUndo() {}, // Callback function when snackbar is undoed
icon: '<span class="material-icons-outlined wpmf-snack-icon"> campaign </span>',
is_closable: true, // Can this snackbar be closed by user
auto_close: true, // Do the snackbar close automatically
auto_close_delay: 6000, // Time to wait before closing automatically
is_progress: false, // Do we show the progress bar
percentage: null // Percentage of the progress bar
},
/**
* Initialize snackbar module
*/
initModule: function initModule() {
wpmfSnackbarModule.$snackbar_wrapper = $('<div class="wpmf-snackbar-wrapper"></div>').appendTo('body');
},
/**
* Display a new snackbar
* @param options
* @return HTMLElement the snackbar generated
*/
show: function show(options) {
if (options === undefined) {
options = {};
}
// Set default values
options = $.extend({}, wpmfSnackbarModule.snackbar_defaults, options);
// If an id is set save it
if (typeof options.id === "undefined") {
options.id = options.content;
}
if (options.id !== undefined) {
wpmfSnackbarModule.snackbar_ids[options.id] = options;
}
return wpmfSnackbarModule.renderSnack(options);
},
renderSnack: function renderSnack(notification_options) {
var notification_class = 'wpmf-snackbar-wrap';
if (typeof notification_options !== "undefined" && typeof notification_options.error !== "undefined" && notification_options.error) {
notification_class += ' wpmf-snackbar-error';
}
var snack = '<div class="' + notification_class + '">';
var snack_count = 0;
Object.keys(wpmfSnackbarModule.snackbar_ids).map(function (snack_id, index) {
snack_count++;
var options = wpmfSnackbarModule.snackbar_ids[snack_id];
// Generate undo html if needed
var undo = '';
if (options.is_undoable) {
undo = '<a href="#" class="wpmf-snackbar-undo">' + wpmf.l18n.wpmf_undo + '</a>';
}
var id = '';
if (options.id) {
id = 'data-id="' + options.id + '"';
}
snack += '<div ' + id + ' class="wpmf-snackbar">\n ' + options.icon + '\n <div class="wpmf-snackbar-content">' + options.content + '</div>\n ' + undo + ' \n </div>';
});
snack += '<a class="wpmf-snackbar-close" href="#"><i class="material-icons">close</i></a>';
snack += '</div>';
// Add element to the DOM
$('.wpmf-snackbar-wrap').remove();
if (snack_count > 0) {
var $snack = $(snack).prependTo(wpmfSnackbarModule.$snackbar_wrapper);
// Initialize undo function
$snack.find('.wpmf-snackbar-undo').click(function (e) {
var snack_id = $(this).closest('.wpmf-snackbar').data('id');
e.preventDefault();
wpmfSnackbarModule.snackbar_ids[snack_id].onUndo();
// Reset the close function as we've done an undo
wpmfSnackbarModule.snackbar_ids[snack_id].onClose = function () {};
// Finally close the snackbar
wpmfSnackbarModule.snackbar_ids[snack_id].close(snack_id);
});
Object.keys(wpmfSnackbarModule.snackbar_ids).map(function (snack_id, index) {
// Initialize autoclose feature
var options = wpmfSnackbarModule.snackbar_ids[snack_id];
if (options.auto_close) {
setTimeout(function () {
wpmfSnackbarModule.close(options.id);
}, options.auto_close_delay);
}
});
// Initialize close button
$snack.find('.wpmf-snackbar-close').click(function (e) {
$(this).closest('.wpmf-snackbar-wrap').remove();
wpmfSnackbarModule.snackbar_ids = [];
});
}
},
/**
* Remove a snackbar and call onClose callback if needed
* @param snack_id snackbar element
*/
close: function close(snack_id) {
// Remove the id if exists
if (snack_id !== undefined) {
delete wpmfSnackbarModule.snackbar_ids[snack_id];
}
wpmfSnackbarModule.renderSnack();
},
/**
* Retrieve an existing snackbar from its id
* @param id
* @return {null|object}
*/
getFromId: function getFromId(id) {
if (wpmfSnackbarModule.snackbar_ids[id] === undefined) {
return null;
}
return id;
},
/**
* Set the snackbar progress bar width
* @param $snack jQuery element representing a snackbar
* @param percentage int
*/
setProgress: function setProgress($snack, percentage) {
if ($snack === null) {
return;
}
var $progress = $snack.find('.wpmfliner_progress > div');
if (percentage !== undefined) {
$progress.addClass('determinate').removeClass('indeterminate');
$progress.css('width', percentage + '%');
} else {
$progress.addClass('indeterminate').removeClass('determinate');
}
}
};
// Let's initialize WPMF features
$(document).ready(function () {
wpmfSnackbarModule.initModule();
});
})(jQuery);
@@ -0,0 +1,262 @@
/**
* Folder tree for WP Media Folder
*/
var wpmfFoldersTreeCategoriesModule;
(function ($) {
wpmfFoldersTreeCategoriesModule = {
categories: [], // categories
folders_states: [], // Contains open or closed status of folders
/**
* Retrieve the Jquery tree view element
* of the current frame
* @return jQuery
*/
getTreeElement: function () {
return $('#wpmf_foldertree_categories').find('.wpmf-folder-tree');
},
/**
* Initialize module related things
*/
initModule: function () {
// Import categories from wpmf main module
wpmfFoldersTreeCategoriesModule.importCategories();
// Add the tree view to the main content
$('<div class="wpmf-folder-tree wpmf-no-margin wpmf-no-padding"></div>').appendTo($('#wpmf_foldertree_categories'));
// Render the tree view
wpmfFoldersTreeCategoriesModule.loadTreeView();
},
getchecked: function (folder_id, button) {
$('#wpmf_foldertree_categories .media_checkbox').not(button).prop('checked', false);
if ($(button).is(':checked')) {
wpmfFoldersTreeCategoriesModule.renderBreadCrumb(folder_id);
} else {
wpmfFoldersTreeCategoriesModule.renderBreadCrumb(0);
}
},
/**
* Import categories from wpmf main module
*/
importCategories: function () {
var folders_ordered = [];
// Add each category
$(wpmf.vars.wpmf_categories_order).each(function () {
folders_ordered.push(wpmf.vars.wpmf_categories[this]);
});
// Reorder array based on children
var folders_ordered_deep = [];
var processed_ids = [];
var loadChildren = function (id) {
if (processed_ids.indexOf(id) < 0) {
processed_ids.push(id);
for (var ij = 0; ij < folders_ordered.length; ij++) {
if (folders_ordered[ij].parent_id === id) {
folders_ordered_deep.push(folders_ordered[ij]);
loadChildren(folders_ordered[ij].id);
}
}
}
};
loadChildren(parseInt(wpmf.vars.term_root_id));
// Finally save it to the global var
wpmfFoldersTreeCategoriesModule.categories = folders_ordered_deep;
},
/**
* Render tree view inside content
*/
loadTreeView: function () {
wpmfFoldersTreeCategoriesModule.getTreeElement().html(wpmfFoldersTreeCategoriesModule.getRendering());
},
/**
* Get the html resulting tree view
* @return {string}
*/
getRendering: function () {
var ij = 0;
var content = ''; // Final tree view content
/**
* Recursively print list of folders
* @return {boolean}
*/
var generateList = function generateList() {
content += '<ul>';
while (ij < wpmfFoldersTreeCategoriesModule.categories.length) {
var className = 'closed';
if (typeof wpmfFoldersTreeCategoriesModule.categories[ij].drive_type !== "undefined" && wpmfFoldersTreeCategoriesModule.categories[ij].drive_type !== '') {
className += ' hide';
}
// Open li tag
content += '<li class="' + className + '" data-id="' + wpmfFoldersTreeCategoriesModule.categories[ij].id + '" >';
var a_tag = '<a data-id="' + wpmfFoldersTreeCategoriesModule.categories[ij].id + '">';
// get color folder
var bgcolor = '';
if (typeof wpmf.vars.colors !== 'undefined' && typeof wpmf.vars.colors[wpmfFoldersTreeCategoriesModule.categories[ij].id] !== 'undefined') {
bgcolor = 'color: ' + wpmf.vars.colors[wpmfFoldersTreeCategoriesModule.categories[ij].id];
} else {
bgcolor = 'color: #8f8f8f';
}
if (wpmfFoldersTreeCategoriesModule.categories[ij + 1] && wpmfFoldersTreeCategoriesModule.categories[ij + 1].depth > wpmfFoldersTreeCategoriesModule.categories[ij].depth) { // The next element is a sub folder
content += '<a onclick="wpmfFoldersTreeCategoriesModule.toggle(' + wpmfFoldersTreeCategoriesModule.categories[ij].id + ')"><i class="material-icons wpmf-arrow">keyboard_arrow_down</i></a>';
content += a_tag;
// Add folder icon
content += '<i class="material-icons" style="' + bgcolor + '">folder</i>';
} else {
content += a_tag;
// Add folder icon
content += '<i class="material-icons wpmf-no-arrow" style="' + bgcolor + '">folder</i>';
}
content += '<input type="checkbox" class="media_checkbox" onclick="wpmfFoldersTreeCategoriesModule.getchecked(' + wpmfFoldersTreeCategoriesModule.categories[ij].id + ', this)" data-id="' + wpmfFoldersTreeCategoriesModule.categories[ij].id + '" />';
// Add current category name
if (wpmfFoldersTreeCategoriesModule.categories[ij].id === 0) {
// If this is the root folder then rename it
content += '<span onclick="wpmfFoldersTreeCategoriesModule.changeFolder(0)">' + wpmf.l18n.media_folder + '</span>';
} else {
content += '<span onclick="wpmfFoldersTreeCategoriesModule.changeFolder(' + wpmfFoldersTreeCategoriesModule.categories[ij].id + ')">' + wpmfFoldersTreeCategoriesModule.categories[ij].label + '</span>';
}
content += '</a>';
// This is the end of the array
if (wpmfFoldersTreeCategoriesModule.categories[ij + 1] === undefined) {
// var's close all opened tags
for (var ik = wpmfFoldersTreeCategoriesModule.categories[ij].depth; ik >= 0; ik--) {
content += '</li>';
content += '</ul>';
}
// We are at the end don't continue to process array
return false;
}
if (wpmfFoldersTreeCategoriesModule.categories[ij + 1].depth > wpmfFoldersTreeCategoriesModule.categories[ij].depth) { // The next element is a sub folder
// Recursively list it
ij++;
if (generateList() === false) {
// We have reached the end, var's recursively end
return false;
}
} else if (wpmfFoldersTreeCategoriesModule.categories[ij + 1].depth < wpmfFoldersTreeCategoriesModule.categories[ij].depth) { // The next element don't have the same parent
// var's close opened tags
for (var ik1 = wpmfFoldersTreeCategoriesModule.categories[ij].depth; ik1 > wpmfFoldersTreeCategoriesModule.categories[ij + 1].depth; ik1--) {
content += '</li>';
content += '</ul>';
}
// We're not at the end of the array var's continue processing it
return true;
}
// Close the current element
content += '</li>';
ij++;
}
};
// Start generation
generateList();
return content;
},
/**
* Change the selected folder in tree view
* @param folder_id
*/
changeFolder: function (folder_id) {
// Remove previous selection
wpmfFoldersTreeCategoriesModule.getTreeElement().find('li').removeClass('selected');
// Select the folder
wpmfFoldersTreeCategoriesModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('selected').// Open parent folders
parents('.wpmf-folder-tree li.closed').removeClass('closed');
},
/**
* Change the selected folder in tree view
* @param folder_id
*/
renderBreadCrumb: function (folder_id) {
if (parseInt(folder_id) === 0) {
$('.dir_name_categories').val('/').data('id_category' , 0);
} else {
var category = wpmf.vars.wpmf_categories[folder_id];
var breadcrumb_content = '';
// Ascend until there is no more parent
while (parseInt(category.parent_id) !== parseInt(wpmf.vars.parent)) {
// Generate breadcrumb element
breadcrumb_content = '/' + wpmf.vars.wpmf_categories[category.id].label + breadcrumb_content;
// Get the parent
category = wpmf.vars.wpmf_categories[wpmf.vars.wpmf_categories[category.id].parent_id];
}
if (parseInt(category.id) !== 0) {
breadcrumb_content = wpmf.vars.wpmf_categories[category.id].label + breadcrumb_content;
}
breadcrumb_content = '/' + breadcrumb_content + '/';
$('.dir_name_categories').val(breadcrumb_content).data('id_category' , folder_id);
}
},
/**
* Toggle the open / closed state of a folder
* @param folder_id
*/
toggle: function (folder_id) {
// Check is folder has closed class
if (wpmfFoldersTreeCategoriesModule.getTreeElement().find('li[data-id="' + folder_id + '"]').hasClass('closed')) {
// Open the folder
wpmfFoldersTreeCategoriesModule.openFolder(folder_id);
} else {
// Close the folder
wpmfFoldersTreeCategoriesModule.closeFolder(folder_id);
// close all sub folder
$('li[data-id="' + folder_id + '"]').find('li').addClass('closed');
}
},
/**
* Open a folder to show children
*/
openFolder: function (folder_id) {
wpmfFoldersTreeCategoriesModule.getTreeElement().find('li[data-id="' + folder_id + '"]').removeClass('closed');
wpmfFoldersTreeCategoriesModule.folders_states[folder_id] = 'open';
},
/**
* Close a folder and hide children
*/
closeFolder: function (folder_id) {
wpmfFoldersTreeCategoriesModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('closed');
wpmfFoldersTreeCategoriesModule.folders_states[folder_id] = 'close';
}
};
// var's initialize WPMF folder tree features
$(document).ready(function () {
wpmfFoldersTreeCategoriesModule.initModule();
});
})(jQuery);
@@ -0,0 +1,189 @@
(function ($) {
$(document).ready(function () {
/**
* options
* @type {{root: string, showroot: string, onclick: onclick, oncheck: oncheck, usecheckboxes: boolean, expandSpeed: number, collapseSpeed: number, expandEasing: null, collapseEasing: null, canselect: boolean}}
*/
var options_sync = {
'root': '/',
'showroot': wpmfoption.l18n.tree_ftp_root_label,
'onclick': function (elem, type, file) {
},
'oncheck': function (elem, checked, type, file) {
},
'usecheckboxes': false, //can be true files dirs or false
'expandSpeed': 500,
'collapseSpeed': 500,
'expandEasing': null,
'collapseEasing': null,
'canselect': true
};
/**
* Main folder tree of ftp function for sync feature
*/
var methods_sync = {
init_sync: function () {
$thissyncftp = $('#wpmf_foldertree_sync');
if ($thissyncftp.length === 0) {
return;
}
if (options_sync.showroot !== '') {
$thissyncftp.html('<ul class="jaofiletree"><li class="tree_ftp_root drive directory collapsed selected"><a href="#" data-file="' + options_sync.root + '" data-type="dir">' + options_sync.showroot + '</a></li></ul>');
}
openfolder_sync(options_sync.root);
},
/**
* open folder tree by dir name
* @param dir
*/
open_sync: function (dir) {
openfolder_sync(dir);
},
/**
* close folder tree by dir name
* @param dir
*/
close_sync: function (dir) {
closedir_sync(dir);
},
getchecked: function () {
$("#wpmf_foldertree_sync span.check").unbind('click').bind('click', function () {
if ($(this).closest('li').hasClass('folder_disabled')) {
return;
}
$(this).removeClass('pchecked');
$(this).toggleClass('checked');
$('#wpmf_foldertree_sync .ftp_checkbox').prop('checked', false);
$('#wpmf_foldertree_sync .check').not(this).removeClass('pchecked checked');
var dir = $(this).closest('li').find('.tree-status-folder').data('file');
if ($(this).hasClass('checked')) {
$(this).prev().prop('checked', true).trigger('change');
$('.dir_name_ftp').val(wpmfoption.vars.wpmf_root_site + dir);
} else {
$(this).prev().prop('checked', false).trigger('change');
$('.dir_name_ftp').val('');
}
});
}
};
/**
* open folder tree by dir name
* @param dir dir name
* @param callback
*/
var openfolder_sync = function (dir , callback) {
if ($thissyncftp.find('a[data-file="' + dir + '"]').parent().hasClass('expanded')) {
return;
}
if ($thissyncftp.find('a[data-file="' + dir + '"]').parent().hasClass('expanded') || $thissyncftp.find('a[data-file="' + dir + '"]').parent().hasClass('wait')) {
if (typeof callback === 'function')
callback();
return;
}
var ret;
ret = $.ajax({
url: ajaxurl,
method:'POST',
data: {
dir: dir,
action: 'wpmf_get_folder',
wpmf_nonce: wpmf.vars.wpmf_nonce
},
context: $thissyncftp,
dataType: 'json',
beforeSend: function () {
$('#wpmf_foldertree_sync').find('a[data-file="' + dir + '"]').parent().addClass('wait');
}
}).done(function (datas) {
ret = '<ul class="jaofiletree" style="display: none">';
for (var ij = 0; ij < datas.length; ij++) {
if (datas[ij].type === 'dir') {
var classe = 'directory collapsed';
if (datas[ij].disable) {
classe += ' folder_disabled';
} else {
classe += ' folder_enabled';
}
var isdir = '/';
} else {
classe = 'file ext_' + datas[ij].ext;
isdir = '';
}
ret += '<li class="' + classe + '">';
if (!datas[ij].disable) {
ret += '<input type="checkbox" class="ftp_checkbox" data-file="' + dir + datas[ij].file + isdir + '" data-type="' + datas[ij].type + '" />';
}
ret += '<span class="check" data-file="' + dir + datas[ij].file + isdir + '" data-type="' + datas[ij].type + '" ></span>';
ret += '<i class="zmdi zmdi-folder tree-status-folder" data-file="' + dir + datas[ij].file + isdir + '"></i>';
ret += '<a href="#" data-file="' + dir + datas[ij].file + isdir + '" data-type="' + datas[ij].type + '">' + datas[ij].file + '</a>';
ret += '</li>';
}
ret += '</ul>';
$('#wpmf_foldertree_sync').find('a[data-file="' + dir + '"]').parent().removeClass('wait').removeClass('collapsed').addClass('expanded');
$thissyncftp.find('.tree-status-folder[data-file="' + dir + '"]').removeClass('zmdi-folder').addClass('zmdi-folder-outline');
$('#wpmf_foldertree_sync').find('a[data-file="' + dir + '"]').after(ret);
$('#wpmf_foldertree_sync').find('a[data-file="' + dir + '"]').next().slideDown(options_sync.expandSpeed, options_sync.expandEasing,
function () {
methods_sync.getchecked();
if (typeof callback === 'function')
callback();
});
setevents_sync();
}).done(function () {
methods_sync.getchecked();
});
};
/**
* close folder tree by dir name
* @param dir
*/
var closedir_sync = function (dir) {
$thissyncftp.find('a[data-file="' + dir + '"]').next().slideUp(options_sync.collapseSpeed, options_sync.collapseEasing, function () {
$(this).remove();
});
$thissyncftp.find('a[data-file="' + dir + '"]').parent().removeClass('expanded').addClass('collapsed');
$thissyncftp.find('.tree-status-folder[data-file="' + dir + '"]').addClass('zmdi-folder').removeClass('zmdi-folder-outline');
setevents_sync();
};
/**
* init event click to open/close folder tree
*/
var setevents_sync = function () {
$thissyncftp = $('#wpmf_foldertree_sync');
$thissyncftp.find('li a').unbind('click');
//Bind userdefined function on click an element
$thissyncftp.find('li a').bind('click', function () {
options_sync.onclick(this, $(this).attr('data-type'), $(this).attr('data-file'));
if (options_sync.canselect) {
$thissyncftp.find('li').removeClass('selected');
$(this).parent().addClass('selected');
}
return false;
});
//Bind for collapse or expand elements
$thissyncftp.find('li.directory.collapsed a').bind('click', function () {
methods_sync.open_sync($(this).attr('data-file'));
return false;
});
$thissyncftp.find('li.directory.expanded a').bind('click', function () {
methods_sync.close_sync($(this).attr('data-file'));
return false;
});
};
/**
* Folder tree function
*/
methods_sync.init_sync();
});
})(jQuery);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,276 @@
(function ($) {
$(document).ready(function () {
/**
* options
* @type {{root: string, showroot: string, onclick: onclick, oncheck: oncheck, usecheckboxes: boolean, expandSpeed: number, collapseSpeed: number, expandEasing: null, collapseEasing: null, canselect: boolean}}
*/
var optionsuser = {
'root': '/',
'showroot': wpmfoption.l18n.media_library,
'onclick': function (elem, type, file) {
},
'oncheck': function (elem, checked, type, file) {
},
'usecheckboxes': true, //can be true files dirs or false
'expandSpeed': 500,
'collapseSpeed': 500,
'expandEasing': null,
'collapseEasing': null,
'canselect': true
};
/**
* Main folder tree function for user media root feature
* @type {{init: init, open: open, close: close, getchecked: getchecked, getselected: getselected}}
*/
var methods_users = {
/**
* Folder tree init
*/
init: function () {
$userimagetree = $('#wpmfjaouser');
if ($userimagetree.length === 0) {
return;
}
var attachment_id = $('.attachment-details').data('id');
if (typeof attachment_id === "undefined")
attachment_id = $('#post_ID').val();
if (optionsuser.showroot !== '') {
var tree_init = '';
tree_init += '<ul class="jaofiletree">';
tree_init += '<li data-id="0" class="directory_users collapsed_users selected">';
tree_init += '<div class="pure-checkbox">';
tree_init += '<input type="checkbox" value="0" id="/" name="wpmf_checkbox_tree" class="wpmf_checkbox_tree" data-file="/" data-type="dir">';
tree_init += '<label class="checked" for="/">';
tree_init += '<a class="title-folder title-root" data-id="0" data-file="' + optionsuser.root + '" data-type="dir">' + optionsuser.showroot + '</a>';
tree_init += '</label>';
tree_init += '</div>';
tree_init += '</li>';
tree_init += '</ul>';
$userimagetree.html(tree_init);
}
openfolderuser(attachment_id, optionsuser.root);
},
/**
* open folder tree by dir name
* @param dir
*/
open: function (dir) {
var attachment_id = $('.attachment-details').data('id');
if (typeof attachment_id === "undefined")
attachment_id = $('#post_ID').val();
openfolderuser(attachment_id, dir);
},
/**
* close folder tree by dir name
* @param dir
*/
close: function (dir) {
closediruser(dir);
},
/**
* Get selected
* @returns {Array}
*/
getselected: function () {
var list = [];
var ik = 0;
$userimagetree.find('li.selected > a').each(function () {
list[ik] = {
type: $(this).attr('data-type'),
file: $(this).attr('data-file')
};
ik++;
});
return list;
}
};
/**
* open folder tree by dir name
* @param attachment_id attachment id
* @param dir dir name
* @param callback
*/
var openfolderuser = function (attachment_id, dir, callback) {
if (typeof $userimagetree === "undefined")
return;
var id = $userimagetree.find('a[data-file="' + dir + '"]').data('id');
if ($userimagetree.find('a[data-file="' + dir + '"]').closest('li').hasClass('expanded_users') || $userimagetree.find('a[data-file="' + dir + '"]').closest('li').hasClass('wait')) {
if (typeof callback === 'function')
callback();
return;
}
/* Ajax get user media */
var ret;
ret = $.ajax({
method: 'POST',
url: ajaxurl,
data: {
dir: dir,
id: id,
attachment_id: attachment_id,
action: 'wpmf',
task: 'get_user_media_tree',
wpmf_nonce: wpmf.vars.wpmf_nonce
},
context: $userimagetree,
dataType: 'json',
beforeSend: function () {
this.find('a[data-file="' + dir + '"]').closest('li').addClass('wait');
}
}).done(function (res) {
var selectedId = $('#wpmfjaouser').find('.directory_users.selected').data('id');
ret = '<ul class="jaofiletree">';
if (res.status) {
var datas = res.dirs;
for (var ij = 0; ij < datas.length; ij++) {
if (parseInt(wpmfoption.vars.root_media_root) !== datas[ij].id) {
var classe = '';
if (datas[ij].type === 'dir') {
classe = 'directory_users collapsed_users';
} else {
classe = 'file ext_' + datas[ij].ext;
}
if (parseInt(datas[ij].id) === parseInt(selectedId)) {
classe += ' selected';
}
ret += '<li class="' + classe + '" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" data-group="' + datas[ij].term_group + '">';
if (datas[ij].count_child > 0) {
ret += '<div class="icon-open-close" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" data-file="' + dir + datas[ij].file + '/" data-type="' + datas[ij].type + '"></div>';
} else {
ret += '<div class="icon-open-close" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" data-file="' + dir + datas[ij].file + '/" data-type="' + datas[ij].type + '" style="opacity:0"></div>';
}
ret += '<div class="pure-checkbox">';
if (parseInt(res.user_media_folder_root) === 0) {
$('.wpmf_checkbox_tree[value="0"]').prop('checked', true);
ret += '<input type="checkbox" id="' + dir + datas[ij].file + '/" name="wpmf_checkbox_tree" class="wpmf_checkbox_tree" value="' + datas[ij].id + '" data-id="' + datas[ij].id + '" data-file="' + dir + datas[ij].file + '" data-type="' + datas[ij].type + '">';
} else {
if (parseInt(res.user_media_folder_root) === parseInt(datas[ij].id)) {
ret += '<input type="checkbox" checked id="' + dir + datas[ij].file + '/" name="wpmf_checkbox_tree" class="wpmf_checkbox_tree" value="' + datas[ij].id + '" data-id="' + datas[ij].id + '" data-file="' + dir + datas[ij].file + '" data-type="' + datas[ij].type + '">';
} else {
ret += '<input type="checkbox" id="' + dir + datas[ij].file + '/" name="wpmf_checkbox_tree" class="wpmf_checkbox_tree" value="' + datas[ij].id + '" data-id="' + datas[ij].id + '" data-file="' + dir + datas[ij].file + '" data-type="' + datas[ij].type + '">';
}
}
if (datas[ij].checked) {
ret += '<label class="check" for="' + dir + datas[ij].file + '/">';
} else {
if (datas[ij].pchecked) {
ret += '<label class="pchecked" for="' + dir + datas[ij].file + '/">';
ret += '<span class="ppp"></span>';
} else {
ret += '<label for="' + dir + datas[ij].file + '/">';
}
}
if (parseInt(datas[ij].id) === parseInt(selectedId)) {
ret += '<i class="zmdi wpmf-zmdi-folder-open"></i>';
} else {
ret += '<i class="zmdi zmdi-folder"></i>';
}
ret += '<a class="title-folder" data-id="' + datas[ij].id + '" data-parent_id="' + datas[ij].parent_id + '" data-file="' + dir + datas[ij].file + '/" data-type="' + datas[ij].type + '">' + datas[ij].file + '</a>';
ret += '</label>';
ret += '</div>';
ret += '</li>';
}
}
}
ret += '</ul>';
this.find('a[data-file="' + dir + '"]').closest('li').removeClass('wait').removeClass('collapsed_users').addClass('expanded_users');
this.find('a[data-file="' + dir + '"]').closest('li').append(ret);
this.find('a[data-file="' + dir + '"]').closest('li').children('.jaofiletree').slideDown(optionsuser.expandSpeed, optionsuser.expandEasing,
function () {
$userimagetree.trigger('afteropen');
$userimagetree.trigger('afterupdate');
if (typeof callback === 'function')
callback();
});
seteventsuser();
}).done(function () {
$userimagetree.trigger('afteropen');
$userimagetree.trigger('afterupdate');
});
};
/**
* close folder tree by dir name
* @param dir
*/
var closediruser = function (dir) {
if (typeof $userimagetree === "undefined")
return;
$userimagetree.find('a[data-file="' + dir + '"]').closest('li').children('.jaofiletree').slideUp(optionsuser.collapseSpeed, optionsuser.collapseEasing, function () {
$(this).remove();
});
$userimagetree.find('a[data-file="' + dir + '"]').closest('li').removeClass('expanded_users').addClass('collapsed_users');
seteventsuser();
//Trigger custom event
$userimagetree.trigger('afterclose');
$userimagetree.trigger('afterupdate');
};
/**
* init event click to open/close folder tree
*/
var seteventsuser = function () {
var $userimagetree = $('#wpmfjaouser');
$userimagetree.find('li a,li .icon-open-close').unbind('click');
//Bind for collapse or expand elements
$userimagetree.find('li.directory_users a').bind('click', function (e) {
e.preventDefault();
if (!$(this).hasClass('wpmfaddFolder')) {
$userimagetree.find('li').removeClass('selected');
$userimagetree.find('i.zmdi').removeClass('wpmf-zmdi-folder-open').addClass("zmdi-folder");
$(this).closest('li').addClass("selected");
$(this).closest('li').find(' > .pure-checkbox i.zmdi').removeClass("zmdi-folder").addClass("wpmf-zmdi-folder-open");
methods_users.open($(this).attr('data-file'));
}
});
/* open folder tree use icon */
$userimagetree.find('li.directory_users.collapsed_users .icon-open-close').bind('click', function () {
methods_users.open($(this).attr('data-file'));
});
/* close folder tree use icon */
$userimagetree.find('li.directory_users.expanded_users .icon-open-close').bind('click', function () {
methods_users.close($(this).attr('data-file'));
});
/* Check/uncheck folder */
$userimagetree.find('li.directory_users.expanded_users .wpmf_checkbox_tree').bind('click', function () {
$('.wpmf_checkbox_tree').not($(this)).prop('checked', false);
if ($(this).is(':checked')) {
$(this).closest('.pure-checkbox').find('label').removeClass('pchecked').addClass('checked');
} else {
$(this).closest('.pure-checkbox').find('label').removeClass('checked');
}
});
};
/**
* Folder tree function
*/
methods_users.init();
});
}(jQuery));
@@ -0,0 +1,306 @@
(function ($) {
'use strict';
/**
* run masonry layout
*/
function wpmfVcInitSlider($container) {
var columns = parseInt($container.data('wpmfcolumns'));
var autoplay = $container.data('auto_animation');
if ($container.is(':hidden')) {
return;
}
if ($container.hasClass('slick-initialized')) {
$container.slick('unslick');
}
$container.imagesLoaded(function () {
var slick_args = {
infinite: true,
slidesToShow: columns,
slidesToScroll: columns,
pauseOnHover: false,
autoplay: (parseInt(autoplay) === 1),
adaptiveHeight: (parseInt(columns) === 1),
autoplaySpeed: 5000,
rows: 1,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
};
if (!$container.hasClass('slick-initialized')) {
setTimeout(function () {
$container.slick(slick_args);
}, 120);
}
});
}
function wpmfVcInitMasonry($container) {
var layout = $container.closest('.wpmf-gallerys-addon').data('layout');
var padding = $container.data('gutter-width');
if ($container.hasClass('masonry')) {
$container.masonry('destroy');
}
if ($container.hasClass('justified-gallery')) {
$container.justifiedGallery('destroy');
}
if (layout === 'horizontal') {
var row_height = $container.closest('.wpmf-gallerys-addon').data('row_height');
if (typeof row_height === "undefined" || row_height === '') {
row_height = 200;
}
$container.imagesLoaded(function () {
setTimeout(function () {
$container.justifiedGallery({
rowHeight: row_height,
margins: padding
});
},200);
});
return;
}
$container.imagesLoaded(function () {
var $postBox = $container.children('.wpmf-gallery-item');
var o = wpmfVcCalculateGrid($container);
$postBox.css({'width': o.columnWidth + 'px', 'margin-bottom': o.gutterWidth + 'px'});
$container.masonry({
itemSelector: '.wpmf-gallery-item',
columnWidth: o.columnWidth,
gutter: o.gutterWidth,
transitionDuration: 400
});
$container.css('visibility', 'visible');
$container.find('.wpmf-gallery-item').addClass('wpmf-gallery-item-show');
});
}
function wpmfVcInitFlowsSlide($container) {
$container.imagesLoaded(function () {
var enableNavButtons = $container.data('button');
if (typeof enableNavButtons !== "undefined" && parseInt(enableNavButtons) === 1) {
$container.flipster({
style: 'coverflow',
buttons: 'custom',
spacing: 0,
loop: true,
autoplay: 5000,
buttonNext: '<i class="flipto-next material-icons"> keyboard_arrow_right </i>',
buttonPrev: '<i class="flipto-prev material-icons"> keyboard_arrow_left </i>',
onItemSwitch: function (currentItem, previousItem) {
$container.find('.flipster__container').height(jQuery(currentItem).height());
},
onItemStart: function (currentItem) {
$container.find('.flipster__container').height(jQuery(currentItem).height());
}
});
} else {
$container.flipster({
style: 'coverflow',
spacing: 0,
loop: true,
autoplay: 5000,
onItemSwitch: function (currentItem, previousItem) {
$container.find('.flipster__container').height(jQuery(currentItem).height());
},
onItemStart: function (currentItem) {
$container.find('.flipster__container').height(jQuery(currentItem).height());
}
});
}
});
}
function wpmfVcInitCustomGrid($container) {
$container.imagesLoaded(function () {
var gutter = $container.data('gutter');
$container.closest('.wpmf_gallery_wrap').find('.loading_gallery').hide();
var wrap_width = $container.width();
var one_col_width = (wrap_width - gutter*12)/12;
$container.find('.grid-item').each(function() {
var dimensions = jQuery(this).data('styles');
var w = (typeof dimensions.width !== "undefined") ? parseInt(dimensions.width) : 2;
var h = (typeof dimensions.height !== "undefined") ? parseInt(dimensions.height) : 2;
var g = (parseInt(w) - 1)*gutter;
var display_width = one_col_width;
var display_height = one_col_width;
if (w > 1) {
display_width = one_col_width*w + g;
}
if (w == h) {
display_height = display_width;
} else {
if (h > 1) {
display_height = (one_col_width*h) + (h - 1)*gutter;
}
}
jQuery(this).width(display_width);
jQuery(this).height(display_height);
});
$container.isotope({
itemSelector: '.grid-item',
layoutMode: 'packery',
resizable: true,
initLayout: true,
packery: {
gutter: gutter
}
});
$container.addClass('wpmfInitPackery');
});
}
function wpmfVcCalculateGrid($container) {
let columns = parseInt($container.data('wpmfcolumns'));
let gutterWidth = $container.data('gutterWidth');
let containerWidth = $container.width();
if (isNaN(gutterWidth)) {
gutterWidth = 5;
} else if (gutterWidth > 500 || gutterWidth < 0) {
gutterWidth = 5;
}
if (parseInt(columns) < 2 || containerWidth <= 450) {
columns = 2;
}
gutterWidth = parseInt(gutterWidth);
let allGutters = gutterWidth * (columns - 1);
let contentWidth = containerWidth - allGutters;
let columnWidth = Math.floor(contentWidth / columns);
return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns};
}
// gallery detect render
window.InlineShortcodeView_vc_wpmf_gallery = window.InlineShortcodeView.extend( {
render: function () {
//var model_id = this.model.get( 'id' );
window.InlineShortcodeView_vc_wpmf_gallery.__super__.render.call( this );
var masonry_container = jQuery(this.el).find('.gallery-masonry');
var tab_container;
if (masonry_container.length) {
tab_container = masonry_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitMasonry(masonry_container);
}
} else {
wpmfVcInitMasonry(masonry_container);
}
}
var slider_container = jQuery(this.el).find('.wpmfslick');
if (slider_container.length) {
tab_container = slider_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitSlider(slider_container);
}
} else {
wpmfVcInitSlider(slider_container);
}
}
return this;
}
});
// gallery addon detect render
window.InlineShortcodeView_vc_wpmf_gallery_addon = window.InlineShortcodeView.extend( {
render: function () {
window.InlineShortcodeView_vc_wpmf_gallery_addon.__super__.render.call( this );
jQuery(this.el).find('.loading_gallery').hide();
var masonry_container = jQuery(this.el).find('.gallery-masonry');
var tab_container;
if (masonry_container.length) {
tab_container = masonry_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitMasonry(masonry_container);
}
} else {
wpmfVcInitMasonry(masonry_container);
}
}
var slider_container = jQuery(this.el).find('.wpmfslick');
if (slider_container.length) {
tab_container = slider_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitSlider(slider_container);
}
} else {
wpmfVcInitSlider(slider_container);
}
}
var flowslide_container = jQuery(this.el).find('.flipster');
if (flowslide_container.length) {
tab_container = flowslide_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitFlowsSlide(flowslide_container);
}
} else {
wpmfVcInitFlowsSlide(flowslide_container);
}
}
var custom_grid_container = jQuery(this.el).find('.wpmf-custom-grid');
if (custom_grid_container.length) {
tab_container = custom_grid_container.closest('.vc_tta-panel');
if (tab_container.length) {
if (tab_container.hasClass('vc_active')) {
wpmfVcInitCustomGrid(custom_grid_container);
}
} else {
wpmfVcInitCustomGrid(custom_grid_container);
}
}
return this;
}
});
// pdf embed detect render
window.InlineShortcodeView_vc_pdf_embed = window.InlineShortcodeView.extend( {
render: function () {
window.InlineShortcodeView_vc_pdf_embed.__super__.render.call( this );
return this;
}
});
})();
@@ -0,0 +1,50 @@
(function ($) {
$(document).ready(function () {
$(document).on("click", '.wpmf_vc_select_pdf', function (e) {
if (typeof frame !== "undefined") {
frame.open();
return;
}
// Create the media frame.
var frame = wp.media({
library: {
type: 'application/pdf'
}
});
// When an image is selected, run a callback.
frame.on('select', function () {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first().toJSON();
$('.pdfembed_url_field').val(attachment.url);
});
frame.open();
});
$(document).on("click", '.wpmf_vc_select_file', function (e) {
if (typeof frame !== "undefined") {
frame.open();
return;
}
// Create the media frame.
var frame = wp.media({
// Tell the modal to show only images.
library: {
type: '*'
}
});
// When an image is selected, run a callback.
frame.on('select', function () {
// Grab the selected attachment.
var attachment = frame.state().get('selection').first().toJSON();
$('.singlefile_url_field').val(attachment.url);
});
frame.open();
});
});
}(jQuery));
@@ -0,0 +1,74 @@
(function ($) {
if (typeof ajaxurl === "undefined") {
ajaxurl = wpmf.vars.ajaxurl;
}
$(document).ready(function () {
if (typeof wp !== "undefined") {
if (wp.media && $('body.upload-php table.media').length === 0) {
if (wp.media.view.AttachmentFilters === undefined || wp.media.view.AttachmentsBrowser === undefined)
return;
/* Create display own media filter */
var wpmffilterDisplayMedia = function () {
//=========================================================================
wp.media.view.AttachmentFilters['wpmf_filter_display_media'] = wp.media.view.AttachmentFilters.extend({
className: 'wpmf-filter-display-media attachment-filters',
id: 'wpmf-display-media-filters',
createFilters: function () {
var filters = {};
filters['yes'] = {
text: 'Yes',
props: {
wpmf_display_media: 'yes'
}
};
filters.all = {
text: 'No',
props: {
wpmf_display_media: 'no'
},
priority: 10
};
this.filters = filters;
}
});
/* backup the method */
var orig = wp.media.view.AttachmentsBrowser;
/* render filter */
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
createToolbar: function () {
// call the original method
orig.prototype.createToolbar.apply(this, arguments);
this.toolbar.set('displaymediatags', new wp.media.view.AttachmentFilters['wpmf_filter_display_media']({
controller: this.controller,
model: this.collection.props,
priority: -80
}).render());
}
});
//=========================================================================
};
if (typeof wpmf.vars.wpmf_role !== 'undefined') {
if (wpmf.vars.wpmf_role === 'administrator') {
wpmffilterDisplayMedia();
}
}
} else {
/* table page */
if (typeof wpmf.l18n.no_media_label === "undefined")
wpmf.l18n.no_media_label = 'No';
if (typeof wpmf.l18n.yes_media_label === "undefined")
wpmf.l18n.yes_media_label = 'Yes';
var filter_displaymedia = '<select name="wpmf-display-media-filters" id="wpmf-display-media-filters" class="wpmf-filter-display-media attachment-filters">';
filter_displaymedia += '<option value="all" selected>' + wpmf.l18n.no_media_label + '</option>';
filter_displaymedia += '<option value="yes" selected>' + wpmf.l18n.yes_media_label + '</option>';
filter_displaymedia += '</select>';
$('.wpmf-categories').after(filter_displaymedia);
}
}
});
}(jQuery));