| @@ -6,12 +6,12 @@ | ||
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | generate_download_link(); |
| 9 | 9 | generate_delete_link(); |
| 10 | - wpstream_handle_video_selection(); | |
| 10 | + social_media_toggle('wpstream_on_facebook'); | |
| 11 | + social_media_toggle('wpstream_on_youtube'); | |
| 12 | + social_media_toggle('wpstream_on_twich'); | |
| 11 | 13 | |
| 12 | - | |
| 13 | - | |
| 14 | 14 | |
| 15 | 15 | function social_media_toggle(social_class){ |
| 16 | 16 | |
| 17 | 17 | jQuery('.'+social_class).on('change',function(){ |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - jQuery('.wpstream_notices .notice-dismiss').on('click',function(){ | |
| 30 | + jQuery('.wpestate_notices .notice-dismiss').on('click',function(){ | |
| 31 | 31 | |
| 32 | 32 | var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 33 | 33 | var notice_type = $(this).parent().attr('data-notice-type'); |
| 34 | 34 | var nonce = $('#wpstream_notice_nonce').val(); |
| @@ -67,9 +67,9 @@ | ||
| 67 | 67 | |
| 68 | 68 | jQuery.ajax({ |
| 69 | 69 | type: 'POST', |
| 70 | 70 | url: ajaxurl, |
| 71 | - dataType: 'json', | |
| 71 | + | |
| 72 | 72 | data: { |
| 73 | 73 | 'action' : 'wpstream_get_delete_file', |
| 74 | 74 | 'video_name' : video_name |
| 75 | 75 | |
| @@ -74,12 +74,9 @@ | ||
| 74 | 74 | 'video_name' : video_name |
| 75 | 75 | |
| 76 | 76 | }, |
| 77 | 77 | success: function (data) { |
| 78 | - | |
| 79 | - if(data.success===true){ | |
| 80 | - parent.remove(); | |
| 81 | - } | |
| 78 | + parent.remove(); | |
| 82 | 79 | |
| 83 | 80 | |
| 84 | 81 | }, |
| 85 | 82 | error: function (errorThrown) { |
| @@ -105,9 +102,9 @@ | ||
| 105 | 102 | |
| 106 | 103 | jQuery.ajax({ |
| 107 | 104 | type: 'POST', |
| 108 | 105 | url: ajaxurl, |
| 109 | - dataType: 'json', | |
| 106 | + | |
| 110 | 107 | data: { |
| 111 | 108 | 'action' : 'wpstream_get_download_link', |
| 112 | 109 | 'video_name' : video_name, |
| 113 | 110 | |
| @@ -112,26 +109,16 @@ | ||
| 112 | 109 | 'video_name' : video_name, |
| 113 | 110 | |
| 114 | 111 | }, |
| 115 | 112 | success: function (data) { |
| 116 | - | |
| 117 | - | |
| 118 | - | |
| 119 | - if(data.success===true){ | |
| 113 | + | |
| 114 | + if(String(data)==='toolarge'){ | |
| 115 | + parent.find('.wpstream_download_link').show().text(wpstream_admin_control_vars.no_band); | |
| 116 | + }else{ | |
| 120 | 117 | parent.find('.wpstream_download_link').show().text(wpstream_admin_control_vars.download_mess); |
| 121 | - parent.find('.wpstream_download_link').show().attr('href',data.url); | |
| 122 | - }else{ | |
| 123 | - var error_message=data.error; | |
| 124 | - | |
| 125 | - if(data.error==='NOT_ENOUGH_TRAFFIC'){ | |
| 126 | - error_message = 'Not Enough data to download!'; | |
| 127 | - | |
| 128 | - } | |
| 129 | - | |
| 130 | - parent.find('.wpstream_download_link').show().text(error_message); | |
| 118 | + parent.find('.wpstream_download_link').show().attr('href',data); | |
| 119 | + | |
| 131 | 120 | } |
| 132 | - | |
| 133 | - | |
| 134 | 121 | |
| 135 | 122 | }, |
| 136 | 123 | error: function (errorThrown) { |
| 137 | 124 | } |
| @@ -169,17 +156,8 @@ | ||
| 169 | 156 | .on( 'focus', function(){ $input.addClass( 'has-focus' ); }) |
| 170 | 157 | .on( 'blur', function(){ $input.removeClass( 'has-focus' ); }); |
| 171 | 158 | }); |
| 172 | 159 | |
| 173 | - | |
| 174 | - | |
| 175 | - /* | |
| 176 | - * | |
| 177 | - * File Upload | |
| 178 | - * | |
| 179 | - */ | |
| 180 | - | |
| 181 | - | |
| 182 | 160 | var form = $('.direct-upload'); |
| 183 | 161 | var filesUploaded = []; |
| 184 | 162 | var folders = []; |
| 185 | 163 | |
| @@ -185,16 +163,14 @@ | ||
| 185 | 163 | |
| 186 | 164 | // var new_file_name=''; |
| 187 | 165 | |
| 188 | 166 | form.fileupload({ |
| 189 | - | |
| 190 | 167 | url: form.attr('action'), |
| 191 | 168 | type: form.attr('method'), |
| 192 | - | |
| 193 | 169 | datatype: 'xml', |
| 194 | 170 | add: function (event, data) { |
| 195 | 171 | |
| 196 | - | |
| 172 | + | |
| 197 | 173 | if( data.files[0].type!=='video/mp4' && data.files[0].type!=='video/quicktime'){ |
| 198 | 174 | jQuery('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.not_accepted); |
| 199 | 175 | return; |
| 200 | 176 | } |
| @@ -200,9 +176,9 @@ | ||
| 200 | 176 | } |
| 201 | 177 | |
| 202 | 178 | |
| 203 | 179 | |
| 204 | - var file_size = (parseInt(data.files[0].size,10))/1000000; | |
| 180 | + var file_size=(parseInt(data.files[0].size,10))/1000000; | |
| 205 | 181 | var user_storage = jQuery('#wpstream_storage').val(); |
| 206 | 182 | var user_band = jQuery('#wpstream_band').val(); |
| 207 | 183 | |
| 208 | 184 | |
| @@ -222,9 +198,9 @@ | ||
| 222 | 198 | }; |
| 223 | 199 | |
| 224 | 200 | var file = data.files[0]; |
| 225 | 201 | |
| 226 | - | |
| 202 | + //console.log('file'+JSON.stringify(file)); | |
| 227 | 203 | form.find('input[name="Content-Type"]').val(file.type); |
| 228 | 204 | form.find('input[name="Content-Length"]').val(file.size); |
| 229 | 205 | |
| 230 | 206 | // Actually submit to form to S3. |
| @@ -243,26 +219,12 @@ | ||
| 243 | 219 | $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', percent + '%').html(percent+'%'); |
| 244 | 220 | }, |
| 245 | 221 | |
| 246 | 222 | fail: function (e, data) { |
| 247 | - | |
| 248 | 223 | // Remove the 'unsaved changes' message. |
| 249 | 224 | window.onbeforeunload = null; |
| 250 | 225 | $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', '100%').addClass('red').html(''); |
| 251 | - $('.bar').remove(); | |
| 252 | - $('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_failed); | |
| 253 | - $('#wpstream_label_action').empty().html(wpstream_admin_control_vars.upload_failed2); | |
| 254 | 226 | }, |
| 255 | - | |
| 256 | - error: function (e, data) { | |
| 257 | - | |
| 258 | - // Remove the 'unsaved changes' message. | |
| 259 | - window.onbeforeunload = null; | |
| 260 | - $('.progress[data-mod="'+data.files[0].size+'"] .bar').css('width', '100%').addClass('red').html(''); | |
| 261 | - $('.bar').remove(); | |
| 262 | - $('#wpstream_uploaded_mes').empty().html(wpstream_admin_control_vars.upload_failed); | |
| 263 | - $('#wpstream_label_action').empty().html(wpstream_admin_control_vars.upload_failed2); | |
| 264 | - }, | |
| 265 | 227 | done: function (event, data) { |
| 266 | 228 | |
| 267 | 229 | window.onbeforeunload = null; |
| 268 | 230 | $('.bar').remove(); |
| @@ -271,12 +233,12 @@ | ||
| 271 | 233 | |
| 272 | 234 | var new_file_name=data.files[0].name; |
| 273 | 235 | |
| 274 | 236 | |
| 275 | - var new_file_name_array = data.files[0].name.split("."); | |
| 276 | - var temp_file_name = new_file_name_array[0].split(' ').join('_'); | |
| 277 | - temp_file_name = temp_file_name.replace(/\W/g, ''); | |
| 278 | - new_file_name = temp_file_name+'.'+new_file_name_array[new_file_name_array.length-1]; | |
| 237 | + var new_file_name_array= data.files[0].name.split("."); | |
| 238 | + var temp_file_name= new_file_name_array[0].split(' ').join('_'); | |
| 239 | + temp_file_name= temp_file_name.replace(/\W/g, ''); | |
| 240 | + new_file_name=temp_file_name+'.'+new_file_name_array[new_file_name_array.length-1]; | |
| 279 | 241 | |
| 280 | 242 | |
| 281 | 243 | |
| 282 | 244 | |
| @@ -286,14 +248,12 @@ | ||
| 286 | 248 | to_insert=to_insert+'<strong class="storage_file_name">File Name :</strong><span class="storage_file_name_real">'+new_file_name+' </span></div>'; |
| 287 | 249 | to_insert=to_insert+'<div class="wpstream_delete_media" '; |
| 288 | 250 | to_insert=to_insert+' onclick=" return confirm('+onclick_string+') "'; |
| 289 | 251 | to_insert=to_insert+' data-filename="'+new_file_name+'" >delete file</div>'; |
| 290 | - to_insert=to_insert+'<div class="wpstream_get_download_link" data-filename="'+new_file_name+'">download</div> '; | |
| 252 | + to_insert=to_insert+'<div class="wpstream_get_download_link" data-filename="'+new_file_name+'">get download link</div> '; | |
| 291 | 253 | to_insert=to_insert+'<a href="" class="wpstream_download_link">Click to download! The url will work for the next 20 minutes!</a></div>'; |
| 292 | 254 | |
| 293 | 255 | $('#video_management_title').after(to_insert); |
| 294 | - | |
| 295 | - | |
| 296 | 256 | |
| 297 | 257 | $('.wpstream_get_download_link').unbind('click'); |
| 298 | 258 | $('.wpstream_delete_media').unbind('click'); |
| 299 | 259 | |
| @@ -298,10 +258,8 @@ | ||
| 298 | 258 | $('.wpstream_delete_media').unbind('click'); |
| 299 | 259 | |
| 300 | 260 | generate_download_link(); |
| 301 | 261 | generate_delete_link(); |
| 302 | - | |
| 303 | - setTimeout(function(){ window.location.href = window.location.href; }, 1000); | |
| 304 | 262 | |
| 305 | 263 | |
| 306 | 264 | } |
| 307 | 265 | }); |
| @@ -315,9 +273,9 @@ | ||
| 315 | 273 | |
| 316 | 274 | jQuery('#product-type').on('change',function(){ |
| 317 | 275 | |
| 318 | 276 | var product_type= jQuery('#product-type').val(); |
| 319 | - if(product_type==='live_stream' || product_type==='video_on_demand' || product_type==='wpstream_bundle' ){ | |
| 277 | + if(product_type==='live_stream' || product_type==='video_on_demand'){ | |
| 320 | 278 | jQuery('._sold_individually_field').show(); |
| 321 | 279 | } |
| 322 | 280 | |
| 323 | 281 | }); |
| @@ -330,21 +288,16 @@ | ||
| 330 | 288 | jQuery('#product-type').val('live_stream').trigger('change'); |
| 331 | 289 | } |
| 332 | 290 | |
| 333 | 291 | var product_type= jQuery('#product-type').val(); |
| 334 | - console.log('xxx '+product_type); | |
| 292 | + | |
| 335 | 293 | if ( product_type === 'video_on_demand' ) { |
| 336 | - jQuery('.show_if_video_on_demand' ).show(); | |
| 337 | - }else if ( product_type === 'live_stream' ) { | |
| 338 | - jQuery( '.show_if_live_stream' ).show(); | |
| 339 | - } else if ( product_type === 'wpstream_bundle' ) { | |
| 340 | - jQuery( '.show_if_wpstream_bundle' ).show(); | |
| 341 | - console.log ('we do click'); | |
| 342 | - var element= jQuery('.general_tab'); | |
| 343 | - console.log(element); | |
| 344 | - jQuery('.general_tab').trigger('click'); | |
| 345 | - $('a[href="#general_product_data"]').click(); | |
| 346 | - $('.product_data_tabs .tab.general_tab').click(); | |
| 294 | + jQuery('.show_if_video_on_demand' ).show(); | |
| 295 | + | |
| 296 | + } | |
| 297 | + else if ( product_type === 'live_stream' ) { | |
| 298 | + $( '.show_if_live_stream' ).show(); | |
| 299 | + | |
| 347 | 300 | } |
| 348 | 301 | |
| 349 | 302 | |
| 350 | 303 | |
| @@ -365,9 +318,9 @@ | ||
| 365 | 318 | |
| 366 | 319 | |
| 367 | 320 | jQuery('#_subscript_live_event').change(function(){ |
| 368 | 321 | //alert('move it'+product_type); |
| 369 | - if ( product_type === 'video_on_demand' || product_type === 'live_stream' || product_type === 'wpstream_bundle' ) { | |
| 322 | + if ( product_type === 'video_on_demand' || product_type === 'live_stream' ) { | |
| 370 | 323 | |
| 371 | 324 | }else{ |
| 372 | 325 | var value= jQuery(this).val(); |
| 373 | 326 | if(value==="no"){ |
| @@ -381,29 +334,38 @@ | ||
| 381 | 334 | jQuery('#_subscript_live_event').trigger('change'); |
| 382 | 335 | |
| 383 | 336 | |
| 384 | 337 | $('#wpstream_product_type').change(function(){ |
| 385 | - jQuery('.video_free').hide(); | |
| 386 | - jQuery('.video_free_external').hide(); | |
| 387 | - | |
| 388 | - jQuery('.wpstream_option_vod_source').hide(); | |
| 338 | + $('.video_free').hide(); | |
| 339 | + $('.video_free_external').hide(); | |
| 389 | 340 | |
| 390 | - if( jQuery('#wpstream_product_type').val()=== "2"){ | |
| 391 | - jQuery('.video_free').show(); | |
| 392 | - jQuery('.wpstream_show_recording').show(); | |
| 341 | + if( $('#wpstream_product_type').val()=== "2"){ | |
| 342 | + $('.video_free').show(); | |
| 393 | 343 | } |
| 394 | - if( jQuery('#wpstream_product_type').val()=== "3"){ | |
| 395 | - jQuery('.video_free_external').show(); | |
| 396 | - jQuery('.wpstream_show_external').show(); | |
| 344 | + if( $('#wpstream_product_type').val()=== "3"){ | |
| 345 | + $('.video_free_external').show(); | |
| 397 | 346 | } |
| 398 | 347 | }); |
| 399 | 348 | $('#wpstream_product_type').trigger('change'); |
| 400 | 349 | |
| 350 | + | |
| 401 | 351 | |
| 402 | - | |
| 403 | - | |
| 404 | - | |
| 405 | - | |
| 352 | + $('#wpstream_free_video_external_button').on( 'click', function(event) { | |
| 353 | + var formfield = $('#wpstream_free_video_external').attr('name'); | |
| 354 | + tb_show('', 'media-upload.php?type=image&TB_iframe=true'); | |
| 355 | + window.send_to_editor = function (html) { | |
| 356 | + var pathArray = html.match(/<media>(.*)<\/media>/); | |
| 357 | + var mediaUrl = pathArray != null && typeof pathArray[1] != 'undefined' ? pathArray[1] : ''; | |
| 358 | + | |
| 359 | + if(mediaUrl===''){ | |
| 360 | + mediaUrl = jQuery(html).attr("href"); | |
| 361 | + } | |
| 362 | + jQuery('#wpstream_free_video_external').val(mediaUrl); | |
| 363 | + tb_remove(); | |
| 364 | + }; | |
| 365 | + return false; | |
| 366 | + }); | |
| 367 | + | |
| 406 | 368 | $('.close_event').click(function(event){ |
| 407 | 369 | event.preventDefault(); |
| 408 | 370 | var ajaxurl = wpstream_admin_control_vars.admin_url + 'admin-ajax.php'; |
| 409 | 371 | var acesta = $(this); |
| @@ -455,46 +417,7 @@ | ||
| 455 | 417 | }); |
| 456 | 418 | |
| 457 | 419 | |
| 458 | 420 | }); |
| 459 | - | |
| 460 | 421 | |
| 461 | -/* | |
| 462 | -* handle video selection for recording | |
| 463 | -* | |
| 464 | -*/ | |
| 465 | - | |
| 466 | -function wpstream_handle_video_selection(){ | |
| 467 | - | |
| 468 | - jQuery('#wpstream_free_video_external_button').on( 'click', function(event) { | |
| 469 | - var parent=jQuery(this).parent(); | |
| 470 | - wpstream_admin_return_uploaded_image().then(function(image) { | |
| 471 | - parent.find('#wpstream_free_video_external').val(image.url); | |
| 472 | - }); | |
| 473 | - }); | |
| 474 | -} | |
| 475 | - | |
| 476 | - | |
| 477 | - | |
| 478 | -/* | |
| 479 | -* return uploaded image | |
| 480 | -* | |
| 481 | -*/ | |
| 482 | -function wpstream_admin_return_uploaded_image(){ | |
| 483 | - | |
| 484 | - | |
| 485 | - return new Promise(function(resolve, reject) { | |
| 486 | - var mediaUploader = wp.media({ | |
| 487 | - frame: "post", | |
| 488 | - state: "insert", | |
| 489 | - multiple: false | |
| 490 | - }); | |
| 491 | - | |
| 492 | - mediaUploader.on("insert", function(){ | |
| 493 | - var image = mediaUploader.state().get("selection").first().toJSON(); | |
| 494 | - resolve(image); | |
| 495 | - }); | |
| 496 | - | |
| 497 | - mediaUploader.open(); | |
| 498 | - }); | |
| 499 | -} | |
| 422 | + | |
| 500 | 423 | |