forked from scribu/wp-press-this-reloaded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpress-this-reloaded.js
137 lines (108 loc) · 3.39 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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('');
hideToolbar( true );
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').fadeIn();
return false;
break;
case 'photo' :
function setup_photo_actions() {
jQuery('.close').click(function() {
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
hideToolbar( false );
});
jQuery('.refresh').click(function() {
photostorage = false;
show('photo');
});
jQuery('#waiting').hide();
if ( hasImages )
jQuery('#extra-fields').fadeIn();
else if ( firstTime ){
hideToolbar( false );
firstTime = false;
}
//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;
}
}
function hideToolbar( value ){
if ( value )
jQuery('#wp-content-media-buttons').fadeOut('fast');
else
jQuery('#wp-content-media-buttons').fadeIn('fast');
}
jQuery(document).ready(function($) {
firstTime = true;
//$('#extra-fields').remove();
$('#extra-fields').prependTo('#wp-content-wrap');
$('#waiting').prependTo('#wp-content-wrap');
//resize screen
//window.resizeTo(740,580);
// set button actions
$('#photo_button').click(function() {
show('photo');
jQuery('#extra-fields').fadeIn();
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();
});
//By default lets read the images
show('photo');
});