diff --git a/auto-thickbox-options.php b/auto-thickbox-options.php index 0e391b4..dc5034f 100644 --- a/auto-thickbox-options.php +++ b/auto-thickbox-options.php @@ -63,16 +63,18 @@ class auto_thickbox_options { } function general_metabox() { - $builtin_res_checked = $this->options['builtin_res'] == 'on'; + $builtin_thickbox = $this->options['thickbox_type'] == 'built-in'; ?> @@ -96,6 +98,8 @@ class auto_thickbox_options { @@ -935,7 +941,7 @@ class auto_thickbox_options { register_setting( $this->option_group, 'auto-thickbox-plus', array(&$this, 'options_callback') ); } - var $checkboxes_on = array('wp_gallery', 'thickbox_text', 'auto_resize_img', 'auto_resize_html', + var $checkboxes_on = array('wp_gallery', 'thickbox_img', 'thickbox_text', 'auto_resize_img', 'auto_resize_html', 'key_close_esc', 'key_close_enter', 'key_prev_angle', 'key_prev_left', 'key_next_angle', 'key_next_right', diff --git a/auto-thickbox.js b/auto-thickbox.js index 7385571..d50c4f5 100644 --- a/auto-thickbox.js +++ b/auto-thickbox.js @@ -74,6 +74,20 @@ jQuery(function($) { return false; }); }); + + tb_init("a.thickbox-image"); // prevent href from being modified by media-upload.js + var tb_position2 = tb_position; + tb_position = function() { + if ($("#TB_iframeContent").length) { // tb_position() in media-upload.js + tb_position2(); + } else { // tb_position() in built-in thickbox.js + var isIE6 = typeof document.body.style.maxHeight === "undefined"; + jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); + if ( ! isIE6 ) { // take away IE6 + jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); + } + } + }; }); function updateEffectSpeed(radio) { @@ -100,9 +114,11 @@ function disableHideInitOption(radio) { document.form[name].disabled = radio.value == 'none'; } -function disablePlaceOption(checkbox) { +function disablePlaceOption(select) { for (var i = 0; i < document.form['auto-thickbox-plus[script_place]'].length; i++) - document.form['auto-thickbox-plus[script_place]'][i].disabled = checkbox.checked; + document.form['auto-thickbox-plus[script_place]'][i].disabled = select.value == 'built-in'; + if (select.value == 'built-in') + document.form['auto-thickbox-plus[script_place]'][1].checked = true; } function disableClickOption(radio) { diff --git a/auto-thickbox.php b/auto-thickbox.php index 8d86942..4b01749 100644 --- a/auto-thickbox.php +++ b/auto-thickbox.php @@ -84,7 +84,8 @@ class auto_thickbox { * @return anchor $anchor **/ function image($anchor) { - if ( ($this->options['thickbox_text'] == 'off' && !preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body'])) + if ( ($this->options['thickbox_img'] == 'off' && preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body'])) + || ($this->options['thickbox_text'] == 'off' && !preg_match("/^\s*<\s*img\s.+?>\s*$/is", $anchor['body'])) || ($this->options['thickbox_target'] == 'off' && !empty($anchor['attr']['target'])) ) return $anchor; @@ -129,13 +130,13 @@ class auto_thickbox { * @return void **/ function scripts() { - if ( $this->options['builtin_res'] == 'off' ) { + if ( $this->options['thickbox_type'] == 'modified' ) { wp_deregister_script('thickbox'); $in_footer = $this->options['script_place'] == 'footer'; wp_register_script('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.js' :'thickbox.min.js'), array('jquery'), AUTO_THICKBOX_PLUS_VER, $in_footer); } wp_enqueue_script('thickbox'); - if ( $this->options['builtin_res'] == 'off' ) { + if ( $this->options['thickbox_type'] == 'modified' ) { $l10n = array( 'next' => $this->texts['next'], 'prev' => $this->texts['prev'], @@ -169,7 +170,7 @@ class auto_thickbox { * @return void **/ function styles() { - if ( $this->options['builtin_res'] == 'off' ) { + if ( $this->options['thickbox_type'] == 'modified' ) { wp_deregister_style('thickbox'); wp_register_style('thickbox', $this->util->plugins_url(WP_DEBUG ? 'thickbox.css' : 'thickbox.min.css'), false, AUTO_THICKBOX_PLUS_VER); } @@ -195,6 +196,10 @@ jQuery(function($) { var nothickbox = ['options['no_thickbox'])); ?>']; for (var i = 0; i < nothickbox.length; i++) if ($(this).hasClass(nothickbox[i])) return false; +options['thickbox_img'] == 'off') : ?> + // Image links to images + if ($(this).is(':has(img)')) return false; +options['thickbox_text'] == 'off') : ?> // Text links to images if (!$(this).is(':has(img)')) return false; @@ -253,7 +258,7 @@ jQuery(function($) { }); options['builtin_res'] == 'on') { + if ($this->options['thickbox_type'] == 'built-in') { if ( version_compare('3.2', get_bloginfo('version')) > 0 ) { $includes_url = includes_url(); echo <<
util->_e('Display Style'); ?>
+ util->_e('Single Image'); ?> + (util->_e('Preview'); ?>) + util->_e('Gallery Images'); ?> + (util->_e('Preview'); ?>)
+

util->_e('ThickBox Resources'); ?> -
- +