Sync with current wp version
This commit is contained in:
@ -20,6 +20,63 @@ class CWV3{
|
|||||||
// AJAX Handle
|
// AJAX Handle
|
||||||
add_action('wp_ajax_cwv3_ajax', array(&$this, 'handle_ajax'));
|
add_action('wp_ajax_cwv3_ajax', array(&$this, 'handle_ajax'));
|
||||||
add_action('wp_ajax_nopriv_cwv3_ajax', array(&$this, 'handle_ajax'));
|
add_action('wp_ajax_nopriv_cwv3_ajax', array(&$this, 'handle_ajax'));
|
||||||
|
|
||||||
|
// Post column filters
|
||||||
|
add_filter('manage_page_posts_columns', array(&$this, 'post_cols'));
|
||||||
|
add_filter('manage_post_posts_columns', array(&$this, 'post_cols'));
|
||||||
|
|
||||||
|
|
||||||
|
//add_action('quick_edit_custom_box', array(&$this, 'display_qe'), 10, 2);
|
||||||
|
|
||||||
|
// Post column info
|
||||||
|
add_action('manage_posts_custom_column', array(&$this, 'set_col_data'));
|
||||||
|
add_action('manage_pages_custom_column', array(&$this, 'set_col_data'));
|
||||||
|
|
||||||
|
add_action('admin_head', array(&$this, 'render_lazy_mans_css'));
|
||||||
|
|
||||||
|
add_action('wp_head', array(&$this, 'override_css'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function override_css(){
|
||||||
|
|
||||||
|
$img = get_option('cwv3_bg_image', '');
|
||||||
|
$color = get_option('cwv3_bg_color');
|
||||||
|
?><style type="text/css"><?
|
||||||
|
if(!empty($img)){
|
||||||
|
?>
|
||||||
|
#cboxOverlay{background:url(<?=$img?>) no-repeat top center; background-color:<?=$color['color'];?>;}
|
||||||
|
<?
|
||||||
|
}else{
|
||||||
|
?>
|
||||||
|
#cboxOverlay{background-image:url(<?=$img?>) no-repeat top center; background-color:<?=$color['color'];?>;}
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
?></style><?
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render_lazy_mans_css(){
|
||||||
|
echo '<style type="text/css">th#cwv2{width: 32px; text-align:center;} td.column-cwv2{text-align:center;}</style>';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_col_data($col){
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
$sw = get_option('cwv3_sitewide');
|
||||||
|
switch($col){
|
||||||
|
case 'cwv2':
|
||||||
|
if(get_post_meta($post->ID, 'cwv3_auth', true) == 'yes' || $sw[0] == 'enabled'){
|
||||||
|
echo '<span style="color:#0F0; font-weight:bold;" class="cw_protected">Yes</span>';
|
||||||
|
}else{
|
||||||
|
echo '<span style="color:#F00; font-weight:bold;" class="cw_vulnerable">No</span>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function post_cols($cols){
|
||||||
|
|
||||||
|
return array_slice($cols, 0,1,true)+array('cwv2'=> 'CW')+array_slice($cols, 1, count($array)-1, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cw_meta(){
|
public function cw_meta(){
|
||||||
@ -56,37 +113,40 @@ class CWV3{
|
|||||||
|
|
||||||
check_ajax_referer('cwv3_ajax_'.$post_id, 'nonce');
|
check_ajax_referer('cwv3_ajax_'.$post_id, 'nonce');
|
||||||
|
|
||||||
$sw = get_option('cwv3_sitewide') == 'enabled' ? true : false;
|
|
||||||
$cData = json_decode($_COOKIE['cwv3_auth']);
|
|
||||||
$time = get_option('cwv3_death');
|
|
||||||
$time = time()+($time['multiplier']*$time['time']);
|
|
||||||
if($_POST['method'] == 'exit'){
|
if($_POST['method'] == 'exit'){
|
||||||
if(get_option('cwv3_denial') == 'enabled'){
|
$d = get_option('cwv3_denial');
|
||||||
|
if($d[0] == 'enabled'){
|
||||||
|
$resp = $this->set_cookie($post_id, 3);
|
||||||
}
|
}
|
||||||
|
$resp = "denied";
|
||||||
|
}else{
|
||||||
|
$resp = $this->set_cookie($post_id, 1);
|
||||||
}
|
}
|
||||||
|
echo $resp;
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load_dependancies(){
|
public function load_dependancies(){
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
if(current_user_can('manage_options')) return;
|
||||||
|
|
||||||
wp_enqueue_style('cwv3_css');
|
wp_enqueue_style('cwv3_css');
|
||||||
wp_enqueue_script('cwv3_js');
|
wp_enqueue_script('cwv3_js');
|
||||||
|
|
||||||
$elink = get_option('cwv3_enter_link');
|
$elink = get_option('cwv3_enter_link');
|
||||||
$exlink = get_option('cwv3_exit_link');
|
$exlink = get_option('cwv3_exit_link');
|
||||||
$p_ID = (is_home()) ? -1 : (is_attachment() ? $post->post_parent : (is_archive() || is_search()) ? -2 : $post->ID);
|
$p_ID = (is_home()) ? -1 : (is_attachment() ? $post->post_parent : (is_archive() || is_search()) ? -2 : $post->ID);
|
||||||
|
$d = get_option('cwv3_denial');
|
||||||
wp_localize_script('cwv3_js', 'cwv3_params', array(
|
wp_localize_script('cwv3_js', 'cwv3_params', array(
|
||||||
'action' => 'cwv3_ajax',
|
'action' => 'cwv3_ajax',
|
||||||
'nonce' => wp_create_nonce('cwv3_ajax_'.$p_ID),
|
'nonce' => wp_create_nonce('cwv3_ajax_'.$p_ID),
|
||||||
'admin_url' => admin_url( 'admin-ajax.php' ),
|
'admin_url' => admin_url( 'admin-ajax.php' ),
|
||||||
'id' => $p_ID,
|
'id' => $p_ID,
|
||||||
'sd' => ($this->check_data() !== true) ? true : false,
|
'sd' => ($this->check_data() == false || ($this->check_data() == 3 && $d[0] == 'enabled')) ? true : false,
|
||||||
'enter' => !empty($elink) ? $elink : '#',
|
'enter' => !empty($elink) ? $elink : '#',
|
||||||
'exit' => !empty($exlink) ? $exlink : 'http://google.com'
|
'exit' => !empty($exlink) ? $exlink : 'http://google.com',
|
||||||
|
'opacity' => get_option('cwv3_bg_opacity', 0.85)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,16 +156,65 @@ class CWV3{
|
|||||||
wp_register_script('colorbox_js', plugins_url('js/colorbox.1.4.14/jquery.colorbox-min.js', dirname(__FILE__)), array('jquery'), '1.4.14', true);
|
wp_register_script('colorbox_js', plugins_url('js/colorbox.1.4.14/jquery.colorbox-min.js', dirname(__FILE__)), array('jquery'), '1.4.14', true);
|
||||||
|
|
||||||
// Main data
|
// Main data
|
||||||
wp_register_script('cwv3_js', plugins_url('js/cwv3.js', dirname(__FILE__)), array('colorbox_js'), '1.0', true);
|
wp_register_script('cwv3_js', plugins_url('js/cwv3.js', dirname(__FILE__)), array('colorbox_js'), uniqid(), true);
|
||||||
wp_register_style('cwv3_css', plugins_url('css/cwv3.css', dirname(__FILE__)), array('colorbox'), '1.0');
|
wp_register_style('cwv3_css', plugins_url('css/cwv3.css', dirname(__FILE__)), array('colorbox'), '1.0');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_cookie($id, $action){
|
public function set_cookie($id, $action){
|
||||||
$cData = json_decode($_COOKIE['cwv3_auth']);
|
|
||||||
$cData[$id] = $action;
|
|
||||||
|
|
||||||
$time = get_option('cwv3_death');
|
$time = get_option('cwv3_death');
|
||||||
setcookie('cwv3_auth', json_encode($cData), ($time['multiplier'] * $time['time'])+time(),'/', COOKIE_DOMAIN, false);
|
|
||||||
|
$sw = get_option('cwv3_sitewide');
|
||||||
|
$hm = get_option('cwv3_homepage');
|
||||||
|
$mi = get_option('cwv3_misc');
|
||||||
|
if(get_magic_quotes_gpc() == true){
|
||||||
|
$cData = array(
|
||||||
|
'pages'=> json_decode(stripslashes($_COOKIE['cwv3_pages'])),
|
||||||
|
'posts' => json_decode(stripslashes($_COOKIE['cwv3_posts'])),
|
||||||
|
'categories' => json_decode(stripslashes($_COOKIE['cwv3_cats']))
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$cData = array(
|
||||||
|
'pages' => json_decode($_COOKIE['cwv3_pages']),
|
||||||
|
'posts' => json_decode($_COOKIE['cwv3_posts']),
|
||||||
|
'categories' => json_decode($_COOKIE['cwv3_cats'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if($sw[0] == 'enabled'){
|
||||||
|
$cData['pages']->sitewide = $action;
|
||||||
|
return setcookie('cwv3_pages', json_encode($cData['pages']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($hm[0] == 'enabled' && $id == -1){
|
||||||
|
$cData['pages']->home = $action;
|
||||||
|
return setcookie('cwv3_pages', json_encode($cData['pages']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($mi[0] == 'enabled' && $id == -2){
|
||||||
|
$cData['pages']->other = $action;
|
||||||
|
//return print_r($cData, true);
|
||||||
|
return setcookie('cwv3_pages', json_encode($cData['pages']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = get_post_type($id);
|
||||||
|
if($type == 'post'){
|
||||||
|
$catData = get_option("cwv3_cat_list");
|
||||||
|
$curCat = get_the_category($id);
|
||||||
|
if($this->inCat($catData, $curCat)){
|
||||||
|
$cData['categories']->$id = $action;
|
||||||
|
return setcookie('cwv3_cats', json_encode($cData['categories']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}else if(get_post_meta($id, 'cwv3_auth', true) == 'yes'){
|
||||||
|
$cData['posts']->$id = $action;
|
||||||
|
return setcookie('cwv3_posts', json_encode($cData['posts']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(get_post_meta($id, 'cwv3_auth', true) == 'yes'){
|
||||||
|
$cData['pages']->$id = $action;
|
||||||
|
return setcookie('cwv3_pages', json_encode($cData['pages']), ($time['multiplier'] * $time['time'])+time(),COOKIEPATH, COOKIE_DOMAIN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Failed to set cookie.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function check_data(){
|
public function check_data(){
|
||||||
@ -115,26 +224,32 @@ class CWV3{
|
|||||||
//Don't want to hender the feed, just in case.
|
//Don't want to hender the feed, just in case.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
$cData = array(
|
||||||
|
'pages'=> json_decode(stripslashes($_COOKIE['cwv3_pages']), true),
|
||||||
|
'posts' => json_decode(stripslashes($_COOKIE['cwv3_posts']), true),
|
||||||
|
'categories' => json_decode(stripslashes($_COOKIE['cwv3_cats']), true)
|
||||||
|
);
|
||||||
|
|
||||||
|
//return print_r($cData, true);
|
||||||
|
|
||||||
$cData = json_decode($_COOKIE['cwv3_auth']);
|
|
||||||
$sw = get_option('cwv3_sitewide');
|
$sw = get_option('cwv3_sitewide');
|
||||||
$hm = get_option('cwv3_homepage');
|
$hm = get_option('cwv3_homepage');
|
||||||
$mi = get_option('cwv3_misc');
|
$mi = get_option('cwv3_misc');
|
||||||
|
|
||||||
if($sw[0] == 'enabled'){
|
if($sw[0] == 'enabled'){
|
||||||
return (!empty($cData['sitewide']) ? $cData['sitewide'] : false);
|
return (!empty($cData['pages']['sitewide']) ? $cData['pages']['sitewide'] : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_home() && $hm[0] == 'enabled'){
|
if(is_home() && $hm[0] == 'enabled'){
|
||||||
return (!empty($cData['-1']) ? $cData['-1'] : false);
|
return (!empty($cData['pages']['home']) ? $cData['pages']['home'] : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((is_archive() || is_search()) && $mi[0] == 'enabled'){
|
if((is_archive() || is_search()) && $mi[0] == 'enabled'){
|
||||||
// Protect misc pages aswell
|
// Protect misc pages aswell
|
||||||
return (!empty($cData['-2']) ? $cData['-2'] : false);
|
return (!empty($cData['pages']['other']) ? $cData['pages']['other'] : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_page()){
|
if(is_page() && get_post_meta($post->ID, 'cwv3_auth', true) == 'yes'){
|
||||||
$c = $cData['pages'][$post->ID];
|
$c = $cData['pages'][$post->ID];
|
||||||
return(!empty($c) ? $c : false);
|
return(!empty($c) ? $c : false);
|
||||||
}
|
}
|
||||||
@ -143,31 +258,47 @@ class CWV3{
|
|||||||
// First see if categories are setup in the admin side.
|
// First see if categories are setup in the admin side.
|
||||||
$catData = get_option("cwv3_cat_list");
|
$catData = get_option("cwv3_cat_list");
|
||||||
$curCat = get_the_category($id);
|
$curCat = get_the_category($id);
|
||||||
if(in_array($curCat, $catData)){
|
if(get_post_type($id) == 'post' && $this->inCat($catData, $curCat)){
|
||||||
// If the current category is selected in the admin page, that means the administrator wishes to protect it.
|
// If the current category is selected in the admin page, that means the administrator wishes to protect it.
|
||||||
// respect the admin's wishes and do it.
|
// respect the admin's wishes and do it.
|
||||||
return(!empty($cData['categories'][$post->id]) ? $cData['categories'][$id] : false );
|
return(!empty($cData['categories'][$post->ID]) ? $cData['categories'][$id] : false );
|
||||||
}
|
}
|
||||||
// Since that's not the case, we need to check post_meta data and see if this post is protected.
|
// Since that's not the case, we need to check post_meta data and see if this post is protected.
|
||||||
if(get_post_meta($post->ID, 'cwv3_auth', true) == 'yes'){
|
if(get_post_meta($post->ID, 'cwv3_auth', true) == 'yes' && !is_home()){
|
||||||
return(!empty($cData['posts'][$post->ID]) ? $cData['posts'][$id] : false );
|
return(!empty($cData['posts'][$post->ID]) ? $cData['posts'][$id] : false );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return 'failed all checks';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function inCat($catIDs, $catArray){
|
||||||
|
if(!is_array($catIDs)){
|
||||||
|
$catIDs = array(); // Empty
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($catArray as $cat){
|
||||||
|
if(in_array($cat->term_id, $catIDs)){return true;}else{continue;}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderDialog(){
|
public function renderDialog(){
|
||||||
|
|
||||||
$dtype = $this->check_data();
|
$d = get_option('cwv3_denial');
|
||||||
|
if($this->check_data() == 3 && $d[0] == 'enabled'){
|
||||||
|
$dtype = true;
|
||||||
|
}else{
|
||||||
|
$dtype = false;
|
||||||
|
}
|
||||||
$etxt = get_option('cwv3_enter_txt');
|
$etxt = get_option('cwv3_enter_txt');
|
||||||
$extxt = get_option('cwv3_exit_txt');
|
$extxt = get_option('cwv3_exit_txt');
|
||||||
?>
|
?>
|
||||||
<!-- CWV3 Dialog -->
|
<!-- CWV3 Dialog -->
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
<div id="cwv3_auth">
|
<div id="cwv3_auth">
|
||||||
<div id="cwv3_title"><? if($dtype === 'denial'): ?><? echo get_option('cwv3_den_title'); ?><? else: ?><? echo get_option('cwv3_d_title'); ?><? endif; ?></div>
|
<div id="cwv3_title"><? if($dtype == true): ?><? echo get_option('cwv3_den_title'); ?><? else: ?><? echo get_option('cwv3_d_title'); ?><? endif; ?></div>
|
||||||
<div id="cwv3_content"><? if($dtype === 'denial'): ?><? echo get_option('cwv3_den_msg'); ?><? else: ?><? echo get_option('cwv3_d_msg'); ?><? endif; ?></div>
|
<div id="cwv3_content"><? if($dtype === true): ?><? echo do_shortcode( get_option('cwv3_den_msg') ); ?><? else: ?><? echo do_shortcode( get_option('cwv3_d_msg') ); ?><? endif; ?></div>
|
||||||
<div id="cwv3_btns"><? if($dtype !== 'denial'): ?><div id="cwv3_enter"><a href="javascript:;" id="cw_enter_link"><? echo (!empty($etxt) ? $etxt : 'Enter'); ?></a></div><? endif; ?><div id="cwv3_exit"><a href="javascript:;" id="cw_exit_link"><? echo (!empty($extxt) ? $extxt : 'Exit'); ?></a></div></div>
|
<div id="cwv3_btns"><? if($dtype !== true): ?><div id="cwv3_enter"><a href="javascript:;" id="cw_enter_link"><? echo (!empty($etxt) ? $etxt : 'Enter'); ?></a></div><? endif; ?><div id="cwv3_exit"><a href="javascript:;" id="cw_exit_link"><? echo (!empty($extxt) ? $extxt : 'Exit'); ?></a></div></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- END CWV3 Dialog -->
|
<!-- END CWV3 Dialog -->
|
||||||
@ -176,18 +307,56 @@ class CWV3{
|
|||||||
|
|
||||||
public function render_metabox($post){
|
public function render_metabox($post){
|
||||||
wp_nonce_field(plugin_basename(__FILE__), 'cwv3_meta');
|
wp_nonce_field(plugin_basename(__FILE__), 'cwv3_meta');
|
||||||
|
$curval = get_post_meta($post->ID, 'cwv3_auth', true);
|
||||||
|
$sw = get_option('cwv3_sitewide');
|
||||||
|
$disabled = $sw[0] == 'enabled' ? 'disabled="disabled"' : '';
|
||||||
|
|
||||||
$curval = get_post_meta($post->ID, 'cwv3_auth', true);?>
|
|
||||||
|
?>
|
||||||
<? //wp_die(print_r($curval), true); ?>
|
<? //wp_die(print_r($curval), true); ?>
|
||||||
<label for="cwv3_auth">Use authorization for this content:</label>
|
<label for="cwv3_auth">Use authorization for this content:</label>
|
||||||
<input type="checkbox" id="cwv3_auth" name="cwv3_auth" <? checked('yes', $curval, true); ?> value="yes"/>
|
<input type="checkbox" id="cwv3_auth" name="cwv3_auth" <? checked('yes', $curval, true); ?> value="yes" <?=$disabled;?>/><br />
|
||||||
|
<? if($sw[0] == 'enabled') : ?>
|
||||||
|
<p class="description">Cannot be changed while site wide option is enabled.</p>
|
||||||
|
<? endif; ?>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
public function display_qe($column_name, $post_type){
|
||||||
|
global $post;
|
||||||
|
?>
|
||||||
|
<fieldset class="inline-edit-col-right inline-edit-book">
|
||||||
|
<div class="inline-edit-col column-<?php echo $column_name ?>">
|
||||||
|
<label class="inline-edit-group">
|
||||||
|
<?php
|
||||||
|
switch ( $column_name ) {
|
||||||
|
case 'cwv2':
|
||||||
|
wp_nonce_field(plugin_basename(__FILE__), 'cwv3_meta');
|
||||||
|
$curval = get_post_meta($post->ID, 'cwv3_auth', true);
|
||||||
|
$sw = get_option('cwv3_sitewide');
|
||||||
|
$disabled = $sw[0] == 'enabled' ? 'disabled="disabled"' : ''; ?>
|
||||||
|
|
||||||
|
<label for="cwv3_auth">
|
||||||
|
<input type="checkbox" id="cwv3_auth" name="cwv3_auth" <? checked('yes', $curval, true); ?> value="yes" <?=$disabled;?>/>
|
||||||
|
<span class="checkbox-title">Use CWv2 for this content <?=$post->ID ?></span>
|
||||||
|
<? if($sw[0] == 'enabled') : ?>
|
||||||
|
<span class="description">(Cannot be changed while site wide option is enabled.)</span>
|
||||||
|
<? endif; ?>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new CWV3;
|
new CWV3;
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,18 +1,15 @@
|
|||||||
<?
|
<?
|
||||||
/*
|
/*
|
||||||
Plugin Name: Content Warning v3
|
Plugin Name: Content Warning v2
|
||||||
Plugin URI: http://plugish.com/plugins/content-warning-v3
|
Plugin URI: http://plugish.com/plugins/content-warning-v3
|
||||||
Description: A plugin based on my v2 code, while drastically deviating from the original. Used mainly for NSFW websites, this plugin provides a dialog popup to warn viewers of it's possible content.
|
Description: A plugin based on my v2 code, while drastically deviating from the original. Used mainly for NSFW websites, this plugin provides a dialog popup to warn viewers of it's possible content.
|
||||||
Author: Jerry Wood Jr.
|
Author: Jerry Wood Jr.
|
||||||
Version: 3.46
|
Version: 3.48
|
||||||
Author URI: http://plugish.com
|
Author URI: http://plugish.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once (dirname(__FILE__).'/inc/options.inc.php');
|
require_once (dirname(__FILE__).'/inc/options.inc.php');
|
||||||
require_once (dirname(__FILE__).'/lib/jw_simple_options/simple_options.php');
|
require_once (dirname(__FILE__).'/lib/jw_simple_options/simple_options.php');
|
||||||
require_once (dirname(__FILE__).'/class/main.class.php');
|
require_once (dirname(__FILE__).'/class/main.class.php');
|
||||||
|
|
||||||
$cwv3_options = new JW_SIMPLE_OPTIONS($cwv3_op_data);
|
$cwv3_options = new JW_SIMPLE_OPTIONS($cwv3_op_data);
|
||||||
register_uninstall_hook(__FILE__, $cwv3_options->uninstall() );
|
register_uninstall_hook(__FILE__, $cwv3_options->uninstall() );
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,2 +1 @@
|
|||||||
/* CSS Document */
|
/* CSS Document */
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
/* CSS Document */
|
/* CSS Document */
|
||||||
.cwv3_box{background: transparent;}
|
.cwv3_box{background: transparent;}
|
||||||
|
|
||||||
/* Undocumented cBox colors */
|
/* Undocumented cBox colors */
|
||||||
#cboxLoadingOverlay, #cboxContent, #cboxLoadedContent{background-color: #FFF !important;}
|
#cboxLoadingOverlay, #cboxContent, #cboxLoadedContent{background-color: #FFF !important;}
|
||||||
|
|
||||||
#cwv3_auth{border: 3px solid #ccc; background: #FFF;}
|
#cwv3_auth{border: 3px solid #ccc; background: #FFF;}
|
||||||
#cwv3_auth div{padding: 0.25em}
|
#cwv3_auth div{padding: 0.25em}
|
||||||
#cwv3_title{color: #FFF; font-weight: bold; text-align:center; background: #f00;}
|
#cwv3_title{color: #FFF; font-weight: bold; text-align:center; background: #f00;}
|
||||||
|
@ -1,2 +1 @@
|
|||||||
/* CSS Document */
|
/* CSS Document */
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
// Get categories
|
// Get categories
|
||||||
$cat_list = get_categories();
|
$cat_list = get_categories();
|
||||||
$final_cat_list = array();
|
$final_cat_list = array();
|
||||||
@ -133,9 +132,10 @@ $cwv3_op_data = array(
|
|||||||
),
|
),
|
||||||
'bg_opacity' => array(
|
'bg_opacity' => array(
|
||||||
'name' => 'Background Opacity',
|
'name' => 'Background Opacity',
|
||||||
'desc' => 'Input a number from 0-100, the latter being completely opaque.',
|
'desc' => 'Input a float value from 0-1, the latter being completely opaque.',
|
||||||
'type' => 'text',
|
'type' => 'number',
|
||||||
'def' => 75
|
'def' => 0.85,
|
||||||
|
'step' => 0.01
|
||||||
),
|
),
|
||||||
'bg_color' => array(
|
'bg_color' => array(
|
||||||
'name' => 'Background Color',
|
'name' => 'Background Color',
|
||||||
@ -143,6 +143,12 @@ $cwv3_op_data = array(
|
|||||||
'type' => 'color',
|
'type' => 'color',
|
||||||
'fields' => array('color'=>'#000000')
|
'fields' => array('color'=>'#000000')
|
||||||
),
|
),
|
||||||
|
'css' => array(
|
||||||
|
'name' => 'Custom CSS',
|
||||||
|
'desc' => 'For a completely custom look, just drop your css here.',
|
||||||
|
'type' => 'textbox',
|
||||||
|
'def' => ''
|
||||||
|
),
|
||||||
'cat_list' => array(
|
'cat_list' => array(
|
||||||
'name' => 'Category restrictions',
|
'name' => 'Category restrictions',
|
||||||
'desc' => 'Select categories that you would like to restrict with the dialog.',
|
'desc' => 'Select categories that you would like to restrict with the dialog.',
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
|
.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
|
||||||
.cboxIframe{width:100%; height:100%; display:block; border:0;}
|
.cboxIframe{width:100%; height:100%; display:block; border:0;}
|
||||||
#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
|
#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
User Style:
|
User Style:
|
||||||
Change the following styles to modify the appearance of Colorbox. They are
|
Change the following styles to modify the appearance of Colorbox. They are
|
||||||
@ -29,13 +28,11 @@
|
|||||||
#cboxLoadingOverlay{background:#000;}
|
#cboxLoadingOverlay{background:#000;}
|
||||||
#cboxTitle{position:absolute; top:-22px; left:0; color:#000;}
|
#cboxTitle{position:absolute; top:-22px; left:0; color:#000;}
|
||||||
#cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;}
|
#cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;}
|
||||||
|
|
||||||
/* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
|
/* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
|
||||||
#cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;}
|
#cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;}
|
||||||
|
|
||||||
/* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
|
/* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
|
||||||
#cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;}
|
#cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;}
|
||||||
|
|
||||||
#cboxPrevious{background-position:0px 0px; right:44px;}
|
#cboxPrevious{background-position:0px 0px; right:44px;}
|
||||||
#cboxPrevious:hover{background-position:0px -25px;}
|
#cboxPrevious:hover{background-position:0px -25px;}
|
||||||
#cboxNext{background-position:-25px 0px; right:22px;}
|
#cboxNext{background-position:-25px 0px; right:22px;}
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
retinaImage: false,
|
retinaImage: false,
|
||||||
retinaUrl: false,
|
retinaUrl: false,
|
||||||
retinaSuffix: '@2x.$1',
|
retinaSuffix: '@2x.$1',
|
||||||
|
|
||||||
// internationalization
|
// internationalization
|
||||||
current: "image {current} of {total}",
|
current: "image {current} of {total}",
|
||||||
previous: "previous",
|
previous: "previous",
|
||||||
@ -45,7 +44,6 @@
|
|||||||
close: "close",
|
close: "close",
|
||||||
xhrError: "This content failed to load.",
|
xhrError: "This content failed to load.",
|
||||||
imgError: "This image failed to load.",
|
imgError: "This image failed to load.",
|
||||||
|
|
||||||
open: false,
|
open: false,
|
||||||
returnFocus: true,
|
returnFocus: true,
|
||||||
reposition: true,
|
reposition: true,
|
||||||
@ -56,7 +54,6 @@
|
|||||||
slideshowStart: "start slideshow",
|
slideshowStart: "start slideshow",
|
||||||
slideshowStop: "stop slideshow",
|
slideshowStop: "stop slideshow",
|
||||||
photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i,
|
photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i,
|
||||||
|
|
||||||
onOpen: false,
|
onOpen: false,
|
||||||
onLoad: false,
|
onLoad: false,
|
||||||
onComplete: false,
|
onComplete: false,
|
||||||
@ -85,7 +82,6 @@
|
|||||||
event_cleanup = prefix + '_cleanup',
|
event_cleanup = prefix + '_cleanup',
|
||||||
event_closed = prefix + '_closed',
|
event_closed = prefix + '_closed',
|
||||||
event_purge = prefix + '_purge',
|
event_purge = prefix + '_purge',
|
||||||
|
|
||||||
// Cached jQuery Object Variables
|
// Cached jQuery Object Variables
|
||||||
$overlay,
|
$overlay,
|
||||||
$box,
|
$box,
|
||||||
@ -127,7 +123,6 @@
|
|||||||
className,
|
className,
|
||||||
requests = 0,
|
requests = 0,
|
||||||
init;
|
init;
|
||||||
|
|
||||||
// ****************
|
// ****************
|
||||||
// HELPER FUNCTIONS
|
// HELPER FUNCTIONS
|
||||||
// ****************
|
// ****************
|
||||||
@ -135,15 +130,12 @@
|
|||||||
// Convience function for creating new jQuery objects
|
// Convience function for creating new jQuery objects
|
||||||
function $tag(tag, id, css) {
|
function $tag(tag, id, css) {
|
||||||
var element = document.createElement(tag);
|
var element = document.createElement(tag);
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
element.id = prefix + id;
|
element.id = prefix + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (css) {
|
if (css) {
|
||||||
element.style.cssText = css;
|
element.style.cssText = css;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $(element);
|
return $(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +144,6 @@
|
|||||||
function winheight() {
|
function winheight() {
|
||||||
return window.innerHeight ? window.innerHeight : $(window).height();
|
return window.innerHeight ? window.innerHeight : $(window).height();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the next and previous members in a group.
|
// Determine the next and previous members in a group.
|
||||||
function getIndex(increment) {
|
function getIndex(increment) {
|
||||||
var
|
var
|
||||||
@ -161,7 +152,6 @@
|
|||||||
|
|
||||||
return (newIndex < 0) ? max + newIndex : newIndex;
|
return (newIndex < 0) ? max + newIndex : newIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert '%' and 'px' values to integers
|
// Convert '%' and 'px' values to integers
|
||||||
function setSize(size, dimension) {
|
function setSize(size, dimension) {
|
||||||
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
|
return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
|
||||||
@ -172,18 +162,15 @@
|
|||||||
function isImage(settings, url) {
|
function isImage(settings, url) {
|
||||||
return settings.photo || settings.photoRegex.test(url);
|
return settings.photo || settings.photoRegex.test(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function retinaUrl(settings, url) {
|
function retinaUrl(settings, url) {
|
||||||
return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
|
return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trapFocus(e) {
|
function trapFocus(e) {
|
||||||
if ('contains' in $box[0] && !$box[0].contains(e.target)) {
|
if ('contains' in $box[0] && !$box[0].contains(e.target)) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$box.focus();
|
$box.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assigns function results to their respective properties
|
// Assigns function results to their respective properties
|
||||||
function makeSettings() {
|
function makeSettings() {
|
||||||
var i,
|
var i,
|
||||||
@ -212,19 +199,15 @@
|
|||||||
settings.href = $.trim(settings.href);
|
settings.href = $.trim(settings.href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger(event, callback) {
|
function trigger(event, callback) {
|
||||||
// for external use
|
// for external use
|
||||||
$(document).trigger(event);
|
$(document).trigger(event);
|
||||||
|
|
||||||
// for internal use
|
// for internal use
|
||||||
$events.trigger(event);
|
$events.trigger(event);
|
||||||
|
|
||||||
if ($.isFunction(callback)) {
|
if ($.isFunction(callback)) {
|
||||||
callback.call(element);
|
callback.call(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slideshow functionality
|
// Slideshow functionality
|
||||||
function slideshow() {
|
function slideshow() {
|
||||||
var
|
var
|
||||||
@ -240,24 +223,20 @@
|
|||||||
clear = function () {
|
clear = function () {
|
||||||
clearTimeout(timeOut);
|
clearTimeout(timeOut);
|
||||||
};
|
};
|
||||||
|
|
||||||
set = function () {
|
set = function () {
|
||||||
if (settings.loop || $related[index + 1]) {
|
if (settings.loop || $related[index + 1]) {
|
||||||
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
start = function () {
|
start = function () {
|
||||||
$slideshow
|
$slideshow
|
||||||
.html(settings.slideshowStop)
|
.html(settings.slideshowStop)
|
||||||
.unbind(click)
|
.unbind(click)
|
||||||
.one(click, stop);
|
.one(click, stop);
|
||||||
|
|
||||||
$events
|
$events
|
||||||
.bind(event_complete, set)
|
.bind(event_complete, set)
|
||||||
.bind(event_load, clear)
|
.bind(event_load, clear)
|
||||||
.bind(event_cleanup, stop);
|
.bind(event_cleanup, stop);
|
||||||
|
|
||||||
$box.removeClass(className + "off").addClass(className + "on");
|
$box.removeClass(className + "off").addClass(className + "on");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -276,7 +255,6 @@
|
|||||||
publicMethod.next();
|
publicMethod.next();
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
$box.removeClass(className + "on").addClass(className + "off");
|
$box.removeClass(className + "on").addClass(className + "off");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -289,7 +267,6 @@
|
|||||||
$box.removeClass(className + "off " + className + "on");
|
$box.removeClass(className + "off " + className + "on");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function launch(target) {
|
function launch(target) {
|
||||||
if (!closing) {
|
if (!closing) {
|
||||||
|
|
||||||
@ -305,7 +282,6 @@
|
|||||||
$related = $('.' + boxElement).filter(function () {
|
$related = $('.' + boxElement).filter(function () {
|
||||||
var data = $.data(this, colorbox),
|
var data = $.data(this, colorbox),
|
||||||
relRelated;
|
relRelated;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
relRelated = $(this).data('rel') || data.rel || this.rel;
|
relRelated = $(this).data('rel') || data.rel || this.rel;
|
||||||
}
|
}
|
||||||
@ -327,7 +303,6 @@
|
|||||||
visibility: 'visible'
|
visibility: 'visible'
|
||||||
}).show();
|
}).show();
|
||||||
|
|
||||||
|
|
||||||
if (className) {
|
if (className) {
|
||||||
$box.add($overlay).removeClass(className);
|
$box.add($overlay).removeClass(className);
|
||||||
}
|
}
|
||||||
@ -335,9 +310,7 @@
|
|||||||
$box.add($overlay).addClass(settings.className);
|
$box.add($overlay).addClass(settings.className);
|
||||||
}
|
}
|
||||||
className = settings.className;
|
className = settings.className;
|
||||||
|
|
||||||
$close.html(settings.close).show();
|
$close.html(settings.close).show();
|
||||||
|
|
||||||
if (!open) {
|
if (!open) {
|
||||||
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
||||||
|
|
||||||
@ -345,7 +318,6 @@
|
|||||||
$box.css({visibility:'hidden', display:'block'});
|
$box.css({visibility:'hidden', display:'block'});
|
||||||
|
|
||||||
$loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden').appendTo($content);
|
$loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden').appendTo($content);
|
||||||
|
|
||||||
// Cache values needed for size calculations
|
// Cache values needed for size calculations
|
||||||
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();
|
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();
|
||||||
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
|
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
|
||||||
@ -357,26 +329,21 @@
|
|||||||
settings.w = setSize(settings.initialWidth, 'x');
|
settings.w = setSize(settings.initialWidth, 'x');
|
||||||
settings.h = setSize(settings.initialHeight, 'y');
|
settings.h = setSize(settings.initialHeight, 'y');
|
||||||
publicMethod.position();
|
publicMethod.position();
|
||||||
|
|
||||||
slideshow();
|
slideshow();
|
||||||
|
|
||||||
trigger(event_open, settings.onOpen);
|
trigger(event_open, settings.onOpen);
|
||||||
|
|
||||||
$groupControls.add($title).hide();
|
$groupControls.add($title).hide();
|
||||||
|
|
||||||
$box.focus();
|
$box.focus();
|
||||||
|
|
||||||
// Confine focus to the modal
|
// Confine focus to the modal
|
||||||
// Uses event capturing that is not supported in IE8-
|
// Uses event capturing that is not supported in IE8-
|
||||||
if (document.addEventListener) {
|
if (document.addEventListener) {
|
||||||
|
|
||||||
document.addEventListener('focus', trapFocus, true);
|
document.addEventListener('focus', trapFocus, true);
|
||||||
|
|
||||||
$events.one(event_closed, function () {
|
$events.one(event_closed, function () {
|
||||||
document.removeEventListener('focus', trapFocus, true);
|
document.removeEventListener('focus', trapFocus, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return focus on closing
|
// Return focus on closing
|
||||||
if (settings.returnFocus) {
|
if (settings.returnFocus) {
|
||||||
$events.one(event_closed, function () {
|
$events.one(event_closed, function () {
|
||||||
@ -388,7 +355,6 @@
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colorbox's markup needs to be added to the DOM prior to being called
|
// Colorbox's markup needs to be added to the DOM prior to being called
|
||||||
// so that the browser will go ahead and load the CSS background images.
|
// so that the browser will go ahead and load the CSS background images.
|
||||||
function appendHTML() {
|
function appendHTML() {
|
||||||
@ -435,11 +401,9 @@
|
|||||||
$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
||||||
|
|
||||||
$groupControls = $next.add($prev).add($current).add($slideshow);
|
$groupControls = $next.add($prev).add($current).add($slideshow);
|
||||||
|
|
||||||
$(document.body).append($overlay, $box.append($wrap, $loadingBay));
|
$(document.body).append($overlay, $box.append($wrap, $loadingBay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Colorbox's event bindings
|
// Add Colorbox's event bindings
|
||||||
function addBindings() {
|
function addBindings() {
|
||||||
function clickHandler(e) {
|
function clickHandler(e) {
|
||||||
@ -450,11 +414,9 @@
|
|||||||
launch(this);
|
launch(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($box) {
|
if ($box) {
|
||||||
if (!init) {
|
if (!init) {
|
||||||
init = true;
|
init = true;
|
||||||
|
|
||||||
// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
|
// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
|
||||||
$next.click(function () {
|
$next.click(function () {
|
||||||
publicMethod.next();
|
publicMethod.next();
|
||||||
@ -488,7 +450,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($.isFunction($.fn.on)) {
|
if ($.isFunction($.fn.on)) {
|
||||||
// For jQuery 1.7+
|
// For jQuery 1.7+
|
||||||
$(document).on('click.'+prefix, '.'+boxElement, clickHandler);
|
$(document).on('click.'+prefix, '.'+boxElement, clickHandler);
|
||||||
@ -503,16 +464,12 @@
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't do anything if Colorbox already exists.
|
// Don't do anything if Colorbox already exists.
|
||||||
if ($.colorbox) {
|
if ($.colorbox) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the HTML when the DOM loads
|
// Append the HTML when the DOM loads
|
||||||
$(appendHTML);
|
$(appendHTML);
|
||||||
|
|
||||||
|
|
||||||
// ****************
|
// ****************
|
||||||
// PUBLIC FUNCTIONS
|
// PUBLIC FUNCTIONS
|
||||||
// Usage format: $.colorbox.close();
|
// Usage format: $.colorbox.close();
|
||||||
@ -525,7 +482,6 @@
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
appendHTML();
|
appendHTML();
|
||||||
|
|
||||||
if (addBindings()) {
|
if (addBindings()) {
|
||||||
if ($.isFunction($this)) { // assume a call to $.colorbox
|
if ($.isFunction($this)) { // assume a call to $.colorbox
|
||||||
$this = $('<a/>');
|
$this = $('<a/>');
|
||||||
@ -549,7 +505,6 @@
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethod.position = function (speed, loadedCallback) {
|
publicMethod.position = function (speed, loadedCallback) {
|
||||||
var
|
var
|
||||||
css,
|
css,
|
||||||
@ -560,13 +515,10 @@
|
|||||||
scrollLeft;
|
scrollLeft;
|
||||||
|
|
||||||
$window.unbind('resize.' + prefix);
|
$window.unbind('resize.' + prefix);
|
||||||
|
|
||||||
// remove the modal so that it doesn't influence the document width/height
|
// remove the modal so that it doesn't influence the document width/height
|
||||||
$box.css({top: -9e4, left: -9e4});
|
$box.css({top: -9e4, left: -9e4});
|
||||||
|
|
||||||
scrollTop = $window.scrollTop();
|
scrollTop = $window.scrollTop();
|
||||||
scrollLeft = $window.scrollLeft();
|
scrollLeft = $window.scrollLeft();
|
||||||
|
|
||||||
if (settings.fixed) {
|
if (settings.fixed) {
|
||||||
offset.top -= scrollTop;
|
offset.top -= scrollTop;
|
||||||
offset.left -= scrollLeft;
|
offset.left -= scrollLeft;
|
||||||
@ -576,7 +528,6 @@
|
|||||||
left = scrollLeft;
|
left = scrollLeft;
|
||||||
$box.css({position: 'absolute'});
|
$box.css({position: 'absolute'});
|
||||||
}
|
}
|
||||||
|
|
||||||
// keeps the top and left positions within the browser's viewport.
|
// keeps the top and left positions within the browser's viewport.
|
||||||
if (settings.right !== false) {
|
if (settings.right !== false) {
|
||||||
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
|
left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
|
||||||
@ -593,9 +544,7 @@
|
|||||||
} else {
|
} else {
|
||||||
top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
|
top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$box.css({top: offset.top, left: offset.left, visibility:'visible'});
|
$box.css({top: offset.top, left: offset.left, visibility:'visible'});
|
||||||
|
|
||||||
// setting the speed to 0 to reduce the delay between same-sized content.
|
// setting the speed to 0 to reduce the delay between same-sized content.
|
||||||
speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
|
speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
|
||||||
|
|
||||||
@ -608,9 +557,7 @@
|
|||||||
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt(that.style.width,10) - interfaceWidth)+'px';
|
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt(that.style.width,10) - interfaceWidth)+'px';
|
||||||
$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt(that.style.height,10) - interfaceHeight)+'px';
|
$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt(that.style.height,10) - interfaceHeight)+'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left};
|
css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left};
|
||||||
|
|
||||||
if(speed===0){ // temporary workaround to side-step jQuery-UI 1.8 bug (http://bugs.jquery.com/ticket/12273)
|
if(speed===0){ // temporary workaround to side-step jQuery-UI 1.8 bug (http://bugs.jquery.com/ticket/12273)
|
||||||
$box.css(css);
|
$box.css(css);
|
||||||
}
|
}
|
||||||
@ -630,7 +577,6 @@
|
|||||||
$window.bind('resize.' + prefix, publicMethod.position);
|
$window.bind('resize.' + prefix, publicMethod.position);
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadedCallback) {
|
if (loadedCallback) {
|
||||||
loadedCallback();
|
loadedCallback();
|
||||||
}
|
}
|
||||||
@ -640,7 +586,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethod.resize = function (options) {
|
publicMethod.resize = function (options) {
|
||||||
if (open) {
|
if (open) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@ -668,16 +613,13 @@
|
|||||||
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
|
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethod.prep = function (object) {
|
publicMethod.prep = function (object) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var callback, speed = settings.transition === "none" ? 0 : settings.speed;
|
var callback, speed = settings.transition === "none" ? 0 : settings.speed;
|
||||||
|
|
||||||
$loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
|
$loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
|
||||||
|
|
||||||
$loaded = $tag(div, 'LoadedContent').append(object);
|
$loaded = $tag(div, 'LoadedContent').append(object);
|
||||||
|
|
||||||
function getWidth() {
|
function getWidth() {
|
||||||
@ -702,7 +644,6 @@
|
|||||||
// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
|
// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
|
||||||
|
|
||||||
$(photo).css({'float': 'none'});
|
$(photo).css({'float': 'none'});
|
||||||
|
|
||||||
callback = function () {
|
callback = function () {
|
||||||
var total = $related.length,
|
var total = $related.length,
|
||||||
iframe,
|
iframe,
|
||||||
@ -726,7 +667,6 @@
|
|||||||
trigger(event_complete, settings.onComplete);
|
trigger(event_complete, settings.onComplete);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$title.html(settings.title).add($loaded).show();
|
$title.html(settings.title).add($loaded).show();
|
||||||
|
|
||||||
if (total > 1) { // handle grouping
|
if (total > 1) { // handle grouping
|
||||||
@ -748,7 +688,6 @@
|
|||||||
img,
|
img,
|
||||||
i = $related[this],
|
i = $related[this],
|
||||||
data = $.data(i, colorbox);
|
data = $.data(i, colorbox);
|
||||||
|
|
||||||
if (data && data.href) {
|
if (data && data.href) {
|
||||||
src = data.href;
|
src = data.href;
|
||||||
if ($.isFunction(src)) {
|
if ($.isFunction(src)) {
|
||||||
@ -757,7 +696,6 @@
|
|||||||
} else {
|
} else {
|
||||||
src = $(i).attr('href');
|
src = $(i).attr('href');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src && isImage(data, src)) {
|
if (src && isImage(data, src)) {
|
||||||
src = retinaUrl(data, src);
|
src = retinaUrl(data, src);
|
||||||
img = new Image();
|
img = new Image();
|
||||||
@ -779,7 +717,6 @@
|
|||||||
if (allowTransparency in iframe) {
|
if (allowTransparency in iframe) {
|
||||||
iframe[allowTransparency] = "true";
|
iframe[allowTransparency] = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.scrolling) {
|
if (!settings.scrolling) {
|
||||||
iframe.scrolling = "no";
|
iframe.scrolling = "no";
|
||||||
}
|
}
|
||||||
@ -799,7 +736,6 @@
|
|||||||
$events.one(event_purge, function () {
|
$events.one(event_purge, function () {
|
||||||
iframe.src = "//about:blank";
|
iframe.src = "//about:blank";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (settings.fastIframe) {
|
if (settings.fastIframe) {
|
||||||
$(iframe).trigger('load');
|
$(iframe).trigger('load');
|
||||||
}
|
}
|
||||||
@ -822,7 +758,6 @@
|
|||||||
publicMethod.position(speed, callback);
|
publicMethod.position(speed, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function load () {
|
function load () {
|
||||||
var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
|
var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
|
||||||
|
|
||||||
@ -871,11 +806,9 @@
|
|||||||
// Inserts an empty placeholder where inline content is being pulled from.
|
// Inserts an empty placeholder where inline content is being pulled from.
|
||||||
// An event is bound to put inline content back when Colorbox closes or loads new content.
|
// An event is bound to put inline content back when Colorbox closes or loads new content.
|
||||||
$inline = $tag(div).hide().insertBefore($(href)[0]);
|
$inline = $tag(div).hide().insertBefore($(href)[0]);
|
||||||
|
|
||||||
$events.one(event_purge, function () {
|
$events.one(event_purge, function () {
|
||||||
$inline.replaceWith($loaded.children());
|
$inline.replaceWith($loaded.children());
|
||||||
});
|
});
|
||||||
|
|
||||||
prep($(href));
|
prep($(href));
|
||||||
} else if (settings.iframe) {
|
} else if (settings.iframe) {
|
||||||
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
||||||
@ -884,9 +817,7 @@
|
|||||||
} else if (settings.html) {
|
} else if (settings.html) {
|
||||||
prep(settings.html);
|
prep(settings.html);
|
||||||
} else if (isImage(settings, href)) {
|
} else if (isImage(settings, href)) {
|
||||||
|
|
||||||
href = retinaUrl(settings, href);
|
href = retinaUrl(settings, href);
|
||||||
|
|
||||||
$(photo = new Image())
|
$(photo = new Image())
|
||||||
.addClass(prefix + 'Photo')
|
.addClass(prefix + 'Photo')
|
||||||
.bind('error',function () {
|
.bind('error',function () {
|
||||||
@ -895,18 +826,14 @@
|
|||||||
})
|
})
|
||||||
.one('load', function () {
|
.one('load', function () {
|
||||||
var percent;
|
var percent;
|
||||||
|
|
||||||
if (request !== requests) {
|
if (request !== requests) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
photo.alt = $(element).attr('alt') || $(element).attr('data-alt') || '';
|
photo.alt = $(element).attr('alt') || $(element).attr('data-alt') || '';
|
||||||
|
|
||||||
if (settings.retinaImage && window.devicePixelRatio > 1) {
|
if (settings.retinaImage && window.devicePixelRatio > 1) {
|
||||||
photo.height = photo.height / window.devicePixelRatio;
|
photo.height = photo.height / window.devicePixelRatio;
|
||||||
photo.width = photo.width / window.devicePixelRatio;
|
photo.width = photo.width / window.devicePixelRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.scalePhotos) {
|
if (settings.scalePhotos) {
|
||||||
setResize = function () {
|
setResize = function () {
|
||||||
photo.height -= photo.height * percent;
|
photo.height -= photo.height * percent;
|
||||||
@ -932,10 +859,8 @@
|
|||||||
publicMethod.next();
|
publicMethod.next();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
photo.style.width = photo.width + 'px';
|
photo.style.width = photo.width + 'px';
|
||||||
photo.style.height = photo.height + 'px';
|
photo.style.height = photo.height + 'px';
|
||||||
|
|
||||||
setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
|
setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
|
||||||
prep(photo);
|
prep(photo);
|
||||||
}, 1);
|
}, 1);
|
||||||
@ -967,7 +892,6 @@
|
|||||||
launch($related[index]);
|
launch($related[index]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: to use this within an iframe use the following format: parent.jQuery.colorbox.close();
|
// Note: to use this within an iframe use the following format: parent.jQuery.colorbox.close();
|
||||||
publicMethod.close = function () {
|
publicMethod.close = function () {
|
||||||
if (open && !closing) {
|
if (open && !closing) {
|
||||||
@ -997,11 +921,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Removes changes Colorbox made to the document, but does not remove the plugin.
|
// Removes changes Colorbox made to the document, but does not remove the plugin.
|
||||||
publicMethod.remove = function () {
|
publicMethod.remove = function () {
|
||||||
if (!$box) { return; }
|
if (!$box) { return; }
|
||||||
|
|
||||||
$box.stop();
|
$box.stop();
|
||||||
$.colorbox.close();
|
$.colorbox.close();
|
||||||
$box.stop().remove();
|
$box.stop().remove();
|
||||||
@ -1011,16 +933,12 @@
|
|||||||
$('.' + boxElement)
|
$('.' + boxElement)
|
||||||
.removeData(colorbox)
|
.removeData(colorbox)
|
||||||
.removeClass(boxElement);
|
.removeClass(boxElement);
|
||||||
|
|
||||||
$(document).unbind('click.'+prefix);
|
$(document).unbind('click.'+prefix);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A method for fetching the current element Colorbox is referencing.
|
// A method for fetching the current element Colorbox is referencing.
|
||||||
// returns a jQuery object.
|
// returns a jQuery object.
|
||||||
publicMethod.element = function () {
|
publicMethod.element = function () {
|
||||||
return $(element);
|
return $(element);
|
||||||
};
|
};
|
||||||
|
|
||||||
publicMethod.settings = defaults;
|
publicMethod.settings = defaults;
|
||||||
|
|
||||||
}(jQuery, document, window));
|
}(jQuery, document, window));
|
||||||
|
18
js/cwv3.js
18
js/cwv3.js
@ -1,9 +1,9 @@
|
|||||||
// JavaScript Document
|
// JavaScript Document
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
var wpdata = cwv3_params;
|
var wpdata = cwv3_params;
|
||||||
|
//console.log(wpdata);
|
||||||
var enter = $('cw_enter_link');
|
var enter = $('#cw_enter_link');
|
||||||
var exit = $('cw_exit_link');
|
var exit = $('#cw_exit_link');
|
||||||
|
|
||||||
if(wpdata.sd == true){
|
if(wpdata.sd == true){
|
||||||
var cboxObj = $.colorbox(
|
var cboxObj = $.colorbox(
|
||||||
@ -19,19 +19,25 @@ jQuery(document).ready(function($) {
|
|||||||
onLoad: function(){
|
onLoad: function(){
|
||||||
$('#cboxClose').remove();
|
$('#cboxClose').remove();
|
||||||
},
|
},
|
||||||
className: 'cwv3_box'
|
className: 'cwv3_box',
|
||||||
|
opacity: cwv3_params.opacity
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
enter.click(function(e){
|
enter.click(function(e){
|
||||||
|
//console.log(e);
|
||||||
$.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'enter'}, function(e){
|
$.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'enter'}, function(e){
|
||||||
// Deal with the response from the 'entry' handler.
|
if(cwv3_params.enter == "#"){
|
||||||
|
$.colorbox.close();
|
||||||
|
}else{
|
||||||
|
window.location = wpdata.enter;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
exit.click(function(e){
|
exit.click(function(e){
|
||||||
$.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'exit'}, function(e){
|
$.post(wpdata.admin_url, {action: wpdata.action, nonce: wpdata.nonce, id: wpdata.id, method: 'exit'}, function(e){
|
||||||
// Deal with the response from the 'exit' handler.
|
window.location = wpdata.exit;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user