admin
2 months ago
builder
2 months ago
stripe
2 months ago
admin.js
2 months ago
checkout-fields-manager.js
2 months ago
checkout.js
4 days ago
clipboard.min.js
2 months ago
content-control.js
2 months ago
create-form.js
2 months ago
frontend.js
2 months ago
frontend.min.js
4 days ago
index.php
2 months ago
jcarousel.min.js
2 months ago
jquery.blockUI.js
2 months ago
mailoptin.js
2 months ago
member-directory.js
2 months ago
member-directory.min.js
2 months ago
pp-wp-editor.js
2 months ago
pp-wp-editor.js
193 lines
| 1 | jQuery.fn.pp_wp_editor = function (options) { |
| 2 | |
| 3 | var default_options, |
| 4 | id_regexp = new RegExp('ppWPEditor', 'g'); |
| 5 | |
| 6 | if (typeof tinyMCEPreInit === 'undefined' || typeof QTags === 'undefined' || typeof ppWPEditor_globals === 'undefined') { |
| 7 | console.warn('js_wp_editor( $settings ); must be loaded'); |
| 8 | return this; |
| 9 | } |
| 10 | |
| 11 | default_options = { |
| 12 | 'mode': 'html', |
| 13 | 'mceInit': { |
| 14 | "theme": "modern", |
| 15 | "skin": "lightgray", |
| 16 | "language": "en", |
| 17 | "formats": { |
| 18 | "alignleft": [ |
| 19 | { |
| 20 | "selector": "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", |
| 21 | "styles": {"textAlign": "left"}, |
| 22 | "deep": false, |
| 23 | "remove": "none" |
| 24 | }, |
| 25 | { |
| 26 | "selector": "img,table,dl.wp-caption", |
| 27 | "classes": ["alignleft"], |
| 28 | "deep": false, |
| 29 | "remove": "none" |
| 30 | } |
| 31 | ], |
| 32 | "aligncenter": [ |
| 33 | { |
| 34 | "selector": "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", |
| 35 | "styles": {"textAlign": "center"}, |
| 36 | "deep": false, |
| 37 | "remove": "none" |
| 38 | }, |
| 39 | { |
| 40 | "selector": "img,table,dl.wp-caption", |
| 41 | "classes": ["aligncenter"], |
| 42 | "deep": false, |
| 43 | "remove": "none" |
| 44 | } |
| 45 | ], |
| 46 | "alignright": [ |
| 47 | { |
| 48 | "selector": "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", |
| 49 | "styles": {"textAlign": "right"}, |
| 50 | "deep": false, |
| 51 | "remove": "none" |
| 52 | }, |
| 53 | { |
| 54 | "selector": "img,table,dl.wp-caption", |
| 55 | "classes": ["alignright"], |
| 56 | "deep": false, |
| 57 | "remove": "none" |
| 58 | } |
| 59 | ], |
| 60 | "strikethrough": {"inline": "del", "deep": true, "split": true} |
| 61 | }, |
| 62 | "relative_urls": false, |
| 63 | "remove_script_host": false, |
| 64 | "convert_urls": false, |
| 65 | "browser_spellcheck": true, |
| 66 | "fix_list_elements": true, |
| 67 | "entities": "38,amp,60,lt,62,gt", |
| 68 | "entity_encoding": "raw", |
| 69 | "keep_styles": false, |
| 70 | "paste_webkit_styles": "font-weight font-style color", |
| 71 | "preview_styles": "font-family font-size font-weight font-style text-decoration text-transform", |
| 72 | "wpeditimage_disable_captions": false, |
| 73 | "wpeditimage_html5_captions": false, |
| 74 | "plugins": "charmap,hr,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpview,image", |
| 75 | "content_css": ppWPEditor_globals.includes_url + "css/dashicons.css?ver=3.9," + ppWPEditor_globals.includes_url + "js/mediaelement/mediaelementplayer.min.css?ver=3.9," + ppWPEditor_globals.includes_url + "js/mediaelement/wp-mediaelement.css?ver=3.9," + ppWPEditor_globals.includes_url + "js/tinymce/skins/wordpress/wp-content.css?ver=3.9", |
| 76 | "selector": "#ppWPEditor", |
| 77 | "resize": "vertical", |
| 78 | "menubar": false, |
| 79 | "toolbar1": "bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,fullscreen,wp_adv", |
| 80 | "toolbar2": "formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help", |
| 81 | "toolbar3": "", |
| 82 | "toolbar4": "", |
| 83 | "tabfocus_elements": ":prev,:next", |
| 84 | "body_class": "ppWPEditor", |
| 85 | 'branding': false, |
| 86 | // ensure paragraphs are wrapped in <p> and the indent makes the paragraphs to be in new line instead of |
| 87 | // <p>ss</p><p>kk</p> |
| 88 | "wpautop": false, |
| 89 | "indent": true |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | if (tinyMCEPreInit.mceInit.ppWPEditor) { |
| 94 | default_options.mceInit = tinyMCEPreInit.mceInit.ppWPEditor; |
| 95 | } |
| 96 | |
| 97 | options = jQuery.extend(true, {}, default_options, options); |
| 98 | |
| 99 | return this.each(function () { |
| 100 | var $this = jQuery(this), |
| 101 | current_id = $this.attr('id'), |
| 102 | temp = {}; |
| 103 | |
| 104 | if (tinyMCE.editors[current_id] !== undefined) { |
| 105 | tinyMCE.remove(tinymce.editors[current_id]); |
| 106 | } |
| 107 | |
| 108 | if (!$this.is('textarea')) { |
| 109 | console.warn('Element must be a textarea'); |
| 110 | if ($this.closest('.wp-editor-wrap').length) { |
| 111 | temp.editor_wrap = $this.closest('.wp-editor-wrap'); |
| 112 | temp.field_parent = temp.editor_wrap.parent(); |
| 113 | |
| 114 | temp.editor_wrap.before($this.clone()); |
| 115 | temp.editor_wrap.remove(); |
| 116 | |
| 117 | $this = temp.field_parent.find('textarea[id="' + current_id + '"]'); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | $this.addClass('wp-editor-area').show(); |
| 122 | |
| 123 | |
| 124 | jQuery.each(options.mceInit, function (key, value) { |
| 125 | if (jQuery.type(value) === 'string') { |
| 126 | options.mceInit[key] = value.replace(id_regexp, current_id); |
| 127 | } |
| 128 | }); |
| 129 | |
| 130 | options.mode = options.mode === 'tmce' ? 'tmce' : 'html'; |
| 131 | |
| 132 | tinyMCEPreInit.mceInit[current_id] = options.mceInit; |
| 133 | |
| 134 | var wrap = jQuery('<div id="wp-' + current_id + '-wrap" class="wp-core-ui wp-editor-wrap ' + options.mode + '-active" />'), |
| 135 | editor_tools = jQuery('<div id="wp-' + current_id + '-editor-tools" class="wp-editor-tools hide-if-no-js" />'), |
| 136 | editor_tabs = jQuery('<div class="wp-editor-tabs" />'), |
| 137 | switch_editor_html = jQuery('<a id="' + current_id + '-html" class="wp-switch-editor switch-html" data-wp-editor-id="' + current_id + '">' + ppWPEditor_globals.wpeditor_texttab_label + '</a>'), |
| 138 | switch_editor_tmce = jQuery('<a id="' + current_id + '-tmce" class="wp-switch-editor switch-tmce" data-wp-editor-id="' + current_id + '">' + ppWPEditor_globals.wpeditor_visualtab_label + '</a>'), |
| 139 | media_buttons = jQuery('<div id="wp-' + current_id + '-media-buttons" class="wp-media-buttons" />'), |
| 140 | insert_media_button = jQuery('<a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="' + current_id + '" title="' + ppWPEditor_globals.wpeditor_addmedia_label + '"><span class="wp-media-buttons-icon"></span>' + ppWPEditor_globals.wpeditor_addmedia_label + '</a>'), |
| 141 | editor_container = jQuery('<div id="wp-' + current_id + '-editor-container" class="wp-editor-container" />'), |
| 142 | content_css = false; |
| 143 | |
| 144 | insert_media_button.appendTo(media_buttons); |
| 145 | media_buttons.appendTo(editor_tools); |
| 146 | |
| 147 | switch_editor_tmce.appendTo(editor_tabs); |
| 148 | switch_editor_html.appendTo(editor_tabs); |
| 149 | editor_tabs.appendTo(editor_tools); |
| 150 | |
| 151 | editor_tools.appendTo(wrap); |
| 152 | editor_container.appendTo(wrap); |
| 153 | |
| 154 | editor_container.append($this.clone().addClass('wp-editor-area')); |
| 155 | |
| 156 | if (content_css !== false) |
| 157 | jQuery.each(content_css, function () { |
| 158 | if (!jQuery('link[href="' + this + '"]').length) |
| 159 | $this.before('<link rel="stylesheet" type="text/css" href="' + this + '">'); |
| 160 | }); |
| 161 | |
| 162 | $this.before('<link rel="stylesheet" id="editor-buttons-css" href="' + ppWPEditor_globals.includes_url + 'css/editor.css" type="text/css" media="all">'); |
| 163 | |
| 164 | $this.before(wrap); |
| 165 | $this.remove(); |
| 166 | |
| 167 | new QTags(current_id); |
| 168 | QTags._buttonsInit(); |
| 169 | switchEditors.go(current_id, options.mode); |
| 170 | |
| 171 | jQuery('.insert-media', wrap).on('click', function (event) { |
| 172 | var elem = jQuery(event.currentTarget), |
| 173 | options = { |
| 174 | frame: 'post', |
| 175 | state: 'insert', |
| 176 | title: wp.media.view.l10n.addMedia, |
| 177 | multiple: true |
| 178 | }; |
| 179 | |
| 180 | event.preventDefault(); |
| 181 | |
| 182 | elem.trigger('blur'); |
| 183 | |
| 184 | if (elem.hasClass('gallery')) { |
| 185 | options.state = 'gallery'; |
| 186 | options.title = wp.media.view.l10n.createGalleryTitle; |
| 187 | } |
| 188 | |
| 189 | wp.media.editor.open(current_id, options); |
| 190 | }); |
| 191 | |
| 192 | }); |
| 193 | }; |