diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php deleted file mode 100644 index 9292fd9a..00000000 --- a/modules/custom-status/custom-status.php +++ /dev/null @@ -1,11 +0,0 @@ - * { - flex-basis: 48%; -} - -.publishpress-extended-post-status .publishpress-extended-post-status-note { - flex-basis: 100%; - color: #545454; -} - -.block-editor button.components-button.editor-post-save-draft { - /* Hide the main text */ - overflow: hidden; - text-indent: -99999px; - font-size: 0; -} - -.block-editor button.components-button.editor-post-save-draft:before { - content: attr(aria-label); - /* Reset styles to make the text visible */ - overflow: auto; - text-indent: 0; - font-size: initial; -} - -.block-editor button.components-button.editor-post-save-draft.has-icon::before { - content: none; -} diff --git a/modules/custom-status/lib/custom-status-block-editor.css.map b/modules/custom-status/lib/custom-status-block-editor.css.map deleted file mode 100644 index 010217d5..00000000 --- a/modules/custom-status/lib/custom-status-block-editor.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sourceRoot":"","sources":["custom-status-block-editor.scss"],"names":[],"mappings":"AAAA;EACE;;AACA;EACE;;AAGF;EACE","file":"custom-status-block-editor.css"} \ No newline at end of file diff --git a/modules/custom-status/lib/custom-status-block-editor.scss b/modules/custom-status/lib/custom-status-block-editor.scss deleted file mode 100644 index e2553d68..00000000 --- a/modules/custom-status/lib/custom-status-block-editor.scss +++ /dev/null @@ -1,29 +0,0 @@ -.publishpress-extended-post-status { - flex-flow: row wrap; - - > * { - flex-basis: 48%; - } - - .publishpress-extended-post-status-note { - flex-basis: 100%; - color: #545454; - } -} - -.block-editor { - button.components-button.editor-post-save-draft { - overflow: hidden; - text-indent: -99999px; - } - - button.components-button.editor-post-save-draft::before { - overflow: auto; - text-indent: 0; - content: attr(aria-label); - } - - button.components-button.editor-post-save-draft.has-icon::before { - content: none; - } -} diff --git a/modules/custom-status/lib/custom-status-block-style.css b/modules/custom-status/lib/custom-status-block-style.css deleted file mode 100644 index c39dfff8..00000000 --- a/modules/custom-status/lib/custom-status-block-style.css +++ /dev/null @@ -1 +0,0 @@ -/*# sourceMappingURL=custom-status-block-style.css.map */ diff --git a/modules/custom-status/lib/custom-status-block-style.css.map b/modules/custom-status/lib/custom-status-block-style.css.map deleted file mode 100644 index 4e8ec35c..00000000 --- a/modules/custom-status/lib/custom-status-block-style.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sourceRoot":"","sources":[],"names":[],"mappings":"","file":"custom-status-block-style.css"} \ No newline at end of file diff --git a/modules/custom-status/lib/custom-status-block.jsx b/modules/custom-status/lib/custom-status-block.jsx deleted file mode 100644 index 212374a9..00000000 --- a/modules/custom-status/lib/custom-status-block.jsx +++ /dev/null @@ -1,180 +0,0 @@ -/** - * ------------------------------------------------------------------------------ - * Based on Edit Flow - * Author: Daniel Bachhuber, Scott Bressler, Mohammad Jangda, Automattic, and - * others - * Copyright (c) 2009-2019 Mohammad Jangda, Daniel Bachhuber, et al. - * ------------------------------------------------------------------------------ - */ - -let {__} = wp.i18n; -let {PluginPostStatusInfo} = wp.hasOwnProperty('editPost') ? wp.editPost : ''; -let {registerPlugin} = wp.plugins; -let {withSelect, withDispatch, subscribe} = wp.data; -let {compose} = wp.compose; -let {SelectControl} = wp.components; - -const publishedStatuses = ['publish', 'future', 'private']; - -/** - * Map Custom Statuses as options for SelectControl - */ -let getStatusLabel = slug => { - let item = window.PPCustomStatuses.find(s => s.slug === slug); - - if (item) { - return item.name; - } - - let draft = window.PPCustomStatuses.find(s => s.slug === 'draft'); - - return draft.name; -}; - -// Remove the Published statuses and Pending Review from the list. -let getStatuses = () => { - let statuses = window.PPCustomStatuses.map(s => ({label: s.name, value: s.slug})); - statuses = statuses.filter((item) => { - return !publishedStatuses.includes(item.value) && 'pending' != item.value; - }); - - return statuses; -}; - -/** - * Hack :( - * - * @see https://github.com/WordPress/gutenberg/issues/3144 - * - * @param status - */ -let updateTheSaveAsButtonText = (status) => { - setTimeout(() => { - let node = document.querySelector('.editor-post-save-draft, .editor-post-switch-to-draft'); - - if (!node) { - return; - } - - let label; - let currentStatus = wp.data.select('core/editor').getCurrentPost().status; - if (publishedStatuses.includes(currentStatus)) { - if ('future' === currentStatus) { - label = __('Unschedule and Save as %s', 'publishpress').replace('%s', getStatusLabel('draft')); - } else { - label = __('Unpublish and Save as %s', 'publishpress').replace('%s', getStatusLabel('draft')); - } - } else { - label = __('Save as %s', 'publishpress').replace('%s', getStatusLabel(status)); - } - - if (label !== node.getAttribute('aria-label')) { - node.setAttribute('aria-label', label); - } - }, 100); -}; - -/** - * Hack :( - * We need an interval because the DOM element is removed by autosave and rendered back after finishing. - * - * @see - */ -if (PluginPostStatusInfo) { - var lastStatus = wp.data.select('core/editor').getCurrentPost().status; - setInterval(() => { - let currentStatus = wp.data.select('core/editor').getCurrentPost().status; - let editedStatus = wp.data.select('core/editor').getEditedPostAttribute('status'); - - updateTheSaveAsButtonText(editedStatus); - - if (lastStatus !== editedStatus) { - - // Force to render after a post status change - wp.data.dispatch('core/editor').editPost({ status: '!' }); - wp.data.dispatch('core/editor').editPost({ status: editedStatus }); - - lastStatus = editedStatus; - } - }, 100); -} - - -/** - * Custom status component - * @param object props - */ -let PPCustomPostStatusInfo = ({onUpdate, status}) => { - let statusControl; - let originalStatus = wp.data.select('core/editor').getCurrentPost().status; - let noteElement; - - if ([originalStatus, status].includes('publish')) { - statusControl =
{__('Published', 'publishpress')}
; - noteElement = - {__('To select a custom status, please unpublish the content first.', 'publishpress')} - ; - } else if ([originalStatus, status].includes('future')) { - statusControl =
{__('Scheduled', 'publishpress')}
; - noteElement = - {__('To select a custom status, please unschedule the content first.', 'publishpress')} - ; - } else if ('pending' === status) { - statusControl =
{__('Pending review', 'publishpress')}
; - noteElement = - {__('To select a custom status, please uncheck the "Pending Review" checkbox first.', 'publishpress')} - ; - } else if ([originalStatus, status].includes('private')) { - statusControl = -
{__('Privately Published', 'publishpress')}
; - noteElement = - {__('To select a custom status, please unpublish the content first.', 'publishpress')} - ; - } else { - statusControl = ; - } - - return ( - -

{__('Post Status', 'publishpress')}

- {statusControl} - {noteElement} -
- ); -}; - -let getCurrentPostStatus = function () { - let currentPostStatus = wp.data.select('core/editor').getEditedPostAttribute('status'); - - if (currentPostStatus === 'auto-draft') { - currentPostStatus = 'draft'; - } - - return currentPostStatus; -}; - -let plugin = compose( - withSelect((select) => ({ - status: getCurrentPostStatus() - })), - withDispatch((dispatch) => ({ - onUpdate(status) { - wp.data.dispatch('core/editor').editPost({status}); - updateTheSaveAsButtonText(status); - } - })) -)(PPCustomPostStatusInfo); - -if (PluginPostStatusInfo) { - registerPlugin('publishpress-custom-status-block', { - icon: 'admin-site', - render: plugin - }); -} \ No newline at end of file diff --git a/modules/custom-status/lib/custom-status-block.min.js b/modules/custom-status/lib/custom-status-block.min.js deleted file mode 100644 index 0d6ece2c..00000000 --- a/modules/custom-status/lib/custom-status-block.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){var t={};function s(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,s),r.l=!0,r.exports}s.m=e,s.c=t,s.d=function(e,t,a){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(s.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)s.d(a,r,function(t){return e[t]}.bind(null,r));return a},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=1)}([,function(e,t){var s=wp.i18n.__,a=(wp.hasOwnProperty("editPost")?wp.editPost:"").PluginPostStatusInfo,r=wp.plugins.registerPlugin,u=wp.data,n=u.withSelect,i=u.withDispatch,o=(u.subscribe,wp.compose.compose),l=wp.components.SelectControl,c=["publish","future","private"],p=function(e){var t=window.PPCustomStatuses.find((function(t){return t.slug===e}));return t?t.name:window.PPCustomStatuses.find((function(e){return"draft"===e.slug})).name},d=function(e){setTimeout((function(){var t=document.querySelector(".editor-post-save-draft, .editor-post-switch-to-draft");if(t){var a,r=wp.data.select("core/editor").getCurrentPost().status;(a=c.includes(r)?"future"===r?s("Unschedule and Save as %s","publishpress").replace("%s",p("draft")):s("Unpublish and Save as %s","publishpress").replace("%s",p("draft")):s("Save as %s","publishpress").replace("%s",p(e)))!==t.getAttribute("aria-label")&&t.setAttribute("aria-label",a)}}),100)};if(a){var f=wp.data.select("core/editor").getCurrentPost().status;setInterval((function(){wp.data.select("core/editor").getCurrentPost().status;var e=wp.data.select("core/editor").getEditedPostAttribute("status");d(e),f!==e&&(wp.data.dispatch("core/editor").editPost({status:"!"}),wp.data.dispatch("core/editor").editPost({status:e}),f=e)}),100)}var b=o(n((function(e){return{status:(t=wp.data.select("core/editor").getEditedPostAttribute("status"),"auto-draft"===t&&(t="draft"),t)};var t})),i((function(e){return{onUpdate:function(e){wp.data.dispatch("core/editor").editPost({status:e}),d(e)}}})))((function(e){var t,r,u,n=e.onUpdate,i=e.status,o=wp.data.select("core/editor").getCurrentPost().status;return[o,i].includes("publish")?(t=React.createElement("div",{className:"publishpress-static-post-status"},s("Published","publishpress")),r=React.createElement("small",{className:"publishpress-extended-post-status-note"},s("To select a custom status, please unpublish the content first.","publishpress"))):[o,i].includes("future")?(t=React.createElement("div",{className:"publishpress-static-post-status"},s("Scheduled","publishpress")),r=React.createElement("small",{className:"publishpress-extended-post-status-note"},s("To select a custom status, please unschedule the content first.","publishpress"))):"pending"===i?(t=React.createElement("div",{className:"publishpress-static-post-status"},s("Pending review","publishpress")),r=React.createElement("small",{className:"publishpress-extended-post-status-note"},s('To select a custom status, please uncheck the "Pending Review" checkbox first.',"publishpress"))):[o,i].includes("private")?(t=React.createElement("div",{className:"publishpress-static-post-status"},s("Privately Published","publishpress")),r=React.createElement("small",{className:"publishpress-extended-post-status-note"},s("To select a custom status, please unpublish the content first.","publishpress"))):t=React.createElement(l,{label:"",value:i,options:(u=window.PPCustomStatuses.map((function(e){return{label:e.name,value:e.slug}})),u=u.filter((function(e){return!c.includes(e.value)&&"pending"!=e.value}))),onChange:n}),React.createElement(a,{className:"publishpress-extended-post-status publishpress-extended-post-status-".concat(i)},React.createElement("h4",null,s("Post Status","publishpress")),t,r)}));a&&r("publishpress-custom-status-block",{icon:"admin-site",render:b})}]); \ No newline at end of file diff --git a/modules/custom-status/lib/custom-status-configure.js b/modules/custom-status/lib/custom-status-configure.js deleted file mode 100644 index 103aa582..00000000 --- a/modules/custom-status/lib/custom-status-configure.js +++ /dev/null @@ -1,175 +0,0 @@ -(function ($) { - - inlineEditCustomStatus = { - - init: function () { - var t = this, row = $('#inline-edit'); - - t.what = '#term-'; - - $(document).on('click', '.editinline', function () { - inlineEditCustomStatus.edit(this); - - return false; - }); - - // prepare the edit row - row.on('keyup', function (e) { - if (e.which == 27) return inlineEditCustomStatus.revert(); - }); - - $('a.cancel', row).on('click', function () { - return inlineEditCustomStatus.revert(); - }); - $('a.save', row).on('click', function () { - return inlineEditCustomStatus.save(this); - }); - $('input, select', row).on('keydown', function (e) { - if (e.which == 13) return inlineEditCustomStatus.save(this); - }); - - $('#posts-filter input[type="submit"]').on('mousedown', function (e) { - t.revert(); - }); - }, - - toggle: function (el) { - var t = this; - $(t.what + t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); - }, - - edit: function (id) { - var t = this, editRow; - t.revert(); - - if (typeof (id) == 'object') - id = t.getId(id); - - editRow = $('#inline-edit').clone(true), rowData = $('#inline_' + id); - $('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length); - - if ($(t.what + id).hasClass('alternate')) - $(editRow).addClass('alternate'); - - $(t.what + id).hide().after(editRow); - - $(':input[name="name"]', editRow).val($('.name', rowData).text()); - $(':input[name="description"]', editRow).val($('.description', rowData).text()); - $(':input[name="color"]', editRow).val($('.color', rowData).text()); - $(':input[name="icon"]', editRow).val($('.icon', rowData).text()); - - $(editRow).attr('id', 'edit-' + id).addClass('inline-editor').show(); - $('.ptitle', editRow).eq(0).focus(); - - return false; - }, - - save: function (id) { - var params, fields, tax = $('input[name="taxonomy"]').val() || ''; - - if (typeof (id) == 'object') - id = this.getId(id); - - $('table.widefat .inline-edit-save .waiting').show(); - - params = { - action: 'inline_save_status', - status_id: id - }; - - fields = $('#edit-' + id + ' :input').serialize(); - params = fields + '&' + $.param(params); - - // make ajax request - $.post(ajaxurl, params, - function (r) { - var row, new_id; - $('table.widefat .inline-edit-save .waiting').hide(); - - if (r) { - if (-1 != r.indexOf(''; - } else { - var message = '

' + retval.message + '

'; - } - $('.publishpress-admin header').after(message); - }).fail(function() { - var message = '

Error

'; - $('.publishpress-admin header').after(message); - }); - } - }); - $('.pp-custom-status-wrap #the-list tr.term-static').disableSelection(); - }); -})(jQuery); diff --git a/modules/custom-status/lib/custom-status.css b/modules/custom-status/lib/custom-status.css deleted file mode 100644 index e69de29b..00000000 diff --git a/modules/custom-status/lib/custom-status.js b/modules/custom-status/lib/custom-status.js deleted file mode 100644 index da8b8a5d..00000000 --- a/modules/custom-status/lib/custom-status.js +++ /dev/null @@ -1,211 +0,0 @@ -jQuery(document).ready(function () { - - jQuery('label[for=post_status]').show(); - jQuery('#post-status-display').show(); - - if (jQuery('select[name="_status"]').length == 0) { // not on quick edit - - // Show the button for users who can, and can't publish. Those who can't, should see a button to Send for Review - jQuery('#publish').show(); - - if (!(current_user_can_publish_posts || (current_status == 'publish' && current_user_can_edit_published_posts))) { - // mimic default post status dropdown - jQuery(' Edit' + - '
' + - ' ' + - ' ' + - ' OK' + - ' Cancel' + - '
').insertAfter('#post-status-display'); - - if (!status_dropdown_visible) { - jQuery('#post-status-select').hide(); - jQuery('.edit-post-status').show(); - } - - jQuery('.edit-post-status').on('click', function () { - jQuery('#post-status-select').slideDown(); - jQuery('.edit-post-status').hide(); - return false; - }); - jQuery('.cancel-post-status, .save-post-status').on('click', function () { - jQuery('#post-status-select').slideUp(); - jQuery('.edit-post-status').show(); - return false; - }); - jQuery('.save-post-status').on('click', function () { - jQuery('#post-status-display').text(jQuery('select[name="post_status"] :selected').text()); - return false; - }); - // Make sure we have the button to save - if (0 === jQuery('#save-post').length) { - jQuery('').appendTo('#save-action'); - jQuery('').appendTo('#save-action'); - } - } - } - - // 1. Add custom statuses to post.php Status dropdown - // Or 2. Add custom statuses to quick-edit status dropdowns on edit.php - // Or 3. Hide two inputs with the default workflow status to override 'Draft' as the default contributor status - if (jQuery('select[name="post_status"]').length > 0) { - - // Set the Save button to generic text by default - pp_update_save_button('Save'); - - // Bind event when OK button is clicked - jQuery('.save-post-status').on('click', function () { - pp_update_save_button(); - }); - - // Add custom statuses to Status dropdown - pp_append_to_dropdown('select[name="post_status"]'); - - // Make status dropdown visible on load if enabled - if (status_dropdown_visible) { - jQuery('#post-status-select').show(); - jQuery('.edit-post-status').hide(); - } - - // Hide status dropdown if not allowed to edit - if (!pp_can_change_status(current_status)) { - jQuery('#post-status-select').hide(); - jQuery('.edit-post-status').hide(); - - // set the current status as the selected one - var $option = jQuery('').text(current_status_name).attr('value', current_status).prop('selected', true); - - $option.appendTo('select[name="post_status"]'); - } - - // If custom status set for post, then set is as #post-status-display - jQuery('#post-status-display').text(pp_get_status_name(current_status)); - - } else if (jQuery('select[name="_status"]').length > 0) { - pp_append_to_dropdown('select[name="_status"]'); - // Refresh the custom status dropdowns everytime Quick Edit is loaded - jQuery('#the-list a.editinline').on('click', function () { - pp_append_to_dropdown('#the-list select[name="_status"]'); - }); - // Clean up the bulk edit selector because it's non-standard - jQuery('#bulk-edit').find('select[name="_status"]').prepend(''); - jQuery('#bulk-edit').find('select[name="_status"] option').prop('selected', false); - jQuery('#bulk-edit').find('select[name="_status"] option[value="future"]').remove(); - } else { - - // Set the Save button to generic text by default - pp_update_save_button('Save'); - - // If custom status set for post, then set is as #post-status-display - jQuery('#post-status-display').text(pp_get_status_name(current_status)); - - } - - if (jQuery('ul.subsubsub')) { - pp_add_tooltips_to_filter_links('ul.subsubsub li a'); - } - - // Add custom statuses to Status dropdown - function pp_append_to_dropdown(id) { - - // Empty dropdown except for 'future' because we need to persist that - jQuery(id + ' option').not('[value="future"]').remove(); - - // Add "Published" status to quick-edit for users that can publish - if (id == 'select[name="_status"]' && current_user_can_publish_posts) { - jQuery(id).append(jQuery('') - .attr('value', 'publish') - .text('Published') - ); - } - - var status_select_options_values = jQuery('option', jQuery(id)) - .map(function getSelectOptionValue(option_index, option) { - return option.value; - }) - .toArray() - .filter(function isSelectOptionUnique(option_value, option_value_index, self) { - return self.indexOf(option_value) === option_value_index - }); - - // Add remaining statuses to dropdown. 'private' is always handled by a checkbox, and 'future' already exists if we need it - jQuery.each(custom_statuses, function () { - if (this.slug == 'private' || this.slug == 'future') - return; - - if (current_status != 'publish' && this.slug == 'publish') - return; - - if (status_select_options_values.indexOf(this.slug) >= 0) return; - - var $option = jQuery('') - .text(this.name) - .attr('value', this.slug) - .attr('title', (this.description) ? this.description : '') - ; - - if (current_status == this.slug) { - $option.prop('selected', true); - } - - $option.appendTo(jQuery(id)); - - status_select_options_values.push(this.slug); - }); - } - - function pp_can_change_status(slug) { - var change = false; - - jQuery.each(custom_statuses, function () { - if (this.slug == slug) change = true; - }); - if (slug == 'publish' && !current_user_can_publish_posts) { - change = false; - } - return change; - } - - function pp_add_tooltips_to_filter_links(selector) { - jQuery.each(custom_statuses, function () { - jQuery(selector + ':contains("' + this.name + '")') - .attr('title', this.description); - }); - - } - - // Update "Save" button text - function pp_update_save_button(text) { - if (!text) text = 'Save as ' + jQuery('select[name="post_status"] :selected').text(); - jQuery(':input#save-post').attr('value', text); - } - - // Returns the name of the status given a slug - function pp_get_status_name(slug) { - var name = ''; - jQuery.each(custom_statuses, function () { - if (this.slug == slug) name = this.name; - }); - - if (!name) { - name = current_status_name; - } - - return name; - } - - // If we're on the Manage Posts screen, remove the trailing dashes left behind once we hide the post-state span (the status). - // We do this since we already add a custom column for post status on the screen since custom statuses are a core part of EF. - if (jQuery('.post-state').length > 0) { - pp_remove_post_title_trailing_dashes(); - } - - // Remove the " - " in between a post title and the post-state span (separately hidden via CSS). - // This will not affect the dash before post-state-format spans. - function pp_remove_post_title_trailing_dashes() { - jQuery('.post-title.column-title strong').each(function () { - jQuery(this).html(jQuery(this).html().replace(/(.*) - ()$/g, '$1$2')); - }); - } -}); diff --git a/modules/custom-status/lib/icon-picker.css b/modules/custom-status/lib/icon-picker.css deleted file mode 100644 index b2e73330..00000000 --- a/modules/custom-status/lib/icon-picker.css +++ /dev/null @@ -1,64 +0,0 @@ -.dashicon-picker-container { - position: absolute; - width: 220px; - height: 252px; - font-size: 14px; - background-color: #fff; - -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); - overflow: hidden; - padding: 5px; - box-sizing: border-box; -} - -.dashicon-picker-container ul { - margin: 0; - padding: 0; - margin-bottom: 10px; -} - -.dashicon-picker-container ul .dashicons { - width: 20px; - height: 20px; - font-size: 20px; -} - -.dashicon-picker-container ul li { - display: inline-block; - margin: 5px; - float: left; -} - -.dashicon-picker-container ul li a { - display: block; - text-decoration: none; - color: #373737; - padding: 5px 5px; - border: 1px solid #dfdfdf; -} - -.dashicon-picker-container ul li a:hover { - border-color: #999; - background: #efefef; -} - -.dashicon-picker-control { - height: 32px; -} - -.dashicon-picker-control a { - padding: 5px; - text-decoration: none; - line-height: 32px; - width: 25px; -} - -.dashicon-picker-control a span { - display: inline; - vertical-align: middle; -} - -.dashicon-picker-control input { - font-size: 12px; - width: 140px; -} diff --git a/modules/custom-status/lib/icon-picker.js b/modules/custom-status/lib/icon-picker.js deleted file mode 100644 index 252eade4..00000000 --- a/modules/custom-status/lib/icon-picker.js +++ /dev/null @@ -1,422 +0,0 @@ -/** - * Dashicons Picker - * - * Based on: https://github.com/bradvin/dashicons-picker/ - */ - -(function ($) { - 'use strict'; - /** - * - * @returns {void} - */ - $.fn.dashiconsPicker = function () { - - /** - * Dashicons, in CSS order - * - * @type Array - */ - var icons = [ - 'menu', - 'admin-site', - 'dashboard', - 'admin-media', - 'admin-page', - 'admin-comments', - 'admin-appearance', - 'admin-plugins', - 'admin-users', - 'admin-tools', - 'admin-settings', - 'admin-network', - 'admin-generic', - 'admin-home', - 'admin-collapse', - 'filter', - 'admin-customizer', - 'admin-multisite', - 'admin-links', - 'format-links', - 'admin-post', - 'format-standard', - 'format-image', - 'format-gallery', - 'format-audio', - 'format-video', - 'format-chat', - 'format-status', - 'format-aside', - 'format-quote', - 'welcome-write-blog', - 'welcome-edit-page', - 'welcome-add-page', - 'welcome-view-site', - 'welcome-widgets-menus', - 'welcome-comments', - 'welcome-learn-more', - 'image-crop', - 'image-rotate', - 'image-rotate-left', - 'image-rotate-right', - 'image-flip-vertical', - 'image-flip-horizontal', - 'image-filter', - 'undo', - 'redo', - 'editor-bold', - 'editor-italic', - 'editor-ul', - 'editor-ol', - 'editor-quote', - 'editor-alignleft', - 'editor-aligncenter', - 'editor-alignright', - 'editor-insertmore', - 'editor-spellcheck', - 'editor-distractionfree', - 'editor-expand', - 'editor-contract', - 'editor-kitchensink', - 'editor-underline', - 'editor-justify', - 'editor-textcolor', - 'editor-paste-word', - 'editor-paste-text', - 'editor-removeformatting', - 'editor-video', - 'editor-customchar', - 'editor-outdent', - 'editor-indent', - 'editor-help', - 'editor-strikethrough', - 'editor-unlink', - 'editor-rtl', - 'editor-break', - 'editor-code', - 'editor-paragraph', - 'editor-table', - 'align-left', - 'align-right', - 'align-center', - 'align-none', - 'lock', - 'unlock', - 'calendar', - 'calendar-alt', - 'visibility', - 'hidden', - 'post-status', - 'edit', - 'post-trash', - 'trash', - 'sticky', - 'external', - 'arrow-up', - 'arrow-down', - 'arrow-left', - 'arrow-right', - 'arrow-up-alt', - 'arrow-down-alt', - 'arrow-left-alt', - 'arrow-right-alt', - 'arrow-up-alt2', - 'arrow-down-alt2', - 'arrow-left-alt2', - 'arrow-right-alt2', - 'leftright', - 'sort', - 'randomize', - 'list-view', - 'excerpt-view', - 'grid-view', - 'hammer', - 'art', - 'migrate', - 'performance', - 'universal-access', - 'universal-access-alt', - 'tickets', - 'nametag', - 'clipboard', - 'heart', - 'megaphone', - 'schedule', - 'wordpress', - 'wordpress-alt', - 'pressthis', - 'update', - 'screenoptions', - 'cart', - 'feedback', - 'cloud', - 'translation', - 'tag', - 'category', - 'archive', - 'tagcloud', - 'text', - 'media-archive', - 'media-audio', - 'media-code', - 'media-default', - 'media-document', - 'media-interactive', - 'media-spreadsheet', - 'media-text', - 'media-video', - 'playlist-audio', - 'playlist-video', - 'controls-play', - 'controls-pause', - 'controls-forward', - 'controls-skipforward', - 'controls-back', - 'controls-skipback', - 'controls-repeat', - 'controls-volumeon', - 'controls-volumeoff', - 'yes', - 'no', - 'no-alt', - 'plus', - 'plus-alt', - 'plus-alt2', - 'minus', - 'dismiss', - 'marker', - 'star-filled', - 'star-half', - 'star-empty', - 'flag', - 'info', - 'warning', - 'share', - 'share1', - 'share-alt', - 'share-alt2', - 'twitter', - 'rss', - 'email', - 'email-alt', - 'facebook', - 'facebook-alt', - 'networking', - 'googleplus', - 'location', - 'location-alt', - 'camera', - 'images-alt', - 'images-alt2', - 'video-alt', - 'video-alt2', - 'video-alt3', - 'vault', - 'shield', - 'shield-alt', - 'sos', - 'search', - 'slides', - 'analytics', - 'chart-pie', - 'chart-bar', - 'chart-line', - 'chart-area', - 'groups', - 'businessman', - 'id', - 'id-alt', - 'products', - 'awards', - 'forms', - 'testimonial', - 'portfolio', - 'book', - 'book-alt', - 'download', - 'upload', - 'backup', - 'clock', - 'lightbulb', - 'microphone', - 'desktop', - 'tablet', - 'smartphone', - 'phone', - 'smiley', - 'index-card', - 'carrot', - 'building', - 'store', - 'album', - 'palmtree', - 'tickets-alt', - 'money', - 'thumbs-up', - 'thumbs-down', - 'layout', - 'align-pull-left', - 'align-pull-right', - 'block-default', - 'cloud-saved', - 'cloud-upload', - 'columns', - 'cover-image', - 'embed-audio', - 'embed-generic', - 'embed-photo', - 'embed-post', - 'embed-video', - 'exit', - 'html', - 'info-outline', - 'insert-after', - 'insert-before', - 'insert', - 'remove', - 'shortcode', - 'table-col-after', - 'table-col-before', - 'table-col-delete', - 'table-row-after', - 'table-row-before', - 'table-row-delete', - 'saved', - 'amazon', - 'google', - 'linkedin', - 'pinterest', - 'podio', - 'reddit', - 'spotify', - 'twitch', - 'whatsapp', - 'xing', - 'youtube', - 'database-add', - 'database-export', - 'database-import', - 'database-remove', - 'database-view', - 'database', - 'bell', - 'airplane', - 'car', - 'calculator', - 'ames', - 'printer', - 'beer', - 'coffee', - 'drumstick', - 'food', - 'bank', - 'hourglass', - 'money-alt', - 'open-folder', - 'pdf', - 'pets', - 'privacy', - 'superhero', - 'superhero-alt', - 'edit-page', - 'fullscreen-alt', - 'fullscreen-exit-alt', - '', - '', - '' - ]; - - return this.each(function () { - - var button = $(this), - offsetTop, - offsetLeft; - - button.on('click.dashiconsPicker', function (e) { - offsetTop = $(e.currentTarget).offset().top; - offsetLeft = $(e.currentTarget).offset().left; - createPopup(button); - }); - - function createPopup(button) { - - var target = $(button.data('target')), - preview = $(button.data('preview')), - popup = $('
' + - '
' + - '
    ' + - '
    ').css({ - 'top': offsetTop, - 'left': offsetLeft - }), - list = popup.find('.dashicon-picker-list'); - - for (var i in icons) { - if (icons.hasOwnProperty(i)) { - list.append('
  • '); - } - } - - $('a', list).on('click', function (e) { - e.preventDefault(); - var title = $(this).attr('title'); - target.val('dashicons-' + title); - preview - .prop('class', 'dashicons') - .addClass('dashicons-' + title); - removePopup(); - }); - - var control = popup.find('.dashicon-picker-control'); - - control.html('' + - '' + - '' + - '' - ); - - $('a', control).on('click', function (e) { - e.preventDefault(); - if ($(this).data('direction') === 'back') { - $('li:gt(' + (icons.length - 26) + ')', list).prependTo(list); - } else { - $('li:lt(25)', list).appendTo(list); - } - }); - - popup.appendTo('body').show(); - - $('input', control).on('keyup', function (e) { - var search = $(this).val(); - if (search === '') { - $('li:lt(25)', list).show(); - } else { - $('li', list).each(function () { - if ($(this).data('icon').toLowerCase().indexOf(search.toLowerCase()) !== -1) { - $(this).show(); - } else { - $(this).hide(); - } - }); - } - }); - - $(document).on('mouseup.dashicons-picker', function (e) { - if (!popup.is(e.target) && popup.has(e.target).length === 0) { - removePopup(); - } - }); - } - - function removePopup() { - $('.dashicon-picker-container').remove(); - $(document).off('.dashicons-picker'); - } - }); - }; - - $(function () { - $('.dashicons-picker').dashiconsPicker(); - }); - -}(jQuery));