1var galleryObj; 2var nextpage = 2; 3var upload_sync = false; 4var activity_id = - 1; 5var uploaderObj; 6var objUploadView; 7var rtmedia_load_template_flag = true; 8 9jQuery( function ( $ ) { 10 11 var o_is_album, o_is_edit_allowed; 12 if ( typeof ( is_album ) == "undefined" ) { 13 o_is_album = new Array( "" ); 14 } else { 15 o_is_album = is_album 16 } 17 if ( typeof ( is_edit_allowed ) == "undefined" ) { 18 o_is_edit_allowed = new Array( "" ) 19 } else { 20 o_is_edit_allowed = is_edit_allowed; 21 } 22 23 rtMedia = window.rtMedia || { }; 24 25 rtMedia = window.rtMedia || { }; 26 27 rtMedia.Context = Backbone.Model.extend( { 28 url: function () { 29 var url = rtmedia_media_slug + "/"; 30 31 if ( ! upload_sync && nextpage > 0 ) { 32 url += 'pg/' + nextpage + '/'; 33 } 34 35 return url; 36 }, 37 defaults: { 38 "context": "post", 39 "context_id": false 40 } 41 } ); 42 43 rtMedia.Media = Backbone.Model.extend( { 44 defaults: { 45 "id": 0, 46 "blog_id": false, 47 "media_id": false, 48 "media_author": false, 49 "media_title": false, 50 "album_id": false, 51 "media_type": "photo", 52 "activity_id": false, 53 "privacy": 0, 54 "views": 0, 55 "downloads": 0, 56 "ratings_average": 0, 57 "ratings_total": 0, 58 "ratings_count": 0, 59 "likes": 0, 60 "dislikes": 0, 61 "guid": false, 62 "width": 0, 63 "height": 0, 64 "rt_permalink": false, 65 "duration": "0:00" 66 // "next" : -1, 67 // "prev" : -1 68 } 69 70 } ); 71 72 rtMedia.Gallery = Backbone.Collection.extend( { 73 model: rtMedia.Media, 74 url: function () { 75 var temp = window.location.pathname; 76 var url = ''; 77 if ( temp.indexOf( "/" + rtmedia_media_slug + "/" ) == - 1 ) { 78 url = rtmedia_media_slug + '/'; 79 } else { 80 if ( temp.indexOf( 'pg/' ) == - 1 ) { 81 url = temp; 82 } else { 83 url = window.location.pathname.substr( 0, window.location.pathname.lastIndexOf( "pg/" ) ); 84 } 85 } 86 if ( ! upload_sync && nextpage > 1 ) { 87 if ( url.substr( url.length - 1 ) != "/" ) { 88 url += "/"; 89 } 90 91 url += 'pg/' + nextpage + '/'; 92 } 93 return url; 94 }, 95 getNext: function ( page, el, element ) { 96 if ( jQuery( '.rtmedia-no-media-found' ).length > 0 ) { 97 jQuery( '.rtmedia-no-media-found' ).replaceWith( "<ul class='rtmedia-list rtmedia-list-media'></ul>" ); 98 } 99 that = this; 100 if ( rtmedia_load_template_flag == true ) { 101 if ( jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=media_title]' ).length > 0 ) { 102 template_url += '&media_title=' + jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=media_title]' ).val(); 103 } 104 if ( jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).length > 0 ) { 105 template_url += '&lightbox=' + jQuery( '.rtmedia_gallery_wrapper' ).find( 'input[name=lightbox]' ).val(); 106 } 107 $( "#rtmedia-gallery-item-template" ).load( template_url, { backbone: true, is_album: o_is_album, is_edit_allowed: o_is_edit_allowed }, function () { 108 rtmedia_load_template_flag = false; 109 that.getNext( page, el, element ); 110 } ); 111 } 112 113 if ( ! rtmedia_load_template_flag ) { 114 var query = { 115 json: true, 116 rtmedia_page: nextpage 117 }; 118 if ( el == undefined ) { 119 el = jQuery( ".rtmedia-list" ).parent().parent(); 120 } 121 122 if ( el != undefined ) { 123 if ( element != undefined ) { 124 $( element ).parent().parent().prevAll( "input[type=hidden]" ).not( "input[name=_wp_http_referer], input[name=rtmedia_media_delete_nonce], input[name=rtmedia_bulk_delete_nonce], input[name=bulk-action], input[name=rtmedia_create_album_nonce], input[name=rtmedia_media_nonce], input[name=rtmedia_upload_nonce], input[name=rtmedia_allow_upload_attribute]" ).each( function ( e ) { 125 if ( $( this ).attr( "name" ) ) { 126 query[ $( this ).attr( "name" ) ] = $( this ).val(); 127 } 128 } ); 129 } 130 131 $( el ).find( "input[type=hidden]" ).not( "input[name=_wp_http_referer], input[name=rtmedia_media_delete_nonce], input[name=rtmedia_bulk_delete_nonce], input[name=bulk-action], input[name=rtmedia_create_album_nonce], input[name=rtmedia_media_nonce], input[name=rtmedia_upload_nonce], input[name=rtmedia_allow_upload_attribute]" ).each( function ( e ) { 132 if ( $( this ).attr( "name" ) ) { 133 query[ $( this ).attr( "name" ) ] = $( this ).val(); 134 } 135 } ); 136 } 137 138 this.fetch( { 139 data: query, 140 success: function ( model, response ) { 141 jQuery( '.rtm-media-loading' ).hide(); 142 var list_el = ""; 143 144 if ( typeof ( element ) === "undefined" ) { 145 list_el = $( ".rtmedia-list" )[0]; 146 } else { 147 list_el = element.parent().siblings( '.rtmedia-list' ); 148 } 149 150 nextpage = response.next; 151 152 if ( nextpage < 1 ) { 153 if ( typeof el == "object" ) { 154 jQuery( el ).find( '.rtmedia_next_prev' ).children( '#rtMedia-galary-next' ).hide(); 155 } 156 //$("#rtMedia-galary-next").show(); 157 } 158 159 var galleryViewObj = new rtMedia.GalleryView( { 160 collection: new rtMedia.Gallery( response.data ), 161 el: list_el 162 } ); 163 //element.show(); 164 jQuery( '.rtmedia-container .rtmedia-list' ).css( 'opacity', '1' ); 165 rtMediaHook.call( 'rtmedia_after_gallery_load' ); 166 167 jQuery( '.rtmedia-container .rtmedia_next_prev .rtm-pagination' ).remove(); 168 jQuery( '.rtmedia-container .rtmedia_next_prev .clear' ).remove(); 169 jQuery( '.rtmedia-container .rtmedia_next_prev .rtm-media-loading' ).remove(); 170 jQuery( '.rtmedia-container .rtmedia_next_prev br' ).remove(); 171 jQuery( '.rtmedia-container .rtmedia_next_prev' ).append( response.pagination ); 172 } 173 } ); 174 } 175 }, 176 reloadView: function () { 177 upload_sync = true; 178 nextpage = 1; 179 jQuery( '.rtmedia-container .rtmedia-list' ).css( 'opacity', '0.5' ); 180 this.getNext(); 181 } 182 } ); 183 184 rtMedia.MediaView = Backbone.View.extend( { 185 tagName: 'li', 186 className: 'rtmedia-list-item', 187 initialize: function () { 188 this.template = _.template( $( "#rtmedia-gallery-item-template" ).html() ); 189 this.model.bind( 'change', this.render ); 190 this.model.bind( 'remove', this.unrender ); 191 this.render(); 192 }, 193 render: function () { 194 $( this.el ).html( this.template( this.model.toJSON() ) ); 195 return this.el; 196 }, 197 unrender: function () { 198 $( this.el ).remove(); 199 }, 200 remove: function () { 201 this.model.destroy(); 202 } 203 } ); 204 205 rtMedia.GalleryView = Backbone.View.extend( { 206 tagName: 'ul', 207 className: 'rtmedia-list', 208 initialize: function () { 209 this.template = _.template( $( "#rtmedia-gallery-item-template" ).html() ); 210 this.render(); 211 }, 212 render: function () { 213 214 that = this; 215 216 if ( upload_sync ) { 217 $( that.el ).html( '' ); 218 } 219 220 if ( typeof ( rtmedia_load_more_or_pagination ) != 'undefined' && rtmedia_load_more_or_pagination == 'pagination' ) { 221 $( that.el ).html( '' ); 222 } 223 224 $.each( this.collection.toJSON(), function ( key, media ) { 225 $( that.el ).append( that.template( media ) ); 226 } ); 227 228 if ( upload_sync ) { 229 upload_sync = false;
230 } 231 if ( nextpage > 1 ) { 232 $( that.el ).siblings( '.rtmedia_next_prev' ).children( '#rtMedia-galary-next' ).show(); 233 //$("#rtMedia-galary-next").show(); 234 } 235 if ( typeof rtmedia_masonry_layout != "undefined" && rtmedia_masonry_layout == "true" && jQuery( '.rtmedia-container .rtmedia-list.rtm-no-masonry' ).length == 0 ) { 236 rtm_masonry_reload( rtm_masonry_container ); 237 } 238 }, 239 appendTo: function ( media ) { 240 //console.log("append"); 241 var mediaView = new rtMedia.MediaView( { 242 model: media 243 } ); 244 $( this.el ).append( mediaView.render().el ); 245 } 246 } ); 247 248 galleryObj = new rtMedia.Gallery(); 249 250 $( "body" ).append( '<script id="rtmedia-gallery-item-template" type="text/template"></script>' ); 251 252 $( document ).on( "click", "#rtMedia-galary-next", function ( e ) { 253 if ( jQuery( '.rtm-media-loading' ).length == 0 ) { 254 $( this ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" ); 255 } else { 256 jQuery( '.rtm-media-loading' ).show(); 257 } 258 $( this ).hide(); 259 e.preventDefault(); 260 galleryObj.getNext( nextpage, $( this ).parent().parent().parent(), $( this ) ); 261 } ); 262 263 $( document ).on( "keypress", "#rtmedia_go_to_num", function( e ) { 264 if ( e.keyCode == 13 ) { 265 e.preventDefault(); 266 267 if ( jQuery( '.rtm-media-loading' ).length == 0 ) { 268 $( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" ); 269 } else { 270 jQuery( '.rtm-media-loading' ).show(); 271 } 272 273 if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) { 274 nextpage = parseInt( $( '#rtmedia_last_page' ).val() ); 275 } else { 276 nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() ); 277 } 278 279 galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() ); 280 281 return false; 282 } 283 } ); 284 285 $( document ).on( "click", ".rtmedia-page-link", function ( e ) { 286 if ( jQuery( '.rtm-media-loading' ).length == 0 ) { 287 $( '.rtm-pagination' ).before( "<div class='rtm-media-loading'><img src='" + rMedia_loading_media + "' /></div>" ); 288 } else { 289 jQuery( '.rtm-media-loading' ).show(); 290 } 291 292 e.preventDefault(); 293 if ( $( this ).data( 'page-type' ) == 'page' ) { 294 nextpage = $( this ).data( 'page' ); 295 } else if ( $( this ).data( 'page-type' ) == 'prev' ) { 296 if ( nextpage == - 1 ) { 297 nextpage = parseInt( $( '#rtmedia_last_page' ).val() ) - 1; 298 } else { 299 nextpage -= 2; 300 } 301 } else if ( $( this ).data( 'page-type' ) == 'num' ) { 302 if ( parseInt( $( '#rtmedia_go_to_num' ).val() ) > parseInt( $( '#rtmedia_last_page' ).val() ) ) { 303 nextpage = parseInt( $( '#rtmedia_last_page' ).val() ); 304 } else { 305 nextpage = parseInt( $( '#rtmedia_go_to_num' ).val() ); 306 } 307 } 308 309 if ( $( this ).data( 'page-type' ) == 'num' ) { 310 galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() ); 311 } else { 312 galleryObj.getNext( nextpage, $( this ).parent().parent().parent().parent().parent(), $( this ).parent().parent() ); 313 } 314 } ); 315 316 if ( window.location.pathname.indexOf( rtmedia_media_slug ) != - 1 ) { 317 var tempNext = window.location.pathname.substring( window.location.pathname.lastIndexOf( "pg/" ) + 5, window.location.pathname.lastIndexOf( "/" ) ); 318 if ( isNaN( tempNext ) === false ) { 319 nextpage = parseInt( tempNext ) + 1; 320 } 321 } 322 323 window.UploadView = Backbone.View.extend( { 324 events: { 325 "click #rtMedia-start-upload": "uploadFiles" 326 }, 327 initialize: function ( config ) { 328 this.uploader = new plupload.Uploader( config ); 329 }, 330 render: function () { 331 332 }, 333 initUploader: function ( a ) { 334 if ( typeof ( a ) !== "undefined" ) { 335 a = false;// if rtmediapro widget calls the function, dont show max size note. 336 } this.uploader.init(); 337 //The plupload HTML5 code gives a negative z-index making add files button unclickable 338 $( ".plupload.html5" ).css( { 339 zIndex: 0 340 } ); 341 $( "#rtMedia-upload-button" ).css( { 342 zIndex: 2 343 } ); 344 if ( a !== false ) { 345 window.file_size_info = rtmedia_max_file_msg + this.uploader.settings.max_file_size_msg; 346 if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9 347 file_extn = this.uploader.settings.filters.mime_types[0].extensions; 348 } else { 349 file_extn = this.uploader.settings.filters[0].extensions; 350 } 351 window.file_extn_info = rtmedia_allowed_file_formats + " : " + file_extn.split( ',' ).join( ', ' ); 352 353 var info = window.file_size_info + "\n" + window.file_extn_info; 354 $( ".rtm-file-size-limit" ).attr( 'title', info ); 355 //$("#rtMedia-upload-button").after("<span>( <strong>" + rtmedia_max_file_msg + "</strong> "+ this.uploader.settings.max_file_size_msg + ")</span>"); 356 } 357 358 return this; 359 }, 360 uploadFiles: function ( e ) { 361 if ( e != undefined ) { 362 e.preventDefault(); 363 } 364 this.uploader.start(); 365 return false;
366 } 367 368 } ); 369 370 if ( $( "#rtMedia-upload-button" ).length > 0 ) { 371 if ( typeof rtmedia_upload_type_filter == "object" && rtmedia_upload_type_filter.length > 0 ) { 372 rtMedia_plupload_config.filters[0].extensions = rtmedia_upload_type_filter.join(); 373 } 374 uploaderObj = new UploadView( rtMedia_plupload_config ); 375 uploaderObj.initUploader(); 376 377 uploaderObj.uploader.bind( 'UploadComplete', function ( up, files ) { 378 activity_id = - 1; 379 var hook_respo = rtMediaHook.call( 'rtmedia_js_after_files_uploaded' ); 380 if ( typeof rtmedia_gallery_reload_on_upload != "undefined" && rtmedia_gallery_reload_on_upload == '1' ) { //reload gallery view when upload completes if enabled( by default enabled) 381 if ( hook_respo != false ) { 382 galleryObj.reloadView(); 383 } 384 } 385 jQuery( '#rtmedia_uploader_filelist li.plupload_queue_li' ).remove(); 386 jQuery( '.start-media-upload' ).hide(); 387 apply_rtMagnificPopup( jQuery( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' ) ); 388 window.onbeforeunload = null; 389 } ); 390 391 uploaderObj.uploader.bind( 'FilesAdded', function ( up, files ) { 392 var upload_size_error = false; 393 var upload_error = ""; 394 var upload_error_sep = ""; 395 var upload_remove_array = [ ]; 396 $.each( files, function ( i, file ) { 397 //set file title along with file 398 rtm_file_name_array = file.name.split( '.' ); 399 file.title = rtm_file_name_array[0]; 400 401 var hook_respo = rtMediaHook.call( 'rtmedia_js_file_added', [ up, file, "#rtmedia_uploader_filelist" ] ); 402 403 if ( hook_respo == false ) { 404 file.status = - 1; 405 upload_remove_array.push( file.id ); 406 return true; 407 } 408 409 jQuery( '.rtmedia-upload-input' ).attr( 'value', rtmedia_add_more_files_msg ); 410 if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' ) { 411 jQuery( '.start-media-upload' ).hide(); 412 } else { 413 jQuery( '.start-media-upload' ).show(); 414 } 415 if ( uploaderObj.uploader.settings.max_file_size < file.size ) { 416 return true; 417 } 418 var tmp_array = file.name.split( "." ); 419 if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9 420 var ext_array = uploaderObj.uploader.settings.filters.mime_types[0].extensions.split( ',' ); 421 } else { 422 var ext_array = uploaderObj.uploader.settings.filters[0].extensions.split( ',' ); 423 } 424 if ( tmp_array.length > 1 ) { 425 var ext = tmp_array[tmp_array.length - 1]; 426 ext = ext.toLowerCase(); 427 if ( jQuery.inArray( ext, ext_array ) === - 1 ) { 428 return true; 429 } 430 } else { 431 return true; 432 } 433 434 if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9 435 uploaderObj.uploader.settings.filters.mime_types[0].title; 436 } else { 437 uploaderObj.uploader.settings.filters[0].title; 438 } 439 440 // Creating list of media to preview selected files 441 rtmedia_selected_file_list( plupload, file, '', '' ); 442 443 //Delete Function 444 $( "#" + file.id + " .plupload_delete .remove-from-queue" ).click( function ( e ) { 445 e.preventDefault(); 446 uploaderObj.uploader.removeFile( up.getFile( file.id ) ); 447 $( "#" + file.id ).remove(); 448 rtMediaHook.call( 'rtmedia_js_file_remove', [ up, file ] ); 449 return false; 450 } ); 451 452 // To change the name of the uploading file 453 $( "#label_" + file.id ).click( function ( e ) { 454 e.preventDefault(); 455 456 rtm_file_label = this; 457 458 rtm_file_title_id = 'text_' + file.id; 459 rtm_file_title_input = '#' + rtm_file_title_id; 460 rtm_file_title_wrapper_id = 'rtm_title_wp_' + file.id; 461 rtm_file_title_wrapper = '#' + rtm_file_title_wrapper_id; 462 463 rtm_file_desc_id = 'rtm_desc_' + file.id; 464 rtm_file_desc_input = '#' + rtm_file_desc_id; 465 rtm_file_desc_wrapper_id = 'rtm_desc_wp_' + file.id; 466 rtm_file_desc_wrapper = '#' + rtm_file_desc_wrapper_id; 467 468 rtm_file_save_id = 'save_' + file.id; 469 rtm_file_save_el = '#' + rtm_file_save_id; 470 471 jQuery( rtm_file_label ).hide(); 472 jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide(); 473 474 // show/create text box to edit media title 475 if ( jQuery( rtm_file_title_input ).length === 0 ) { 476 jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' ); 477 } else { 478 jQuery( rtm_file_title_wrapper ).show(); 479 jQuery( rtm_file_desc_wrapper ).show(); 480 jQuery( rtm_file_save_el ).show(); 481 } 482 483 jQuery( rtm_file_title_input ).focus(); 484 485 // set media title and description in file object 486 jQuery( rtm_file_save_el ).click( function(){ 487 var file_title_val = jQuery( rtm_file_title_input ).val(); 488 var file_desc_val = jQuery( rtm_file_desc_input ).val(); 489 var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ); 490 491 if ( file_title_val != '' ) { 492 file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] ); 493 file.title = file_title_val; 494 } 495 496 if ( file_desc_val != '' ) { 497 file.description = file_desc_val; 498 } 499 500 jQuery( rtm_file_title_wrapper ).hide(); 501 jQuery( rtm_file_desc_wrapper ).hide(); 502 file_name_wrapper_el.show(); 503 jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ) 504 jQuery( rtm_file_label ).show(); 505 jQuery( this ).hide(); 506 } ); 507 } ); 508 } ); 509 510 $.each( upload_remove_array, function ( i, rfile ) { 511 if ( up.getFile( rfile ) ) { 512 up.removeFile( up.getFile( rfile ) ); 513 } 514 } ); 515 516 rtMediaHook.call( 'rtmedia_js_after_files_added', [ up, files ] ); 517 518 if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' ) { 519 var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true ); 520 if ( allow_upload == false ) { 521 return false;
522 } 523 uploaderObj.uploadFiles(); 524 } 525 526 } ); 527 528 uploaderObj.uploader.bind( 'Error', function ( up, err ) { 529 530 if ( err.code == - 600 ) { //file size error // if file size is greater than server's max allowed size 531 var tmp_array; 532 var ext = tr = ''; 533 tmp_array = err.file.name.split( "." ); 534 if ( tmp_array.length > 1 ) { 535 ext = tmp_array[tmp_array.length - 1]; 536 if ( ! ( typeof ( up.settings.upload_size ) != "undefined" && typeof ( up.settings.upload_size[ext] ) != "undefined" && typeof ( up.settings.upload_size[ext]['size'] ) ) ) { 537 rtmedia_selected_file_list( plupload, err.file, up, err ); 538 } 539 } 540 } else { 541 542 if ( err.code == - 601 ) { // file extension error 543 err.message = rtmedia_file_extension_error_msg; 544 } 545 546 rtmedia_selected_file_list( plupload, err.file, '', err ); 547 } 548 549 jQuery( '.plupload_delete' ).on( 'click', function ( e ) { 550 e.preventDefault(); 551 jQuery( this ).parent().parent( 'li' ).remove(); 552 } ); 553 return false; 554 555 } ); 556 557 jQuery( '.start-media-upload' ).on( 'click', function ( e ) { 558 e.preventDefault(); 559 560 /** 561 * To check if any media file is selected or not for uploading 562 */ 563 if ( jQuery( '#rtmedia_uploader_filelist' ).children( 'li' ).length > 0 ) { 564 var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true ); 565 566 if ( allow_upload == false ) { 567 return false; 568 } 569 uploaderObj.uploadFiles(); 570 } 571 } ); 572 573 uploaderObj.uploader.bind( 'UploadProgress', function ( up, file ) { 574 //$("#" + file.id + " .plupload_file_status").html(file.percent + "%"); 575 //$( "#" + file.id + " .plupload_file_status" ).html( rtmedia_uploading_msg + '( ' + file.percent + '% )' ); 576 $( "#" + file.id + " .plupload_file_status" ).html( '<div class="plupload_file_progress ui-widget-header" style="width: ' + file.percent + '%;"></div>' ); 577 $( "#" + file.id ).addClass( 'upload-progress' ); 578 if ( file.percent == 100 ) { 579 $( "#" + file.id ).toggleClass( 'upload-success' ); 580 } 581 582 window.onbeforeunload = function ( evt ) { 583 var message = rtmedia_upload_progress_error_message; 584 return message; 585 }; 586 } ); 587 588 uploaderObj.uploader.bind( 'BeforeUpload', function ( up, file ) { 589 up.settings.multipart_params.title = file.title.split( '.' )[ 0 ]; 590 591 if ( typeof file.description != "undefined" ) { 592 up.settings.multipart_params.description = file.description; 593 } else { 594 up.settings.multipart_params.description = ''; 595 } 596 597 var privacy = $( "#rtm-file_upload-ui select.privacy" ).val(); 598 if ( privacy !== undefined ) { 599 up.settings.multipart_params.privacy = $( "#rtm-file_upload-ui select.privacy" ).val(); 600 } 601 if ( jQuery( "#rt_upload_hf_redirect" ).length > 0 ) { 602 up.settings.multipart_params.redirect = up.files.length; 603 } 604 jQuery( "#rtmedia-uploader-form input[type=hidden]" ).each( function () { 605 up.settings.multipart_params[$( this ).attr( "name" )] = $( this ).val(); 606 } ); 607 up.settings.multipart_params.activity_id = activity_id; 608 if ( $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).length > 0 ) { 609 up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-user-album-list' ).find( ":selected" ).val(); 610 } else if ( $( '#rtmedia-uploader-form .rtmedia-current-album' ).length > 0 ) { 611 up.settings.multipart_params.album_id = $( '#rtmedia-uploader-form .rtmedia-current-album' ).val(); 612 } 613 614 rtMediaHook.call( 'rtmedia_js_before_file_upload', [up, file] ); 615 } ); 616 617 uploaderObj.uploader.bind( 'FileUploaded', function ( up, file, res ) { 618 if ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) ) { //test for MSIE x.x; 619 var ieversion = new Number( RegExp.$1 ) // capture x.x portion and store as a number 620 621 if ( ieversion < 10 ) { 622 if ( typeof res.response !== "undefined" ) { 623 res.status = 200; } 624 } 625 } 626 var rtnObj; 627 try { 628 629 rtnObj = JSON.parse( res.response ); 630 uploaderObj.uploader.settings.multipart_params.activity_id = rtnObj.activity_id; 631 activity_id = rtnObj.activity_id; 632 if ( rtnObj.permalink != '' ) { 633 $( "#" + file.id + " .plupload_file_name" ).html( "<a href='" + rtnObj.permalink + "' target='_blank' title='" + rtnObj.permalink + "'>" + file.title.substring( 0, 40 ).replace( /(<([^>]+)>)/ig, "" ) + "</a>" ); 634 $( "#" + file.id + " .plupload_media_edit" ).html( "<a href='" + rtnObj.permalink + "edit' target='_blank'><span title='" + rtmedia_edit_media + "'><i class='dashicons dashicons-edit rtmicon'></i> " + rtmedia_edit + "</span></a>" ); 635 $( "#" + file.id + " .plupload_delete" ).html( "<span id='" + rtnObj.media_id + "' class='rtmedia-delete-uploaded-media' title='" + rtmedia_delete + "'>×</span>" ); 636 } 637 638 } catch ( e ) { 639 // console.log('Invalid Activity ID'); 640 } 641 if ( res.status == 200 || res.status == 302 ) { 642 if ( uploaderObj.upload_count == undefined ) { 643 uploaderObj.upload_count = 1; 644 } else { 645 uploaderObj.upload_count ++; 646 } 647 648 if ( uploaderObj.upload_count == up.files.length && jQuery( "#rt_upload_hf_redirect" ).length > 0 && jQuery.trim( rtnObj.redirect_url.indexOf( "http" ) == 0 ) ) { 649 window.location = rtnObj.redirect_url; 650 } 651 652 $( "#" + file.id + " .plupload_file_status" ).html( rtmedia_uploaded_msg ); 653 rtMediaHook.call( 'rtmedia_js_after_file_upload', [ up, file, res.response ] ); 654 } else { 655 $( "#" + file.id + " .plupload_file_status" ).html( rtmedia_upload_failed_msg ); 656 } 657 658 files = up.files; 659 lastfile = files[files.length - 1]; 660 661 } ); 662 663 uploaderObj.uploader.refresh();//refresh the uploader for opera/IE fix on media page 664 665 $( "#rtMedia-start-upload" ).click( function ( e ) { 666 uploaderObj.uploadFiles( e ); 667 } ); 668 $( "#rtMedia-start-upload" ).hide(); 669 670 jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () { 671 jQuery( '#rtm-media-gallery-uploader' ).slideToggle(); 672 uploaderObj.uploader.refresh();//refresh the uploader for opera/IE fix on media page 673 jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' ); 674 } ); 675 } else { 676 jQuery( document ).on( 'click', '#rtm_show_upload_ui', function () { 677 jQuery( '#rtm-media-gallery-uploader' ).slideToggle(); 678 jQuery( '#rtm_show_upload_ui' ).toggleClass( 'primary' ); 679 } ); 680 } 681 682 jQuery( document ).on( 'click', '.plupload_delete .rtmedia-delete-uploaded-media', function () { 683 var that = $( this ); 684 if ( confirm( rtmedia_delete_uploaded_media ) ) { 685 var nonce = $( '#rtmedia-upload-container #rtmedia_media_delete_nonce' ).val(); 686 var media_id = $( this ).attr( 'id' ); 687 var data = { 688 action: 'delete_uploaded_media', 689 nonce: nonce, 690 media_id: media_id 691 } 692 693 $.post( ajaxurl, data, function ( response ) { 694 if ( response == '1' ) { 695 that.closest( 'tr' ).remove(); 696 $( '#' + media_id ).remove(); 697 } 698 } ); 699 } 700 } ); 701 702} ); 703 704/** Activity Update Js **/ 705 706jQuery( document ).ready( function ( $ ) { 707 708 //handling the "post update: button on activity page 709 jQuery( '#aw-whats-new-submit' ).removeAttr( 'disabled' ); 710 jQuery( document ).on( "blur", '#whats-new', function () { 711 setTimeout( function () { 712 jQuery( '#aw-whats-new-submit' ).removeAttr( 'disabled' ); 713 }, 100 ); 714 } ); 715 jQuery( '#aw-whats-new-submit' ).on( 'click', function ( e ) { 716 setTimeout( function () { 717 jQuery( '#aw-whats-new-submit' ).removeAttr( 'disabled' ); 718 }, 100 ); 719 } ); 720 721 // when user changes the value in activity "post in" dropdown, hide the privacy dropdown and show when posting in profile. 722 jQuery( '#whats-new-post-in' ).on( 'change', function ( e ) { 723 if ( jQuery( this ).val() == '0' ) { 724 jQuery( "#rtmedia-action-update .privacy" ).prop( 'disabled', false ).show(); 725 } else { 726 jQuery( "#rtmedia-action-update .privacy" ).prop( 'disabled', true ).hide(); 727 } 728 } ); 729 730 if ( typeof rtMedia_update_plupload_config == 'undefined' ) { 731 return false;
732 } 733 var activity_attachemnt_ids = [ ]; 734 735 if ( $( "#rtmedia-add-media-button-post-update" ).length > 0 ) { 736 objUploadView = new UploadView( rtMedia_update_plupload_config ); 737 objUploadView.initUploader(); 738 739 setTimeout( function () { 740 if ( $( "#rtmedia-add-media-button-post-update" ).length > 0 ) { 741 $( "#whats-new-options" ).prepend( $( ".rtmedia-plupload-container" ) ); 742 if ( $( "#rtm-file_upload-ui .privacy" ).length > 0 ) { 743 $( ".rtmedia-plupload-container" ).append( $( "#rtm-file_upload-ui .privacy" ) ); 744 } 745 $( '#rtmedia-whts-new-upload-container > div' ).css( 'top', '0' ); 746 $( '#rtmedia-whts-new-upload-container > div' ).css( 'left', '0' ); 747 } 748 }, 100 ); 749 750 if ( $( '#whats-new-options' ).length > 0 && $( '.rtmedia-uploader-div' ).length > 0 ) { 751 $( '#whats-new-options' ).append( $( '.rtmedia-uploader-div' ) ); 752 } 753 754 $( "#whats-new-form" ).on( 'click', '#rtmedia-add-media-button-post-update', function ( e ) { 755 objUploadView.uploader.refresh(); 756 $( '#rtmedia-whts-new-upload-container > div' ).css( 'top', '0' ); 757 $( '#rtmedia-whts-new-upload-container > div' ).css( 'left', '0' ); 758 759 //Enable 'post update' button when media get select 760 $( '#aw-whats-new-submit' ).prop( "disabled", false ); 761 } ); 762 //whats-new-post-in 763 764 objUploadView.upload_remove_array = [ ]; 765 766 objUploadView.uploader.bind( 'FilesAdded', function ( upl, rfiles ) { 767 //$("#aw-whats-new-submit").attr('disabled', 'disabled'); 768 769 $.each( rfiles, function ( i, file ) { 770 771 //set file title along with file 772 rtm_file_name_array = file.name.split( '.' ); 773 file.title = rtm_file_name_array[0]; 774 775 var hook_respo = rtMediaHook.call( 'rtmedia_js_file_added', [ upl, file, "#rtmedia_uploader_filelist" ] ); 776 777 if ( hook_respo == false ) { 778 file.status = - 1; 779 objUploadView.upload_remove_array.push( file.id ); 780 return true; 781 } 782 783 if ( objUploadView.uploader.settings.max_file_size < file.size ) { 784 return true; 785 } 786 787 var tmp_array = file.name.split( "." ); 788 789 if ( rtmedia_version_compare( rtm_wp_version, "3.9" ) ) { // plupload getting updated in 3.9 790 var ext_array = objUploadView.uploader.settings.filters.mime_types[0].extensions.split( ',' ); 791 } else { 792 var ext_array = objUploadView.uploader.settings.filters[0].extensions.split( ',' ); 793 } 794 if ( tmp_array.length > 1 ) { 795 var ext = tmp_array[tmp_array.length - 1]; 796 ext = ext.toLowerCase(); 797 if ( jQuery.inArray( ext, ext_array ) === - 1 ) { 798 return true; 799 } 800 } else { 801 return true; 802 } 803 804 rtmedia_selected_file_list( plupload, file, '', '' ); 805 806 jQuery( '#whats-new-content' ).css( 'padding-bottom', '0px' ); 807 808 $( "#" + file.id + " .plupload_delete" ).click( function ( e ) { 809 e.preventDefault(); 810 objUploadView.uploader.removeFile( upl.getFile( file.id ) ); 811 $( "#" + file.id ).remove(); 812 return false; 813 } ); 814 815 // To change the name of the uploading file 816 $( "#label_" + file.id ).click( function ( e ) { 817 e.preventDefault(); 818 819 rtm_file_label = this; 820 821 rtm_file_title_id = 'text_' + file.id; 822 rtm_file_title_input = '#' + rtm_file_title_id; 823 rtm_file_title_wrapper_id = 'rtm_title_wp_' + file.id; 824 rtm_file_title_wrapper = '#' + rtm_file_title_wrapper_id; 825 826 rtm_file_desc_id = 'rtm_desc_' + file.id; 827 rtm_file_desc_input = '#' + rtm_file_desc_id; 828 rtm_file_desc_wrapper_id = 'rtm_desc_wp_' + file.id; 829 rtm_file_desc_wrapper = '#' + rtm_file_desc_wrapper_id; 830 831 rtm_file_save_id = 'save_' + file.id; 832 rtm_file_save_el = '#' + rtm_file_save_id; 833 834 jQuery( rtm_file_label ).hide(); 835 jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ).hide(); 836 837 // show/create text box to edit media title 838 if ( jQuery( rtm_file_title_input ).length === 0 ) { 839 jQuery( rtm_file_label ).parent( '.plupload_file_name' ).prepend( '<div id="' + rtm_file_title_wrapper_id + '" class="rtm-upload-edit-title-wrapper"><label>' + rtmedia_edit_media_info_upload.title + '</label><input type="text" class="rtm-upload-edit-title" id="' + rtm_file_title_id + '" value="' + file.title + '" style="width: 75%;" /></div><div id="' + rtm_file_desc_wrapper_id + '" class="rtm-upload-edit-desc-wrapper"><label>' + rtmedia_edit_media_info_upload.description + '</label><textarea class="rtm-upload-edit-desc" id="' + rtm_file_desc_id + '"></textarea></div><span id="' + rtm_file_save_id + '" title="Save Change" class="rtmicon dashicons dashicons-yes"></span>' ); 840 } else { 841 jQuery( rtm_file_title_wrapper ).show(); 842 jQuery( rtm_file_desc_wrapper ).show(); 843 jQuery( rtm_file_save_el ).show(); 844 } 845 846 jQuery( rtm_file_title_input ).focus(); 847 848 jQuery( rtm_file_save_el ).click( function(){ 849 var file_title_val = jQuery( rtm_file_title_input ).val(); 850 var file_desc_val = jQuery( rtm_file_desc_input ).val(); 851 var file_name_wrapper_el = jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ); 852 853 if ( file_title_val != '' ) { 854 file_name_wrapper_el.text( file_title_val + "." + rtm_file_name_array[ 1 ] ); 855 file.title = file_title_val; 856 } 857 858 if ( file_desc_val != '' ) { 859 file.description = file_desc_val; 860 } 861 862 jQuery( rtm_file_title_wrapper ).hide(); 863 jQuery( rtm_file_desc_wrapper ).hide(); 864 file_name_wrapper_el.show(); 865 jQuery( rtm_file_label ).siblings( '.plupload_file_name_wrapper' ) 866 jQuery( rtm_file_label ).show(); 867 jQuery( this ).hide(); 868 } ); 869 } ); 870 } ); 871 872 $.each( objUploadView.upload_remove_array, function ( i, rfile ) { 873 if ( upl.getFile( rfile ) ) { 874 upl.removeFile( upl.getFile( rfile ) ); 875 } 876 } ); 877 878 if ( typeof rtmedia_direct_upload_enabled != 'undefined' && rtmedia_direct_upload_enabled == '1' && jQuery.trim( jQuery( "#whats-new" ).val() ) != "" ) { 879 //Call upload event direct when direct upload is enabled (removed UPLOAD button and its triggered event) 880 var allow_upload = rtMediaHook.call( 'rtmedia_js_upload_file', true ); 881 882 if ( allow_upload == false ) { 883 return false;
884 } 885 886 objUploadView.uploadFiles(); 887 } 888 } ); 889 890 objUploadView.uploader.bind( 'FileUploaded', function ( up, file, res ) { 891 if ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) ) { //test for MSIE x.x; 892 var ieversion = new Number( RegExp.$1 ) // capture x.x portion and store as a number 893 894 if ( ieversion < 10 ) { 895 try { 896 if ( typeof JSON.parse( res.response ) !== "undefined" ) { 897 res.status = 200; 898 } 899 } catch ( e ) { 900 } 901 } 902 } 903 904 if ( res.status == 200 ) { 905 try { 906 var objIds = JSON.parse( res.response ); 907 $.each( objIds, function ( key, val ) { 908 activity_attachemnt_ids.push( val ); 909 if ( $( "#whats-new-form" ).find( "#rtmedia_attached_id_" + val ).length < 1 ) { 910 $( "#whats-new-form" ).append( "<input type='hidden' name='rtMedia_attached_files[]' data-mode='rtMedia-update' id='rtmedia_attached_id_" + val + "' value='" 911 + val + "' />" ); 912 } 913 } ); 914 } catch ( e ) { 915 916 } 917 rtMediaHook.call( 'rtmedia_js_after_file_upload', [ up, file, res.response ] ); 918 } 919 } ); 920 921 objUploadView.uploader.bind( 'Error', function ( up, err ) { 922 923 if ( err.code == - 600 ) { //file size error // if file size is greater than server's max allowed size 924 var tmp_array; 925 var ext = tr = ''; 926 tmp_array = err.file.name.split( "." ); 927 if ( tmp_array.length > 1 ) { 928 929 ext = tmp_array[tmp_array.length - 1]; 930 if ( ! ( typeof ( up.settings.upload_size ) != "undefined" && typeof ( up.settings.upload_size[ext] ) != "undefined" && ( up.settings.upload_size[ext]["size"] < 1 || ( up.settings.upload_size[ext]["size"] * 1024 * 1024 ) >= err.file.size ) ) ) { 931 rtmedia_selected_file_list( plupload, err.file, up, err ); 932 } 933 } 934 } else { 935 if ( err.code == - 601 ) { // file extension error 936 err.message = rtmedia_file_extension_error_msg; 937 } 938 939 rtmedia_selected_file_list( plupload, err.file, '', err ); 940 } 941 942 jQuery( '.plupload_delete' ).on( 'click', function ( e ) { 943 e.preventDefault(); 944 jQuery( this ).parent().parent( 'li' ).remove(); 945 } ); 946 947 return false; 948 949 } ); 950 951 objUploadView.uploader.bind( 'BeforeUpload', function ( up, files ) { 952 953 $.each( objUploadView.upload_remove_array, function ( i, rfile ) { 954 if ( up.getFile( rfile ) ) { 955 up.removeFile( up.getFile( rfile ) ); } 956 } ); 957 958 var object = ''; 959 var item_id = jQuery( "#whats-new-post-in" ).val(); 960 if ( item_id == undefined ) { 961 item_id = 0; } 962 if ( item_id > 0 ) { 963 object = "group"; 964 } else { 965 object = "profile"; 966 } 967 968 up.settings.multipart_params.context = object; 969 up.settings.multipart_params.context_id = item_id; 970 up.settings.multipart_params.title = files.title.split( '.' )[ 0 ]; 971 972 if ( typeof files.description != "undefined" ) { 973 up.settings.multipart_params.description = files.description; 974 } else { 975 up.settings.multipart_params.description = ''; 976 } 977 978 // if privacy dropdown is not disabled, then get the privacy value of the update 979 if ( jQuery( "select.privacy" ).prop( 'disabled' ) === false ) { 980 up.settings.multipart_params.privacy = jQuery( "select.privacy" ).val(); 981 } 982 } ); 983 984 objUploadView.uploader.bind( 'UploadComplete', function ( up, files ) { 985 media_uploading = true; 986 $( "#aw-whats-new-submit" ).click(); 987 $( '#rtmedia_uploader_filelist li.plupload_queue_li' ).remove(); 988 //$("#aw-whats-new-submit").removeAttr('disabled'); 989 window.onbeforeunload = null; 990 } ); 991 992 objUploadView.uploader.bind( 'UploadProgress', function ( up, file ) { 993 //$( "#" + file.id + " .plupload_file_status" ).html( rtmedia_uploading_msg + '( ' + file.percent + '% )' ); 994 $( "#" + file.id + " .plupload_file_status" ).html( '<div class="plupload_file_progress ui-widget-header" style="width: ' + file.percent + '%;"></div>' ); 995 $( "#" + file.id ).addClass( 'upload-progress' ); 996 if ( file.percent == 100 ) { 997 $( "#" + file.id ).toggleClass( 'upload-success' ); 998 } 999 1000 window.onbeforeunload = function ( evt ) { 1001 var message = rtmedia_upload_progress_error_message; 1002 return message; 1003 }; 1004 } ); 1005 1006 $( "#rtMedia-start-upload" ).hide(); 1007 1008 var change_flag = false 1009 var media_uploading = false;
1010 1011 $.ajaxPrefilter( function ( options, originalOptions, jqXHR ) { 1012 // Modify options, control originalOptions, store jqXHR, etc 1013 try { 1014 if ( originalOptions.data == null || typeof ( originalOptions.data ) == "undefined" || typeof ( originalOptions.data.action ) == "undefined" ) { 1015 return true; 1016 } 1017 } catch ( e ) { 1018 return true; 1019 } 1020 1021 if ( originalOptions.data.action == 'post_update' || originalOptions.data.action == 'activity_widget_filter' ) { 1022 var temp = activity_attachemnt_ids; 1023 while ( activity_attachemnt_ids.length > 0 ) { 1024 options.data += "&rtMedia_attached_files[]=" + activity_attachemnt_ids.pop(); 1025 } 1026 1027 var dynamic_privacy = ''; 1028 1029 if ( jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).length > 0 ) { 1030 dynamic_privacy = jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).val(); 1031 } else if ( jQuery( 'input[name="privacy"]' ).length > 0 ) { 1032 dynamic_privacy = jQuery( 'input[name="privacy"]' ).val(); 1033 } 1034 1035 options.data += "&rtmedia-privacy=" + dynamic_privacy; 1036 activity_attachemnt_ids = temp; 1037 1038 var orignalSuccess = originalOptions.success; 1039 options.beforeSend = function () { 1040 /** 1041 * This hook is added for rtMedia Upload Terms plugin to check if it is checked or not for activity 1042 */ 1043 var allowActivityPost = rtMediaHook.call( 'rtmedia_js_before_activity_added', true ); 1044 1045 if ( ! allowActivityPost ) { 1046 $( '#rtmedia_upload_terms_conditions' ).removeAttr( 'disabled' ); 1047 $( '#rtmedia-whts-new-upload-container' ).find( 'input' ).removeAttr( 'disabled' ); 1048 1049 return false; 1050 } 1051 1052 if ( originalOptions.data.action == 'post_update' ) { 1053 if ( $.trim( $( "#whats-new" ).val() ) == "" && objUploadView.uploader.files.length > 0 ) { 1054 /* 1055 *Added $nbsp; as activity text to post activity without TEXT 1056 * Disabled TextBox color(transparent) 1057 */ 1058 $( "#whats-new" ).css( 'color', 'transparent' ); 1059 $( "#whats-new" ).val( ' ' ); 1060 } 1061 } 1062 if ( ! media_uploading && objUploadView.uploader.files.length > 0 ) { 1063 $( "#whats-new-post-in" ).attr( 'disabled', 'disabled' ); 1064 $( "#rtmedia-add-media-button-post-update" ).attr( 'disabled', 'disabled' ); 1065 objUploadView.uploadFiles() 1066 media_uploading = true; 1067 return false; 1068 } else { 1069 media_uploading = false; 1070 return true; 1071 } 1072 1073 } 1074 options.success = function ( response ) { 1075 orignalSuccess( response ); 1076 if ( response[0] + response[1] == '-1' ) { 1077 //Error 1078 1079 } else { 1080 if ( originalOptions.data.action == 'activity_widget_filter' ) { 1081 $( "div.activity" ).bind( "fadeIn", function () { 1082 apply_rtMagnificPopup( jQuery( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' ) ); 1083 rtMediaHook.call( 'rtmedia_js_after_activity_added', [ ] ); 1084 } ); 1085 $( "div.activity" ).fadeIn( 100 ); 1086 } 1087 jQuery( "input[data-mode=rtMedia-update]" ).remove(); 1088 while ( objUploadView.uploader.files.pop() != undefined ) { 1089 } 1090 objUploadView.uploader.refresh(); 1091 $( '#rtmedia-whts-new-upload-container > div' ).css( { 'top': '0', 'left': '0' } ); 1092 $( '#rtMedia-update-queue-list' ).html( '' ); 1093 //$("#div-attache-rtmedia").hide(); 1094 apply_rtMagnificPopup( jQuery( '.rtmedia-list-media, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.widget-item-listing,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content' ) ); 1095 jQuery( 'ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode' ).mediaelementplayer( { 1096 // if the <video width> is not specified, this is the default 1097 defaultVideoWidth: 480, 1098 // if the <video height> is not specified, this is the default 1099 defaultVideoHeight: 270, 1100 // if set, overrides <video width> 1101 //videoWidth: 1, 1102 // if set, overrides <video height> 1103 //videoHeight: 1 1104 } ); 1105 rtMediaHook.call( 'rtmedia_js_after_activity_added', [ ] ); 1106 } 1107 1108 $( "#whats-new-post-in" ).removeAttr( 'disabled' ); 1109 $( "#rtmedia-add-media-button-post-update" ).removeAttr( 'disabled' ); 1110 // Enabled TextBox color back to normal 1111 $( "#whats-new" ).css( 'color', '' ); 1112 1113 } 1114 } 1115 } ); 1116 } else { 1117 $.ajaxPrefilter( function ( options, originalOptions, jqXHR ) { 1118 // Modify options, control originalOptions, store jqXHR, etc 1119 try { 1120 if ( originalOptions.data == null || typeof ( originalOptions.data ) == "undefined" || typeof ( originalOptions.data.action ) == "undefined" ) { 1121 return true; 1122 } 1123 } catch ( e ) { 1124 return true; 1125 } 1126 1127 if ( originalOptions.data.action == 'post_update' || originalOptions.data.action == 'activity_widget_filter' ) { 1128 var dynamic_privacy = ''; 1129 1130 if ( jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).length > 0 ) { 1131 dynamic_privacy = jQuery( 'select.privacy' ).not( '.rtm-activity-privacy-opt' ).val(); 1132 } else if ( jQuery( 'input[name="privacy"]' ).length > 0 ) { 1133 dynamic_privacy = jQuery( 'input[name="privacy"]' ).val(); 1134 } 1135 1136 options.data += "&rtmedia-privacy=" + dynamic_privacy; 1137 var orignalSuccess = originalOptions.success; 1138 options.success = function ( response ) { 1139 orignalSuccess( response ); 1140 if ( response[0] + response[1] == '-1' ) { 1141 //Error 1142 } else { 1143 if ( originalOptions.data.action == 'activity_widget_filter' ) { 1144 $( "div.activity" ).fadeIn( 100 ); 1145 } 1146 } 1147 1148 $( "#whats-new-post-in" ).removeAttr( 'disabled' ); 1149 // Enabled TextBox color back to normal 1150 $( "#whats-new" ).css( 'color', '' ); 1151 1152 } 1153 } 1154 } ); 1155 } 1156} ); 1157/** 1158 * rtMedia Comment Js 1159 */ 1160jQuery( document ).ready( function ( $ ) { 1161 jQuery( document ).on( "click", "#rt_media_comment_form #rt_media_comment_submit", function ( e ) { 1162 var comment_content_el = jQuery( '#comment_content' ); 1163 var comment_form_el = jQuery( "#rt_media_comment_form" ); 1164 var that = this; 1165 1166 e.preventDefault(); 1167 if ( $.trim( $( "#comment_content" ).val() ) == "" ) { 1168 rtmedia_single_media_alert_message( rtmedia_empty_comment_msg, 'warning' ); 1169 return false;
1170 } 1171 1172 $( this ).attr( 'disabled', 'disabled' ); 1173 1174 // sanitize comment content and escape html tags 1175 comment_content_el.val( jQuery( '<span/>' ).text( jQuery.trim( comment_content_el.val() ) ).html() ); 1176 1177 $.ajax( { 1178 url: comment_form_el.attr( "action" ), 1179 type: 'post', 1180 data: comment_form_el.serialize() + "&rtajax=true", 1181 success: function ( data ) { 1182 $( '#rtmedia-no-comments' ).remove(); 1183 $( "#rtmedia_comment_ul" ).append( data ); 1184 comment_content_el.val( "" ); 1185 $( that ).removeAttr( 'disabled' ); 1186 rtMediaHook.call( 'rtmedia_js_after_comment_added', [ ] ); 1187 } 1188 } ); 1189 1190 return false; 1191 } ); 1192 1193 //Delete comment 1194 jQuery( document ).on( 'click', '.rtmedia-delete-comment', function ( e ) { 1195 e.preventDefault(); 1196 var ask_confirmation = true 1197 ask_confirmation = rtMediaHook.call( 'rtmedia_js_delete_comment_confirmation', [ ask_confirmation ] ); 1198 if ( ask_confirmation && ! confirm( rtmedia_media_comment_delete_confirmation ) ) { 1199 return false; 1200 } 1201 var current_comment = jQuery( this ); 1202 var current_comment_parent = current_comment.parent(); 1203 var comment_id = current_comment.data( 'id' ); 1204 current_comment_parent.css( 'opacity', '0.4' ); 1205 if ( comment_id == '' || isNaN( comment_id ) ) { 1206 return false; 1207 } 1208 var action = current_comment.closest( 'ul' ).data( "action" ); 1209 1210 jQuery.ajax( { 1211 url: action, 1212 type: 'post', 1213 data: { comment_id: comment_id }, 1214 success: function ( res ) { 1215 if ( res != 'undefined' && res == 1 ) { 1216 current_comment.closest( 'li' ).hide( 1000, function () { 1217 current_comment.closest( 'li' ).remove(); 1218 } ); 1219 } else { 1220 current_comment.css( 'opacity', '1' ); 1221 } 1222 rtMediaHook.call( 'rtmedia_js_after_comment_deleted', [ ] ); 1223 } 1224 } ); 1225 1226 } ); 1227 1228 $( document ).on( "click", '.rtmedia-like', function ( e ) { 1229 e.preventDefault(); 1230 var that = this; 1231 var like_nonce = $( this ).siblings( '#rtm_media_like_nonce' ).val(); 1232 $( this ).attr( 'disabled', 'disabled' ); 1233 var url = $( this ).parent().attr( "action" ); 1234 $( that ).prepend( "<img class='rtm-like-loading' src='" + rMedia_loading_file + "' style='width:10px' />" ); 1235 $.ajax( { 1236 url: url, 1237 type: 'post', 1238 data: { json: true, like_nonce: like_nonce }, 1239 success: function ( data ) { 1240 try { 1241 data = JSON.parse( data ); 1242 } catch ( e ) { 1243 1244 } 1245 $( '.rtmedia-like span' ).html( data.next ); 1246 $( '.rtm-like-loading' ).remove(); 1247 $( that ).removeAttr( 'disabled' ); 1248 //update the like counter 1249 $( '.rtmedia-like-counter' ).html( data.count ); 1250 if ( data.count > 0 ) { 1251 $( '.rtmedia-like-info' ).removeClass( 'hide' ); 1252 } else { 1253 $( '.rtmedia-like-info' ).addClass( 'hide' ); 1254 } 1255 } 1256 } ); 1257 1258 } ); 1259 $( document ).on( "click", '.rtmedia-featured, .rtmedia-group-featured', function ( e ) { 1260 e.preventDefault(); 1261 var that = this; 1262 $( this ).attr( 'disabled', 'disabled' ); 1263 var featured_nonce = $( this ).siblings( '#rtm_media_featured_nonce' ).val(); 1264 var url = $( this ).parent().attr( "action" ); 1265 $( that ).prepend( "<img class='rtm-featured-loading' src='" + rMedia_loading_file + "' />" ); 1266 $.ajax( { 1267 url: url, 1268 type: 'post', 1269 data: { json:true, featured_nonce:featured_nonce }, 1270 success: function ( data ) { 1271 try { 1272 data = JSON.parse( data ); 1273 } catch ( e ) { 1274 1275 } 1276 1277 if ( data.nonce ) { 1278 rtmedia_single_media_alert_message( rtmedia_something_wrong_msg, 'warning' ); 1279 } else { 1280 if (data.action) { 1281 rtmedia_single_media_alert_message( rtmedia_set_featured_image_msg, 'success' ); 1282 } else { 1283 rtmedia_single_media_alert_message( rtmedia_unset_featured_image_msg, 'success' ); 1284 } 1285 } 1286 $( that ).find( 'span' ).html( data.next ); 1287 $( '.rtm-featured-loading' ).remove(); 1288 $( that ).removeAttr( 'disabled' ); 1289 } 1290 } ); 1291 1292 } ); 1293 jQuery( "#div-attache-rtmedia" ).find( "input[type=file]" ).each( function () { 1294 //$(this).attr("capture", "camera"); 1295 // $(this).attr("accept", $(this).attr("accept") + ';capture=camera'); 1296 1297 } ); 1298 1299 // manually trigger fadein event so that we can bind some function on this event. It is used in activity when content getting load via ajax 1300 var _old_fadein = $.fn.fadeIn; 1301 jQuery.fn.fadeIn = function () { 1302 return _old_fadein.apply( this, arguments ).trigger( "fadeIn" ); 1303 }; 1304} ); 1305 1306function rtmedia_selected_file_list( plupload, file, uploader, error ) { 1307 var icon = '', err_msg = '', upload_progress = '', title = ''; 1308 1309 if ( error == '' ) { 1310 upload_progress = '<div class="plupload_file_progress ui-widget-header" style="width: 0%;">'; 1311 upload_progress += '</div>'; 1312 icon = '<span id="label_' + file.id + '" class="dashicons dashicons-edit rtmicon" title="Edit File Name"></span>'; 1313 } else if ( error.code == - 600 ) { 1314 err_msg = ( uploader != '' ) ? rtmedia_max_file_msg + uploader.settings.max_file_size : window.file_size_info; 1315 title = "title='" + err_msg + "'"; 1316 icon = '<i class="dashicons dashicons-info rtmicon" ' + title + '></i>'; 1317 } else if ( error.code == - 601 ) { 1318 err_msg = error.message + '. ' + window.file_extn_info; 1319 title = "title='" + err_msg + "'"; 1320 icon = '<i class="dashicons dashicons-info rtmicon" ' + title + '></i>'; 1321 } 1322 1323 var rtmedia_plupload_file = '<li class="plupload_file ui-state-default plupload_queue_li" id="' + file.id + '" ' + title + '>'; 1324 rtmedia_plupload_file += '<div id="file_thumb_' + file.id + '" class="plupload_file_thumb">'; 1325 rtmedia_plupload_file += '</div>'; 1326 rtmedia_plupload_file += '<div class="plupload_file_status">'; 1327 rtmedia_plupload_file += upload_progress; 1328 rtmedia_plupload_file += '</div>'; 1329 rtmedia_plupload_file += '<div class="plupload_file_name" title="' + ( f
1329ile.name ? file.name : '' ) + '">'; 1330 rtmedia_plupload_file += '<span class="plupload_file_name_wrapper">'; 1331 rtmedia_plupload_file += ( file.name ? file.name : '' ); 1332 rtmedia_plupload_file += '</span>'; 1333 rtmedia_plupload_file += icon; 1334 rtmedia_plupload_file += '</div>'; 1335 rtmedia_plupload_file += '<div class="plupload_file_action">'; 1336 rtmedia_plupload_file += '<div class="plupload_action_icon ui-icon plupload_delete">'; 1337 rtmedia_plupload_file += '<span class="remove-from-queue dashicons dashicons-dismiss"></span>'; 1338 rtmedia_plupload_file += '</div>'; 1339 rtmedia_plupload_file += '</div>'; 1340 rtmedia_plupload_file += '<div class="plupload_file_size">'; 1341 rtmedia_plupload_file += plupload.formatSize( file.size ); 1342 rtmedia_plupload_file += '</div>'; 1343 rtmedia_plupload_file += '<div class="plupload_file_fields">'; 1344 rtmedia_plupload_file += '</div>'; 1345 rtmedia_plupload_file += '</li>'; 1346 1347 jQuery( rtmedia_plupload_file ).appendTo( '#rtmedia_uploader_filelist' ); 1348 var type = file.type; 1349 var media_title = file.name; 1350 var ext = media_title.substring( media_title.lastIndexOf( "." ) + 1, media_title.length ); 1351 1352 if ( /image/i.test( type ) ) { 1353 if ( ext === 'gif' ) { 1354 jQuery( '<img src="' + rtmedia_media_thumbs[ 'photo' ] + '" />' ).appendTo( '#file_thumb_' + file.id ); 1355 } else { 1356 var img = new mOxie.Image(); 1357 1358 img.onload = function () { 1359 this.embed( jQuery( '#file_thumb_' + file.id ).get( 0 ), { 1360 width: 100, 1361 height: 60, 1362 crop: true 1363 } ); 1364 }; 1365 1366 img.onembedded = function () { 1367 this.destroy(); 1368 }; 1369 1370 img.onerror = function () { 1371 this.destroy(); 1372 }; 1373 1374 img.load( file.getSource() ); 1375 } 1376 } else { 1377 jQuery.each( rtmedia_exteansions, function( key, value ) { 1378 if ( value.indexOf( ext ) >= 0 ) { 1379 jQuery( '<img src="' + rtmedia_media_thumbs[ key ] + '" />' ).appendTo( '#file_thumb_' + file.id ); 1380 1381 return false; 1382 } 1383 } ); 1384 } 1385 1386}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.