rtMedia for WordPress, BuddyPress and bbPress - Version 3.0.13

Version Description

  • Add redirect in upload shortcode sponsored by Henry Wright
  • Fixed getID3 issue for FFMPEG
  • Add rtMedia JS hook for lighbox
Download this release

Release Info

Developer faishal
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 3.0.13
Comparing to
See all releases

Code changes from version 3.0.12 to 3.0.13

app/assets/js/admin.js CHANGED
@@ -57,18 +57,22 @@ jQuery(document).ready(function($) {
57
  });
58
 
59
  /* Submit Request */
60
- jQuery('.bp-media-support').on('submit', '#bp_media_settings_form', function(e) {
61
- e.preventDefault();
62
- var data = {
63
- action: 'rtmedia_submit_request',
64
- form_data: jQuery('form').serialize()
65
- };
66
 
67
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
68
- jQuery.post(ajaxurl, data, function(response) {
69
- jQuery('#bp_media_settings_form .bp-media-metabox-holder').html()
70
- jQuery('#bp_media_settings_form .bp-media-metabox-holder').html(response).fadeIn('slow');
 
 
 
 
 
 
71
  });
 
 
 
 
72
  });
73
 
74
  jQuery(document).on('click', "#bpm-services .encoding-try-now,#rtm-services .encoding-try-now", function(e) {
57
  });
58
 
59
  /* Submit Request */
 
 
 
 
 
 
60
 
61
+ jQuery('#bp-media-settings-boxes').on('submit', '#bp_media_settings_form,#rtmedia-settings-submit', function(e) {
62
+ var return_code = true;
63
+ var reg = new RegExp('^auto$|^[+-]?[0-9]+\\.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)?$')
64
+ jQuery("input[name*='defaultSizes']").each(function(el) {
65
+ if (!reg.test(jQuery(this).val())) {
66
+ alert("Invalid value for " + jQuery(this).attr('name').replace('rtmedia-options[', '').replace(']', '').replace(/_/g, ' '))
67
+ return_code = false;
68
+ return false;
69
+ }
70
+
71
  });
72
+ if (!return_code) {
73
+ e.preventDefault();
74
+ }
75
+
76
  });
77
 
