PluginProbe ʕ •ᴥ•ʔ
Shortcoder — Create Shortcodes for Anything / 4.1.2
Shortcoder — Create Shortcodes for Anything v4.1.2
trunk 3.0 3.0.1 3.1 3.2 3.3 3.4 3.4.1 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.3 4.4 4.5 4.6 5.0 5.0.1 5.0.2 5.0.3 5.0.4 5.1 5.2 5.2.1 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.4 5.5 5.6 5.7 5.8 6.0 6.1 6.2 6.3 6.3.1 6.3.2 6.4 6.5 6.5.1 6.5.2 6.5.3
shortcoder / admin / js / script-insert.js
shortcoder / admin / js Last commit date
tinymce 8 years ago script-insert.js 8 years ago script.js 8 years ago
script-insert.js
114 lines
1 (function($){
2
3 $(document).ready(function(){
4
5 var last_sort = 'desc';
6
7 var send_editor = function( content = '' ){
8 if( typeof parent.send_to_editor === 'function' ){
9 parent.send_to_editor( content );
10 }else{
11 alert( 'Editor does not exist. Cannot insert content !' );
12 }
13 }
14
15 var close_window = function(){
16 if( typeof parent.tb_remove === 'function' ){
17 parent.tb_remove();
18 }
19 }
20
21 var sort = function( ele, orderby ){
22 var total = ele.length;
23 while( total ){
24 ele.each(function(){
25 var $cur = $(this);
26 var $next = $cur.next();
27 if( $next.length ){
28 var cur_name = $cur.attr( 'data-name' ).toLowerCase();
29 var nxt_name = $next.attr( 'data-name' ).toLowerCase();
30 if( ( orderby == 'asc' && cur_name > nxt_name ) || ( orderby == 'desc' && cur_name < nxt_name ) ){
31 $next.after( $cur );
32 }
33 }
34 });
35 total--;
36 }
37 }
38
39 $('.sc_shortcode_name').append('<span class="sc_toggle"></span>');
40
41 $( document ).on( 'click', '.sc_insert', function(){
42
43 var params = '';
44 var scname = $(this).closest( '.sc_shortcode' ).attr( 'data-name' );
45 var sc = '';
46
47 $(this).parent().children().find('input[type="text"]').each(function(){
48 if($(this).val() != ''){
49 attr = $(this).attr('data-param');
50 val = $(this).val().replace( /\"/g, '' );
51 params += attr + '="' + val + '" ';
52 }
53 });
54
55 sc = '[sc name="' + scname + '" ' + params + ']';
56 send_editor( sc );
57 close_window();
58
59 });
60
61 $( document ).on( 'click', '.sc_quick_insert', function(){
62
63 var scname = $(this).closest( '.sc_shortcode' ).attr( 'data-name' );
64 var sc = '[sc name="' + scname + '"]';
65
66 send_editor( sc );
67 close_window();
68
69 });
70
71 $( document ).on( 'click', '.sc_shortcode_name', function(e){
72 $('.sc_params').slideUp();
73 if($(this).next('.sc_params').is(':visible')){
74 $(this).next('.sc_params').slideUp();
75 }else{
76 $(this).next('.sc_params').slideDown();
77 }
78 });
79
80 $( document ).on( 'change', '.coffee_amt', function(){
81 var btn = $( '.buy_coffee_btn' );
82 btn.attr( 'href', btn.data( 'link' ) + $(this).val() );
83 });
84
85 $( document ).on( 'click', '.sort_btn', function(){
86 last_sort = ( last_sort == 'asc' ) ? 'desc' : 'asc';
87 sort( $( '.sc_shortcode' ), last_sort );
88 });
89
90 $( document ).on( 'keyup', '.search_box', function(){
91 var re = new RegExp($(this).val(), 'g');
92 $('.sc_wrap .sc_shortcode').each(function(){
93 var name = $(this).attr('data-name');
94 if( name.match(re) === null ){
95 $(this).hide();
96 }else{
97 $(this).show();
98 }
99 });
100
101 var visible = $('.sc_wrap .sc_shortcode:visible').length;
102 var $no_scs_msg = $('.sc_wrap').find('p');
103 if( visible == 0 ){
104 if( $no_scs_msg.length == 0 ){
105 $('.sc_wrap').append( '<p align="center"><i>No shortcodes match search term !</i></p>' );
106 }
107 }else{
108 $no_scs_msg.remove();
109 }
110 });
111
112 });
113
114 })( jQuery );