Version Description
- 2012-11-09
Download this release
Release Info
Developer | kosinix |
Plugin | Cyclone Slider |
Version | 2.0.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.0.1
- README.txt +5 -3
- cyclone-slider.php +85 -85
- inc/class-cyclone-slider.php +688 -688
- js/admin.js +157 -157
- js/jquery.cycle2.min.js +5 -5
- js/jquery.cycle2.tile.min.js +1 -1
README.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.codefleet.net/donate
|
|
4 |
Tags: slider, slideshow, jquery, cycle 2, responsive, multilingual support, custom post, cyclone slider
|
5 |
Requires at least: 3.3.2
|
6 |
Tested up to: 3.4.2
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -83,11 +83,13 @@ Inside your theme create a folder named "cycloneslider". Add your templates insi
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
-
=
|
|
|
|
|
87 |
* Initial
|
88 |
|
89 |
|
90 |
== Upgrade Notice ==
|
91 |
|
92 |
-
=
|
93 |
* Initial. If you are using Cyclone Slider (version 1) deactivate it first before activating Cyclone Slider 2
|
4 |
Tags: slider, slideshow, jquery, cycle 2, responsive, multilingual support, custom post, cyclone slider
|
5 |
Requires at least: 3.3.2
|
6 |
Tested up to: 3.4.2
|
7 |
+
Stable tag: 2.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 2.0.1 - 2012-11-09 =
|
87 |
+
* Bug fix for hover pause
|
88 |
+
= 2.0.0 - 2012-10-28 =
|
89 |
* Initial
|
90 |
|
91 |
|
92 |
== Upgrade Notice ==
|
93 |
|
94 |
+
= 2.0.0 =
|
95 |
* Initial. If you are using Cyclone Slider (version 1) deactivate it first before activating Cyclone Slider 2
|
cyclone-slider.php
CHANGED
@@ -1,86 +1,86 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Cyclone Slider 2
|
4 |
-
Plugin URI: http://www.codefleet.net/cyclone-slider-2/
|
5 |
-
Description: Create responsive slideshows with ease. Built for both developers and non-developers.
|
6 |
-
Version: 2.0.
|
7 |
-
Author: Nico Amarilla
|
8 |
-
Author URI: http://www.codefleet.net/
|
9 |
-
License:
|
10 |
-
|
11 |
-
Copyright 2012 (kosinix@codefleet.net)
|
12 |
-
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License, version 2, as
|
15 |
-
published by the Free Software Foundation.
|
16 |
-
|
17 |
-
This program is distributed in the hope that it will be useful,
|
18 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
-
GNU General Public License for more details.
|
21 |
-
|
22 |
-
You should have received a copy of the GNU General Public License
|
23 |
-
along with this program; if not, write to the Free Software
|
24 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
-
|
26 |
-
*/
|
27 |
-
require_once('inc/class-cyclone-slider.php');
|
28 |
-
require_once('inc/class-image-resizer.php');
|
29 |
-
|
30 |
-
if(!defined('CYCLONE_PATH')){
|
31 |
-
define('CYCLONE_PATH', realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR );
|
32 |
-
}
|
33 |
-
if(!defined('CYCLONE_URL')){
|
34 |
-
define('CYCLONE_URL', plugin_dir_url(__FILE__) );
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
-
if(class_exists('Cyclone_Slider')):
|
39 |
-
new Cyclone_Slider();
|
40 |
-
endif;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Thumbnailer
|
44 |
-
*
|
45 |
-
* Creates thumbnail of the slide image using the specified attachment ID, width and height
|
46 |
-
*
|
47 |
-
*
|
48 |
-
* @param int $original_attachment_id Attachment ID.
|
49 |
-
* @param int $width Width of thumbnail in pixels.
|
50 |
-
* @param int $height Height of thumbnail in pixels.
|
51 |
-
* @param bool $refresh Recreate thumbnail if it already exists if set to true. Default to false, will not recreate thumbnails if it already exist.
|
52 |
-
* @return string The url to the thumbnail. False on failure.
|
53 |
-
*/
|
54 |
-
//
|
55 |
-
function cycloneslider_thumb( $original_attachment_id, $width, $height, $refresh = false ){
|
56 |
-
$dir = wp_upload_dir();
|
57 |
-
|
58 |
-
// Get full path to the slide image
|
59 |
-
$image_path = get_attached_file($original_attachment_id);
|
60 |
-
if(empty($image_path)){
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
|
64 |
-
// Full url to the slide image
|
65 |
-
$image_url = wp_get_attachment_url($original_attachment_id);
|
66 |
-
if(empty($image_path)){
|
67 |
-
return false;
|
68 |
-
}
|
69 |
-
|
70 |
-
$info = pathinfo($image_path);
|
71 |
-
$dirname = isset($info['dirname']) ? $info['dirname'] : '';
|
72 |
-
$ext = isset($info['extension']) ? $info['extension'] : '';
|
73 |
-
$thumb = wp_basename($image_path, ".$ext")."-{$width}x{$height}.{$ext}";
|
74 |
-
|
75 |
-
// Check if thumb already exists. If it is, return its url, unless refresh is true
|
76 |
-
if(file_exists($dirname.'/'.$thumb ) and !$refresh){
|
77 |
-
return dirname($image_url).'/'.$thumb;
|
78 |
-
}
|
79 |
-
|
80 |
-
$resizeObj = new Image_Resizer($image_path);
|
81 |
-
$resizeObj -> resizeImage($width, $height);
|
82 |
-
$resizeObj -> saveImage($dirname.'/'.$thumb, 80);
|
83 |
-
|
84 |
-
return dirname($image_url).'/'.$thumb;
|
85 |
-
|
86 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Cyclone Slider 2
|
4 |
+
Plugin URI: http://www.codefleet.net/cyclone-slider-2/
|
5 |
+
Description: Create responsive slideshows with ease. Built for both developers and non-developers.
|
6 |
+
Version: 2.0.1
|
7 |
+
Author: Nico Amarilla
|
8 |
+
Author URI: http://www.codefleet.net/
|
9 |
+
License:
|
10 |
+
|
11 |
+
Copyright 2012 (kosinix@codefleet.net)
|
12 |
+
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License, version 2, as
|
15 |
+
published by the Free Software Foundation.
|
16 |
+
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with this program; if not, write to the Free Software
|
24 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
+
|
26 |
+
*/
|
27 |
+
require_once('inc/class-cyclone-slider.php');
|
28 |
+
require_once('inc/class-image-resizer.php');
|
29 |
+
|
30 |
+
if(!defined('CYCLONE_PATH')){
|
31 |
+
define('CYCLONE_PATH', realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR );
|
32 |
+
}
|
33 |
+
if(!defined('CYCLONE_URL')){
|
34 |
+
define('CYCLONE_URL', plugin_dir_url(__FILE__) );
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
if(class_exists('Cyclone_Slider')):
|
39 |
+
new Cyclone_Slider();
|
40 |
+
endif;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Thumbnailer
|
44 |
+
*
|
45 |
+
* Creates thumbnail of the slide image using the specified attachment ID, width and height
|
46 |
+
*
|
47 |
+
*
|
48 |
+
* @param int $original_attachment_id Attachment ID.
|
49 |
+
* @param int $width Width of thumbnail in pixels.
|
50 |
+
* @param int $height Height of thumbnail in pixels.
|
51 |
+
* @param bool $refresh Recreate thumbnail if it already exists if set to true. Default to false, will not recreate thumbnails if it already exist.
|
52 |
+
* @return string The url to the thumbnail. False on failure.
|
53 |
+
*/
|
54 |
+
//
|
55 |
+
function cycloneslider_thumb( $original_attachment_id, $width, $height, $refresh = false ){
|
56 |
+
$dir = wp_upload_dir();
|
57 |
+
|
58 |
+
// Get full path to the slide image
|
59 |
+
$image_path = get_attached_file($original_attachment_id);
|
60 |
+
if(empty($image_path)){
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
// Full url to the slide image
|
65 |
+
$image_url = wp_get_attachment_url($original_attachment_id);
|
66 |
+
if(empty($image_path)){
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
+
$info = pathinfo($image_path);
|
71 |
+
$dirname = isset($info['dirname']) ? $info['dirname'] : '';
|
72 |
+
$ext = isset($info['extension']) ? $info['extension'] : '';
|
73 |
+
$thumb = wp_basename($image_path, ".$ext")."-{$width}x{$height}.{$ext}";
|
74 |
+
|
75 |
+
// Check if thumb already exists. If it is, return its url, unless refresh is true
|
76 |
+
if(file_exists($dirname.'/'.$thumb ) and !$refresh){
|
77 |
+
return dirname($image_url).'/'.$thumb;
|
78 |
+
}
|
79 |
+
|
80 |
+
$resizeObj = new Image_Resizer($image_path);
|
81 |
+
$resizeObj -> resizeImage($width, $height);
|
82 |
+
$resizeObj -> saveImage($dirname.'/'.$thumb, 80);
|
83 |
+
|
84 |
+
return dirname($image_url).'/'.$thumb;
|
85 |
+
|
86 |
}
|
inc/class-cyclone-slider.php
CHANGED
@@ -1,689 +1,689 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('Cyclone_Slider')):
|
3 |
-
|
4 |
-
class Cyclone_Slider {
|
5 |
-
var $plugin_path;
|
6 |
-
var $plugin_url;
|
7 |
-
var $template_slide_box;
|
8 |
-
var $template_slide_box_js;
|
9 |
-
var $template_slider_dir;
|
10 |
-
var $slider_count;
|
11 |
-
var $effects;
|
12 |
-
/*--------------------------------------------*
|
13 |
-
* Constructor
|
14 |
-
*--------------------------------------------*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Initializes the plugin by setting localization, filters, and administration functions.
|
18 |
-
*/
|
19 |
-
function __construct() {
|
20 |
-
// Paths and urls init
|
21 |
-
$ds = DIRECTORY_SEPARATOR;
|
22 |
-
$this->plugin_path = CYCLONE_PATH;
|
23 |
-
$this->plugin_url = CYCLONE_URL;//url to plugin
|
24 |
-
$this->template_slide_box = $this->plugin_path . 'inc'.$ds.'admin'.$ds.'box.php';
|
25 |
-
$this->template_slide_box_js = $this->plugin_path . 'inc'.$ds.'admin'.$ds.'box-js.php';
|
26 |
-
$this->template_slider_dir = $this->plugin_path . 'templates'.$ds;
|
27 |
-
$this->slider_count = 0;
|
28 |
-
$this->effects = array(
|
29 |
-
'fade'=>'Fade',
|
30 |
-
'fadeout'=>'Fade Out',
|
31 |
-
'none'=>'None',
|
32 |
-
'scrollHorz'=>'Scroll Horizontally',
|
33 |
-
'tileBlind'=>'Tile Blind',
|
34 |
-
'tileSlide'=>'Tile Slide'
|
35 |
-
);
|
36 |
-
|
37 |
-
load_plugin_textdomain( 'cycloneslider', false, 'cyclone-slider-2/lang' );
|
38 |
-
|
39 |
-
// Register admin styles and scripts
|
40 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'register_admin_scripts' ), 10);
|
41 |
-
|
42 |
-
// Register frontend styles and scripts
|
43 |
-
add_action( 'wp_enqueue_scripts', array( &$this, 'register_plugin_scripts' ) );
|
44 |
-
|
45 |
-
|
46 |
-
// Add admin menus
|
47 |
-
add_action( 'init', array( &$this, 'create_post_types' ) );
|
48 |
-
|
49 |
-
// Update the messages for our custom post make it appropriate for slideshow
|
50 |
-
add_filter('post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
51 |
-
|
52 |
-
// Add slider metaboxes
|
53 |
-
add_action( 'add_meta_boxes', array( &$this, 'add_meta_boxes' ) );
|
54 |
-
|
55 |
-
// Save slides
|
56 |
-
add_action( 'save_post', array( &$this, 'save_post' ) );
|
57 |
-
|
58 |
-
// Hacky way to change text in thickbox
|
59 |
-
add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 10, 3 );
|
60 |
-
|
61 |
-
// Modify html of image
|
62 |
-
add_filter( 'image_send_to_editor', array( $this, 'image_send_to_editor'), 1, 8 );
|
63 |
-
|
64 |
-
// Custom columns
|
65 |
-
add_action( 'manage_cycloneslider_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
|
66 |
-
add_filter( 'manage_edit-cycloneslider_columns', array( $this, 'slideshow_columns') );
|
67 |
-
|
68 |
-
// Add hook for admin footer
|
69 |
-
add_action('admin_footer', array( $this, 'admin_footer') );
|
70 |
-
|
71 |
-
// Our shortcode
|
72 |
-
add_shortcode('cycloneslider', array( $this, 'cycloneslider_shortcode') );
|
73 |
-
|
74 |
-
// Add query var for so we can access our css via www.mysite.com/?cyclone_templates_css=1
|
75 |
-
add_filter('query_vars', array( $this, 'modify_query_vars'));
|
76 |
-
|
77 |
-
// The magic that shows our css
|
78 |
-
add_action('template_redirect', array( $this, 'cyclone_css_hook'));
|
79 |
-
} // end constructor
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Registers and enqueues admin-specific JavaScript.
|
83 |
-
*/
|
84 |
-
public function register_admin_scripts() {
|
85 |
-
if('cycloneslider' == get_post_type()){ /* Load only scripts here and not on all admin pages */
|
86 |
-
//styles
|
87 |
-
wp_enqueue_style('thickbox');
|
88 |
-
|
89 |
-
wp_register_style( 'cycloneslider-admin-styles', $this->plugin_url.'css/admin.css' );
|
90 |
-
wp_enqueue_style( 'cycloneslider-admin-styles' );
|
91 |
-
|
92 |
-
//scripts
|
93 |
-
wp_dequeue_script( 'autosave' );//disable autosave
|
94 |
-
|
95 |
-
wp_enqueue_script('jquery');
|
96 |
-
wp_enqueue_script('jquery-ui-sortable');
|
97 |
-
wp_enqueue_script('media-upload');
|
98 |
-
wp_enqueue_script('thickbox');
|
99 |
-
|
100 |
-
wp_register_script( 'jquery-cookie', $this->plugin_url.'js/jquery.cookie.js' );
|
101 |
-
wp_enqueue_script( 'jquery-cookie' );
|
102 |
-
wp_register_script( 'cycloneslider-admin-script', $this->plugin_url.'js/admin.js' );
|
103 |
-
wp_enqueue_script( 'cycloneslider-admin-script' );
|
104 |
-
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Registers and enqueues frontend-specific scripts.
|
110 |
-
*/
|
111 |
-
public function register_plugin_scripts() {
|
112 |
-
/*** Styles ***/
|
113 |
-
$cyclone_css = add_query_arg(array('cyclone_templates_css' => 1), home_url( '/' ));
|
114 |
-
wp_register_style( 'cyclone-slider-plugin-styles', $cyclone_css );//contains our combined css from ALL templates
|
115 |
-
wp_enqueue_style( 'cyclone-slider-plugin-styles' );
|
116 |
-
|
117 |
-
/*** Scripts ***/
|
118 |
-
wp_register_script( 'cycle2', $this->plugin_url.'js/jquery.cycle2.min.js', array('jquery') );
|
119 |
-
wp_enqueue_script( 'cycle2' );
|
120 |
-
|
121 |
-
wp_register_script( 'cycle2-tile', $this->plugin_url.'js/jquery.cycle2.tile.min.js', array('cycle2') );
|
122 |
-
wp_enqueue_script( 'cycle2-tile' );
|
123 |
-
|
124 |
-
wp_register_script( 'display', $this->plugin_url.'js/display.js', array('jquery') );
|
125 |
-
wp_enqueue_script( 'display' );
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
/*--------------------------------------------*
|
130 |
-
* Core Functions
|
131 |
-
*---------------------------------------------*/
|
132 |
-
// Create custom post for slideshows
|
133 |
-
function create_post_types() {
|
134 |
-
register_post_type( 'cycloneslider',
|
135 |
-
array(
|
136 |
-
'labels' => array(
|
137 |
-
'name' => __('Cyclone Slider', 'cycloneslider'),
|
138 |
-
'singular_name' => __('Slideshow', 'cycloneslider'),
|
139 |
-
'add_new' => __('Add Slideshow', 'cycloneslider'),
|
140 |
-
'add_new_item' => __('Add New Slideshow', 'cycloneslider'),
|
141 |
-
'edit_item' => __('Edit Slideshow', 'cycloneslider'),
|
142 |
-
'new_item' => __('New Slideshow', 'cycloneslider'),
|
143 |
-
'view_item' => __('View Slideshow', 'cycloneslider'),
|
144 |
-
'search_items' => __('Search Slideshows', 'cycloneslider'),
|
145 |
-
'not_found' => __('No slideshows found', 'cycloneslider'),
|
146 |
-
'not_found_in_trash' => __('No slideshows found in Trash', 'cycloneslider')
|
147 |
-
),
|
148 |
-
'supports' => array('title'),
|
149 |
-
'public' => false,
|
150 |
-
'exclude_from_search' => true,
|
151 |
-
'show_ui' => true,
|
152 |
-
'menu_position' => 100
|
153 |
-
)
|
154 |
-
);
|
155 |
-
}
|
156 |
-
|
157 |
-
// Messages
|
158 |
-
function post_updated_messages($messages){
|
159 |
-
global $post, $post_ID;
|
160 |
-
$messages['cycloneslider'] = array(
|
161 |
-
0 => '',
|
162 |
-
1 => sprintf( __( 'Slideshow updated. Shortcode is [cycloneslider id="%s"]', 'cycloneslider' ), $post->post_name),
|
163 |
-
2 => __( 'Custom field updated.', 'cycloneslider' ),
|
164 |
-
3 => __( 'Custom field deleted.', 'cycloneslider' ),
|
165 |
-
4 => __( 'Slideshow updated.', 'cycloneslider' ),
|
166 |
-
5 => __( 'Slideshow updated.', 'cycloneslider' ),
|
167 |
-
6 => sprintf( __( 'Slideshow published. Shortcode is [cycloneslider id="%s"]', 'cycloneslider' ), $post->post_name),
|
168 |
-
7 => __( 'Slideshow saved.', 'cycloneslider' ),
|
169 |
-
8 => __( 'Slideshow updated.', 'cycloneslider' ),
|
170 |
-
9 => __( 'Slideshow updated.', 'cycloneslider' ),
|
171 |
-
10 => __( 'Slideshow updated.', 'cycloneslider' )
|
172 |
-
);
|
173 |
-
return $messages;
|
174 |
-
}
|
175 |
-
|
176 |
-
// Slides metabox init
|
177 |
-
function add_meta_boxes(){
|
178 |
-
add_meta_box(
|
179 |
-
'cyclone-slides-metabox',
|
180 |
-
__('Slides', 'cycloneslider'),
|
181 |
-
array( &$this, 'render_slides_meta_box' ),
|
182 |
-
'cycloneslider' ,
|
183 |
-
'normal',
|
184 |
-
'high'
|
185 |
-
);
|
186 |
-
add_meta_box(
|
187 |
-
'cyclone-slider-properties-metabox',
|
188 |
-
__('Slider Settings', 'cycloneslider'),
|
189 |
-
array( &$this, 'render_slider_properties_meta_box' ),
|
190 |
-
'cycloneslider' ,
|
191 |
-
'side',
|
192 |
-
'low'
|
193 |
-
);
|
194 |
-
add_meta_box(
|
195 |
-
'cyclone-slider-templates-metabox',
|
196 |
-
__('Slider Templates', 'cycloneslider'),
|
197 |
-
array( &$this, 'render_slider_templates_meta_box' ),
|
198 |
-
'cycloneslider' ,
|
199 |
-
'normal',
|
200 |
-
'low'
|
201 |
-
);
|
202 |
-
}
|
203 |
-
|
204 |
-
// Get Image mime type. @param $image - full path to image
|
205 |
-
function get_mime_type( $image ){
|
206 |
-
if($properties = getimagesize( $image )){
|
207 |
-
return $properties['mime'];
|
208 |
-
}
|
209 |
-
return false;
|
210 |
-
}
|
211 |
-
|
212 |
-
// Slides metabox render
|
213 |
-
function render_slides_meta_box($post){
|
214 |
-
|
215 |
-
// Use nonce for verification
|
216 |
-
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
217 |
-
|
218 |
-
$meta = get_post_custom($post->ID);
|
219 |
-
|
220 |
-
$slider_metas = $this->get_slider_metas($meta);
|
221 |
-
$slider_settings = $this->get_slider_admin_settings($meta);
|
222 |
-
|
223 |
-
$debug = 0;
|
224 |
-
if($debug){
|
225 |
-
echo '<pre>';
|
226 |
-
print_r($slider_settings);
|
227 |
-
print_r($slider_metas);
|
228 |
-
echo '</pre>';
|
229 |
-
}
|
230 |
-
?>
|
231 |
-
<div class="cycloneslider-sortable">
|
232 |
-
<?php
|
233 |
-
if(is_array($slider_metas) and count($slider_metas)>0):
|
234 |
-
foreach($slider_metas as $i=>$slider_meta):
|
235 |
-
$attachment_id = (int) $slider_meta['id'];
|
236 |
-
$image_url = wp_get_attachment_image_src( $attachment_id, 'medium', true );
|
237 |
-
$image_url = (is_array($image_url)) ? $image_url[0] : '';
|
238 |
-
|
239 |
-
include($this->template_slide_box);
|
240 |
-
endforeach;
|
241 |
-
endif;
|
242 |
-
?>
|
243 |
-
</div><!-- end .cycloneslider-sortable -->
|
244 |
-
|
245 |
-
<input type="button" value="<?php _e('Add Slide', 'cycloneslider'); ?>" class="button-secondary" name="cycloneslider_add_slide" />
|
246 |
-
<?php
|
247 |
-
}
|
248 |
-
|
249 |
-
function render_slider_properties_meta_box($post){
|
250 |
-
// Use nonce for verification
|
251 |
-
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
252 |
-
|
253 |
-
$meta = get_post_custom($post->ID);
|
254 |
-
$slider_settings = $this->get_slider_admin_settings($meta);
|
255 |
-
//default values
|
256 |
-
$slider_settings['timeout'] = (!isset($slider_settings['timeout']) || $slider_settings['timeout']===null) ? 4000 : $slider_settings['timeout'];
|
257 |
-
$slider_settings['speed'] = (!isset($slider_settings['speed']) || $slider_settings['speed']===null) ? 1000 : $slider_settings['speed'];
|
258 |
-
$slider_settings['width'] = (!isset($slider_settings['width']) || $slider_settings['width']===null) ? 960 : $slider_settings['width'];
|
259 |
-
$slider_settings['height'] = (!isset($slider_settings['height']) || $slider_settings['height']===null) ? 300 : $slider_settings['height'];
|
260 |
-
$slider_settings['show_prev_next'] = (!isset($slider_settings['show_prev_next']) || $slider_settings['show_prev_next']===null) ? 1 : $slider_settings['show_prev_next'];
|
261 |
-
$slider_settings['show_nav'] = (!isset($slider_settings['show_nav']) || $slider_settings['show_nav']===null) ? 1 : $slider_settings['show_nav'];
|
262 |
-
$slider_settings['hover_pause'] = (!isset($slider_settings['hover_pause']) || $slider_settings['hover_pause']===null) ? 1 : $slider_settings['hover_pause'];
|
263 |
-
|
264 |
-
?>
|
265 |
-
<div class="cycloneslider-field">
|
266 |
-
<label for="cycloneslider_settings_fx"><?php _e('Transition Effects to Use:', 'cycloneslider'); ?></label>
|
267 |
-
<select id="cycloneslider_settings_fx" name="cycloneslider_settings[fx]">
|
268 |
-
<?php foreach($this->effects as $key=>$fx): ?>
|
269 |
-
<option <?php echo (isset($slider_settings['fx']) && $key==$slider_settings['fx']) ? 'selected="selected"' : ''; ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($fx); ?></option>
|
270 |
-
<?php endforeach; ?>
|
271 |
-
</select>
|
272 |
-
<div class="clear"></div>
|
273 |
-
</div>
|
274 |
-
<?php
|
275 |
-
?>
|
276 |
-
<div class="cycloneslider-field">
|
277 |
-
<label for="cycloneslider_settings_timeout"><?php _e('Next Slide Delay:', 'cycloneslider'); ?> </label>
|
278 |
-
<input id="cycloneslider_settings_timeout" type="text" name="cycloneslider_settings[timeout]" value="<?php echo esc_attr($slider_settings['timeout']); ?>" />
|
279 |
-
<span class="note"><?php _e('Milliseconds. 0 to disable auto advance.', 'cycloneslider'); ?></span>
|
280 |
-
<div class="clear"></div>
|
281 |
-
</div>
|
282 |
-
<div class="cycloneslider-field">
|
283 |
-
<label for="cycloneslider_settings_speed"><?php _e('Transition Effects Speed:', 'cycloneslider'); ?></label>
|
284 |
-
<input id="cycloneslider_settings_speed" type="text" name="cycloneslider_settings[speed]" value="<?php echo esc_attr($slider_settings['speed']); ?>" />
|
285 |
-
<span class="note"><?php _e('Milliseconds', 'cycloneslider'); ?></span>
|
286 |
-
<div class="clear"></div>
|
287 |
-
</div>
|
288 |
-
<div class="cycloneslider-field">
|
289 |
-
<label for="cycloneslider_settings_width"><?php _e('Width:', 'cycloneslider'); ?> </label>
|
290 |
-
<input id="cycloneslider_settings_width" type="text" name="cycloneslider_settings[width]" value="<?php echo esc_attr($slider_settings['width']); ?>" />
|
291 |
-
<span class="note"><?php _e('pixels.', 'cycloneslider'); ?></span>
|
292 |
-
<div class="clear"></div>
|
293 |
-
</div>
|
294 |
-
<div class="cycloneslider-field">
|
295 |
-
<label for="cycloneslider_settings_height"><?php _e('Height:', 'cycloneslider'); ?> </label>
|
296 |
-
<input id="cycloneslider_settings_height" type="text" name="cycloneslider_settings[height]" value="<?php echo esc_attr($slider_settings['height']); ?>" />
|
297 |
-
<span class="note"><?php _e('pixels.', 'cycloneslider'); ?></span>
|
298 |
-
<div class="clear"></div>
|
299 |
-
</div>
|
300 |
-
<div class="cycloneslider-field">
|
301 |
-
<label for="cycloneslider_settings_hover_pause"><?php _e('Pause on Hover?', 'cycloneslider'); ?></label>
|
302 |
-
<select id="cycloneslider_settings_hover_pause" name="cycloneslider_settings[hover_pause]">
|
303 |
-
<option <?php echo (
|
304 |
-
<option <?php echo (
|
305 |
-
</select>
|
306 |
-
<div class="clear"></div>
|
307 |
-
</div>
|
308 |
-
<div class="cycloneslider-field">
|
309 |
-
<label for="cycloneslider_settings_show_prev_next"><?php _e('Show Prev/Next Buttons?', 'cycloneslider'); ?></label>
|
310 |
-
<select id="cycloneslider_settings_show_prev_next" name="cycloneslider_settings[show_prev_next]">
|
311 |
-
<option <?php echo (1==$slider_settings['show_prev_next']) ? 'selected="selected"' : ''; ?> value="1"><?php _e('Yes', 'cycloneslider'); ?></option>
|
312 |
-
<option <?php echo (0==$slider_settings['show_prev_next']) ? 'selected="selected"' : ''; ?> value="0"><?php _e('No', 'cycloneslider'); ?></option>
|
313 |
-
</select>
|
314 |
-
<div class="clear"></div>
|
315 |
-
</div>
|
316 |
-
<div class="cycloneslider-field last">
|
317 |
-
<label for="cycloneslider_settings_show_nav"><?php _e('Show Navigation?', 'cycloneslider'); ?></label>
|
318 |
-
<select id="cycloneslider_settings_show_nav" name="cycloneslider_settings[show_nav]">
|
319 |
-
<option <?php echo (1==$slider_settings['show_nav']) ? 'selected="selected"' : ''; ?> value="1"><?php _e('Yes', 'cycloneslider'); ?></option>
|
320 |
-
<option <?php echo (0==$slider_settings['show_nav']) ? 'selected="selected"' : ''; ?> value="0"><?php _e('No', 'cycloneslider'); ?></option>
|
321 |
-
</select>
|
322 |
-
<div class="clear"></div>
|
323 |
-
</div>
|
324 |
-
<?php
|
325 |
-
}
|
326 |
-
|
327 |
-
function render_slider_templates_meta_box($post){
|
328 |
-
// Use nonce for verification
|
329 |
-
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
330 |
-
|
331 |
-
$meta = get_post_custom($post->ID);
|
332 |
-
$slider_settings = $this->get_slider_admin_settings($meta);
|
333 |
-
//default values
|
334 |
-
$slider_settings['template'] = ($slider_settings['template']===null) ? 'default' : $slider_settings['template'];
|
335 |
-
|
336 |
-
$templates = $this->get_all_templates();
|
337 |
-
$template_options = array();
|
338 |
-
$template_options['default'] = 'Default';
|
339 |
-
foreach($templates as $name=>$template){
|
340 |
-
if($name!='default'){
|
341 |
-
$template_options[$name]= ucwords(str_replace('-',' ',$name));
|
342 |
-
}
|
343 |
-
}
|
344 |
-
?>
|
345 |
-
<div class="cycloneslider-field last">
|
346 |
-
<label for="cycloneslider_settings_template"><?php _e('Select Template to Use:', 'cycloneslider'); ?></label>
|
347 |
-
<select id="cycloneslider_settings_template" name="cycloneslider_settings[template]">
|
348 |
-
<?php foreach($template_options as $key=>$name): ?>
|
349 |
-
<option <?php echo ($key==$slider_settings['template']) ? 'selected="selected"' : ''; ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($name); ?></option>
|
350 |
-
<?php endforeach; ?>
|
351 |
-
</select>
|
352 |
-
<div class="clear"></div>
|
353 |
-
</div>
|
354 |
-
<?php
|
355 |
-
}
|
356 |
-
|
357 |
-
function save_post($post_id){
|
358 |
-
|
359 |
-
// verify nonce
|
360 |
-
if (!empty($_POST['cycloneslider_metabox_nonce'])) {
|
361 |
-
if (!wp_verify_nonce($_POST['cycloneslider_metabox_nonce'], basename(__FILE__))) {
|
362 |
-
return $post_id;
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
// check autosave
|
367 |
-
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
368 |
-
return $post_id;
|
369 |
-
}
|
370 |
-
|
371 |
-
//slide metas
|
372 |
-
$this->save_metas($post_id);
|
373 |
-
|
374 |
-
//settings
|
375 |
-
$this->save_settings($post_id);
|
376 |
-
|
377 |
-
remove_action( 'save_post', array( &$this, 'save_post' ) );
|
378 |
-
}
|
379 |
-
|
380 |
-
//sanitize and save
|
381 |
-
function save_metas($post_id){
|
382 |
-
|
383 |
-
if(isset($_POST['cycloneslider_metas'])){
|
384 |
-
|
385 |
-
$slides = array();
|
386 |
-
$i=0;//always start from 0
|
387 |
-
foreach($_POST['cycloneslider_metas'] as $slide){
|
388 |
-
//bord($i.' '.$slide['fx']);
|
389 |
-
$slides[$i]['id'] = (int) $slide['id'];
|
390 |
-
$slides[$i]['link'] = esc_url_raw($slide['link']);
|
391 |
-
$slides[$i]['title'] = sanitize_text_field($slide['title']);
|
392 |
-
$slides[$i]['description'] = wp_kses_post($slide['description']);
|
393 |
-
$slides[$i]['link_target'] = wp_kses_post($slide['link_target']);
|
394 |
-
$slides[$i]['fx'] = wp_kses_post($slide['fx']);
|
395 |
-
$slides[$i]['speed'] = sanitize_text_field($slide['speed']);
|
396 |
-
$slides[$i]['timeout'] = sanitize_text_field($slide['timeout']);
|
397 |
-
$i++;
|
398 |
-
}
|
399 |
-
delete_post_meta($post_id, '_cycloneslider_metas');
|
400 |
-
update_post_meta($post_id, '_cycloneslider_metas', $slides);
|
401 |
-
}
|
402 |
-
}
|
403 |
-
|
404 |
-
//sanitize and save
|
405 |
-
function save_settings($post_id){
|
406 |
-
if(isset($_POST['cycloneslider_settings'])){
|
407 |
-
$settings = array();
|
408 |
-
$settings['template'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['template']);
|
409 |
-
$settings['fx'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['fx']);
|
410 |
-
$settings['timeout'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['timeout']);
|
411 |
-
$settings['speed'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['speed']);
|
412 |
-
$settings['width'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['width']);
|
413 |
-
$settings['height'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['height']);
|
414 |
-
$settings['hover_pause'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['hover_pause']);
|
415 |
-
$settings['show_prev_next'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['show_prev_next']);
|
416 |
-
$settings['show_nav'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['show_nav']);
|
417 |
-
|
418 |
-
delete_post_meta($post_id, '_cycloneslider_settings');
|
419 |
-
update_post_meta($post_id, '_cycloneslider_settings', $settings);
|
420 |
-
}
|
421 |
-
}
|
422 |
-
|
423 |
-
function replace_text_in_thickbox($translation, $text, $domain ) {
|
424 |
-
$http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
425 |
-
$req_referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
|
426 |
-
if(strpos($http_referrer, 'cycloneslider')!==false or $req_referrer=='cycloneslider') {
|
427 |
-
if ( 'default' == $domain and 'Insert into Post' == $text )
|
428 |
-
{
|
429 |
-
return 'Add to Slide';
|
430 |
-
}
|
431 |
-
}
|
432 |
-
return $translation;
|
433 |
-
}
|
434 |
-
|
435 |
-
// Add attachment ID as html5 data attr in thickbox
|
436 |
-
function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ){
|
437 |
-
if(strpos($html, '<img data-id="')===false){
|
438 |
-
$html = str_replace('<img', '<img data-id="'.$id.'" ', $html);
|
439 |
-
}
|
440 |
-
return $html;
|
441 |
-
}
|
442 |
-
|
443 |
-
// Modify columns
|
444 |
-
function slideshow_columns($columns) {
|
445 |
-
$columns = array();
|
446 |
-
$columns['title']= __('Slideshow Name', 'cycloneslider');
|
447 |
-
$columns['id']= __('Slideshow ID', 'cycloneslider');
|
448 |
-
$columns['shortcode']= __('Shortcode', 'cycloneslider');
|
449 |
-
return $columns;
|
450 |
-
}
|
451 |
-
|
452 |
-
// Add content to custom columns
|
453 |
-
function custom_column( $column_name, $post_id ){
|
454 |
-
if ($column_name == 'id') {
|
455 |
-
$post = get_post($post_id);
|
456 |
-
echo $post->post_name;
|
457 |
-
}
|
458 |
-
if ($column_name == 'shortcode') {
|
459 |
-
$post = get_post($post_id);
|
460 |
-
echo '[cycloneslider id="'.$post->post_name.'"]';
|
461 |
-
}
|
462 |
-
}
|
463 |
-
|
464 |
-
// For js adding of box
|
465 |
-
function admin_footer() {
|
466 |
-
if(get_post_type()=='cycloneslider'){
|
467 |
-
?>
|
468 |
-
<div class="cycloneslider-box-template">
|
469 |
-
<?php
|
470 |
-
include_once($this->template_slide_box_js);
|
471 |
-
?>
|
472 |
-
</div><!-- end .cycloneslider-box-template -->
|
473 |
-
<?php
|
474 |
-
}
|
475 |
-
}
|
476 |
-
|
477 |
-
// Compare the value from admin and shortcode. If shortcode value is present and not empty, use it, otherwise return admin value
|
478 |
-
function get_comp_slider_setting($admin_val, $shortcode_val){
|
479 |
-
if($shortcode_val!==null){//make sure its really null and not just int zero 0
|
480 |
-
return $shortcode_val;
|
481 |
-
}
|
482 |
-
return $admin_val;
|
483 |
-
}
|
484 |
-
|
485 |
-
/* Our shortcode function.
|
486 |
-
Slider settings comes from both admin settings and shortcode attributes.
|
487 |
-
Shortcode attributes, if present, will override the admin settings.
|
488 |
-
*/
|
489 |
-
function cycloneslider_shortcode($shortcode_settings) {
|
490 |
-
// Process shortcode settings and return only allowed vars
|
491 |
-
$shortcode_settings = shortcode_atts(
|
492 |
-
array(
|
493 |
-
'id' => 0,
|
494 |
-
'template' => null,
|
495 |
-
'fx' => null,
|
496 |
-
'speed' => null,
|
497 |
-
'timeout' => null,
|
498 |
-
'width' => null,
|
499 |
-
'height' => null,
|
500 |
-
'hover_pause' => null,
|
501 |
-
'show_prev_next' => null,
|
502 |
-
'show_nav' => null
|
503 |
-
),
|
504 |
-
$shortcode_settings
|
505 |
-
);
|
506 |
-
$slider_id = esc_attr($shortcode_settings['id']);
|
507 |
-
|
508 |
-
$cycle_options = array();
|
509 |
-
$this->slider_count++;//make each call to shortcode unique
|
510 |
-
// Get slideshow by id
|
511 |
-
$my_query = new WP_Query(
|
512 |
-
array(
|
513 |
-
'post_type' => 'cycloneslider',
|
514 |
-
'order'=>'ASC',
|
515 |
-
'posts_per_page' => 1,
|
516 |
-
'name'=> $slider_id
|
517 |
-
)
|
518 |
-
);
|
519 |
-
if($my_query->have_posts()):
|
520 |
-
while ( $my_query->have_posts() ) : $my_query->the_post();
|
521 |
-
|
522 |
-
$meta = get_post_custom();
|
523 |
-
|
524 |
-
$admin_settings = $this->get_slider_admin_settings($meta);
|
525 |
-
$slider_metas = $this->get_slider_metas($meta);
|
526 |
-
$slides = $this->get_slides_from_meta($slider_metas);
|
527 |
-
|
528 |
-
$template = $this->get_comp_slider_setting($admin_settings['template'], $shortcode_settings['template']);
|
529 |
-
$template = esc_attr($template===null ? 'default' : $template);//fallback to default
|
530 |
-
$slider_settings['fx'] = esc_attr($this->get_comp_slider_setting($admin_settings['fx'], $shortcode_settings['fx']));
|
531 |
-
$slider_settings['speed'] = (int) $this->get_comp_slider_setting($admin_settings['speed'], $shortcode_settings['speed']);
|
532 |
-
$slider_settings['timeout'] = (int) $this->get_comp_slider_setting($admin_settings['timeout'], $shortcode_settings['timeout']);
|
533 |
-
$slider_settings['width'] = (int) $this->get_comp_slider_setting($admin_settings['width'], $shortcode_settings['width']);
|
534 |
-
$slider_settings['height'] = (int) $this->get_comp_slider_setting($admin_settings['height'], $shortcode_settings['height']);
|
535 |
-
$slider_settings['hover_pause'] =
|
536 |
-
$slider_settings['show_prev_next'] = (int) $this->get_comp_slider_setting($admin_settings['show_prev_next'], $shortcode_settings['show_prev_next']);
|
537 |
-
$slider_settings['show_nav'] = (int) $this->get_comp_slider_setting($admin_settings['show_nav'], $shortcode_settings['show_nav']);
|
538 |
-
|
539 |
-
$slider = $this->get_slider_template($slider_id, $template, $slides, $slider_metas, $slider_settings, $this->slider_count);
|
540 |
-
|
541 |
-
endwhile;
|
542 |
-
|
543 |
-
wp_reset_postdata();
|
544 |
-
|
545 |
-
else:
|
546 |
-
$slider = __('[Slideshow not found]', 'cycloneslider');
|
547 |
-
endif;
|
548 |
-
|
549 |
-
return $slider;
|
550 |
-
}
|
551 |
-
|
552 |
-
// Process the post meta and return the settings
|
553 |
-
function get_slider_admin_settings($meta){
|
554 |
-
if(isset($meta['cycloneslider_settings'][0]) and !empty($meta['cycloneslider_settings'][0])){//from version 1.0.0. set for deletion in future releases
|
555 |
-
return maybe_unserialize($meta['cycloneslider_settings'][0]);
|
556 |
-
}
|
557 |
-
if(isset($meta['_cycloneslider_settings'][0]) and !empty($meta['_cycloneslider_settings'][0])){//we have added prefix _ since 1.0.2
|
558 |
-
return maybe_unserialize($meta['_cycloneslider_settings'][0]);
|
559 |
-
}
|
560 |
-
return false;
|
561 |
-
}
|
562 |
-
|
563 |
-
// Process the post meta and return the settings
|
564 |
-
function get_slider_metas($meta){
|
565 |
-
if(isset($meta['cycloneslider_metas'][0]) and !empty($meta['cycloneslider_metas'][0])){//from version 1.0.0. set for deletion in future releases
|
566 |
-
return maybe_unserialize($meta['cycloneslider_metas'][0]);
|
567 |
-
}
|
568 |
-
if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){//we have added prefix _ since 1.0.2
|
569 |
-
return maybe_unserialize($meta['_cycloneslider_metas'][0]);
|
570 |
-
}
|
571 |
-
return false;
|
572 |
-
}
|
573 |
-
|
574 |
-
// Get slideshow template
|
575 |
-
function get_slider_template($slider_id, $template_name, $slides, $slider_metas, $slider_settings, $slider_count){
|
576 |
-
|
577 |
-
$template = get_stylesheet_directory()."/cycloneslider/{$template_name}/slider.php";
|
578 |
-
if(@is_file($template)){
|
579 |
-
ob_start();
|
580 |
-
include($template);
|
581 |
-
$html = ob_get_clean();
|
582 |
-
return $html = $this->trim_white_spaces($html);
|
583 |
-
}
|
584 |
-
|
585 |
-
$template = $this->template_slider_dir."{$template_name}/slider.php";
|
586 |
-
if(@is_file($template)) {
|
587 |
-
ob_start();
|
588 |
-
include($template);
|
589 |
-
$html = ob_get_clean();
|
590 |
-
return $html = $this->trim_white_spaces($html);
|
591 |
-
}
|
592 |
-
|
593 |
-
return sprintf(__('[Template "%s" not found]', 'cycloneslider'), $template_name);
|
594 |
-
}
|
595 |
-
|
596 |
-
function trim_white_spaces($buffer){
|
597 |
-
$search = array(
|
598 |
-
'/\>[^\S ]+/s', //strip whitespaces after tags, except space
|
599 |
-
'/[^\S ]+\</s', //strip whitespaces before tags, except space
|
600 |
-
'/(\s)+/s' // shorten multiple whitespace sequences
|
601 |
-
);
|
602 |
-
$replace = array(
|
603 |
-
'>',
|
604 |
-
'<',
|
605 |
-
'\\1'
|
606 |
-
);
|
607 |
-
return preg_replace($search, $replace, $buffer);
|
608 |
-
}
|
609 |
-
|
610 |
-
// Return array of slide urls from meta
|
611 |
-
function get_slides_from_meta($slider_metas){
|
612 |
-
$slides = array();
|
613 |
-
if(is_array($slider_metas)){
|
614 |
-
foreach($slider_metas as $slider_meta){
|
615 |
-
$attachment_id = (int) $slider_meta['id'];
|
616 |
-
$image_url = wp_get_attachment_url($attachment_id);
|
617 |
-
$image_url = ($image_url===false) ? '' : $image_url;
|
618 |
-
$slides[] = $image_url;
|
619 |
-
}
|
620 |
-
}
|
621 |
-
return $slides;
|
622 |
-
}
|
623 |
-
|
624 |
-
// Add custom query var
|
625 |
-
function modify_query_vars($vars) {
|
626 |
-
$vars[] = 'cyclone_templates_css';//add our own
|
627 |
-
return $vars;
|
628 |
-
}
|
629 |
-
|
630 |
-
// Hook to template redirect
|
631 |
-
function cyclone_css_hook() {
|
632 |
-
if(intval(get_query_var('cyclone_templates_css')) == 1) {
|
633 |
-
$ds = DIRECTORY_SEPARATOR;
|
634 |
-
header("Content-type: text/css");
|
635 |
-
|
636 |
-
if(file_exists($this->plugin_path."css{$ds}common.css")){
|
637 |
-
echo file_get_contents($this->plugin_path."css{$ds}common.css");
|
638 |
-
}
|
639 |
-
|
640 |
-
$template_folders = $this->get_all_templates();
|
641 |
-
foreach($template_folders as $name=>$folder){
|
642 |
-
$style = $folder['path']."{$ds}style.css";
|
643 |
-
if(file_exists($style)){
|
644 |
-
echo "\n".str_replace('$tpl', $folder['url'], file_get_contents($style));//apply url and print css
|
645 |
-
}
|
646 |
-
}
|
647 |
-
die();
|
648 |
-
}
|
649 |
-
}
|
650 |
-
|
651 |
-
// Get all template locations. Returns array of locations containing path and url
|
652 |
-
function get_all_locations(){
|
653 |
-
$ds = DIRECTORY_SEPARATOR;
|
654 |
-
$template_locations = array();
|
655 |
-
$template_locations[0] = array(
|
656 |
-
'path'=>$this->template_slider_dir, //this resides in the plugin
|
657 |
-
'url'=>$this->plugin_url.'templates/'
|
658 |
-
);
|
659 |
-
$template_locations[1] = array(
|
660 |
-
'path'=> realpath(get_stylesheet_directory())."{$ds}cycloneslider{$ds}",//this resides in the current theme or child theme
|
661 |
-
'url'=> get_stylesheet_directory_uri()."/cycloneslider/"
|
662 |
-
);
|
663 |
-
return $template_locations;
|
664 |
-
}
|
665 |
-
|
666 |
-
// Get all templates from all locations. Returns array of templates with keys as name containing array of path and url
|
667 |
-
function get_all_templates(){
|
668 |
-
$template_locations = $this->get_all_locations();
|
669 |
-
$template_folders = array();
|
670 |
-
foreach($template_locations as $location){
|
671 |
-
if($files = @scandir($location['path'])){
|
672 |
-
$c = 0;
|
673 |
-
foreach($files as $name){
|
674 |
-
if($name!='.' and $name!='..' and is_dir($location['path'].$name)){
|
675 |
-
$name = sanitize_title($name);//change space to dash and all lowercase
|
676 |
-
$template_folders[$name] = array( //here we override template of the same names. templates inside themes take precedence
|
677 |
-
'path'=>$location['path'].$name,
|
678 |
-
'url'=>$location['url'].$name,
|
679 |
-
);
|
680 |
-
}
|
681 |
-
}
|
682 |
-
}
|
683 |
-
}
|
684 |
-
return $template_folders;
|
685 |
-
}
|
686 |
-
|
687 |
-
} // end class
|
688 |
-
|
689 |
endif;
|
1 |
+
<?php
|
2 |
+
if(!class_exists('Cyclone_Slider')):
|
3 |
+
|
4 |
+
class Cyclone_Slider {
|
5 |
+
var $plugin_path;
|
6 |
+
var $plugin_url;
|
7 |
+
var $template_slide_box;
|
8 |
+
var $template_slide_box_js;
|
9 |
+
var $template_slider_dir;
|
10 |
+
var $slider_count;
|
11 |
+
var $effects;
|
12 |
+
/*--------------------------------------------*
|
13 |
+
* Constructor
|
14 |
+
*--------------------------------------------*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Initializes the plugin by setting localization, filters, and administration functions.
|
18 |
+
*/
|
19 |
+
function __construct() {
|
20 |
+
// Paths and urls init
|
21 |
+
$ds = DIRECTORY_SEPARATOR;
|
22 |
+
$this->plugin_path = CYCLONE_PATH;
|
23 |
+
$this->plugin_url = CYCLONE_URL;//url to plugin
|
24 |
+
$this->template_slide_box = $this->plugin_path . 'inc'.$ds.'admin'.$ds.'box.php';
|
25 |
+
$this->template_slide_box_js = $this->plugin_path . 'inc'.$ds.'admin'.$ds.'box-js.php';
|
26 |
+
$this->template_slider_dir = $this->plugin_path . 'templates'.$ds;
|
27 |
+
$this->slider_count = 0;
|
28 |
+
$this->effects = array(
|
29 |
+
'fade'=>'Fade',
|
30 |
+
'fadeout'=>'Fade Out',
|
31 |
+
'none'=>'None',
|
32 |
+
'scrollHorz'=>'Scroll Horizontally',
|
33 |
+
'tileBlind'=>'Tile Blind',
|
34 |
+
'tileSlide'=>'Tile Slide'
|
35 |
+
);
|
36 |
+
|
37 |
+
load_plugin_textdomain( 'cycloneslider', false, 'cyclone-slider-2/lang' );
|
38 |
+
|
39 |
+
// Register admin styles and scripts
|
40 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'register_admin_scripts' ), 10);
|
41 |
+
|
42 |
+
// Register frontend styles and scripts
|
43 |
+
add_action( 'wp_enqueue_scripts', array( &$this, 'register_plugin_scripts' ) );
|
44 |
+
|
45 |
+
|
46 |
+
// Add admin menus
|
47 |
+
add_action( 'init', array( &$this, 'create_post_types' ) );
|
48 |
+
|
49 |
+
// Update the messages for our custom post make it appropriate for slideshow
|
50 |
+
add_filter('post_updated_messages', array( &$this, 'post_updated_messages' ) );
|
51 |
+
|
52 |
+
// Add slider metaboxes
|
53 |
+
add_action( 'add_meta_boxes', array( &$this, 'add_meta_boxes' ) );
|
54 |
+
|
55 |
+
// Save slides
|
56 |
+
add_action( 'save_post', array( &$this, 'save_post' ) );
|
57 |
+
|
58 |
+
// Hacky way to change text in thickbox
|
59 |
+
add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 10, 3 );
|
60 |
+
|
61 |
+
// Modify html of image
|
62 |
+
add_filter( 'image_send_to_editor', array( $this, 'image_send_to_editor'), 1, 8 );
|
63 |
+
|
64 |
+
// Custom columns
|
65 |
+
add_action( 'manage_cycloneslider_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
|
66 |
+
add_filter( 'manage_edit-cycloneslider_columns', array( $this, 'slideshow_columns') );
|
67 |
+
|
68 |
+
// Add hook for admin footer
|
69 |
+
add_action('admin_footer', array( $this, 'admin_footer') );
|
70 |
+
|
71 |
+
// Our shortcode
|
72 |
+
add_shortcode('cycloneslider', array( $this, 'cycloneslider_shortcode') );
|
73 |
+
|
74 |
+
// Add query var for so we can access our css via www.mysite.com/?cyclone_templates_css=1
|
75 |
+
add_filter('query_vars', array( $this, 'modify_query_vars'));
|
76 |
+
|
77 |
+
// The magic that shows our css
|
78 |
+
add_action('template_redirect', array( $this, 'cyclone_css_hook'));
|
79 |
+
} // end constructor
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Registers and enqueues admin-specific JavaScript.
|
83 |
+
*/
|
84 |
+
public function register_admin_scripts() {
|
85 |
+
if('cycloneslider' == get_post_type()){ /* Load only scripts here and not on all admin pages */
|
86 |
+
//styles
|
87 |
+
wp_enqueue_style('thickbox');
|
88 |
+
|
89 |
+
wp_register_style( 'cycloneslider-admin-styles', $this->plugin_url.'css/admin.css' );
|
90 |
+
wp_enqueue_style( 'cycloneslider-admin-styles' );
|
91 |
+
|
92 |
+
//scripts
|
93 |
+
wp_dequeue_script( 'autosave' );//disable autosave
|
94 |
+
|
95 |
+
wp_enqueue_script('jquery');
|
96 |
+
wp_enqueue_script('jquery-ui-sortable');
|
97 |
+
wp_enqueue_script('media-upload');
|
98 |
+
wp_enqueue_script('thickbox');
|
99 |
+
|
100 |
+
wp_register_script( 'jquery-cookie', $this->plugin_url.'js/jquery.cookie.js' );
|
101 |
+
wp_enqueue_script( 'jquery-cookie' );
|
102 |
+
wp_register_script( 'cycloneslider-admin-script', $this->plugin_url.'js/admin.js' );
|
103 |
+
wp_enqueue_script( 'cycloneslider-admin-script' );
|
104 |
+
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Registers and enqueues frontend-specific scripts.
|
110 |
+
*/
|
111 |
+
public function register_plugin_scripts() {
|
112 |
+
/*** Styles ***/
|
113 |
+
$cyclone_css = add_query_arg(array('cyclone_templates_css' => 1), home_url( '/' ));
|
114 |
+
wp_register_style( 'cyclone-slider-plugin-styles', $cyclone_css );//contains our combined css from ALL templates
|
115 |
+
wp_enqueue_style( 'cyclone-slider-plugin-styles' );
|
116 |
+
|
117 |
+
/*** Scripts ***/
|
118 |
+
wp_register_script( 'cycle2', $this->plugin_url.'js/jquery.cycle2.min.js', array('jquery') );
|
119 |
+
wp_enqueue_script( 'cycle2' );
|
120 |
+
|
121 |
+
wp_register_script( 'cycle2-tile', $this->plugin_url.'js/jquery.cycle2.tile.min.js', array('cycle2') );
|
122 |
+
wp_enqueue_script( 'cycle2-tile' );
|
123 |
+
|
124 |
+
wp_register_script( 'display', $this->plugin_url.'js/display.js', array('jquery') );
|
125 |
+
wp_enqueue_script( 'display' );
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/*--------------------------------------------*
|
130 |
+
* Core Functions
|
131 |
+
*---------------------------------------------*/
|
132 |
+
// Create custom post for slideshows
|
133 |
+
function create_post_types() {
|
134 |
+
register_post_type( 'cycloneslider',
|
135 |
+
array(
|
136 |
+
'labels' => array(
|
137 |
+
'name' => __('Cyclone Slider', 'cycloneslider'),
|
138 |
+
'singular_name' => __('Slideshow', 'cycloneslider'),
|
139 |
+
'add_new' => __('Add Slideshow', 'cycloneslider'),
|
140 |
+
'add_new_item' => __('Add New Slideshow', 'cycloneslider'),
|
141 |
+
'edit_item' => __('Edit Slideshow', 'cycloneslider'),
|
142 |
+
'new_item' => __('New Slideshow', 'cycloneslider'),
|
143 |
+
'view_item' => __('View Slideshow', 'cycloneslider'),
|
144 |
+
'search_items' => __('Search Slideshows', 'cycloneslider'),
|
145 |
+
'not_found' => __('No slideshows found', 'cycloneslider'),
|
146 |
+
'not_found_in_trash' => __('No slideshows found in Trash', 'cycloneslider')
|
147 |
+
),
|
148 |
+
'supports' => array('title'),
|
149 |
+
'public' => false,
|
150 |
+
'exclude_from_search' => true,
|
151 |
+
'show_ui' => true,
|
152 |
+
'menu_position' => 100
|
153 |
+
)
|
154 |
+
);
|
155 |
+
}
|
156 |
+
|
157 |
+
// Messages
|
158 |
+
function post_updated_messages($messages){
|
159 |
+
global $post, $post_ID;
|
160 |
+
$messages['cycloneslider'] = array(
|
161 |
+
0 => '',
|
162 |
+
1 => sprintf( __( 'Slideshow updated. Shortcode is [cycloneslider id="%s"]', 'cycloneslider' ), $post->post_name),
|
163 |
+
2 => __( 'Custom field updated.', 'cycloneslider' ),
|
164 |
+
3 => __( 'Custom field deleted.', 'cycloneslider' ),
|
165 |
+
4 => __( 'Slideshow updated.', 'cycloneslider' ),
|
166 |
+
5 => __( 'Slideshow updated.', 'cycloneslider' ),
|
167 |
+
6 => sprintf( __( 'Slideshow published. Shortcode is [cycloneslider id="%s"]', 'cycloneslider' ), $post->post_name),
|
168 |
+
7 => __( 'Slideshow saved.', 'cycloneslider' ),
|
169 |
+
8 => __( 'Slideshow updated.', 'cycloneslider' ),
|
170 |
+
9 => __( 'Slideshow updated.', 'cycloneslider' ),
|
171 |
+
10 => __( 'Slideshow updated.', 'cycloneslider' )
|
172 |
+
);
|
173 |
+
return $messages;
|
174 |
+
}
|
175 |
+
|
176 |
+
// Slides metabox init
|
177 |
+
function add_meta_boxes(){
|
178 |
+
add_meta_box(
|
179 |
+
'cyclone-slides-metabox',
|
180 |
+
__('Slides', 'cycloneslider'),
|
181 |
+
array( &$this, 'render_slides_meta_box' ),
|
182 |
+
'cycloneslider' ,
|
183 |
+
'normal',
|
184 |
+
'high'
|
185 |
+
);
|
186 |
+
add_meta_box(
|
187 |
+
'cyclone-slider-properties-metabox',
|
188 |
+
__('Slider Settings', 'cycloneslider'),
|
189 |
+
array( &$this, 'render_slider_properties_meta_box' ),
|
190 |
+
'cycloneslider' ,
|
191 |
+
'side',
|
192 |
+
'low'
|
193 |
+
);
|
194 |
+
add_meta_box(
|
195 |
+
'cyclone-slider-templates-metabox',
|
196 |
+
__('Slider Templates', 'cycloneslider'),
|
197 |
+
array( &$this, 'render_slider_templates_meta_box' ),
|
198 |
+
'cycloneslider' ,
|
199 |
+
'normal',
|
200 |
+
'low'
|
201 |
+
);
|
202 |
+
}
|
203 |
+
|
204 |
+
// Get Image mime type. @param $image - full path to image
|
205 |
+
function get_mime_type( $image ){
|
206 |
+
if($properties = getimagesize( $image )){
|
207 |
+
return $properties['mime'];
|
208 |
+
}
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
|
212 |
+
// Slides metabox render
|
213 |
+
function render_slides_meta_box($post){
|
214 |
+
|
215 |
+
// Use nonce for verification
|
216 |
+
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
217 |
+
|
218 |
+
$meta = get_post_custom($post->ID);
|
219 |
+
|
220 |
+
$slider_metas = $this->get_slider_metas($meta);
|
221 |
+
$slider_settings = $this->get_slider_admin_settings($meta);
|
222 |
+
|
223 |
+
$debug = 0;
|
224 |
+
if($debug){
|
225 |
+
echo '<pre>';
|
226 |
+
print_r($slider_settings);
|
227 |
+
print_r($slider_metas);
|
228 |
+
echo '</pre>';
|
229 |
+
}
|
230 |
+
?>
|
231 |
+
<div class="cycloneslider-sortable">
|
232 |
+
<?php
|
233 |
+
if(is_array($slider_metas) and count($slider_metas)>0):
|
234 |
+
foreach($slider_metas as $i=>$slider_meta):
|
235 |
+
$attachment_id = (int) $slider_meta['id'];
|
236 |
+
$image_url = wp_get_attachment_image_src( $attachment_id, 'medium', true );
|
237 |
+
$image_url = (is_array($image_url)) ? $image_url[0] : '';
|
238 |
+
|
239 |
+
include($this->template_slide_box);
|
240 |
+
endforeach;
|
241 |
+
endif;
|
242 |
+
?>
|
243 |
+
</div><!-- end .cycloneslider-sortable -->
|
244 |
+
|
245 |
+
<input type="button" value="<?php _e('Add Slide', 'cycloneslider'); ?>" class="button-secondary" name="cycloneslider_add_slide" />
|
246 |
+
<?php
|
247 |
+
}
|
248 |
+
|
249 |
+
function render_slider_properties_meta_box($post){
|
250 |
+
// Use nonce for verification
|
251 |
+
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
252 |
+
|
253 |
+
$meta = get_post_custom($post->ID);
|
254 |
+
$slider_settings = $this->get_slider_admin_settings($meta);
|
255 |
+
//default values
|
256 |
+
$slider_settings['timeout'] = (!isset($slider_settings['timeout']) || $slider_settings['timeout']===null) ? 4000 : $slider_settings['timeout'];
|
257 |
+
$slider_settings['speed'] = (!isset($slider_settings['speed']) || $slider_settings['speed']===null) ? 1000 : $slider_settings['speed'];
|
258 |
+
$slider_settings['width'] = (!isset($slider_settings['width']) || $slider_settings['width']===null) ? 960 : $slider_settings['width'];
|
259 |
+
$slider_settings['height'] = (!isset($slider_settings['height']) || $slider_settings['height']===null) ? 300 : $slider_settings['height'];
|
260 |
+
$slider_settings['show_prev_next'] = (!isset($slider_settings['show_prev_next']) || $slider_settings['show_prev_next']===null) ? 1 : $slider_settings['show_prev_next'];
|
261 |
+
$slider_settings['show_nav'] = (!isset($slider_settings['show_nav']) || $slider_settings['show_nav']===null) ? 1 : $slider_settings['show_nav'];
|
262 |
+
$slider_settings['hover_pause'] = (!isset($slider_settings['hover_pause']) || $slider_settings['hover_pause']===null) ? 1 : $slider_settings['hover_pause'];
|
263 |
+
|
264 |
+
?>
|
265 |
+
<div class="cycloneslider-field">
|
266 |
+
<label for="cycloneslider_settings_fx"><?php _e('Transition Effects to Use:', 'cycloneslider'); ?></label>
|
267 |
+
<select id="cycloneslider_settings_fx" name="cycloneslider_settings[fx]">
|
268 |
+
<?php foreach($this->effects as $key=>$fx): ?>
|
269 |
+
<option <?php echo (isset($slider_settings['fx']) && $key==$slider_settings['fx']) ? 'selected="selected"' : ''; ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($fx); ?></option>
|
270 |
+
<?php endforeach; ?>
|
271 |
+
</select>
|
272 |
+
<div class="clear"></div>
|
273 |
+
</div>
|
274 |
+
<?php
|
275 |
+
?>
|
276 |
+
<div class="cycloneslider-field">
|
277 |
+
<label for="cycloneslider_settings_timeout"><?php _e('Next Slide Delay:', 'cycloneslider'); ?> </label>
|
278 |
+
<input id="cycloneslider_settings_timeout" type="text" name="cycloneslider_settings[timeout]" value="<?php echo esc_attr($slider_settings['timeout']); ?>" />
|
279 |
+
<span class="note"><?php _e('Milliseconds. 0 to disable auto advance.', 'cycloneslider'); ?></span>
|
280 |
+
<div class="clear"></div>
|
281 |
+
</div>
|
282 |
+
<div class="cycloneslider-field">
|
283 |
+
<label for="cycloneslider_settings_speed"><?php _e('Transition Effects Speed:', 'cycloneslider'); ?></label>
|
284 |
+
<input id="cycloneslider_settings_speed" type="text" name="cycloneslider_settings[speed]" value="<?php echo esc_attr($slider_settings['speed']); ?>" />
|
285 |
+
<span class="note"><?php _e('Milliseconds', 'cycloneslider'); ?></span>
|
286 |
+
<div class="clear"></div>
|
287 |
+
</div>
|
288 |
+
<div class="cycloneslider-field">
|
289 |
+
<label for="cycloneslider_settings_width"><?php _e('Width:', 'cycloneslider'); ?> </label>
|
290 |
+
<input id="cycloneslider_settings_width" type="text" name="cycloneslider_settings[width]" value="<?php echo esc_attr($slider_settings['width']); ?>" />
|
291 |
+
<span class="note"><?php _e('pixels.', 'cycloneslider'); ?></span>
|
292 |
+
<div class="clear"></div>
|
293 |
+
</div>
|
294 |
+
<div class="cycloneslider-field">
|
295 |
+
<label for="cycloneslider_settings_height"><?php _e('Height:', 'cycloneslider'); ?> </label>
|
296 |
+
<input id="cycloneslider_settings_height" type="text" name="cycloneslider_settings[height]" value="<?php echo esc_attr($slider_settings['height']); ?>" />
|
297 |
+
<span class="note"><?php _e('pixels.', 'cycloneslider'); ?></span>
|
298 |
+
<div class="clear"></div>
|
299 |
+
</div>
|
300 |
+
<div class="cycloneslider-field">
|
301 |
+
<label for="cycloneslider_settings_hover_pause"><?php _e('Pause on Hover?', 'cycloneslider'); ?></label>
|
302 |
+
<select id="cycloneslider_settings_hover_pause" name="cycloneslider_settings[hover_pause]">
|
303 |
+
<option <?php echo ('true'==$slider_settings['hover_pause']) ? 'selected="selected"' : ''; ?> value="true"><?php _e('Yes', 'cycloneslider'); ?></option>
|
304 |
+
<option <?php echo ('false'==$slider_settings['hover_pause']) ? 'selected="selected"' : ''; ?> value="false"><?php _e('No', 'cycloneslider'); ?></option>
|
305 |
+
</select>
|
306 |
+
<div class="clear"></div>
|
307 |
+
</div>
|
308 |
+
<div class="cycloneslider-field">
|
309 |
+
<label for="cycloneslider_settings_show_prev_next"><?php _e('Show Prev/Next Buttons?', 'cycloneslider'); ?></label>
|
310 |
+
<select id="cycloneslider_settings_show_prev_next" name="cycloneslider_settings[show_prev_next]">
|
311 |
+
<option <?php echo (1==$slider_settings['show_prev_next']) ? 'selected="selected"' : ''; ?> value="1"><?php _e('Yes', 'cycloneslider'); ?></option>
|
312 |
+
<option <?php echo (0==$slider_settings['show_prev_next']) ? 'selected="selected"' : ''; ?> value="0"><?php _e('No', 'cycloneslider'); ?></option>
|
313 |
+
</select>
|
314 |
+
<div class="clear"></div>
|
315 |
+
</div>
|
316 |
+
<div class="cycloneslider-field last">
|
317 |
+
<label for="cycloneslider_settings_show_nav"><?php _e('Show Navigation?', 'cycloneslider'); ?></label>
|
318 |
+
<select id="cycloneslider_settings_show_nav" name="cycloneslider_settings[show_nav]">
|
319 |
+
<option <?php echo (1==$slider_settings['show_nav']) ? 'selected="selected"' : ''; ?> value="1"><?php _e('Yes', 'cycloneslider'); ?></option>
|
320 |
+
<option <?php echo (0==$slider_settings['show_nav']) ? 'selected="selected"' : ''; ?> value="0"><?php _e('No', 'cycloneslider'); ?></option>
|
321 |
+
</select>
|
322 |
+
<div class="clear"></div>
|
323 |
+
</div>
|
324 |
+
<?php
|
325 |
+
}
|
326 |
+
|
327 |
+
function render_slider_templates_meta_box($post){
|
328 |
+
// Use nonce for verification
|
329 |
+
echo '<input type="hidden" name="cycloneslider_metabox_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
|
330 |
+
|
331 |
+
$meta = get_post_custom($post->ID);
|
332 |
+
$slider_settings = $this->get_slider_admin_settings($meta);
|
333 |
+
//default values
|
334 |
+
$slider_settings['template'] = ($slider_settings['template']===null) ? 'default' : $slider_settings['template'];
|
335 |
+
|
336 |
+
$templates = $this->get_all_templates();
|
337 |
+
$template_options = array();
|
338 |
+
$template_options['default'] = 'Default';
|
339 |
+
foreach($templates as $name=>$template){
|
340 |
+
if($name!='default'){
|
341 |
+
$template_options[$name]= ucwords(str_replace('-',' ',$name));
|
342 |
+
}
|
343 |
+
}
|
344 |
+
?>
|
345 |
+
<div class="cycloneslider-field last">
|
346 |
+
<label for="cycloneslider_settings_template"><?php _e('Select Template to Use:', 'cycloneslider'); ?></label>
|
347 |
+
<select id="cycloneslider_settings_template" name="cycloneslider_settings[template]">
|
348 |
+
<?php foreach($template_options as $key=>$name): ?>
|
349 |
+
<option <?php echo ($key==$slider_settings['template']) ? 'selected="selected"' : ''; ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_attr($name); ?></option>
|
350 |
+
<?php endforeach; ?>
|
351 |
+
</select>
|
352 |
+
<div class="clear"></div>
|
353 |
+
</div>
|
354 |
+
<?php
|
355 |
+
}
|
356 |
+
|
357 |
+
function save_post($post_id){
|
358 |
+
|
359 |
+
// verify nonce
|
360 |
+
if (!empty($_POST['cycloneslider_metabox_nonce'])) {
|
361 |
+
if (!wp_verify_nonce($_POST['cycloneslider_metabox_nonce'], basename(__FILE__))) {
|
362 |
+
return $post_id;
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
// check autosave
|
367 |
+
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
368 |
+
return $post_id;
|
369 |
+
}
|
370 |
+
|
371 |
+
//slide metas
|
372 |
+
$this->save_metas($post_id);
|
373 |
+
|
374 |
+
//settings
|
375 |
+
$this->save_settings($post_id);
|
376 |
+
|
377 |
+
remove_action( 'save_post', array( &$this, 'save_post' ) );
|
378 |
+
}
|
379 |
+
|
380 |
+
//sanitize and save
|
381 |
+
function save_metas($post_id){
|
382 |
+
|
383 |
+
if(isset($_POST['cycloneslider_metas'])){
|
384 |
+
|
385 |
+
$slides = array();
|
386 |
+
$i=0;//always start from 0
|
387 |
+
foreach($_POST['cycloneslider_metas'] as $slide){
|
388 |
+
//bord($i.' '.$slide['fx']);
|
389 |
+
$slides[$i]['id'] = (int) $slide['id'];
|
390 |
+
$slides[$i]['link'] = esc_url_raw($slide['link']);
|
391 |
+
$slides[$i]['title'] = sanitize_text_field($slide['title']);
|
392 |
+
$slides[$i]['description'] = wp_kses_post($slide['description']);
|
393 |
+
$slides[$i]['link_target'] = wp_kses_post($slide['link_target']);
|
394 |
+
$slides[$i]['fx'] = wp_kses_post($slide['fx']);
|
395 |
+
$slides[$i]['speed'] = sanitize_text_field($slide['speed']);
|
396 |
+
$slides[$i]['timeout'] = sanitize_text_field($slide['timeout']);
|
397 |
+
$i++;
|
398 |
+
}
|
399 |
+
delete_post_meta($post_id, '_cycloneslider_metas');
|
400 |
+
update_post_meta($post_id, '_cycloneslider_metas', $slides);
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
//sanitize and save
|
405 |
+
function save_settings($post_id){
|
406 |
+
if(isset($_POST['cycloneslider_settings'])){
|
407 |
+
$settings = array();
|
408 |
+
$settings['template'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['template']);
|
409 |
+
$settings['fx'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['fx']);
|
410 |
+
$settings['timeout'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['timeout']);
|
411 |
+
$settings['speed'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['speed']);
|
412 |
+
$settings['width'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['width']);
|
413 |
+
$settings['height'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['height']);
|
414 |
+
$settings['hover_pause'] = wp_filter_nohtml_kses($_POST['cycloneslider_settings']['hover_pause']);
|
415 |
+
$settings['show_prev_next'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['show_prev_next']);
|
416 |
+
$settings['show_nav'] = (int) wp_filter_nohtml_kses($_POST['cycloneslider_settings']['show_nav']);
|
417 |
+
|
418 |
+
delete_post_meta($post_id, '_cycloneslider_settings');
|
419 |
+
update_post_meta($post_id, '_cycloneslider_settings', $settings);
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
function replace_text_in_thickbox($translation, $text, $domain ) {
|
424 |
+
$http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
425 |
+
$req_referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
|
426 |
+
if(strpos($http_referrer, 'cycloneslider')!==false or $req_referrer=='cycloneslider') {
|
427 |
+
if ( 'default' == $domain and 'Insert into Post' == $text )
|
428 |
+
{
|
429 |
+
return 'Add to Slide';
|
430 |
+
}
|
431 |
+
}
|
432 |
+
return $translation;
|
433 |
+
}
|
434 |
+
|
435 |
+
// Add attachment ID as html5 data attr in thickbox
|
436 |
+
function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ){
|
437 |
+
if(strpos($html, '<img data-id="')===false){
|
438 |
+
$html = str_replace('<img', '<img data-id="'.$id.'" ', $html);
|
439 |
+
}
|
440 |
+
return $html;
|
441 |
+
}
|
442 |
+
|
443 |
+
// Modify columns
|
444 |
+
function slideshow_columns($columns) {
|
445 |
+
$columns = array();
|
446 |
+
$columns['title']= __('Slideshow Name', 'cycloneslider');
|
447 |
+
$columns['id']= __('Slideshow ID', 'cycloneslider');
|
448 |
+
$columns['shortcode']= __('Shortcode', 'cycloneslider');
|
449 |
+
return $columns;
|
450 |
+
}
|
451 |
+
|
452 |
+
// Add content to custom columns
|
453 |
+
function custom_column( $column_name, $post_id ){
|
454 |
+
if ($column_name == 'id') {
|
455 |
+
$post = get_post($post_id);
|
456 |
+
echo $post->post_name;
|
457 |
+
}
|
458 |
+
if ($column_name == 'shortcode') {
|
459 |
+
$post = get_post($post_id);
|
460 |
+
echo '[cycloneslider id="'.$post->post_name.'"]';
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
// For js adding of box
|
465 |
+
function admin_footer() {
|
466 |
+
if(get_post_type()=='cycloneslider'){
|
467 |
+
?>
|
468 |
+
<div class="cycloneslider-box-template">
|
469 |
+
<?php
|
470 |
+
include_once($this->template_slide_box_js);
|
471 |
+
?>
|
472 |
+
</div><!-- end .cycloneslider-box-template -->
|
473 |
+
<?php
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
// Compare the value from admin and shortcode. If shortcode value is present and not empty, use it, otherwise return admin value
|
478 |
+
function get_comp_slider_setting($admin_val, $shortcode_val){
|
479 |
+
if($shortcode_val!==null){//make sure its really null and not just int zero 0
|
480 |
+
return $shortcode_val;
|
481 |
+
}
|
482 |
+
return $admin_val;
|
483 |
+
}
|
484 |
+
|
485 |
+
/* Our shortcode function.
|
486 |
+
Slider settings comes from both admin settings and shortcode attributes.
|
487 |
+
Shortcode attributes, if present, will override the admin settings.
|
488 |
+
*/
|
489 |
+
function cycloneslider_shortcode($shortcode_settings) {
|
490 |
+
// Process shortcode settings and return only allowed vars
|
491 |
+
$shortcode_settings = shortcode_atts(
|
492 |
+
array(
|
493 |
+
'id' => 0,
|
494 |
+
'template' => null,
|
495 |
+
'fx' => null,
|
496 |
+
'speed' => null,
|
497 |
+
'timeout' => null,
|
498 |
+
'width' => null,
|
499 |
+
'height' => null,
|
500 |
+
'hover_pause' => null,
|
501 |
+
'show_prev_next' => null,
|
502 |
+
'show_nav' => null
|
503 |
+
),
|
504 |
+
$shortcode_settings
|
505 |
+
);
|
506 |
+
$slider_id = esc_attr($shortcode_settings['id']);
|
507 |
+
|
508 |
+
$cycle_options = array();
|
509 |
+
$this->slider_count++;//make each call to shortcode unique
|
510 |
+
// Get slideshow by id
|
511 |
+
$my_query = new WP_Query(
|
512 |
+
array(
|
513 |
+
'post_type' => 'cycloneslider',
|
514 |
+
'order'=>'ASC',
|
515 |
+
'posts_per_page' => 1,
|
516 |
+
'name'=> $slider_id
|
517 |
+
)
|
518 |
+
);
|
519 |
+
if($my_query->have_posts()):
|
520 |
+
while ( $my_query->have_posts() ) : $my_query->the_post();
|
521 |
+
|
522 |
+
$meta = get_post_custom();
|
523 |
+
|
524 |
+
$admin_settings = $this->get_slider_admin_settings($meta);
|
525 |
+
$slider_metas = $this->get_slider_metas($meta);
|
526 |
+
$slides = $this->get_slides_from_meta($slider_metas);
|
527 |
+
|
528 |
+
$template = $this->get_comp_slider_setting($admin_settings['template'], $shortcode_settings['template']);
|
529 |
+
$template = esc_attr($template===null ? 'default' : $template);//fallback to default
|
530 |
+
$slider_settings['fx'] = esc_attr($this->get_comp_slider_setting($admin_settings['fx'], $shortcode_settings['fx']));
|
531 |
+
$slider_settings['speed'] = (int) $this->get_comp_slider_setting($admin_settings['speed'], $shortcode_settings['speed']);
|
532 |
+
$slider_settings['timeout'] = (int) $this->get_comp_slider_setting($admin_settings['timeout'], $shortcode_settings['timeout']);
|
533 |
+
$slider_settings['width'] = (int) $this->get_comp_slider_setting($admin_settings['width'], $shortcode_settings['width']);
|
534 |
+
$slider_settings['height'] = (int) $this->get_comp_slider_setting($admin_settings['height'], $shortcode_settings['height']);
|
535 |
+
$slider_settings['hover_pause'] = $this->get_comp_slider_setting($admin_settings['hover_pause'], $shortcode_settings['hover_pause']);
|
536 |
+
$slider_settings['show_prev_next'] = (int) $this->get_comp_slider_setting($admin_settings['show_prev_next'], $shortcode_settings['show_prev_next']);
|
537 |
+
$slider_settings['show_nav'] = (int) $this->get_comp_slider_setting($admin_settings['show_nav'], $shortcode_settings['show_nav']);
|
538 |
+
|
539 |
+
$slider = $this->get_slider_template($slider_id, $template, $slides, $slider_metas, $slider_settings, $this->slider_count);
|
540 |
+
|
541 |
+
endwhile;
|
542 |
+
|
543 |
+
wp_reset_postdata();
|
544 |
+
|
545 |
+
else:
|
546 |
+
$slider = __('[Slideshow not found]', 'cycloneslider');
|
547 |
+
endif;
|
548 |
+
|
549 |
+
return $slider;
|
550 |
+
}
|
551 |
+
|
552 |
+
// Process the post meta and return the settings
|
553 |
+
function get_slider_admin_settings($meta){
|
554 |
+
if(isset($meta['cycloneslider_settings'][0]) and !empty($meta['cycloneslider_settings'][0])){//from version 1.0.0. set for deletion in future releases
|
555 |
+
return maybe_unserialize($meta['cycloneslider_settings'][0]);
|
556 |
+
}
|
557 |
+
if(isset($meta['_cycloneslider_settings'][0]) and !empty($meta['_cycloneslider_settings'][0])){//we have added prefix _ since 1.0.2
|
558 |
+
return maybe_unserialize($meta['_cycloneslider_settings'][0]);
|
559 |
+
}
|
560 |
+
return false;
|
561 |
+
}
|
562 |
+
|
563 |
+
// Process the post meta and return the settings
|
564 |
+
function get_slider_metas($meta){
|
565 |
+
if(isset($meta['cycloneslider_metas'][0]) and !empty($meta['cycloneslider_metas'][0])){//from version 1.0.0. set for deletion in future releases
|
566 |
+
return maybe_unserialize($meta['cycloneslider_metas'][0]);
|
567 |
+
}
|
568 |
+
if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){//we have added prefix _ since 1.0.2
|
569 |
+
return maybe_unserialize($meta['_cycloneslider_metas'][0]);
|
570 |
+
}
|
571 |
+
return false;
|
572 |
+
}
|
573 |
+
|
574 |
+
// Get slideshow template
|
575 |
+
function get_slider_template($slider_id, $template_name, $slides, $slider_metas, $slider_settings, $slider_count){
|
576 |
+
|
577 |
+
$template = get_stylesheet_directory()."/cycloneslider/{$template_name}/slider.php";
|
578 |
+
if(@is_file($template)){
|
579 |
+
ob_start();
|
580 |
+
include($template);
|
581 |
+
$html = ob_get_clean();
|
582 |
+
return $html = $this->trim_white_spaces($html);
|
583 |
+
}
|
584 |
+
|
585 |
+
$template = $this->template_slider_dir."{$template_name}/slider.php";
|
586 |
+
if(@is_file($template)) {
|
587 |
+
ob_start();
|
588 |
+
include($template);
|
589 |
+
$html = ob_get_clean();
|
590 |
+
return $html = $this->trim_white_spaces($html);
|
591 |
+
}
|
592 |
+
|
593 |
+
return sprintf(__('[Template "%s" not found]', 'cycloneslider'), $template_name);
|
594 |
+
}
|
595 |
+
|
596 |
+
function trim_white_spaces($buffer){
|
597 |
+
$search = array(
|
598 |
+
'/\>[^\S ]+/s', //strip whitespaces after tags, except space
|
599 |
+
'/[^\S ]+\</s', //strip whitespaces before tags, except space
|
600 |
+
'/(\s)+/s' // shorten multiple whitespace sequences
|
601 |
+
);
|
602 |
+
$replace = array(
|
603 |
+
'>',
|
604 |
+
'<',
|
605 |
+
'\\1'
|
606 |
+
);
|
607 |
+
return preg_replace($search, $replace, $buffer);
|
608 |
+
}
|
609 |
+
|
610 |
+
// Return array of slide urls from meta
|
611 |
+
function get_slides_from_meta($slider_metas){
|
612 |
+
$slides = array();
|
613 |
+
if(is_array($slider_metas)){
|
614 |
+
foreach($slider_metas as $slider_meta){
|
615 |
+
$attachment_id = (int) $slider_meta['id'];
|
616 |
+
$image_url = wp_get_attachment_url($attachment_id);
|
617 |
+
$image_url = ($image_url===false) ? '' : $image_url;
|
618 |
+
$slides[] = $image_url;
|
619 |
+
}
|
620 |
+
}
|
621 |
+
return $slides;
|
622 |
+
}
|
623 |
+
|
624 |
+
// Add custom query var
|
625 |
+
function modify_query_vars($vars) {
|
626 |
+
$vars[] = 'cyclone_templates_css';//add our own
|
627 |
+
return $vars;
|
628 |
+
}
|
629 |
+
|
630 |
+
// Hook to template redirect
|
631 |
+
function cyclone_css_hook() {
|
632 |
+
if(intval(get_query_var('cyclone_templates_css')) == 1) {
|
633 |
+
$ds = DIRECTORY_SEPARATOR;
|
634 |
+
header("Content-type: text/css");
|
635 |
+
|
636 |
+
if(file_exists($this->plugin_path."css{$ds}common.css")){
|
637 |
+
echo file_get_contents($this->plugin_path."css{$ds}common.css");
|
638 |
+
}
|
639 |
+
|
640 |
+
$template_folders = $this->get_all_templates();
|
641 |
+
foreach($template_folders as $name=>$folder){
|
642 |
+
$style = $folder['path']."{$ds}style.css";
|
643 |
+
if(file_exists($style)){
|
644 |
+
echo "\n".str_replace('$tpl', $folder['url'], file_get_contents($style));//apply url and print css
|
645 |
+
}
|
646 |
+
}
|
647 |
+
die();
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
// Get all template locations. Returns array of locations containing path and url
|
652 |
+
function get_all_locations(){
|
653 |
+
$ds = DIRECTORY_SEPARATOR;
|
654 |
+
$template_locations = array();
|
655 |
+
$template_locations[0] = array(
|
656 |
+
'path'=>$this->template_slider_dir, //this resides in the plugin
|
657 |
+
'url'=>$this->plugin_url.'templates/'
|
658 |
+
);
|
659 |
+
$template_locations[1] = array(
|
660 |
+
'path'=> realpath(get_stylesheet_directory())."{$ds}cycloneslider{$ds}",//this resides in the current theme or child theme
|
661 |
+
'url'=> get_stylesheet_directory_uri()."/cycloneslider/"
|
662 |
+
);
|
663 |
+
return $template_locations;
|
664 |
+
}
|
665 |
+
|
666 |
+
// Get all templates from all locations. Returns array of templates with keys as name containing array of path and url
|
667 |
+
function get_all_templates(){
|
668 |
+
$template_locations = $this->get_all_locations();
|
669 |
+
$template_folders = array();
|
670 |
+
foreach($template_locations as $location){
|
671 |
+
if($files = @scandir($location['path'])){
|
672 |
+
$c = 0;
|
673 |
+
foreach($files as $name){
|
674 |
+
if($name!='.' and $name!='..' and is_dir($location['path'].$name)){
|
675 |
+
$name = sanitize_title($name);//change space to dash and all lowercase
|
676 |
+
$template_folders[$name] = array( //here we override template of the same names. templates inside themes take precedence
|
677 |
+
'path'=>$location['path'].$name,
|
678 |
+
'url'=>$location['url'].$name,
|
679 |
+
);
|
680 |
+
}
|
681 |
+
}
|
682 |
+
}
|
683 |
+
}
|
684 |
+
return $template_folders;
|
685 |
+
}
|
686 |
+
|
687 |
+
} // end class
|
688 |
+
|
689 |
endif;
|
js/admin.js
CHANGED
@@ -1,158 +1,158 @@
|
|
1 |
-
jQuery(document).ready(function($){
|
2 |
-
(function() {
|
3 |
-
/*** hide wordpress admin stuff ***/
|
4 |
-
$('#minor-publishing-actions').hide();
|
5 |
-
$('#misc-publishing-actions').hide();
|
6 |
-
|
7 |
-
/*** make it sortable ***/
|
8 |
-
$('.cycloneslider-sortable').sortable({
|
9 |
-
handle:'.cycloneslider-box-drag',
|
10 |
-
placeholder: "cycloneslider-box-placeholder",
|
11 |
-
forcePlaceholderSize:true,
|
12 |
-
update: function(event, ui) {
|
13 |
-
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
14 |
-
$(this).find('.cycloneslider-slide-meta-id').attr('name', 'cycloneslider_metas['+(i)+'][id]');
|
15 |
-
$(this).find('.cycloneslider-slide-meta-link').attr('name', 'cycloneslider_metas['+(i)+'][link]');
|
16 |
-
$(this).find('.cycloneslider-slide-meta-title').attr('name', 'cycloneslider_metas['+(i)+'][title]');
|
17 |
-
$(this).find('.cycloneslider-slide-meta-description').attr('name', 'cycloneslider_metas['+(i)+'][description]');
|
18 |
-
});
|
19 |
-
}
|
20 |
-
});
|
21 |
-
|
22 |
-
/*** ID ***/
|
23 |
-
$('.cycloneslider-upload-button').each(function(i){
|
24 |
-
$(this).data('cycloneslider_id',i);
|
25 |
-
});
|
26 |
-
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
27 |
-
$(this).data('cycloneslider_id',i);
|
28 |
-
$(this).find('.cycloneslider-box-title-left').html('Slide '+(i+1));
|
29 |
-
});
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
/*** Add new slide box ***/
|
34 |
-
$('input[name="cycloneslider_add_slide"]').on('click', function(e){
|
35 |
-
var id = $('.cycloneslider-sortable .cycloneslider-box').length;
|
36 |
-
var html = $('.cycloneslider-box-template').html();
|
37 |
-
html = html.replace(/{id}/g, id);/*** replace all occurences of {id} to real id ***/
|
38 |
-
|
39 |
-
$('.cycloneslider-sortable').append(html);
|
40 |
-
$('.cycloneslider-sortable .cycloneslider-box:last').find('.cycloneslider-slide-thumb').hide().end().find('.cycloneslider-box-body').show();
|
41 |
-
$('.cycloneslider-upload-button').each(function(i){
|
42 |
-
$(this).data('cycloneslider_id',i);
|
43 |
-
});
|
44 |
-
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
45 |
-
$(this).data('cycloneslider_id',i);
|
46 |
-
});
|
47 |
-
$('.cycloneslider-field-body').each(function(i){
|
48 |
-
$(this).data('cycloneslider_id',i);
|
49 |
-
});
|
50 |
-
|
51 |
-
e.preventDefault();
|
52 |
-
});
|
53 |
-
|
54 |
-
/*** Toggle slide visiblity ***/
|
55 |
-
$('.cycloneslider-box-toggle').live('click', function(e) {
|
56 |
-
var box = $(this).parents('.cycloneslider-box');
|
57 |
-
var body = box.find('.cycloneslider-box-body');
|
58 |
-
|
59 |
-
if(body.is(':visible')){
|
60 |
-
body.slideUp(100);
|
61 |
-
$.cookie('cycloneslider_box_'+box.data('cycloneslider_id'), null);
|
62 |
-
|
63 |
-
} else {
|
64 |
-
body.slideDown(100);
|
65 |
-
$.cookie('cycloneslider_box_'+box.data('cycloneslider_id'), 'open', { expires: 7});/*** remember open section ***/
|
66 |
-
}
|
67 |
-
e.preventDefault();
|
68 |
-
});
|
69 |
-
|
70 |
-
/*** Slide Properties ***/
|
71 |
-
$('.cycloneslider-field-body').each(function(i){
|
72 |
-
$(this).data('cycloneslider_id',i);
|
73 |
-
});
|
74 |
-
/*** Slide Properties Toggle ***/
|
75 |
-
$('.cycloneslider-meta-field .cycloneslider-field-title').live('click',function(e){
|
76 |
-
var body = $(this).next();
|
77 |
-
var id = body.data('cycloneslider_id');
|
78 |
-
if(body.is(':visible')){
|
79 |
-
body.slideUp(100);
|
80 |
-
$.cookie('cycloneslider_slide_meta_field_'+id, null);/*** delete cookie ***/
|
81 |
-
} else {
|
82 |
-
body.slideDown(100);
|
83 |
-
$.cookie('cycloneslider_slide_meta_field_'+id, 'open', { expires: 7});/*** remember open section ***/
|
84 |
-
}
|
85 |
-
});
|
86 |
-
/*** Slide Properties Cookie ***/
|
87 |
-
$('.cycloneslider-field-body').each(function(i){
|
88 |
-
body = $(this);
|
89 |
-
var id = $(this).data('cycloneslider_id');
|
90 |
-
if($.cookie('cycloneslider_slide_meta_field_'+id)!='open'){/*** do not close open section ***/
|
91 |
-
body.hide();
|
92 |
-
}
|
93 |
-
});
|
94 |
-
/*** hide all thats hidden ***/
|
95 |
-
$('.cycloneslider-sortable .cycloneslider-box').each(function(){
|
96 |
-
var body = $(this).find('.cycloneslider-box-body');
|
97 |
-
var id = $(this).data('cycloneslider_id');
|
98 |
-
if($.cookie('cycloneslider_box_'+id)=='open'){/*** do not close open section ***/
|
99 |
-
body.show();
|
100 |
-
}
|
101 |
-
});
|
102 |
-
|
103 |
-
/*** Delete Slide ***/
|
104 |
-
$('.cycloneslider-box-delete').live('click',function(e) {
|
105 |
-
|
106 |
-
var box = $(this).parents('.cycloneslider-box');
|
107 |
-
box.fadeOut('slow', function(){ box.remove()});
|
108 |
-
|
109 |
-
e.preventDefault();
|
110 |
-
});
|
111 |
-
})();
|
112 |
-
|
113 |
-
(function() {
|
114 |
-
/*** Modify WP media uploader ***/
|
115 |
-
var current_slide_box = false;/*** we use this var to determine if thickbox is being used in cycloneslider. also saves the field to be updated later. ***/
|
116 |
-
$(document).on('click', '.cycloneslider-upload-button', function() {
|
117 |
-
var box = $(this).parents('.cycloneslider-box');/*** get current box ***/
|
118 |
-
|
119 |
-
current_slide_box = box;
|
120 |
-
tb_show('', 'media-upload.php?referer=cycloneslider&post_id=0&type=image&TB_iframe=true');/*** referer param needed to change button text ***/
|
121 |
-
return false;
|
122 |
-
});
|
123 |
-
|
124 |
-
window.original_send_to_editor = window.send_to_editor;/*** backup original for other parts of admin that uses thickbox to work ***/
|
125 |
-
window.send_to_editor = function(html) {
|
126 |
-
if (current_slide_box) {
|
127 |
-
var slide_thumb = current_slide_box.find('.cycloneslider-slide-thumb');/*** find the thumb ***/
|
128 |
-
var slide_attachment_id = current_slide_box.find('.cycloneslider-slide-meta-id');/*** find the hidden field that will hold the attachment id ***/
|
129 |
-
|
130 |
-
var image = false;
|
131 |
-
if(jQuery(html).get(0) != undefined){ /*** Check if its a valid html tag ***/
|
132 |
-
if(jQuery(html).get(0).nodeName.toLowerCase()=='img'){/*** Check if html is an img tag ***/
|
133 |
-
image = jQuery(html);
|
134 |
-
} else { /*** If not may be it contains the img tag ***/
|
135 |
-
if(jQuery(html).find('img').length > 0){
|
136 |
-
image = jQuery(html).find('img');
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
if(image){
|
141 |
-
var url = image.attr('src');
|
142 |
-
var attachment_id = image.attr('data-id');
|
143 |
-
|
144 |
-
slide_thumb.attr('src', url).show();
|
145 |
-
slide_attachment_id.val(attachment_id);
|
146 |
-
|
147 |
-
} else {
|
148 |
-
alert('Could not insert image.');
|
149 |
-
}
|
150 |
-
|
151 |
-
tb_remove();
|
152 |
-
current_slide_box = false;
|
153 |
-
} else {
|
154 |
-
window.original_send_to_editor(html);
|
155 |
-
}
|
156 |
-
};
|
157 |
-
})();
|
158 |
});
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
(function() {
|
3 |
+
/*** hide wordpress admin stuff ***/
|
4 |
+
$('#minor-publishing-actions').hide();
|
5 |
+
$('#misc-publishing-actions').hide();
|
6 |
+
|
7 |
+
/*** make it sortable ***/
|
8 |
+
$('.cycloneslider-sortable').sortable({
|
9 |
+
handle:'.cycloneslider-box-drag',
|
10 |
+
placeholder: "cycloneslider-box-placeholder",
|
11 |
+
forcePlaceholderSize:true,
|
12 |
+
update: function(event, ui) {
|
13 |
+
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
14 |
+
$(this).find('.cycloneslider-slide-meta-id').attr('name', 'cycloneslider_metas['+(i)+'][id]');
|
15 |
+
$(this).find('.cycloneslider-slide-meta-link').attr('name', 'cycloneslider_metas['+(i)+'][link]');
|
16 |
+
$(this).find('.cycloneslider-slide-meta-title').attr('name', 'cycloneslider_metas['+(i)+'][title]');
|
17 |
+
$(this).find('.cycloneslider-slide-meta-description').attr('name', 'cycloneslider_metas['+(i)+'][description]');
|
18 |
+
});
|
19 |
+
}
|
20 |
+
});
|
21 |
+
|
22 |
+
/*** ID ***/
|
23 |
+
$('.cycloneslider-upload-button').each(function(i){
|
24 |
+
$(this).data('cycloneslider_id',i);
|
25 |
+
});
|
26 |
+
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
27 |
+
$(this).data('cycloneslider_id',i);
|
28 |
+
$(this).find('.cycloneslider-box-title-left').html('Slide '+(i+1));
|
29 |
+
});
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
/*** Add new slide box ***/
|
34 |
+
$('input[name="cycloneslider_add_slide"]').on('click', function(e){
|
35 |
+
var id = $('.cycloneslider-sortable .cycloneslider-box').length;
|
36 |
+
var html = $('.cycloneslider-box-template').html();
|
37 |
+
html = html.replace(/{id}/g, id);/*** replace all occurences of {id} to real id ***/
|
38 |
+
|
39 |
+
$('.cycloneslider-sortable').append(html);
|
40 |
+
$('.cycloneslider-sortable .cycloneslider-box:last').find('.cycloneslider-slide-thumb').hide().end().find('.cycloneslider-box-body').show();
|
41 |
+
$('.cycloneslider-upload-button').each(function(i){
|
42 |
+
$(this).data('cycloneslider_id',i);
|
43 |
+
});
|
44 |
+
$('.cycloneslider-sortable .cycloneslider-box').each(function(i){
|
45 |
+
$(this).data('cycloneslider_id',i);
|
46 |
+
});
|
47 |
+
$('.cycloneslider-field-body').each(function(i){
|
48 |
+
$(this).data('cycloneslider_id',i);
|
49 |
+
});
|
50 |
+
|
51 |
+
e.preventDefault();
|
52 |
+
});
|
53 |
+
|
54 |
+
/*** Toggle slide visiblity ***/
|
55 |
+
$('.cycloneslider-box-toggle').live('click', function(e) {
|
56 |
+
var box = $(this).parents('.cycloneslider-box');
|
57 |
+
var body = box.find('.cycloneslider-box-body');
|
58 |
+
|
59 |
+
if(body.is(':visible')){
|
60 |
+
body.slideUp(100);
|
61 |
+
$.cookie('cycloneslider_box_'+box.data('cycloneslider_id'), null);
|
62 |
+
|
63 |
+
} else {
|
64 |
+
body.slideDown(100);
|
65 |
+
$.cookie('cycloneslider_box_'+box.data('cycloneslider_id'), 'open', { expires: 7});/*** remember open section ***/
|
66 |
+
}
|
67 |
+
e.preventDefault();
|
68 |
+
});
|
69 |
+
|
70 |
+
/*** Slide Properties ***/
|
71 |
+
$('.cycloneslider-field-body').each(function(i){
|
72 |
+
$(this).data('cycloneslider_id',i);
|
73 |
+
});
|
74 |
+
/*** Slide Properties Toggle ***/
|
75 |
+
$('.cycloneslider-meta-field .cycloneslider-field-title').live('click',function(e){
|
76 |
+
var body = $(this).next();
|
77 |
+
var id = body.data('cycloneslider_id');
|
78 |
+
if(body.is(':visible')){
|
79 |
+
body.slideUp(100);
|
80 |
+
$.cookie('cycloneslider_slide_meta_field_'+id, null);/*** delete cookie ***/
|
81 |
+
} else {
|
82 |
+
body.slideDown(100);
|
83 |
+
$.cookie('cycloneslider_slide_meta_field_'+id, 'open', { expires: 7});/*** remember open section ***/
|
84 |
+
}
|
85 |
+
});
|
86 |
+
/*** Slide Properties Cookie ***/
|
87 |
+
$('.cycloneslider-field-body').each(function(i){
|
88 |
+
body = $(this);
|
89 |
+
var id = $(this).data('cycloneslider_id');
|
90 |
+
if($.cookie('cycloneslider_slide_meta_field_'+id)!='open'){/*** do not close open section ***/
|
91 |
+
body.hide();
|
92 |
+
}
|
93 |
+
});
|
94 |
+
/*** hide all thats hidden ***/
|
95 |
+
$('.cycloneslider-sortable .cycloneslider-box').each(function(){
|
96 |
+
var body = $(this).find('.cycloneslider-box-body');
|
97 |
+
var id = $(this).data('cycloneslider_id');
|
98 |
+
if($.cookie('cycloneslider_box_'+id)=='open'){/*** do not close open section ***/
|
99 |
+
body.show();
|
100 |
+
}
|
101 |
+
});
|
102 |
+
|
103 |
+
/*** Delete Slide ***/
|
104 |
+
$('.cycloneslider-box-delete').live('click',function(e) {
|
105 |
+
|
106 |
+
var box = $(this).parents('.cycloneslider-box');
|
107 |
+
box.fadeOut('slow', function(){ box.remove()});
|
108 |
+
|
109 |
+
e.preventDefault();
|
110 |
+
});
|
111 |
+
})();
|
112 |
+
|
113 |
+
(function() {
|
114 |
+
/*** Modify WP media uploader ***/
|
115 |
+
var current_slide_box = false;/*** we use this var to determine if thickbox is being used in cycloneslider. also saves the field to be updated later. ***/
|
116 |
+
$(document).on('click', '.cycloneslider-upload-button', function() {
|
117 |
+
var box = $(this).parents('.cycloneslider-box');/*** get current box ***/
|
118 |
+
|
119 |
+
current_slide_box = box;
|
120 |
+
tb_show('', 'media-upload.php?referer=cycloneslider&post_id=0&type=image&TB_iframe=true');/*** referer param needed to change button text ***/
|
121 |
+
return false;
|
122 |
+
});
|
123 |
+
|
124 |
+
window.original_send_to_editor = window.send_to_editor;/*** backup original for other parts of admin that uses thickbox to work ***/
|
125 |
+
window.send_to_editor = function(html) {
|
126 |
+
if (current_slide_box) {
|
127 |
+
var slide_thumb = current_slide_box.find('.cycloneslider-slide-thumb');/*** find the thumb ***/
|
128 |
+
var slide_attachment_id = current_slide_box.find('.cycloneslider-slide-meta-id');/*** find the hidden field that will hold the attachment id ***/
|
129 |
+
|
130 |
+
var image = false;
|
131 |
+
if(jQuery(html).get(0) != undefined){ /*** Check if its a valid html tag ***/
|
132 |
+
if(jQuery(html).get(0).nodeName.toLowerCase()=='img'){/*** Check if html is an img tag ***/
|
133 |
+
image = jQuery(html);
|
134 |
+
} else { /*** If not may be it contains the img tag ***/
|
135 |
+
if(jQuery(html).find('img').length > 0){
|
136 |
+
image = jQuery(html).find('img');
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
if(image){
|
141 |
+
var url = image.attr('src');
|
142 |
+
var attachment_id = image.attr('data-id');
|
143 |
+
|
144 |
+
slide_thumb.attr('src', url).show();
|
145 |
+
slide_attachment_id.val(attachment_id);
|
146 |
+
|
147 |
+
} else {
|
148 |
+
alert('Could not insert image.');
|
149 |
+
}
|
150 |
+
|
151 |
+
tb_remove();
|
152 |
+
current_slide_box = false;
|
153 |
+
} else {
|
154 |
+
window.original_send_to_editor(html);
|
155 |
+
}
|
156 |
+
};
|
157 |
+
})();
|
158 |
});
|
js/jquery.cycle2.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
/*!
|
2 |
-
* jQuery Cycle2; ver: BETA-20121002
|
3 |
-
* http://jquery.malsup.com/cycle2/
|
4 |
-
* Copyright (c) 2012 M. Alsup; Dual licensed: MIT/GPL
|
5 |
-
*/
|
6 |
(function(a){function c(){window.console&&console.log&&console.log("[cycle2] "+Array.prototype.join.call(arguments," "))}function d(a){return(a||"").toLowerCase()}"use strict";var b="BETA-20120923";a.fn.cycle=function(b){var e;return this.length===0&&!a.isReady?(e={s:this.selector,c:this.context},c("requeuing slideshow (dom not ready)"),a(function(){a(e.s,e.c).cycle(b)}),this):this.each(function(){var e,f,g,h,i=a(this);if(i.data("cycle.opts"))return;if(i.data("cycle-log")===!1||b&&b.log===!1||f&&f.log===!1)c=a.noop;c("--c2 init--"),e=i.data();for(var j in e)e.hasOwnProperty(j)&&/^cycle[A-Z]+/.test(j)&&(h=e[j],g=j.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,d),c(g+":",h,"("+typeof h+")"),e[g]=h);f=a.extend({},a.fn.cycle.defaults,e,b||{}),f.timeoutId=0,f.paused=0,f.container=i,f._maxZ=f.maxZ,f.API=a.extend({_container:i},a.fn.cycle.API),f.API.log=c,f.API.trigger=function(a,b){return f.container.trigger(a,b),f.API},i.data("cycle.opts",f),i.data("cycle.API",f.API),f.API.trigger("cycle-bootstrap",[f,f.API]),f.API.addInitialSlides(),f.API.preInitSlideshow(),f.slides.length&&f.API.initSlideshow()})},a.fn.cycle.API={opts:function(){return this._container.data("cycle.opts")},addInitialSlides:function(){var b=this.opts(),c=b.slides;b.slideCount=0,b.slides=a(),c=c.jquery?c:b.container.find(c),b.API.add(c)},preInitSlideshow:function(){var b=this.opts();b.API.trigger("cycle-pre-initialize",[b]);var c=a.fn.cycle.transitions[b.fx];c&&a.isFunction(c.preInit)&&c.preInit(b),b._preInitialized=!0},postInitSlideshow:function(){var b=this.opts();b.API.trigger("cycle-post-initialize",[b]);var c=a.fn.cycle.transitions[b.fx];c&&a.isFunction(c.postInit)&&c.postInit(b)},initSlideshow:function(){var b=this.opts(),c=b.container;b.API.calcFirstSlide(),b.container.css("position")=="static"&&b.container.css("position","relative"),a(b.slides[b.currSlide]).css("opacity",1).show(),b.API.stackSlides(b.slides[b.currSlide],b.slides[b.nextSlide],!b.reverse),b.pauseOnHover&&(b.pauseOnHover!==!0&&(c=a(b.pauseOnHover)),c.hover(function(){b.paused=1,b.API.trigger("cycle-paused",[b])},function(){b.paused=0,b.API.trigger("cycle-resumed",[b])})),b.timeout&&(b.timeoutId=setTimeout(function(){b.API.prepareTx(!1,!b.reverse)},b.timeout+b.delay)),b._initialized=!0,b.API.updateView(),b.container.on("cycle-paused cycle-resumed",function(a){b.container[a.type==="cycle-paused"?"addClass":"removeClass"]("cycle-paused")}),b.API.trigger("cycle-initialized",[b]),b.API.postInitSlideshow()},add:function(b,c){var d=this.opts(),e=d.slideCount,f=!1;a(b).each(function(b){var e,f=a(this);c?d.container.prepend(f):d.container.append(f),d.slideCount++,e=d.API.buildSlideOpts(f),c?d.slides=a(f).add(d.slides):d.slides=d.slides.add(f),d.API.initSlide(e,f,--d._maxZ),f.data("cycle.opts",e),d.API.trigger("cycle-slide-added",[d,e,f])}),d.API.updateView(),f=d._preInitialized&&e<2&&d.slideCount>=1,f&&(d._initialized?d.timeout&&(d.timeoutId=setTimeout(function(){var a=d.slides.length;d.nextSlide=d.reverse?a-1:1,d.API.prepareTx(!1,!d.reverse)},d.timeout+d.delay)):d.API.initSlideshow())},calcFirstSlide:function(){var a=this.opts(),b;b=parseInt(a.startingSlide||0,10);if(b>=a.slides.length||b<0)b=0;a.currSlide=b,a.reverse?(a.nextSlide=b-1,a.nextSlide<0&&(a.nextSlide=a.slides.length-1)):(a.nextSlide=b+1,a.nextSlide==a.slides.length&&(a.nextSlide=0))},calcNextSlide:function(){var a=this.opts(),b;a.reverse?(b=a.nextSlide-1<0,a.nextSlide=b?a.slideCount-1:a.nextSlide-1,a.currSlide=b?0:a.nextSlide+1):(b=a.nextSlide+1==a.slides.length,a.nextSlide=b?0:a.nextSlide+1,a.currSlide=b?a.slides.length-1:a.nextSlide-1)},calcTx:function(b,d){var e=b,f;return d&&e.manualFx&&(f=a.fn.cycle.transitions[e.manualFx]),f||(f=a.fn.cycle.transitions[e.fx]),f||(f=a.fn.cycle.transitions.fade,c('Transition "'+e.fx+'" not found. Using fade.')),f},prepareTx:function(a,b){var c=this.opts(),d,e,f,g,h;if(c.slideCount<2){c.timeoutId=0;return}a&&(c.API.stopTransition(),c.busy=!1,clearTimeout(c.timeoutId),c.timeoutId=0);if(c.busy)return;if(c.timeoutId===0&&!a)return;e=c.slides[c.currSlide],f=c.slides[c.nextSlide],g=c.API.getSlideOpts(c.nextSlide),h=c.API.calcTx(g,a),c._tx=h,a&&g.manualSpeed!==undefined&&(g.speed=g.manualSpeed),c.nextSlide!=c.currSlide&&(a||!c.paused&&c.timeout)?(c.API.trigger("cycle-before",[g,e,f,b]),h.before&&h.before(g,e,f,b),d=function(){c.busy=!1,h.after&&h.after(g,e,f,b),c.API.trigger("cycle-after",[g,e,f,b]),c.API.queueTransition(g),c.API.updateView()},c.busy=!0,h.transition?h.transition(g,e,f,b,d):c.API.doTransition(g,e,f,b,d),c.API.calcNextSlide()):c.API.queueTransition(g)},doTransition:function(b,c,d,e,f){var g=b,h=a(c),i=a(d),j=function(){i.animate(g.animIn||{opacity:1},g.speed,g.easeIn||g.easing,f)};i.css(g.cssBefore||{}),h.animate(g.animOut||{},g.speed,g.easeOut||g.easing,function(){h.css(g.cssAfter||{}),g.sync||j()}),g.sync&&j()},queueTransition:function(a){var b=this.opts();if(b.nextSlide===0&&--b.loop===0){b.API.log("terminating; loop=0"),b.timeout=0,b.API.trigger("cycle-finished",[b]),b.nextSlide=b.currSlide;return}a.timeout&&(b.timeoutId=setTimeout(function(){b.API.prepareTx(!1,!b.reverse)},a.timeout))},stopTransition:function(){var a=this.opts();a.slides.filter(":animated").length&&(a.slides.stop(!1,!0),a.API.trigger("cycle-transition-stopped",[a])),a._tx&&a._tx.stopTransition&&a._tx.stopTransition(a)},advanceSlide:function(a){var b=this.opts();return clearTimeout(b.timeoutId),b.timeoutId=0,b.nextSlide=b.currSlide+a,b.nextSlide<0?b.nextSlide=b.slides.length-1:b.nextSlide>=b.slides.length&&(b.nextSlide=0),b.API.prepareTx(!0,a>=0),!1},buildSlideOpts:function(b){var e=this.opts(),f,g,h=b.data()||{};for(var i in h)h.hasOwnProperty(i)&&/^cycle[A-Z]+/.test(i)&&(f=h[i],g=i.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,d),c("["+(e.slideCount-1)+"]",g+":",f,"("+typeof f+")"),h[g]=f);h=a.extend({},a.fn.cycle.defaults,e,h),h.slideNum=e.slideCount;try{delete h.API,delete h.slideCount,delete h.currSlide,delete h.nextSlide,delete h.slides}catch(j){}return h},getSlideOpts:function(b){var c=this.opts();b===undefined&&(b=c.currSlide);var d=c.slides[b],e=a(d).data("cycle.opts");return a.extend({},c,e)},initSlide:function(b,c,d){var e=this.opts();c.css(b.slideCss||{}),d>0&&c.css("zIndex",d),isNaN(b.speed)&&(b.speed=a.fx.speeds[b.speed]||a.fx.speeds._default),b.sync||(b.speed=b.speed/2),c.addClass(e.slideClass)},updateView:function(){var a=this.opts();if(!a._initialized)return;var b=a.API.getSlideOpts(),c=a.slides[a.currSlide];a.slideActiveClass&&a.slides.removeClass(a.slideActiveClass).eq(a.currSlide).addClass(a.slideActiveClass),a.hideNonActive&&a.slides.filter(":not(."+a.slideActiveClass+")").hide(),a.API.trigger("cycle-update-view",[a,b,c])},getComponent:function(b){var c=this.opts(),d=c[b];return typeof d=="string"?/^\s*\>/.test(d)?c.container.find(d):a(d):d.jquery?d:a(d)},stackSlides:function(b,c,d){var e=this.opts();b||(b=e.slides[e.currSlide],c=e.slides[e.nextSlide],d=!e.reverse),a(b).css("zIndex",e.maxZ);var f,g=e.maxZ-2,h=e.slideCount;if(d){for(f=e.currSlide+1;f<h;f++)a(e.slides[f]).css("zIndex",g--);for(f=0;f<e.currSlide;f++)a(e.slides[f]).css("zIndex",g--)}else{for(f=e.currSlide-1;f>=0;f--)a(e.slides[f]).css("zIndex",g--);for(f=h-1;f>e.currSlide;f--)a(e.slides[f]).css("zIndex",g--)}a(c).css("zIndex",e.maxZ-1)},getSlideIndex:function(a){return this.opts().slides.index(a)}},a.fn.cycle.log=c,a.fn.cycle.version=function(){return"Cycle2: "+b},a.fn.cycle.transitions={custom:{},none:{before:function(a,b,c,d){a.API.stackSlides(c,b,d),a.cssBefore={opacity:1,display:"block"}}},fade:{before:function(b,c,d,e){var f=b.API.getSlideOpts(b.nextSlide).slideCss||{};b.API.stackSlides(c,d,e),b.cssBefore=a.extend(f,{opacity:0,display:"block"}),b.animIn={opacity:1},b.animOut={opacity:0}}},fadeout:{before:function(b,c,d,e){var f=b.API.getSlideOpts(b.nextSlide).slideCss||{};b.API.stackSlides(c,d,e),b.cssBefore=a.extend(f,{opacity:1,display:"block"}),b.animOut={opacity:0}}},scrollHorz:{before:function(a,b,c,d){a.API.stackSlides(b,c,d);var e=a.container.css("overflow","hidden").width();a.cssBefore={left:d?e:-e,top:0,opacity:1,display:"block"},a.cssAfter={zIndex:a._maxZ-2},a.animIn={left:0},a.animOut={left:d?-e:e}}}},a.fn.cycle.defaults={allowWrap:!0,autoSelector:".cycle-slideshow",delay:0,easing:null,fx:"fade",hideNonActive:!0,loop:0,manualFx:undefined,manualSpeed:undefined,maxZ:100,pauseOnHover:!1,reverse:!1,slideActiveClass:"cycle-slide-active",slideClass:"cycle-slide",slideCss:{position:"absolute",top:0,left:0},slides:"> img",speed:500,startingSlide:0,sync:!0,timeout:4e3},a(document).ready(function(){a(a.fn.cycle.defaults.autoSelector).cycle()})})(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{autoHeight:0}),a(document).on("cycle-initialized",function(b,c){function e(){c.container.height(c.container.width()/d)}var d;a.type(c.autoHeight)=="number"&&c.autoHeight>=0?c._sentinel=a(c.slides[c.autoHeight]).clone().css({position:"static",visibility:"hidden",display:"block"}).prependTo(c.container).removeClass().addClass("cycle-sentinel cycle-slide"):a.type(c.autoHeight)=="string"&&/\d+\:\d+/.test(c.autoHeight)&&(d=c.autoHeight.match(/(\d+)\:(\d+)/),d=d[1]/d[2],a(window).on("resize",e),c._autoHeightOnResize=e,setTimeout(function(){a(window).triggerHandler("resize")},15))}),a(document).on("cycle-destroyed",function(b,c){c._sentinel&&c._sentinel.remove(),c._autoHeightOnResize&&a(window).off("resize",c._autoHeightOnResize)})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{caption:"> .cycle-caption",captionTemplate:"{{slideNum}} / {{slideCount}}",overlay:"> .cycle-overlay",overlayTemplate:"<div>{{title}}</div><div>{{desc}}</div>"}),a(document).on("cycle-update-view",function(b,c,d,e){var f;a.each(["caption","overlay"],function(){var a=this,b=d[a+"Template"];c[a]&&b&&(f=c.API.getComponent(a),f.html(c.API.tmpl(b,d,e)))})}),a(document).on("cycle-destroyed",function(b,c){var d;a.each(["caption","overlay"],function(){var a=this,b=c[a+"Template"];c[a]&&b&&(d=c.API.getComponent("caption"),d.empty())})})}(jQuery),function(a){"use strict";var b=a.fn.cycle;a.fn.cycle=function(c){var d,e,f,g=a.makeArray(arguments);return a.type(c)=="number"?this.cycle("goto",c):a.type(c)=="string"?this.each(function(){var h;d=c,f=a(this).data("cycle.opts");if(f===undefined){b.log('slideshow must be initialized before sending commands; "'+d+'" ignored');return}d=d=="goto"?"jump":d,e=f.API[d];if(a.isFunction(e))return h=a.makeArray(g),h.shift(),e.apply(f.API,h);b.log("unknown command: ",d)}):b.apply(this,arguments)},a.extend(a.fn.cycle,b),a.extend(b.API,{next:function(){var a=this.opts(),b=a.reverse?-1:1;if(a.allowWrap===!1&&a.currSlide+b>=a.slideCount)return;a.API.advanceSlide(b),a.API.trigger("cycle-next",[a]).log("cycle-next")},prev:function(){var a=this.opts(),b=a.reverse?1:-1;if(a.allowWrap===!1&&a.currSlide+b<0)return;a.API.advanceSlide(b),a.API.trigger("cycle-prev",[a]).log("cycle-prev")},destroy:function(){var a=this.opts();clearTimeout(a.timeoutId),a.timeoutId=0,a.API.stop(),a.API.trigger("cycle-destroyed",[a]).log("cycle-destroyed"),a.container.removeData("cycle.opts")},jump:function(a){var b=this.opts(),c=parseInt(a,10);if(isNaN(c)||c<0||c>=b.slides.length){b.API.log("goto: invalid slide index: "+c);return}if(c==b.currSlide){b.API.log("goto: skipping, already on slide",c);return}b.nextSlide=c,clearTimeout(b.timeoutId),b.timeoutId=0,b.API.log("goto: ",c," (zero-index)"),b.API.prepareTx(!0,!b.reverse)},stop:function(){var b=this.opts(),c=b.container;clearTimeout(b.timeoutId),b.timeoutId=0,b.API.stopTransition(),b.pauseOnHover&&(b.pauseOnHover!==!0&&(c=a(b.pauseOnHover)),c.off("mouseenter mouseleave")),b.API.trigger("cycle-stopped",[b]).log("cycle-stopped")},pause:function(){var a=this.opts();a.paused=!0,a.API.trigger("cycle-paused",[a]).log("cycle-paused")},resume:function(){var a=this.opts();a.paused=!1,a.API.trigger("cycle-resumed",[a]).log("cycle-resumed")},reinit:function(){var a=this.opts();a.API.destroy(),a.container.cycle()},remove:function(b){var c=this.opts(),d,e,f=[],g=1;for(var h=0;h<c.slides.length;h++)d=c.slides[h],h==b?e=d:(f.push(d),d.data("cycle.opts").slideNum=g,g++);e&&(c.slides=a(f),c.slideCount--,a(e).remove(),b==c.currSlide&&c.API.advanceSlide(1),c.API.trigger("cycle-slide-removed",[c,b,e]).log("cycle-slide-removed"),c.API.updateView())}}),a(document).on("click.cycle","[data-cycle-cmd]",function(b){b.preventDefault();var c=a(this),d=c.data("cycle-cmd"),e=c.data("cycle-context")||".cycle-slideshow";a(e).cycle(d,c.data("cycle-arg"))})}(jQuery),function(a){function b(b,c){var d;if(b._hashFence){b._hashFence=!1;return}d=window.location.hash.substring(1),b.slides.each(function(e){if(a(this).data("cycle-hash")===d)return c===!0?b.startingSlide=e:(b.nextSlide=e,b.API.prepareTx(!0,!1)),!1})}"use strict",a(document).on("cycle-pre-initialize",function(c,d){b(d,!0),d._onHashChange=function(){b(d,!1)},a(window).on("hashchange",d._onHashChange)}),a(document).on("cycle-update-view",function(a,b,c){c.hash&&(b._hashFence=!0,window.location.hash=c.hash)}),a(document).on("cycle-destroyed",function(b,c){c._onHashChange&&a(window).off("hashchange",c._onHashChange)})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{loader:!1}),a(document).on("cycle-bootstrap",function(b,c){function e(b,e){function h(b){var h;c.loader=="wait"?(f.push(b),g===0&&(d.apply(c.API,[f,e]),c.container.removeClass("cycle-loading"))):(h=a(c.slides[c.currSlide]),d.apply(c.API,[b,e]),h.show(),c.container.removeClass("cycle-loading"))}var f=[];b=a(b);var g=b.length;b.hide().each(function(){function k(){--b===0&&(--g,h(i))}var b=0,i=a(this),j=i.is("img")?i:i.find("img");j=j.filter(":not(.cycle-loader-ignore)");if(!j.length){--g,f.push(i);return}b=j.length,j.each(function(){this.complete?k():a(this).load(function(){k()}).error(function(){--b===0&&(c.API.log("slide skipped; img not loaded:",this.src),--g===0&&c.loader=="wait"&&d.apply(c.API,[f,e]))})})}),g&&c.container.addClass("cycle-loading")}var d;if(!c.loader)return;d=c.API.add,c.API.add=e})}(jQuery),function(a){function b(b,c,d){var e,f=b.API.getComponent("pager");f.each(function(){var f=a(this);if(c.pagerTemplate){var g=b.API.tmpl(c.pagerTemplate,c,d[0]);e=a(g).appendTo(f)}else e=f.children().eq(b.slideCount-1);e.on(b.pagerEvent,function(a){a.preventDefault(),b.API.page(f,a.currentTarget)})})}function c(a,b){var c=this.opts(),d=a.children().index(b),e=d,f=c.currSlide<e;if(c.currSlide==e)return;c.nextSlide=e,c.API.prepareTx(!0,f),c.API.trigger("cycle-pager-activated",[c,a,b])}"use strict",a.extend(a.fn.cycle.defaults,{pager:"> .cycle-pager",pagerActiveClass:"cycle-pager-active",pagerEvent:"click.cycle",pagerTemplate:"<span>•</span>"}),a(document).on("cycle-bootstrap",function(a,c,d){d.buildPagerLink=b}),a(document).on("cycle-slide-added",function(a,b,d,e){b.pager&&(b.API.buildPagerLink(b,d,e),b.API.page=c)}),a(document).on("cycle-slide-removed",function(b,c,d,e){if(c.pager){var f=c.API.getComponent(c,"pager");f.each(function(){var b=a(this);a(b.children()[d]).remove()})}}),a(document).on("cycle-update-view",function(b,c,d){var e;c.pager&&(e=c.API.getComponent("pager"),e.each(function(){a(this).children().removeClass(c.pagerActiveClass).eq(c.currSlide).addClass(c.pagerActiveClass)}))}),a(document).on("cycle-destroyed",function(a,b){var c;b.pager&&b.pagerTemplate&&(c=b.API.getComponent("pager"),c.empty())})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{next:"> .cycle-next",nextEvent:"click.cycle",disabledClass:"disabled",prev:"> .cycle-prev",prevEvent:"click.cycle",swipe:!1}),a(document).on("cycle-initialized",function(a,b){b.API.getComponent("next").off(b.nextEvent).on(b.nextEvent,function(a){a.preventDefault(),b.API.next()}),b.API.getComponent("prev").off(b.prevEvent).on(b.prevEvent,function(a){a.preventDefault(),b.API.prev()}),b.swipe&&(b.container.on("swipeleft.cycle",function(){b.API.next()}),b.container.on("swiperight.cycle",function(){b.API.prev()}))}),a(document).on("cycle-update-view",function(a,b,c,d){if(b.allowWrap)return;var e=b.disabledClass,f=b.API.getComponent("next"),g=b.API.getComponent("prev"),h=b._prevBoundry||0,i=b._nextBoundry||b.slideCount-1;b.currSlide==i?f.addClass(e).prop("disabled",!0):f.removeClass(e).prop("disabled",!1),b.currSlide===h?g.addClass(e).prop("disabled",!0):g.removeClass(e).prop("disabled",!1)}),a(document).on("cycle-destroyed",function(b,c){a(c.next).off(c.nextEvent),a(c.prev).off(c.prevEvent),c.container.off("swipeleft.cycle swiperight.cycle")})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{progressive:!1}),a(document).on("cycle-pre-initialize",function(b,c){if(!c.progressive)return;var d=c.API,e=d.next,f=d.prev,g=d.prepareTx,h,i=a.type(c.progressive);if(i=="array")h=c.progressive;else if(a.isFunction(c.progressive))h=c.progressive(c);else if(i=="string"){h=a(c.progressive).html();if(!a.trim(h))return;try{h=a.parseJSON(h)}catch(j){d.log("error parsing progressive slides",j);return}}g&&(d.prepareTx=function(a,b){var d,e;if(a||h.length===0){g.apply(c.API,[a,b]);return}b&&c.currSlide==c.slideCount-1?(e=h[0],h=h.slice(1),c.container.one("cycle-slide-added",function(a,b){b.API.advanceSlide(1)}),c.API.add(e)):!b&&c.currSlide===0?(d=h.length-1,e=h[d],h=h.slice(0,d),c.container.one("cycle-slide-added",function(a,b){b.currSlide=1,b.API.advanceSlide(-1)}),c.API.add(e,!0)):g.apply(c.API,[a,b])}),e&&(d.next=function(){var a=this.opts();if(h.length&&a.currSlide==a.slideCount-1){var b=h[0];h=h.slice(1),a.container.one("cycle-slide-added",function(a,b){e.apply(b.API),b.container.removeClass("cycle-loading")}),a.container.addClass("cycle-loading"),a.API.add(b)}else e.apply(a.API)}),f&&(d.prev=function(){var a=this.opts();if(h.length&&a.currSlide===0){var b=h.length-1,c=h[b];h=h.slice(0,b),a.container.one("cycle-slide-added",function(a,b){b.currSlide=1,b.API.advanceSlide(-1),b.container.removeClass("cycle-loading")}),a.container.addClass("cycle-loading"),a.API.add(c,!0)}else f.apply(a.API)})})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.API,{tmpl:function(b,c,d){if(b&&c)return b.replace(/\{\{((\.)?.*?)\}\}/g,function(b,e){var f,g,h=c,i=e.split(".");if(i.length>1){g=c;for(f=0;f<i.length;f++)h=g,g=g[i[f]]||e}else g=c[e];return a.isFunction(g)?g.call(h,c):g!==undefined&&g!==null?g:d&&d[e]!==undefined?d[e]:e})}})}(jQuery);
|
1 |
+
/*!
|
2 |
+
* jQuery Cycle2; ver: BETA-20121002
|
3 |
+
* http://jquery.malsup.com/cycle2/
|
4 |
+
* Copyright (c) 2012 M. Alsup; Dual licensed: MIT/GPL
|
5 |
+
*/
|
6 |
(function(a){function c(){window.console&&console.log&&console.log("[cycle2] "+Array.prototype.join.call(arguments," "))}function d(a){return(a||"").toLowerCase()}"use strict";var b="BETA-20120923";a.fn.cycle=function(b){var e;return this.length===0&&!a.isReady?(e={s:this.selector,c:this.context},c("requeuing slideshow (dom not ready)"),a(function(){a(e.s,e.c).cycle(b)}),this):this.each(function(){var e,f,g,h,i=a(this);if(i.data("cycle.opts"))return;if(i.data("cycle-log")===!1||b&&b.log===!1||f&&f.log===!1)c=a.noop;c("--c2 init--"),e=i.data();for(var j in e)e.hasOwnProperty(j)&&/^cycle[A-Z]+/.test(j)&&(h=e[j],g=j.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,d),c(g+":",h,"("+typeof h+")"),e[g]=h);f=a.extend({},a.fn.cycle.defaults,e,b||{}),f.timeoutId=0,f.paused=0,f.container=i,f._maxZ=f.maxZ,f.API=a.extend({_container:i},a.fn.cycle.API),f.API.log=c,f.API.trigger=function(a,b){return f.container.trigger(a,b),f.API},i.data("cycle.opts",f),i.data("cycle.API",f.API),f.API.trigger("cycle-bootstrap",[f,f.API]),f.API.addInitialSlides(),f.API.preInitSlideshow(),f.slides.length&&f.API.initSlideshow()})},a.fn.cycle.API={opts:function(){return this._container.data("cycle.opts")},addInitialSlides:function(){var b=this.opts(),c=b.slides;b.slideCount=0,b.slides=a(),c=c.jquery?c:b.container.find(c),b.API.add(c)},preInitSlideshow:function(){var b=this.opts();b.API.trigger("cycle-pre-initialize",[b]);var c=a.fn.cycle.transitions[b.fx];c&&a.isFunction(c.preInit)&&c.preInit(b),b._preInitialized=!0},postInitSlideshow:function(){var b=this.opts();b.API.trigger("cycle-post-initialize",[b]);var c=a.fn.cycle.transitions[b.fx];c&&a.isFunction(c.postInit)&&c.postInit(b)},initSlideshow:function(){var b=this.opts(),c=b.container;b.API.calcFirstSlide(),b.container.css("position")=="static"&&b.container.css("position","relative"),a(b.slides[b.currSlide]).css("opacity",1).show(),b.API.stackSlides(b.slides[b.currSlide],b.slides[b.nextSlide],!b.reverse),b.pauseOnHover&&(b.pauseOnHover!==!0&&(c=a(b.pauseOnHover)),c.hover(function(){b.paused=1,b.API.trigger("cycle-paused",[b])},function(){b.paused=0,b.API.trigger("cycle-resumed",[b])})),b.timeout&&(b.timeoutId=setTimeout(function(){b.API.prepareTx(!1,!b.reverse)},b.timeout+b.delay)),b._initialized=!0,b.API.updateView(),b.container.on("cycle-paused cycle-resumed",function(a){b.container[a.type==="cycle-paused"?"addClass":"removeClass"]("cycle-paused")}),b.API.trigger("cycle-initialized",[b]),b.API.postInitSlideshow()},add:function(b,c){var d=this.opts(),e=d.slideCount,f=!1;a(b).each(function(b){var e,f=a(this);c?d.container.prepend(f):d.container.append(f),d.slideCount++,e=d.API.buildSlideOpts(f),c?d.slides=a(f).add(d.slides):d.slides=d.slides.add(f),d.API.initSlide(e,f,--d._maxZ),f.data("cycle.opts",e),d.API.trigger("cycle-slide-added",[d,e,f])}),d.API.updateView(),f=d._preInitialized&&e<2&&d.slideCount>=1,f&&(d._initialized?d.timeout&&(d.timeoutId=setTimeout(function(){var a=d.slides.length;d.nextSlide=d.reverse?a-1:1,d.API.prepareTx(!1,!d.reverse)},d.timeout+d.delay)):d.API.initSlideshow())},calcFirstSlide:function(){var a=this.opts(),b;b=parseInt(a.startingSlide||0,10);if(b>=a.slides.length||b<0)b=0;a.currSlide=b,a.reverse?(a.nextSlide=b-1,a.nextSlide<0&&(a.nextSlide=a.slides.length-1)):(a.nextSlide=b+1,a.nextSlide==a.slides.length&&(a.nextSlide=0))},calcNextSlide:function(){var a=this.opts(),b;a.reverse?(b=a.nextSlide-1<0,a.nextSlide=b?a.slideCount-1:a.nextSlide-1,a.currSlide=b?0:a.nextSlide+1):(b=a.nextSlide+1==a.slides.length,a.nextSlide=b?0:a.nextSlide+1,a.currSlide=b?a.slides.length-1:a.nextSlide-1)},calcTx:function(b,d){var e=b,f;return d&&e.manualFx&&(f=a.fn.cycle.transitions[e.manualFx]),f||(f=a.fn.cycle.transitions[e.fx]),f||(f=a.fn.cycle.transitions.fade,c('Transition "'+e.fx+'" not found. Using fade.')),f},prepareTx:function(a,b){var c=this.opts(),d,e,f,g,h;if(c.slideCount<2){c.timeoutId=0;return}a&&(c.API.stopTransition(),c.busy=!1,clearTimeout(c.timeoutId),c.timeoutId=0);if(c.busy)return;if(c.timeoutId===0&&!a)return;e=c.slides[c.currSlide],f=c.slides[c.nextSlide],g=c.API.getSlideOpts(c.nextSlide),h=c.API.calcTx(g,a),c._tx=h,a&&g.manualSpeed!==undefined&&(g.speed=g.manualSpeed),c.nextSlide!=c.currSlide&&(a||!c.paused&&c.timeout)?(c.API.trigger("cycle-before",[g,e,f,b]),h.before&&h.before(g,e,f,b),d=function(){c.busy=!1,h.after&&h.after(g,e,f,b),c.API.trigger("cycle-after",[g,e,f,b]),c.API.queueTransition(g),c.API.updateView()},c.busy=!0,h.transition?h.transition(g,e,f,b,d):c.API.doTransition(g,e,f,b,d),c.API.calcNextSlide()):c.API.queueTransition(g)},doTransition:function(b,c,d,e,f){var g=b,h=a(c),i=a(d),j=function(){i.animate(g.animIn||{opacity:1},g.speed,g.easeIn||g.easing,f)};i.css(g.cssBefore||{}),h.animate(g.animOut||{},g.speed,g.easeOut||g.easing,function(){h.css(g.cssAfter||{}),g.sync||j()}),g.sync&&j()},queueTransition:function(a){var b=this.opts();if(b.nextSlide===0&&--b.loop===0){b.API.log("terminating; loop=0"),b.timeout=0,b.API.trigger("cycle-finished",[b]),b.nextSlide=b.currSlide;return}a.timeout&&(b.timeoutId=setTimeout(function(){b.API.prepareTx(!1,!b.reverse)},a.timeout))},stopTransition:function(){var a=this.opts();a.slides.filter(":animated").length&&(a.slides.stop(!1,!0),a.API.trigger("cycle-transition-stopped",[a])),a._tx&&a._tx.stopTransition&&a._tx.stopTransition(a)},advanceSlide:function(a){var b=this.opts();return clearTimeout(b.timeoutId),b.timeoutId=0,b.nextSlide=b.currSlide+a,b.nextSlide<0?b.nextSlide=b.slides.length-1:b.nextSlide>=b.slides.length&&(b.nextSlide=0),b.API.prepareTx(!0,a>=0),!1},buildSlideOpts:function(b){var e=this.opts(),f,g,h=b.data()||{};for(var i in h)h.hasOwnProperty(i)&&/^cycle[A-Z]+/.test(i)&&(f=h[i],g=i.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,d),c("["+(e.slideCount-1)+"]",g+":",f,"("+typeof f+")"),h[g]=f);h=a.extend({},a.fn.cycle.defaults,e,h),h.slideNum=e.slideCount;try{delete h.API,delete h.slideCount,delete h.currSlide,delete h.nextSlide,delete h.slides}catch(j){}return h},getSlideOpts:function(b){var c=this.opts();b===undefined&&(b=c.currSlide);var d=c.slides[b],e=a(d).data("cycle.opts");return a.extend({},c,e)},initSlide:function(b,c,d){var e=this.opts();c.css(b.slideCss||{}),d>0&&c.css("zIndex",d),isNaN(b.speed)&&(b.speed=a.fx.speeds[b.speed]||a.fx.speeds._default),b.sync||(b.speed=b.speed/2),c.addClass(e.slideClass)},updateView:function(){var a=this.opts();if(!a._initialized)return;var b=a.API.getSlideOpts(),c=a.slides[a.currSlide];a.slideActiveClass&&a.slides.removeClass(a.slideActiveClass).eq(a.currSlide).addClass(a.slideActiveClass),a.hideNonActive&&a.slides.filter(":not(."+a.slideActiveClass+")").hide(),a.API.trigger("cycle-update-view",[a,b,c])},getComponent:function(b){var c=this.opts(),d=c[b];return typeof d=="string"?/^\s*\>/.test(d)?c.container.find(d):a(d):d.jquery?d:a(d)},stackSlides:function(b,c,d){var e=this.opts();b||(b=e.slides[e.currSlide],c=e.slides[e.nextSlide],d=!e.reverse),a(b).css("zIndex",e.maxZ);var f,g=e.maxZ-2,h=e.slideCount;if(d){for(f=e.currSlide+1;f<h;f++)a(e.slides[f]).css("zIndex",g--);for(f=0;f<e.currSlide;f++)a(e.slides[f]).css("zIndex",g--)}else{for(f=e.currSlide-1;f>=0;f--)a(e.slides[f]).css("zIndex",g--);for(f=h-1;f>e.currSlide;f--)a(e.slides[f]).css("zIndex",g--)}a(c).css("zIndex",e.maxZ-1)},getSlideIndex:function(a){return this.opts().slides.index(a)}},a.fn.cycle.log=c,a.fn.cycle.version=function(){return"Cycle2: "+b},a.fn.cycle.transitions={custom:{},none:{before:function(a,b,c,d){a.API.stackSlides(c,b,d),a.cssBefore={opacity:1,display:"block"}}},fade:{before:function(b,c,d,e){var f=b.API.getSlideOpts(b.nextSlide).slideCss||{};b.API.stackSlides(c,d,e),b.cssBefore=a.extend(f,{opacity:0,display:"block"}),b.animIn={opacity:1},b.animOut={opacity:0}}},fadeout:{before:function(b,c,d,e){var f=b.API.getSlideOpts(b.nextSlide).slideCss||{};b.API.stackSlides(c,d,e),b.cssBefore=a.extend(f,{opacity:1,display:"block"}),b.animOut={opacity:0}}},scrollHorz:{before:function(a,b,c,d){a.API.stackSlides(b,c,d);var e=a.container.css("overflow","hidden").width();a.cssBefore={left:d?e:-e,top:0,opacity:1,display:"block"},a.cssAfter={zIndex:a._maxZ-2},a.animIn={left:0},a.animOut={left:d?-e:e}}}},a.fn.cycle.defaults={allowWrap:!0,autoSelector:".cycle-slideshow",delay:0,easing:null,fx:"fade",hideNonActive:!0,loop:0,manualFx:undefined,manualSpeed:undefined,maxZ:100,pauseOnHover:!1,reverse:!1,slideActiveClass:"cycle-slide-active",slideClass:"cycle-slide",slideCss:{position:"absolute",top:0,left:0},slides:"> img",speed:500,startingSlide:0,sync:!0,timeout:4e3},a(document).ready(function(){a(a.fn.cycle.defaults.autoSelector).cycle()})})(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{autoHeight:0}),a(document).on("cycle-initialized",function(b,c){function e(){c.container.height(c.container.width()/d)}var d;a.type(c.autoHeight)=="number"&&c.autoHeight>=0?c._sentinel=a(c.slides[c.autoHeight]).clone().css({position:"static",visibility:"hidden",display:"block"}).prependTo(c.container).removeClass().addClass("cycle-sentinel cycle-slide"):a.type(c.autoHeight)=="string"&&/\d+\:\d+/.test(c.autoHeight)&&(d=c.autoHeight.match(/(\d+)\:(\d+)/),d=d[1]/d[2],a(window).on("resize",e),c._autoHeightOnResize=e,setTimeout(function(){a(window).triggerHandler("resize")},15))}),a(document).on("cycle-destroyed",function(b,c){c._sentinel&&c._sentinel.remove(),c._autoHeightOnResize&&a(window).off("resize",c._autoHeightOnResize)})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{caption:"> .cycle-caption",captionTemplate:"{{slideNum}} / {{slideCount}}",overlay:"> .cycle-overlay",overlayTemplate:"<div>{{title}}</div><div>{{desc}}</div>"}),a(document).on("cycle-update-view",function(b,c,d,e){var f;a.each(["caption","overlay"],function(){var a=this,b=d[a+"Template"];c[a]&&b&&(f=c.API.getComponent(a),f.html(c.API.tmpl(b,d,e)))})}),a(document).on("cycle-destroyed",function(b,c){var d;a.each(["caption","overlay"],function(){var a=this,b=c[a+"Template"];c[a]&&b&&(d=c.API.getComponent("caption"),d.empty())})})}(jQuery),function(a){"use strict";var b=a.fn.cycle;a.fn.cycle=function(c){var d,e,f,g=a.makeArray(arguments);return a.type(c)=="number"?this.cycle("goto",c):a.type(c)=="string"?this.each(function(){var h;d=c,f=a(this).data("cycle.opts");if(f===undefined){b.log('slideshow must be initialized before sending commands; "'+d+'" ignored');return}d=d=="goto"?"jump":d,e=f.API[d];if(a.isFunction(e))return h=a.makeArray(g),h.shift(),e.apply(f.API,h);b.log("unknown command: ",d)}):b.apply(this,arguments)},a.extend(a.fn.cycle,b),a.extend(b.API,{next:function(){var a=this.opts(),b=a.reverse?-1:1;if(a.allowWrap===!1&&a.currSlide+b>=a.slideCount)return;a.API.advanceSlide(b),a.API.trigger("cycle-next",[a]).log("cycle-next")},prev:function(){var a=this.opts(),b=a.reverse?1:-1;if(a.allowWrap===!1&&a.currSlide+b<0)return;a.API.advanceSlide(b),a.API.trigger("cycle-prev",[a]).log("cycle-prev")},destroy:function(){var a=this.opts();clearTimeout(a.timeoutId),a.timeoutId=0,a.API.stop(),a.API.trigger("cycle-destroyed",[a]).log("cycle-destroyed"),a.container.removeData("cycle.opts")},jump:function(a){var b=this.opts(),c=parseInt(a,10);if(isNaN(c)||c<0||c>=b.slides.length){b.API.log("goto: invalid slide index: "+c);return}if(c==b.currSlide){b.API.log("goto: skipping, already on slide",c);return}b.nextSlide=c,clearTimeout(b.timeoutId),b.timeoutId=0,b.API.log("goto: ",c," (zero-index)"),b.API.prepareTx(!0,!b.reverse)},stop:function(){var b=this.opts(),c=b.container;clearTimeout(b.timeoutId),b.timeoutId=0,b.API.stopTransition(),b.pauseOnHover&&(b.pauseOnHover!==!0&&(c=a(b.pauseOnHover)),c.off("mouseenter mouseleave")),b.API.trigger("cycle-stopped",[b]).log("cycle-stopped")},pause:function(){var a=this.opts();a.paused=!0,a.API.trigger("cycle-paused",[a]).log("cycle-paused")},resume:function(){var a=this.opts();a.paused=!1,a.API.trigger("cycle-resumed",[a]).log("cycle-resumed")},reinit:function(){var a=this.opts();a.API.destroy(),a.container.cycle()},remove:function(b){var c=this.opts(),d,e,f=[],g=1;for(var h=0;h<c.slides.length;h++)d=c.slides[h],h==b?e=d:(f.push(d),d.data("cycle.opts").slideNum=g,g++);e&&(c.slides=a(f),c.slideCount--,a(e).remove(),b==c.currSlide&&c.API.advanceSlide(1),c.API.trigger("cycle-slide-removed",[c,b,e]).log("cycle-slide-removed"),c.API.updateView())}}),a(document).on("click.cycle","[data-cycle-cmd]",function(b){b.preventDefault();var c=a(this),d=c.data("cycle-cmd"),e=c.data("cycle-context")||".cycle-slideshow";a(e).cycle(d,c.data("cycle-arg"))})}(jQuery),function(a){function b(b,c){var d;if(b._hashFence){b._hashFence=!1;return}d=window.location.hash.substring(1),b.slides.each(function(e){if(a(this).data("cycle-hash")===d)return c===!0?b.startingSlide=e:(b.nextSlide=e,b.API.prepareTx(!0,!1)),!1})}"use strict",a(document).on("cycle-pre-initialize",function(c,d){b(d,!0),d._onHashChange=function(){b(d,!1)},a(window).on("hashchange",d._onHashChange)}),a(document).on("cycle-update-view",function(a,b,c){c.hash&&(b._hashFence=!0,window.location.hash=c.hash)}),a(document).on("cycle-destroyed",function(b,c){c._onHashChange&&a(window).off("hashchange",c._onHashChange)})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{loader:!1}),a(document).on("cycle-bootstrap",function(b,c){function e(b,e){function h(b){var h;c.loader=="wait"?(f.push(b),g===0&&(d.apply(c.API,[f,e]),c.container.removeClass("cycle-loading"))):(h=a(c.slides[c.currSlide]),d.apply(c.API,[b,e]),h.show(),c.container.removeClass("cycle-loading"))}var f=[];b=a(b);var g=b.length;b.hide().each(function(){function k(){--b===0&&(--g,h(i))}var b=0,i=a(this),j=i.is("img")?i:i.find("img");j=j.filter(":not(.cycle-loader-ignore)");if(!j.length){--g,f.push(i);return}b=j.length,j.each(function(){this.complete?k():a(this).load(function(){k()}).error(function(){--b===0&&(c.API.log("slide skipped; img not loaded:",this.src),--g===0&&c.loader=="wait"&&d.apply(c.API,[f,e]))})})}),g&&c.container.addClass("cycle-loading")}var d;if(!c.loader)return;d=c.API.add,c.API.add=e})}(jQuery),function(a){function b(b,c,d){var e,f=b.API.getComponent("pager");f.each(function(){var f=a(this);if(c.pagerTemplate){var g=b.API.tmpl(c.pagerTemplate,c,d[0]);e=a(g).appendTo(f)}else e=f.children().eq(b.slideCount-1);e.on(b.pagerEvent,function(a){a.preventDefault(),b.API.page(f,a.currentTarget)})})}function c(a,b){var c=this.opts(),d=a.children().index(b),e=d,f=c.currSlide<e;if(c.currSlide==e)return;c.nextSlide=e,c.API.prepareTx(!0,f),c.API.trigger("cycle-pager-activated",[c,a,b])}"use strict",a.extend(a.fn.cycle.defaults,{pager:"> .cycle-pager",pagerActiveClass:"cycle-pager-active",pagerEvent:"click.cycle",pagerTemplate:"<span>•</span>"}),a(document).on("cycle-bootstrap",function(a,c,d){d.buildPagerLink=b}),a(document).on("cycle-slide-added",function(a,b,d,e){b.pager&&(b.API.buildPagerLink(b,d,e),b.API.page=c)}),a(document).on("cycle-slide-removed",function(b,c,d,e){if(c.pager){var f=c.API.getComponent(c,"pager");f.each(function(){var b=a(this);a(b.children()[d]).remove()})}}),a(document).on("cycle-update-view",function(b,c,d){var e;c.pager&&(e=c.API.getComponent("pager"),e.each(function(){a(this).children().removeClass(c.pagerActiveClass).eq(c.currSlide).addClass(c.pagerActiveClass)}))}),a(document).on("cycle-destroyed",function(a,b){var c;b.pager&&b.pagerTemplate&&(c=b.API.getComponent("pager"),c.empty())})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{next:"> .cycle-next",nextEvent:"click.cycle",disabledClass:"disabled",prev:"> .cycle-prev",prevEvent:"click.cycle",swipe:!1}),a(document).on("cycle-initialized",function(a,b){b.API.getComponent("next").off(b.nextEvent).on(b.nextEvent,function(a){a.preventDefault(),b.API.next()}),b.API.getComponent("prev").off(b.prevEvent).on(b.prevEvent,function(a){a.preventDefault(),b.API.prev()}),b.swipe&&(b.container.on("swipeleft.cycle",function(){b.API.next()}),b.container.on("swiperight.cycle",function(){b.API.prev()}))}),a(document).on("cycle-update-view",function(a,b,c,d){if(b.allowWrap)return;var e=b.disabledClass,f=b.API.getComponent("next"),g=b.API.getComponent("prev"),h=b._prevBoundry||0,i=b._nextBoundry||b.slideCount-1;b.currSlide==i?f.addClass(e).prop("disabled",!0):f.removeClass(e).prop("disabled",!1),b.currSlide===h?g.addClass(e).prop("disabled",!0):g.removeClass(e).prop("disabled",!1)}),a(document).on("cycle-destroyed",function(b,c){a(c.next).off(c.nextEvent),a(c.prev).off(c.prevEvent),c.container.off("swipeleft.cycle swiperight.cycle")})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.defaults,{progressive:!1}),a(document).on("cycle-pre-initialize",function(b,c){if(!c.progressive)return;var d=c.API,e=d.next,f=d.prev,g=d.prepareTx,h,i=a.type(c.progressive);if(i=="array")h=c.progressive;else if(a.isFunction(c.progressive))h=c.progressive(c);else if(i=="string"){h=a(c.progressive).html();if(!a.trim(h))return;try{h=a.parseJSON(h)}catch(j){d.log("error parsing progressive slides",j);return}}g&&(d.prepareTx=function(a,b){var d,e;if(a||h.length===0){g.apply(c.API,[a,b]);return}b&&c.currSlide==c.slideCount-1?(e=h[0],h=h.slice(1),c.container.one("cycle-slide-added",function(a,b){b.API.advanceSlide(1)}),c.API.add(e)):!b&&c.currSlide===0?(d=h.length-1,e=h[d],h=h.slice(0,d),c.container.one("cycle-slide-added",function(a,b){b.currSlide=1,b.API.advanceSlide(-1)}),c.API.add(e,!0)):g.apply(c.API,[a,b])}),e&&(d.next=function(){var a=this.opts();if(h.length&&a.currSlide==a.slideCount-1){var b=h[0];h=h.slice(1),a.container.one("cycle-slide-added",function(a,b){e.apply(b.API),b.container.removeClass("cycle-loading")}),a.container.addClass("cycle-loading"),a.API.add(b)}else e.apply(a.API)}),f&&(d.prev=function(){var a=this.opts();if(h.length&&a.currSlide===0){var b=h.length-1,c=h[b];h=h.slice(0,b),a.container.one("cycle-slide-added",function(a,b){b.currSlide=1,b.API.advanceSlide(-1),b.container.removeClass("cycle-loading")}),a.container.addClass("cycle-loading"),a.API.add(c,!0)}else f.apply(a.API)})})}(jQuery),function(a){"use strict",a.extend(a.fn.cycle.API,{tmpl:function(b,c,d){if(b&&c)return b.replace(/\{\{((\.)?.*?)\}\}/g,function(b,e){var f,g,h=c,i=e.split(".");if(i.length>1){g=c;for(f=0;f<i.length;f++)h=g,g=g[i[f]]||e}else g=c[e];return a.isFunction(g)?g.call(h,c):g!==undefined&&g!==null?g:d&&d[e]!==undefined?d[e]:e})}})}(jQuery);
|
js/jquery.cycle2.tile.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: BETA-20120923 */
|
2 |
(function(a){"use strict",a.fn.cycle.transitions.tileSlide=a.fn.cycle.transitions.tileBlind={before:function(b,c,d,e){b.API.stackSlides(c,d,e),a(c).show(),b.container.css("overflow","hidden"),b.tileDelay=b.tileDelay||b.fx=="tileSlide"?100:125,b.tileCount=b.tileCount||7,b.tileVertical=b.tileVertical!==!1,b.container.data("cycleTileInitialized")||(b.container.on("cycle-destroyed",this.onDestroy),b.container.data("cycleTileInitialized",!0))},transition:function(b,c,d,e,f){function w(a){g.eq(a).animate(s,{duration:b.speed,easing:b.easing,complete:function(){(e?o-1===a:0===a)&&b._tileAniCallback()}}),setTimeout(function(){(e?o-1!==a:0!==a)&&w(e?a+1:a-1)},b.tileDelay)}b.slides.not(c).not(d).hide();var g=a(),h=a(c),i=a(d),j,k,l,m,n,o=b.tileCount,p=b.tileVertical,q=b.container.height(),r=b.container.width();p?(k=Math.floor(r/o),m=r-k*(o-1),l=n=q):(k=m=r,l=Math.floor(q/o),n=q-l*(o-1)),b.container.find(".cycle-tiles-container").remove();var s,t={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};p?s=b.fx=="tileSlide"?{top:q}:{width:0}:s=b.fx=="tileSlide"?{left:r}:{height:0};var u=a('<div class="cycle-tiles-container"></div>');u.css({zIndex:h.css("z-index"),overflow:"visible",position:"absolute",top:0}),u.insertBefore(d);for(var v=0;v<o;v++)j=a("<div></div>").css(t).css({width:o-1===v?m:k,height:o-1===v?n:l,marginLeft:p?v*k:0,marginTop:p?0:v*l}).append(h.clone().css({position:"relative",maxWidth:"none",width:h.width(),margin:0,padding:0,marginLeft:p?-(v*k):0,marginTop:p?0:-(v*l)})),g=g.add(j);u.append(g),h.hide(),i.show().css("opacity",1),w(e?0:o-1),b._tileAniCallback=function(){i.show(),h.hide(),u.remove(),f()}},stopTransition:function(a){a.container.find("*").stop(!0,!0),a._tileAniCallback&&a._tileAniCallback()},onDestroy:function(a){var b=this.opts();b.container.find(".cycle-tiles-container").remove()}}})(jQuery);
|
1 |
+
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: BETA-20120923 */
|
2 |
(function(a){"use strict",a.fn.cycle.transitions.tileSlide=a.fn.cycle.transitions.tileBlind={before:function(b,c,d,e){b.API.stackSlides(c,d,e),a(c).show(),b.container.css("overflow","hidden"),b.tileDelay=b.tileDelay||b.fx=="tileSlide"?100:125,b.tileCount=b.tileCount||7,b.tileVertical=b.tileVertical!==!1,b.container.data("cycleTileInitialized")||(b.container.on("cycle-destroyed",this.onDestroy),b.container.data("cycleTileInitialized",!0))},transition:function(b,c,d,e,f){function w(a){g.eq(a).animate(s,{duration:b.speed,easing:b.easing,complete:function(){(e?o-1===a:0===a)&&b._tileAniCallback()}}),setTimeout(function(){(e?o-1!==a:0!==a)&&w(e?a+1:a-1)},b.tileDelay)}b.slides.not(c).not(d).hide();var g=a(),h=a(c),i=a(d),j,k,l,m,n,o=b.tileCount,p=b.tileVertical,q=b.container.height(),r=b.container.width();p?(k=Math.floor(r/o),m=r-k*(o-1),l=n=q):(k=m=r,l=Math.floor(q/o),n=q-l*(o-1)),b.container.find(".cycle-tiles-container").remove();var s,t={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};p?s=b.fx=="tileSlide"?{top:q}:{width:0}:s=b.fx=="tileSlide"?{left:r}:{height:0};var u=a('<div class="cycle-tiles-container"></div>');u.css({zIndex:h.css("z-index"),overflow:"visible",position:"absolute",top:0}),u.insertBefore(d);for(var v=0;v<o;v++)j=a("<div></div>").css(t).css({width:o-1===v?m:k,height:o-1===v?n:l,marginLeft:p?v*k:0,marginTop:p?0:v*l}).append(h.clone().css({position:"relative",maxWidth:"none",width:h.width(),margin:0,padding:0,marginLeft:p?-(v*k):0,marginTop:p?0:-(v*l)})),g=g.add(j);u.append(g),h.hide(),i.show().css("opacity",1),w(e?0:o-1),b._tileAniCallback=function(){i.show(),h.hide(),u.remove(),f()}},stopTransition:function(a){a.container.find("*").stop(!0,!0),a._tileAniCallback&&a._tileAniCallback()},onDestroy:function(a){var b=this.opts();b.container.find(".cycle-tiles-container").remove()}}})(jQuery);
|