78
  jQuery(document).on('click', "#bpm-services .encoding-try-now,#rtm-services .encoding-try-now", function(e) {
app/assets/js/main.js CHANGED
@@ -2,59 +2,58 @@
2
  * BuddyPress Media Default JS
3
  */
4
  //Legacy media element for old activities
5
- function bp_media_create_element(id){
6
  return false;
7
  }
8
  var $current;
9
-
10
  //window.onbeforeunload= function() { return "Custom message here"; };
11
 
12
- jQuery(document).ready(function(){
13
 
14
- jQuery('body').on('mediapreview','.bp_media_content video,.bp_media_content audio, video.bp-media-featured-media, audio.bp-media-featured-media', function(){
15
  jQuery(this).mediaelementplayer({
16
  enableKeyboard: false,
17
  startVolume: 1,
18
- success: function(mediaElement,domElement){
19
- var $thisMediaElement = (mediaElement.id) ? jQuery("#"+mediaElement.id) : jQuery(mediaElement);
20
- $thisMediaElement.parents('.mejs-container').find(".mejs-volume-current").css("top","8px");
21
- $thisMediaElement.parents('.mejs-container').find(".mejs-volume-handle").css("top","5px");
22
  }
23
  });
24
  });
25
  jQuery('.bp_media_content video,.bp_media_content audio, video.bp-media-featured-media, audio.bp-media-featured-media').trigger('mediapreview');
26
 
27
- jQuery('ul#activity-stream').on('DOMNodeInserted', function(){
28
  jQuery('ul#activity-stream .bp_media_content video,ul#activity-stream .bp_media_content audio').trigger('mediapreview');
29
  });
30
- var $id, $idtxt;
31
-
32
- jQuery('body').on('click','.bp-media-featured-media-button',function(e){
33
- e.preventDefault();
34
- $idtxt = jQuery(this).closest('.bp-media-image').attr('id');
35
- $id = $idtxt.replace('bp-media-id-','');
36
- data = {
37
- 'media_id' : $id,
38
- 'action' : 'bp_set_featured'
39
- }
40
- jQuery.get(ajaxurl,data, function(response){
41
- if ($id == response){
42
- jQuery('#'+$idtxt).find('.bp-media-featured-media-button').remove();
43
- }
44
- });
45
- })
46
-
47
-
48
- jQuery('#item-body').on('click','#bp-media-upload-button', function(){
49
  jQuery('#bp-media-move-merge-ui').slideUp();
50
  jQuery('#bp-media-delete-ui').slideUp();
51
  jQuery('#bp-media-list input').remove();
52
- jQuery('#bp-media-show-more').attr('data-move',0);
53
  $parent = jQuery('.bp-media-album-actions');
54
  $wrapper = jQuery('.bp-media-upload-wrapper');
55
  $description = jQuery('.bp-media-album-description');
56
- if($parent.length>0 && $wrapper.length<=0 ){
57
- if($description.length>0)
58
  $description.after('<div class="bp-media-action-wrapper bp-media-upload-wrapper"></div>');
59
  else
60
  $parent.after('<div class="bp-media-action-wrapper bp-media-upload-wrapper"></div>');
@@ -63,99 +62,99 @@ jQuery(document).ready(function(){
63
  jQuery('#bp-media-upload-ui').slideToggle();
64
  });
65
 
66
- jQuery('#item-body').on('click','#bp-media-move-merge-button', function(){
67
  jQuery('#bp-media-upload-ui').slideUp();
68
  jQuery('#bp-media-delete-ui').slideUp();
69
  $parent = jQuery('.bp-media-album-actions');
70
  $wrapper = jQuery('.bp-media-move-merge-wrapper');
71
  $description = jQuery('.bp-media-album-description');
72
- if($parent.length>0 && $wrapper.length<=0 ){
73
- if($description.length>0)
74
  $description.after('<div class="bp-media-action-wrapper bp-media-move-merge-wrapper"></div>');
75
  else
76
  $parent.after('<div class="bp-media-action-wrapper bp-media-move-merge-wrapper"></div>');
77
  jQuery('#bp-media-move-merge-ui').appendTo('.bp-media-move-merge-wrapper');
78
  }
79
- jQuery('#bp-media-move-merge-ui').slideToggle('slow',function(){
80
- if(jQuery(this).css('display') == 'none' || jQuery('#bp-media-move-merge-select option:checked').val() == 'merge') {
81
  jQuery('#bp-media-list input').remove();
82
- jQuery('#bp-media-show-more').attr('data-move',0);
83
- } else if ( !jQuery('#bp-media-list input').length ) {
84
- jQuery('#bp-media-show-more').attr('data-move',1);
85
- jQuery('#bp-media-list h3').each(function(){
86
- $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-','');
87
- jQuery(this).prepend('<input type="checkbox" name="move" value="'+$media_id+'" />');
88
  });
89
  }
90
  });
91
  });
92
 
93
- jQuery('#item-body').on('click','#bp-media-delete-button', function(){
94
  jQuery('#bp-media-upload-ui').slideUp();
95
  jQuery('#bp-media-move-merge-ui').slideUp();
96
  $parent = jQuery('.bp-media-album-actions');
97
  $wrapper = jQuery('.bp-media-delete-wrapper');
98
  $description = jQuery('.bp-media-album-description');
99
- if($parent.length>0 && $wrapper.length<=0 ){
100
- if($description.length>0)
101
  $description.after('<div class="bp-media-action-wrapper bp-media-delete-wrapper"></div>');
102
  else
103
  $parent.after('<div class="bp-media-action-wrapper bp-media-delete-wrapper"></div>');
104
  jQuery('#bp-media-delete-ui').appendTo('.bp-media-delete-wrapper');
105
  }
106
- jQuery('#bp-media-delete-ui').slideToggle('slow',function(){
107
- if(jQuery(this).css('display') == 'none') {
108
  jQuery('#bp-media-list input').remove();
109
- jQuery('#bp-media-show-more').attr('data-move',0);
110
- } else if ( !jQuery('#bp-media-list input').length ) {
111
- jQuery('#bp-media-show-more').attr('data-move',1);
112
- jQuery('#bp-media-list h3').each(function(){
113
- $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-','');
114
- jQuery(this).prepend('<input type="checkbox" name="move" value="'+$media_id+'" />');
115
  });
116
  }
117
  });
118
  });
119
 
120
- jQuery('.rtmedia-container').on('click','.select-all', function(e){
121
  e.preventDefault();
122
- jQuery('.rtmedia-list input').each(function(){
123
- jQuery(this).prop('checked',true);
124
  });
125
  });
126
 
127
- jQuery('.rtmedia-container').on('click','.unselect-all', function(e){
128
  e.preventDefault();
129
- jQuery('.rtmedia-list input').each(function(){
130
- jQuery(this).prop('checked',false);
131
  });
132
  });
133
 
134
- jQuery('#bp-media-move-merge-ui').on('change','#bp-media-move-merge-select', function(){
135
  $this = jQuery(this);
136
- if ( $this.val() == 'move' ) {
137
- if ( !jQuery('#bp-media-list input').length ) {
138
- jQuery('#bp-media-list h3').each(function(){
139
- $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-','');
140
- jQuery(this).prepend('<input type="checkbox" name="move" value="'+$media_id+'" />');
141
  });
142
  }
143
- jQuery('#bp-media-show-more').attr('data-move',1);
144
  jQuery('.bp-media-move-selected-checks').fadeIn();
145
- } else if ( $this.val() == 'merge' ) {
146
  jQuery('.bp-media-move-selected-checks').fadeOut();
147
  jQuery('#bp-media-list input').remove();
148
- jQuery('#bp-media-show-more').attr('data-move',0)
149
  }
150
  });
151
 
152
- jQuery('#bp-media-move-merge-ui').on('click','#bp-media-move-merge-media',function(){
153
  jQuery(this).siblings('.bp-media-ajax-spinner').show();
154
- jQuery(this).prop('disabled',true);
155
  jQuery(this).addClass('disabled');
156
  $val = jQuery('#bp-media-move-merge-select option:checked').val();
157
- if ( $val == 'merge' ) {
158
- if(confirm(bp_media_main_strings.merge_confirmation)){
159
  $delete_album = false;
160
  // if ( jQuery('.bp-media-can-delete').length ) {
161
  // if(confirm(bp_media_main_strings.delete_after_merge))
@@ -163,7 +162,7 @@ jQuery(document).ready(function(){
163
  // }
164
  $from = jQuery('#bp-media-selected-album').val();
165
  $to = jQuery('.bp-media-selected-album-move-merge option:checked').val();
166
- if ( $from && $to ) {
167
  var data = {
168
  action: 'bp_media_merge_album',
169
  from: $from,
@@ -171,10 +170,10 @@ jQuery(document).ready(function(){
171
  delete_album: $delete_album
172
  };
173
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
174
- if(response.length==0) {
175
- jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>'+bp_media_main_strings.something_went_wrong+'</p></div>');
176
- } else if( response == 'redirect' ) {
177
- window.location = window.location.href.replace($from,$to);
178
  } else {
179
  location.reload();
180
  }
@@ -182,96 +181,96 @@ jQuery(document).ready(function(){
182
  }
183
  } else {
184
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
185
- jQuery(this).prop('disabled',false);
186
  jQuery(this).removeClass('disabled');
187
  return false;
188
  }
189
- } else if( $val == 'move' ) {
190
  $media = new Array();
191
- jQuery('input:checkbox[name="move"]:checked').each(function(){
192
  $media.push(jQuery(this).val());
193
  });
194
  if ($media.length) {
195
- if(confirm(bp_media_main_strings.are_you_sure)){
196
  var data = {
197
  action: 'bp_media_move_selected_media',
198
  media: $media,
199
  parent: jQuery('.bp-media-selected-album-move-merge option:checked').val()
200
  };
201
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
202
- if(response.length==0) {
203
- jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>'+bp_media_main_strings.something_went_wrong+'</p></div>');
204
  } else {
205
  location.reload();
206
  }
207
  });
208
  } else {
209
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
210
- jQuery(this).prop('disabled',false);
211
  jQuery(this).removeClass('disabled');
212
  }
213
  } else {
214
  alert(bp_media_main_strings.select_media);
215
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
216
- jQuery(this).prop('disabled',false);
217
  jQuery(this).removeClass('disabled');
218
  }
219
  } else {
220
  alert(bp_media_main_strings.select_action);
221
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
222
- jQuery(this).prop('disabled',false);
223
  jQuery(this).removeClass('disabled');
224
  return false;
225
  }
226
 
227
  });
228
 
229
- jQuery('#bp-media-delete-ui').on('click','#bp-media-delete-media',function(){
230
  jQuery(this).siblings('.bp-media-ajax-spinner').show();
231
- jQuery(this).prop('disabled',true);
232
  jQuery(this).addClass('disabled');
233
  $media = new Array();
234
- jQuery('input:checkbox[name="move"]:checked').each(function(){
235
  $media.push(jQuery(this).val());
236
  });
237
  if ($media.length) {
238
- if(confirm(bp_media_main_strings.delete_selected_media)){
239
  var data = {
240
  action: 'bp_media_delete_selected_media',
241
  media: $media
242
  };
243
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
244
- if(response.length==0) {
245
- jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>'+bp_media_main_strings.something_went_wrong+'</p></div>');
246
  } else {
247
  location.reload();
248
  }
249
  });
250
  } else {
251
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
252
- jQuery(this).prop('disabled',false);
253
  jQuery(this).removeClass('disabled');
254
  return false;
255
  }
256
  } else {
257
  alert(bp_media_main_strings.select_media);
258
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
259
- jQuery(this).prop('disabled',false);
260
  jQuery(this).removeClass('disabled');
261
  }
262
  });
263
 
264
- jQuery('#bp-media-upload-ui').bind('dragover', function(e){
265
  jQuery(this).addClass('hover');
266
  return 0;
267
  });
268
- jQuery('#bp-media-upload-ui').bind('dragleave', function(e){
269
  jQuery(this).removeClass('hover');
270
  return 0;
271
  });
272
 
273
  var bp_media_recent_tabs = jQuery('.media-tabs-container-tabs');
274
- if(bp_media_recent_tabs.length>0){
275
  jQuery(bp_media_recent_tabs).tabs();
276
  }
277
 
@@ -279,115 +278,115 @@ jQuery(document).ready(function(){
279
  jQuery('#recent-media-tabs .bp-media-tab-panel').each(function() {
280
 
281
  var thisHeight = jQuery(this).height();
282
- if(thisHeight > tallest) {
283
  tallest = thisHeight;
284
  }
285
  }).height(tallest);
286
 
287
 
288
- jQuery('#bp-media-show-more').click(function(e){
289
  e.preventDefault();
290
  var data = load_more_data();
291
  jQuery.get(bp_media_vars.ajaxurl, data, function(response) {
292
- if(response.length==0)
293
  jQuery('#bp-media-show-more').parent().remove();
294
  else
295
  jQuery('.bp-media-gallery').append(response);
296
  });
297
  });
298
 
299
- jQuery('#bp-media-show-more-sc').click(function(e){
300
  e.preventDefault();
301
  $this = jQuery(this);
302
  $this.prop("disabled", true);
303
  var data = {
304
  action: 'bp_media_load_more_sc',
305
- page: parseInt($this.attr('data-page'))+1,
306
- media:$this.attr('data-media'),
307
- count:$this.attr('data-count'),
308
- title:$this.attr('data-title')
309
  };
310
  jQuery.get(bp_media_vars.ajaxurl, data, function(response) {
311
- if(response.length==0) {
312
  jQuery('#bp-media-show-more-sc').parent().remove();
313
- }else{
314
  $this.prop("disabled", false);
315
- $this.attr('data-page',parseInt($this.attr('data-page'))+1);
316
  jQuery('.bp-media-gallery').append(response);
317
  }
318
  });
319
  });
320
- setTimeout(function(){
321
- jQuery('.media album_updated .delete-activity,.media_upload .delete-activity').unbind('click').click(function(e){
322
- if(confirm(bp_media_main_strings.delete_activity_media)){
323
  return true;
324
  }
325
- else{
326
  return false;
327
  }
328
  });
329
 
330
- },1000);
331
 
332
  /* Add Featured Image */
333
- jQuery('.bp-media-image').on('click','.bp-media-featured',function(e){
334
  e.preventDefault();
335
  var post_id = jQuery(this).attr('data-post-id');
336
  var album_id = jQuery(this).attr('data-album-id');
337
  var curr_obj = jQuery(this);
338
  var data = {
339
  action: 'bp_media_set_album_cover',
340
- post_id:post_id,
341
- album_id:album_id
342
  };
343
- jQuery.get(bp_media_vars.ajaxurl,data,function( response )
344
  {
345
  curr_obj.text(response);
346
- curr_obj.attr('title',response);
347
  }
348
  );
349
  });
350
 
351
- if ( bp_media_vars.lightbox > 0 && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) ) {
352
 
353
- jQuery('#bp-media-list,.widget-item-listing,.bp-media-sc-list').on('click','li a',function(e){
354
  e.preventDefault();
355
  $current = jQuery(this);
356
  load_media($current);
357
  });
358
  jQuery('ul#activity-stream').on('click',
359
- 'li.media.album_updated ul li a, ul.bp-media-list-media li a, li.activity-item div.activity-content div.activity-inner div.bp_media_content a',function(e){
360
- e.preventDefault();
361
- $current = jQuery(this);
362
- load_media($current);
363
- });
364
- jQuery('body').on('click','a.modal-next', function(e){
365
  e.preventDefault();
366
- if(!$current.parent().hasClass('bp_media_content')){
367
  $next_current = $current.closest('li').next().find('a');
368
- if($next_current.length<1){
369
- if(jQuery('#bp-media-show-more').length>0){
370
  var args = load_more_data();
371
  var request = jQuery.get(bp_media_vars.ajaxurl, args);
372
- chained = request.then(function( data ) {
373
- if(data.length==0){
374
  jQuery('#bp-media-show-more').parent().remove();
375
  return false;
376
- }else{
377
  jQuery('#bp-media-list').append(data);
378
  return true;
379
  }
380
  });
381
 
382
- chained.done(function( truth ) {
383
- if(truth!=false){
384
  $next_current = $current.closest('li').next().find('a');
385
  $current = $next_current;
386
  transit_media($current);
387
  }
388
  });
389
  }
390
- }else{
391
  $current = $next_current;
392
  transit_media($next_current);
393
  }
@@ -395,17 +394,17 @@ jQuery(document).ready(function(){
395
 
396
 
397
  });
398
- jQuery('body').on('click','a.modal-prev', function(e){
399
  e.preventDefault();
400
- if(!$current.parent().hasClass('bp_media_content')){
401
- if($current.closest('li').prev().length>0 && $current.closest('li').prev().find('#bp-media-upload-ui').length<1 ){
402
  $current = $current.closest('li').prev().find('a');
403
 
404
  transit_media($current);
405
  }
406
  }
407
  });
408
- jQuery(document.documentElement).keyup(function (event) {
409
  if (event.keyCode == 37) {
410
  jQuery('a.modal-prev').trigger('click');
411
  } else if (event.keyCode == 39) {
@@ -413,25 +412,25 @@ jQuery(document).ready(function(){
413
  }
414
  });
415
 
416
- function load_media($current){
417
- jQuery.get($current.attr('href'),function(response){
418
  $mediacontent = jQuery(response).find('.bp-media-single');
419
  $medialoaded = jQuery('<div class="bp-media-ajax-single"></div>');
420
  $medialoaded.append($mediacontent);
421
- jQuery.modal($medialoaded,{
422
- 'zIndex':99999,
423
- 'autoResize':true,
424
  'opacity': 90
425
  });
426
  do_fixes($medialoaded);
427
  jQuery('.bp_media_content video,.bp_media_content audio').trigger('mediapreview');
428
  });
429
  }
430
- function transit_media($current){
431
  $medialoaded = jQuery('.bp-media-ajax-single');
432
  $medialoaded.empty();
433
- $medialoaded.append( jQuery('<div class="lightbox-spinner" />'));
434
- jQuery.get($current.attr('href'),function(response){
435
  $mediacontent = jQuery(response).find('.bp-media-single');
436
  $medialoaded = jQuery('.bp-media-ajax-single');
437
  $medialoaded.empty();
@@ -441,58 +440,58 @@ jQuery(document).ready(function(){
441
  });
442
  }
443
 
444
- function do_fixes($medialoaded){
445
  $medialoaded.find('.bp-media-content-wrap').append('<a class="modal-prev modal-ctrl"><span class="img-icon"></span></a><a class="modal-next modal-ctrl"><span class="img-icon"></span></a>');
446
  $medialoaded.find('.bp_media_description').remove();
447
  $image = $medialoaded.find('.bp-media-content-wrap .bp_media_content img');
448
- if($image.length<1){
449
  $image = $medialoaded.find('.bp-media-content-wrap .bp_media_content video');
450
  $dimensions = adjust_dimensions($image);
451
  adjust_comment_div($dimensions[0]);
452
- jQuery.modal.update($dimensions[0],$dimensions[1]);
453
  }
454
  $form = $medialoaded.find('form.ac-form');
455
- if($form.length>0){
456
  $form.find('.ac-reply-avatar').remove();
457
- $form.html($form.html().replace('&nbsp; or press esc to cancel.',''));
458
  }
459
- $image.load(function(){
460
  $dimensions = adjust_dimensions($image);
461
  adjust_comment_div($dimensions[0]);
462
- jQuery.modal.update($dimensions[0],$dimensions[1]);
463
  })
464
  }
465
 
466
- function adjust_dimensions($image){
467
- $height = ($image.height()>480)?$image.height():480;
468
- $width = ($image.width()>640)?$image.width():640;
469
- $width = $width +280;
470
  $image.hide();
471
  $image.show();
472
- return [$height,$width];
473
 
474
  }
475
 
476
- function adjust_comment_div($height){
477
  $medialoaded.find('.bp-media-meta-content-wrap').css({
478
  'height': $height,
479
- 'overflow':'auto'
480
  });
481
  }
482
- function load_more_data(){
483
  if (jQuery('#bp-media-show-more').attr('data-move') == 1)
484
  $move = 1;
485
  else
486
  $move = 0;
487
  var data = {
488
  action: 'bp_media_load_more',
489
- page:++bp_media_vars.page,
490
- current_action : bp_media_vars.current_action,
491
- action_variables : bp_media_vars.action_variables,
492
- displayed_user : bp_media_vars.displayed_user,
493
- loggedin_user : bp_media_vars.loggedin_user,
494
- current_group : bp_media_vars.current_group,
495
- move : $move
496
  };
497
  return data;
498
  }
@@ -507,30 +506,30 @@ jQuery(document).ready(function(){
507
  // bp_legacy_theme_hide_comments();
508
 
509
  jQuery('.bp-media-image-editor').bind('DOMNodeInserted DOMNodeRemoved', function(event) {
510
- $id = jQuery('.bp-media-image-editor').attr('id').replace('image-editor-','');
511
- if (!jQuery('#imgedit-save-target-'+$id).length){
512
- jQuery('#imgedit-y-'+$id).after('<p id="imgedit-save-target-'+$id+'" style="display: none;"><input type="checkbox" style="display:none;" checked="checked" name="imgedit-target-'+$id+'" value="all"></p>');
513
  }
514
  });
515
 
516
  /* Activity list event delegation */
517
- jQuery('body').on( 'click', '.bp-media-ajax-single div.activity',function(event) {
518
  var target = jQuery(event.target);
519
- if ( target.hasClass('bp-media-featured') ) {
520
  var post_id = target.attr('data-post-id');
521
  var album_id = target.attr('data-album-id');
522
  var data = {
523
  action: 'bp_media_set_album_cover',
524
- post_id:post_id,
525
- album_id:album_id
526
  };
527
  target.addClass('loading');
528
- jQuery.get(bp_media_vars.ajaxurl,data,function( response )
529
  {
530
  target.removeClass('loading');
531
- target.fadeOut( 200, function() {
532
  jQuery(this).html(response);
533
- jQuery(this).attr('title',response);
534
  jQuery(this).fadeIn(200);
535
  });
536
 
@@ -539,15 +538,15 @@ jQuery(document).ready(function(){
539
  }
540
 
541
  /* Favoriting activity stream items */
542
- if ( target.hasClass('fav') || target.hasClass('unfav') ) {
543
  event.preventDefault();
544
  var type = target.hasClass('fav') ? 'fav' : 'unfav';
545
  var parent = target.closest('.activity_update');
546
- var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
547
 
548
  target.addClass('loading');
549
 
550
- jQuery.post( ajaxurl, {
551
  action: 'activity_mark_' + type,
552
  'cookie': encodeURIComponent(document.cookie),
553
  'id': parent_id
@@ -555,100 +554,100 @@ jQuery(document).ready(function(){
555
  function(response) {
556
  target.removeClass('loading');
557
 
558
- target.fadeOut( 200, function() {
559
  jQuery(this).html(response);
560
  jQuery(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
561
  jQuery(this).fadeIn(200);
562
  });
563
 
564
- if ( 'fav' == type ) {
565
- if ( !jQuery('.item-list-tabs #activity-favorites').length )
566
- jQuery('.item-list-tabs ul #activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
567
 
568
  target.removeClass('fav');
569
  target.addClass('unfav');
570
 
571
- jQuery('.item-list-tabs ul #activity-favorites span').html( Number( jQuery('.item-list-tabs ul #activity-favorites span').html() ) + 1 );
572
  } else {
573
  target.removeClass('unfav');
574
  target.addClass('fav');
575
 
576
- jQuery('.item-list-tabs ul #activity-favorites span').html( Number( jQuery('.item-list-tabs ul #activity-favorites span').html() ) - 1 );
577
 
578
- if ( !Number( jQuery('.item-list-tabs ul #activity-favorites span').html() ) ) {
579
- if ( jQuery('.item-list-tabs ul #activity-favorites').hasClass('selected') )
580
- bp_activity_request( null, null );
581
 
582
  jQuery('.item-list-tabs ul #activity-favorites').remove();
583
  }
584
  }
585
 
586
- if ( 'activity-favorites' == jQuery( '.item-list-tabs li.selected').attr('id') )
587
  target.parent().parent().parent().slideUp(100);
588
  });
589
 
590
  return false;
591
  }
592
  /* Comment / comment reply links */
593
- if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) {
594
- if ( target.parent().hasClass('acomment-reply') )
595
  target = target.parent();
596
 
597
  var id = target.attr('id');
598
  ids = id.split('-');
599
 
600
  var a_id = ids[2]
601
- var c_id = target.attr('href').substr( 10, target.attr('href').length );
602
- var form = jQuery( '.bp-media-ajax-single #ac-form-' + a_id );
603
 
604
- form.css( 'display', 'none' );
605
  form.removeClass('root');
606
  jQuery('.ac-form').hide();
607
 
608
  /* Hide any error messages */
609
- form.children('div').each( function() {
610
- if ( jQuery(this).hasClass( 'error' ) )
611
  jQuery(this).hide();
612
  });
613
 
614
 
615
- if ( ids[1] != 'comment' ) {
616
- jQuery('.bp-media-ajax-single #acomment-' + c_id).append( form );
617
  } else {
618
- jQuery('.bp-media-ajax-single #activity-' + a_id + ' .activity-comments').append( form );
619
  }
620
 
621
- if ( form.parent().hasClass( 'activity-comments' ) )
622
  form.addClass('root');
623
 
624
- form.slideDown( 200 );
625
- jQuery.scrollTo( form, 500, {
626
- offset:-100,
627
- easing:'easeOutQuad'
628
- } );
629
  jQuery('.bp-media-ajax-single #ac-form-' + ids[2] + ' textarea').focus();
630
 
631
  return false;
632
  }
633
 
634
  /* Activity comment posting */
635
- if ( target.attr('name') == 'ac_form_submit' ) {
636
- var form = target.closest( 'form' );
637
  var form_parent = form.parent();
638
  var form_id = form.attr('id').split('-');
639
 
640
- if ( !form_parent.hasClass('activity-comments') ) {
641
  var tmp_id = form_parent.attr('id').split('-');
642
  var comment_id = tmp_id[1];
643
  } else {
644
  var comment_id = form_id[2];
645
  }
646
 
647
- var content = jQuery( target.closest('.ac-reply-content').find('textarea') );
648
  // var content = jQuery( target.closest())'#' + form.attr('id') + ' textarea' );
649
 
650
  /* Hide any error messages */
651
- jQuery( '.bp-media-ajax-single #' + form.attr('id') + ' div.error').hide();
652
  target.addClass('loading').prop('disabled', true);
653
  content.addClass('loading').prop('disabled', true);
654
 
@@ -663,22 +662,22 @@ jQuery(document).ready(function(){
663
 
664
  // Akismet
665
  var ak_nonce = jQuery('#_bp_as_nonce_' + comment_id).val();
666
- if ( ak_nonce ) {
667
  ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
668
  }
669
 
670
- jQuery.post( ajaxurl, ajaxdata, function(response) {
671
  target.removeClass('loading');
672
  content.removeClass('loading');
673
 
674
  /* Check for errors and append if found. */
675
- if ( response[0] + response[1] == '-1' ) {
676
- form.append( jQuery( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
677
  } else {
678
- form.fadeOut( 200, function() {
679
  form_parent_id = jQuery('#' + form.parent().attr('id'));
680
- if ( 0 == form.parent().children('ul').length ) {
681
- if ( form.parent().hasClass('activity-comments') ) {
682
  form_parent_id.prepend('<ul></ul>');
683
  } else {
684
  form_parent_id.parent().append('<ul></ul>');
@@ -686,19 +685,19 @@ jQuery(document).ready(function(){
686
  }
687
 
688
  /* Preceeding whitespace breaks output with jQuery 1.9.0 */
689
- var the_comment = jQuery.trim( response );
690
  //var addnl_comment = jQuery.trim( response );
691
 
692
  //form.parent().children('ul').append( jQuery( the_comment ).hide().fadeIn( 200 ) );
693
- form_parent_id.children('ul').append( jQuery( the_comment ).hide().fadeIn( 200 ) );
694
 
695
  form.children('textarea').val('');
696
  form.parent().parent().addClass('has-comments');
697
- } );
698
- jQuery( '.bp-media-ajax-single #' + form.attr('id') + ' textarea').val('');
699
 
700
  /* Increase the "Reply (X)" button count */
701
- jQuery('.bp-media-ajax-single #activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jQuery('#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
702
  }
703
 
704
  jQuery(target).prop("disabled", false);
@@ -709,7 +708,7 @@ jQuery(document).ready(function(){
709
  }
710
 
711
  /* Deleting an activity comment */
712
- if ( target.hasClass('acomment-delete') ) {
713
  var link_href = target.attr('href');
714
  var comment_li = target.parent().parent();
715
  var form = comment_li.parents('div.activity-comments').children('form');
@@ -729,7 +728,7 @@ jQuery(document).ready(function(){
729
  /* Reset the form position */
730
  comment_li.parents('.activity-comments').append(form);
731
 
732
- jQuery.post( ajaxurl, {
733
  action: 'delete_activity_comment',
734
  'cookie': encodeURIComponent(document.cookie),
735
  '_wpnonce': nonce,
@@ -737,24 +736,24 @@ jQuery(document).ready(function(){
737
  },
738
  function(response) {
739
  /* Check for errors and append if found. */
740
- if ( response[0] + response[1] == '-1' ) {
741
- comment_li.prepend( jQuery( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
742
  } else {
743
- var children = jQuery( '#' + comment_li.attr('id') + ' ul' ).children('li');
744
  var child_count = 0;
745
- jQuery(children).each( function() {
746
- if ( !jQuery(this).is(':hidden') )
747
  child_count++;
748
  });
749
  comment_li.fadeOut(200);
750
 
751
  /* Decrease the "Reply (X)" button count */
752
  var count_span = jQuery('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');
753
- var new_count = count_span.html() - ( 1 + child_count );
754
  count_span.html(new_count);
755
 
756
  /* If that was the last comment for the item, remove the has-comments class to clean up the styling */
757
- if ( 0 == new_count ) {
758
  jQuery(comment_li.parents('#activity-stream > li')).removeClass('has-comments');
759
  }
760
  }
@@ -764,43 +763,42 @@ jQuery(document).ready(function(){
764
  }
765
 
766
  // Spam an activity stream comment
767
- if ( target.hasClass( 'spam-activity-comment' ) ) {
768
- var link_href = target.attr( 'href' );
769
  var comment_li = target.parent().parent();
770
 
771
  target.addClass('loading');
772
 
773
  // Remove any error messages
774
- jQuery( '.activity-comments ul div.error' ).remove();
775
 
776
  // Reset the form position
777
- comment_li.parents( '.activity-comments' ).append( comment_li.parents( '.activity-comments' ).children( 'form' ) );
778
 
779
- jQuery.post( ajaxurl, {
780
  action: 'bp_spam_activity_comment',
781
- 'cookie': encodeURIComponent( document.cookie ),
782
- '_wpnonce': link_href.split( '_wpnonce=' )[1],
783
- 'id': link_href.split( 'cid=' )[1].split( '&' )[0]
784
  },
785
-
786
- function ( response ) {
787
  // Check for errors and append if found.
788
- if ( response[0] + response[1] == '-1' ) {
789
- comment_li.prepend( jQuery( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
790
 
791
  } else {
792
- var children = jQuery( '#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' );
793
  var child_count = 0;
794
- jQuery(children).each( function() {
795
- if ( !jQuery( this ).is( ':hidden' ) ) {
796
  child_count++;
797
  }
798
  });
799
- comment_li.fadeOut( 200 );
800
 
801
  // Decrease the "Reply (X)" button count
802
- var parent_li = comment_li.parents( '#activity-stream > li' );
803
- jQuery( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jQuery( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) );
804
  }
805
  });
806
 
@@ -808,14 +806,14 @@ jQuery(document).ready(function(){
808
  }
809
 
810
  /* Showing hidden comments - pause for half a second */
811
- if ( target.parent().hasClass('show-all') ) {
812
  target.parent().addClass('loading');
813
 
814
- setTimeout( function() {
815
  target.parent().parent().children('li').fadeIn(200, function() {
816
  target.parent().remove();
817
  });
818
- }, 600 );
819
 
820
  return false;
821
  }
@@ -823,7 +821,7 @@ jQuery(document).ready(function(){
823
 
824
  }
825
 
826
- jQuery('.rtmedia-item-thumbnail a').magnificPopup({type:'ajax'});
827
 
828
  });
829
 
2
  * BuddyPress Media Default JS
3
  */
4
  //Legacy media element for old activities
5
+ function bp_media_create_element(id) {
6
  return false;
7
  }
8
  var $current;
 
9
  //window.onbeforeunload= function() { return "Custom message here"; };
10
 
11
+ jQuery(document).ready(function() {
12
 
13
+ jQuery('body').on('mediapreview', '.bp_media_content video,.bp_media_content audio, video.bp-media-featured-media, audio.bp-media-featured-media', function() {
14
  jQuery(this).mediaelementplayer({
15
  enableKeyboard: false,
16
  startVolume: 1,
17
+ success: function(mediaElement, domElement) {
18
+ var $thisMediaElement = (mediaElement.id) ? jQuery("#" + mediaElement.id) : jQuery(mediaElement);
19
+ $thisMediaElement.parents('.mejs-container').find(".mejs-volume-current").css("top", "8px");
20
+ $thisMediaElement.parents('.mejs-container').find(".mejs-volume-handle").css("top", "5px");
21
  }
22
  });
23
  });
24
  jQuery('.bp_media_content video,.bp_media_content audio, video.bp-media-featured-media, audio.bp-media-featured-media').trigger('mediapreview');
25
 
26
+ jQuery('ul#activity-stream').on('DOMNodeInserted', function() {
27
  jQuery('ul#activity-stream .bp_media_content video,ul#activity-stream .bp_media_content audio').trigger('mediapreview');
28
  });
29
+ var $id, $idtxt;
30
+
31
+ jQuery('body').on('click', '.bp-media-featured-media-button', function(e) {
32
+ e.preventDefault();
33
+ $idtxt = jQuery(this).closest('.bp-media-image').attr('id');
34
+ $id = $idtxt.replace('bp-media-id-', '');
35
+ data = {
36
+ 'media_id': $id,
37
+ 'action': 'bp_set_featured'
38
+ }
39
+ jQuery.get(ajaxurl, data, function(response) {
40
+ if ($id == response) {
41
+ jQuery('#' + $idtxt).find('.bp-media-featured-media-button').remove();
42
+ }
43
+ });
44
+ })
45
+
46
+
47
+ jQuery('#item-body').on('click', '#bp-media-upload-button', function() {
48
  jQuery('#bp-media-move-merge-ui').slideUp();
49
  jQuery('#bp-media-delete-ui').slideUp();
50
  jQuery('#bp-media-list input').remove();
51
+ jQuery('#bp-media-show-more').attr('data-move', 0);
52
  $parent = jQuery('.bp-media-album-actions');
53
  $wrapper = jQuery('.bp-media-upload-wrapper');
54
  $description = jQuery('.bp-media-album-description');
55
+ if ($parent.length > 0 && $wrapper.length <= 0) {
56
+ if ($description.length > 0)
57
  $description.after('<div class="bp-media-action-wrapper bp-media-upload-wrapper"></div>');
58
  else
59
  $parent.after('<div class="bp-media-action-wrapper bp-media-upload-wrapper"></div>');
62
  jQuery('#bp-media-upload-ui').slideToggle();
63
  });
64
 
65
+ jQuery('#item-body').on('click', '#bp-media-move-merge-button', function() {
66
  jQuery('#bp-media-upload-ui').slideUp();
67
  jQuery('#bp-media-delete-ui').slideUp();
68
  $parent = jQuery('.bp-media-album-actions');
69
  $wrapper = jQuery('.bp-media-move-merge-wrapper');
70
  $description = jQuery('.bp-media-album-description');
71
+ if ($parent.length > 0 && $wrapper.length <= 0) {
72
+ if ($description.length > 0)
73
  $description.after('<div class="bp-media-action-wrapper bp-media-move-merge-wrapper"></div>');
74
  else
75
  $parent.after('<div class="bp-media-action-wrapper bp-media-move-merge-wrapper"></div>');
76
  jQuery('#bp-media-move-merge-ui').appendTo('.bp-media-move-merge-wrapper');
77
  }
78
+ jQuery('#bp-media-move-merge-ui').slideToggle('slow', function() {
79
+ if (jQuery(this).css('display') == 'none' || jQuery('#bp-media-move-merge-select option:checked').val() == 'merge') {
80
  jQuery('#bp-media-list input').remove();
81
+ jQuery('#bp-media-show-more').attr('data-move', 0);
82
+ } else if (!jQuery('#bp-media-list input').length) {
83
+ jQuery('#bp-media-show-more').attr('data-move', 1);
84
+ jQuery('#bp-media-list h3').each(function() {
85
+ $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-', '');
86
+ jQuery(this).prepend('<input type="checkbox" name="move" value="' + $media_id + '" />');
87
  });
88
  }
89
  });
90
  });
91
 
92
+ jQuery('#item-body').on('click', '#bp-media-delete-button', function() {
93
  jQuery('#bp-media-upload-ui').slideUp();
94
  jQuery('#bp-media-move-merge-ui').slideUp();
95
  $parent = jQuery('.bp-media-album-actions');
96
  $wrapper = jQuery('.bp-media-delete-wrapper');
97
  $description = jQuery('.bp-media-album-description');
98
+ if ($parent.length > 0 && $wrapper.length <= 0) {
99
+ if ($description.length > 0)
100
  $description.after('<div class="bp-media-action-wrapper bp-media-delete-wrapper"></div>');
101
  else
102
  $parent.after('<div class="bp-media-action-wrapper bp-media-delete-wrapper"></div>');
103
  jQuery('#bp-media-delete-ui').appendTo('.bp-media-delete-wrapper');
104
  }
105
+ jQuery('#bp-media-delete-ui').slideToggle('slow', function() {
106
+ if (jQuery(this).css('display') == 'none') {
107
  jQuery('#bp-media-list input').remove();
108
+ jQuery('#bp-media-show-more').attr('data-move', 0);
109
+ } else if (!jQuery('#bp-media-list input').length) {
110
+ jQuery('#bp-media-show-more').attr('data-move', 1);
111
+ jQuery('#bp-media-list h3').each(function() {
112
+ $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-', '');
113
+ jQuery(this).prepend('<input type="checkbox" name="move" value="' + $media_id + '" />');
114
  });
115
  }
116
  });
117
  });
118
 
119
+ jQuery('.rtmedia-container').on('click', '.select-all', function(e) {
120
  e.preventDefault();
121
+ jQuery('.rtmedia-list input').each(function() {
122
+ jQuery(this).prop('checked', true);
123
  });
124
  });
125
 
126
+ jQuery('.rtmedia-container').on('click', '.unselect-all', function(e) {
127
  e.preventDefault();
128
+ jQuery('.rtmedia-list input').each(function() {
129
+ jQuery(this).prop('checked', false);
130
  });
131
  });
132
 
133
+ jQuery('#bp-media-move-merge-ui').on('change', '#bp-media-move-merge-select', function() {
134
  $this = jQuery(this);
135
+ if ($this.val() == 'move') {
136
+ if (!jQuery('#bp-media-list input').length) {
137
+ jQuery('#bp-media-list h3').each(function() {
138
+ $media_id = jQuery(this).parent().attr('id').replace('bp-media-item-', '');
139
+ jQuery(this).prepend('<input type="checkbox" name="move" value="' + $media_id + '" />');
140
  });
141
  }
142
+ jQuery('#bp-media-show-more').attr('data-move', 1);
143
  jQuery('.bp-media-move-selected-checks').fadeIn();
144
+ } else if ($this.val() == 'merge') {
145
  jQuery('.bp-media-move-selected-checks').fadeOut();
146
  jQuery('#bp-media-list input').remove();
147
+ jQuery('#bp-media-show-more').attr('data-move', 0)
148
  }
149
  });
150
 
151
+ jQuery('#bp-media-move-merge-ui').on('click', '#bp-media-move-merge-media', function() {
152
  jQuery(this).siblings('.bp-media-ajax-spinner').show();
153
+ jQuery(this).prop('disabled', true);
154
  jQuery(this).addClass('disabled');
155
  $val = jQuery('#bp-media-move-merge-select option:checked').val();
156
+ if ($val == 'merge') {
157
+ if (confirm(bp_media_main_strings.merge_confirmation)) {
158
  $delete_album = false;
159
  // if ( jQuery('.bp-media-can-delete').length ) {
160
  // if(confirm(bp_media_main_strings.delete_after_merge))
162
  // }
163
  $from = jQuery('#bp-media-selected-album').val();
164
  $to = jQuery('.bp-media-selected-album-move-merge option:checked').val();
165
+ if ($from && $to) {
166
  var data = {
167
  action: 'bp_media_merge_album',
168
  from: $from,
170
  delete_album: $delete_album
171
  };
172
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
173
+ if (response.length == 0) {
174
+ jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>' + bp_media_main_strings.something_went_wrong + '</p></div>');
175
+ } else if (response == 'redirect') {
176
+ window.location = window.location.href.replace($from, $to);
177
  } else {
178
  location.reload();
179
  }
181
  }
182
  } else {
183
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
184
+ jQuery(this).prop('disabled', false);
185
  jQuery(this).removeClass('disabled');
186
  return false;
187
  }
188
+ } else if ($val == 'move') {
189
  $media = new Array();
190
+ jQuery('input:checkbox[name="move"]:checked').each(function() {
191
  $media.push(jQuery(this).val());
192
  });
193
  if ($media.length) {
194
+ if (confirm(bp_media_main_strings.are_you_sure)) {
195
  var data = {
196
  action: 'bp_media_move_selected_media',
197
  media: $media,
198
  parent: jQuery('.bp-media-selected-album-move-merge option:checked').val()
199
  };
200
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
201
+ if (response.length == 0) {
202
+ jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>' + bp_media_main_strings.something_went_wrong + '</p></div>');
203
  } else {
204
  location.reload();
205
  }
206
  });
207
  } else {
208
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
209
+ jQuery(this).prop('disabled', false);
210
  jQuery(this).removeClass('disabled');
211
  }
212
  } else {
213
  alert(bp_media_main_strings.select_media);
214
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
215
+ jQuery(this).prop('disabled', false);
216
  jQuery(this).removeClass('disabled');
217
  }
218
  } else {
219
  alert(bp_media_main_strings.select_action);
220
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
221
+ jQuery(this).prop('disabled', false);
222
  jQuery(this).removeClass('disabled');
223
  return false;
224
  }
225
 
226
  });
227
 
228
+ jQuery('#bp-media-delete-ui').on('click', '#bp-media-delete-media', function() {
229
  jQuery(this).siblings('.bp-media-ajax-spinner').show();
230
+ jQuery(this).prop('disabled', true);
231
  jQuery(this).addClass('disabled');
232
  $media = new Array();
233
+ jQuery('input:checkbox[name="move"]:checked').each(function() {
234
  $media.push(jQuery(this).val());
235
  });
236
  if ($media.length) {
237
+ if (confirm(bp_media_main_strings.delete_selected_media)) {
238
  var data = {
239
  action: 'bp_media_delete_selected_media',
240
  media: $media
241
  };
242
  jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
243
+ if (response.length == 0) {
244
+ jQuery('.item-list-tabs:last').after('<div id="message" class="error"><p>' + bp_media_main_strings.something_went_wrong + '</p></div>');
245
  } else {
246
  location.reload();
247
  }
248
  });
249
  } else {
250
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
251
+ jQuery(this).prop('disabled', false);
252
  jQuery(this).removeClass('disabled');
253
  return false;
254
  }
255
  } else {
256
  alert(bp_media_main_strings.select_media);
257
  jQuery(this).siblings('.bp-media-ajax-spinner').hide();
258
+ jQuery(this).prop('disabled', false);
259
  jQuery(this).removeClass('disabled');
260
  }
261
  });
262
 
263
+ jQuery('#bp-media-upload-ui').bind('dragover', function(e) {
264
  jQuery(this).addClass('hover');
265
  return 0;
266
  });
267
+ jQuery('#bp-media-upload-ui').bind('dragleave', function(e) {
268
  jQuery(this).removeClass('hover');
269
  return 0;
270
  });
271
 
272
  var bp_media_recent_tabs = jQuery('.media-tabs-container-tabs');
273
+ if (bp_media_recent_tabs.length > 0) {
274
  jQuery(bp_media_recent_tabs).tabs();
275
  }
276
 
278
  jQuery('#recent-media-tabs .bp-media-tab-panel').each(function() {
279
 
280
  var thisHeight = jQuery(this).height();
281
+ if (thisHeight > tallest) {
282
  tallest = thisHeight;
283
  }
284
  }).height(tallest);
285
 
286
 
287
+ jQuery('#bp-media-show-more').click(function(e) {
288
  e.preventDefault();
289
  var data = load_more_data();
290
  jQuery.get(bp_media_vars.ajaxurl, data, function(response) {
291
+ if (response.length == 0)
292
  jQuery('#bp-media-show-more').parent().remove();
293
  else
294
  jQuery('.bp-media-gallery').append(response);
295
  });
296
  });
297
 
298
+ jQuery('#bp-media-show-more-sc').click(function(e) {
299
  e.preventDefault();
300
  $this = jQuery(this);
301
  $this.prop("disabled", true);
302
  var data = {
303
  action: 'bp_media_load_more_sc',
304
+ page: parseInt($this.attr('data-page')) + 1,
305
+ media: $this.attr('data-media'),
306
+ count: $this.attr('data-count'),
307
+ title: $this.attr('data-title')
308
  };
309
  jQuery.get(bp_media_vars.ajaxurl, data, function(response) {
310
+ if (response.length == 0) {
311
  jQuery('#bp-media-show-more-sc').parent().remove();
312
+ } else {
313
  $this.prop("disabled", false);
314
+ $this.attr('data-page', parseInt($this.attr('data-page')) + 1);
315
  jQuery('.bp-media-gallery').append(response);
316
  }
317
  });
318
  });
319
+ setTimeout(function() {
320
+ jQuery('.media album_updated .delete-activity,.media_upload .delete-activity').unbind('click').click(function(e) {
321
+ if (confirm(bp_media_main_strings.delete_activity_media)) {
322
  return true;
323
  }
324
+ else {
325
  return false;
326
  }
327
  });
328
 
329
+ }, 1000);
330
 
331
  /* Add Featured Image */
332
+ jQuery('.bp-media-image').on('click', '.bp-media-featured', function(e) {
333
  e.preventDefault();
334
  var post_id = jQuery(this).attr('data-post-id');
335
  var album_id = jQuery(this).attr('data-album-id');
336
  var curr_obj = jQuery(this);
337
  var data = {
338
  action: 'bp_media_set_album_cover',
339
+ post_id: post_id,
340
+ album_id: album_id
341
  };
342
+ jQuery.get(bp_media_vars.ajaxurl, data, function(response)
343
  {
344
  curr_obj.text(response);
345
+ curr_obj.attr('title', response);
346
  }
347
  );
348
  });
349
 
350
+ if (bp_media_vars.lightbox > 0 && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent))) {
351
 
352
+ jQuery('#bp-media-list,.widget-item-listing,.bp-media-sc-list').on('click', 'li a', function(e) {
353
  e.preventDefault();
354
  $current = jQuery(this);
355
  load_media($current);
356
  });
357
  jQuery('ul#activity-stream').on('click',
358
+ 'li.media.album_updated ul li a, ul.bp-media-list-media li a, li.activity-item div.activity-content div.activity-inner div.bp_media_content a', function(e) {
359
+ e.preventDefault();
360
+ $current = jQuery(this);
361
+ load_media($current);
362
+ });
363
+ jQuery('body').on('click', 'a.modal-next', function(e) {
364
  e.preventDefault();
365
+ if (!$current.parent().hasClass('bp_media_content')) {
366
  $next_current = $current.closest('li').next().find('a');
367
+ if ($next_current.length < 1) {
368
+ if (jQuery('#bp-media-show-more').length > 0) {
369
  var args = load_more_data();
370
  var request = jQuery.get(bp_media_vars.ajaxurl, args);
371
+ chained = request.then(function(data) {
372
+ if (data.length == 0) {
373
  jQuery('#bp-media-show-more').parent().remove();
374
  return false;
375
+ } else {
376
  jQuery('#bp-media-list').append(data);
377
  return true;
378
  }
379
  });
380
 
381
+ chained.done(function(truth) {
382
+ if (truth != false) {
383
  $next_current = $current.closest('li').next().find('a');
384
  $current = $next_current;
385
  transit_media($current);
386
  }
387
  });
388
  }
389
+ } else {
390
  $current = $next_current;
391
  transit_media($next_current);
392
  }
394
 
395
 
396
  });
397
+ jQuery('body').on('click', 'a.modal-prev', function(e) {
398
  e.preventDefault();
399
+ if (!$current.parent().hasClass('bp_media_content')) {
400
+ if ($current.closest('li').prev().length > 0 && $current.closest('li').prev().find('#bp-media-upload-ui').length < 1) {
401
  $current = $current.closest('li').prev().find('a');
402
 
403
  transit_media($current);
404
  }
405
  }
406
  });
407
+ jQuery(document.documentElement).keyup(function(event) {
408
  if (event.keyCode == 37) {
409
  jQuery('a.modal-prev').trigger('click');
410
  } else if (event.keyCode == 39) {
412
  }
413
  });
414
 
415
+ function load_media($current) {
416
+ jQuery.get($current.attr('href'), function(response) {
417
  $mediacontent = jQuery(response).find('.bp-media-single');
418
  $medialoaded = jQuery('<div class="bp-media-ajax-single"></div>');
419
  $medialoaded.append($mediacontent);
420
+ jQuery.modal($medialoaded, {
421
+ 'zIndex': 99999,
422
+ 'autoResize': true,
423
  'opacity': 90
424
  });
425
  do_fixes($medialoaded);
426
  jQuery('.bp_media_content video,.bp_media_content audio').trigger('mediapreview');
427
  });
428
  }
429
+ function transit_media($current) {
430
  $medialoaded = jQuery('.bp-media-ajax-single');
431
  $medialoaded.empty();
432
+ $medialoaded.append(jQuery('<div class="lightbox-spinner" />'));
433
+ jQuery.get($current.attr('href'), function(response) {
434
  $mediacontent = jQuery(response).find('.bp-media-single');
435
  $medialoaded = jQuery('.bp-media-ajax-single');
436
  $medialoaded.empty();
440
  });
441
  }
442
 
443
+ function do_fixes($medialoaded) {
444
  $medialoaded.find('.bp-media-content-wrap').append('<a class="modal-prev modal-ctrl"><span class="img-icon"></span></a><a class="modal-next modal-ctrl"><span class="img-icon"></span></a>');
445
  $medialoaded.find('.bp_media_description').remove();
446
  $image = $medialoaded.find('.bp-media-content-wrap .bp_media_content img');
447
+ if ($image.length < 1) {
448
  $image = $medialoaded.find('.bp-media-content-wrap .bp_media_content video');
449
  $dimensions = adjust_dimensions($image);
450
  adjust_comment_div($dimensions[0]);
451
+ jQuery.modal.update($dimensions[0], $dimensions[1]);
452
  }
453
  $form = $medialoaded.find('form.ac-form');
454
+ if ($form.length > 0) {
455
  $form.find('.ac-reply-avatar').remove();
456
+ $form.html($form.html().replace('&nbsp; or press esc to cancel.', ''));
457
  }
458
+ $image.load(function() {
459
  $dimensions = adjust_dimensions($image);
460
  adjust_comment_div($dimensions[0]);
461
+ jQuery.modal.update($dimensions[0], $dimensions[1]);
462
  })
463
  }
464
 
465
+ function adjust_dimensions($image) {
466
+ $height = ($image.height() > 480) ? $image.height() : 480;
467
+ $width = ($image.width() > 640) ? $image.width() : 640;
468
+ $width = $width + 280;
469
  $image.hide();
470
  $image.show();
471
+ return [$height, $width];
472
 
473
  }
474
 
475
+ function adjust_comment_div($height) {
476
  $medialoaded.find('.bp-media-meta-content-wrap').css({
477
  'height': $height,
478
+ 'overflow': 'auto'
479
  });
480
  }
481
+ function load_more_data() {
482
  if (jQuery('#bp-media-show-more').attr('data-move') == 1)
483
  $move = 1;
484
  else
485
  $move = 0;
486
  var data = {
487
  action: 'bp_media_load_more',
488
+ page: ++bp_media_vars.page,
489
+ current_action: bp_media_vars.current_action,
490
+ action_variables: bp_media_vars.action_variables,
491
+ displayed_user: bp_media_vars.displayed_user,
492
+ loggedin_user: bp_media_vars.loggedin_user,
493
+ current_group: bp_media_vars.current_group,
494
+ move: $move
495
  };
496
  return data;
497
  }
506
  // bp_legacy_theme_hide_comments();
507
 
508
  jQuery('.bp-media-image-editor').bind('DOMNodeInserted DOMNodeRemoved', function(event) {
509
+ $id = jQuery('.bp-media-image-editor').attr('id').replace('image-editor-', '');
510
+ if (!jQuery('#imgedit-save-target-' + $id).length) {
511
+ jQuery('#imgedit-y-' + $id).after('<p id="imgedit-save-target-' + $id + '" style="display: none;"><input type="checkbox" style="display:none;" checked="checked" name="imgedit-target-' + $id + '" value="all"></p>');
512
  }
513
  });
514
 
515
  /* Activity list event delegation */
516
+ jQuery('body').on('click', '.bp-media-ajax-single div.activity', function(event) {
517
  var target = jQuery(event.target);
518
+ if (target.hasClass('bp-media-featured')) {
519
  var post_id = target.attr('data-post-id');
520
  var album_id = target.attr('data-album-id');
521
  var data = {
522
  action: 'bp_media_set_album_cover',
523
+ post_id: post_id,
524
+ album_id: album_id
525
  };
526
  target.addClass('loading');
527
+ jQuery.get(bp_media_vars.ajaxurl, data, function(response)
528
  {
529
  target.removeClass('loading');
530
+ target.fadeOut(200, function() {
531
  jQuery(this).html(response);
532
+ jQuery(this).attr('title', response);
533
  jQuery(this).fadeIn(200);
534
  });
535
 
538
  }
539
 
540
  /* Favoriting activity stream items */
541
+ if (target.hasClass('fav') || target.hasClass('unfav')) {
542
  event.preventDefault();
543
  var type = target.hasClass('fav') ? 'fav' : 'unfav';
544
  var parent = target.closest('.activity_update');
545
+ var parent_id = parent.attr('id').substr(9, parent.attr('id').length);
546
 
547
  target.addClass('loading');
548
 
549
+ jQuery.post(ajaxurl, {
550
  action: 'activity_mark_' + type,
551
  'cookie': encodeURIComponent(document.cookie),
552
  'id': parent_id
554
  function(response) {
555
  target.removeClass('loading');
556
 
557
+ target.fadeOut(200, function() {
558
  jQuery(this).html(response);
559
  jQuery(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
560
  jQuery(this).fadeIn(200);
561
  });
562
 
563
+ if ('fav' == type) {
564
+ if (!jQuery('.item-list-tabs #activity-favorites').length)
565
+ jQuery('.item-list-tabs ul #activity-mentions').before('<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
566
 
567
  target.removeClass('fav');
568
  target.addClass('unfav');
569
 
570
+ jQuery('.item-list-tabs ul #activity-favorites span').html(Number(jQuery('.item-list-tabs ul #activity-favorites span').html()) + 1);
571
  } else {
572
  target.removeClass('unfav');
573
  target.addClass('fav');
574
 
575
+ jQuery('.item-list-tabs ul #activity-favorites span').html(Number(jQuery('.item-list-tabs ul #activity-favorites span').html()) - 1);
576
 
577
+ if (!Number(jQuery('.item-list-tabs ul #activity-favorites span').html())) {
578
+ if (jQuery('.item-list-tabs ul #activity-favorites').hasClass('selected'))
579
+ bp_activity_request(null, null);
580
 
581
  jQuery('.item-list-tabs ul #activity-favorites').remove();
582
  }
583
  }
584
 
585
+ if ('activity-favorites' == jQuery('.item-list-tabs li.selected').attr('id'))
586
  target.parent().parent().parent().slideUp(100);
587
  });
588
 
589
  return false;
590
  }
591
  /* Comment / comment reply links */
592
+ if (target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply')) {
593
+ if (target.parent().hasClass('acomment-reply'))
594
  target = target.parent();
595
 
596
  var id = target.attr('id');
597
  ids = id.split('-');
598
 
599
  var a_id = ids[2]
600
+ var c_id = target.attr('href').substr(10, target.attr('href').length);
601
+ var form = jQuery('.bp-media-ajax-single #ac-form-' + a_id);
602
 
603
+ form.css('display', 'none');
604
  form.removeClass('root');
605
  jQuery('.ac-form').hide();
606
 
607
  /* Hide any error messages */
608
+ form.children('div').each(function() {
609
+ if (jQuery(this).hasClass('error'))
610
  jQuery(this).hide();
611
  });
612
 
613
 
614
+ if (ids[1] != 'comment') {
615
+ jQuery('.bp-media-ajax-single #acomment-' + c_id).append(form);
616
  } else {
617
+ jQuery('.bp-media-ajax-single #activity-' + a_id + ' .activity-comments').append(form);
618
  }
619
 
620
+ if (form.parent().hasClass('activity-comments'))
621
  form.addClass('root');
622
 
623
+ form.slideDown(200);
624
+ jQuery.scrollTo(form, 500, {
625
+ offset: -100,
626
+ easing: 'easeOutQuad'
627
+ });
628
  jQuery('.bp-media-ajax-single #ac-form-' + ids[2] + ' textarea').focus();
629
 
630
  return false;
631
  }
632
 
633
  /* Activity comment posting */
634
+ if (target.attr('name') == 'ac_form_submit') {
635
+ var form = target.closest('form');
636
  var form_parent = form.parent();
637
  var form_id = form.attr('id').split('-');
638
 
639
+ if (!form_parent.hasClass('activity-comments')) {
640
  var tmp_id = form_parent.attr('id').split('-');
641
  var comment_id = tmp_id[1];
642
  } else {
643
  var comment_id = form_id[2];
644
  }
645
 
646
+ var content = jQuery(target.closest('.ac-reply-content').find('textarea'));
647
  // var content = jQuery( target.closest())'#' + form.attr('id') + ' textarea' );
648
 
649
  /* Hide any error messages */
650
+ jQuery('.bp-media-ajax-single #' + form.attr('id') + ' div.error').hide();
651
  target.addClass('loading').prop('disabled', true);
652
  content.addClass('loading').prop('disabled', true);
653
 
662
 
663
  // Akismet
664
  var ak_nonce = jQuery('#_bp_as_nonce_' + comment_id).val();
665
+ if (ak_nonce) {
666
  ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
667
  }
668
 
669
+ jQuery.post(ajaxurl, ajaxdata, function(response) {
670
  target.removeClass('loading');
671
  content.removeClass('loading');
672
 
673
  /* Check for errors and append if found. */
674
+ if (response[0] + response[1] == '-1') {
675
+ form.append(jQuery(response.substr(2, response.length)).hide().fadeIn(200));
676
  } else {
677
+ form.fadeOut(200, function() {
678
  form_parent_id = jQuery('#' + form.parent().attr('id'));
679
+ if (0 == form.parent().children('ul').length) {
680
+ if (form.parent().hasClass('activity-comments')) {
681
  form_parent_id.prepend('<ul></ul>');
682
  } else {
683
  form_parent_id.parent().append('<ul></ul>');
685
  }
686
 
687
  /* Preceeding whitespace breaks output with jQuery 1.9.0 */
688
+ var the_comment = jQuery.trim(response);
689
  //var addnl_comment = jQuery.trim( response );
690
 
691
  //form.parent().children('ul').append( jQuery( the_comment ).hide().fadeIn( 200 ) );
692
+ form_parent_id.children('ul').append(jQuery(the_comment).hide().fadeIn(200));
693
 
694
  form.children('textarea').val('');
695
  form.parent().parent().addClass('has-comments');
696
+ });
697
+ jQuery('.bp-media-ajax-single #' + form.attr('id') + ' textarea').val('');
698
 
699
  /* Increase the "Reply (X)" button count */
700
+ jQuery('.bp-media-ajax-single #activity-' + form_id[2] + ' a.acomment-reply span').html(Number(jQuery('#activity-' + form_id[2] + ' a.acomment-reply span').html()) + 1);
701
  }
702
 
703
  jQuery(target).prop("disabled", false);
708
  }
709
 
710
  /* Deleting an activity comment */
711
+ if (target.hasClass('acomment-delete')) {
712
  var link_href = target.attr('href');
713
  var comment_li = target.parent().parent();
714
  var form = comment_li.parents('div.activity-comments').children('form');
728
  /* Reset the form position */
729
  comment_li.parents('.activity-comments').append(form);
730
 
731
+ jQuery.post(ajaxurl, {
732
  action: 'delete_activity_comment',
733
  'cookie': encodeURIComponent(document.cookie),
734
  '_wpnonce': nonce,
736
  },
737
  function(response) {
738
  /* Check for errors and append if found. */
739
+ if (response[0] + response[1] == '-1') {
740
+ comment_li.prepend(jQuery(response.substr(2, response.length)).hide().fadeIn(200));
741
  } else {
742
+ var children = jQuery('#' + comment_li.attr('id') + ' ul').children('li');
743
  var child_count = 0;
744
+ jQuery(children).each(function() {
745
+ if (!jQuery(this).is(':hidden'))
746
  child_count++;
747
  });
748
  comment_li.fadeOut(200);
749
 
750
  /* Decrease the "Reply (X)" button count */
751
  var count_span = jQuery('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');
752
+ var new_count = count_span.html() - (1 + child_count);
753
  count_span.html(new_count);
754
 
755
  /* If that was the last comment for the item, remove the has-comments class to clean up the styling */
756
+ if (0 == new_count) {
757
  jQuery(comment_li.parents('#activity-stream > li')).removeClass('has-comments');
758
  }
759
  }
763
  }
764
 
765
  // Spam an activity stream comment
766
+ if (target.hasClass('spam-activity-comment')) {
767
+ var link_href = target.attr('href');
768
  var comment_li = target.parent().parent();
769
 
770
  target.addClass('loading');
771
 
772
  // Remove any error messages
773
+ jQuery('.activity-comments ul div.error').remove();
774
 
775
  // Reset the form position
776
+ comment_li.parents('.activity-comments').append(comment_li.parents('.activity-comments').children('form'));
777
 
778
+ jQuery.post(ajaxurl, {
779
  action: 'bp_spam_activity_comment',
780
+ 'cookie': encodeURIComponent(document.cookie),
781
+ '_wpnonce': link_href.split('_wpnonce=')[1],
782
+ 'id': link_href.split('cid=')[1].split('&')[0]
783
  },
784
+ function(response) {
 
785
  // Check for errors and append if found.
786
+ if (response[0] + response[1] == '-1') {
787
+ comment_li.prepend(jQuery(response.substr(2, response.length)).hide().fadeIn(200));
788
 
789
  } else {
790
+ var children = jQuery('#' + comment_li.attr('id') + ' ul').children('li');
791
  var child_count = 0;
792
+ jQuery(children).each(function() {
793
+ if (!jQuery(this).is(':hidden')) {
794
  child_count++;
795
  }
796
  });
797
+ comment_li.fadeOut(200);
798
 
799
  // Decrease the "Reply (X)" button count
800
+ var parent_li = comment_li.parents('#activity-stream > li');
801
+ jQuery('#' + parent_li.attr('id') + ' a.acomment-reply span').html(jQuery('#' + parent_li.attr('id') + ' a.acomment-reply span').html() - (1 + child_count));
802
  }
803
  });
804
 
806
  }
807
 
808
  /* Showing hidden comments - pause for half a second */
809
+ if (target.parent().hasClass('show-all')) {
810
  target.parent().addClass('loading');
811
 
812
+ setTimeout(function() {
813
  target.parent().parent().children('li').fadeIn(200, function() {
814
  target.parent().remove();
815
  });
816
+ }, 600);
817
 
818
  return false;
819
  }
821
 
822
  }
823
 
824
+ jQuery('.rtmedia-item-thumbnail a').magnificPopup({type: 'ajax'});
825
 
826
  });
827
 
app/assets/js/rtMedia.backbone.js CHANGED
@@ -303,6 +303,8 @@ jQuery(function($) {
303
  });
304
  uploaderObj.uploader.bind('BeforeUpload', function(up, file) {
305
  up.settings.multipart_params.privacy = $("#rtm-file_upload-ui select#privacy").val();
 
 
306
  jQuery("#rtmedia-uploader-form input[type=hidden]").each(function() {
307
  up.settings.multipart_params[$(this).attr("name")] = $(this).val();
308
  });
@@ -314,9 +316,20 @@ jQuery(function($) {
314
  });
315
 
316
  uploaderObj.uploader.bind('FileUploaded', function(up, file, res) {
 
 
 
 
 
 
 
 
 
 
317
 
318
  files = up.files;
319
  lastfile = files[files.length - 1];
 
320
  try {
321
  var rtnObj;
322
  rtnObj = JSON.parse(res.response);
@@ -325,6 +338,7 @@ jQuery(function($) {
325
  } catch (e) {
326
  // console.log('Invalid Activity ID');
327
  }
 
328
  });
329
 
330
  $("#rtMedia-start-upload").click(function(e) {
@@ -364,11 +378,13 @@ jQuery(document).ready(function($) {
364
  $("#rtmedia-action-update").append($("#privacy"));
365
  }
366
  }
 
367
  $("#whats-new-form").on('click', '#rtmedia-add-media-button-post-update', function(e) {
368
  $("#div-attache-rtmedia").toggle();
 
369
  })
370
  //whats-new-post-in
371
- var objUploadView = new UploadView(rtMedia_update_plupload_config);
372
 
373
  objUploadView.uploader.bind('FilesAdded', function(up, files) {
374
  //$("#aw-whats-new-submit").attr('disabled', 'disabled');
303
  });
304
  uploaderObj.uploader.bind('BeforeUpload', function(up, file) {
305
  up.settings.multipart_params.privacy = $("#rtm-file_upload-ui select#privacy").val();
306
+ if (jQuery("#rt_upload_hf_redirect").length > 0)
307
+ up.settings.multipart_params.redirect = up.files.length;
308
  jQuery("#rtmedia-uploader-form input[type=hidden]").each(function() {
309
  up.settings.multipart_params[$(this).attr("name")] = $(this).val();
310
  });
316
  });
317
 
318
  uploaderObj.uploader.bind('FileUploaded', function(up, file, res) {
319
+ if (res.status == 200 || res.status == 302) {
320
+ if (uploaderObj.upload_count == undefined)
321
+ uploaderObj.upload_count = 1;
322
+ else
323
+ uploaderObj.upload_count++;
324
+
325
+ if (uploaderObj.upload_count == up.files.length && jQuery("#rt_upload_hf_redirect").length > 0 && res.response.indexOf("http") == 0) {
326
+ window.location = res.response;
327
+ }
328
+ }
329
 
330
  files = up.files;
331
  lastfile = files[files.length - 1];
332
+
333
  try {
334
  var rtnObj;
335
  rtnObj = JSON.parse(res.response);
338
  } catch (e) {
339
  // console.log('Invalid Activity ID');
340
  }
341
+
342
  });
343
 
344
  $("#rtMedia-start-upload").click(function(e) {
378
  $("#rtmedia-action-update").append($("#privacy"));
379
  }
380
  }
381
+ var objUploadView = new UploadView(rtMedia_update_plupload_config);
382
  $("#whats-new-form").on('click', '#rtmedia-add-media-button-post-update', function(e) {
383
  $("#div-attache-rtmedia").toggle();
384
+ objUploadView.uploader.refresh();
385
  })
386
  //whats-new-post-in
387
+
388
 
389
  objUploadView.uploader.bind('FilesAdded', function(up, files) {
390
  //$("#aw-whats-new-submit").attr('disabled', 'disabled');
app/assets/js/rtMedia.js CHANGED
@@ -1,4 +1,19 @@
1
  var rtMagnificPopup;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  jQuery('document').ready(function($) {
3
 
4
  $("#rt_media_comment_form").submit(function(e) {
@@ -20,7 +35,7 @@ jQuery('document').ready(function($) {
20
  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').magnificPopup({
21
  delegate: 'a:not(".no-popup")',
22
  type: 'ajax',
23
- tLoading: 'Loading image #%curr%...',
24
  mainClass: 'mfp-img-mobile',
25
  preload: [1, 3],
26
  closeOnBgClick: false,
@@ -60,10 +75,11 @@ jQuery('document').ready(function($) {
60
  settings.pluginPath = _wpmejsSettings.pluginPath;
61
 
62
  $('.mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video').mediaelementplayer(settings);
63
- $('.mfp-content .mejs-audio .mejs-controls').css('position','relative');
 
64
  },
65
  close: function(e) {
66
- console.log(e);
67
  },
68
  BeforeChange: function(e) {
69
  console.log(e);
1
  var rtMagnificPopup;
2
+ var rtMediaHook = {
3
+ hooks: [],
4
+ register: function(name, callback) {
5
+ if ('undefined' == typeof(rtMediaHook.hooks[name]))
6
+ rtMediaHook.hooks[name] = []
7
+ rtMediaHook.hooks[name].push(callback)
8
+ },
9
+ call: function(name, arguments) {
10
+ if ('undefined' != typeof(rtMediaHook.hooks[name]))
11
+ for (i = 0; i < rtMediaHook.hooks[name].length; ++i)
12
+ if (true != rtMediaHook.hooks[name][i](arguments)) {
13
+ break;
14
+ }
15
+ }
16
+ }
17
  jQuery('document').ready(function($) {
18
 
19
  $("#rt_media_comment_form").submit(function(e) {
35
  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').magnificPopup({
36
  delegate: 'a:not(".no-popup")',
37
  type: 'ajax',
38
+ tLoading: 'Loading media #%curr%...',
39
  mainClass: 'mfp-img-mobile',
40
  preload: [1, 3],
41
  closeOnBgClick: false,
75
  settings.pluginPath = _wpmejsSettings.pluginPath;
76
 
77
  $('.mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video').mediaelementplayer(settings);
78
+ $('.mfp-content .mejs-audio .mejs-controls').css('position', 'relative');
79
+ rtMediaHook.call('rtmedia_js_popup_after_content_added', []);
80
  },
81
  close: function(e) {
82
+ console.log(e);
83
  },
84
  BeforeChange: function(e) {
85
  console.log(e);
app/helper/rtDimensions.php CHANGED
@@ -12,111 +12,109 @@
12
  */
13
  class rtDimensions extends rtForm {
14
 
15
- private $element_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- private static $id_count = 0;
18
-
19
- private static $default_class = "rt-form-dimension";
20
-
21
- private function get_default_id() {
22
- return self::$id_count;
23
- }
24
-
25
- private function update_default_id() {
26
- self::$id_count ++;
27
- }
28
-
29
- private function get_default_class() {
30
- return self::$default_class;
31
- }
32
-
33
- private function embedd_class( $element, $class = null ) {
34
-
35
- $html = 'class = "' . $this->get_default_class();
36
-
37
- if( isset( $class ) ) {
38
-
39
- if( is_array( $class ) )
40
- $html .= ' ' . implode(" ", $class);
41
- else
42
- throw new rtFormsInvalidArgumentsException( "class [". $element ."]" );
43
- }
44
- $html .= '"';
45
-
46
- return $html;
47
- }
48
-
49
-
50
- protected function generate_dimensions( $attributes ) {
51
-
52
- $element = "rtDimension";
53
- global $rtmedia;
54
- $defaults = array(
55
- 'desc' => '',
56
- 'show_desc' => false
57
- );
58
-
59
- $attributes = wp_parse_args($attributes, $defaults);
60
- extract($attributes);
61
-
62
- $html = '<div ';
63
-
64
- if( isset($attributes['id']) )
65
- $html .= 'id="' . $attributes['id'] . '" ';
66
- else {
67
- $html .= 'id="' . $this->get_default_class () . '-' . $this->get_default_id () . '" ';
68
- $this->update_default_id();
69
- }
70
-
71
- if( isset($attributes['class']) )
72
- $html .= self::embedd_class($element, $attributes['class']);
73
- else
74
- $html .= self::embedd_class($element);
75
- $html .= '>';
76
-
77
- $html .= parent::get_number(array(
78
- 'name' => "rtmedia-options[{$key}_width]",
79
- 'value' => $width,
80
- 'class' => array("small-text large-offset-1"),
81
- 'show_desc' => $show_desc
82
- ));
83
-
84
- if (isset($height)) {
85
- $html .= parent::get_number(array(
86
- 'name' => "rtmedia-options[{$key}_height]",
87
- 'value' => $height,
88
- 'class' => array("small-text large-offset-1"),
89
- 'show_desc' => $show_desc
90
- ));
91
- }
92
-
93
- if(isset($crop)) {
94
- $html .= parent::get_checkbox(array(
95
- 'name' => "rtmedia-options[{$key}_crop]",
96
- 'rtForm_options' => array(array(
97
- '' => 1, //label would be blank
98
- 'checked' => $crop
99
- )),
100
- 'class' => array("large-offset-1"),
101
- 'show_desc' => $show_desc
102
- ));
103
- }
104
-
105
- if ($desc && $show_desc)
106
- $html .= '<span class="clearfix large-offset-3 description">' . $desc . '</span>';
107
-
108
- $html .= '</div>';
109
-
110
- if( isset($attributes['label']) )
111
- $html = parent::enclose_label('container', $html, $attributes['label']);
112
-
113
- return $html;
114
- }
115
-
116
- public function get_dimensions( $attributes = '' ) {
117
-
118
- return $this->generate_dimensions($attributes);
119
- }
120
  }
121
 
122
  ?>
12
  */
13
  class rtDimensions extends rtForm {
14
 
15
+ private $element_id;
16
+ private static $id_count = 0;
17
+ private static $default_class = "rt-form-dimension";
18
+
19
+ private function get_default_id () {
20
+ return self::$id_count;
21
+ }
22
+
23
+ private function update_default_id () {
24
+ self::$id_count ++;
25
+ }
26
+
27
+ private function get_default_class () {
28
+ return self::$default_class;
29
+ }
30
+
31
+ private function embedd_class ( $element, $class = null ) {
32
+
33
+ $html = 'class = "' . $this->get_default_class ();
34
+
35
+ if ( isset ( $class ) ) {
36
+
37
+ if ( is_array ( $class ) )
38
+ $html .= ' ' . implode ( " ", $class );
39
+ else
40
+ throw new rtFormsInvalidArgumentsException ( "class [" . $element . "]" );
41
+ }
42
+ $html .= '"';
43
+
44
+ return $html;
45
+ }
46
+
47
+ protected function generate_dimensions ( $attributes ) {
48
+
49
+ $element = "rtDimension";
50
+ global $rtmedia;
51
+ $defaults = array(
52
+ 'desc' => '',
53
+ 'show_desc' => false
54
+ );
55
+
56
+ $attributes = wp_parse_args ( $attributes, $defaults );
57
+ extract ( $attributes );
58
+
59
+ $html = '<div ';
60
+
61
+ if ( isset ( $attributes[ 'id' ] ) )
62
+ $html .= 'id="' . $attributes[ 'id' ] . '" ';
63
+ else {
64
+ $html .= 'id="' . $this->get_default_class () . '-' . $this->get_default_id () . '" ';
65
+ $this->update_default_id ();
66
+ }
67
+
68
+ if ( isset ( $attributes[ 'class' ] ) )
69
+ $html .= self::embedd_class ( $element, $attributes[ 'class' ] );
70
+ else
71
+ $html .= self::embedd_class ( $element );
72
+ $html .= '>';
73
+
74
+ $html .= parent::get_textbox ( array(
75
+ 'name' => "rtmedia-options[{$key}_width]",
76
+ 'value' => $width,
77
+ 'class' => array( "small-text large-offset-1" ),
78
+ 'show_desc' => $show_desc
79
+ ) );
80
+
81
+ if ( isset ( $height ) ) {
82
+ $html .= parent::get_textbox ( array(
83
+ 'name' => "rtmedia-options[{$key}_height]",
84
+ 'value' => $height,
85
+ 'class' => array( "small-text large-offset-1" ),
86
+ 'show_desc' => $show_desc
87
+ ) );
88
+ }
89
+
90
+ if ( isset ( $crop ) ) {
91
+ $html .= parent::get_checkbox ( array(
92
+ 'name' => "rtmedia-options[{$key}_crop]",
93
+ 'rtForm_options' => array( array(
94
+ '' => 1, //label would be blank
95
+ 'checked' => $crop
96
+ ) ),
97
+ 'class' => array( "large-offset-1" ),
98
+ 'show_desc' => $show_desc
99
+ ) );
100
+ }
101
+
102
+ if ( $desc && $show_desc )
103
+ $html .= '<span class="clearfix large-offset-3 description">' . $desc . '</span>';
104
+
105
+ $html .= '</div>';
106
+
107
+ if ( isset ( $attributes[ 'label' ] ) )
108
+ $html = parent::enclose_label ( 'container', $html, $attributes[ 'label' ] );
109
+
110
+ return $html;
111
+ }
112
+
113
+ public function get_dimensions ( $attributes = '' ) {
114
+
115
+ return $this->generate_dimensions ( $attributes );
116
+ }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
 
120
  ?>
app/main/controllers/shortcodes/RTMediaUploadShortcode.php CHANGED
@@ -61,7 +61,10 @@ class RTMediaUploadShortcode {
61
  }
62
 
63
  if ( self::display_allowed () ) {
64
-
 
 
 
65
  ob_start ();
66
 
67
  self::$add_sc_script = true;
61
  }
62
 
63
  if ( self::display_allowed () ) {
64
+ if ( ! _device_can_upload () ) {
65
+ echo '<p>' . __ ( 'The web browser on your device cannot be used to upload files.' ) . '</p>';
66
+ return;
67
+ }
68
  ob_start ();
69
 
70
  self::$add_sc_script = true;
app/main/controllers/upload/RTMediaUploadEndpoint.php CHANGED
@@ -63,25 +63,39 @@ class RTMediaUploadEndpoint {
63
  $wpdb->update ( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html () ), array( "id" => $activity_id ) );
64
  }
65
  }
66
- if ( isset ( $_POST[ "redirect" ] ) && $_POST[ "redirect" ] == "no" ) {
67
- // Ha ha ha
68
- ob_end_clean ();
69
- if ( isset ( $_POST[ "rtmedia_update" ] ) && $_POST[ "rtmedia_update" ] == "true" ) {
70
- header ( 'Content-type: application/json' );
71
- echo json_encode ( $rtupload->media_ids );
 
 
 
 
 
 
 
 
72
  } else {
73
- // Media Upload Case - on album/post/profile/group
74
- $data = array( 'activity_id' => $activity_id );
75
- header ( 'Content-type: application/json' );
76
- echo json_encode ( $data );
 
 
 
 
 
 
 
 
77
  }
78
- die ();
79
  } else {
80
  //wp_safe_redirect(wp_get_referer());
81
  }
 
82
  }
83
-
84
- //die ();
85
  }
86
 
87
  }
63
  $wpdb->update ( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html () ), array( "id" => $activity_id ) );
64
  }
65
  }
66
+ if ( isset ( $_POST[ "redirect" ] ) ) {
67
+ if ( $_POST[ "redirect" ] == "no" ) {
68
+
69
+ // Ha ha ha
70
+ ob_end_clean ();
71
+ if ( isset ( $_POST[ "rtmedia_update" ] ) && $_POST[ "rtmedia_update" ] == "true" ) {
72
+ header ( 'Content-type: application/json' );
73
+ echo json_encode ( $rtupload->media_ids );
74
+ } else {
75
+ // Media Upload Case - on album/post/profile/group
76
+ $data = array( 'activity_id' => $activity_id );
77
+ header ( 'Content-type: application/json' );
78
+ echo json_encode ( $data );
79
+ }
80
  } else {
81
+ if ( is_numeric ( $_POST[ "redirect" ] ) ) {
82
+ if ( intval ( $_POST[ "redirect" ] ) > 1 ) {
83
+ //bulkurl
84
+ if ( $media[ 0 ]->context == "group" ) {
85
+ echo trailingslashit ( get_rtmedia_group_link ( $media[ 0 ]->context_id ) ) . RTMEDIA_MEDIA_SLUG;
86
+ } else {
87
+ echo trailingslashit ( get_rtmedia_user_link ( $media[ 0 ]->media_author ) ) . RTMEDIA_MEDIA_SLUG;
88
+ }
89
+ } else {
90
+ echo get_rtmedia_permalink ( $media[ 0 ]->id );
91
+ }
92
+ }
93
  }
 
94
  } else {
95
  //wp_safe_redirect(wp_get_referer());
96
  }
97
+ die ();
98
  }
 
 
99
  }
100
 
101
  }
app/main/controllers/upload/RTMediaUploadView.php CHANGED
@@ -68,7 +68,7 @@ class RTMediaUploadView {
68
  if ( $attr && is_array ( $attr ) ) {
69
  foreach ( $attr as $key => $val ) {
70
  ?>
71
- <input type='hidden' value='<?php echo $val; ?>' name ='<?php echo $key; ?>' />
72
  <?php
73
  }
74
  }
68
  if ( $attr && is_array ( $attr ) ) {
69
  foreach ( $attr as $key => $val ) {
70
  ?>
71
+ <input type='hidden' id="rt_upload_hf_<?php echo sanitize_key ( $key ); ?>" value='<?php echo $val; ?>' name ='<?php echo $key; ?>' />
72
  <?php
73
  }
74
  }
index.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
  Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
  Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
7
- Version: 3.0.12
8
  Author: rtCamp
9
  Text Domain: rtmedia
10
  Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
4
  Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
  Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
  Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
7
+ Version: 3.0.13
8
  Author: rtCamp
9
  Text Domain: rtmedia
10
  Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
lib/getid3/getid3.php CHANGED
@@ -11,10 +11,10 @@
11
  /////////////////////////////////////////////////////////////////
12
  // attempt to define temp dir as something flexible but reliable
13
 
14
- if ( ! class_exists ( "getID3" ) ) {
15
  return;
16
  }
17
- if ( ! class_exists ( "getid3_exception" ) ) {
18
  return;
19
  }
20
  $temp_dir = ini_get ( 'upload_tmp_dir' );
11
  /////////////////////////////////////////////////////////////////
12
  // attempt to define temp dir as something flexible but reliable
13
 
14
+ if ( class_exists ( "getID3" ) ) {
15
  return;
16
  }
17
+ if ( class_exists ( "getid3_exception" ) ) {
18
  return;
19
  }
20
  $temp_dir = ini_get ( 'upload_tmp_dir' );
readme.txt CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: WordPress 3.6
8
  Tested up to: WordPress 3.6 + BuddyPress 1.7
9
- Stable tag: 3.0.12
10
 
11
  rtMedia adds albums, audio/video encoding, privacy/sharing, front-end uploads & more. All this works nicely on mobile/tablets devices.
12
 
@@ -160,6 +160,11 @@ Please visit [rtMedia's Features page](http://rtcamp.com/buddypress-media/?utm_s
160
 
161
  Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
162
 
 
 
 
 
 
163
  = 3.0.12 =
164
  * Fixed activity mention issue
165
  * Fixed group avatar blank page issue
@@ -546,8 +551,8 @@ Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap
546
 
547
  == Upgrade Notice ==
548
 
549
- = 3.0.12 =
550
- Requires BuddyPress 1.7 or higher, if using BuddyPress. Fixed activity mention,featured video,Other minor bugs and Update SEO for media.
551
 
552
  == Sponsors ==
553
 
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: WordPress 3.6
8
  Tested up to: WordPress 3.6 + BuddyPress 1.7
9
+ Stable tag: 3.0.13
10
 
11
  rtMedia adds albums, audio/video encoding, privacy/sharing, front-end uploads & more. All this works nicely on mobile/tablets devices.
12
 
160
 
161
  Please visit [rtMedia's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
162
 
163
+ = 3.0.13 =
164
+ * Add redirect in upload shortcode sponsored by [Henry Wright](http://profiles.wordpress.org/henrywright-1)
165
+ * Fixed getID3 issue for FFMPEG
166
+ * Add rtMedia JS hook for lighbox
167
+
168
  = 3.0.12 =
169
  * Fixed activity mention issue
170
  * Fixed group avatar blank page issue
551
 
552
  == Upgrade Notice ==
553
 
554
+ = 3.0.13 =
555
+ Requires BuddyPress 1.7 or higher, if using BuddyPress. Add redirect in upload shortcode.
556
 
557
  == Sponsors ==
558