1 | jQuery(document).ready(function() {
|
---|
2 | jQuery("#suggestedtags h3.hndle span").html( html_entity_decode(stHelperSuggestedTagsL10n.title_bloc) );
|
---|
3 | jQuery("#suggestedtags .inside .container_clicktags").html( stHelperSuggestedTagsL10n.content_bloc );
|
---|
4 |
|
---|
5 | // Yahoo API
|
---|
6 | jQuery("a.yahoo_api").click(function() {
|
---|
7 | jQuery('#st_ajax_loading').show();
|
---|
8 | jQuery("#suggestedtags .container_clicktags").load( stHelperSuggestedTagsL10n.site_url + '/wp-admin/admin.php?st_ajax_action=tags_from_yahoo', {content:getContentFromEditor(),title:jQuery("#title").val(),tags:jQuery("#tags-input").val()}, function(){
|
---|
9 | registerClickTags();
|
---|
10 | });
|
---|
11 | return false;
|
---|
12 | });
|
---|
13 |
|
---|
14 | // Tag The Net API
|
---|
15 | jQuery("a.ttn_api").click(function() {
|
---|
16 | jQuery('#st_ajax_loading').show();
|
---|
17 | jQuery("#suggestedtags .container_clicktags").load( stHelperSuggestedTagsL10n.site_url + '/wp-admin/admin.php?st_ajax_action=tags_from_tagthenet', {content:getContentFromEditor(),title:jQuery("#title").val()}, function(){
|
---|
18 | registerClickTags();
|
---|
19 | });
|
---|
20 | return false;
|
---|
21 | });
|
---|
22 |
|
---|
23 | // Local Tags Database
|
---|
24 | jQuery("a.local_db").click(function() {
|
---|
25 | jQuery('#st_ajax_loading').show();
|
---|
26 | jQuery("#suggestedtags .container_clicktags").load( stHelperSuggestedTagsL10n.site_url + '/wp-admin/admin.php?st_ajax_action=tags_from_local_db', {content:getContentFromEditor(),title:jQuery("#title").val()}, function(){
|
---|
27 | registerClickTags();
|
---|
28 | });
|
---|
29 | return false;
|
---|
30 | });
|
---|
31 | });
|
---|
32 |
|
---|
33 | function getContentFromEditor() {
|
---|
34 | var data = '';
|
---|
35 | if ( (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden() ) { // Tiny MCE
|
---|
36 |
|
---|
37 | var ed = tinyMCE.activeEditor;
|
---|
38 | if ( 'mce_fullscreen' == ed.id ) {
|
---|
39 | tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
|
---|
40 | }
|
---|
41 | tinyMCE.get('content').save();
|
---|
42 | data = jQuery("#content").val();
|
---|
43 |
|
---|
44 | } else if ( typeof FCKeditorAPI != "undefined" ) { // FCK Editor
|
---|
45 |
|
---|
46 | var oEditor = FCKeditorAPI.GetInstance('content') ;
|
---|
47 | data = oEditor.GetHTML().stripTags();
|
---|
48 |
|
---|
49 | } else if ( typeof WYM_INSTANCES != "undefined" ) { // Simple WYMeditor
|
---|
50 |
|
---|
51 | data = WYM_INSTANCES[0].xhtml();
|
---|
52 |
|
---|
53 | } else { // No editor, just quick tags
|
---|
54 |
|
---|
55 | data = jQuery("#content").val();
|
---|
56 |
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Trim data
|
---|
60 | data = data.replace( /^\s+/, '' ).replace( /\s+$/, '' );
|
---|
61 | if ( data != '' ) {
|
---|
62 | data = strip_tags(data);
|
---|
63 | }
|
---|
64 |
|
---|
65 | return data;
|
---|
66 | }
|
---|
67 |
|
---|
68 | function registerClickTags() {
|
---|
69 | jQuery("#suggestedtags .container_clicktags span").click(function() {
|
---|
70 | addTag(this.innerHTML);
|
---|
71 | });
|
---|
72 |
|
---|
73 | jQuery('#st_ajax_loading').hide();
|
---|
74 | if ( jQuery('#suggestedtags .inside').css('display') != 'block' ) {
|
---|
75 | jQuery('#suggestedtags').toggleClass('closed');
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | function html_entity_decode(str) {
|
---|
80 | var ta = document.createElement("textarea");
|
---|
81 | ta.innerHTML = str.replace(/</g,"<").replace(/>/g,">");
|
---|
82 | toReturn = ta.value;
|
---|
83 | ta = null;
|
---|
84 | return toReturn
|
---|
85 | }
|
---|
86 |
|
---|
87 | function strip_tags(str) {
|
---|
88 | return str.replace(/<\/?[^>]+>/gi, "");
|
---|
89 | } |
---|