-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpress-this-reloaded.js
101 lines (87 loc) · 2.81 KB
/
press-this-reloaded.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var photostorage = false;
var wpActiveEditor = 'content';
function insert_plain_editor(text) {
if ( typeof(QTags) != 'undefined' )
QTags.insertContent(text);
}
function set_editor(text) {
if ( '' == text || '<p></p>' == text )
text = '<p><br /></p>';
if ( tinyMCE.activeEditor )
tinyMCE.execCommand('mceSetContent', false, text);
}
function insert_editor(text) {
if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
} else {
insert_plain_editor(decodeURI(text));
}
}
function append_editor(text) {
if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
} else {
insert_plain_editor(text);
}
}
function show(tab_name) {
jQuery('#extra-fields').html('');
switch(tab_name) {
case 'video' :
jQuery('#extra-fields').load(PTReloaded.pressThisUrl, { ajax: 'video', s: PTReloaded.content}, function() {
jQuery('#embed-code').prepend(PTReloaded.content);
});
jQuery('#extra-fields').show();
return false;
break;
case 'photo' :
function setup_photo_actions() {
jQuery('.close').click(function() {
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
});
jQuery('.refresh').click(function() {
photostorage = false;
show('photo');
});
jQuery('#waiting').hide();
jQuery('#extra-fields').show();
}
jQuery('#waiting').show();
if(photostorage == false) {
jQuery.ajax({
type: "GET",
cache : false,
url: PTReloaded.pressThisUrl,
data: "ajax=photo_js&u="+PTReloaded.urlEncoded,
dataType : "script",
success : function(data) {
eval(data);
photostorage = jQuery('#extra-fields').html();
setup_photo_actions();
}
});
} else {
jQuery('#extra-fields').html(photostorage);
setup_photo_actions();
}
return false;
break;
}
}
jQuery(document).ready(function($) {
//$('#extra-fields').remove();
$('#extra-fields').prependTo('#wp-content-wrap');
//resize screen
//window.resizeTo(740,580);
// set button actions
$('#photo_button').click(function() { show('photo'); return false; });
$('#video_button').click(function() { show('video'); return false; });
// auto select
show(PTReloaded.type);
jQuery('#title').unbind();
jQuery('#publish, #save').click(function() { jQuery('.press-this #publishing-actions .spinner').css('display', 'inline-block'); });
$('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
$(this).siblings('.inside').toggle();
});
});