forked from alohaeditor/Aloha-Editor
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgpickerdialog.js
More file actions
72 lines (66 loc) · 3.9 KB
/
gpickerdialog.js
File metadata and controls
72 lines (66 loc) · 3.9 KB
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
// Google Picker for uploading images
function newImagePicker() {
google.load('picker', '1', {"callback" : createImagePicker});
}
// Create and render a Picker object for selecting documents
function createImagePicker() {
var picker = new google.picker.PickerBuilder().
addView(new google.picker.ImageSearchView().
setLicense(google.picker.ImageSearchView.License.REUSE)
).
addView(google.picker.ViewId.PHOTO_UPLOAD).
/*
addViewGroup(
new google.picker.ViewGroup(google.picker.ViewId.PHOTOS).
addView(new google.picker.PhotosView().
setType(google.picker.PhotosView.Type.UPLOADED)).
addView(new google.picker.PhotosView().
setType(google.picker.PhotosView.Type.FEATURED))).
*/
addView(google.picker.ViewId.PHOTOS).
addView(new google.picker.WebCamView(google.picker.WebCamViewType.STANDARD)).
setCallback(ImagePickerCallback).
build();
picker.setVisible(true);
}
// A simple callback implementation for Picker.
function ImagePickerCallback(data) {
if(data.action == google.picker.Action.PICKED){
var doc = data[google.picker.Response.DOCUMENTS][0];
site_url = doc[google.picker.Document.URL]; // only shows website url :(
image_url = data.docs[0].thumbnails[data.docs[0].thumbnails.length - 1].url;
var img = Aloha.jQuery("<img />").attr("src", image_url);
AlohaInsertIntoDom(img);
}
}
// Google Picker for uploading videos
function newVideoPicker() {
google.load('picker', '1', {"callback" : createVideoPicker});
}
function createVideoPicker() {
var picker = new google.picker.PickerBuilder().
addView(new google.picker.VideoSearchView().
setSite(google.picker.VideoSearchView.YOUTUBE)).
addView(google.picker.ViewId.YOUTUBE).
addView(new google.picker.WebCamView()).
setCallback(VideoPickerCallback).
build();
picker.setVisible(true);
}
// A simple callback implementation for Picker.
function VideoPickerCallback(data) {
if(data.action == google.picker.Action.PICKED){
console.log(data);
var doc = data[google.picker.Response.DOCUMENTS][0];
site_url = doc[google.picker.Document.URL]; // only shows website url :(
// image_url = data.docs[0].thumbnails[data.docs[0].thumbnails.length - 1].url; // we only get a image preview with this
embed_url = doc[google.picker.Document.EMBEDDABLE_URL];
video_id = doc[google.picker.Document.ID];
// var embed_code_template = Aloha.jQuery('<object width="420" height="236"><param name="movie" value="http://www.youtube.com/v/Rj8JoAAytyg?version=3&hl=de_DE"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" frameborder="0"></embed></object>');
var embed_code_template = Aloha.jQuery('<div class="multimedia-video"><iframe style="width:420px; height:360px" width="640" height="360" src="" frameborder="0"></iframe></div>');
// var embed_code_template = Aloha.jQuery('<object width="420" height="360"><param name="movie" value="http://www.youtube.com/v/Rj8JoAAytyg?version=3&hl=de_DE"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><iframe src="" type="application/x-shockwave-flash" width="560" height="360" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" frameborder="0"></iframe></object>');
//TODO Replace this to ensure only the specific video is changed
var embed_code = Aloha.jQuery(embed_code_template).find('iframe').attr('src', "http://www.youtube.com/embed/"+video_id+"?wmode=transparent");
AlohaInsertIntoDom(embed_code);
}
}