Changeset 1501924
- Timestamp:
- 09/24/2016 01:31:18 PM (10 years ago)
- Location:
- click-to-scroll/trunk
- Files:
-
- 8 edited
-
assets/css/back.css (modified) (1 diff)
-
assets/css/style.css (modified) (2 diffs)
-
assets/css/style.min.css (modified) (1 diff)
-
assets/js/back.js (modified) (3 diffs)
-
click-to-scroll.php (modified) (1 diff)
-
inc/CTS_Backend.php (modified) (5 diffs)
-
inc/CTS_Frontend.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
click-to-scroll/trunk/assets/css/back.css
r1484533 r1501924 27 27 } 28 28 29 /* 30 #cts_reset { 31 margin-left: 15px; 29 .cts-button-image { 30 max-width: 150px; 32 31 } 33 */ 32 33 .cts-button-image img { 34 max-width: 100%; 35 } -
click-to-scroll/trunk/assets/css/style.css
r1481666 r1501924 11 11 opacity: 0; 12 12 visibility: hidden; 13 z-index: 9999; 13 14 } 14 15 … … 37 38 transition: border-color 0.3s; 38 39 } 40 41 .cts-button-image { 42 max-width: 150px; 43 } 44 45 .cts-button-image img { 46 max-width: 100%; 47 } -
click-to-scroll/trunk/assets/css/style.min.css
r1481666 r1501924 1 .cts-button{display:block;position:fixed;bottom:30px;right:30px;-webkit-transition:all .3s;-moz-transition:all .3s;-ms-transition:all .3s;-o-transition:all .3s;transition:all .3s;opacity:0;visibility:hidden }.cts-button.active{opacity:1;visibility:visible}.cts-button:focus{outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.cts-button-icon{position:absolute;left:50%;top:50%;width:0;height:0;-webkit-transition:border-color .3s;-moz-transition:border-color .3s;-ms-transition:border-color .3s;-o-transition:border-color .3s;transition:border-color .3s}1 .cts-button{display:block;position:fixed;bottom:30px;right:30px;-webkit-transition:all .3s;-moz-transition:all .3s;-ms-transition:all .3s;-o-transition:all .3s;transition:all .3s;opacity:0;visibility:hidden;z-index:9999}.cts-button.active{opacity:1;visibility:visible}.cts-button:focus{outline:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.cts-button-icon{position:absolute;left:50%;top:50%;width:0;height:0;-webkit-transition:border-color .3s;-moz-transition:border-color .3s;-ms-transition:border-color .3s;-o-transition:border-color .3s;transition:border-color .3s}.cts-button-image{max-width:150px}.cts-button-image img{max-width:100%} -
click-to-scroll/trunk/assets/js/back.js
r1484533 r1501924 29 29 }); 30 30 31 function conditionalLogic(name, dependencyName) { 31 // conditional logic for image use 32 conditionalLogic('arrow_width', 'use_image', true); 33 conditionalLogic('arrow_height', 'use_image', true); 34 conditionalLogic('button_width', 'use_image', true); 35 conditionalLogic('button_height', 'use_image', true); 36 conditionalLogic('button_arrow_color', 'use_image', true); 37 conditionalLogic('button_arrow_hover_color', 'use_image', true); 38 conditionalLogic('button_bg_color', 'use_image', true); 39 conditionalLogic('button_bg_hover_color', 'use_image', true); 40 conditionalLogic('button_border_radius', 'use_image', true); 41 conditionalLogic('image_url', 'use_image'); 42 43 $('[name="cts_options[use_image]"]').on('change', function() { 44 conditionalLogic('arrow_width', 'use_image', true); 45 conditionalLogic('arrow_height', 'use_image', true); 46 conditionalLogic('button_width', 'use_image', true); 47 conditionalLogic('button_height', 'use_image', true); 48 conditionalLogic('button_arrow_color', 'use_image', true); 49 conditionalLogic('button_arrow_hover_color', 'use_image', true); 50 conditionalLogic('button_bg_color', 'use_image', true); 51 conditionalLogic('button_bg_hover_color', 'use_image', true); 52 conditionalLogic('button_border_radius', 'use_image', true); 53 conditionalLogic('image_url', 'use_image'); 54 }); 55 56 function conditionalLogic(name, dependencyName, hide) { 32 57 var $dep = $('[name="cts_options[' + dependencyName + ']"]'), 33 58 $field = $('[name="cts_options[' + name + ']"]'); … … 35 60 36 61 if( $dep.length && $field.length ) { 37 if( $dep.is(':checked') ) { 62 63 if( ( ! hide && $dep.is(':checked') ) || ( hide && ! $dep.is(':checked') ) ) { 38 64 $field.closest('tr').removeClass('hidden').slideDown(); 39 65 } else { … … 43 69 } 44 70 71 $('.cts-upload-field').on('click', '.upload-btn', function(e) { 72 e.preventDefault(); 73 74 var $that = $(this); 75 76 var image = wp.media({ 77 title: 'Upload Image', 78 // mutiple: true if you want to upload multiple files at once 79 multiple: false 80 }).open() 81 .on('select', function(e){ 82 // This will return the selected image from the Media Uploader, the result is an object 83 var uploaded_image = image.state().get('selection').first(); 84 85 // We convert uploaded_image to a JSON object to make accessing it easier 86 var image_url = uploaded_image.toJSON().url; 87 // Let's assign the url value to the input field 88 $that.parent().find('.image_url').val(image_url); 89 }); 90 }); 91 92 93 94 45 95 }); 96 97 $('#submit').click(function () { 98 if( validateFields() !== true ) { 99 return false; 100 } 101 }); 102 103 function validateFields() { 104 if( $('[name="cts_options[use_image]"]').is(':checked') && ! $('[name="cts_options[image_url]"]').val() ) { 105 // todo: create an object to keep JS strings translations 106 alert('Please upload the button image'); 107 108 return false; 109 } 110 111 return true; 112 } 46 113 })(jQuery); -
click-to-scroll/trunk/click-to-scroll.php
r1491234 r1501924 13 13 * Plugin Name: Click to Scroll 14 14 * Description: Add a customizable scroll-to-top button to your site and the admin area 15 * Version: 1. 2.015 * Version: 1.3.0 16 16 * Author: Igor Skoldin 17 17 * Author URI: https://profiles.wordpress.org/skoldin/ -
click-to-scroll/trunk/inc/CTS_Backend.php
r1491234 r1501924 47 47 <?php } 48 48 49 public function cts_button_image_field() { 50 $this->show_field('image', 'image_url'); 51 } 52 49 53 public function cts_button_width_field() { 50 54 $this->show_field('size', 'button_width', 35); 55 } 56 57 public function cts_button_use_image_field() { 58 $this->show_field('checkbox', 'use_image', 0); 51 59 } 52 60 … … 136 144 137 145 // todo: maybe show the fields with a loop 146 147 add_settings_field( 148 'use-image', 149 __( 'I would like to use an image', 'cts' ), 150 array( $this, 'cts_button_use_image_field' ), 151 'cts-options', 152 'style' 153 ); 154 155 add_settings_field( 156 'image-url', 157 __( 'Upload the button image', 'cts' ), 158 array( $this, 'cts_button_image_field' ), 159 'cts-options', 160 'style' 161 ); 138 162 139 163 add_settings_field( … … 264 288 wp_enqueue_script( 'jquery-ui-slider' ); 265 289 wp_enqueue_style( 'jquery-ui-smoothness', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' ); 266 wp_enqueue_script( 'cts_admin_scripts', CTS_URL . '/assets/js/back.js', array( 'jquery' ), '1.2.0', true ); 267 wp_enqueue_style( 'cts_admin_styles', CTS_URL . '/assets/css/back.css', null, '1.2.0' ); 290 wp_enqueue_script( 'cts_admin_scripts', CTS_URL . '/assets/js/back.js', array( 'jquery' ), '1.3.0', true ); 291 wp_enqueue_style( 'cts_admin_styles', CTS_URL . '/assets/css/back.css', null, '1.3.0' ); 292 293 wp_enqueue_media(); 268 294 } 269 295 … … 286 312 } 287 313 314 if ( $type === 'image' ) { 315 $this->show_image_field( $val, $name ); 316 } 288 317 if ( $type === 'size' ) { 289 318 $this->show_number_field( $val, $name, 1, 0, null, 'px' ); … … 314 343 315 344 echo "<input type='number' step='$step' $min_val $max_val value='$val' id='cts-$name' name='cts_options[$name]'>$after"; 345 } 346 347 private function show_image_field( $val, $name ) { 348 ?> 349 <div class="cts-upload-field"> 350 <input type='url' value='<?php echo $val; ?>' id='cts-<?php echo $name; ?>' class='image_url' name='cts_options[<?php echo $name; ?>]'> 351 <input type='button' name='upload-btn' class='upload-btn button-secondary' value='Upload Image'> 352 </div> 353 <?php 316 354 } 317 355 -
click-to-scroll/trunk/inc/CTS_Frontend.php
r1491234 r1501924 34 34 $options = $this->options; 35 35 36 // need to check it here as well because the default values may be not saved 37 $button_width = ( ! empty( $options['button_width'] ) ) ? $options['button_width'] : 40; 38 $button_height = ( ! empty( $options['button_height'] ) ) ? $options['button_height'] : 40; 36 $uses_image = ( $this->options['use_image'] == 1 && ! empty($this->options['image_url']) ) ? true : false; 39 37 40 $arrow_width = ( ! empty( $options['arrow_width'] ) ) ? $options['arrow_width'] : 20;41 $arrow_width_half = round( $arrow_width / 2 );42 $arrow_height = ( ! empty( $options['arrow_height'] ) ) ? $options['arrow_height'] : 15;43 $arrow_height_half = round( $arrow_height / 2 );38 if( ! $uses_image ) { 39 // need to check it here as well because the default values may be not saved 40 $button_width = ( ! empty( $options['button_width'] ) ) ? $options['button_width'] : 40; 41 $button_height = ( ! empty( $options['button_height'] ) ) ? $options['button_height'] : 40; 44 42 45 $button_bg_color = ( ! empty( $options['button_bg_color'] ) ) ? $options['button_bg_color'] : '#333333';46 $button_arrow_color = ( ! empty( $options['button_arrow_color'] ) ) ? $options['button_arrow_color'] : '#ffffff';47 $button_bg_hover_color = ( ! empty( $options['button_bg_hover_color'] ) ) ? $options['button_bg_hover_color'] : '#6D6D6D';48 $button_arrow_hover_color = ( ! empty( $options['button_arrow_hover_color'] ) ) ? $options['button_arrow_hover_color'] : '#ffffff';43 $arrow_width = ( ! empty( $options['arrow_width'] ) ) ? $options['arrow_width'] : 20; 44 $arrow_width_half = round( $arrow_width / 2 ); 45 $arrow_height = ( ! empty( $options['arrow_height'] ) ) ? $options['arrow_height'] : 15; 46 $arrow_height_half = round( $arrow_height / 2 ); 49 47 50 $button_opacity = ( ! empty( $options['button_opacity'] ) ) ? $options['button_opacity'] : 1; 48 $button_bg_color = ( ! empty( $options['button_bg_color'] ) ) ? $options['button_bg_color'] : '#333333'; 49 $button_arrow_color = ( ! empty( $options['button_arrow_color'] ) ) ? $options['button_arrow_color'] : '#ffffff'; 50 $button_bg_hover_color = ( ! empty( $options['button_bg_hover_color'] ) ) ? $options['button_bg_hover_color'] : '#6D6D6D'; 51 $button_arrow_hover_color = ( ! empty( $options['button_arrow_hover_color'] ) ) ? $options['button_arrow_hover_color'] : '#ffffff'; 52 53 $button_border_radius = ( isset( $options['button_border_radius'] ) ) ? $options['button_border_radius'] : 50; 54 } 55 56 $button_opacity = ( ! empty( $options['button_opacity'] ) ) ? $options['button_opacity'] : 1; 51 57 $button_hover_opacity = ( ! empty( $options['button_hover_opacity'] ) ) ? $options['button_hover_opacity'] : 1; 52 53 $button_border_radius = ( isset($options['button_border_radius']) ) ? $options['button_border_radius'] : 50; ?> 58 ?> 54 59 <style> 55 .cts-button {60 .cts-button-css { 56 61 width: <?php echo $button_width; ?>px; 57 62 height: <?php echo $button_height; ?>px; … … 68 73 } 69 74 70 .cts-button- icon {75 .cts-button-css .cts-button-icon { 71 76 margin-left: -<?php echo $arrow_width_half; ?>px; 72 77 margin-top: -<?php echo $arrow_height_half; ?>px; … … 77 82 } 78 83 79 .cts-button :hover {84 .cts-button-css:hover { 80 85 background-color: <?php echo $button_bg_hover_color; ?>; 81 86 } 82 87 83 .cts-button :hover .cts-button-icon {88 .cts-button-css:hover .cts-button-icon { 84 89 border-bottom-color: <?php echo $button_arrow_hover_color; ?>; 85 90 } … … 90 95 $suffix = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min'; 91 96 92 wp_enqueue_style( 'cts_styles', CTS_URL . '/assets/css/style.min.css', null, '1. 2.0' );97 wp_enqueue_style( 'cts_styles', CTS_URL . '/assets/css/style.min.css', null, '1.3.0' ); 93 98 wp_enqueue_script( 'cts_scripts', CTS_URL . '/assets/js/front'.$suffix.'.js', array( 'jquery' ), '1.2.0', true ); 94 99 } 95 100 96 101 public function show_button() { 97 echo "<a href='#' class='cts-button'><span class='cts-button-icon'></span></a>"; 98 102 if( $this->options['use_image'] == 1 && ! empty($this->options['image_url']) ) { 103 echo "<a href='#' class='cts-button cts-button-image'><img src='{$this->options['image_url']}' alt='Scroll to Top Button'/></a>"; 104 } else { 105 echo "<a href='#' class='cts-button cts-button-css'><span class='cts-button-icon'></span></a>"; 106 } 99 107 } 100 108 -
click-to-scroll/trunk/readme.txt
r1491234 r1501924 61 61 == Changelog == 62 62 63 = 1.3.0 = 64 * Fix: z-index issue because of which the button may be overlapped by other site elements 65 * Add: the capability to use a button image 66 63 67 = 1.2.0 = 64 68
Note: See TracChangeset
for help on using the changeset viewer.