PluginProbe ʕ •ᴥ•ʔ
Simple Author Box / 2.52
Simple Author Box v2.52
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.0.1 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.11 2.3.12 2.3.15 2.3.16 2.3.2 2.3.20 2.3.21 2.3.22 2.4 2.41 2.42 2.45 2.46 2.47 2.48 2.49 2.50 2.51 2.52 2.54 2.55 2.56 2.57 2.59 2.60
simple-author-box / assets / js / sabox-editor.js
simple-author-box / assets / js Last commit date
sab-pointers.js 4 years ago sab-preview.js 3 years ago sab_gutenberg_editor_script.js 3 years ago sabox-admin.js 4 years ago sabox-editor.js 4 years ago sabox-picker.js 4 years ago sweetalert2.min.js 5 years ago webfont.js 3 years ago
sabox-editor.js
156 lines
1 /**
2 * SAB
3 * (c) WebFactory Ltd, 2016 - 2021
4 */
5
6 (function( $ ) {
7
8 'use strict';
9 var SABox = {};
10
11 var mediaControl = {
12
13 // Initializes a new media manager or returns an existing frame.
14 // @see wp.media.featuredImage.frame()
15 selector: null,
16 size: null,
17 container: null,
18 frame: function() {
19 if ( this._frame ) {
20 return this._frame;
21
22 }
23
24 this._frame = wp.media( {
25 title: 'Media',
26 button: {
27 text: 'Update'
28 },
29 multiple: false
30 } );
31
32 this._frame.on( 'open', this.updateFrame ).state( 'library' ).on( 'select', this.select );
33
34 return this._frame;
35
36 },
37
38 select: function() {
39 var context = $( '#sabox-custom-profile-image' ),
40 input = context.find( '#sabox-custom-image' ),
41 image = context.find( 'img' ),
42 attachment = mediaControl.frame().state().get( 'selection' ).first().toJSON();
43
44 image.attr( 'src', attachment.url );
45 input.val( attachment.url );
46
47 },
48
49 init: function() {
50 var context = $( '#sabox-custom-profile-image' );
51 context.on( 'click', '#sabox-add-image', function( e ) {
52 e.preventDefault();
53 mediaControl.frame().open();
54 } );
55
56 context.on( 'click', '#sabox-remove-image', function( e ) {
57 var context = $( '#sabox-custom-profile-image' ),
58 input = context.find( '#sabox-custom-image' ),
59 image = context.find( 'img' );
60
61 e.preventDefault();
62
63 input.val( '' );
64 image.attr( 'src', image.data( 'default' ) );
65 } );
66
67 }
68
69 };
70
71 $( document ).ready( function() {
72 if ( $( '#description' ).length > 0 ) {
73 wp.editor.initialize( 'description', {
74 tinymce: {
75 wpautop: true
76 },
77 quicktags: true
78 } );
79 }
80
81 // WYSIWYG editor for textarea with class sab-editor.
82 var sab_editor = jQuery('.sab-editor');
83 if (sab_editor.length == 1) {
84 var sab_editor_id = sab_editor.attr('id');
85 wp.editor.initialize(sab_editor_id, {
86 tinymce: {
87 wpautop: true,
88 browser_spellcheck: true,
89 mediaButtons: false,
90 wp_autoresize_on: true,
91 toolbar1: 'bold,italic,bullist,numlist,link,strikethrough',
92 setup: function (editor) {
93 editor.on('change', function () {
94 editor.save();
95 jQuery(sab_editor).trigger('change');
96 });
97 }
98 },
99 quicktags: true
100 });
101
102 } else if (sab_editor.length > 1) {
103 sab_editor.each(function () {
104 var sab_editor_id = jQuery(this).attr('id');
105 wp.editor.initialize(sab_editor_id, {
106 tinymce: {
107 wpautop: true,
108 browser_spellcheck: true,
109 mediaButtons: false,
110 wp_autoresize_on: true,
111 toolbar1: 'bold,italic,link,strikethrough',
112 setup: function (editor) {
113 editor.on('change', function () {
114 editor.save();
115 jQuery(this).trigger('change');
116 });
117 }
118 },
119 quicktags: true
120 });
121 });
122
123 }
124
125
126 // Add Social Links
127 $( '.sabox-add-social-link a' ).click( function( e ) {
128
129 e.preventDefault();
130
131 if ( undefined === SABox.html ) {
132 SABox.html = '<tr> <th><span class="sabox-drag"></span><select name="sabox-social-icons[]">';
133 $.each( SABHelper.socialIcons, function( key, name ) {
134 SABox.html = SABox.html + '<option value="' + key + '">' + name + '</option>';
135 } );
136 SABox.html = SABox.html + '</select></th><td><input name="sabox-social-links[]" type="text" class="regular-text"><span class="dashicons dashicons-trash"></span><td></tr>';
137 }
138
139 $( '#sabox-social-table' ).append( SABox.html );
140
141 } );
142
143 // Remove Social Link
144 $( '#sabox-social-table' ).on( 'click', '.dashicons-trash', function() {
145 var row = $( this ).parents( 'tr' );
146 row.fadeOut( 'slow', function() {
147 row.remove();
148 } );
149 } );
150
151 mediaControl.init();
152
153 } );
154
155 })( jQuery );
156