PluginProbe
FV Player 8 / trunk
FV Player 8 vtrunk
trunk 8.0.18 8.0.19 8.0.20 8.0.21 8.0.25 8.0.27 8.1 8.1.3
fv-player / js / editor-extras.js

editor-extras.js in FV Player 8 trunk, at js/editor-extras.js

118 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* eslint-disable no-unused-vars */
2 /*global fv_player_editor_matcher */
3
4 // What's here needs to stay global
5
6 // used in FV Player Pro to add more matchers
7 if (typeof(window.fv_player_editor_matcher) == 'undefined') {
8 window.fv_player_editor_matcher = {};
9 }
10
11 fv_player_editor_matcher.default = {
12 // matches URL of the video
13 matcher: /\.(mp4|webm|m3u8)(?:(?:\?.*?|\#.*?)?)?$/i,
14 // AJAX will return these fields which can be auto-updated via JS
15 update_fields: ['duration', 'last_video_meta_check'],
16 support_thumb_generate: true
17 }
18
19 function fv_wp_flowplayer_dialog_resize() {
20 fv_player_editor.fv_wp_flowplayer_dialog_resize();
21 }
22
23 function fv_flowplayer_insertUpdateOrDeletePlayerMeta( options ) {
24 fv_player_editor.insertUpdateOrDeletePlayerMeta( options );
25 }
26
27 function fv_flowplayer_insertUpdateOrDeleteVideoMeta( options ) {
28 fv_player_editor.insertUpdateOrDeleteVideoMeta( options );
29 }
30
31 function fv_wp_flowplayer_shortcode_parse_arg( sShortcode, sArg, bHTML, sCallback ) {
32 return fv_player_editor.shortcode_parse_arg( sShortcode, sArg, bHTML, sCallback );
33 }
34
35 // TODO: This is used in editor-screenshots.js and FV Player Pay Per View!
36 function fv_wp_flowplayer_submit( preview ) {
37
38 }
39
40 jQuery(document).on('fv_flowplayer_shortcode_insert', function(e) {
41 jQuery(e.target).siblings('.button.fv-wordpress-flowplayer-button').val('Edit');
42 });
43
44 /*
45 * Player edit lock
46 */
47 if( typeof(fv_player_editor_conf) != "undefined" ) {
48 // extending DB player edit lock's timer
49 jQuery( document ).on( 'heartbeat-send', function ( event, data ) {
50 // FV Player might not be loaded, like in case of Elementor
51 if( !window.fv_player_editor ) return;
52
53 if( fv_player_editor.get_current_player_db_id() > -1 ) {
54 data.fv_flowplayer_edit_lock_id = fv_player_editor.get_current_player_db_id();
55 }
56
57 var
58 removals = fv_player_editor.get_edit_lock_removal(),
59 removalsEmpty = true;
60
61 for (var i in removals) {
62 removalsEmpty = false;
63 break;
64 }
65
66 if( !removalsEmpty ) {
67 data.fv_flowplayer_edit_lock_removal = fv_player_editor.get_edit_lock_removal();
68 } else {
69 delete(data.fv_flowplayer_edit_lock_removal);
70 }
71 });
72
73 // remove edit locks in the config if it was removed on the server
74 jQuery( document ).on( 'heartbeat-tick', function ( event, data ) {
75 if ( data.fv_flowplayer_edit_locks_removed ) {
76 var
77 edit_lock_removal = fv_player_editor.get_edit_lock_removal(),
78 new_edit_lock_removal = {};
79
80 // remove only edit locks that were removed server-side
81 for (var i in edit_lock_removal) {
82 if (!data.fv_flowplayer_edit_locks_removed[i]) {
83 new_edit_lock_removal[i] = edit_lock_removal[i];
84 }
85 }
86
87 fv_player_editor.set_edit_lock_removal(new_edit_lock_removal);
88 }
89 });
90 }
91
92 /**
93 * LMS | Teaching saving into Player meta
94 */
95 (function ($) {
96 $( document ).on( 'fv_flowplayer_player_meta_save', function( event, data ) {
97 fv_flowplayer_insertUpdateOrDeletePlayerMeta( {
98 data: data,
99 meta_key: 'lms_teaching',
100 element: $( '[name=fv_wp_flowplayer_field_lms_teaching]' )[0],
101 } );
102
103 });
104
105 $( document ).on( 'fv_flowplayer_player_meta_load', function( event, data ) {
106 if ( data.meta ) {
107 for ( let i in data.meta ) {
108 if ( 'lms_teaching' == data.meta[i].meta_key ) {
109 $( '[name=fv_wp_flowplayer_field_lms_teaching]' )
110 .prop( 'checked', data.meta[i].meta_value )
111 .attr( 'data-id', data.meta[i].id )
112 .trigger( 'change' );
113 }
114 }
115 }
116 } );
117
118 }(jQuery));