-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodal.js
More file actions
96 lines (73 loc) · 2.08 KB
/
Copy pathmodal.js
File metadata and controls
96 lines (73 loc) · 2.08 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var ray = ray || {};
/**
* JS functionality to handle our custom "Add External Media" button.
*
* Slightly-altered JS from ocean90's Media Modal Demo plugin.
*
* @link https://github.com/ocean90/media-modal-demo
*/
( function( $ ) {
var media;
ray.media = media = {};
_.extend( media, { view: {}, controller: {} } );
media.buttonId = '#add-external-media',
_.extend( media, {
frame: function() {
if ( this._frame ) {
return this._frame;
}
this._frame = wp.media( {
className: 'media-frame mode-select',
frame: 'post',
// Default tab to select when modal is loaded.
// @todo This should probably be configurable...
state: window.mexp && mexp.services && mexp.services.vimeo ? 'mexp-service-vimeo' : 'shortcode-ui',
// Disables plupload dropzone; plugins will be handling this by themselves.
uploader: false
} );
this._frame.on( 'open', this.open );
this._frame.on( 'ready', this.ready );
this._frame.on( 'close', this.close );
this._frame.on( 'menu:render:default', this.menuRender );
return this._frame;
},
open: function() {
$( '.media-modal' ).addClass( 'smaller' );
$( '.media-modal .media-menu .separator' ).hide();
},
ready: function() {
//console.log( 'Frame ready' );
},
close: function() {
$( '.media-modal' ).removeClass( 'smaller' );
},
/**
* Get rid of some menu items we don't need.
*
* @todo Make this more intelligent instead of manually removing items.
*/
menuRender: function( view ) {
// 'Insert from link'
view.unset( 'embed' );
// Playlists
view.unset( 'playlist' );
view.unset( 'video-playlist' );
// Misc
view.unset( 'insert' );
view.unset( 'featured-image' );
view.unset( 'library-separator' );
view.unset( 'gallery' );
// 3rd-party
//view.unset( 'mexp-service-twitter' );
//view.unset( 'mexp-service-youtube' );
view.unset( 'mexp-service-instagram' );
},
init: function() {
$( media.buttonId ).on( 'click', function( e ) {
e.preventDefault();
media.frame().open();
});
}
} );
$( media.init );
} )( jQuery );