Version Description
- Remove notices and update js libs
Download this release
Release Info
Developer | faishal |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 3.2.10.1 |
Comparing to | |
See all releases |
Code changes from version 3.2.10 to 3.2.10.1
- app/admin/RTMediaAdmin.php +180 -204
- app/admin/RTMediaFormHandler.php +9 -0
- app/assets/img/BuddyPressMedia-Instagram.png +0 -0
- app/assets/img/bpm-photo-tagging.png +0 -0
- app/assets/img/ffmpeg-logo-240x184.png +0 -0
- app/assets/img/new-buddypress-media-kaltura-logo-240x184.png +0 -0
- app/assets/img/rtMedia-pro-ad-300x300px-2-RS.png +0 -0
- app/assets/js/jquery.observehashchange.pack.js +68 -1
- app/assets/js/jquery.powertip.min.js +1159 -1
- app/assets/js/jquery.sliderTabs.min.js +830 -1
- app/helper/RTMediaAddon.php +5 -5
- app/helper/RTMediaSettings.php +8 -7
- app/helper/rtPluginUpdateChecker.php +4 -662
- index.php +1 -1
- readme.txt +6 -3
app/admin/RTMediaAdmin.php
CHANGED
@@ -19,7 +19,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
19 |
public function __construct () {
|
20 |
global $rtmedia;
|
21 |
add_action ( 'init', array( $this, 'video_transcoding_survey_response' ) );
|
22 |
-
|
23 |
if ( is_multisite () ) {
|
24 |
add_action ( 'network_admin_notices', array( $this, 'upload_filetypes_error' ) );
|
25 |
add_action ( 'admin_notices', array( $this, 'upload_filetypes_error' ) );
|
@@ -44,9 +44,9 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
44 |
add_action ( 'wp_dashboard_setup', array( &$this, 'add_dashboard_widgets' ), 0 );
|
45 |
add_filter("attachment_fields_to_edit", array($this,"edit_video_thumbnail"), null, 2);
|
46 |
add_filter("attachment_fields_to_save", array($this,"save_video_thumbnail"), null, 2);
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
if ($obj_encoding->api_key){
|
51 |
add_filter ("media_row_actions", array($this,"add_reencode_link"), null, 2);
|
52 |
add_action( 'admin_head-upload.php', array( $this, 'add_bulk_actions_regenerate' ) );
|
@@ -54,7 +54,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
54 |
add_action( 'admin_action_bulk_video_regenerate_thumbnails', array( $this, 'bulk_action_handler' ) );
|
55 |
add_action( 'admin_action_-1', array( $this, 'bulk_action_handler' ) );
|
56 |
}
|
57 |
-
|
58 |
|
59 |
if ( isset ( $_POST[ "rtmedia-options" ] ) ) {
|
60 |
if ( isset ( $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] ) && $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] == "1" )
|
@@ -67,7 +67,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
67 |
add_action ( 'admin_enqueue_scripts', array( $this, 'ui' ) );
|
68 |
//bp_core_admin_hook();
|
69 |
add_action ( 'admin_menu', array( $this, 'menu' ), 1 );
|
70 |
-
|
71 |
if ( is_multisite () )
|
72 |
add_action ( 'network_admin_edit_rtmedia', array( $this, 'save_multisite_options' ) );
|
73 |
}
|
@@ -75,28 +75,20 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
75 |
$this->rtmedia_encoding = new RTMediaEncoding();
|
76 |
if(! defined("RTMEDIA_PRO_VERSION"))
|
77 |
add_action ( 'rtmedia_before_default_admin_widgets', array( $this, 'rtmedia_advertisement' ),1);
|
78 |
-
add_action ( 'wp_ajax_rtmedia_addon_popup_not_show_again', array( $this, 'rtmedia_addon_popup_not_show_again' ), 1 );
|
79 |
}
|
80 |
|
81 |
-
function rtmedia_addon_popup_not_show_again() {
|
82 |
-
if( rtmedia_update_site_option( "rtmedia-addon-popup", "hide" ) ) {
|
83 |
-
echo "1";
|
84 |
-
} else {
|
85 |
-
echo "0";
|
86 |
-
}
|
87 |
-
die();
|
88 |
-
}
|
89 |
-
|
90 |
function bp_admin_tabs() {
|
91 |
if ( current_user_can ( 'manage_options' ) ) {
|
92 |
add_action ( 'bp_admin_tabs', array( $this, 'tab' ) );
|
93 |
}
|
94 |
}
|
95 |
|
96 |
-
function rtmedia_advertisement(){
|
|
|
|
|
97 |
<div class='rtmedia-admin-ad'>
|
98 |
<a href='http://rtcamp.com/store/rtmedia-pro/' target='_blank' title='rtMedia Pro'>
|
99 |
-
<img src='
|
100 |
</a>
|
101 |
</div>
|
102 |
<?php }
|
@@ -117,14 +109,14 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
117 |
$results = $wpdb->get_results ( $sql );
|
118 |
if ( $results ) {
|
119 |
foreach ( $results as $media ) {
|
120 |
-
|
121 |
?>
|
122 |
<tr>
|
123 |
<td class = "b"> <?php echo $media->count; ?> </td>
|
124 |
<td class = "t"><?php echo constant(strtoupper('RTMEDIA_'.$media->media_type.'_PLURAL_LABEL') ); ?></td>
|
125 |
</tr>
|
126 |
<?php
|
127 |
-
|
128 |
}
|
129 |
}
|
130 |
?>
|
@@ -214,19 +206,19 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
214 |
|
215 |
function add_reencode_link ($actions, $post) {
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
|
224 |
-
|
225 |
-
|
226 |
wp_safe_redirect(add_query_arg(array("media_ids" => urlencode(implode(",", $_REQUEST["media"]))), admin_url("admin.php?page=rtmedia-regenerate")));
|
227 |
exit;
|
228 |
-
|
229 |
-
|
230 |
|
231 |
function admin_bar_menu ( $admin_bar ) {
|
232 |
if ( ! current_user_can ( 'manage_options' ) )
|
@@ -295,7 +287,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
295 |
'rtmedia_page_rtmedia-premium'
|
296 |
);
|
297 |
$admin_pages = apply_filters ( 'rtmedia_filter_admin_pages_array', $admin_pages );
|
298 |
-
|
299 |
$admin_ajax = admin_url ( 'admin-ajax.php' );
|
300 |
|
301 |
wp_enqueue_script ( 'bootstrap-switch', RTMEDIA_URL . 'app/assets/js/bootstrap-switch.js', array( 'jquery' ), RTMEDIA_VERSION );
|
@@ -335,7 +327,6 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
335 |
wp_enqueue_style ( 'grid-foundation', RTMEDIA_URL . 'app/assets/css/grid-foundation.css', '', RTMEDIA_VERSION );
|
336 |
wp_enqueue_style ( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/main.css', '', RTMEDIA_VERSION );
|
337 |
wp_enqueue_style ( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/css/admin.css', '', RTMEDIA_VERSION );
|
338 |
-
wp_enqueue_style ( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/css/rtmedia-addon-popup.css', '', RTMEDIA_VERSION );
|
339 |
if(isset($_REQUEST['page']) && $_REQUEST['page']== "rtmedia-settings") {
|
340 |
wp_enqueue_style ( 'foundation-admin-css', RTMEDIA_URL . 'app/assets/css/settings.css', '', RTMEDIA_VERSION );
|
341 |
}
|
@@ -355,9 +346,9 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
355 |
add_submenu_page ( 'rtmedia-settings', __( 'Settings', 'rtmedia' ), __( 'Settings', 'rtmedia' ), 'manage_options', 'rtmedia-settings', array( $this, 'settings_page' ) );
|
356 |
add_submenu_page ( 'rtmedia-settings', __( 'Addons', 'rtmedia' ), __( 'Addons', 'rtmedia' ), 'manage_options', 'rtmedia-addons', array( $this, 'addons_page' ) );
|
357 |
add_submenu_page ( 'rtmedia-settings', __( 'Support', 'rtmedia' ), __( 'Support', 'rtmedia' ), 'manage_options', 'rtmedia-support', array( $this, 'support_page' ) );
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
|
362 |
$obj_encoding = new RTMediaEncoding(true);
|
363 |
if ($obj_encoding->api_key)
|
@@ -365,7 +356,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
365 |
|
366 |
// add_submenu_page('rtmedia-settings', __('Importer', 'rtmedia'), __('Importer', 'rtmedia'), 'manage_options', 'rtmedia-importer', array($this, 'rt_importer_page'));
|
367 |
// if (!BPMediaPrivacy::is_installed()) {
|
368 |
-
//
|
369 |
// }
|
370 |
}
|
371 |
|
@@ -468,65 +459,65 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
468 |
</div> <?php
|
469 |
}
|
470 |
|
471 |
-
|
472 |
-
|
473 |
if ($obj_encoding->api_key) {
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
|
531 |
|
532 |
function get_video_without_thumbs() {
|
@@ -569,11 +560,11 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
569 |
$this->render_page ( 'rtmedia-support' );
|
570 |
}
|
571 |
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
|
576 |
-
|
577 |
*
|
578 |
* @return type
|
579 |
*/
|
@@ -634,10 +625,10 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
634 |
if ( $page == 'rtmedia-addons' )
|
635 |
RTMediaAddon::render_addons ( $page );
|
636 |
else if ( $page == 'rtmedia-support' ) {
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
do_settings_sections ( $page );
|
642 |
?>
|
643 |
<?php
|
@@ -655,27 +646,6 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
655 |
<?php $this->admin_sidebar (); ?>
|
656 |
</div>
|
657 |
</div><!-- .metabox-holder -->
|
658 |
-
<!-- rtmedia addon popup -->
|
659 |
-
<?php
|
660 |
-
$site_option = rtmedia_get_site_option("rtmedia-addon-popup");
|
661 |
-
if(!$site_option || $site_option != "hide") {
|
662 |
-
rtmedia_update_site_option("rtmedia-addon-popup", "show");
|
663 |
-
?>
|
664 |
-
<?php add_thickbox(); ?>
|
665 |
-
<div id="rtmedia-addon-add-parent" style="display:none;">
|
666 |
-
<div id="rtmedia-addon-add-container">
|
667 |
-
<div style="text-align:right"><a href="#" id="rtmedia-addon-do-not-show" onclick="return rtmedia_addon_do_not_show();"><?php _e('Do not show again','rtmedia');?></a></div>
|
668 |
-
<h1 id="rtmedia-flat-50-message"><?php _e('Flat','rtmedia'); ?> <span class="alert"><?php _e('50%','rtmedia'); ?></span> <?php _e('Discount On All rtMedia Addons','rtmedia'); ?></h1>
|
669 |
-
<h3 id="rtmedia-flat-50-link"><span class="regular"><a href="http://rtcamp.com/promo/flat-50-discount-rtcamp-products" target="_blank"><?php _e('Read More','rtmedia') ?></a><span></h3>
|
670 |
-
<h2 id="rtmedia-flat-50-code"><span class="regular"><?php _e('Use Promo Code:','rtmedia'); ?></span> <span class="alert">RTMEDIA50</span></h2>
|
671 |
-
<h5 id="rtmedia-flat-50-valid"><span class="regular"> <?php _e('Offer Valid Till:','rtmedia');?> December 3, 11:59PM PST</span></h5>
|
672 |
-
</div>
|
673 |
-
</div>
|
674 |
-
<a href="#TB_inline?width=600&height=170&inlineId=rtmedia-addon-add-parent" style="display:none;" class="thickbox rtmedia-addon-thickbox">rtMedia Addons</a>
|
675 |
-
<?php
|
676 |
-
}
|
677 |
-
?>
|
678 |
-
<!-- E.O. rtMedia addon popup -->
|
679 |
</div><!-- .bp-media-admin --><?php
|
680 |
}
|
681 |
|
@@ -731,10 +701,10 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
731 |
'name' => __( 'Support', 'rtmedia' ),
|
732 |
'slug' => 'rtmedia-support'
|
733 |
)//,
|
734 |
-
//
|
735 |
-
//
|
736 |
-
//
|
737 |
-
//
|
738 |
// )
|
739 |
);
|
740 |
|
@@ -744,9 +714,9 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
744 |
foreach ( array_values ( $tabs ) as $tab_data ) {
|
745 |
$is_current = ( bool ) ( $tab_data[ 'slug' ] == $this->get_current_tab () );
|
746 |
$tab_class = $is_current ? $active_class : $idle_class;
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
$tabs_html .= '<a href="' . $tab_data[ 'href' ] . '" class="' . $tab_class . '">' . $tab_data[ 'name' ] . '</a>';
|
751 |
}
|
752 |
|
@@ -860,19 +830,19 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
860 |
|
861 |
$query =
|
862 |
"SELECT
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
$result = $wpdb->get_results ( $query );
|
877 |
if ( ! is_array ( $result ) )
|
878 |
return false;
|
@@ -933,18 +903,18 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
933 |
|
934 |
$message = sprintf ( __( 'I use @buddypressmedia http://goo.gl/8Upmv on %s', 'rtmedia' ), home_url() );
|
935 |
$addons = '<div id="social" class="row">
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
//<li><a href="' . sprintf('%s', 'http://www.facebook.com/rtCamp.solutions/') . '" title="' . __('Become a fan on Facebook', 'rtmedia') . '" class="bp-media-facebook bp-media-social">' . __('Facebook', 'rtmedia') . '</a></li>
|
947 |
-
//<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', 'rtmedia') . '" class="bp-media-twitter bp-media-social">' . __('Twitter', 'rtmedia') . '</a></li>
|
948 |
new RTMediaAdminWidget ( 'spread-the-word', __( 'Spread the Word', 'rtmedia' ), $addons );
|
949 |
|
950 |
// $donate = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
@@ -956,7 +926,7 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
956 |
// <!-- Specify details about the contribution -->
|
957 |
// <input type="hidden" name="item_name" value="BuddyPress Media">
|
958 |
// <label><b>' . __('USD', 'rtmedia') . '</b></label>
|
959 |
-
//
|
960 |
// <input type="hidden" name="currency_code" value="USD">
|
961 |
// <!-- Display the payment button. -->
|
962 |
// <input type="hidden" name="cpp_header_image" value="' . RTMEDIA_URL . 'app/assets/img/rtcamp-logo.png">
|
@@ -970,16 +940,16 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
970 |
// new BPMediaAdminWidget('donate', __('Donate', 'rtmedia'), $donate);
|
971 |
|
972 |
$branding = '<form action="http://rtcamp.us1.list-manage1.com/subscribe/post?u=85b65c9c71e2ba3fab8cb1950&id=9e8ded4470" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
new RTMediaAdminWidget ( 'branding', __( 'Subscribe', 'rtmedia' ), $branding );
|
984 |
|
985 |
$news = '<img src ="' . admin_url ( '/images/wpspin_light.gif' ) . '" /> Loading...';
|
@@ -1142,54 +1112,60 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
1142 |
function save_video_thumbnail($post, $attachment) {
|
1143 |
if( isset($post['rtmedia-thumbnail']) ){
|
1144 |
$rtmedia_model = new RTMediaModel();
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
$rtmedia_model->update(array("cover_art" => $post['rtmedia-thumbnail']), array("media_id"=>$post['ID']));
|
1149 |
-
|
1150 |
}
|
1151 |
return $post;
|
1152 |
}
|
1153 |
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
|
1192 |
function presstrends_plugin() {
|
|
|
|
|
|
|
|
|
|
|
|
|
1193 |
// PressTrends Account API Key
|
1194 |
$api_key = 'djbzu1no2tdz4qq4u2fpgaemuup2zzmtjulb';
|
1195 |
$auth = 'o3w063qppl7ha022jyc3bjpi7usrmczho';
|
@@ -1241,4 +1217,4 @@ if ( ! class_exists ( 'RTMediaAdmin' ) ) {
|
|
1241 |
}
|
1242 |
}
|
1243 |
|
1244 |
-
}
|
19 |
public function __construct () {
|
20 |
global $rtmedia;
|
21 |
add_action ( 'init', array( $this, 'video_transcoding_survey_response' ) );
|
22 |
+
add_action ( 'admin_init', array( $this, 'presstrends_plugin' ) );
|
23 |
if ( is_multisite () ) {
|
24 |
add_action ( 'network_admin_notices', array( $this, 'upload_filetypes_error' ) );
|
25 |
add_action ( 'admin_notices', array( $this, 'upload_filetypes_error' ) );
|
44 |
add_action ( 'wp_dashboard_setup', array( &$this, 'add_dashboard_widgets' ), 0 );
|
45 |
add_filter("attachment_fields_to_edit", array($this,"edit_video_thumbnail"), null, 2);
|
46 |
add_filter("attachment_fields_to_save", array($this,"save_video_thumbnail"), null, 2);
|
47 |
+
add_action ( 'admin_notices', array( $this, 'rtmedia_regenerate_thumbnail_notice' ) );
|
48 |
+
add_action ( 'wp_ajax_rtmedia_hide_video_thumb_admin_notice', array( $this, 'rtmedia_hide_video_thumb_admin_notice' ), 1 );
|
49 |
+
$obj_encoding = new RTMediaEncoding(true);
|
50 |
if ($obj_encoding->api_key){
|
51 |
add_filter ("media_row_actions", array($this,"add_reencode_link"), null, 2);
|
52 |
add_action( 'admin_head-upload.php', array( $this, 'add_bulk_actions_regenerate' ) );
|
54 |
add_action( 'admin_action_bulk_video_regenerate_thumbnails', array( $this, 'bulk_action_handler' ) );
|
55 |
add_action( 'admin_action_-1', array( $this, 'bulk_action_handler' ) );
|
56 |
}
|
57 |
+
add_action ( 'wp_ajax_rt_media_regeneration', array( $this, 'rt_media_regeneration' ), 1 );
|
58 |
|
59 |
if ( isset ( $_POST[ "rtmedia-options" ] ) ) {
|
60 |
if ( isset ( $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] ) && $_POST[ "rtmedia-options" ][ "general_showAdminMenu" ] == "1" )
|
67 |
add_action ( 'admin_enqueue_scripts', array( $this, 'ui' ) );
|
68 |
//bp_core_admin_hook();
|
69 |
add_action ( 'admin_menu', array( $this, 'menu' ), 1 );
|
70 |
+
add_action( 'init', array( $this,'bp_admin_tabs' ) );
|
71 |
if ( is_multisite () )
|
72 |
add_action ( 'network_admin_edit_rtmedia', array( $this, 'save_multisite_options' ) );
|
73 |
}
|
75 |
$this->rtmedia_encoding = new RTMediaEncoding();
|
76 |
if(! defined("RTMEDIA_PRO_VERSION"))
|
77 |
add_action ( 'rtmedia_before_default_admin_widgets', array( $this, 'rtmedia_advertisement' ),1);
|
|
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
function bp_admin_tabs() {
|
81 |
if ( current_user_can ( 'manage_options' ) ) {
|
82 |
add_action ( 'bp_admin_tabs', array( $this, 'tab' ) );
|
83 |
}
|
84 |
}
|
85 |
|
86 |
+
function rtmedia_advertisement(){
|
87 |
+
$src = RTMEDIA_URL."app/assets/img/rtMedia-pro-ad-300x300px-2-RS.png"
|
88 |
+
?>
|
89 |
<div class='rtmedia-admin-ad'>
|
90 |
<a href='http://rtcamp.com/store/rtmedia-pro/' target='_blank' title='rtMedia Pro'>
|
91 |
+
<img src='<?php echo $src; ?>' alt='rtMedia Pro is released' />
|
92 |
</a>
|
93 |
</div>
|
94 |
<?php }
|
109 |
$results = $wpdb->get_results ( $sql );
|
110 |
if ( $results ) {
|
111 |
foreach ( $results as $media ) {
|
112 |
+
if( defined( strtoupper( 'RTMEDIA_'.$media->media_type.'_PLURAL_LABEL' ) ) ) {
|
113 |
?>
|
114 |
<tr>
|
115 |
<td class = "b"> <?php echo $media->count; ?> </td>
|
116 |
<td class = "t"><?php echo constant(strtoupper('RTMEDIA_'.$media->media_type.'_PLURAL_LABEL') ); ?></td>
|
117 |
</tr>
|
118 |
<?php
|
119 |
+
}
|
120 |
}
|
121 |
}
|
122 |
?>
|
206 |
|
207 |
function add_reencode_link ($actions, $post) {
|
208 |
|
209 |
+
$mime_type_array = explode("/", $post->post_mime_type);
|
210 |
+
if(is_array($mime_type_array) && $mime_type_array != "" && $mime_type_array[0] == "video") {
|
211 |
+
$actions['reencode'] = "<a class='submitdelete' onclick='return rtmedia_regenerate_thumbs(".$post->ID.")' href='#'>". __( 'Regenerate Thumbnail', 'rtmedia' ) ."</a>";
|
212 |
+
}
|
213 |
+
return $actions;
|
214 |
+
}
|
215 |
|
216 |
+
function bulk_action_handler() {
|
217 |
+
if($_REQUEST['action'] == "bulk_video_regenerate_thumbnails" && $_REQUEST['media'] != "") {
|
218 |
wp_safe_redirect(add_query_arg(array("media_ids" => urlencode(implode(",", $_REQUEST["media"]))), admin_url("admin.php?page=rtmedia-regenerate")));
|
219 |
exit;
|
220 |
+
}
|
221 |
+
}
|
222 |
|
223 |
function admin_bar_menu ( $admin_bar ) {
|
224 |
if ( ! current_user_can ( 'manage_options' ) )
|
287 |
'rtmedia_page_rtmedia-premium'
|
288 |
);
|
289 |
$admin_pages = apply_filters ( 'rtmedia_filter_admin_pages_array', $admin_pages );
|
290 |
+
if ( in_array ( $hook, $admin_pages ) || strpos( $hook, 'rtmedia-migration') ) {
|
291 |
$admin_ajax = admin_url ( 'admin-ajax.php' );
|
292 |
|
293 |
wp_enqueue_script ( 'bootstrap-switch', RTMEDIA_URL . 'app/assets/js/bootstrap-switch.js', array( 'jquery' ), RTMEDIA_VERSION );
|
327 |
wp_enqueue_style ( 'grid-foundation', RTMEDIA_URL . 'app/assets/css/grid-foundation.css', '', RTMEDIA_VERSION );
|
328 |
wp_enqueue_style ( 'rtmedia-main', RTMEDIA_URL . 'app/assets/css/main.css', '', RTMEDIA_VERSION );
|
329 |
wp_enqueue_style ( 'rtmedia-admin', RTMEDIA_URL . 'app/assets/css/admin.css', '', RTMEDIA_VERSION );
|
|
|
330 |
if(isset($_REQUEST['page']) && $_REQUEST['page']== "rtmedia-settings") {
|
331 |
wp_enqueue_style ( 'foundation-admin-css', RTMEDIA_URL . 'app/assets/css/settings.css', '', RTMEDIA_VERSION );
|
332 |
}
|
346 |
add_submenu_page ( 'rtmedia-settings', __( 'Settings', 'rtmedia' ), __( 'Settings', 'rtmedia' ), 'manage_options', 'rtmedia-settings', array( $this, 'settings_page' ) );
|
347 |
add_submenu_page ( 'rtmedia-settings', __( 'Addons', 'rtmedia' ), __( 'Addons', 'rtmedia' ), 'manage_options', 'rtmedia-addons', array( $this, 'addons_page' ) );
|
348 |
add_submenu_page ( 'rtmedia-settings', __( 'Support', 'rtmedia' ), __( 'Support', 'rtmedia' ), 'manage_options', 'rtmedia-support', array( $this, 'support_page' ) );
|
349 |
+
if(! defined("RTMEDIA_PRO_VERSION")) {
|
350 |
+
add_submenu_page ( 'rtmedia-settings', __( 'Premium', 'rtmedia' ), __( 'Premium ', 'rtmedia' ), 'manage_options', 'rtmedia-premium', array( $this, 'premium_page' ) );
|
351 |
+
}
|
352 |
|
353 |
$obj_encoding = new RTMediaEncoding(true);
|
354 |
if ($obj_encoding->api_key)
|
356 |
|
357 |
// add_submenu_page('rtmedia-settings', __('Importer', 'rtmedia'), __('Importer', 'rtmedia'), 'manage_options', 'rtmedia-importer', array($this, 'rt_importer_page'));
|
358 |
// if (!BPMediaPrivacy::is_installed()) {
|
359 |
+
// add_submenu_page('rtmedia-settings', __('rtMedia Database Update', 'rtmedia'), __('Update Database', 'rtmedia'), 'manage_options', 'rtmedia-db-update', array($this, 'privacy_page'));
|
360 |
// }
|
361 |
}
|
362 |
|
459 |
</div> <?php
|
460 |
}
|
461 |
|
462 |
+
function rtmedia_regenerate_thumbnail_notice() {
|
463 |
+
$obj_encoding = new RTMediaEncoding(true);
|
464 |
if ($obj_encoding->api_key) {
|
465 |
+
$site_option = rtmedia_get_site_option("rtmedia-video-thumb-notice");
|
466 |
+
if(!$site_option || $site_option != "hide") {
|
467 |
+
rtmedia_update_site_option("rtmedia-video-thumb-notice", "show");
|
468 |
+
$videos_without_thumbs = get_video_without_thumbs();
|
469 |
+
if(isset($videos_without_thumbs) && is_array($videos_without_thumbs) && sizeof($videos_without_thumbs) > 0 ) {
|
470 |
+
echo '<div class="error rtmedia-regenerate-video-thumb-error">
|
471 |
+
<p>
|
472 |
+
'. sprintf ( __( "You have total %s videos without thumbnails. Click <a href='%s'> here </a> to generate thumbnails. <a href='#' onclick='rtmedia_hide_video_thumb_notice()' style='float:right'>Hide</a>", 'rtmedia' ), sizeof($videos_without_thumbs), admin_url('admin.php?page=rtmedia-regenerate') ) .'
|
473 |
+
</p>
|
474 |
+
</div>';
|
475 |
+
|
476 |
+
?>
|
477 |
+
<script type="text/javascript">
|
478 |
+
function rtmedia_hide_video_thumb_notice() {
|
479 |
+
var data = {action : 'rtmedia_hide_video_thumb_admin_notice'};
|
480 |
+
jQuery.post(ajaxurl,data,function(response){
|
481 |
+
response = response.trim();
|
482 |
+
if(response === "1")
|
483 |
+
jQuery('.rtmedia-regenerate-video-thumb-error').remove();
|
484 |
+
});
|
485 |
+
}
|
486 |
+
</script>
|
487 |
+
<?php
|
488 |
+
}
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
|
493 |
+
function rtmedia_hide_video_thumb_admin_notice() {
|
494 |
+
if(rtmedia_update_site_option("rtmedia-video-thumb-notice", "hide"))
|
495 |
+
echo "1";
|
496 |
+
else
|
497 |
+
echo "0";
|
498 |
+
die();
|
499 |
+
}
|
500 |
|
501 |
+
function rt_media_regeneration() {
|
502 |
+
if(isset($_POST['media_id'])) {
|
503 |
+
$model = new RTMediaModel();
|
504 |
+
$media = $model->get_media ( array( 'media_id' => $_POST['media_id'] ), 0, 1 );
|
505 |
+
$media_type = $media[ 0 ]->media_type;
|
506 |
+
$response = array();
|
507 |
+
if($media_type == "video") {
|
508 |
+
$objRTMediaEncoding = new RTMediaEncoding(true);
|
509 |
+
$autoformat = "thumbnails";
|
510 |
+
$objRTMediaEncoding->reencoding(intval($_POST['media_id']), $autoformat);
|
511 |
+
$response['status'] = true;
|
512 |
+
}
|
513 |
+
else {
|
514 |
+
$response['status'] = false;
|
515 |
+
$response['message'] = __( 'not a video ...', 'rtmedia' );
|
516 |
+
}
|
517 |
+
echo json_encode($response);
|
518 |
+
die();
|
519 |
+
}
|
520 |
+
}
|
521 |
|
522 |
|
523 |
function get_video_without_thumbs() {
|
560 |
$this->render_page ( 'rtmedia-support' );
|
561 |
}
|
562 |
|
563 |
+
public function premium_page() {
|
564 |
+
$this->render_page ( 'rtmedia-premium' );
|
565 |
+
}
|
566 |
|
567 |
+
/**
|
568 |
*
|
569 |
* @return type
|
570 |
*/
|
625 |
if ( $page == 'rtmedia-addons' )
|
626 |
RTMediaAddon::render_addons ( $page );
|
627 |
else if ( $page == 'rtmedia-support' ) {
|
628 |
+
$rtmedia_support = new RTMediaSupport(false);
|
629 |
+
$rtmedia_support->render_support($page);
|
630 |
+
}
|
631 |
+
else
|
632 |
do_settings_sections ( $page );
|
633 |
?>
|
634 |
<?php
|
646 |
<?php $this->admin_sidebar (); ?>
|
647 |
</div>
|
648 |
</div><!-- .metabox-holder -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
</div><!-- .bp-media-admin --><?php
|
650 |
}
|
651 |
|
701 |
'name' => __( 'Support', 'rtmedia' ),
|
702 |
'slug' => 'rtmedia-support'
|
703 |
)//,
|
704 |
+
// array(
|
705 |
+
// 'href' => get_admin_url(null, add_query_arg(array('page' => 'rtmedia-importer'), 'admin.php')),
|
706 |
+
// 'name' => __('Importer', 'rtmedia'),
|
707 |
+
// 'slug' => 'rtmedia-importer'
|
708 |
// )
|
709 |
);
|
710 |
|
714 |
foreach ( array_values ( $tabs ) as $tab_data ) {
|
715 |
$is_current = ( bool ) ( $tab_data[ 'slug' ] == $this->get_current_tab () );
|
716 |
$tab_class = $is_current ? $active_class : $idle_class;
|
717 |
+
if(isset($tab_data['class']) && is_array($tab_data['class'])) {
|
718 |
+
$tab_class .= " ".implode(" ", $tab_data['class']);
|
719 |
+
}
|
720 |
$tabs_html .= '<a href="' . $tab_data[ 'href' ] . '" class="' . $tab_class . '">' . $tab_data[ 'name' ] . '</a>';
|
721 |
}
|
722 |
|
830 |
|
831 |
$query =
|
832 |
"SELECT
|
833 |
+
p.post_author,pmp.meta_value,
|
834 |
+
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
|
835 |
+
SUM(CASE WHEN post_mime_type LIKE 'music%' THEN 1 ELSE 0 END) as Music,
|
836 |
+
SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
|
837 |
+
SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums
|
838 |
+
FROM
|
839 |
+
$wpdb->posts p inner join $wpdb->postmeta pm on pm.post_id = p.id INNER JOIN $wpdb->postmeta pmp
|
840 |
+
on pmp.post_id = p.id WHERE
|
841 |
+
pm.meta_key = 'bp-media-key' AND
|
842 |
+
pm.meta_value > 0 AND
|
843 |
+
pmp.meta_key = 'bp_media_privacy' AND
|
844 |
+
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'music%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
|
845 |
+
GROUP BY p.post_author,pmp.meta_value order by p.post_author";
|
846 |
$result = $wpdb->get_results ( $query );
|
847 |
if ( ! is_array ( $result ) )
|
848 |
return false;
|
903 |
|
904 |
$message = sprintf ( __( 'I use @buddypressmedia http://goo.gl/8Upmv on %s', 'rtmedia' ), home_url() );
|
905 |
$addons = '<div id="social" class="row">
|
906 |
+
<label class="columns large-6 large-offset-3" for="bp-media-add-linkback"><input' . checked ( rtmedia_get_site_option ( 'rtmedia-add-linkback', false ), true, false ) . ' type="checkbox" name="bp-media-add-linkback" value="1" id="bp-media-add-linkback"/> ' . __( 'Add link to footer', 'rtmedia' ) . '</label>
|
907 |
+
<div class="row">
|
908 |
+
<div class="columns large-6"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Frtcamp.com%2Fbuddypress-media%2F&send=false&layout=button_count&width=72&show_faces=false&font&colorscheme=light&action=like&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px; margin-top: 5px;" allowTransparency="true"></iframe></div>
|
909 |
+
<div class="columns large-6"><a href="https://www.facebook.com/sharer/sharer.php?u=http://rtcamp.com/buddypress-media/" class="button" target="_blank"> <i class="icon-facebook"></i> ' . __ ( 'Share', 'rtmedia' ) . '</a></div>
|
910 |
+
<div class="columns large-6"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/follow_button.html?screen_name=buddypressmedia&show_count=false" style="width:62px; height:21px; margin-top: 5px;"></iframe></div>
|
911 |
+
<div class="columns large-6"><a href="http://twitter.com/home/?status=' . $message . '" class="button button-tweet" target= "_blank"><i class="icon-twitter"></i> ' . __( 'Tweet', 'rtmedia' ) . '</a></div>
|
912 |
+
<div class="columns large-6"><a href="http://wordpress.org/support/view/plugin-reviews/buddypress-media?rate=5#postform" class="button bpm-wp-button" target= "_blank"><span class="bpm-wp-icon"> </span> ' . __( 'Review', 'rtmedia' ) . '</a></div>
|
913 |
+
<div class="columns large-6"><a href="' . sprintf ( '%s', 'http://feeds.feedburner.com/rtcamp/' ) . '" title="' . __ ( 'Subscribe to our feeds', 'rtmedia' ) . '" class="button" target="_blank"><i class="bp-media-rss icon-rss"></i> ' . __ ( 'Feeds', 'rtmedia' ) . '</a></div>
|
914 |
+
</div>
|
915 |
+
</div>';
|
916 |
//<li><a href="' . sprintf('%s', 'http://www.facebook.com/rtCamp.solutions/') . '" title="' . __('Become a fan on Facebook', 'rtmedia') . '" class="bp-media-facebook bp-media-social">' . __('Facebook', 'rtmedia') . '</a></li>
|
917 |
+
//<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', 'rtmedia') . '" class="bp-media-twitter bp-media-social">' . __('Twitter', 'rtmedia') . '</a></li> ;
|
918 |
new RTMediaAdminWidget ( 'spread-the-word', __( 'Spread the Word', 'rtmedia' ), $addons );
|
919 |
|
920 |
// $donate = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
926 |
// <!-- Specify details about the contribution -->
|
927 |
// <input type="hidden" name="item_name" value="BuddyPress Media">
|
928 |
// <label><b>' . __('USD', 'rtmedia') . '</b></label>
|
929 |
+
// <input type="text" name="amount" size="3">
|
930 |
// <input type="hidden" name="currency_code" value="USD">
|
931 |
// <!-- Display the payment button. -->
|
932 |
// <input type="hidden" name="cpp_header_image" value="' . RTMEDIA_URL . 'app/assets/img/rtcamp-logo.png">
|
940 |
// new BPMediaAdminWidget('donate', __('Donate', 'rtmedia'), $donate);
|
941 |
|
942 |
$branding = '<form action="http://rtcamp.us1.list-manage1.com/subscribe/post?u=85b65c9c71e2ba3fab8cb1950&id=9e8ded4470" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
943 |
+
<div class="mc-field-group">
|
944 |
+
<input type="email" value="' . $current_user->user_email . '" name="EMAIL" placeholder="Email" class="required email" id="mce-EMAIL">
|
945 |
+
<input style="display:none;" type="checkbox" checked="checked" value="1" name="group[1721][1]" id="mce-group[1721]-1721-0"><label for="mce-group[1721]-1721-0">
|
946 |
+
<div id="mce-responses" class="clear">
|
947 |
+
<div class="response" id="mce-error-response" style="display:none"></div>
|
948 |
+
<div class="response" id="mce-success-response" style="display:none"></div>
|
949 |
+
</div>
|
950 |
+
<input type="submit" value="' . __( 'Subscribe', 'rtmedia' ) . '" name="subscribe" id="mc-embedded-subscribe" class="button">
|
951 |
+
</div>
|
952 |
+
</form>';
|
953 |
new RTMediaAdminWidget ( 'branding', __( 'Subscribe', 'rtmedia' ), $branding );
|
954 |
|
955 |
$news = '<img src ="' . admin_url ( '/images/wpspin_light.gif' ) . '" /> Loading...';
|
1112 |
function save_video_thumbnail($post, $attachment) {
|
1113 |
if( isset($post['rtmedia-thumbnail']) ){
|
1114 |
$rtmedia_model = new RTMediaModel();
|
1115 |
+
$model = new RTMediaModel();
|
1116 |
+
$media = $model->get(array("media_id" => $post['ID']));
|
1117 |
+
$media_id = $media[0]->id;
|
1118 |
$rtmedia_model->update(array("cover_art" => $post['rtmedia-thumbnail']), array("media_id"=>$post['ID']));
|
1119 |
+
update_activity_after_thumb_set($media_id);
|
1120 |
}
|
1121 |
return $post;
|
1122 |
}
|
1123 |
|
1124 |
+
function rtmedia_regenerate_thumb_js() {
|
1125 |
+
global $pagenow;
|
1126 |
+
|
1127 |
+
if($pagenow == 'upload.php') {
|
1128 |
+
?>
|
1129 |
+
<script type="text/javascript">
|
1130 |
+
function rtmedia_regenerate_thumbs(post_id) {
|
1131 |
+
if(post_id != "") {
|
1132 |
+
var data = {
|
1133 |
+
action: 'rt_media_regeneration',
|
1134 |
+
media_id: post_id
|
1135 |
+
};
|
1136 |
+
jQuery.post(ajaxurl,data, function(data) {
|
1137 |
+
data = JSON.parse(data);
|
1138 |
+
if(data.status === true) {
|
1139 |
+
alert("<?php _e('Video is sent to generate thumbnails.', 'rtmedia') ?>");
|
1140 |
+
}
|
1141 |
+
else {
|
1142 |
+
alert("<?php _e('Video can\'t be sent to generate thumbnails.', 'rtmedia') ?>");
|
1143 |
+
}
|
1144 |
+
});
|
1145 |
+
}
|
1146 |
+
}
|
1147 |
+
</script>
|
1148 |
+
<?php
|
1149 |
+
}
|
1150 |
+
}
|
1151 |
|
1152 |
+
function add_bulk_actions_regenerate () {
|
1153 |
+
?>
|
1154 |
+
<script type="text/javascript">
|
1155 |
+
jQuery(document).ready(function($){
|
1156 |
+
$('select[name^="action"] option:last-child').before('<option value="bulk_video_regenerate_thumbnails"><?php esc_attr_e( 'Regenerate Video Thumbnails', 'rtmedia'); ?></option>');
|
1157 |
+
});
|
1158 |
+
</script>
|
1159 |
+
<?php
|
1160 |
+
}
|
1161 |
|
1162 |
function presstrends_plugin() {
|
1163 |
+
global $rtmedia;
|
1164 |
+
$option = $rtmedia->options;
|
1165 |
+
if(!isset($option['general_AllowUserData'] )) return;
|
1166 |
+
if($option['general_AllowUserData'] == "0" ) {
|
1167 |
+
return;
|
1168 |
+
}
|
1169 |
// PressTrends Account API Key
|
1170 |
$api_key = 'djbzu1no2tdz4qq4u2fpgaemuup2zzmtjulb';
|
1171 |
$auth = 'o3w063qppl7ha022jyc3bjpi7usrmczho';
|
1217 |
}
|
1218 |
}
|
1219 |
|
1220 |
+
}
|
app/admin/RTMediaFormHandler.php
CHANGED
@@ -248,6 +248,15 @@ class RTMediaFormHandler {
|
|
248 |
'desc' => __('Enable menu in WordPress admin bar','rtmedia')
|
249 |
),
|
250 |
'group' => "10"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
)
|
252 |
);
|
253 |
|
248 |
'desc' => __('Enable menu in WordPress admin bar','rtmedia')
|
249 |
),
|
250 |
'group' => "10"
|
251 |
+
),
|
252 |
+
'general_AllowUserData' => array(
|
253 |
+
'title' => __('Allow User Data Tracking','rtmedia'),
|
254 |
+
'callback' => array('RTMediaFormHandler', 'checkbox'),
|
255 |
+
'args' => array(
|
256 |
+
'key' => 'general_AllowUserData',
|
257 |
+
'value' => $options['general_AllowUserData'],
|
258 |
+
'desc' => __('Enable user Data tracking','rtmedia')
|
259 |
+
)
|
260 |
)
|
261 |
);
|
262 |
|
app/assets/img/BuddyPressMedia-Instagram.png
ADDED
Binary file
|
app/assets/img/bpm-photo-tagging.png
ADDED
Binary file
|
app/assets/img/ffmpeg-logo-240x184.png
ADDED
Binary file
|
app/assets/img/new-buddypress-media-kaltura-logo-240x184.png
ADDED
Binary file
|
app/assets/img/rtMedia-pro-ad-300x300px-2-RS.png
ADDED
Binary file
|
app/assets/js/jquery.observehashchange.pack.js
CHANGED
@@ -15,6 +15,73 @@
|
|
15 |
* The above copyright notice and this permission notice shall be included in
|
16 |
* all copies or substantial portions of the Software.
|
17 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
**/
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
* The above copyright notice and this permission notice shall be included in
|
16 |
* all copies or substantial portions of the Software.
|
17 |
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
24 |
+
* DEALINGS IN THE SOFTWARE.
|
25 |
**/
|
26 |
+
(function($) {
|
27 |
+
$.fn.hashchange = function(fn) {
|
28 |
+
$(window).bind("jQuery.hashchange", fn);
|
29 |
+
return this;
|
30 |
+
};
|
31 |
|
32 |
+
$.observeHashChange = function(options) {
|
33 |
+
var opts = $.extend({}, $.observeHashChange.defaults, options);
|
34 |
+
if (isHashChangeEventSupported()) {
|
35 |
+
nativeVersion();
|
36 |
+
}
|
37 |
+
else {
|
38 |
+
setIntervalVersion(opts);
|
39 |
+
}
|
40 |
+
};
|
41 |
+
|
42 |
+
var locationHash = null;
|
43 |
+
var functionStore = null;
|
44 |
+
var interval = 0;
|
45 |
+
|
46 |
+
$.observeHashChange.defaults = {
|
47 |
+
interval : 500
|
48 |
+
};
|
49 |
+
|
50 |
+
function isHashChangeEventSupported() {
|
51 |
+
return "onhashchange" in window;
|
52 |
+
}
|
53 |
+
|
54 |
+
function nativeVersion() {
|
55 |
+
locationHash = document.location.hash;
|
56 |
+
window.onhashchange = onhashchangeHandler;
|
57 |
+
}
|
58 |
+
|
59 |
+
function onhashchangeHandler(e, data) {
|
60 |
+
var oldHash = locationHash;
|
61 |
+
locationHash = document.location.hash;
|
62 |
+
$(window).trigger("jQuery.hashchange", {before: oldHash, after: locationHash});
|
63 |
+
}
|
64 |
+
|
65 |
+
function setIntervalVersion(opts) {
|
66 |
+
if (locationHash == null) {
|
67 |
+
locationHash = document.location.hash;
|
68 |
+
}
|
69 |
+
if (functionStore != null) {
|
70 |
+
clearInterval(functionStore);
|
71 |
+
}
|
72 |
+
if (interval != opts.interval) {
|
73 |
+
functionStore = setInterval(checkLocationHash, opts.interval);
|
74 |
+
interval = opts.interval;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
function checkLocationHash() {
|
79 |
+
if (locationHash != document.location.hash) {
|
80 |
+
var oldHash = locationHash;
|
81 |
+
locationHash = document.location.hash;
|
82 |
+
$(window).trigger("jQuery.hashchange", {before: oldHash, after: locationHash});
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
$.observeHashChange();
|
87 |
+
})(jQuery);
|
app/assets/js/jquery.powertip.min.js
CHANGED
@@ -5,4 +5,1162 @@
|
|
5 |
Released under MIT license.
|
6 |
https://raw.github.com/stevenbenner/jquery-powertip/master/LICENSE.txt
|
7 |
*/
|
8 |
-
(function(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
Released under MIT license.
|
6 |
https://raw.github.com/stevenbenner/jquery-powertip/master/LICENSE.txt
|
7 |
*/
|
8 |
+
(function(factory) {
|
9 |
+
if (typeof define === 'function' && define.amd) {
|
10 |
+
// AMD. Register as an anonymous module.
|
11 |
+
define(['jquery'], factory);
|
12 |
+
} else {
|
13 |
+
// Browser globals
|
14 |
+
factory(jQuery);
|
15 |
+
}
|
16 |
+
}(function($) {
|
17 |
+
|
18 |
+
// useful private variables
|
19 |
+
var $document = $(document),
|
20 |
+
$window = $(window),
|
21 |
+
$body = $('body');
|
22 |
+
|
23 |
+
// constants
|
24 |
+
var DATA_DISPLAYCONTROLLER = 'displayController',
|
25 |
+
DATA_HASACTIVEHOVER = 'hasActiveHover',
|
26 |
+
DATA_FORCEDOPEN = 'forcedOpen',
|
27 |
+
DATA_HASMOUSEMOVE = 'hasMouseMove',
|
28 |
+
DATA_MOUSEONTOTIP = 'mouseOnToPopup',
|
29 |
+
DATA_ORIGINALTITLE = 'originalTitle',
|
30 |
+
DATA_POWERTIP = 'powertip',
|
31 |
+
DATA_POWERTIPJQ = 'powertipjq',
|
32 |
+
DATA_POWERTIPTARGET = 'powertiptarget',
|
33 |
+
RAD2DEG = 180 / Math.PI;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Session data
|
37 |
+
* Private properties global to all powerTip instances
|
38 |
+
*/
|
39 |
+
var session = {
|
40 |
+
isTipOpen: false,
|
41 |
+
isFixedTipOpen: false,
|
42 |
+
isClosing: false,
|
43 |
+
tipOpenImminent: false,
|
44 |
+
activeHover: null,
|
45 |
+
currentX: 0,
|
46 |
+
currentY: 0,
|
47 |
+
previousX: 0,
|
48 |
+
previousY: 0,
|
49 |
+
desyncTimeout: null,
|
50 |
+
mouseTrackingActive: false,
|
51 |
+
delayInProgress: false,
|
52 |
+
windowWidth: 0,
|
53 |
+
windowHeight: 0,
|
54 |
+
scrollTop: 0,
|
55 |
+
scrollLeft: 0
|
56 |
+
};
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Collision enumeration
|
60 |
+
* @enum {number}
|
61 |
+
*/
|
62 |
+
var Collision = {
|
63 |
+
none: 0,
|
64 |
+
top: 1,
|
65 |
+
bottom: 2,
|
66 |
+
left: 4,
|
67 |
+
right: 8
|
68 |
+
};
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Display hover tooltips on the matched elements.
|
72 |
+
* @param {(Object|string)} opts The options object to use for the plugin, or
|
73 |
+
* the name of a method to invoke on the first matched element.
|
74 |
+
* @param {*=} [arg] Argument for an invoked method (optional).
|
75 |
+
* @return {jQuery} jQuery object for the matched selectors.
|
76 |
+
*/
|
77 |
+
$.fn.powerTip = function(opts, arg) {
|
78 |
+
// don't do any work if there were no matched elements
|
79 |
+
if (!this.length) {
|
80 |
+
return this;
|
81 |
+
}
|
82 |
+
|
83 |
+
// handle api method calls on the plugin, e.g. powerTip('hide')
|
84 |
+
if ($.type(opts) === 'string' && $.powerTip[opts]) {
|
85 |
+
return $.powerTip[opts].call(this, this, arg);
|
86 |
+
}
|
87 |
+
|
88 |
+
// extend options and instantiate TooltipController
|
89 |
+
var options = $.extend({}, $.fn.powerTip.defaults, opts),
|
90 |
+
tipController = new TooltipController(options);
|
91 |
+
|
92 |
+
// hook mouse and viewport dimension tracking
|
93 |
+
initTracking();
|
94 |
+
|
95 |
+
// setup the elements
|
96 |
+
this.each(function elementSetup() {
|
97 |
+
var $this = $(this),
|
98 |
+
dataPowertip = $this.data(DATA_POWERTIP),
|
99 |
+
dataElem = $this.data(DATA_POWERTIPJQ),
|
100 |
+
dataTarget = $this.data(DATA_POWERTIPTARGET),
|
101 |
+
title;
|
102 |
+
|
103 |
+
// handle repeated powerTip calls on the same element by destroying the
|
104 |
+
// original instance hooked to it and replacing it with this call
|
105 |
+
if ($this.data(DATA_DISPLAYCONTROLLER)) {
|
106 |
+
$.powerTip.destroy($this);
|
107 |
+
}
|
108 |
+
|
109 |
+
// attempt to use title attribute text if there is no data-powertip,
|
110 |
+
// data-powertipjq or data-powertiptarget. If we do use the title
|
111 |
+
// attribute, delete the attribute so the browser will not show it
|
112 |
+
title = $this.attr('title');
|
113 |
+
if (!dataPowertip && !dataTarget && !dataElem && title) {
|
114 |
+
$this.data(DATA_POWERTIP, title);
|
115 |
+
$this.data(DATA_ORIGINALTITLE, title);
|
116 |
+
$this.removeAttr('title');
|
117 |
+
}
|
118 |
+
|
119 |
+
// create hover controllers for each element
|
120 |
+
$this.data(
|
121 |
+
DATA_DISPLAYCONTROLLER,
|
122 |
+
new DisplayController($this, options, tipController)
|
123 |
+
);
|
124 |
+
});
|
125 |
+
|
126 |
+
// attach events to matched elements if the manual options is not enabled
|
127 |
+
if (!options.manual) {
|
128 |
+
this.on({
|
129 |
+
// mouse events
|
130 |
+
'mouseenter.powertip': function elementMouseEnter(event) {
|
131 |
+
$.powerTip.show(this, event);
|
132 |
+
},
|
133 |
+
'mouseleave.powertip': function elementMouseLeave() {
|
134 |
+
$.powerTip.hide(this);
|
135 |
+
},
|
136 |
+
// keyboard events
|
137 |
+
'focus.powertip': function elementFocus() {
|
138 |
+
$.powerTip.show(this);
|
139 |
+
},
|
140 |
+
'blur.powertip': function elementBlur() {
|
141 |
+
$.powerTip.hide(this, true);
|
142 |
+
},
|
143 |
+
'keydown.powertip': function elementKeyDown(event) {
|
144 |
+
// close tooltip when the escape key is pressed
|
145 |
+
if (event.keyCode === 27) {
|
146 |
+
$.powerTip.hide(this, true);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
});
|
150 |
+
}
|
151 |
+
|
152 |
+
return this;
|
153 |
+
};
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Default options for the powerTip plugin.
|
157 |
+
*/
|
158 |
+
$.fn.powerTip.defaults = {
|
159 |
+
fadeInTime: 200,
|
160 |
+
fadeOutTime: 100,
|
161 |
+
followMouse: false,
|
162 |
+
popupId: 'powerTip',
|
163 |
+
intentSensitivity: 7,
|
164 |
+
intentPollInterval: 100,
|
165 |
+
closeDelay: 100,
|
166 |
+
placement: 'n',
|
167 |
+
smartPlacement: false,
|
168 |
+
offset: 10,
|
169 |
+
mouseOnToPopup: false,
|
170 |
+
manual: false
|
171 |
+
};
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Default smart placement priority lists.
|
175 |
+
* The first item in the array is the highest priority, the last is the lowest.
|
176 |
+
* The last item is also the default, which will be used if all previous options
|
177 |
+
* do not fit.
|
178 |
+
*/
|
179 |
+
$.fn.powerTip.smartPlacementLists = {
|
180 |
+
n: ['n', 'ne', 'nw', 's'],
|
181 |
+
e: ['e', 'ne', 'se', 'w', 'nw', 'sw', 'n', 's', 'e'],
|
182 |
+
s: ['s', 'se', 'sw', 'n'],
|
183 |
+
w: ['w', 'nw', 'sw', 'e', 'ne', 'se', 'n', 's', 'w'],
|
184 |
+
nw: ['nw', 'w', 'sw', 'n', 's', 'se', 'nw'],
|
185 |
+
ne: ['ne', 'e', 'se', 'n', 's', 'sw', 'ne'],
|
186 |
+
sw: ['sw', 'w', 'nw', 's', 'n', 'ne', 'sw'],
|
187 |
+
se: ['se', 'e', 'ne', 's', 'n', 'nw', 'se'],
|
188 |
+
'nw-alt': ['nw-alt', 'n', 'ne-alt', 'sw-alt', 's', 'se-alt', 'w', 'e'],
|
189 |
+
'ne-alt': ['ne-alt', 'n', 'nw-alt', 'se-alt', 's', 'sw-alt', 'e', 'w'],
|
190 |
+
'sw-alt': ['sw-alt', 's', 'se-alt', 'nw-alt', 'n', 'ne-alt', 'w', 'e'],
|
191 |
+
'se-alt': ['se-alt', 's', 'sw-alt', 'ne-alt', 'n', 'nw-alt', 'e', 'w']
|
192 |
+
};
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Public API
|
196 |
+
*/
|
197 |
+
$.powerTip = {
|
198 |
+
/**
|
199 |
+
* Attempts to show the tooltip for the specified element.
|
200 |
+
* @param {jQuery|Element} element The element to open the tooltip for.
|
201 |
+
* @param {jQuery.Event=} event jQuery event for hover intent and mouse
|
202 |
+
* tracking (optional).
|
203 |
+
*/
|
204 |
+
show: function apiShowTip(element, event) {
|
205 |
+
if (event) {
|
206 |
+
trackMouse(event);
|
207 |
+
session.previousX = event.pageX;
|
208 |
+
session.previousY = event.pageY;
|
209 |
+
$(element).data(DATA_DISPLAYCONTROLLER).show();
|
210 |
+
} else {
|
211 |
+
$(element).first().data(DATA_DISPLAYCONTROLLER).show(true, true);
|
212 |
+
}
|
213 |
+
return element;
|
214 |
+
},
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Repositions the tooltip on the element.
|
218 |
+
* @param {jQuery|Element} element The element the tooltip is shown for.
|
219 |
+
*/
|
220 |
+
reposition: function apiResetPosition(element) {
|
221 |
+
$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();
|
222 |
+
return element;
|
223 |
+
},
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Attempts to close any open tooltips.
|
227 |
+
* @param {(jQuery|Element)=} element The element with the tooltip that
|
228 |
+
* should be closed (optional).
|
229 |
+
* @param {boolean=} immediate Disable close delay (optional).
|
230 |
+
*/
|
231 |
+
hide: function apiCloseTip(element, immediate) {
|
232 |
+
if (element) {
|
233 |
+
$(element).first().data(DATA_DISPLAYCONTROLLER).hide(immediate);
|
234 |
+
} else {
|
235 |
+
if (session.activeHover) {
|
236 |
+
session.activeHover.data(DATA_DISPLAYCONTROLLER).hide(true);
|
237 |
+
}
|
238 |
+
}
|
239 |
+
return element;
|
240 |
+
},
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Destroy and roll back any powerTip() instance on the specified element.
|
244 |
+
* @param {jQuery|Element} element The element with the powerTip instance.
|
245 |
+
*/
|
246 |
+
destroy: function apiDestroy(element) {
|
247 |
+
$(element).off('.powertip').each(function destroy() {
|
248 |
+
var $this = $(this),
|
249 |
+
dataAttributes = [
|
250 |
+
DATA_ORIGINALTITLE,
|
251 |
+
DATA_DISPLAYCONTROLLER,
|
252 |
+
DATA_HASACTIVEHOVER,
|
253 |
+
DATA_FORCEDOPEN
|
254 |
+
];
|
255 |
+
|
256 |
+
if ($this.data(DATA_ORIGINALTITLE)) {
|
257 |
+
$this.attr('title', $this.data(DATA_ORIGINALTITLE));
|
258 |
+
dataAttributes.push(DATA_POWERTIP);
|
259 |
+
}
|
260 |
+
|
261 |
+
$this.removeData(dataAttributes);
|
262 |
+
});
|
263 |
+
return element;
|
264 |
+
}
|
265 |
+
};
|
266 |
+
|
267 |
+
// API aliasing
|
268 |
+
$.powerTip.showTip = $.powerTip.show;
|
269 |
+
$.powerTip.closeTip = $.powerTip.hide;
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Creates a new CSSCoordinates object.
|
273 |
+
* @private
|
274 |
+
* @constructor
|
275 |
+
*/
|
276 |
+
function CSSCoordinates() {
|
277 |
+
var me = this;
|
278 |
+
|
279 |
+
// initialize object properties
|
280 |
+
me.top = 'auto';
|
281 |
+
me.left = 'auto';
|
282 |
+
me.right = 'auto';
|
283 |
+
me.bottom = 'auto';
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Set a property to a value.
|
287 |
+
* @private
|
288 |
+
* @param {string} property The name of the property.
|
289 |
+
* @param {number} value The value of the property.
|
290 |
+
*/
|
291 |
+
me.set = function(property, value) {
|
292 |
+
if ($.isNumeric(value)) {
|
293 |
+
me[property] = Math.round(value);
|
294 |
+
}
|
295 |
+
};
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Creates a new tooltip display controller.
|
300 |
+
* @private
|
301 |
+
* @constructor
|
302 |
+
* @param {jQuery} element The element that this controller will handle.
|
303 |
+
* @param {Object} options Options object containing settings.
|
304 |
+
* @param {TooltipController} tipController The TooltipController object for
|
305 |
+
* this instance.
|
306 |
+
*/
|
307 |
+
function DisplayController(element, options, tipController) {
|
308 |
+
var hoverTimer = null;
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Begins the process of showing a tooltip.
|
312 |
+
* @private
|
313 |
+
* @param {boolean=} immediate Skip intent testing (optional).
|
314 |
+
* @param {boolean=} forceOpen Ignore cursor position and force tooltip to
|
315 |
+
* open (optional).
|
316 |
+
*/
|
317 |
+
function openTooltip(immediate, forceOpen) {
|
318 |
+
cancelTimer();
|
319 |
+
if (!element.data(DATA_HASACTIVEHOVER)) {
|
320 |
+
if (!immediate) {
|
321 |
+
session.tipOpenImminent = true;
|
322 |
+
hoverTimer = setTimeout(
|
323 |
+
function intentDelay() {
|
324 |
+
hoverTimer = null;
|
325 |
+
checkForIntent();
|
326 |
+
},
|
327 |
+
options.intentPollInterval
|
328 |
+
);
|
329 |
+
} else {
|
330 |
+
if (forceOpen) {
|
331 |
+
element.data(DATA_FORCEDOPEN, true);
|
332 |
+
}
|
333 |
+
tipController.showTip(element);
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Begins the process of closing a tooltip.
|
340 |
+
* @private
|
341 |
+
* @param {boolean=} disableDelay Disable close delay (optional).
|
342 |
+
*/
|
343 |
+
function closeTooltip(disableDelay) {
|
344 |
+
cancelTimer();
|
345 |
+
session.tipOpenImminent = false;
|
346 |
+
if (element.data(DATA_HASACTIVEHOVER)) {
|
347 |
+
element.data(DATA_FORCEDOPEN, false);
|
348 |
+
if (!disableDelay) {
|
349 |
+
session.delayInProgress = true;
|
350 |
+
hoverTimer = setTimeout(
|
351 |
+
function closeDelay() {
|
352 |
+
hoverTimer = null;
|
353 |
+
tipController.hideTip(element);
|
354 |
+
session.delayInProgress = false;
|
355 |
+
},
|
356 |
+
options.closeDelay
|
357 |
+
);
|
358 |
+
} else {
|
359 |
+
tipController.hideTip(element);
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Checks mouse position to make sure that the user intended to hover on the
|
366 |
+
* specified element before showing the tooltip.
|
367 |
+
* @private
|
368 |
+
*/
|
369 |
+
function checkForIntent() {
|
370 |
+
// calculate mouse position difference
|
371 |
+
var xDifference = Math.abs(session.previousX - session.currentX),
|
372 |
+
yDifference = Math.abs(session.previousY - session.currentY),
|
373 |
+
totalDifference = xDifference + yDifference;
|
374 |
+
|
375 |
+
// check if difference has passed the sensitivity threshold
|
376 |
+
if (totalDifference < options.intentSensitivity) {
|
377 |
+
tipController.showTip(element);
|
378 |
+
} else {
|
379 |
+
// try again
|
380 |
+
session.previousX = session.currentX;
|
381 |
+
session.previousY = session.currentY;
|
382 |
+
openTooltip();
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Cancels active hover timer.
|
388 |
+
* @private
|
389 |
+
*/
|
390 |
+
function cancelTimer() {
|
391 |
+
hoverTimer = clearTimeout(hoverTimer);
|
392 |
+
session.delayInProgress = false;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Repositions the tooltip on this element.
|
397 |
+
* @private
|
398 |
+
*/
|
399 |
+
function repositionTooltip() {
|
400 |
+
tipController.resetPosition(element);
|
401 |
+
}
|
402 |
+
|
403 |
+
// expose the methods
|
404 |
+
this.show = openTooltip;
|
405 |
+
this.hide = closeTooltip;
|
406 |
+
this.cancel = cancelTimer;
|
407 |
+
this.resetPosition = repositionTooltip;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Creates a new Placement Calculator.
|
412 |
+
* @private
|
413 |
+
* @constructor
|
414 |
+
*/
|
415 |
+
function PlacementCalculator() {
|
416 |
+
/**
|
417 |
+
* Compute the CSS position to display a tooltip at the specified placement
|
418 |
+
* relative to the specified element.
|
419 |
+
* @private
|
420 |
+
* @param {jQuery} element The element that the tooltip should target.
|
421 |
+
* @param {string} placement The placement for the tooltip.
|
422 |
+
* @param {number} tipWidth Width of the tooltip element in pixels.
|
423 |
+
* @param {number} tipHeight Height of the tooltip element in pixels.
|
424 |
+
* @param {number} offset Distance to offset tooltips in pixels.
|
425 |
+
* @return {CSSCoordinates} A CSSCoordinates object with the position.
|
426 |
+
*/
|
427 |
+
function computePlacementCoords(element, placement, tipWidth, tipHeight, offset) {
|
428 |
+
var placementBase = placement.split('-')[0], // ignore 'alt' for corners
|
429 |
+
coords = new CSSCoordinates(),
|
430 |
+
position;
|
431 |
+
|
432 |
+
if (isSvgElement(element)) {
|
433 |
+
position = getSvgPlacement(element, placementBase);
|
434 |
+
} else {
|
435 |
+
position = getHtmlPlacement(element, placementBase);
|
436 |
+
}
|
437 |
+
|
438 |
+
// calculate the appropriate x and y position in the document
|
439 |
+
switch (placement) {
|
440 |
+
case 'n':
|
441 |
+
coords.set('left', position.left - (tipWidth / 2));
|
442 |
+
coords.set('bottom', session.windowHeight - position.top + offset);
|
443 |
+
break;
|
444 |
+
case 'e':
|
445 |
+
coords.set('left', position.left + offset);
|
446 |
+
coords.set('top', position.top - (tipHeight / 2));
|
447 |
+
break;
|
448 |
+
case 's':
|
449 |
+
coords.set('left', position.left - (tipWidth / 2));
|
450 |
+
coords.set('top', position.top + offset);
|
451 |
+
break;
|
452 |
+
case 'w':
|
453 |
+
coords.set('top', position.top - (tipHeight / 2));
|
454 |
+
coords.set('right', session.windowWidth - position.left + offset);
|
455 |
+
break;
|
456 |
+
case 'nw':
|
457 |
+
coords.set('bottom', session.windowHeight - position.top + offset);
|
458 |
+
coords.set('right', session.windowWidth - position.left - 20);
|
459 |
+
break;
|
460 |
+
case 'nw-alt':
|
461 |
+
coords.set('left', position.left);
|
462 |
+
coords.set('bottom', session.windowHeight - position.top + offset);
|
463 |
+
break;
|
464 |
+
case 'ne':
|
465 |
+
coords.set('left', position.left - 20);
|
466 |
+
coords.set('bottom', session.windowHeight - position.top + offset);
|
467 |
+
break;
|
468 |
+
case 'ne-alt':
|
469 |
+
coords.set('bottom', session.windowHeight - position.top + offset);
|
470 |
+
coords.set('right', session.windowWidth - position.left);
|
471 |
+
break;
|
472 |
+
case 'sw':
|
473 |
+
coords.set('top', position.top + offset);
|
474 |
+
coords.set('right', session.windowWidth - position.left - 20);
|
475 |
+
break;
|
476 |
+
case 'sw-alt':
|
477 |
+
coords.set('left', position.left);
|
478 |
+
coords.set('top', position.top + offset);
|
479 |
+
break;
|
480 |
+
case 'se':
|
481 |
+
coords.set('left', position.left - 20);
|
482 |
+
coords.set('top', position.top + offset);
|
483 |
+
break;
|
484 |
+
case 'se-alt':
|
485 |
+
coords.set('top', position.top + offset);
|
486 |
+
coords.set('right', session.windowWidth - position.left);
|
487 |
+
break;
|
488 |
+
}
|
489 |
+
|
490 |
+
return coords;
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Finds the tooltip attachment point in the document for a HTML DOM element
|
495 |
+
* for the specified placement.
|
496 |
+
* @private
|
497 |
+
* @param {jQuery} element The element that the tooltip should target.
|
498 |
+
* @param {string} placement The placement for the tooltip.
|
499 |
+
* @return {Object} An object with the top,left position values.
|
500 |
+
*/
|
501 |
+
function getHtmlPlacement(element, placement) {
|
502 |
+
var objectOffset = element.offset(),
|
503 |
+
objectWidth = element.outerWidth(),
|
504 |
+
objectHeight = element.outerHeight(),
|
505 |
+
left,
|
506 |
+
top;
|
507 |
+
|
508 |
+
// calculate the appropriate x and y position in the document
|
509 |
+
switch (placement) {
|
510 |
+
case 'n':
|
511 |
+
left = objectOffset.left + objectWidth / 2;
|
512 |
+
top = objectOffset.top;
|
513 |
+
break;
|
514 |
+
case 'e':
|
515 |
+
left = objectOffset.left + objectWidth;
|
516 |
+
top = objectOffset.top + objectHeight / 2;
|
517 |
+
break;
|
518 |
+
case 's':
|
519 |
+
left = objectOffset.left + objectWidth / 2;
|
520 |
+
top = objectOffset.top + objectHeight;
|
521 |
+
break;
|
522 |
+
case 'w':
|
523 |
+
left = objectOffset.left;
|
524 |
+
top = objectOffset.top + objectHeight / 2;
|
525 |
+
break;
|
526 |
+
case 'nw':
|
527 |
+
left = objectOffset.left;
|
528 |
+
top = objectOffset.top;
|
529 |
+
break;
|
530 |
+
case 'ne':
|
531 |
+
left = objectOffset.left + objectWidth;
|
532 |
+
top = objectOffset.top;
|
533 |
+
break;
|
534 |
+
case 'sw':
|
535 |
+
left = objectOffset.left;
|
536 |
+
top = objectOffset.top + objectHeight;
|
537 |
+
break;
|
538 |
+
case 'se':
|
539 |
+
left = objectOffset.left + objectWidth;
|
540 |
+
top = objectOffset.top + objectHeight;
|
541 |
+
break;
|
542 |
+
}
|
543 |
+
|
544 |
+
return {
|
545 |
+
top: top,
|
546 |
+
left: left
|
547 |
+
};
|
548 |
+
}
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Finds the tooltip attachment point in the document for a SVG element for
|
552 |
+
* the specified placement.
|
553 |
+
* @private
|
554 |
+
* @param {jQuery} element The element that the tooltip should target.
|
555 |
+
* @param {string} placement The placement for the tooltip.
|
556 |
+
* @return {Object} An object with the top,left position values.
|
557 |
+
*/
|
558 |
+
function getSvgPlacement(element, placement) {
|
559 |
+
var svgElement = element.closest('svg')[0],
|
560 |
+
domElement = element[0],
|
561 |
+
point = svgElement.createSVGPoint(),
|
562 |
+
boundingBox = domElement.getBBox(),
|
563 |
+
matrix = domElement.getScreenCTM(),
|
564 |
+
halfWidth = boundingBox.width / 2,
|
565 |
+
halfHeight = boundingBox.height / 2,
|
566 |
+
placements = [],
|
567 |
+
placementKeys = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'],
|
568 |
+
coords,
|
569 |
+
rotation,
|
570 |
+
steps,
|
571 |
+
x;
|
572 |
+
|
573 |
+
function pushPlacement() {
|
574 |
+
placements.push(point.matrixTransform(matrix));
|
575 |
+
}
|
576 |
+
|
577 |
+
// get bounding box corners and midpoints
|
578 |
+
point.x = boundingBox.x;
|
579 |
+
point.y = boundingBox.y;
|
580 |
+
pushPlacement();
|
581 |
+
point.x += halfWidth;
|
582 |
+
pushPlacement();
|
583 |
+
point.x += halfWidth;
|
584 |
+
pushPlacement();
|
585 |
+
point.y += halfHeight;
|
586 |
+
pushPlacement();
|
587 |
+
point.y += halfHeight;
|
588 |
+
pushPlacement();
|
589 |
+
point.x -= halfWidth;
|
590 |
+
pushPlacement();
|
591 |
+
point.x -= halfWidth;
|
592 |
+
pushPlacement();
|
593 |
+
point.y -= halfHeight;
|
594 |
+
pushPlacement();
|
595 |
+
|
596 |
+
// determine rotation
|
597 |
+
if (placements[0].y !== placements[1].y || placements[0].x !== placements[7].x) {
|
598 |
+
rotation = Math.atan2(matrix.b, matrix.a) * RAD2DEG;
|
599 |
+
steps = Math.ceil(((rotation % 360) - 22.5) / 45);
|
600 |
+
if (steps < 1) {
|
601 |
+
steps += 8;
|
602 |
+
}
|
603 |
+
while (steps--) {
|
604 |
+
placementKeys.push(placementKeys.shift());
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
// find placement
|
609 |
+
for (x = 0; x < placements.length; x++) {
|
610 |
+
if (placementKeys[x] === placement) {
|
611 |
+
coords = placements[x];
|
612 |
+
break;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
return {
|
617 |
+
top: coords.y + session.scrollTop,
|
618 |
+
left: coords.x + session.scrollLeft
|
619 |
+
};
|
620 |
+
}
|
621 |
+
|
622 |
+
// expose methods
|
623 |
+
this.compute = computePlacementCoords;
|
624 |
+
}
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Creates a new tooltip controller.
|
628 |
+
* @private
|
629 |
+
* @constructor
|
630 |
+
* @param {Object} options Options object containing settings.
|
631 |
+
*/
|
632 |
+
function TooltipController(options) {
|
633 |
+
var placementCalculator = new PlacementCalculator(),
|
634 |
+
tipElement = $('#' + options.popupId);
|
635 |
+
|
636 |
+
// build and append tooltip div if it does not already exist
|
637 |
+
if (tipElement.length === 0) {
|
638 |
+
tipElement = $('<div/>', { id: options.popupId });
|
639 |
+
// grab body element if it was not populated when the script loaded
|
640 |
+
// note: this hack exists solely for jsfiddle support
|
641 |
+
if ($body.length === 0) {
|
642 |
+
$body = $('body');
|
643 |
+
}
|
644 |
+
$body.append(tipElement);
|
645 |
+
}
|
646 |
+
|
647 |
+
// hook mousemove for cursor follow tooltips
|
648 |
+
if (options.followMouse) {
|
649 |
+
// only one positionTipOnCursor hook per tooltip element, please
|
650 |
+
if (!tipElement.data(DATA_HASMOUSEMOVE)) {
|
651 |
+
$document.on('mousemove', positionTipOnCursor);
|
652 |
+
$window.on('scroll', positionTipOnCursor);
|
653 |
+
tipElement.data(DATA_HASMOUSEMOVE, true);
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
// if we want to be able to mouse onto the tooltip then we need to attach
|
658 |
+
// hover events to the tooltip that will cancel a close request on hover and
|
659 |
+
// start a new close request on mouseleave
|
660 |
+
if (options.mouseOnToPopup) {
|
661 |
+
tipElement.on({
|
662 |
+
mouseenter: function tipMouseEnter() {
|
663 |
+
// we only let the mouse stay on the tooltip if it is set to let
|
664 |
+
// users interact with it
|
665 |
+
if (tipElement.data(DATA_MOUSEONTOTIP)) {
|
666 |
+
// check activeHover in case the mouse cursor entered the
|
667 |
+
// tooltip during the fadeOut and close cycle
|
668 |
+
if (session.activeHover) {
|
669 |
+
session.activeHover.data(DATA_DISPLAYCONTROLLER).cancel();
|
670 |
+
}
|
671 |
+
}
|
672 |
+
},
|
673 |
+
mouseleave: function tipMouseLeave() {
|
674 |
+
// check activeHover in case the mouse cursor entered the
|
675 |
+
// tooltip during the fadeOut and close cycle
|
676 |
+
if (session.activeHover) {
|
677 |
+
session.activeHover.data(DATA_DISPLAYCONTROLLER).hide();
|
678 |
+
}
|
679 |
+
}
|
680 |
+
});
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Gives the specified element the active-hover state and queues up the
|
685 |
+
* showTip function.
|
686 |
+
* @private
|
687 |
+
* @param {jQuery} element The element that the tooltip should target.
|
688 |
+
*/
|
689 |
+
function beginShowTip(element) {
|
690 |
+
element.data(DATA_HASACTIVEHOVER, true);
|
691 |
+
// show tooltip, asap
|
692 |
+
tipElement.queue(function queueTipInit(next) {
|
693 |
+
showTip(element);
|
694 |
+
next();
|
695 |
+
});
|
696 |
+
}
|
697 |
+
|
698 |
+
/**
|
699 |
+
* Shows the tooltip, as soon as possible.
|
700 |
+
* @private
|
701 |
+
* @param {jQuery} element The element that the tooltip should target.
|
702 |
+
*/
|
703 |
+
function showTip(element) {
|
704 |
+
var tipContent;
|
705 |
+
|
706 |
+
// it is possible, especially with keyboard navigation, to move on to
|
707 |
+
// another element with a tooltip during the queue to get to this point
|
708 |
+
// in the code. if that happens then we need to not proceed or we may
|
709 |
+
// have the fadeout callback for the last tooltip execute immediately
|
710 |
+
// after this code runs, causing bugs.
|
711 |
+
if (!element.data(DATA_HASACTIVEHOVER)) {
|
712 |
+
return;
|
713 |
+
}
|
714 |
+
|
715 |
+
// if the tooltip is open and we got asked to open another one then the
|
716 |
+
// old one is still in its fadeOut cycle, so wait and try again
|
717 |
+
if (session.isTipOpen) {
|
718 |
+
if (!session.isClosing) {
|
719 |
+
hideTip(session.activeHover);
|
720 |
+
}
|
721 |
+
tipElement.delay(100).queue(function queueTipAgain(next) {
|
722 |
+
showTip(element);
|
723 |
+
next();
|
724 |
+
});
|
725 |
+
return;
|
726 |
+
}
|
727 |
+
|
728 |
+
// trigger powerTipPreRender event
|
729 |
+
element.trigger('powerTipPreRender');
|
730 |
+
|
731 |
+
// set tooltip content
|
732 |
+
tipContent = getTooltipContent(element);
|
733 |
+
if (tipContent) {
|
734 |
+
tipElement.empty().append(tipContent);
|
735 |
+
} else {
|
736 |
+
// we have no content to display, give up
|
737 |
+
return;
|
738 |
+
}
|
739 |
+
|
740 |
+
// trigger powerTipRender event
|
741 |
+
element.trigger('powerTipRender');
|
742 |
+
|
743 |
+
session.activeHover = element;
|
744 |
+
session.isTipOpen = true;
|
745 |
+
|
746 |
+
tipElement.data(DATA_MOUSEONTOTIP, options.mouseOnToPopup);
|
747 |
+
|
748 |
+
// set tooltip position
|
749 |
+
if (!options.followMouse) {
|
750 |
+
positionTipOnElement(element);
|
751 |
+
session.isFixedTipOpen = true;
|
752 |
+
} else {
|
753 |
+
positionTipOnCursor();
|
754 |
+
}
|
755 |
+
|
756 |
+
// fadein
|
757 |
+
tipElement.fadeIn(options.fadeInTime, function fadeInCallback() {
|
758 |
+
// start desync polling
|
759 |
+
if (!session.desyncTimeout) {
|
760 |
+
session.desyncTimeout = setInterval(closeDesyncedTip, 500);
|
761 |
+
}
|
762 |
+
|
763 |
+
// trigger powerTipOpen event
|
764 |
+
element.trigger('powerTipOpen');
|
765 |
+
});
|
766 |
+
}
|
767 |
+
|
768 |
+
/**
|
769 |
+
* Hides the tooltip.
|
770 |
+
* @private
|
771 |
+
* @param {jQuery} element The element that the tooltip should target.
|
772 |
+
*/
|
773 |
+
function hideTip(element) {
|
774 |
+
// reset session
|
775 |
+
session.isClosing = true;
|
776 |
+
session.activeHover = null;
|
777 |
+
session.isTipOpen = false;
|
778 |
+
|
779 |
+
// stop desync polling
|
780 |
+
session.desyncTimeout = clearInterval(session.desyncTimeout);
|
781 |
+
|
782 |
+
// reset element state
|
783 |
+
element.data(DATA_HASACTIVEHOVER, false);
|
784 |
+
element.data(DATA_FORCEDOPEN, false);
|
785 |
+
|
786 |
+
// fade out
|
787 |
+
tipElement.fadeOut(options.fadeOutTime, function fadeOutCallback() {
|
788 |
+
var coords = new CSSCoordinates();
|
789 |
+
|
790 |
+
// reset session and tooltip element
|
791 |
+
session.isClosing = false;
|
792 |
+
session.isFixedTipOpen = false;
|
793 |
+
tipElement.removeClass();
|
794 |
+
|
795 |
+
// support mouse-follow and fixed position tips at the same time by
|
796 |
+
// moving the tooltip to the last cursor location after it is hidden
|
797 |
+
coords.set('top', session.currentY + options.offset);
|
798 |
+
coords.set('left', session.currentX + options.offset);
|
799 |
+
tipElement.css(coords);
|
800 |
+
|
801 |
+
// trigger powerTipClose event
|
802 |
+
element.trigger('powerTipClose');
|
803 |
+
});
|
804 |
+
}
|
805 |
+
|
806 |
+
/**
|
807 |
+
* Moves the tooltip to the users mouse cursor.
|
808 |
+
* @private
|
809 |
+
*/
|
810 |
+
function positionTipOnCursor() {
|
811 |
+
// to support having fixed tooltips on the same page as cursor tooltips,
|
812 |
+
// where both instances are referencing the same tooltip element, we
|
813 |
+
// need to keep track of the mouse position constantly, but we should
|
814 |
+
// only set the tip location if a fixed tip is not currently open, a tip
|
815 |
+
// open is imminent or active, and the tooltip element in question does
|
816 |
+
// have a mouse-follow using it.
|
817 |
+
if (!session.isFixedTipOpen && (session.isTipOpen || (session.tipOpenImminent && tipElement.data(DATA_HASMOUSEMOVE)))) {
|
818 |
+
// grab measurements
|
819 |
+
var tipWidth = tipElement.outerWidth(),
|
820 |
+
tipHeight = tipElement.outerHeight(),
|
821 |
+
coords = new CSSCoordinates(),
|
822 |
+
collisions,
|
823 |
+
collisionCount;
|
824 |
+
|
825 |
+
// grab collisions
|
826 |
+
coords.set('top', session.currentY + options.offset);
|
827 |
+
coords.set('left', session.currentX + options.offset);
|
828 |
+
collisions = getViewportCollisions(
|
829 |
+
coords,
|
830 |
+
tipWidth,
|
831 |
+
tipHeight
|
832 |
+
);
|
833 |
+
|
834 |
+
// handle tooltip view port collisions
|
835 |
+
if (collisions !== Collision.none) {
|
836 |
+
collisionCount = countFlags(collisions);
|
837 |
+
if (collisionCount === 1) {
|
838 |
+
// if there is only one collision (bottom or right) then
|
839 |
+
// simply constrain the tooltip to the view port
|
840 |
+
if (collisions === Collision.right) {
|
841 |
+
coords.set('left', session.windowWidth - tipWidth);
|
842 |
+
} else if (collisions === Collision.bottom) {
|
843 |
+
coords.set('top', session.scrollTop + session.windowHeight - tipHeight);
|
844 |
+
}
|
845 |
+
} else {
|
846 |
+
// if the tooltip has more than one collision then it is
|
847 |
+
// trapped in the corner and should be flipped to get it out
|
848 |
+
// of the users way
|
849 |
+
coords.set('left', session.currentX - tipWidth - options.offset);
|
850 |
+
coords.set('top', session.currentY - tipHeight - options.offset);
|
851 |
+
}
|
852 |
+
}
|
853 |
+
|
854 |
+
// position the tooltip
|
855 |
+
tipElement.css(coords);
|
856 |
+
}
|
857 |
+
}
|
858 |
+
|
859 |
+
/**
|
860 |
+
* Sets the tooltip to the correct position relative to the specified target
|
861 |
+
* element. Based on options settings.
|
862 |
+
* @private
|
863 |
+
* @param {jQuery} element The element that the tooltip should target.
|
864 |
+
*/
|
865 |
+
function positionTipOnElement(element) {
|
866 |
+
var priorityList,
|
867 |
+
finalPlacement;
|
868 |
+
|
869 |
+
if (options.smartPlacement) {
|
870 |
+
priorityList = $.fn.powerTip.smartPlacementLists[options.placement];
|
871 |
+
|
872 |
+
// iterate over the priority list and use the first placement option
|
873 |
+
// that does not collide with the view port. if they all collide
|
874 |
+
// then the last placement in the list will be used.
|
875 |
+
$.each(priorityList, function(idx, pos) {
|
876 |
+
// place tooltip and find collisions
|
877 |
+
var collisions = getViewportCollisions(
|
878 |
+
placeTooltip(element, pos),
|
879 |
+
tipElement.outerWidth(),
|
880 |
+
tipElement.outerHeight()
|
881 |
+
);
|
882 |
+
|
883 |
+
// update the final placement variable
|
884 |
+
finalPlacement = pos;
|
885 |
+
|
886 |
+
// break if there were no collisions
|
887 |
+
if (collisions === Collision.none) {
|
888 |
+
return false;
|
889 |
+
}
|
890 |
+
});
|
891 |
+
} else {
|
892 |
+
// if we're not going to use the smart placement feature then just
|
893 |
+
// compute the coordinates and do it
|
894 |
+
placeTooltip(element, options.placement);
|
895 |
+
finalPlacement = options.placement;
|
896 |
+
}
|
897 |
+
|
898 |
+
// add placement as class for CSS arrows
|
899 |
+
tipElement.addClass(finalPlacement);
|
900 |
+
}
|
901 |
+
|
902 |
+
/**
|
903 |
+
* Sets the tooltip position to the appropriate values to show the tip at
|
904 |
+
* the specified placement. This function will iterate and test the tooltip
|
905 |
+
* to support elastic tooltips.
|
906 |
+
* @private
|
907 |
+
* @param {jQuery} element The element that the tooltip should target.
|
908 |
+
* @param {string} placement The placement for the tooltip.
|
909 |
+
* @return {CSSCoordinates} A CSSCoordinates object with the top, left, and
|
910 |
+
* right position values.
|
911 |
+
*/
|
912 |
+
function placeTooltip(element, placement) {
|
913 |
+
var iterationCount = 0,
|
914 |
+
tipWidth,
|
915 |
+
tipHeight,
|
916 |
+
coords = new CSSCoordinates();
|
917 |
+
|
918 |
+
// set the tip to 0,0 to get the full expanded width
|
919 |
+
coords.set('top', 0);
|
920 |
+
coords.set('left', 0);
|
921 |
+
tipElement.css(coords);
|
922 |
+
|
923 |
+
// to support elastic tooltips we need to check for a change in the
|
924 |
+
// rendered dimensions after the tooltip has been positioned
|
925 |
+
do {
|
926 |
+
// grab the current tip dimensions
|
927 |
+
tipWidth = tipElement.outerWidth();
|
928 |
+
tipHeight = tipElement.outerHeight();
|
929 |
+
|
930 |
+
// get placement coordinates
|
931 |
+
coords = placementCalculator.compute(
|
932 |
+
element,
|
933 |
+
placement,
|
934 |
+
tipWidth,
|
935 |
+
tipHeight,
|
936 |
+
options.offset
|
937 |
+
);
|
938 |
+
|
939 |
+
// place the tooltip
|
940 |
+
tipElement.css(coords);
|
941 |
+
} while (
|
942 |
+
// sanity check: limit to 5 iterations, and...
|
943 |
+
++iterationCount <= 5 &&
|
944 |
+
// try again if the dimensions changed after placement
|
945 |
+
(tipWidth !== tipElement.outerWidth() || tipHeight !== tipElement.outerHeight())
|
946 |
+
);
|
947 |
+
|
948 |
+
return coords;
|
949 |
+
}
|
950 |
+
|
951 |
+
/**
|
952 |
+
* Checks for a tooltip desync and closes the tooltip if one occurs.
|
953 |
+
* @private
|
954 |
+
*/
|
955 |
+
function closeDesyncedTip() {
|
956 |
+
var isDesynced = false;
|
957 |
+
// It is possible for the mouse cursor to leave an element without
|
958 |
+
// firing the mouseleave or blur event. This most commonly happens when
|
959 |
+
// the element is disabled under mouse cursor. If this happens it will
|
960 |
+
// result in a desynced tooltip because the tooltip was never asked to
|
961 |
+
// close. So we should periodically check for a desync situation and
|
962 |
+
// close the tip if such a situation arises.
|
963 |
+
if (session.isTipOpen && !session.isClosing && !session.delayInProgress) {
|
964 |
+
// user moused onto another tip or active hover is disabled
|
965 |
+
if (session.activeHover.data(DATA_HASACTIVEHOVER) === false || session.activeHover.is(':disabled')) {
|
966 |
+
isDesynced = true;
|
967 |
+
} else {
|
968 |
+
// hanging tip - have to test if mouse position is not over the
|
969 |
+
// active hover and not over a tooltip set to let the user
|
970 |
+
// interact with it.
|
971 |
+
// for keyboard navigation: this only counts if the element does
|
972 |
+
// not have focus.
|
973 |
+
// for tooltips opened via the api: we need to check if it has
|
974 |
+
// the forcedOpen flag.
|
975 |
+
if (!isMouseOver(session.activeHover) && !session.activeHover.is(':focus') && !session.activeHover.data(DATA_FORCEDOPEN)) {
|
976 |
+
if (tipElement.data(DATA_MOUSEONTOTIP)) {
|
977 |
+
if (!isMouseOver(tipElement)) {
|
978 |
+
isDesynced = true;
|
979 |
+
}
|
980 |
+
} else {
|
981 |
+
isDesynced = true;
|
982 |
+
}
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
if (isDesynced) {
|
987 |
+
// close the desynced tip
|
988 |
+
hideTip(session.activeHover);
|
989 |
+
}
|
990 |
+
}
|
991 |
+
}
|
992 |
+
|
993 |
+
// expose methods
|
994 |
+
this.showTip = beginShowTip;
|
995 |
+
this.hideTip = hideTip;
|
996 |
+
this.resetPosition = positionTipOnElement;
|
997 |
+
}
|
998 |
+
|
999 |
+
/**
|
1000 |
+
* Determine whether a jQuery object is an SVG element
|
1001 |
+
* @private
|
1002 |
+
* @param {jQuery} element The element to check
|
1003 |
+
* @return {boolean} Whether this is an SVG element
|
1004 |
+
*/
|
1005 |
+
function isSvgElement(element) {
|
1006 |
+
return window.SVGElement && element[0] instanceof SVGElement;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
/**
|
1010 |
+
* Initializes the viewport dimension cache and hooks up the mouse position
|
1011 |
+
* tracking and viewport dimension tracking events.
|
1012 |
+
* Prevents attaching the events more than once.
|
1013 |
+
* @private
|
1014 |
+
*/
|
1015 |
+
function initTracking() {
|
1016 |
+
if (!session.mouseTrackingActive) {
|
1017 |
+
session.mouseTrackingActive = true;
|
1018 |
+
|
1019 |
+
// grab the current viewport dimensions on load
|
1020 |
+
$(function getViewportDimensions() {
|
1021 |
+
session.scrollLeft = $window.scrollLeft();
|
1022 |
+
session.scrollTop = $window.scrollTop();
|
1023 |
+
session.windowWidth = $window.width();
|
1024 |
+
session.windowHeight = $window.height();
|
1025 |
+
});
|
1026 |
+
|
1027 |
+
// hook mouse move tracking
|
1028 |
+
$document.on('mousemove', trackMouse);
|
1029 |
+
|
1030 |
+
// hook viewport dimensions tracking
|
1031 |
+
$window.on({
|
1032 |
+
resize: function trackResize() {
|
1033 |
+
session.windowWidth = $window.width();
|
1034 |
+
session.windowHeight = $window.height();
|
1035 |
+
},
|
1036 |
+
scroll: function trackScroll() {
|
1037 |
+
var x = $window.scrollLeft(),
|
1038 |
+
y = $window.scrollTop();
|
1039 |
+
if (x !== session.scrollLeft) {
|
1040 |
+
session.currentX += x - session.scrollLeft;
|
1041 |
+
session.scrollLeft = x;
|
1042 |
+
}
|
1043 |
+
if (y !== session.scrollTop) {
|
1044 |
+
session.currentY += y - session.scrollTop;
|
1045 |
+
session.scrollTop = y;
|
1046 |
+
}
|
1047 |
+
}
|
1048 |
+
});
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
/**
|
1053 |
+
* Saves the current mouse coordinates to the session object.
|
1054 |
+
* @private
|
1055 |
+
* @param {jQuery.Event} event The mousemove event for the document.
|
1056 |
+
*/
|
1057 |
+
function trackMouse(event) {
|
1058 |
+
session.currentX = event.pageX;
|
1059 |
+
session.currentY = event.pageY;
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
/**
|
1063 |
+
* Tests if the mouse is currently over the specified element.
|
1064 |
+
* @private
|
1065 |
+
* @param {jQuery} element The element to check for hover.
|
1066 |
+
* @return {boolean}
|
1067 |
+
*/
|
1068 |
+
function isMouseOver(element) {
|
1069 |
+
// use getBoundingClientRect() because jQuery's width() and height()
|
1070 |
+
// methods do not work with SVG elements
|
1071 |
+
// compute width/height because those properties do not exist on the object
|
1072 |
+
// returned by getBoundingClientRect() in older versions of IE
|
1073 |
+
var elementPosition = element.offset(),
|
1074 |
+
elementBox = element[0].getBoundingClientRect(),
|
1075 |
+
elementWidth = elementBox.right - elementBox.left,
|
1076 |
+
elementHeight = elementBox.bottom - elementBox.top;
|
1077 |
+
|
1078 |
+
return session.currentX >= elementPosition.left &&
|
1079 |
+
session.currentX <= elementPosition.left + elementWidth &&
|
1080 |
+
session.currentY >= elementPosition.top &&
|
1081 |
+
session.currentY <= elementPosition.top + elementHeight;
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
/**
|
1085 |
+
* Fetches the tooltip content from the specified element's data attributes.
|
1086 |
+
* @private
|
1087 |
+
* @param {jQuery} element The element to get the tooltip content for.
|
1088 |
+
* @return {(string|jQuery|undefined)} The text/HTML string, jQuery object, or
|
1089 |
+
* undefined if there was no tooltip content for the element.
|
1090 |
+
*/
|
1091 |
+
function getTooltipContent(element) {
|
1092 |
+
var tipText = element.data(DATA_POWERTIP),
|
1093 |
+
tipObject = element.data(DATA_POWERTIPJQ),
|
1094 |
+
tipTarget = element.data(DATA_POWERTIPTARGET),
|
1095 |
+
targetElement,
|
1096 |
+
content;
|
1097 |
+
|
1098 |
+
if (tipText) {
|
1099 |
+
if ($.isFunction(tipText)) {
|
1100 |
+
tipText = tipText.call(element[0]);
|
1101 |
+
}
|
1102 |
+
content = tipText;
|
1103 |
+
} else if (tipObject) {
|
1104 |
+
if ($.isFunction(tipObject)) {
|
1105 |
+
tipObject = tipObject.call(element[0]);
|
1106 |
+
}
|
1107 |
+
if (tipObject.length > 0) {
|
1108 |
+
content = tipObject.clone(true, true);
|
1109 |
+
}
|
1110 |
+
} else if (tipTarget) {
|
1111 |
+
targetElement = $('#' + tipTarget);
|
1112 |
+
if (targetElement.length > 0) {
|
1113 |
+
content = targetElement.html();
|
1114 |
+
}
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
return content;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
/**
|
1121 |
+
* Finds any viewport collisions that an element (the tooltip) would have if it
|
1122 |
+
* were absolutely positioned at the specified coordinates.
|
1123 |
+
* @private
|
1124 |
+
* @param {CSSCoordinates} coords Coordinates for the element.
|
1125 |
+
* @param {number} elementWidth Width of the element in pixels.
|
1126 |
+
* @param {number} elementHeight Height of the element in pixels.
|
1127 |
+
* @return {number} Value with the collision flags.
|
1128 |
+
*/
|
1129 |
+
function getViewportCollisions(coords, elementWidth, elementHeight) {
|
1130 |
+
var viewportTop = session.scrollTop,
|
1131 |
+
viewportLeft = session.scrollLeft,
|
1132 |
+
viewportBottom = viewportTop + session.windowHeight,
|
1133 |
+
viewportRight = viewportLeft + session.windowWidth,
|
1134 |
+
collisions = Collision.none;
|
1135 |
+
|
1136 |
+
if (coords.top < viewportTop || Math.abs(coords.bottom - session.windowHeight) - elementHeight < viewportTop) {
|
1137 |
+
collisions |= Collision.top;
|
1138 |
+
}
|
1139 |
+
if (coords.top + elementHeight > viewportBottom || Math.abs(coords.bottom - session.windowHeight) > viewportBottom) {
|
1140 |
+
collisions |= Collision.bottom;
|
1141 |
+
}
|
1142 |
+
if (coords.left < viewportLeft || coords.right + elementWidth > viewportRight) {
|
1143 |
+
collisions |= Collision.left;
|
1144 |
+
}
|
1145 |
+
if (coords.left + elementWidth > viewportRight || coords.right < viewportLeft) {
|
1146 |
+
collisions |= Collision.right;
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
return collisions;
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
/**
|
1153 |
+
* Counts the number of bits set on a flags value.
|
1154 |
+
* @param {number} value The flags value.
|
1155 |
+
* @return {number} The number of bits that have been set.
|
1156 |
+
*/
|
1157 |
+
function countFlags(value) {
|
1158 |
+
var count = 0;
|
1159 |
+
while (value) {
|
1160 |
+
value &= value - 1;
|
1161 |
+
count++;
|
1162 |
+
}
|
1163 |
+
return count;
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
}));
|
app/assets/js/jquery.sliderTabs.min.js
CHANGED
@@ -1 +1,830 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery SliderTabs v1.1
|
3 |
+
* http://lopatin.github.com/sliderTabs
|
4 |
+
*
|
5 |
+
* Copyright 2012, Alex Lopatin
|
6 |
+
* Free to use under the MIT license.
|
7 |
+
* http://www.opensource.org/licenses/mit-license.php
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
(function( $ ){
|
13 |
+
/*
|
14 |
+
* The sliderTabs tabs class
|
15 |
+
*/
|
16 |
+
$.sliderTabs = function(container, options){
|
17 |
+
var plugin = this;
|
18 |
+
|
19 |
+
var defaults = {
|
20 |
+
autoplay: false,
|
21 |
+
tabArrowWidth: 35,
|
22 |
+
classes: {
|
23 |
+
leftTabArrow: '',
|
24 |
+
panel: '',
|
25 |
+
panelActive: '',
|
26 |
+
panelsContainer: '',
|
27 |
+
rightTabArrow: '',
|
28 |
+
tab: '',
|
29 |
+
tabActive: '',
|
30 |
+
tabsList: ''
|
31 |
+
},
|
32 |
+
defaultTab: 1,
|
33 |
+
height: null,
|
34 |
+
indicators: false,
|
35 |
+
mousewheel: true,
|
36 |
+
position: "top",
|
37 |
+
panelArrows: false,
|
38 |
+
panelArrowsShowOnHover: false,
|
39 |
+
tabs: true,
|
40 |
+
tabHeight: 30,
|
41 |
+
tabArrows: true,
|
42 |
+
tabSlideLength: 100,
|
43 |
+
tabSlideSpeed: 200,
|
44 |
+
transition: 'slide',
|
45 |
+
transitionEasing: 'easeOutCubic',
|
46 |
+
transitionSpeed: 500,
|
47 |
+
width: null
|
48 |
+
};
|
49 |
+
|
50 |
+
// jQuery objects of important elements
|
51 |
+
var $container = $(container),
|
52 |
+
$indicators,
|
53 |
+
$tabsList,
|
54 |
+
$contentDivs,
|
55 |
+
$tabsListContainer,
|
56 |
+
$tabsListWrapper,
|
57 |
+
$contentDivsContainer,
|
58 |
+
$leftTabArrow,
|
59 |
+
$rightTabArrow,
|
60 |
+
$leftPanelArrow,
|
61 |
+
$rightPanelArrow;
|
62 |
+
|
63 |
+
// Locks to stop out of sync behavior
|
64 |
+
var selectLock = false,
|
65 |
+
heightLock = true;
|
66 |
+
|
67 |
+
var settings, minMargin;
|
68 |
+
|
69 |
+
// Index of currently selected tab
|
70 |
+
plugin.selectedTab = defaults.defaultTab;
|
71 |
+
|
72 |
+
plugin.init = function(){
|
73 |
+
settings = plugin.settings = $.extend({}, defaults, options);
|
74 |
+
$container.addClass('ui-slider-tabs');
|
75 |
+
|
76 |
+
/*
|
77 |
+
* Rebuild structure of container
|
78 |
+
*/
|
79 |
+
$contentDivs = $container.children("div").addClass('ui-slider-tab-content').remove();
|
80 |
+
|
81 |
+
// Tabs
|
82 |
+
$tabsList = $container.children("ul").addClass('ui-slider-tabs-list').remove();
|
83 |
+
$tabsList.children("li").remove().appendTo($tabsList);
|
84 |
+
plugin.count = $tabsList.children('li').length;
|
85 |
+
$tabsListWrapper = $("<div class='ui-slider-tabs-list-wrapper'>");
|
86 |
+
$tabsListContainer = $("<div class='ui-slider-tabs-list-container'>").append($tabsList).appendTo($tabsListWrapper);
|
87 |
+
$tabsListContainer.find('li').css('height', settings.tabHeight+2);
|
88 |
+
$tabsListContainer.find('li a').css('height', settings.tabHeight+2);
|
89 |
+
|
90 |
+
// Tab arrows
|
91 |
+
$leftTabArrow = $("<a href='#' class='ui-slider-left-arrow'><div></div></a>").css({
|
92 |
+
'width': settings.tabArrowWidth,
|
93 |
+
'height': settings.tabHeight+2
|
94 |
+
}).appendTo($tabsListContainer).click(function(e){
|
95 |
+
plugin.slideTabs('right', settings.tabSlideLength);
|
96 |
+
return false;
|
97 |
+
});
|
98 |
+
$rightTabArrow = $("<a href='#' class='ui-slider-right-arrow'><div></div></a>").css({
|
99 |
+
'width': settings.tabArrowWidth,
|
100 |
+
'height': settings.tabHeight+2
|
101 |
+
}).appendTo($tabsListContainer).click(function(e){
|
102 |
+
plugin.slideTabs('left', settings.tabSlideLength);
|
103 |
+
return false;
|
104 |
+
});
|
105 |
+
|
106 |
+
// Content container
|
107 |
+
$contentDivsContainer = $("<div class='ui-slider-tabs-content-container'>").append($contentDivs);
|
108 |
+
|
109 |
+
// Position the tabs on top or bottom
|
110 |
+
if(settings.position == 'bottom')
|
111 |
+
$container.append($contentDivsContainer).append($tabsListWrapper.addClass('bottom'));
|
112 |
+
else
|
113 |
+
$container.append($tabsListWrapper).append($contentDivsContainer);
|
114 |
+
|
115 |
+
|
116 |
+
if(settings.width)
|
117 |
+
$container.width(parseInt(settings.width));
|
118 |
+
if(settings.height)
|
119 |
+
$contentDivsContainer.height(parseInt(settings.height)- settings.tabHeight);
|
120 |
+
|
121 |
+
// Create and show indicators
|
122 |
+
if(settings.indicators)
|
123 |
+
plugin.showIndicators();
|
124 |
+
|
125 |
+
|
126 |
+
// Select default tab
|
127 |
+
plugin.selectTab(settings.defaultTab);
|
128 |
+
plugin.slideTabs('left', 0);
|
129 |
+
|
130 |
+
reorderPanels();
|
131 |
+
|
132 |
+
resizePanels();
|
133 |
+
|
134 |
+
// When tab is clicked
|
135 |
+
$container.delegate('.ui-slider-tabs-list li a', 'click', function(){
|
136 |
+
if(!$(this).parent().hasClass('selected') && !selectLock){
|
137 |
+
plugin.selectTab($(this).parent());
|
138 |
+
}
|
139 |
+
return false;
|
140 |
+
});
|
141 |
+
|
142 |
+
// When indicator is clicked
|
143 |
+
if($indicators)
|
144 |
+
$indicators.delegate('.ui-slider-tabs-indicator', 'click', function(){
|
145 |
+
if(!$(this).hasClass('selected') && !selectLock)
|
146 |
+
plugin.selectTab($(this).index()+1);
|
147 |
+
});
|
148 |
+
|
149 |
+
// Set classes
|
150 |
+
$.each(settings.classes, function(i, c){
|
151 |
+
switch(i){
|
152 |
+
case 'leftTabArrow':
|
153 |
+
$leftTabArrow.addClass(c);
|
154 |
+
break;
|
155 |
+
case 'rightTabArrow':
|
156 |
+
$rightTabArrow.addClass(c);
|
157 |
+
break;
|
158 |
+
case 'panel':
|
159 |
+
$contentDivs.addClass(c);
|
160 |
+
break;
|
161 |
+
case 'panelsContainer':
|
162 |
+
$contentDivsContainer.addClass(c);
|
163 |
+
break;
|
164 |
+
case 'tab':
|
165 |
+
$tabsList.find('li').addClass(c);
|
166 |
+
break;
|
167 |
+
case 'tabsList':
|
168 |
+
$tabsList.addClass(c);
|
169 |
+
break;
|
170 |
+
default:
|
171 |
+
break;
|
172 |
+
}
|
173 |
+
});
|
174 |
+
|
175 |
+
// Panel arrows
|
176 |
+
// Creates them if they don't exist
|
177 |
+
if(settings.panelArrows)
|
178 |
+
positionPanelArrows();
|
179 |
+
|
180 |
+
if(settings.panelArrowsShowOnHover){
|
181 |
+
if($leftPanelArrow)
|
182 |
+
$leftPanelArrow.addClass('showOnHover');
|
183 |
+
if($rightPanelArrow)
|
184 |
+
$rightPanelArrow.addClass('showOnHover');
|
185 |
+
}
|
186 |
+
|
187 |
+
$contentDivsContainer.resize(positionPanelArrows);
|
188 |
+
|
189 |
+
// Make responsive to changes in dimensions
|
190 |
+
$tabsListWrapper.resize(function(){
|
191 |
+
resizeTabsList();
|
192 |
+
resizePanels();
|
193 |
+
});
|
194 |
+
|
195 |
+
// Resize content container height if inner panels change
|
196 |
+
setInterval(function(){
|
197 |
+
var $panel = $contentDivsContainer.children('.selected');
|
198 |
+
if($panel.outerHeight() > $contentDivsContainer.outerHeight() && heightLock)
|
199 |
+
resizeContentContainer($panel);
|
200 |
+
}, 100);
|
201 |
+
|
202 |
+
resizeTabsList();
|
203 |
+
|
204 |
+
// Hide tabs wrapper if option if false
|
205 |
+
if(!settings.tabs)
|
206 |
+
$tabsListWrapper.hide();
|
207 |
+
|
208 |
+
// Auto play
|
209 |
+
if(settings.autoplay)
|
210 |
+
setInterval(plugin.next, settings.autoplay);
|
211 |
+
|
212 |
+
// Panel arrows
|
213 |
+
|
214 |
+
// Mousehweel
|
215 |
+
$container.bind('mousewheel', function(event, delta, deltaX, deltaY) {
|
216 |
+
if(delta > 0)
|
217 |
+
plugin.next();
|
218 |
+
else if(delta < 0)
|
219 |
+
plugin.prev();
|
220 |
+
return false;
|
221 |
+
});
|
222 |
+
}
|
223 |
+
|
224 |
+
/*
|
225 |
+
* Public methods
|
226 |
+
*/
|
227 |
+
|
228 |
+
// Select tab
|
229 |
+
// param: tab is a tab index (1 ... n) or jQuery object of tab li element
|
230 |
+
plugin.selectTab = function(tab){
|
231 |
+
heightLock = false;
|
232 |
+
|
233 |
+
// Find $targetPanel, the panel to show
|
234 |
+
var $clicked = (typeof tab === 'number') ? $tabsList.children("li:nth-child("+tab+")") : tab;
|
235 |
+
var targetId = ($clicked.find('a').attr('href')).substr(1);
|
236 |
+
var $targetPanel = $contentDivsContainer.children("#"+targetId);
|
237 |
+
|
238 |
+
// Update selected tab
|
239 |
+
plugin.selectedTab = (typeof tab === 'number') ? tab : tab.index()+1;
|
240 |
+
|
241 |
+
// Resize the main contant container to the size of $targetPanel
|
242 |
+
resizeContentContainer($targetPanel);
|
243 |
+
|
244 |
+
// Lock selections until transitions finished
|
245 |
+
selectLock = true;
|
246 |
+
|
247 |
+
// Direction to slide panel on hide
|
248 |
+
var direction = ($tabsList.find('.selected').index() < $clicked.index()) ? 'left' : 'right';
|
249 |
+
|
250 |
+
// Update selected classes
|
251 |
+
$clicked.siblings().removeClass('selected');
|
252 |
+
if(settings.classes.tabActive != '') $clicked.siblings().removeClass(settings.classes.tabActive);
|
253 |
+
$clicked.addClass('selected').addClass(settings.classes.tabActive);
|
254 |
+
|
255 |
+
// Hide and show appropriate panels
|
256 |
+
hidePanel($contentDivsContainer.children(".ui-slider-tab-content:visible"), direction);
|
257 |
+
showPanel($targetPanel);
|
258 |
+
|
259 |
+
// Slide tabs so that they fit in $tabsListContainer
|
260 |
+
fitTabInContainer($clicked);
|
261 |
+
|
262 |
+
// Select the proper indicator
|
263 |
+
selectIndicator();
|
264 |
+
};
|
265 |
+
|
266 |
+
// Select the next (right) panel
|
267 |
+
plugin.next = function(){
|
268 |
+
if(!selectLock){
|
269 |
+
if(plugin.count === plugin.selectedTab)
|
270 |
+
plugin.selectTab(1);
|
271 |
+
else plugin.selectTab(plugin.selectedTab+1);
|
272 |
+
}
|
273 |
+
};
|
274 |
+
|
275 |
+
// Select the previous panel
|
276 |
+
plugin.prev = function(){
|
277 |
+
if(!selectLock){
|
278 |
+
if(plugin.selectedTab === 1)
|
279 |
+
plugin.selectTab(plugin.count);
|
280 |
+
else plugin.selectTab(plugin.selectedTab-1);
|
281 |
+
}
|
282 |
+
};
|
283 |
+
|
284 |
+
// Slide tabs left/right within $tabsListContainer
|
285 |
+
plugin.slideTabs = function(direction, length){
|
286 |
+
var margin = parseInt($tabsList.css('margin-left'));
|
287 |
+
var newMargin = margin;
|
288 |
+
|
289 |
+
// Reset 'edge' classes on tab arrows
|
290 |
+
$leftTabArrow.removeClass('edge');
|
291 |
+
$rightTabArrow.removeClass('edge');
|
292 |
+
|
293 |
+
// Calculate delta to slide by
|
294 |
+
if(direction=='right') newMargin += length;
|
295 |
+
else if(direction=='left') newMargin -= length;
|
296 |
+
if(newMargin >= 0) {
|
297 |
+
newMargin = 0;
|
298 |
+
$leftTabArrow.addClass('edge');
|
299 |
+
}
|
300 |
+
else if(newMargin <= minMargin){
|
301 |
+
newMargin = minMargin;
|
302 |
+
$rightTabArrow.addClass('edge');
|
303 |
+
}
|
304 |
+
|
305 |
+
// Animate
|
306 |
+
$tabsList.animate({'margin-left': newMargin}, settings.tabSlideSpeed);
|
307 |
+
};
|
308 |
+
|
309 |
+
// Show panel indicators
|
310 |
+
// Create indicators if they don't exist yet
|
311 |
+
plugin.showIndicators = function(){
|
312 |
+
if(!$indicators){
|
313 |
+
$indicators = $("<div class='ui-slider-tabs-indicator-container'>");
|
314 |
+
for(var i = 0; i < $contentDivs.length; i++){
|
315 |
+
$indicators.append("<div class='ui-slider-tabs-indicator'></div>");
|
316 |
+
}
|
317 |
+
$contentDivsContainer.append($indicators);
|
318 |
+
}
|
319 |
+
else
|
320 |
+
$indicators.show();
|
321 |
+
};
|
322 |
+
|
323 |
+
// Hide panel indicators
|
324 |
+
plugin.hideIndicators = function(){
|
325 |
+
if($indicators)
|
326 |
+
$indicators.hide();
|
327 |
+
};
|
328 |
+
|
329 |
+
// Show arrows that slide tabs left and right
|
330 |
+
plugin.showTabArrows = function(){
|
331 |
+
if(!settings.tabArrows)
|
332 |
+
return;
|
333 |
+
$leftTabArrow.show();
|
334 |
+
$rightTabArrow.show();
|
335 |
+
$tabsListContainer.css('margin', '0 '+settings.tabArrowWidth+'px');
|
336 |
+
};
|
337 |
+
|
338 |
+
// Hide arrows that slide tabs left and right
|
339 |
+
plugin.hideTabArrows = function(){
|
340 |
+
$leftTabArrow.hide();
|
341 |
+
$rightTabArrow.hide();
|
342 |
+
$tabsListContainer.css('margin', '0');
|
343 |
+
};
|
344 |
+
|
345 |
+
// Show panel arrows
|
346 |
+
plugin.showPanelArrows = function(){
|
347 |
+
if($leftPanelArrow) $leftPanelArrow.show();
|
348 |
+
if($rightPanelArrow) $rightPanelArrow.show();
|
349 |
+
};
|
350 |
+
|
351 |
+
// Hide panel arrows
|
352 |
+
plugin.hidePanelArrows = function(){
|
353 |
+
if($leftPanelArrow) $leftPanelArrow.hide();
|
354 |
+
if($rightPanelArrow) $rightPanelArrow.hide();
|
355 |
+
};
|
356 |
+
|
357 |
+
/*
|
358 |
+
* Private methods
|
359 |
+
*/
|
360 |
+
|
361 |
+
// Add the selected class to the plugin.selectedTab tab. Remove from all others.
|
362 |
+
var selectIndicator = function(){
|
363 |
+
if(settings.indicators && $indicators){
|
364 |
+
var $indicator = $indicators.children("div:nth-child("+plugin.selectedTab+")");
|
365 |
+
$indicator.siblings().removeClass('selected');
|
366 |
+
$indicator.addClass('selected');
|
367 |
+
}
|
368 |
+
};
|
369 |
+
|
370 |
+
// Slide tabs inside of $tabsListContainer so that the selected one fits inside
|
371 |
+
var fitTabInContainer = function(tab){
|
372 |
+
var tabOffset = tab.offset(),
|
373 |
+
containerOffset = $tabsListContainer.offset(),
|
374 |
+
leftOffset = tabOffset.left - containerOffset.left,
|
375 |
+
rightOffset = (containerOffset.left + $tabsListContainer.outerWidth()) - (tabOffset.left + tab.outerWidth() );
|
376 |
+
|
377 |
+
if(leftOffset < 0)
|
378 |
+
plugin.slideTabs('right', -leftOffset);
|
379 |
+
else if(rightOffset < 0)
|
380 |
+
plugin.slideTabs('left', -rightOffset);
|
381 |
+
};
|
382 |
+
|
383 |
+
// Reposition content panels so that they are ready to be transitioned in and out.
|
384 |
+
// This depends on whether the transition is set to slide or fade
|
385 |
+
var reorderPanels = function(){
|
386 |
+
// Position content divs
|
387 |
+
if(settings.transition == 'slide')
|
388 |
+
// Move panels left/right basedon their index relative to the selected panel
|
389 |
+
$tabsList.children('li').each(function(index, el){
|
390 |
+
var selectedIndex = $tabsList.children('.selected').index(),
|
391 |
+
thisIndex = $(el).index();
|
392 |
+
var panel = $contentDivsContainer.children('#'+$(el).find('a').attr('href').substr(1));
|
393 |
+
if(selectedIndex < thisIndex)
|
394 |
+
panel.css({left: $contentDivsContainer.width()+'px'});
|
395 |
+
else if(selectedIndex > thisIndex)
|
396 |
+
panel.css({left: '-'+$contentDivsContainer.width()+'px'});
|
397 |
+
else
|
398 |
+
panel.addClass(settings.classes.panelActive);
|
399 |
+
});
|
400 |
+
|
401 |
+
if(settings.transition == 'fade')
|
402 |
+
// Set opacity to correct value for non selected panels.
|
403 |
+
$tabsList.children('li').each(function(index, el){
|
404 |
+
var selectedIndex = $tabsList.children('.selected').index(),
|
405 |
+
thisIndex = $(el).index();
|
406 |
+
var panel = $contentDivsContainer.children('#'+$(el).find('a').attr('href').substr(1));
|
407 |
+
if(selectedIndex != thisIndex)
|
408 |
+
panel.css({opacity: 0});
|
409 |
+
else
|
410 |
+
panel.addClass(settings.classes.panelActive);
|
411 |
+
});
|
412 |
+
};
|
413 |
+
|
414 |
+
// Object determining css properties to be animated to based on various actions, transitions, and directions
|
415 |
+
var panelAnimationCSS = function(width){
|
416 |
+
return {
|
417 |
+
hide: {
|
418 |
+
slideleft: {
|
419 |
+
left: '-'+width+'px'
|
420 |
+
},
|
421 |
+
slideright: {
|
422 |
+
left: width+'px'
|
423 |
+
},
|
424 |
+
fade: {
|
425 |
+
opacity: 0
|
426 |
+
}
|
427 |
+
},
|
428 |
+
show: {
|
429 |
+
slide: {
|
430 |
+
left: 0
|
431 |
+
},
|
432 |
+
fade: {
|
433 |
+
opacity: 1
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
};
|
438 |
+
|
439 |
+
// Transition out the passed in panel.
|
440 |
+
// param: panel is the jQuery object of the panel to be hidden
|
441 |
+
// direction is either 'left' or 'right' for sliding transitions
|
442 |
+
var hidePanel = function(panel, direction){
|
443 |
+
// Calculate correct key in panelAnimationCSS
|
444 |
+
if(settings.transition == 'slide')
|
445 |
+
var trans = 'slide'+direction;
|
446 |
+
else var trans = settings.transition;
|
447 |
+
|
448 |
+
// Animate the panel out
|
449 |
+
panel.animate(panelAnimationCSS($contentDivsContainer.width())['hide'][trans], settings.transitionSpeed, settings.transitionEasing, function(){
|
450 |
+
panel.hide();
|
451 |
+
panel.removeClass('selected');
|
452 |
+
//if(settings.classes.panelActive != '') panel.removeClass(settings.classes.panelActive);
|
453 |
+
selectLock = false;
|
454 |
+
reorderPanels();
|
455 |
+
});
|
456 |
+
};
|
457 |
+
|
458 |
+
// Transition in the parameter panel
|
459 |
+
// param: panel is the jQuery object of the panel to be shown
|
460 |
+
var showPanel = function(panel){
|
461 |
+
// Show first
|
462 |
+
panel.show();
|
463 |
+
panel.addClass(settings.classes.panelActive).addClass('selected');
|
464 |
+
|
465 |
+
// Then animate css properties
|
466 |
+
panel.animate(panelAnimationCSS($contentDivsContainer.width())['show'][settings.transition], settings.transitionSpeed, settings.transitionEasing, function(){
|
467 |
+
selectLock = false;
|
468 |
+
heightLock = true;
|
469 |
+
reorderPanels();
|
470 |
+
});
|
471 |
+
};
|
472 |
+
|
473 |
+
// Animate the height of the content container to height target
|
474 |
+
// params: target (int) is the new height
|
475 |
+
var resizeContentContainer = function(target){
|
476 |
+
if(!settings.height)
|
477 |
+
$contentDivsContainer.animate({
|
478 |
+
height: actualHeight(target)
|
479 |
+
}, 200);
|
480 |
+
};
|
481 |
+
|
482 |
+
// Position the panel arrows
|
483 |
+
var positionPanelArrows = function(){
|
484 |
+
if(settings.panelArrows){
|
485 |
+
// Initialize them if you need to
|
486 |
+
if(!$leftPanelArrow && !$rightPanelArrow){
|
487 |
+
$leftPanelArrow = $("<div class='ui-slider-tabs-leftPanelArrow'>").click(function(){
|
488 |
+
plugin.prev();
|
489 |
+
});
|
490 |
+
$rightPanelArrow = $("<div class='ui-slider-tabs-rightPanelArrow'>").click(function(){
|
491 |
+
plugin.next();
|
492 |
+
});
|
493 |
+
|
494 |
+
$leftPanelArrow.appendTo($contentDivsContainer);
|
495 |
+
$rightPanelArrow.appendTo($contentDivsContainer);
|
496 |
+
}
|
497 |
+
|
498 |
+
// Set correct CSS 'top' attribute of each panel arrow
|
499 |
+
$rightPanelArrow.css({
|
500 |
+
"top": $contentDivsContainer.height()/2 - $rightPanelArrow.outerHeight()/2
|
501 |
+
});
|
502 |
+
$leftPanelArrow.css({
|
503 |
+
"top": $contentDivsContainer.height()/2 - $leftPanelArrow.outerHeight()/2
|
504 |
+
});
|
505 |
+
}
|
506 |
+
};
|
507 |
+
|
508 |
+
// Change the width of $tabsList to the sum of the outer widths of all tabs
|
509 |
+
var resizeTabsList = function(){
|
510 |
+
// Calculate total width
|
511 |
+
var width = 0;
|
512 |
+
$tabsList.children().each(function(index, element){
|
513 |
+
width += $(element).outerWidth(true);
|
514 |
+
});
|
515 |
+
// Set new width of $tabsList
|
516 |
+
$tabsList.width(width);
|
517 |
+
|
518 |
+
// Update minMargin. Hide tab arrows if no overflow
|
519 |
+
if($tabsListContainer.width() < width && settings.tabArrows){
|
520 |
+
plugin.showTabArrows();
|
521 |
+
minMargin = $tabsListContainer.width() - width;
|
522 |
+
}
|
523 |
+
else plugin.hideTabArrows();
|
524 |
+
}
|
525 |
+
|
526 |
+
// Resize indiviual panels to the width of the new container
|
527 |
+
var resizePanels = function(){
|
528 |
+
$contentDivs.width($contentDivsContainer.width() - ($contentDivs.outerWidth() - $contentDivs.width()));
|
529 |
+
};
|
530 |
+
|
531 |
+
// Get height of a hidden element
|
532 |
+
var actualHeight = function(element){
|
533 |
+
var prevCSS = {
|
534 |
+
'display': element.css('display'),
|
535 |
+
'left': element.css('left'),
|
536 |
+
'position': element.css('position')
|
537 |
+
};
|
538 |
+
element.css({
|
539 |
+
'display': 'normal',
|
540 |
+
'left': -5000,
|
541 |
+
'position': 'absolute'
|
542 |
+
});
|
543 |
+
var height = element.outerHeight();
|
544 |
+
element.css(prevCSS);
|
545 |
+
return height;
|
546 |
+
};
|
547 |
+
|
548 |
+
|
549 |
+
// Initialize the plugin
|
550 |
+
plugin.init();
|
551 |
+
};
|
552 |
+
|
553 |
+
/*
|
554 |
+
* Handle input. Call public functions and initializers
|
555 |
+
*/
|
556 |
+
$.fn.sliderTabs = function( data ) {
|
557 |
+
return this.each(function(){
|
558 |
+
var _this = $(this),
|
559 |
+
plugin = _this.data('sliderTabs');
|
560 |
+
|
561 |
+
// Method calling logic
|
562 |
+
if (!plugin) {
|
563 |
+
// If no plugin, initialize it
|
564 |
+
plugin = new $.sliderTabs(this, data);
|
565 |
+
_this.data('sliderTabs', plugin);
|
566 |
+
return plugin;
|
567 |
+
}
|
568 |
+
if (plugin.methods[data]){
|
569 |
+
// If plugin exists, call a public method
|
570 |
+
return plugin.methods[ data ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
571 |
+
}
|
572 |
+
});
|
573 |
+
};
|
574 |
+
})( jQuery );
|
575 |
+
|
576 |
+
|
577 |
+
|
578 |
+
|
579 |
+
|
580 |
+
/*
|
581 |
+
* Additional easing functions
|
582 |
+
* Taken from jQuery UI source code
|
583 |
+
*
|
584 |
+
* https://github.com/jquery/jquery-ui
|
585 |
+
*/
|
586 |
+
|
587 |
+
$.extend($.easing,
|
588 |
+
{
|
589 |
+
def: 'easeOutQuad',
|
590 |
+
swing: function (x, t, b, c, d) {
|
591 |
+
//alert($.easing.default);
|
592 |
+
return $.easing[$.easing.def](x, t, b, c, d);
|
593 |
+
},
|
594 |
+
easeInQuad: function (x, t, b, c, d) {
|
595 |
+
return c*(t/=d)*t + b;
|
596 |
+
},
|
597 |
+
easeOutQuad: function (x, t, b, c, d) {
|
598 |
+
return -c *(t/=d)*(t-2) + b;
|
599 |
+
},
|
600 |
+
easeInOutQuad: function (x, t, b, c, d) {
|
601 |
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
602 |
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
603 |
+
},
|
604 |
+
easeInCubic: function (x, t, b, c, d) {
|
605 |
+
return c*(t/=d)*t*t + b;
|
606 |
+
},
|
607 |
+
easeOutCubic: function (x, t, b, c, d) {
|
608 |
+
return c*((t=t/d-1)*t*t + 1) + b;
|
609 |
+
},
|
610 |
+
easeInOutCubic: function (x, t, b, c, d) {
|
611 |
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
612 |
+
return c/2*((t-=2)*t*t + 2) + b;
|
613 |
+
},
|
614 |
+
easeInQuart: function (x, t, b, c, d) {
|
615 |
+
return c*(t/=d)*t*t*t + b;
|
616 |
+
},
|
617 |
+
easeOutQuart: function (x, t, b, c, d) {
|
618 |
+
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
619 |
+
},
|
620 |
+
easeInOutQuart: function (x, t, b, c, d) {
|
621 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
622 |
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
623 |
+
},
|
624 |
+
easeInQuint: function (x, t, b, c, d) {
|
625 |
+
return c*(t/=d)*t*t*t*t + b;
|
626 |
+
},
|
627 |
+
easeOutQuint: function (x, t, b, c, d) {
|
628 |
+
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
629 |
+
},
|
630 |
+
easeInOutQuint: function (x, t, b, c, d) {
|
631 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
632 |
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
633 |
+
},
|
634 |
+
easeInSine: function (x, t, b, c, d) {
|
635 |
+
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
636 |
+
},
|
637 |
+
easeOutSine: function (x, t, b, c, d) {
|
638 |
+
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
639 |
+
},
|
640 |
+
easeInOutSine: function (x, t, b, c, d) {
|
641 |
+
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
642 |
+
},
|
643 |
+
easeInExpo: function (x, t, b, c, d) {
|
644 |
+
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
645 |
+
},
|
646 |
+
easeOutExpo: function (x, t, b, c, d) {
|
647 |
+
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
648 |
+
},
|
649 |
+
easeInOutExpo: function (x, t, b, c, d) {
|
650 |
+
if (t==0) return b;
|
651 |
+
if (t==d) return b+c;
|
652 |
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
653 |
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
654 |
+
},
|
655 |
+
easeInCirc: function (x, t, b, c, d) {
|
656 |
+
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
657 |
+
},
|
658 |
+
easeOutCirc: function (x, t, b, c, d) {
|
659 |
+
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
660 |
+
},
|
661 |
+
easeInOutCirc: function (x, t, b, c, d) {
|
662 |
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
663 |
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
664 |
+
},
|
665 |
+
easeInElastic: function (x, t, b, c, d) {
|
666 |
+
var s=1.70158;var p=0;var a=c;
|
667 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
668 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
669 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
670 |
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
671 |
+
},
|
672 |
+
easeOutElastic: function (x, t, b, c, d) {
|
673 |
+
var s=1.70158;var p=0;var a=c;
|
674 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
675 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
676 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
677 |
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
678 |
+
},
|
679 |
+
easeInOutElastic: function (x, t, b, c, d) {
|
680 |
+
var s=1.70158;var p=0;var a=c;
|
681 |
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
682 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
683 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
684 |
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
685 |
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
686 |
+
},
|
687 |
+
easeInBack: function (x, t, b, c, d, s) {
|
688 |
+
if (s == undefined) s = 1.70158;
|
689 |
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
690 |
+
},
|
691 |
+
easeOutBack: function (x, t, b, c, d, s) {
|
692 |
+
if (s == undefined) s = 1.70158;
|
693 |
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
694 |
+
},
|
695 |
+
easeInOutBack: function (x, t, b, c, d, s) {
|
696 |
+
if (s == undefined) s = 1.70158;
|
697 |
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
698 |
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
699 |
+
},
|
700 |
+
easeInBounce: function (x, t, b, c, d) {
|
701 |
+
return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
702 |
+
},
|
703 |
+
easeOutBounce: function (x, t, b, c, d) {
|
704 |
+
if ((t/=d) < (1/2.75)) {
|
705 |
+
return c*(7.5625*t*t) + b;
|
706 |
+
} else if (t < (2/2.75)) {
|
707 |
+
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
708 |
+
} else if (t < (2.5/2.75)) {
|
709 |
+
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
710 |
+
} else {
|
711 |
+
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
712 |
+
}
|
713 |
+
},
|
714 |
+
easeInOutBounce: function (x, t, b, c, d) {
|
715 |
+
if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
716 |
+
return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
717 |
+
}
|
718 |
+
});
|
719 |
+
|
720 |
+
|
721 |
+
|
722 |
+
|
723 |
+
|
724 |
+
/*
|
725 |
+
* The following is the jQuery Mousewheel plugin. Full credit goes to
|
726 |
+
* Brandon Aaron. (https://github.com/brandonaaron/jquery-mousewheel)
|
727 |
+
* /
|
728 |
+
|
729 |
+
|
730 |
+
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
|
731 |
+
* Licensed under the MIT License (LICENSE.txt).
|
732 |
+
*
|
733 |
+
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
734 |
+
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
735 |
+
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
736 |
+
*
|
737 |
+
* Version: 3.0.6
|
738 |
+
*
|
739 |
+
* Requires: 1.2.2+
|
740 |
+
*/
|
741 |
+
|
742 |
+
(function($) {
|
743 |
+
|
744 |
+
var types = ['DOMMouseScroll', 'mousewheel'];
|
745 |
+
|
746 |
+
if ($.event.fixHooks) {
|
747 |
+
for ( var i=types.length; i; ) {
|
748 |
+
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
$.event.special.mousewheel = {
|
753 |
+
setup: function() {
|
754 |
+
if ( this.addEventListener ) {
|
755 |
+
for ( var i=types.length; i; ) {
|
756 |
+
this.addEventListener( types[--i], handler, false );
|
757 |
+
}
|
758 |
+
} else {
|
759 |
+
this.onmousewheel = handler;
|
760 |
+
}
|
761 |
+
},
|
762 |
+
|
763 |
+
teardown: function() {
|
764 |
+
if ( this.removeEventListener ) {
|
765 |
+
for ( var i=types.length; i; ) {
|
766 |
+
this.removeEventListener( types[--i], handler, false );
|
767 |
+
}
|
768 |
+
} else {
|
769 |
+
this.onmousewheel = null;
|
770 |
+
}
|
771 |
+
}
|
772 |
+
};
|
773 |
+
|
774 |
+
$.fn.extend({
|
775 |
+
mousewheel: function(fn) {
|
776 |
+
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
777 |
+
},
|
778 |
+
|
779 |
+
unmousewheel: function(fn) {
|
780 |
+
return this.unbind("mousewheel", fn);
|
781 |
+
}
|
782 |
+
});
|
783 |
+
|
784 |
+
|
785 |
+
function handler(event) {
|
786 |
+
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
787 |
+
event = $.event.fix(orgEvent);
|
788 |
+
event.type = "mousewheel";
|
789 |
+
|
790 |
+
// Old school scrollwheel delta
|
791 |
+
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
|
792 |
+
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
|
793 |
+
|
794 |
+
// New school multidimensional scroll (touchpads) deltas
|
795 |
+
deltaY = delta;
|
796 |
+
|
797 |
+
// Gecko
|
798 |
+
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
799 |
+
deltaY = 0;
|
800 |
+
deltaX = -1*delta;
|
801 |
+
}
|
802 |
+
|
803 |
+
// Webkit
|
804 |
+
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
805 |
+
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
806 |
+
|
807 |
+
// Add event and delta to the front of the arguments
|
808 |
+
args.unshift(event, delta, deltaX, deltaY);
|
809 |
+
|
810 |
+
return ($.event.dispatch || $.event.handle).apply(this, args);
|
811 |
+
}
|
812 |
+
|
813 |
+
})(jQuery);
|
814 |
+
|
815 |
+
|
816 |
+
|
817 |
+
/*
|
818 |
+
* The following is the jQuery Resize plugin. Full credit goes to
|
819 |
+
* "Cowboy" Ben Alman. (https://github.com/cowboy/jquery-resize)
|
820 |
+
* /
|
821 |
+
|
822 |
+
/*
|
823 |
+
* jQuery resize event - v1.1 - 3/14/2010
|
824 |
+
* http://benalman.com/projects/jquery-resize-plugin/
|
825 |
+
*
|
826 |
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
827 |
+
* Dual licensed under the MIT and GPL licenses.
|
828 |
+
* http://benalman.com/about/license/
|
829 |
+
*/
|
830 |
+
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
app/helper/RTMediaAddon.php
CHANGED
@@ -90,11 +90,11 @@ if (!class_exists('RTMediaAddon')) {
|
|
90 |
|
91 |
|
92 |
public function plugins_content($args = '') {
|
93 |
-
|
94 |
$addons = array(
|
95 |
array(
|
96 |
'title' => __('rtMedia Photo Tagging', 'rtmedia'),
|
97 |
-
'img_src' => '
|
98 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-photo-tagging/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
99 |
'desc' => '<p>' . __('rtMedia Photo Tagging add-on enables tagging on photos uploaded using BuddyPress Media.', 'rtmedia') . '</p>
|
100 |
<p><strong>' . __('Important', 'rtmedia') . ':</strong> ' . __('You need to have ImageMagick installed on your server for this addon to work.', 'rtmedia') . '</p>',
|
@@ -104,7 +104,7 @@ if (!class_exists('RTMediaAddon')) {
|
|
104 |
),
|
105 |
array(
|
106 |
'title' => __('rtMedia Instagram', 'rtmedia'),
|
107 |
-
'img_src' => '
|
108 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-instagram/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
109 |
'desc' => '<p>' . __('rtMedia Instagram adds Instagram like filters to images uploaded with rtMedia.', 'rtmedia') . '</p>
|
110 |
<p><strong>' . __('Important', 'rtmedia') . ':</strong> ' . __('You need to have ImageMagick installed on your server for this addon to work.', 'rtmedia') . '</p>',
|
@@ -114,7 +114,7 @@ if (!class_exists('RTMediaAddon')) {
|
|
114 |
),
|
115 |
array(
|
116 |
'title' => __('rtMedia Kaltura Add-on', 'rtmedia'),
|
117 |
-
'img_src' => '
|
118 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-kaltura/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
119 |
'desc' => '<p>' . __('Add support for more video formats using Kaltura video solution.', 'rtmedia') . '</p>
|
120 |
<p>' . __('Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.', 'rtmedia') . '</p>',
|
@@ -124,7 +124,7 @@ if (!class_exists('RTMediaAddon')) {
|
|
124 |
),
|
125 |
array(
|
126 |
'title' => __('rtMedia FFMPEG Add-on', 'rtmedia'),
|
127 |
-
'img_src' => '
|
128 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-ffmpeg-converter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
129 |
'desc' => '<p>' . __('Add supports for more audio & video formats using open-source media-node.', 'rtmedia') . '</p>
|
130 |
<p>' . __('Media node comes with automated setup script for Ubuntu/Debian.', 'rtmedia') . '</p>',
|
90 |
|
91 |
|
92 |
public function plugins_content($args = '') {
|
93 |
+
$img_src = RTMEDIA_URL .'app/assets/img/';
|
94 |
$addons = array(
|
95 |
array(
|
96 |
'title' => __('rtMedia Photo Tagging', 'rtmedia'),
|
97 |
+
'img_src' => $img_src.'bpm-photo-tagging.png',
|
98 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-photo-tagging/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
99 |
'desc' => '<p>' . __('rtMedia Photo Tagging add-on enables tagging on photos uploaded using BuddyPress Media.', 'rtmedia') . '</p>
|
100 |
<p><strong>' . __('Important', 'rtmedia') . ':</strong> ' . __('You need to have ImageMagick installed on your server for this addon to work.', 'rtmedia') . '</p>',
|
104 |
),
|
105 |
array(
|
106 |
'title' => __('rtMedia Instagram', 'rtmedia'),
|
107 |
+
'img_src' => $img_src.'BuddyPressMedia-Instagram.png',
|
108 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-instagram/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
109 |
'desc' => '<p>' . __('rtMedia Instagram adds Instagram like filters to images uploaded with rtMedia.', 'rtmedia') . '</p>
|
110 |
<p><strong>' . __('Important', 'rtmedia') . ':</strong> ' . __('You need to have ImageMagick installed on your server for this addon to work.', 'rtmedia') . '</p>',
|
114 |
),
|
115 |
array(
|
116 |
'title' => __('rtMedia Kaltura Add-on', 'rtmedia'),
|
117 |
+
'img_src' => $img_src.'new-buddypress-media-kaltura-logo-240x184.png',
|
118 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-kaltura/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
119 |
'desc' => '<p>' . __('Add support for more video formats using Kaltura video solution.', 'rtmedia') . '</p>
|
120 |
<p>' . __('Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.', 'rtmedia') . '</p>',
|
124 |
),
|
125 |
array(
|
126 |
'title' => __('rtMedia FFMPEG Add-on', 'rtmedia'),
|
127 |
+
'img_src' => $img_src.'ffmpeg-logo-240x184.png',
|
128 |
'product_link' => 'http://rtcamp.com/store/buddypress-media-ffmpeg-converter/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media',
|
129 |
'desc' => '<p>' . __('Add supports for more audio & video formats using open-source media-node.', 'rtmedia') . '</p>
|
130 |
<p>' . __('Media node comes with automated setup script for Ubuntu/Debian.', 'rtmedia') . '</p>',
|
app/helper/RTMediaSettings.php
CHANGED
@@ -39,7 +39,8 @@ if (!class_exists('RTMediaSettings')) {
|
|
39 |
'general_showAdminMenu' => 0,
|
40 |
'general_videothumbs' => 2,
|
41 |
'general_uniqueviewcount' => 0,
|
42 |
-
'general_viewcount' => 0
|
|
|
43 |
);
|
44 |
|
45 |
$defaults = apply_filters('rtmedia_general_content_default_values', $defaults);
|
@@ -98,7 +99,7 @@ if (!class_exists('RTMediaSettings')) {
|
|
98 |
}
|
99 |
$rtmedia_addon = new RTMediaAddon();
|
100 |
add_settings_section('rtm-addons', __('BuddyPress Media Addons for Photos', 'rtmedia'), array($rtmedia_addon, 'get_addons'), 'rtmedia-addons');
|
101 |
-
|
102 |
add_settings_section('rtm-support', __('Support', 'rtmedia'), array($rtmedia_support, 'get_support_content'), 'rtmedia-support');
|
103 |
|
104 |
// if (!BPMediaPrivacy::is_installed()) {
|
@@ -236,11 +237,11 @@ if (!class_exists('RTMediaSettings')) {
|
|
236 |
);
|
237 |
|
238 |
$notice = '
|
239 |
-
|
240 |
-
|
241 |
. '<a href="' . $url . '">' . __('Update Database', 'rtmedia') . '.</a></p>
|
242 |
-
|
243 |
-
|
244 |
echo $notice;
|
245 |
}
|
246 |
}
|
@@ -252,4 +253,4 @@ if (!class_exists('RTMediaSettings')) {
|
|
252 |
|
253 |
}
|
254 |
|
255 |
-
}
|
39 |
'general_showAdminMenu' => 0,
|
40 |
'general_videothumbs' => 2,
|
41 |
'general_uniqueviewcount' => 0,
|
42 |
+
'general_viewcount' => 0,
|
43 |
+
'general_AllowUserData' => 0
|
44 |
);
|
45 |
|
46 |
$defaults = apply_filters('rtmedia_general_content_default_values', $defaults);
|
99 |
}
|
100 |
$rtmedia_addon = new RTMediaAddon();
|
101 |
add_settings_section('rtm-addons', __('BuddyPress Media Addons for Photos', 'rtmedia'), array($rtmedia_addon, 'get_addons'), 'rtmedia-addons');
|
102 |
+
$rtmedia_support = new RTMediaSupport(false);
|
103 |
add_settings_section('rtm-support', __('Support', 'rtmedia'), array($rtmedia_support, 'get_support_content'), 'rtmedia-support');
|
104 |
|
105 |
// if (!BPMediaPrivacy::is_installed()) {
|
237 |
);
|
238 |
|
239 |
$notice = '
|
240 |
+
<div class="error">
|
241 |
+
<p>' . __('BuddyPress Media 2.6 requires a database upgrade. ', 'rtmedia')
|
242 |
. '<a href="' . $url . '">' . __('Update Database', 'rtmedia') . '.</a></p>
|
243 |
+
</div>
|
244 |
+
';
|
245 |
echo $notice;
|
246 |
}
|
247 |
}
|
253 |
|
254 |
}
|
255 |
|
256 |
+
}
|
app/helper/rtPluginUpdateChecker.php
CHANGED
@@ -1,665 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* A custom plugin update checker.
|
6 |
-
*
|
7 |
-
* @author faishal
|
8 |
-
*/
|
9 |
-
class rtPluginUpdateChecker {
|
10 |
-
|
11 |
-
public $metadataUrl = ''; //The URL of the plugin's metadata file.
|
12 |
-
public $pluginFile = ''; //Plugin filename relative to the plugins directory.
|
13 |
-
public $slug = ''; //Plugin slug.
|
14 |
-
public $checkPeriod = 12; //How often to check for updates (in hours).
|
15 |
-
public $optionName = ''; //Where to store the update info.
|
16 |
-
public $debugMode = true; //Set to TRUE to enable error reporting. Errors are raised using trigger_error()
|
17 |
-
//and should be logged to the standard PHP error log.
|
18 |
-
private $cronHook = null;
|
19 |
-
private $debugBarPlugin = null;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class constructor.
|
23 |
-
*
|
24 |
-
* @param string $metadataUrl The URL of the plugin's metadata file.
|
25 |
-
* @param string $pluginFile Fully qualified path to the main plugin file.
|
26 |
-
* @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
|
27 |
-
* @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
|
28 |
-
* @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
|
29 |
-
*/
|
30 |
-
|
31 |
-
/**
|
32 |
-
*
|
33 |
-
* @param type $metadataUrl
|
34 |
-
* @param type $pluginFile
|
35 |
-
* @param type $slug
|
36 |
-
* @param type $checkPeriod
|
37 |
-
* @param type $optionName
|
38 |
-
*/
|
39 |
-
public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '') {
|
40 |
-
if(strpos($metadataUrl,"https:") !== false){
|
41 |
-
$metadataUrl = str_replace("https:", "http:", $metadataUrl);
|
42 |
-
}
|
43 |
-
$this->metadataUrl = $metadataUrl;
|
44 |
-
$this->pluginFile = plugin_basename($pluginFile);
|
45 |
-
$this->checkPeriod = $checkPeriod;
|
46 |
-
$this->slug = $slug;
|
47 |
-
$this->optionName = $optionName;
|
48 |
-
$this->debugMode = defined('WP_DEBUG') && WP_DEBUG;
|
49 |
-
|
50 |
-
//If no slug is specified, use the name of the main plugin file as the slug.
|
51 |
-
//For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
|
52 |
-
if (empty($this->slug)) {
|
53 |
-
$this->slug = basename($this->pluginFile, '.php');
|
54 |
-
}
|
55 |
-
|
56 |
-
if (empty($this->optionName)) {
|
57 |
-
$this->optionName = 'external_updates-' . $this->slug;
|
58 |
-
}
|
59 |
-
|
60 |
-
$this->installHooks();
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Install the hooks required to run periodic update checks and inject update info
|
65 |
-
* into WP data structures.
|
66 |
-
*
|
67 |
-
* @return void
|
68 |
-
*/
|
69 |
-
protected function installHooks() {
|
70 |
-
//Override requests for plugin information
|
71 |
-
add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
|
72 |
-
|
73 |
-
//Insert our update info into the update array maintained by WP
|
74 |
-
add_filter('site_transient_update_plugins', array($this, 'injectUpdate')); //WP 3.0+
|
75 |
-
add_filter('transient_update_plugins', array($this, 'injectUpdate')); //WP 2.8+
|
76 |
-
|
77 |
-
add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 4);
|
78 |
-
add_action('admin_init', array($this, 'handleManualCheck'));
|
79 |
-
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
|
80 |
-
|
81 |
-
//Set up the periodic update checks
|
82 |
-
$this->cronHook = 'check_plugin_updates-' . $this->slug;
|
83 |
-
if ($this->checkPeriod > 0) {
|
84 |
-
|
85 |
-
//Trigger the check via Cron
|
86 |
-
add_filter('cron_schedules', array($this, '_addCustomSchedule'));
|
87 |
-
if (!wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING')) {
|
88 |
-
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
89 |
-
wp_schedule_event(time(), $scheduleName, $this->cronHook);
|
90 |
-
}
|
91 |
-
add_action($this->cronHook, array($this, 'checkForUpdates'));
|
92 |
-
|
93 |
-
register_deactivation_hook($this->pluginFile, array($this, '_removeUpdaterCron'));
|
94 |
-
|
95 |
-
//In case Cron is disabled or unreliable, we also manually trigger
|
96 |
-
//the periodic checks while the user is browsing the Dashboard.
|
97 |
-
add_action('admin_init', array($this, 'maybeCheckForUpdates'));
|
98 |
-
} else {
|
99 |
-
//Periodic checks are disabled.
|
100 |
-
wp_clear_scheduled_hook($this->cronHook);
|
101 |
-
}
|
102 |
-
|
103 |
-
add_action('plugins_loaded', array($this, 'initDebugBarPanel'));
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Add our custom schedule to the array of Cron schedules used by WP.
|
108 |
-
*
|
109 |
-
* @param array $schedules
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
|
113 |
-
/**
|
114 |
-
*
|
115 |
-
* @param type $schedules
|
116 |
-
* @return type
|
117 |
-
*/
|
118 |
-
public function _addCustomSchedule($schedules) {
|
119 |
-
if ($this->checkPeriod && ($this->checkPeriod > 0)) {
|
120 |
-
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
121 |
-
$schedules[$scheduleName] = array(
|
122 |
-
'interval' => $this->checkPeriod * 3600,
|
123 |
-
'display' => sprintf( __( "Every %d hours", 'rtmedia' ), $this->checkPeriod),
|
124 |
-
);
|
125 |
-
}
|
126 |
-
return $schedules;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Remove the scheduled cron event that the library uses to check for updates.
|
131 |
-
*
|
132 |
-
* @return void
|
133 |
-
*/
|
134 |
-
public function _removeUpdaterCron() {
|
135 |
-
wp_clear_scheduled_hook($this->cronHook);
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
|
140 |
-
*
|
141 |
-
* @return string
|
142 |
-
*/
|
143 |
-
|
144 |
-
/**
|
145 |
-
*
|
146 |
-
* @return type
|
147 |
-
*/
|
148 |
-
public function getCronHookName() {
|
149 |
-
return $this->cronHook;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Retrieve plugin info from the configured API endpoint.
|
154 |
-
*
|
155 |
-
* @uses wp_remote_get()
|
156 |
-
*
|
157 |
-
* @param array $queryArgs Additional query arguments to append to the request. Optional.
|
158 |
-
* @return PluginInfo
|
159 |
-
*/
|
160 |
-
|
161 |
-
/**
|
162 |
-
*
|
163 |
-
* @param type $queryArgs
|
164 |
-
* @return type
|
165 |
-
*/
|
166 |
-
public function requestInfo($queryArgs = array()) {
|
167 |
-
//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
|
168 |
-
$installedVersion = $this->getInstalledVersion();
|
169 |
-
$queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : '';
|
170 |
-
$queryArgs['admin_email'] = get_option("admin_email");
|
171 |
-
$queryArgs['slug'] = $this->slug;
|
172 |
-
$queryArgs = apply_filters('puc_request_info_query_args-' . $this->slug, $queryArgs);
|
173 |
-
//Various options for the wp_remote_get() call. Plugins can filter these, too.
|
174 |
-
$options = array(
|
175 |
-
'timeout' => 10, //seconds
|
176 |
-
'headers' => array(
|
177 |
-
'Accept' => 'application/json'
|
178 |
-
),
|
179 |
-
);
|
180 |
-
$options = apply_filters('puc_request_info_options-' . $this->slug, $options);
|
181 |
-
|
182 |
-
//The plugin info should be at 'http://your-api.com/url/here/$slug/info.json'
|
183 |
-
$url = $this->metadataUrl;
|
184 |
-
if (!empty($queryArgs)) {
|
185 |
-
$url = add_query_arg($queryArgs, $url);
|
186 |
-
}
|
187 |
-
|
188 |
-
$result = wp_remote_get(
|
189 |
-
$url, $options
|
190 |
-
);
|
191 |
-
//Try to parse the response
|
192 |
-
$pluginInfo = null;
|
193 |
-
if (!is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body'])) {
|
194 |
-
$pluginInfo = rtPluginInfo::fromJson($result['body'], $this->debugMode);
|
195 |
-
} else if ($this->debugMode) {
|
196 |
-
$message = sprintf( __( "The URL %s does not point to a valid plugin metadata file.", 'rtmedia'), $url );
|
197 |
-
if (is_wp_error($result)) {
|
198 |
-
$message .= sprintf( __( "WP HTTP error: %s", 'rtmedia'), $result->get_error_message() );
|
199 |
-
} else if (isset($result['response']['code'])) {
|
200 |
-
$message .= sprintf( __( "HTTP response code is %s (expected: 200)", 'rtmedia'), $result['response']['code'] );
|
201 |
-
} else {
|
202 |
-
$message .= __( 'wp_remote_get() returned an unexpected result.', 'rtmedia' );
|
203 |
-
}
|
204 |
-
trigger_error($message, E_USER_WARNING);
|
205 |
-
}
|
206 |
-
|
207 |
-
$pluginInfo = apply_filters('puc_request_info_result-' . $this->slug, $pluginInfo, $result);
|
208 |
-
return $pluginInfo;
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Retrieve the latest update (if any) from the configured API endpoint.
|
213 |
-
*
|
214 |
-
* @uses PluginUpdateChecker::requestInfo()
|
215 |
-
*
|
216 |
-
* @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available.
|
217 |
-
*/
|
218 |
-
|
219 |
-
/**
|
220 |
-
*
|
221 |
-
* @return null
|
222 |
-
*/
|
223 |
-
public function requestUpdate() {
|
224 |
-
//For the sake of simplicity, this function just calls requestInfo()
|
225 |
-
//and transforms the result accordingly.
|
226 |
-
$pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
|
227 |
-
if ($pluginInfo == null) {
|
228 |
-
return null;
|
229 |
-
}
|
230 |
-
return rtPluginUpdate::fromPluginInfo($pluginInfo);
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Get the currently installed version of the plugin.
|
235 |
-
*
|
236 |
-
* @return string Version number.
|
237 |
-
*/
|
238 |
-
|
239 |
-
/**
|
240 |
-
*
|
241 |
-
* @return null
|
242 |
-
*/
|
243 |
-
public function getInstalledVersion() {
|
244 |
-
|
245 |
-
if (!function_exists('get_plugins')) {
|
246 |
-
if (is_multisite()) {
|
247 |
-
require_once( ABSPATH . '/wp-admin/network/includes/plugin.php' );
|
248 |
-
} else {
|
249 |
-
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
250 |
-
}
|
251 |
-
}
|
252 |
-
$allPlugins = get_plugins();
|
253 |
-
if (array_key_exists($this->pluginFile, $allPlugins) && array_key_exists('Version', $allPlugins[$this->pluginFile])) {
|
254 |
-
return $allPlugins[$this->pluginFile]['Version'];
|
255 |
-
} else {
|
256 |
-
//This can happen if the filename is wrong or the plugin is installed in mu-plugins.
|
257 |
-
if ($this->debugMode) {
|
258 |
-
trigger_error(
|
259 |
-
sprintf( __( "Can't to read the Version header for %s. The filename may be incorrect, or the file is not present in /wp-content/plugins.", 'rtmedia' ), $this->pluginFile ), E_USER_WARNING
|
260 |
-
);
|
261 |
-
}
|
262 |
-
return null;
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Check for plugin updates.
|
268 |
-
* The results are stored in the DB option specified in $optionName.
|
269 |
-
*
|
270 |
-
* @return PluginUpdate|null
|
271 |
-
*/
|
272 |
-
|
273 |
-
/**
|
274 |
-
*
|
275 |
-
* @return null
|
276 |
-
*/
|
277 |
-
public function checkForUpdates() {
|
278 |
-
$installedVersion = $this->getInstalledVersion();
|
279 |
-
//Fail silently if we can't find the plugin or read its header.
|
280 |
-
if ($installedVersion === null) {
|
281 |
-
if ($this->debugMode) {
|
282 |
-
trigger_error(
|
283 |
-
sprintf( __( "Skipping update check for %s - installed version unknown.", 'rtmedia'), $this->pluginFile ), E_USER_WARNING
|
284 |
-
);
|
285 |
-
}
|
286 |
-
return null;
|
287 |
-
}
|
288 |
-
|
289 |
-
$state = $this->getUpdateState();
|
290 |
-
if (empty($state)) {
|
291 |
-
$state = new StdClass;
|
292 |
-
$state->lastCheck = 0;
|
293 |
-
$state->checkedVersion = '';
|
294 |
-
$state->update = null;
|
295 |
-
}
|
296 |
-
|
297 |
-
$state->lastCheck = time();
|
298 |
-
$state->checkedVersion = $installedVersion;
|
299 |
-
$this->setUpdateState($state); //Save before checking in case something goes wrong
|
300 |
-
|
301 |
-
$state->update = $this->requestUpdate();
|
302 |
-
$this->setUpdateState($state);
|
303 |
-
|
304 |
-
return $this->getUpdate();
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Check for updates only if the configured check interval has already elapsed.
|
309 |
-
*
|
310 |
-
* @return void
|
311 |
-
*/
|
312 |
-
|
313 |
-
/**
|
314 |
-
*
|
315 |
-
* @return type
|
316 |
-
*/
|
317 |
-
public function maybeCheckForUpdates() {
|
318 |
-
if (empty($this->checkPeriod)) {
|
319 |
-
return;
|
320 |
-
}
|
321 |
-
$state = $this->getUpdateState();
|
322 |
-
|
323 |
-
$shouldCheck =
|
324 |
-
empty($state) ||
|
325 |
-
!isset($state->lastCheck) ||
|
326 |
-
( (time() - $state->lastCheck) >= $this->checkPeriod * 3600 );
|
327 |
-
|
328 |
-
if ($shouldCheck) {
|
329 |
-
$this->checkForUpdates();
|
330 |
-
}
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Load the update checker state from the DB.
|
335 |
-
*
|
336 |
-
* @return StdClass|null
|
337 |
-
*/
|
338 |
-
|
339 |
-
/**
|
340 |
-
*
|
341 |
-
* @return null
|
342 |
-
*/
|
343 |
-
public function getUpdateState() {
|
344 |
-
$state = get_site_option($this->optionName, null);
|
345 |
-
if (empty($state) || !is_object($state)) {
|
346 |
-
$state = null;
|
347 |
-
}
|
348 |
-
|
349 |
-
if (!empty($state) && isset($state->update) && is_object($state->update)) {
|
350 |
-
$state->update = rtPluginUpdate::fromObject($state->update);
|
351 |
-
}
|
352 |
-
return $state;
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* Persist the update checker state to the DB.
|
357 |
-
*
|
358 |
-
* @param StdClass $state
|
359 |
-
* @return void
|
360 |
-
*/
|
361 |
-
|
362 |
-
/**
|
363 |
-
*
|
364 |
-
* @param type $state
|
365 |
-
*/
|
366 |
-
private function setUpdateState($state) {
|
367 |
-
if (isset($state->update) && is_object($state->update) && method_exists($state->update, 'toStdClass')) {
|
368 |
-
$update = $state->update;/** @var PluginUpdate $update */
|
369 |
-
$state->update = $update->toStdClass();
|
370 |
-
}
|
371 |
-
update_site_option($this->optionName, $state);
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Reset update checker state - i.e. last check time, cached update data and so on.
|
376 |
-
*
|
377 |
-
* Call this when your plugin is being uninstalled, or if you want to
|
378 |
-
* clear the update cache.
|
379 |
-
*/
|
380 |
-
public function resetUpdateState() {
|
381 |
-
delete_site_option($this->optionName);
|
382 |
-
}
|
383 |
-
|
384 |
-
/**
|
385 |
-
* Intercept plugins_api() calls that request information about our plugin and
|
386 |
-
* use the configured API endpoint to satisfy them.
|
387 |
-
*
|
388 |
-
* @see plugins_api()
|
389 |
-
*
|
390 |
-
* @param mixed $result
|
391 |
-
* @param string $action
|
392 |
-
* @param array|object $args
|
393 |
-
* @return mixed
|
394 |
-
*/
|
395 |
-
|
396 |
-
/**
|
397 |
-
*
|
398 |
-
* @param type $result
|
399 |
-
* @param type $action
|
400 |
-
* @param type $args
|
401 |
-
* @return type
|
402 |
-
*/
|
403 |
-
public function injectInfo($result, $action = null, $args = null) {
|
404 |
-
$relevant = ($action == 'plugin_information') && isset($args->slug) && ($args->slug == $this->slug);
|
405 |
-
if (!$relevant) {
|
406 |
-
return $result;
|
407 |
-
}
|
408 |
-
|
409 |
-
$pluginInfo = $this->requestInfo();
|
410 |
-
$pluginInfo = apply_filters('puc_pre_inject_info-' . $this->slug, $pluginInfo);
|
411 |
-
if ($pluginInfo) {
|
412 |
-
return $pluginInfo->toWpFormat();
|
413 |
-
}
|
414 |
-
|
415 |
-
return $result;
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Insert the latest update (if any) into the update list maintained by WP.
|
420 |
-
*
|
421 |
-
* @param StdClass $updates Update list.
|
422 |
-
* @return StdClass Modified update list.
|
423 |
-
*/
|
424 |
-
|
425 |
-
/**
|
426 |
-
*
|
427 |
-
* @param StdClass $updates
|
428 |
-
* @return \StdClass
|
429 |
-
*/
|
430 |
-
public function injectUpdate($updates) {
|
431 |
-
//Is there an update to insert?
|
432 |
-
$update = $this->getUpdate();
|
433 |
-
if (!empty($update)) {
|
434 |
-
//Let plugins filter the update info before it's passed on to WordPress.
|
435 |
-
$update = apply_filters('puc_pre_inject_update-' . $this->slug, $update);
|
436 |
-
if (!is_object($updates)) {
|
437 |
-
$updates = new StdClass();
|
438 |
-
$updates->response = array();
|
439 |
-
}
|
440 |
-
$updates->response[$this->pluginFile] = $update->toWpFormat();
|
441 |
-
} else if (isset($updates, $updates->response)) {
|
442 |
-
unset($updates->response[$this->pluginFile]);
|
443 |
-
}
|
444 |
-
|
445 |
-
return $updates;
|
446 |
-
}
|
447 |
-
|
448 |
-
/**
|
449 |
-
* Get the details of the currently available update, if any.
|
450 |
-
*
|
451 |
-
* If no updates are available, or if the last known update version is below or equal
|
452 |
-
* to the currently installed version, this method will return NULL.
|
453 |
-
*
|
454 |
-
* Uses cached update data. To retrieve update information straight from
|
455 |
-
* the metadata URL, call requestUpdate() instead.
|
456 |
-
*
|
457 |
-
* @return PluginUpdate|null
|
458 |
-
*/
|
459 |
-
|
460 |
-
/**
|
461 |
-
*
|
462 |
-
* @return null
|
463 |
-
*/
|
464 |
-
public function getUpdate() {
|
465 |
-
$state = $this->getUpdateState();/** @var StdClass $state */
|
466 |
-
//Is there an update available insert?
|
467 |
-
if (!empty($state) && isset($state->update) && !empty($state->update)) {
|
468 |
-
$update = $state->update;
|
469 |
-
//Check if the update is actually newer than the currently installed version.
|
470 |
-
$installedVersion = $this->getInstalledVersion();
|
471 |
-
if (($installedVersion !== null) && version_compare($update->version, $installedVersion, '>')) {
|
472 |
-
return $update;
|
473 |
-
}
|
474 |
-
}
|
475 |
-
return null;
|
476 |
-
}
|
477 |
-
|
478 |
-
/**
|
479 |
-
* Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
|
480 |
-
* the new link will appear after the "Visit plugin site" link.
|
481 |
-
*
|
482 |
-
* You can change the link text by using the "puc_manual_check_link-$slug" filter.
|
483 |
-
* Returning an empty string from the filter will disable the link.
|
484 |
-
*
|
485 |
-
* @param array $pluginMeta Array of meta links.
|
486 |
-
* @param string $pluginFile
|
487 |
-
* @param array|null $pluginData Currently ignored.
|
488 |
-
* @param string|null $status Currently ignored.
|
489 |
-
* @return array
|
490 |
-
*/
|
491 |
-
|
492 |
-
/**
|
493 |
-
*
|
494 |
-
* @param type $pluginMeta
|
495 |
-
* @param type $pluginFile
|
496 |
-
* @param type $pluginData
|
497 |
-
* @param type $status
|
498 |
-
* @return type
|
499 |
-
*/
|
500 |
-
public function addCheckForUpdatesLink($pluginMeta, $pluginFile, $pluginData = null, $status = null) {
|
501 |
-
if ($pluginFile == $this->pluginFile && current_user_can('update_plugins')) {
|
502 |
-
$linkUrl = wp_nonce_url(
|
503 |
-
add_query_arg(
|
504 |
-
array(
|
505 |
-
'puc_check_for_updates' => 1,
|
506 |
-
'puc_slug' => $this->slug,
|
507 |
-
), is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
|
508 |
-
), 'puc_check_for_updates'
|
509 |
-
);
|
510 |
-
|
511 |
-
$linkText = apply_filters('puc_manual_check_link-' . $this->slug, __( 'Check for updates', 'rtmedia' ) );
|
512 |
-
if (!empty($linkText)) {
|
513 |
-
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
514 |
-
}
|
515 |
-
}
|
516 |
-
return $pluginMeta;
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* Check for updates when the user clicks the "Check for updates" link.
|
521 |
-
* @see self::addCheckForUpdatesLink()
|
522 |
-
*
|
523 |
-
* @return void
|
524 |
-
*/
|
525 |
-
public function handleManualCheck() {
|
526 |
-
$shouldCheck =
|
527 |
-
isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
|
528 |
-
&& $_GET['puc_slug'] == $this->slug
|
529 |
-
&& current_user_can('update_plugins')
|
530 |
-
&& check_admin_referer('puc_check_for_updates');
|
531 |
-
|
532 |
-
if ($shouldCheck) {
|
533 |
-
$update = $this->checkForUpdates();
|
534 |
-
$status = ($update === null) ? 'no_update' : 'update_available';
|
535 |
-
wp_redirect(add_query_arg(
|
536 |
-
array(
|
537 |
-
'puc_update_check_result' => $status,
|
538 |
-
'puc_slug' => $this->slug,
|
539 |
-
), is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
|
540 |
-
));
|
541 |
-
}
|
542 |
-
}
|
543 |
-
|
544 |
-
/**
|
545 |
-
* Display the results of a manual update check.
|
546 |
-
* @see self::handleManualCheck()
|
547 |
-
*
|
548 |
-
* You can change the result message by using the "puc_manual_check_message-$slug" filter.
|
549 |
-
*/
|
550 |
-
public function displayManualCheckResult() {
|
551 |
-
if (isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug)) {
|
552 |
-
$status = strval($_GET['puc_update_check_result']);
|
553 |
-
if ($status == 'no_update') {
|
554 |
-
$message = __( 'This plugin is up to date.', 'rtmedia' );
|
555 |
-
} else if ($status == 'update_available') {
|
556 |
-
$message = __( 'A new version of this plugin is available.', 'rtmedia' );
|
557 |
-
} else {
|
558 |
-
$message = sprintf( __( "Unknown update checker status \"%s\"", 'rtmedia' ), htmlentities($status));
|
559 |
-
}
|
560 |
-
printf(
|
561 |
-
'<div class="updated"><p>%s</p></div>', apply_filters('puc_manual_check_message-' . $this->slug, $message, $status)
|
562 |
-
);
|
563 |
-
}
|
564 |
-
}
|
565 |
-
|
566 |
-
/**
|
567 |
-
* Register a callback for filtering query arguments.
|
568 |
-
*
|
569 |
-
* The callback function should take one argument - an associative array of query arguments.
|
570 |
-
* It should return a modified array of query arguments.
|
571 |
-
*
|
572 |
-
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
573 |
-
*
|
574 |
-
* @param callable $callback
|
575 |
-
* @return void
|
576 |
-
*/
|
577 |
-
|
578 |
-
/**
|
579 |
-
*
|
580 |
-
* @param type $callback
|
581 |
-
*/
|
582 |
-
public function addQueryArgFilter($callback) {
|
583 |
-
add_filter('puc_request_info_query_args-' . $this->slug, $callback);
|
584 |
-
}
|
585 |
-
|
586 |
-
/**
|
587 |
-
* Register a callback for filtering arguments passed to wp_remote_get().
|
588 |
-
*
|
589 |
-
* The callback function should take one argument - an associative array of arguments -
|
590 |
-
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
591 |
-
* for details on what arguments are available and how they work.
|
592 |
-
*
|
593 |
-
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
594 |
-
*
|
595 |
-
* @param callable $callback
|
596 |
-
* @return void
|
597 |
-
*/
|
598 |
-
|
599 |
-
/**
|
600 |
-
*
|
601 |
-
* @param type $callback
|
602 |
-
*/
|
603 |
-
public function addHttpRequestArgFilter($callback) {
|
604 |
-
add_filter('puc_request_info_options-' . $this->slug, $callback);
|
605 |
-
}
|
606 |
-
|
607 |
-
/**
|
608 |
-
* Register a callback for filtering the plugin info retrieved from the external API.
|
609 |
-
*
|
610 |
-
* The callback function should take two arguments. If the plugin info was retrieved
|
611 |
-
* successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
|
612 |
-
* it will be NULL. The second argument will be the corresponding return value of
|
613 |
-
* wp_remote_get (see WP docs for details).
|
614 |
-
*
|
615 |
-
* The callback function should return a new or modified instance of PluginInfo or NULL.
|
616 |
-
*
|
617 |
-
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
618 |
-
*
|
619 |
-
* @param callable $callback
|
620 |
-
* @return void
|
621 |
-
*/
|
622 |
-
|
623 |
-
/**
|
624 |
-
*
|
625 |
-
* @param type $callback
|
626 |
-
*/
|
627 |
-
public function addResultFilter($callback) {
|
628 |
-
add_filter('puc_request_info_result-' . $this->slug, $callback, 10, 2);
|
629 |
-
}
|
630 |
-
|
631 |
-
/**
|
632 |
-
* Register a callback for one of the update checker filters.
|
633 |
-
*
|
634 |
-
* Identical to add_filter(), except it automatically adds the "puc_" prefix
|
635 |
-
* and the "-$plugin_slug" suffix to the filter name. For example, "request_info_result"
|
636 |
-
* becomes "puc_request_info_result-your_plugin_slug".
|
637 |
-
*
|
638 |
-
* @param string $tag
|
639 |
-
* @param callable $callback
|
640 |
-
* @param int $priority
|
641 |
-
* @param int $acceptedArgs
|
642 |
-
*/
|
643 |
-
|
644 |
-
/**
|
645 |
-
*
|
646 |
-
* @param type $tag
|
647 |
-
* @param type $callback
|
648 |
-
* @param type $priority
|
649 |
-
* @param type $acceptedArgs
|
650 |
-
*/
|
651 |
-
public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
|
652 |
-
add_filter('puc_' . $tag . '-' . $this->slug, $callback, $priority, $acceptedArgs);
|
653 |
-
}
|
654 |
-
|
655 |
-
/**
|
656 |
-
* Initialize the update checker Debug Bar plugin/add-on thingy.
|
657 |
-
*/
|
658 |
-
public function initDebugBarPanel() {
|
659 |
-
if (class_exists('Debug_Bar')) {
|
660 |
-
require_once dirname(__FILE__) . '/debug-bar-plugin.php';
|
661 |
-
$this->debugBarPlugin = new PucDebugBarPlugin($this);
|
662 |
}
|
663 |
}
|
664 |
-
|
665 |
-
}
|
1 |
<?php
|
2 |
+
class rtPluginUpdateChecker{
|
3 |
+
function __construct ($url, $path , $slug , $priority) {
|
4 |
+
//code removed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
}
|
6 |
}
|
7 |
+
?>
|
|
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.2.10
|
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.2.10.1
|
8 |
Author: rtCamp
|
9 |
Text Domain: rtmedia
|
10 |
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
|
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.7 + BuddyPress 1.8.1
|
9 |
-
Stable tag: 3.2.10
|
10 |
|
11 |
Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works mobile/tablets devices.
|
12 |
|
@@ -131,6 +131,9 @@ http://www.youtube.com/watch?v=dJrykKQGDcs
|
|
131 |
|
132 |
Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
|
133 |
|
|
|
|
|
|
|
134 |
= 3.2.10 =
|
135 |
* Add support in some strings translations thanks to [rafaelfunchal](profiles.wordpress.org/rafaelfunchal) for pull request
|
136 |
* Bug Fixes
|
@@ -614,8 +617,8 @@ Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_sou
|
|
614 |
|
615 |
== Upgrade Notice ==
|
616 |
|
617 |
-
= 3.2.10 =
|
618 |
-
Requires BuddyPress 1.7 or higher, if using BuddyPress.
|
619 |
|
620 |
== Sponsors ==
|
621 |
|
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.7 + BuddyPress 1.8.1
|
9 |
+
Stable tag: 3.2.10.1
|
10 |
|
11 |
Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works mobile/tablets devices.
|
12 |
|
131 |
|
132 |
Please visit [rtMedia's Roadmap page](http://rtcamp.com/rtmedia/roadmap/?utm_source=readme&utm_medium=plugin&utm_campaign=buddypress-media "Visit rtMedia's Features page") to get some details about future releases.
|
133 |
|
134 |
+
= 3.2.10.1 =
|
135 |
+
* Remove notices and update js libs
|
136 |
+
|
137 |
= 3.2.10 =
|
138 |
* Add support in some strings translations thanks to [rafaelfunchal](profiles.wordpress.org/rafaelfunchal) for pull request
|
139 |
* Bug Fixes
|
617 |
|
618 |
== Upgrade Notice ==
|
619 |
|
620 |
+
= 3.2.10.1 =
|
621 |
+
Requires BuddyPress 1.7 or higher, if using BuddyPress. Remove notices and update js libs.
|
622 |
|
623 |
== Sponsors ==
|
624 |
|