Version Description
- UPD: Update Cherry Framework up to 1.1.1
Download this release
Release Info
Developer | TemplateMonster 2002 |
Plugin | Cherry Sidebars |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- admin/includes/class-cherry-custom-sidebar.php +253 -253
- admin/includes/class-cherry-sidebar-utils.php +80 -80
- admin/includes/class-cherry-sidebars-admin.php +147 -147
- cherry-framework/.gitignore +0 -30
- cherry-framework/cherry-core.php +481 -481
- cherry-framework/codesniffer.ruleset.xml +0 -24
- cherry-framework/config.json +189 -189
- cherry-framework/modules/cherry-js-core/assets/js/cherry-js-core.js +155 -170
- cherry-framework/modules/cherry-js-core/assets/js/min/cherry-js-core.min.js +1 -1
- cherry-framework/modules/cherry-js-core/cherry-js-core.php +184 -184
- cherry-framework/modules/cherry-ui-elements/cherry-ui-elements.php +152 -152
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-checkbox/assets/ui-checkbox.js +74 -73
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-colorpicker/assets/min/ui-colorpicker.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-colorpicker/assets/ui-colorpicker.js +25 -24
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/jquery-iconpicker.js +1445 -0
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/min/jquery-iconpicker.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/min/ui-iconpicker.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/ui-iconpicker.js +47 -37
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/ui-iconpicker.php +293 -279
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-media/assets/min/ui-media.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-media/assets/ui-media.js +159 -158
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-radio/assets/min/ui-radio.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-radio/assets/ui-radio.js +53 -52
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-repeater/assets/min/ui-repeater.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-repeater/assets/ui-repeater.js +174 -174
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-select/assets/min/ui-select.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-select/assets/ui-select.js +29 -28
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-slider/assets/min/ui-slider.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-slider/assets/ui-slider.js +25 -25
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/assets/min/ui-switcher.min.js +1 -1
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/assets/ui-switcher.js +57 -60
- cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/ui-switcher.php +110 -107
- cherry-sidebars.php +8 -4
- includes/class-cherry-include-sidebars.php +97 -97
- readme.txt +14 -4
admin/includes/class-cherry-custom-sidebar.php
CHANGED
@@ -1,253 +1,253 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for render and saving custom sidebars.
|
4 |
-
*
|
5 |
-
* @package Cherry_Sidebars
|
6 |
-
* @author Template Monster
|
7 |
-
* @license GPL-3.0+
|
8 |
-
* @copyright 2002-2016, Template Monster
|
9 |
-
*/
|
10 |
-
|
11 |
-
// If this file is called directly, abort.
|
12 |
-
if ( ! defined( 'WPINC' ) ) {
|
13 |
-
die;
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( ! class_exists( 'Cherry_Custom_Sidebar' ) ) {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Class for render and saving custom sidebars.
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
*/
|
23 |
-
class Cherry_Custom_Sidebar {
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Holds the instances of this class.
|
27 |
-
*
|
28 |
-
* @since 1.0.0
|
29 |
-
* @var object
|
30 |
-
*/
|
31 |
-
private static $instance = null;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Sets up the needed actions for adding and saving the meta boxes.
|
35 |
-
*
|
36 |
-
* @since 1.0.0
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
-
|
40 |
-
// Add the `Layout` meta box on the 'add_meta_boxes' hook.
|
41 |
-
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 );
|
42 |
-
|
43 |
-
// Saves the post format on the post editing page.
|
44 |
-
add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
|
45 |
-
|
46 |
-
// Registrate dynamic sidebar
|
47 |
-
add_action( 'register_sidebar', array( $this, 'register_dynamic_sidebar' ) );
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Adds the meta box if the post type supports 'cherry-post-style' and the current user has
|
52 |
-
* permission to edit post meta.
|
53 |
-
*
|
54 |
-
* @since 1.0.0
|
55 |
-
* @param string $post_type The post type of the current post being edited.
|
56 |
-
* @param object $post The current post object.
|
57 |
-
* @return void
|
58 |
-
*/
|
59 |
-
public function add_meta_boxes( $post_type, $post ) {
|
60 |
-
|
61 |
-
cherry_sidebars()->init_modules();
|
62 |
-
|
63 |
-
$allowed_post_types = apply_filters(
|
64 |
-
'cherry_sidebar_post_type',
|
65 |
-
array(
|
66 |
-
'page',
|
67 |
-
'post',
|
68 |
-
'portfolio',
|
69 |
-
'testimonial',
|
70 |
-
'service',
|
71 |
-
'team',
|
72 |
-
'product',
|
73 |
-
)
|
74 |
-
);
|
75 |
-
|
76 |
-
if ( in_array( $post_type, $allowed_post_types )
|
77 |
-
&& ( current_user_can( 'edit_post_meta', $post->ID )
|
78 |
-
|| current_user_can( 'add_post_meta', $post->ID )
|
79 |
-
|| current_user_can( 'delete_post_meta', $post->ID ) )
|
80 |
-
) {
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Filter the array of 'add_meta_box' parametrs.
|
84 |
-
*
|
85 |
-
* @since 1.0.0
|
86 |
-
*/
|
87 |
-
$metabox = apply_filters( 'cherry_custom_sidebar', array(
|
88 |
-
'id' => 'cherry-sidebars',
|
89 |
-
'title' => __( 'Post Sidebars', 'cherry' ),
|
90 |
-
'page' => $post_type,
|
91 |
-
'context' => 'side',
|
92 |
-
'priority' => 'default',
|
93 |
-
'callback_args' => false,
|
94 |
-
) );
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Add meta box to the administrative interface.
|
98 |
-
*
|
99 |
-
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
|
100 |
-
*/
|
101 |
-
add_meta_box(
|
102 |
-
$metabox['id'],
|
103 |
-
$metabox['title'],
|
104 |
-
array( $this, 'callback_metabox' ),
|
105 |
-
$metabox['page'],
|
106 |
-
$metabox['context'],
|
107 |
-
$metabox['priority'],
|
108 |
-
$metabox['callback_args']
|
109 |
-
);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Displays a meta box of radio selectors on the post editing screen, which allows theme users to select
|
115 |
-
* the layout they wish to use for the specific post.
|
116 |
-
*
|
117 |
-
* @since 1.0.0
|
118 |
-
* @param object $post The post object currently being edited.
|
119 |
-
* @param array $metabox Specific information about the meta box being loaded.
|
120 |
-
* @return void
|
121 |
-
*/
|
122 |
-
public function callback_metabox( $post, $metabox ) {
|
123 |
-
cherry_sidebars()->init_modules();
|
124 |
-
wp_nonce_field( basename( __FILE__ ), 'cherry-sidebar-nonce' );
|
125 |
-
|
126 |
-
global $wp_registered_sidebars;
|
127 |
-
|
128 |
-
$select_sidebar = $this->get_post_sidebar( $post->ID );
|
129 |
-
$select_options = array( '' => __( 'Sidebar not selected', 'cherry-sidebars' ) );
|
130 |
-
|
131 |
-
foreach ( $wp_registered_sidebars as $sidebar => $sidebar_value ) {
|
132 |
-
$select_options[ $sidebar_value['id'] ] = $sidebar_value['name'];
|
133 |
-
}
|
134 |
-
|
135 |
-
foreach ( $wp_registered_sidebars as $sidebar => $sidebar_value ) {
|
136 |
-
if ( array_key_exists( 'dynamic-sidebar',$sidebar_value ) ) {
|
137 |
-
continue;
|
138 |
-
}
|
139 |
-
|
140 |
-
if ( array_key_exists( 'is_global',$sidebar_value ) && false === $sidebar_value['is_global'] ) {
|
141 |
-
continue;
|
142 |
-
}
|
143 |
-
|
144 |
-
$output = '<p><strong>' . $sidebar_value['name'] . '</strong></p>';
|
145 |
-
|
146 |
-
$value = ( is_array( $select_sidebar ) && array_key_exists( $sidebar_value['id'], $select_sidebar ) ) ? $select_sidebar[ $sidebar_value['id'] ] : '' ;
|
147 |
-
|
148 |
-
$ui_select = new UI_Select(
|
149 |
-
array(
|
150 |
-
'id' => $sidebar_value['id'],
|
151 |
-
'name' => 'theme_sidebar[' . $sidebar_value['id'] . ']',
|
152 |
-
'value' => $value,
|
153 |
-
'options' => $select_options,
|
154 |
-
|
155 |
-
)
|
156 |
-
);
|
157 |
-
|
158 |
-
$output .= $ui_select->render();
|
159 |
-
|
160 |
-
echo $output;
|
161 |
-
};
|
162 |
-
|
163 |
-
?>
|
164 |
-
<p class="howto">
|
165 |
-
<?php printf(
|
166 |
-
__( 'You can choose page sidebars or create a new sidebar on %swidgets page%s .', 'cherry-sidebars' ),
|
167 |
-
'<a href="widgets.php" target="_blank" title="' . __( 'Widgets Page', 'cherry-sidebars' ) . '">',
|
168 |
-
'</a>'
|
169 |
-
); ?>
|
170 |
-
</p>
|
171 |
-
<?php
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Register dynamic sidebar.
|
176 |
-
*
|
177 |
-
* @since 1.0.0
|
178 |
-
* @return void
|
179 |
-
*/
|
180 |
-
public function register_dynamic_sidebar() {
|
181 |
-
global $wp_registered_sidebars;
|
182 |
-
|
183 |
-
$instance = new Cherry_Sidebar_Utils();
|
184 |
-
$cusotm_sidebar_array = $instance->get_custom_sidebar_array();
|
185 |
-
|
186 |
-
unset( $cusotm_sidebar_array['cherry-sidebars-counter'] );
|
187 |
-
$wp_registered_sidebars = array_merge( $wp_registered_sidebars, $cusotm_sidebar_array );
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Saves the post style metadata if on the post editing screen in the admin.
|
192 |
-
*
|
193 |
-
* @since 1.0.0
|
194 |
-
* @param int $post_id The ID of the current post being saved.
|
195 |
-
* @param object $post The post object currently being saved.
|
196 |
-
* @return void|int
|
197 |
-
*/
|
198 |
-
public function save_post( $post_id, $post = '' ) {
|
199 |
-
|
200 |
-
if ( ! is_object( $post ) ) {
|
201 |
-
$post = get_post();
|
202 |
-
}
|
203 |
-
|
204 |
-
// Verify the nonce for the post formats meta box.
|
205 |
-
if ( ! isset( $_POST['cherry-sidebar-nonce'] )
|
206 |
-
|| ! wp_verify_nonce( $_POST['cherry-sidebar-nonce'], basename( __FILE__ ) )
|
207 |
-
) {
|
208 |
-
return $post_id;
|
209 |
-
}
|
210 |
-
|
211 |
-
// Get the meta key.
|
212 |
-
$meta_key = 'post_sidebar';
|
213 |
-
|
214 |
-
// Get the all submitted `page-sidebar-manager` data.
|
215 |
-
$sidebar_id = $_POST['theme_sidebar'];
|
216 |
-
|
217 |
-
update_post_meta( $post_id, $meta_key, $sidebar_id );
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Function get post or page sidebar.
|
222 |
-
*
|
223 |
-
* @since 1.0.0
|
224 |
-
* @param int $post_id The ID of the current post being saved.
|
225 |
-
* @return string $post_sidebar Sidebar id value.
|
226 |
-
*/
|
227 |
-
public function get_post_sidebar( $post_id ) {
|
228 |
-
|
229 |
-
// Get the $post_sidebar.
|
230 |
-
$post_sidebar = get_post_meta( $post_id, 'post_sidebar', true );
|
231 |
-
|
232 |
-
return $post_sidebar;
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* Returns the instance.
|
237 |
-
*
|
238 |
-
* @since 1.0.0
|
239 |
-
* @return object
|
240 |
-
*/
|
241 |
-
public static function get_instance() {
|
242 |
-
|
243 |
-
// If the single instance hasn't been set, set it now.
|
244 |
-
if ( null == self::$instance ) {
|
245 |
-
self::$instance = new self;
|
246 |
-
}
|
247 |
-
|
248 |
-
return self::$instance;
|
249 |
-
}
|
250 |
-
}
|
251 |
-
|
252 |
-
Cherry_Custom_Sidebar::get_instance();
|
253 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for render and saving custom sidebars.
|
4 |
+
*
|
5 |
+
* @package Cherry_Sidebars
|
6 |
+
* @author Template Monster
|
7 |
+
* @license GPL-3.0+
|
8 |
+
* @copyright 2002-2016, Template Monster
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If this file is called directly, abort.
|
12 |
+
if ( ! defined( 'WPINC' ) ) {
|
13 |
+
die;
|
14 |
+
}
|
15 |
+
|
16 |
+
if ( ! class_exists( 'Cherry_Custom_Sidebar' ) ) {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Class for render and saving custom sidebars.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
*/
|
23 |
+
class Cherry_Custom_Sidebar {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Holds the instances of this class.
|
27 |
+
*
|
28 |
+
* @since 1.0.0
|
29 |
+
* @var object
|
30 |
+
*/
|
31 |
+
private static $instance = null;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Sets up the needed actions for adding and saving the meta boxes.
|
35 |
+
*
|
36 |
+
* @since 1.0.0
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
|
40 |
+
// Add the `Layout` meta box on the 'add_meta_boxes' hook.
|
41 |
+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 );
|
42 |
+
|
43 |
+
// Saves the post format on the post editing page.
|
44 |
+
add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
|
45 |
+
|
46 |
+
// Registrate dynamic sidebar
|
47 |
+
add_action( 'register_sidebar', array( $this, 'register_dynamic_sidebar' ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Adds the meta box if the post type supports 'cherry-post-style' and the current user has
|
52 |
+
* permission to edit post meta.
|
53 |
+
*
|
54 |
+
* @since 1.0.0
|
55 |
+
* @param string $post_type The post type of the current post being edited.
|
56 |
+
* @param object $post The current post object.
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
public function add_meta_boxes( $post_type, $post ) {
|
60 |
+
|
61 |
+
cherry_sidebars()->init_modules();
|
62 |
+
|
63 |
+
$allowed_post_types = apply_filters(
|
64 |
+
'cherry_sidebar_post_type',
|
65 |
+
array(
|
66 |
+
'page',
|
67 |
+
'post',
|
68 |
+
'portfolio',
|
69 |
+
'testimonial',
|
70 |
+
'service',
|
71 |
+
'team',
|
72 |
+
'product',
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
if ( in_array( $post_type, $allowed_post_types )
|
77 |
+
&& ( current_user_can( 'edit_post_meta', $post->ID )
|
78 |
+
|| current_user_can( 'add_post_meta', $post->ID )
|
79 |
+
|| current_user_can( 'delete_post_meta', $post->ID ) )
|
80 |
+
) {
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Filter the array of 'add_meta_box' parametrs.
|
84 |
+
*
|
85 |
+
* @since 1.0.0
|
86 |
+
*/
|
87 |
+
$metabox = apply_filters( 'cherry_custom_sidebar', array(
|
88 |
+
'id' => 'cherry-sidebars',
|
89 |
+
'title' => __( 'Post Sidebars', 'cherry' ),
|
90 |
+
'page' => $post_type,
|
91 |
+
'context' => 'side',
|
92 |
+
'priority' => 'default',
|
93 |
+
'callback_args' => false,
|
94 |
+
) );
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Add meta box to the administrative interface.
|
98 |
+
*
|
99 |
+
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
|
100 |
+
*/
|
101 |
+
add_meta_box(
|
102 |
+
$metabox['id'],
|
103 |
+
$metabox['title'],
|
104 |
+
array( $this, 'callback_metabox' ),
|
105 |
+
$metabox['page'],
|
106 |
+
$metabox['context'],
|
107 |
+
$metabox['priority'],
|
108 |
+
$metabox['callback_args']
|
109 |
+
);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Displays a meta box of radio selectors on the post editing screen, which allows theme users to select
|
115 |
+
* the layout they wish to use for the specific post.
|
116 |
+
*
|
117 |
+
* @since 1.0.0
|
118 |
+
* @param object $post The post object currently being edited.
|
119 |
+
* @param array $metabox Specific information about the meta box being loaded.
|
120 |
+
* @return void
|
121 |
+
*/
|
122 |
+
public function callback_metabox( $post, $metabox ) {
|
123 |
+
cherry_sidebars()->init_modules();
|
124 |
+
wp_nonce_field( basename( __FILE__ ), 'cherry-sidebar-nonce' );
|
125 |
+
|
126 |
+
global $wp_registered_sidebars;
|
127 |
+
|
128 |
+
$select_sidebar = $this->get_post_sidebar( $post->ID );
|
129 |
+
$select_options = array( '' => __( 'Sidebar not selected', 'cherry-sidebars' ) );
|
130 |
+
|
131 |
+
foreach ( $wp_registered_sidebars as $sidebar => $sidebar_value ) {
|
132 |
+
$select_options[ $sidebar_value['id'] ] = $sidebar_value['name'];
|
133 |
+
}
|
134 |
+
|
135 |
+
foreach ( $wp_registered_sidebars as $sidebar => $sidebar_value ) {
|
136 |
+
if ( array_key_exists( 'dynamic-sidebar',$sidebar_value ) ) {
|
137 |
+
continue;
|
138 |
+
}
|
139 |
+
|
140 |
+
if ( array_key_exists( 'is_global',$sidebar_value ) && false === $sidebar_value['is_global'] ) {
|
141 |
+
continue;
|
142 |
+
}
|
143 |
+
|
144 |
+
$output = '<p><strong>' . $sidebar_value['name'] . '</strong></p>';
|
145 |
+
|
146 |
+
$value = ( is_array( $select_sidebar ) && array_key_exists( $sidebar_value['id'], $select_sidebar ) ) ? $select_sidebar[ $sidebar_value['id'] ] : '' ;
|
147 |
+
|
148 |
+
$ui_select = new UI_Select(
|
149 |
+
array(
|
150 |
+
'id' => $sidebar_value['id'],
|
151 |
+
'name' => 'theme_sidebar[' . $sidebar_value['id'] . ']',
|
152 |
+
'value' => $value,
|
153 |
+
'options' => $select_options,
|
154 |
+
|
155 |
+
)
|
156 |
+
);
|
157 |
+
|
158 |
+
$output .= $ui_select->render();
|
159 |
+
|
160 |
+
echo $output;
|
161 |
+
};
|
162 |
+
|
163 |
+
?>
|
164 |
+
<p class="howto">
|
165 |
+
<?php printf(
|
166 |
+
__( 'You can choose page sidebars or create a new sidebar on %swidgets page%s .', 'cherry-sidebars' ),
|
167 |
+
'<a href="widgets.php" target="_blank" title="' . __( 'Widgets Page', 'cherry-sidebars' ) . '">',
|
168 |
+
'</a>'
|
169 |
+
); ?>
|
170 |
+
</p>
|
171 |
+
<?php
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Register dynamic sidebar.
|
176 |
+
*
|
177 |
+
* @since 1.0.0
|
178 |
+
* @return void
|
179 |
+
*/
|
180 |
+
public function register_dynamic_sidebar() {
|
181 |
+
global $wp_registered_sidebars;
|
182 |
+
|
183 |
+
$instance = new Cherry_Sidebar_Utils();
|
184 |
+
$cusotm_sidebar_array = $instance->get_custom_sidebar_array();
|
185 |
+
|
186 |
+
unset( $cusotm_sidebar_array['cherry-sidebars-counter'] );
|
187 |
+
$wp_registered_sidebars = array_merge( $wp_registered_sidebars, $cusotm_sidebar_array );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Saves the post style metadata if on the post editing screen in the admin.
|
192 |
+
*
|
193 |
+
* @since 1.0.0
|
194 |
+
* @param int $post_id The ID of the current post being saved.
|
195 |
+
* @param object $post The post object currently being saved.
|
196 |
+
* @return void|int
|
197 |
+
*/
|
198 |
+
public function save_post( $post_id, $post = '' ) {
|
199 |
+
|
200 |
+
if ( ! is_object( $post ) ) {
|
201 |
+
$post = get_post();
|
202 |
+
}
|
203 |
+
|
204 |
+
// Verify the nonce for the post formats meta box.
|
205 |
+
if ( ! isset( $_POST['cherry-sidebar-nonce'] )
|
206 |
+
|| ! wp_verify_nonce( $_POST['cherry-sidebar-nonce'], basename( __FILE__ ) )
|
207 |
+
) {
|
208 |
+
return $post_id;
|
209 |
+
}
|
210 |
+
|
211 |
+
// Get the meta key.
|
212 |
+
$meta_key = 'post_sidebar';
|
213 |
+
|
214 |
+
// Get the all submitted `page-sidebar-manager` data.
|
215 |
+
$sidebar_id = $_POST['theme_sidebar'];
|
216 |
+
|
217 |
+
update_post_meta( $post_id, $meta_key, $sidebar_id );
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Function get post or page sidebar.
|
222 |
+
*
|
223 |
+
* @since 1.0.0
|
224 |
+
* @param int $post_id The ID of the current post being saved.
|
225 |
+
* @return string $post_sidebar Sidebar id value.
|
226 |
+
*/
|
227 |
+
public function get_post_sidebar( $post_id ) {
|
228 |
+
|
229 |
+
// Get the $post_sidebar.
|
230 |
+
$post_sidebar = get_post_meta( $post_id, 'post_sidebar', true );
|
231 |
+
|
232 |
+
return $post_sidebar;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Returns the instance.
|
237 |
+
*
|
238 |
+
* @since 1.0.0
|
239 |
+
* @return object
|
240 |
+
*/
|
241 |
+
public static function get_instance() {
|
242 |
+
|
243 |
+
// If the single instance hasn't been set, set it now.
|
244 |
+
if ( null == self::$instance ) {
|
245 |
+
self::$instance = new self;
|
246 |
+
}
|
247 |
+
|
248 |
+
return self::$instance;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
Cherry_Custom_Sidebar::get_instance();
|
253 |
+
}
|
admin/includes/class-cherry-sidebar-utils.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Cherry Sidebar Utils.
|
4 |
-
*
|
5 |
-
* @package Cherry_Sidebars
|
6 |
-
* @author Template Monster
|
7 |
-
* @license GPL-3.0+
|
8 |
-
* @copyright 2002-2016, Template Monster
|
9 |
-
*/
|
10 |
-
|
11 |
-
// If this file is called directly, abort.
|
12 |
-
if ( ! defined( 'WPINC' ) ) {
|
13 |
-
die();
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( ! class_exists( 'Cherry_Sidebar_Utils' ) ) {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Cherry Sidebar Utils.
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
*/
|
23 |
-
class Cherry_Sidebar_Utils {
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Current theme name.
|
27 |
-
*
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
public $current_theme;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Current sidebars theme settings.
|
34 |
-
*
|
35 |
-
* @var array
|
36 |
-
*/
|
37 |
-
public $get_theme_option;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Sets up our actions/filters or another settings.
|
41 |
-
*
|
42 |
-
* @since 1.0.0
|
43 |
-
*/
|
44 |
-
function __construct() {
|
45 |
-
$this->current_theme = wp_get_theme();
|
46 |
-
$this->get_theme_option = get_option( $this->current_theme . '_sidebars', array() );
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Get current sidebars theme settings.
|
51 |
-
*
|
52 |
-
* @since 1.0.0
|
53 |
-
* @return array Current sidebar settings.
|
54 |
-
*/
|
55 |
-
public function get_custom_sidebar_array() {
|
56 |
-
|
57 |
-
if ( ! is_array( $this->get_theme_option ) || ! array_key_exists( 'custom_sidebar', $this->get_theme_option ) ) {
|
58 |
-
$custom_sidebar_array = array();
|
59 |
-
} else {
|
60 |
-
$custom_sidebar_array = $this->get_theme_option['custom_sidebar'];
|
61 |
-
}
|
62 |
-
|
63 |
-
return $custom_sidebar_array;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Updated custom sidebars array and save to database.
|
68 |
-
*
|
69 |
-
* @since 1.0.0
|
70 |
-
* @param array $new_custom_sidebar_array New theme sidebar settings.
|
71 |
-
* @return void
|
72 |
-
*/
|
73 |
-
public function set_custom_sidebar_array( $new_custom_sidebar_array ) {
|
74 |
-
|
75 |
-
$this->get_theme_option['custom_sidebar'] = $new_custom_sidebar_array;
|
76 |
-
|
77 |
-
update_option( $this->current_theme . '_sidebars', $this->get_theme_option );
|
78 |
-
}
|
79 |
-
}
|
80 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cherry Sidebar Utils.
|
4 |
+
*
|
5 |
+
* @package Cherry_Sidebars
|
6 |
+
* @author Template Monster
|
7 |
+
* @license GPL-3.0+
|
8 |
+
* @copyright 2002-2016, Template Monster
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If this file is called directly, abort.
|
12 |
+
if ( ! defined( 'WPINC' ) ) {
|
13 |
+
die();
|
14 |
+
}
|
15 |
+
|
16 |
+
if ( ! class_exists( 'Cherry_Sidebar_Utils' ) ) {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Cherry Sidebar Utils.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
*/
|
23 |
+
class Cherry_Sidebar_Utils {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Current theme name.
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $current_theme;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Current sidebars theme settings.
|
34 |
+
*
|
35 |
+
* @var array
|
36 |
+
*/
|
37 |
+
public $get_theme_option;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Sets up our actions/filters or another settings.
|
41 |
+
*
|
42 |
+
* @since 1.0.0
|
43 |
+
*/
|
44 |
+
function __construct() {
|
45 |
+
$this->current_theme = wp_get_theme();
|
46 |
+
$this->get_theme_option = get_option( $this->current_theme->get_stylesheet() . '_sidebars', array() );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get current sidebars theme settings.
|
51 |
+
*
|
52 |
+
* @since 1.0.0
|
53 |
+
* @return array Current sidebar settings.
|
54 |
+
*/
|
55 |
+
public function get_custom_sidebar_array() {
|
56 |
+
|
57 |
+
if ( ! is_array( $this->get_theme_option ) || ! array_key_exists( 'custom_sidebar', $this->get_theme_option ) ) {
|
58 |
+
$custom_sidebar_array = array();
|
59 |
+
} else {
|
60 |
+
$custom_sidebar_array = $this->get_theme_option['custom_sidebar'];
|
61 |
+
}
|
62 |
+
|
63 |
+
return $custom_sidebar_array;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Updated custom sidebars array and save to database.
|
68 |
+
*
|
69 |
+
* @since 1.0.0
|
70 |
+
* @param array $new_custom_sidebar_array New theme sidebar settings.
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
public function set_custom_sidebar_array( $new_custom_sidebar_array ) {
|
74 |
+
|
75 |
+
$this->get_theme_option['custom_sidebar'] = $new_custom_sidebar_array;
|
76 |
+
|
77 |
+
update_option( $this->current_theme->get_stylesheet() . '_sidebars', $this->get_theme_option );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
admin/includes/class-cherry-sidebars-admin.php
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Sets up the admin functionality for the plugin.
|
4 |
-
*
|
5 |
-
* @package Cherry_Sidebars
|
6 |
-
* @author Template Monster
|
7 |
-
* @license GPL-3.0+
|
8 |
-
* @copyright 2002-2016, Template Monster
|
9 |
-
*/
|
10 |
-
|
11 |
-
// If this file is called directly, abort.
|
12 |
-
if ( ! defined( 'WPINC' ) ) {
|
13 |
-
die();
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Class for admin functionally.
|
18 |
-
*
|
19 |
-
* @since 1.0.0
|
20 |
-
*/
|
21 |
-
class Cherry_Sidebars_Admin {
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Holds the instances of this class.
|
25 |
-
*
|
26 |
-
* @since 1.0.0
|
27 |
-
* @var object
|
28 |
-
*/
|
29 |
-
private static $instance = null;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Sets up needed actions/filters for the admin to initialize.
|
33 |
-
*
|
34 |
-
* @since 1.0.0
|
35 |
-
* @return void
|
36 |
-
*/
|
37 |
-
public function __construct() {
|
38 |
-
|
39 |
-
// Load admin javascript and stylesheet.
|
40 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_assets' ), 1 );
|
41 |
-
|
42 |
-
add_action( 'after_setup_theme', array( $this, 'widgets_ajax_page' ), 10 );
|
43 |
-
add_action( 'sidebar_admin_setup', array( $this, 'registrates_custom_sidebar' ), 10 );
|
44 |
-
add_action( 'widgets_admin_page', array( $this, 'edit_wp_registered_sidebars' ), 10 );
|
45 |
-
add_action( 'sidebar_admin_page', array( $this, 'widgets_page' ), 10 );
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Register and Enqueue admin-specific stylesheet and javascript.
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
* @param string $hook_suffix Hook suffix.
|
53 |
-
* @return void
|
54 |
-
*/
|
55 |
-
public function add_admin_assets( $hook_suffix ) {
|
56 |
-
|
57 |
-
if ( 'widgets.php' === $hook_suffix ) {
|
58 |
-
wp_register_script( 'cherry_admin_sidebars_js', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/js/min/cherry-admin-sidebars.min.js', array( 'jquery' ), CHERRY_SIDEBARS_VERSION, true );
|
59 |
-
wp_register_style( 'cherry_admin_sidebars_css', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/cherry-admin-sidebars.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
60 |
-
|
61 |
-
wp_register_style( 'interface-builder', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/interface-builder.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
62 |
-
|
63 |
-
$cherry_framework_object = array( 'ajax_nonce_new_sidebar' => wp_create_nonce( 'new_custom_sidebar' ) , 'ajax_nonce_remove_sidebar' => wp_create_nonce( 'remove_custom_sidebar' ) );
|
64 |
-
wp_localize_script( 'cherry_admin_sidebars_js', 'cherryFramework', $cherry_framework_object );
|
65 |
-
|
66 |
-
wp_enqueue_script( 'cherry_admin_sidebars_js' );
|
67 |
-
wp_enqueue_style( 'cherry_admin_sidebars_css' );
|
68 |
-
wp_enqueue_style( 'interface-builder' );
|
69 |
-
|
70 |
-
} elseif ( false !== strpos( $hook_suffix, 'post' ) ) {
|
71 |
-
wp_register_style( 'cherry-sidebars-post-page', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/cherry-sidebars-post-page.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
72 |
-
wp_enqueue_style( 'cherry-sidebars-post-page' );
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Returns the instance.
|
78 |
-
*
|
79 |
-
* @since 1.0.0
|
80 |
-
*/
|
81 |
-
public function widgets_page() {
|
82 |
-
cherry_sidebars()->init_modules();
|
83 |
-
require_once( trailingslashit( CHERRY_SIDEBARS_DIR ) . 'admin/views/cherry-widgets-page.php' );
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Registration new custom sidebars.
|
88 |
-
*
|
89 |
-
* @since 1.0.0
|
90 |
-
* @return void
|
91 |
-
*/
|
92 |
-
public function registrates_custom_sidebar() {
|
93 |
-
global $wp_registered_sidebars;
|
94 |
-
|
95 |
-
$instance = new Cherry_Sidebar_Utils();
|
96 |
-
$sidebars_array = $instance->get_custom_sidebar_array();
|
97 |
-
unset( $sidebars_array['cherry-sidebars-counter'] );
|
98 |
-
|
99 |
-
$wp_registered_sidebars = array_merge( $wp_registered_sidebars, $sidebars_array );
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Editing registered sidebars.
|
104 |
-
*
|
105 |
-
* @since 1.0.0
|
106 |
-
* @return void
|
107 |
-
*/
|
108 |
-
public function edit_wp_registered_sidebars() {
|
109 |
-
global $wp_registered_sidebars;
|
110 |
-
|
111 |
-
$instance = new Cherry_Sidebar_Utils();
|
112 |
-
$sidebars_array = $instance->get_custom_sidebar_array();
|
113 |
-
unset( $sidebars_array['cherry-sidebars-counter'] );
|
114 |
-
$sidebars_array_lengh = count( $sidebars_array );
|
115 |
-
|
116 |
-
foreach ( $sidebars_array as $sidebar => $custom_sidebar ) {
|
117 |
-
unset( $wp_registered_sidebars[ $sidebar ] );
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Returns the instance.
|
123 |
-
*
|
124 |
-
* @since 1.0.0
|
125 |
-
*/
|
126 |
-
public function widgets_ajax_page() {
|
127 |
-
require_once( trailingslashit( CHERRY_SIDEBARS_DIR ) . 'admin/views/cherry-new-sidebar.php' );
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Returns the instance.
|
132 |
-
*
|
133 |
-
* @since 1.0.0
|
134 |
-
* @return object
|
135 |
-
*/
|
136 |
-
public static function get_instance() {
|
137 |
-
|
138 |
-
// If the single instance hasn't been set, set it now.
|
139 |
-
if ( null == self::$instance ) {
|
140 |
-
self::$instance = new self;
|
141 |
-
}
|
142 |
-
|
143 |
-
return self::$instance;
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
Cherry_Sidebars_Admin::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sets up the admin functionality for the plugin.
|
4 |
+
*
|
5 |
+
* @package Cherry_Sidebars
|
6 |
+
* @author Template Monster
|
7 |
+
* @license GPL-3.0+
|
8 |
+
* @copyright 2002-2016, Template Monster
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If this file is called directly, abort.
|
12 |
+
if ( ! defined( 'WPINC' ) ) {
|
13 |
+
die();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Class for admin functionally.
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
*/
|
21 |
+
class Cherry_Sidebars_Admin {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Holds the instances of this class.
|
25 |
+
*
|
26 |
+
* @since 1.0.0
|
27 |
+
* @var object
|
28 |
+
*/
|
29 |
+
private static $instance = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Sets up needed actions/filters for the admin to initialize.
|
33 |
+
*
|
34 |
+
* @since 1.0.0
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
|
39 |
+
// Load admin javascript and stylesheet.
|
40 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_assets' ), 1 );
|
41 |
+
|
42 |
+
add_action( 'after_setup_theme', array( $this, 'widgets_ajax_page' ), 10 );
|
43 |
+
add_action( 'sidebar_admin_setup', array( $this, 'registrates_custom_sidebar' ), 10 );
|
44 |
+
add_action( 'widgets_admin_page', array( $this, 'edit_wp_registered_sidebars' ), 10 );
|
45 |
+
add_action( 'sidebar_admin_page', array( $this, 'widgets_page' ), 10 );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Register and Enqueue admin-specific stylesheet and javascript.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
* @param string $hook_suffix Hook suffix.
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
public function add_admin_assets( $hook_suffix ) {
|
56 |
+
|
57 |
+
if ( 'widgets.php' === $hook_suffix ) {
|
58 |
+
wp_register_script( 'cherry_admin_sidebars_js', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/js/min/cherry-admin-sidebars.min.js', array( 'jquery' ), CHERRY_SIDEBARS_VERSION, true );
|
59 |
+
wp_register_style( 'cherry_admin_sidebars_css', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/cherry-admin-sidebars.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
60 |
+
|
61 |
+
wp_register_style( 'interface-builder', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/interface-builder.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
62 |
+
|
63 |
+
$cherry_framework_object = array( 'ajax_nonce_new_sidebar' => wp_create_nonce( 'new_custom_sidebar' ) , 'ajax_nonce_remove_sidebar' => wp_create_nonce( 'remove_custom_sidebar' ) );
|
64 |
+
wp_localize_script( 'cherry_admin_sidebars_js', 'cherryFramework', $cherry_framework_object );
|
65 |
+
|
66 |
+
wp_enqueue_script( 'cherry_admin_sidebars_js' );
|
67 |
+
wp_enqueue_style( 'cherry_admin_sidebars_css' );
|
68 |
+
wp_enqueue_style( 'interface-builder' );
|
69 |
+
|
70 |
+
} elseif ( false !== strpos( $hook_suffix, 'post' ) ) {
|
71 |
+
wp_register_style( 'cherry-sidebars-post-page', trailingslashit( CHERRY_SIDEBARS_URI ) . 'admin/assets/css/cherry-sidebars-post-page.css', array(), CHERRY_SIDEBARS_VERSION, 'all' );
|
72 |
+
wp_enqueue_style( 'cherry-sidebars-post-page' );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Returns the instance.
|
78 |
+
*
|
79 |
+
* @since 1.0.0
|
80 |
+
*/
|
81 |
+
public function widgets_page() {
|
82 |
+
cherry_sidebars()->init_modules();
|
83 |
+
require_once( trailingslashit( CHERRY_SIDEBARS_DIR ) . 'admin/views/cherry-widgets-page.php' );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Registration new custom sidebars.
|
88 |
+
*
|
89 |
+
* @since 1.0.0
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function registrates_custom_sidebar() {
|
93 |
+
global $wp_registered_sidebars;
|
94 |
+
|
95 |
+
$instance = new Cherry_Sidebar_Utils();
|
96 |
+
$sidebars_array = $instance->get_custom_sidebar_array();
|
97 |
+
unset( $sidebars_array['cherry-sidebars-counter'] );
|
98 |
+
|
99 |
+
$wp_registered_sidebars = array_merge( $wp_registered_sidebars, $sidebars_array );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Editing registered sidebars.
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function edit_wp_registered_sidebars() {
|
109 |
+
global $wp_registered_sidebars;
|
110 |
+
|
111 |
+
$instance = new Cherry_Sidebar_Utils();
|
112 |
+
$sidebars_array = $instance->get_custom_sidebar_array();
|
113 |
+
unset( $sidebars_array['cherry-sidebars-counter'] );
|
114 |
+
$sidebars_array_lengh = count( $sidebars_array );
|
115 |
+
|
116 |
+
foreach ( $sidebars_array as $sidebar => $custom_sidebar ) {
|
117 |
+
unset( $wp_registered_sidebars[ $sidebar ] );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Returns the instance.
|
123 |
+
*
|
124 |
+
* @since 1.0.0
|
125 |
+
*/
|
126 |
+
public function widgets_ajax_page() {
|
127 |
+
require_once( trailingslashit( CHERRY_SIDEBARS_DIR ) . 'admin/views/cherry-new-sidebar.php' );
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Returns the instance.
|
132 |
+
*
|
133 |
+
* @since 1.0.0
|
134 |
+
* @return object
|
135 |
+
*/
|
136 |
+
public static function get_instance() {
|
137 |
+
|
138 |
+
// If the single instance hasn't been set, set it now.
|
139 |
+
if ( null == self::$instance ) {
|
140 |
+
self::$instance = new self;
|
141 |
+
}
|
142 |
+
|
143 |
+
return self::$instance;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
Cherry_Sidebars_Admin::get_instance();
|
cherry-framework/.gitignore
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
#########################
|
2 |
-
# Files
|
3 |
-
#########################
|
4 |
-
.sass-cache
|
5 |
-
package.json
|
6 |
-
|
7 |
-
# Windows
|
8 |
-
Thumbs.db
|
9 |
-
Desktop.ini
|
10 |
-
|
11 |
-
# OSX
|
12 |
-
.DS_Store
|
13 |
-
*.swp
|
14 |
-
*~.nib
|
15 |
-
|
16 |
-
#########################
|
17 |
-
# Expansion
|
18 |
-
#########################
|
19 |
-
*.map
|
20 |
-
*.log
|
21 |
-
*.dll
|
22 |
-
|
23 |
-
#########################
|
24 |
-
# Folder
|
25 |
-
#########################
|
26 |
-
node_modules
|
27 |
-
|
28 |
-
#########################
|
29 |
-
# Travis-si files
|
30 |
-
#########################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cherry-framework/cherry-core.php
CHANGED
@@ -1,481 +1,481 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class Cherry Core
|
4 |
-
* Version: 1.1.
|
5 |
-
*
|
6 |
-
* @package Cherry_Framework
|
7 |
-
* @subpackage Class
|
8 |
-
* @author Cherry Team <cherryframework@gmail.com>
|
9 |
-
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
10 |
-
* @link http://www.cherryframework.com/
|
11 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
|
12 |
-
*/
|
13 |
-
|
14 |
-
// If this file is called directly, abort.
|
15 |
-
if ( ! defined( 'WPINC' ) ) {
|
16 |
-
die;
|
17 |
-
}
|
18 |
-
|
19 |
-
if ( ! class_exists( 'Cherry_Core' ) ) {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Class Cherry Core.
|
23 |
-
*/
|
24 |
-
class Cherry_Core {
|
25 |
-
|
26 |
-
/**
|
27 |
-
* A reference to an instance of this class.
|
28 |
-
*
|
29 |
-
* @since 1.0.0
|
30 |
-
* @var object
|
31 |
-
*/
|
32 |
-
private static $instance = null;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Core settings.
|
36 |
-
*
|
37 |
-
* @since 1.0.0
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
public $settings = array();
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Holder for all registered modules for current core instance.
|
44 |
-
*
|
45 |
-
* @since 1.0.0
|
46 |
-
* @var array
|
47 |
-
*/
|
48 |
-
public $modules = array();
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Holder for all modules.
|
52 |
-
*
|
53 |
-
* @since 1.1.0
|
54 |
-
* @var array
|
55 |
-
*/
|
56 |
-
public static $all_modules = array();
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Constructor.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
*/
|
63 |
-
public function __construct( $settings = array() ) {
|
64 |
-
$base_dir = trailingslashit( __DIR__ );
|
65 |
-
$base_url = trailingslashit( $this->base_url( '', __FILE__ ) );
|
66 |
-
|
67 |
-
$defaults = array(
|
68 |
-
'framework_path' => 'cherry-framework',
|
69 |
-
'modules' => array(),
|
70 |
-
'base_dir' => $base_dir,
|
71 |
-
'base_url' => $base_url,
|
72 |
-
'extra_base_dir' => '',
|
73 |
-
);
|
74 |
-
|
75 |
-
$this->settings = array_merge( $defaults, $settings );
|
76 |
-
|
77 |
-
$this->settings['extra_base_dir'] = trailingslashit( $this->settings['base_dir'] );
|
78 |
-
$this->settings['base_dir'] = $base_dir;
|
79 |
-
$this->settings['base_url'] = $base_url;
|
80 |
-
|
81 |
-
$this->run_collector();
|
82 |
-
|
83 |
-
/**
|
84 |
-
* In this hooks priority parameter are very important.
|
85 |
-
*/
|
86 |
-
add_action( 'after_setup_theme', array( 'Cherry_Core', 'load_all_modules' ), 2 );
|
87 |
-
add_action( 'after_setup_theme', array( $this, 'init_required_modules' ), 2 );
|
88 |
-
|
89 |
-
// Init modules with autoload seted up into true.
|
90 |
-
add_action( 'after_setup_theme', array( $this, 'init_autoload_modules' ), 9999 );
|
91 |
-
|
92 |
-
// Backward compatibility for `cherry-widget-factory` module.
|
93 |
-
remove_all_filters( 'cherry_widget_factory_core', 10 );
|
94 |
-
add_filter( 'cherry_widget_factory_core', array( $this, 'pass_core_to_widgets' ), 11, 2 );
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Fire collector for modules.
|
99 |
-
*
|
100 |
-
* @since 1.0.0
|
101 |
-
* @return bool
|
102 |
-
*/
|
103 |
-
private function run_collector() {
|
104 |
-
|
105 |
-
if ( ! is_array( $this->settings['modules'] ) || empty( $this->settings['modules'] ) ) {
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
|
109 |
-
// Cherry_Toolkit module should be loaded by default.
|
110 |
-
if ( ! isset( $this->settings['modules']['cherry-toolkit'] ) ) {
|
111 |
-
$this->settings['modules']['cherry-toolkit'] = array(
|
112 |
-
'autoload' => true,
|
113 |
-
);
|
114 |
-
}
|
115 |
-
|
116 |
-
foreach ( $this->settings['modules'] as $module => $settings ) {
|
117 |
-
$priority = $this->get_module_priority( $module );
|
118 |
-
$path = $this->get_module_path( $module );
|
119 |
-
|
120 |
-
if ( ! array_key_exists( $module, self::$all_modules ) ) {
|
121 |
-
self::$all_modules[ $module ] = array( $priority => $path );
|
122 |
-
} else {
|
123 |
-
|
124 |
-
$old_priority = array_keys( self::$all_modules[ $module ] );
|
125 |
-
|
126 |
-
if ( ! is_array( $old_priority ) || ! isset( $old_priority[0] ) ) {
|
127 |
-
continue;
|
128 |
-
}
|
129 |
-
|
130 |
-
$compare = version_compare( $old_priority[0], $priority, '<' );
|
131 |
-
|
132 |
-
if ( $compare ) {
|
133 |
-
continue;
|
134 |
-
}
|
135 |
-
|
136 |
-
self::$all_modules[ $module ] = array( $priority => $path );
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Filter a holder for all modules.
|
142 |
-
*
|
143 |
-
* @since 1.1.0
|
144 |
-
* @var array
|
145 |
-
*/
|
146 |
-
self::$all_modules = apply_filters( 'cherry_core_all_modules', self::$all_modules, $this );
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Loaded all modules.
|
151 |
-
*
|
152 |
-
* @since 1.1.0
|
153 |
-
*/
|
154 |
-
public static function load_all_modules() {
|
155 |
-
|
156 |
-
foreach ( self::$all_modules as $module => $data ) {
|
157 |
-
|
158 |
-
$path = current( $data );
|
159 |
-
$loaded = self::load_module( $module, $path );
|
160 |
-
|
161 |
-
if ( ! $loaded ) {
|
162 |
-
continue;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Init a required modules.
|
169 |
-
*
|
170 |
-
* @since 1.1.0
|
171 |
-
*/
|
172 |
-
public function init_required_modules() {
|
173 |
-
$required_modules = apply_filters( 'cherry_core_required_modules', array(
|
174 |
-
'cherry-toolkit',
|
175 |
-
'cherry-widget-factory',
|
176 |
-
), $this );
|
177 |
-
|
178 |
-
foreach ( $required_modules as $module ) {
|
179 |
-
|
180 |
-
if ( ! array_key_exists( $module, $this->settings['modules'] ) ) {
|
181 |
-
continue;
|
182 |
-
}
|
183 |
-
|
184 |
-
$settings = $this->settings['modules'][ $module ];
|
185 |
-
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
|
186 |
-
|
187 |
-
$this->init_module( $module, $args );
|
188 |
-
}
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Init autoload modules.
|
193 |
-
*
|
194 |
-
* @since 1.1.0
|
195 |
-
*/
|
196 |
-
public function init_autoload_modules() {
|
197 |
-
|
198 |
-
if ( empty( $this->modules ) ) {
|
199 |
-
return;
|
200 |
-
}
|
201 |
-
|
202 |
-
foreach ( $this->settings['modules'] as $module => $settings ) {
|
203 |
-
|
204 |
-
if ( ! $this->is_module_autoload( $module ) ) {
|
205 |
-
continue;
|
206 |
-
}
|
207 |
-
|
208 |
-
if ( ! empty( $this->modules[ $module ] ) ) {
|
209 |
-
continue;
|
210 |
-
}
|
211 |
-
|
212 |
-
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
|
213 |
-
$this->init_module( $module, $args );
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Init single module.
|
219 |
-
*
|
220 |
-
* @since 1.0.0
|
221 |
-
* @param string $module Module slug.
|
222 |
-
* @param array $args Module arguments array.
|
223 |
-
* @return mixed
|
224 |
-
*/
|
225 |
-
public function init_module( $module, $args = array() ) {
|
226 |
-
$this->modules[ $module ] = $this->get_module_instance( $module, $args );
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Filter a single module after initialization.
|
230 |
-
*
|
231 |
-
* @since 1.1.0
|
232 |
-
*/
|
233 |
-
return apply_filters( 'cherry_core_init_module', $this->modules[ $module ], $module, $args, $this );
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Check module autoload.
|
238 |
-
*
|
239 |
-
* @since 1.0.0
|
240 |
-
* @param string $module Module slug.
|
241 |
-
* @return bool
|
242 |
-
*/
|
243 |
-
public function is_module_autoload( $module ) {
|
244 |
-
|
245 |
-
if ( empty( $this->settings['modules'][ $module ]['autoload'] ) ) {
|
246 |
-
return false;
|
247 |
-
}
|
248 |
-
|
249 |
-
return $this->settings['modules'][ $module ]['autoload'];
|
250 |
-
}
|
251 |
-
|
252 |
-
/**
|
253 |
-
* Include module.
|
254 |
-
*
|
255 |
-
* @since 1.0.0
|
256 |
-
* @param string $module Module slug.
|
257 |
-
* @param string $path Module path.
|
258 |
-
* @return bool
|
259 |
-
*/
|
260 |
-
public static function load_module( $module, $path ) {
|
261 |
-
$class_name = self::get_class_name( $module );
|
262 |
-
|
263 |
-
if ( class_exists( $class_name ) ) {
|
264 |
-
return true;
|
265 |
-
}
|
266 |
-
|
267 |
-
if ( ! $path ) {
|
268 |
-
return false;
|
269 |
-
}
|
270 |
-
|
271 |
-
require_once( $path );
|
272 |
-
|
273 |
-
return true;
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Get module instance.
|
278 |
-
*
|
279 |
-
* @since 1.0.0
|
280 |
-
* @param string $module Module slug.
|
281 |
-
* @param array $args Module arguments.
|
282 |
-
* @return object
|
283 |
-
*/
|
284 |
-
public function get_module_instance( $module, $args = array() ) {
|
285 |
-
$class_name = self::get_class_name( $module );
|
286 |
-
|
287 |
-
if ( ! class_exists( $class_name ) ) {
|
288 |
-
echo '<p>Class <b>' . $class_name . '</b> not exist!</p>';
|
289 |
-
return false;
|
290 |
-
}
|
291 |
-
|
292 |
-
return $this->modules[ $module ] = call_user_func( array( $class_name, 'get_instance' ), $this, $args );
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* Get class name by module slug.
|
297 |
-
*
|
298 |
-
* @since 1.0.0
|
299 |
-
* @param string $slug Module slug.
|
300 |
-
* @return string
|
301 |
-
*/
|
302 |
-
public static function get_class_name( $slug = '' ) {
|
303 |
-
$slug = str_replace( '-', ' ', $slug );
|
304 |
-
$class = str_replace( ' ', '_', ucwords( $slug ) );
|
305 |
-
|
306 |
-
return $class;
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Get path to main file for passed module.
|
311 |
-
*
|
312 |
-
* @since 1.0.1
|
313 |
-
* @param string $module Module slug.
|
314 |
-
* @return string
|
315 |
-
*/
|
316 |
-
public function get_module_path( $module ) {
|
317 |
-
$abs_path = false;
|
318 |
-
$rel_path = 'modules/' . $module . '/' . $module . '.php';
|
319 |
-
|
320 |
-
if ( file_exists( $this->settings['extra_base_dir'] . $rel_path ) ) {
|
321 |
-
$abs_path = $this->settings['extra_base_dir'] . $rel_path;
|
322 |
-
} else if ( file_exists( $this->settings['base_dir'] . $rel_path ) ) {
|
323 |
-
$abs_path = $this->settings['base_dir'] . $rel_path;
|
324 |
-
}
|
325 |
-
|
326 |
-
return $abs_path;
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Get module priority from it's version.
|
331 |
-
* Version information should be provided as a value stored in the header notation.
|
332 |
-
*
|
333 |
-
* @link https://developer.wordpress.org/reference/functions/get_file_data/
|
334 |
-
* @since 1.0.0
|
335 |
-
* @param string $module Module slug or path.
|
336 |
-
* @param bool $is_path Set this as true, if `$module` contains a path.
|
337 |
-
* @return int
|
338 |
-
*/
|
339 |
-
public function get_module_priority( $module, $is_path = false ) {
|
340 |
-
|
341 |
-
// Default phpDoc headers.
|
342 |
-
$default_headers = array(
|
343 |
-
'version' => 'Version',
|
344 |
-
);
|
345 |
-
|
346 |
-
// Maximum version number (major, minor, patch).
|
347 |
-
$max_version = array(
|
348 |
-
99,
|
349 |
-
99,
|
350 |
-
999,
|
351 |
-
);
|
352 |
-
|
353 |
-
// If `$module` is a slug, get module path.
|
354 |
-
if ( ! $is_path ) {
|
355 |
-
$module = $this->get_module_path( $module );
|
356 |
-
}
|
357 |
-
|
358 |
-
$version = '1.0.0';
|
359 |
-
|
360 |
-
/* @TODO: Add smart check */
|
361 |
-
if ( ! $module ) {
|
362 |
-
return $version;
|
363 |
-
}
|
364 |
-
|
365 |
-
$data = get_file_data( $module , $default_headers );
|
366 |
-
|
367 |
-
// Check if version string has a valid value.
|
368 |
-
if ( isset( $data['version'] ) && false !== strpos( $data['version'], '.' ) ) {
|
369 |
-
|
370 |
-
// Clean the version string.
|
371 |
-
preg_match( '/[\d\.]+/', $data['version'], $version );
|
372 |
-
$version = $version[0];
|
373 |
-
}
|
374 |
-
|
375 |
-
// Convert version into integer.
|
376 |
-
$parts = explode( '.', $version );
|
377 |
-
|
378 |
-
// Calculate priority.
|
379 |
-
foreach ( $parts as $index => $part ) {
|
380 |
-
$parts[ $index ] = $max_version[ $index ] - (int) $part;
|
381 |
-
}
|
382 |
-
|
383 |
-
return (int) join( '', $parts );
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Retrieves the absolute URL to the current file.
|
388 |
-
* Like a WordPress function `plugins_url`.
|
389 |
-
*
|
390 |
-
* @link https://codex.wordpress.org/Function_Reference/plugins_url
|
391 |
-
* @since 1.0.1
|
392 |
-
* @param string $file_path Optional. Extra path appended to the end of the URL.
|
393 |
-
* @param string $module_path A full path to the core or module file.
|
394 |
-
* @return string
|
395 |
-
*/
|
396 |
-
public static function base_url( $file_path = '', $module_path ) {
|
397 |
-
$module_path = wp_normalize_path( $module_path );
|
398 |
-
$module_dir = dirname( $module_path );
|
399 |
-
|
400 |
-
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
|
401 |
-
$stylesheet = get_stylesheet();
|
402 |
-
$theme_root = get_raw_theme_root( $stylesheet );
|
403 |
-
$theme_dir = "$theme_root/$stylesheet";
|
404 |
-
|
405 |
-
if ( 0 === strpos( $module_path, $plugin_dir ) ) {
|
406 |
-
$url = plugin_dir_url( $module_path );
|
407 |
-
} else if ( false !== strpos( $module_path, $theme_dir ) ) {
|
408 |
-
$explode = explode( $theme_dir, $module_dir, 2 );
|
409 |
-
$url = get_stylesheet_directory_uri() . $explode[1];
|
410 |
-
} else {
|
411 |
-
$site_url = site_url();
|
412 |
-
$abs_path = wp_normalize_path( ABSPATH );
|
413 |
-
$url = str_replace( untrailingslashit( $abs_path ), $site_url, $module_dir );
|
414 |
-
}
|
415 |
-
|
416 |
-
if ( $file_path && is_string( $file_path ) ) {
|
417 |
-
$url = trailingslashit( $url );
|
418 |
-
$url .= ltrim( $file_path, '/' );
|
419 |
-
}
|
420 |
-
|
421 |
-
return apply_filters( 'cherry_core_base_url', $url, $file_path, $module_path );
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* Pass core instance into widget.
|
426 |
-
*
|
427 |
-
* @since 1.1.0
|
428 |
-
* @param mixed $core Current core object.
|
429 |
-
* @param string $path Abstract widget file path.
|
430 |
-
* @return mixed
|
431 |
-
*/
|
432 |
-
public function pass_core_to_widgets( $core, $path ) {
|
433 |
-
$path = str_replace( '\\', '/', $path );
|
434 |
-
$current_core = str_replace( '\\', '/', $this->settings['extra_base_dir'] );
|
435 |
-
|
436 |
-
if ( false !== strpos( $path, $current_core ) ) {
|
437 |
-
return self::get_instance();
|
438 |
-
}
|
439 |
-
|
440 |
-
return $core;
|
441 |
-
}
|
442 |
-
|
443 |
-
/**
|
444 |
-
* Get path to the core directory.
|
445 |
-
*
|
446 |
-
* @since 1.0.0
|
447 |
-
* @deprecated 1.1.0 Use constant `__DIR__`
|
448 |
-
* @return string
|
449 |
-
*/
|
450 |
-
public function get_core_dir() {
|
451 |
-
return trailingslashit( $this->settings['base_dir'] );
|
452 |
-
}
|
453 |
-
|
454 |
-
/**
|
455 |
-
* Get URI to the core directory.
|
456 |
-
*
|
457 |
-
* @since 1.0.0
|
458 |
-
* @deprecated 1.1.0 Use `base_url()` method
|
459 |
-
* @return string
|
460 |
-
*/
|
461 |
-
public function get_core_url() {
|
462 |
-
return trailingslashit( $this->settings['base_url'] );
|
463 |
-
}
|
464 |
-
|
465 |
-
/**
|
466 |
-
* Returns the instance.
|
467 |
-
*
|
468 |
-
* @since 1.0.0
|
469 |
-
* @return object
|
470 |
-
*/
|
471 |
-
public static function get_instance() {
|
472 |
-
|
473 |
-
// If the single instance hasn't been set, set it now.
|
474 |
-
if ( null == self::$instance ) {
|
475 |
-
self::$instance = new self;
|
476 |
-
}
|
477 |
-
|
478 |
-
return self::$instance;
|
479 |
-
}
|
480 |
-
}
|
481 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Cherry Core
|
4 |
+
* Version: 1.1.1
|
5 |
+
*
|
6 |
+
* @package Cherry_Framework
|
7 |
+
* @subpackage Class
|
8 |
+
* @author Cherry Team <cherryframework@gmail.com>
|
9 |
+
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
10 |
+
* @link http://www.cherryframework.com/
|
11 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
|
12 |
+
*/
|
13 |
+
|
14 |
+
// If this file is called directly, abort.
|
15 |
+
if ( ! defined( 'WPINC' ) ) {
|
16 |
+
die;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( ! class_exists( 'Cherry_Core' ) ) {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class Cherry Core.
|
23 |
+
*/
|
24 |
+
class Cherry_Core {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* A reference to an instance of this class.
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
* @var object
|
31 |
+
*/
|
32 |
+
private static $instance = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Core settings.
|
36 |
+
*
|
37 |
+
* @since 1.0.0
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
public $settings = array();
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Holder for all registered modules for current core instance.
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
public $modules = array();
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Holder for all modules.
|
52 |
+
*
|
53 |
+
* @since 1.1.0
|
54 |
+
* @var array
|
55 |
+
*/
|
56 |
+
public static $all_modules = array();
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Constructor.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
*/
|
63 |
+
public function __construct( $settings = array() ) {
|
64 |
+
$base_dir = trailingslashit( __DIR__ );
|
65 |
+
$base_url = trailingslashit( $this->base_url( '', __FILE__ ) );
|
66 |
+
|
67 |
+
$defaults = array(
|
68 |
+
'framework_path' => 'cherry-framework',
|
69 |
+
'modules' => array(),
|
70 |
+
'base_dir' => $base_dir,
|
71 |
+
'base_url' => $base_url,
|
72 |
+
'extra_base_dir' => '',
|
73 |
+
);
|
74 |
+
|
75 |
+
$this->settings = array_merge( $defaults, $settings );
|
76 |
+
|
77 |
+
$this->settings['extra_base_dir'] = trailingslashit( $this->settings['base_dir'] );
|
78 |
+
$this->settings['base_dir'] = $base_dir;
|
79 |
+
$this->settings['base_url'] = $base_url;
|
80 |
+
|
81 |
+
$this->run_collector();
|
82 |
+
|
83 |
+
/**
|
84 |
+
* In this hooks priority parameter are very important.
|
85 |
+
*/
|
86 |
+
add_action( 'after_setup_theme', array( 'Cherry_Core', 'load_all_modules' ), 2 );
|
87 |
+
add_action( 'after_setup_theme', array( $this, 'init_required_modules' ), 2 );
|
88 |
+
|
89 |
+
// Init modules with autoload seted up into true.
|
90 |
+
add_action( 'after_setup_theme', array( $this, 'init_autoload_modules' ), 9999 );
|
91 |
+
|
92 |
+
// Backward compatibility for `cherry-widget-factory` module.
|
93 |
+
remove_all_filters( 'cherry_widget_factory_core', 10 );
|
94 |
+
add_filter( 'cherry_widget_factory_core', array( $this, 'pass_core_to_widgets' ), 11, 2 );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Fire collector for modules.
|
99 |
+
*
|
100 |
+
* @since 1.0.0
|
101 |
+
* @return bool
|
102 |
+
*/
|
103 |
+
private function run_collector() {
|
104 |
+
|
105 |
+
if ( ! is_array( $this->settings['modules'] ) || empty( $this->settings['modules'] ) ) {
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
// Cherry_Toolkit module should be loaded by default.
|
110 |
+
if ( ! isset( $this->settings['modules']['cherry-toolkit'] ) ) {
|
111 |
+
$this->settings['modules']['cherry-toolkit'] = array(
|
112 |
+
'autoload' => true,
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
foreach ( $this->settings['modules'] as $module => $settings ) {
|
117 |
+
$priority = $this->get_module_priority( $module );
|
118 |
+
$path = $this->get_module_path( $module );
|
119 |
+
|
120 |
+
if ( ! array_key_exists( $module, self::$all_modules ) ) {
|
121 |
+
self::$all_modules[ $module ] = array( $priority => $path );
|
122 |
+
} else {
|
123 |
+
|
124 |
+
$old_priority = array_keys( self::$all_modules[ $module ] );
|
125 |
+
|
126 |
+
if ( ! is_array( $old_priority ) || ! isset( $old_priority[0] ) ) {
|
127 |
+
continue;
|
128 |
+
}
|
129 |
+
|
130 |
+
$compare = version_compare( $old_priority[0], $priority, '<' );
|
131 |
+
|
132 |
+
if ( $compare ) {
|
133 |
+
continue;
|
134 |
+
}
|
135 |
+
|
136 |
+
self::$all_modules[ $module ] = array( $priority => $path );
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Filter a holder for all modules.
|
142 |
+
*
|
143 |
+
* @since 1.1.0
|
144 |
+
* @var array
|
145 |
+
*/
|
146 |
+
self::$all_modules = apply_filters( 'cherry_core_all_modules', self::$all_modules, $this );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Loaded all modules.
|
151 |
+
*
|
152 |
+
* @since 1.1.0
|
153 |
+
*/
|
154 |
+
public static function load_all_modules() {
|
155 |
+
|
156 |
+
foreach ( self::$all_modules as $module => $data ) {
|
157 |
+
|
158 |
+
$path = current( $data );
|
159 |
+
$loaded = self::load_module( $module, $path );
|
160 |
+
|
161 |
+
if ( ! $loaded ) {
|
162 |
+
continue;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Init a required modules.
|
169 |
+
*
|
170 |
+
* @since 1.1.0
|
171 |
+
*/
|
172 |
+
public function init_required_modules() {
|
173 |
+
$required_modules = apply_filters( 'cherry_core_required_modules', array(
|
174 |
+
'cherry-toolkit',
|
175 |
+
'cherry-widget-factory',
|
176 |
+
), $this );
|
177 |
+
|
178 |
+
foreach ( $required_modules as $module ) {
|
179 |
+
|
180 |
+
if ( ! array_key_exists( $module, $this->settings['modules'] ) ) {
|
181 |
+
continue;
|
182 |
+
}
|
183 |
+
|
184 |
+
$settings = $this->settings['modules'][ $module ];
|
185 |
+
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
|
186 |
+
|
187 |
+
$this->init_module( $module, $args );
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Init autoload modules.
|
193 |
+
*
|
194 |
+
* @since 1.1.0
|
195 |
+
*/
|
196 |
+
public function init_autoload_modules() {
|
197 |
+
|
198 |
+
if ( empty( $this->modules ) ) {
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
|
202 |
+
foreach ( $this->settings['modules'] as $module => $settings ) {
|
203 |
+
|
204 |
+
if ( ! $this->is_module_autoload( $module ) ) {
|
205 |
+
continue;
|
206 |
+
}
|
207 |
+
|
208 |
+
if ( ! empty( $this->modules[ $module ] ) ) {
|
209 |
+
continue;
|
210 |
+
}
|
211 |
+
|
212 |
+
$args = ! empty( $settings['args'] ) ? $settings['args'] : array();
|
213 |
+
$this->init_module( $module, $args );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Init single module.
|
219 |
+
*
|
220 |
+
* @since 1.0.0
|
221 |
+
* @param string $module Module slug.
|
222 |
+
* @param array $args Module arguments array.
|
223 |
+
* @return mixed
|
224 |
+
*/
|
225 |
+
public function init_module( $module, $args = array() ) {
|
226 |
+
$this->modules[ $module ] = $this->get_module_instance( $module, $args );
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Filter a single module after initialization.
|
230 |
+
*
|
231 |
+
* @since 1.1.0
|
232 |
+
*/
|
233 |
+
return apply_filters( 'cherry_core_init_module', $this->modules[ $module ], $module, $args, $this );
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Check module autoload.
|
238 |
+
*
|
239 |
+
* @since 1.0.0
|
240 |
+
* @param string $module Module slug.
|
241 |
+
* @return bool
|
242 |
+
*/
|
243 |
+
public function is_module_autoload( $module ) {
|
244 |
+
|
245 |
+
if ( empty( $this->settings['modules'][ $module ]['autoload'] ) ) {
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
|
249 |
+
return $this->settings['modules'][ $module ]['autoload'];
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Include module.
|
254 |
+
*
|
255 |
+
* @since 1.0.0
|
256 |
+
* @param string $module Module slug.
|
257 |
+
* @param string $path Module path.
|
258 |
+
* @return bool
|
259 |
+
*/
|
260 |
+
public static function load_module( $module, $path ) {
|
261 |
+
$class_name = self::get_class_name( $module );
|
262 |
+
|
263 |
+
if ( class_exists( $class_name ) ) {
|
264 |
+
return true;
|
265 |
+
}
|
266 |
+
|
267 |
+
if ( ! $path ) {
|
268 |
+
return false;
|
269 |
+
}
|
270 |
+
|
271 |
+
require_once( $path );
|
272 |
+
|
273 |
+
return true;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Get module instance.
|
278 |
+
*
|
279 |
+
* @since 1.0.0
|
280 |
+
* @param string $module Module slug.
|
281 |
+
* @param array $args Module arguments.
|
282 |
+
* @return object
|
283 |
+
*/
|
284 |
+
public function get_module_instance( $module, $args = array() ) {
|
285 |
+
$class_name = self::get_class_name( $module );
|
286 |
+
|
287 |
+
if ( ! class_exists( $class_name ) ) {
|
288 |
+
echo '<p>Class <b>' . $class_name . '</b> not exist!</p>';
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
|
292 |
+
return $this->modules[ $module ] = call_user_func( array( $class_name, 'get_instance' ), $this, $args );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Get class name by module slug.
|
297 |
+
*
|
298 |
+
* @since 1.0.0
|
299 |
+
* @param string $slug Module slug.
|
300 |
+
* @return string
|
301 |
+
*/
|
302 |
+
public static function get_class_name( $slug = '' ) {
|
303 |
+
$slug = str_replace( '-', ' ', $slug );
|
304 |
+
$class = str_replace( ' ', '_', ucwords( $slug ) );
|
305 |
+
|
306 |
+
return $class;
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Get path to main file for passed module.
|
311 |
+
*
|
312 |
+
* @since 1.0.1
|
313 |
+
* @param string $module Module slug.
|
314 |
+
* @return string
|
315 |
+
*/
|
316 |
+
public function get_module_path( $module ) {
|
317 |
+
$abs_path = false;
|
318 |
+
$rel_path = 'modules/' . $module . '/' . $module . '.php';
|
319 |
+
|
320 |
+
if ( file_exists( $this->settings['extra_base_dir'] . $rel_path ) ) {
|
321 |
+
$abs_path = $this->settings['extra_base_dir'] . $rel_path;
|
322 |
+
} else if ( file_exists( $this->settings['base_dir'] . $rel_path ) ) {
|
323 |
+
$abs_path = $this->settings['base_dir'] . $rel_path;
|
324 |
+
}
|
325 |
+
|
326 |
+
return $abs_path;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Get module priority from it's version.
|
331 |
+
* Version information should be provided as a value stored in the header notation.
|
332 |
+
*
|
333 |
+
* @link https://developer.wordpress.org/reference/functions/get_file_data/
|
334 |
+
* @since 1.0.0
|
335 |
+
* @param string $module Module slug or path.
|
336 |
+
* @param bool $is_path Set this as true, if `$module` contains a path.
|
337 |
+
* @return int
|
338 |
+
*/
|
339 |
+
public function get_module_priority( $module, $is_path = false ) {
|
340 |
+
|
341 |
+
// Default phpDoc headers.
|
342 |
+
$default_headers = array(
|
343 |
+
'version' => 'Version',
|
344 |
+
);
|
345 |
+
|
346 |
+
// Maximum version number (major, minor, patch).
|
347 |
+
$max_version = array(
|
348 |
+
99,
|
349 |
+
99,
|
350 |
+
999,
|
351 |
+
);
|
352 |
+
|
353 |
+
// If `$module` is a slug, get module path.
|
354 |
+
if ( ! $is_path ) {
|
355 |
+
$module = $this->get_module_path( $module );
|
356 |
+
}
|
357 |
+
|
358 |
+
$version = '1.0.0';
|
359 |
+
|
360 |
+
/* @TODO: Add smart check */
|
361 |
+
if ( ! $module ) {
|
362 |
+
return $version;
|
363 |
+
}
|
364 |
+
|
365 |
+
$data = get_file_data( $module , $default_headers );
|
366 |
+
|
367 |
+
// Check if version string has a valid value.
|
368 |
+
if ( isset( $data['version'] ) && false !== strpos( $data['version'], '.' ) ) {
|
369 |
+
|
370 |
+
// Clean the version string.
|
371 |
+
preg_match( '/[\d\.]+/', $data['version'], $version );
|
372 |
+
$version = $version[0];
|
373 |
+
}
|
374 |
+
|
375 |
+
// Convert version into integer.
|
376 |
+
$parts = explode( '.', $version );
|
377 |
+
|
378 |
+
// Calculate priority.
|
379 |
+
foreach ( $parts as $index => $part ) {
|
380 |
+
$parts[ $index ] = $max_version[ $index ] - (int) $part;
|
381 |
+
}
|
382 |
+
|
383 |
+
return (int) join( '', $parts );
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Retrieves the absolute URL to the current file.
|
388 |
+
* Like a WordPress function `plugins_url`.
|
389 |
+
*
|
390 |
+
* @link https://codex.wordpress.org/Function_Reference/plugins_url
|
391 |
+
* @since 1.0.1
|
392 |
+
* @param string $file_path Optional. Extra path appended to the end of the URL.
|
393 |
+
* @param string $module_path A full path to the core or module file.
|
394 |
+
* @return string
|
395 |
+
*/
|
396 |
+
public static function base_url( $file_path = '', $module_path ) {
|
397 |
+
$module_path = wp_normalize_path( $module_path );
|
398 |
+
$module_dir = dirname( $module_path );
|
399 |
+
|
400 |
+
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
|
401 |
+
$stylesheet = get_stylesheet();
|
402 |
+
$theme_root = get_raw_theme_root( $stylesheet );
|
403 |
+
$theme_dir = "$theme_root/$stylesheet";
|
404 |
+
|
405 |
+
if ( 0 === strpos( $module_path, $plugin_dir ) ) {
|
406 |
+
$url = plugin_dir_url( $module_path );
|
407 |
+
} else if ( false !== strpos( $module_path, $theme_dir ) ) {
|
408 |
+
$explode = explode( $theme_dir, $module_dir, 2 );
|
409 |
+
$url = get_stylesheet_directory_uri() . $explode[1];
|
410 |
+
} else {
|
411 |
+
$site_url = site_url();
|
412 |
+
$abs_path = wp_normalize_path( ABSPATH );
|
413 |
+
$url = str_replace( untrailingslashit( $abs_path ), $site_url, $module_dir );
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( $file_path && is_string( $file_path ) ) {
|
417 |
+
$url = trailingslashit( $url );
|
418 |
+
$url .= ltrim( $file_path, '/' );
|
419 |
+
}
|
420 |
+
|
421 |
+
return apply_filters( 'cherry_core_base_url', $url, $file_path, $module_path );
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Pass core instance into widget.
|
426 |
+
*
|
427 |
+
* @since 1.1.0
|
428 |
+
* @param mixed $core Current core object.
|
429 |
+
* @param string $path Abstract widget file path.
|
430 |
+
* @return mixed
|
431 |
+
*/
|
432 |
+
public function pass_core_to_widgets( $core, $path ) {
|
433 |
+
$path = str_replace( '\\', '/', $path );
|
434 |
+
$current_core = str_replace( '\\', '/', $this->settings['extra_base_dir'] );
|
435 |
+
|
436 |
+
if ( false !== strpos( $path, $current_core ) ) {
|
437 |
+
return self::get_instance();
|
438 |
+
}
|
439 |
+
|
440 |
+
return $core;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Get path to the core directory.
|
445 |
+
*
|
446 |
+
* @since 1.0.0
|
447 |
+
* @deprecated 1.1.0 Use constant `__DIR__`
|
448 |
+
* @return string
|
449 |
+
*/
|
450 |
+
public function get_core_dir() {
|
451 |
+
return trailingslashit( $this->settings['base_dir'] );
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Get URI to the core directory.
|
456 |
+
*
|
457 |
+
* @since 1.0.0
|
458 |
+
* @deprecated 1.1.0 Use `base_url()` method
|
459 |
+
* @return string
|
460 |
+
*/
|
461 |
+
public function get_core_url() {
|
462 |
+
return trailingslashit( $this->settings['base_url'] );
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Returns the instance.
|
467 |
+
*
|
468 |
+
* @since 1.0.0
|
469 |
+
* @return object
|
470 |
+
*/
|
471 |
+
public static function get_instance() {
|
472 |
+
|
473 |
+
// If the single instance hasn't been set, set it now.
|
474 |
+
if ( null == self::$instance ) {
|
475 |
+
self::$instance = new self;
|
476 |
+
}
|
477 |
+
|
478 |
+
return self::$instance;
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
cherry-framework/codesniffer.ruleset.xml
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<ruleset name="WordPress Theme Coding Standards">
|
3 |
-
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
4 |
-
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
|
5 |
-
|
6 |
-
<!-- Set a description for this ruleset. -->
|
7 |
-
<description>A custom set of code standard rules to check for WordPress themes.</description>
|
8 |
-
|
9 |
-
<!-- Include the WordPress ruleset, with space for exclusions if necessary. -->
|
10 |
-
<rule ref="WordPress-Core">
|
11 |
-
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
|
12 |
-
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
|
13 |
-
|
14 |
-
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
|
15 |
-
|
16 |
-
<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment" />
|
17 |
-
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
|
18 |
-
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
|
19 |
-
<exclude name="Squiz.Commenting.InlineComment.NotCapital" />
|
20 |
-
</rule>
|
21 |
-
<rule ref="WordPress-Docs">
|
22 |
-
|
23 |
-
</rule>
|
24 |
-
</ruleset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cherry-framework/config.json
CHANGED
@@ -1,189 +1,189 @@
|
|
1 |
-
{
|
2 |
-
"name" : "Cherry Framework",
|
3 |
-
"version" : "1.
|
4 |
-
"description" : "",
|
5 |
-
"doc_link" : "",
|
6 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework",
|
7 |
-
"modules" : {
|
8 |
-
"cherry-breadcrumbs" : {
|
9 |
-
"name" : "Breadcrumb Trail",
|
10 |
-
"description" : "A breadcrumb menu script for WordPress.",
|
11 |
-
"doc_link" : "",
|
12 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-breadcrumbs",
|
13 |
-
"compatible" : ["theme", "plugin"],
|
14 |
-
"wordpress_org" : true,
|
15 |
-
"required" : false,
|
16 |
-
"dependencies" : []
|
17 |
-
},
|
18 |
-
"cherry-creator" : {
|
19 |
-
"name" : "Creator.",
|
20 |
-
"description" : "Creator.",
|
21 |
-
"doc_link" : "",
|
22 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-creator",
|
23 |
-
"compatible" : ["theme", "plugin"],
|
24 |
-
"wordpress_org" : true,
|
25 |
-
"required" : false,
|
26 |
-
"dependencies" : []
|
27 |
-
},
|
28 |
-
"cherry-customizer" : {
|
29 |
-
"name" : "Customizer",
|
30 |
-
"description" : "Customizer functionality.",
|
31 |
-
"doc_link" : "",
|
32 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-customizer",
|
33 |
-
"compatible" : ["theme", "plugin"],
|
34 |
-
"wordpress_org" : true,
|
35 |
-
"required" : false,
|
36 |
-
"dependencies" : []
|
37 |
-
},
|
38 |
-
"cherry-dynamic-css" : {
|
39 |
-
"name" : "Dynamic Css",
|
40 |
-
"description" : "Generate Css.",
|
41 |
-
"doc_link" : "",
|
42 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-dynamic-css",
|
43 |
-
"compatible" : ["theme", "plugin"],
|
44 |
-
"wordpress_org" : true,
|
45 |
-
"required" : false,
|
46 |
-
"dependencies" : []
|
47 |
-
},
|
48 |
-
"cherry-google-fonts-loader" : {
|
49 |
-
"name" : "Google Fonts Loader",
|
50 |
-
"description" : "Enqueue Google font.",
|
51 |
-
"doc_link" : "",
|
52 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-google-fonts-loader",
|
53 |
-
"compatible" : ["theme", "plugin"],
|
54 |
-
"wordpress_org" : true,
|
55 |
-
"required" : false,
|
56 |
-
"dependencies" : []
|
57 |
-
},
|
58 |
-
"cherry-js-core" : {
|
59 |
-
"name" : "JS Core",
|
60 |
-
"description" : "Initializes global JS object which provides additional plugin functionality.",
|
61 |
-
"doc_link" : "",
|
62 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-js-core",
|
63 |
-
"compatible" : ["theme", "plugin"],
|
64 |
-
"wordpress_org" : true,
|
65 |
-
"required" : false,
|
66 |
-
"dependencies" : []
|
67 |
-
},
|
68 |
-
"cherry-page-builder" : {
|
69 |
-
"name" : "Page Builder",
|
70 |
-
"description" : "Provides functionality for building custom options pages.",
|
71 |
-
"doc_link" : "",
|
72 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-page-builder",
|
73 |
-
"compatible" : ["plugin"],
|
74 |
-
"wordpress_org" : true,
|
75 |
-
"required" : false,
|
76 |
-
"dependencies" : []
|
77 |
-
},
|
78 |
-
"cherry-plugin-updater" : {
|
79 |
-
"name" : "Plugin Updater",
|
80 |
-
"description" : "Provides functionality for updating plugins.",
|
81 |
-
"doc_link" : "",
|
82 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-plugin-updater",
|
83 |
-
"compatible" : ["plugin"],
|
84 |
-
"wordpress_org" : false,
|
85 |
-
"required" : false,
|
86 |
-
"dependencies" : []
|
87 |
-
},
|
88 |
-
"cherry-post-formats-api" : {
|
89 |
-
"name" : "Post Formats API",
|
90 |
-
"description" : "API for post formats specific content.",
|
91 |
-
"doc_link" : "",
|
92 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-formats-api",
|
93 |
-
"compatible" : ["theme", "plugin"],
|
94 |
-
"wordpress_org" : true,
|
95 |
-
"required" : false,
|
96 |
-
"dependencies" : [ "cherry-js-core" ]
|
97 |
-
},
|
98 |
-
"cherry-post-meta" : {
|
99 |
-
"name" : "Post Meta",
|
100 |
-
"description" : "Manage post meta.",
|
101 |
-
"doc_link" : "",
|
102 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-meta",
|
103 |
-
"compatible" : ["theme", "plugin"],
|
104 |
-
"wordpress_org" : true,
|
105 |
-
"required" : false,
|
106 |
-
"dependencies" : [ "cherry-ui-elements" ]
|
107 |
-
},
|
108 |
-
"cherry-post-types" : {
|
109 |
-
"name" : "Post Types",
|
110 |
-
"description" : "Provides functionality for creating custom post types.",
|
111 |
-
"doc_link" : "",
|
112 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-types",
|
113 |
-
"compatible" : ["plugin"],
|
114 |
-
"wordpress_org" : true,
|
115 |
-
"required" : false,
|
116 |
-
"dependencies" : [ "cherry-ui-elements" ]
|
117 |
-
},
|
118 |
-
"cherry-taxonomies" : {
|
119 |
-
"name" : "Taxanomies",
|
120 |
-
"description" : "Provides functionality for creating custom taxanomies.",
|
121 |
-
"doc_link" : "",
|
122 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-taxonomies",
|
123 |
-
"compatible" : ["plugin"],
|
124 |
-
"wordpress_org" : true,
|
125 |
-
"required" : false,
|
126 |
-
"dependencies" : []
|
127 |
-
},
|
128 |
-
"cherry-term-meta" : {
|
129 |
-
"name" : "Term Meta",
|
130 |
-
"description" : "Manage term metadata.",
|
131 |
-
"doc_link" : "",
|
132 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-term-meta",
|
133 |
-
"compatible" : ["theme", "plugin"],
|
134 |
-
"wordpress_org" : true,
|
135 |
-
"required" : false,
|
136 |
-
"dependencies" : [ "cherry-ui-elements" ]
|
137 |
-
},
|
138 |
-
"cherry-theme-updater" : {
|
139 |
-
"name" : "Theme Updater",
|
140 |
-
"description" : "Provides functionality for updating themes.",
|
141 |
-
"doc_link" : "",
|
142 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-theme-updater",
|
143 |
-
"compatible" : ["theme"],
|
144 |
-
"wordpress_org" : false,
|
145 |
-
"required" : false,
|
146 |
-
"dependencies" : []
|
147 |
-
},
|
148 |
-
"cherry-ui-elements" : {
|
149 |
-
"name" : "UI Elements",
|
150 |
-
"description" : "UI Elements",
|
151 |
-
"doc_link" : "",
|
152 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-ui-elements",
|
153 |
-
"compatible" : ["theme", "plugin"],
|
154 |
-
"wordpress_org" : true,
|
155 |
-
"required" : false,
|
156 |
-
"dependencies" : [ "cherry-js-core" ]
|
157 |
-
},
|
158 |
-
"cherry-utility" : {
|
159 |
-
"name" : "Utility",
|
160 |
-
"description" : "Multiple utility functions.",
|
161 |
-
"doc_link" : "",
|
162 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-utility",
|
163 |
-
"compatible" : ["theme", "plugin"],
|
164 |
-
"wordpress_org" : true,
|
165 |
-
"required" : false,
|
166 |
-
"dependencies" : []
|
167 |
-
},
|
168 |
-
"cherry-widget-factory" : {
|
169 |
-
"name" : "Widget Factory.",
|
170 |
-
"description" : "Base widget class that simplifies creating of your own widgets.",
|
171 |
-
"doc_link" : "",
|
172 |
-
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-widget-factory",
|
173 |
-
"compatible" : ["theme", "plugin"],
|
174 |
-
"wordpress_org" : true,
|
175 |
-
"required" : false,
|
176 |
-
"dependencies" : [ "cherry-ui-elements" ]
|
177 |
-
},
|
178 |
-
"cherry-toolkit": {
|
179 |
-
"name": "Framework Toolkit",
|
180 |
-
"description": "Framework Toolkit contains various PHP utilities",
|
181 |
-
"doc_link": "",
|
182 |
-
"git_link": "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-toolkit",
|
183 |
-
"compatible": ["theme", "plugin"],
|
184 |
-
"wordpress_org": true,
|
185 |
-
"required": true,
|
186 |
-
"dependencies": []
|
187 |
-
}
|
188 |
-
}
|
189 |
-
}
|
1 |
+
{
|
2 |
+
"name" : "Cherry Framework",
|
3 |
+
"version" : "1.1.1",
|
4 |
+
"description" : "",
|
5 |
+
"doc_link" : "",
|
6 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework",
|
7 |
+
"modules" : {
|
8 |
+
"cherry-breadcrumbs" : {
|
9 |
+
"name" : "Breadcrumb Trail",
|
10 |
+
"description" : "A breadcrumb menu script for WordPress.",
|
11 |
+
"doc_link" : "",
|
12 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-breadcrumbs",
|
13 |
+
"compatible" : ["theme", "plugin"],
|
14 |
+
"wordpress_org" : true,
|
15 |
+
"required" : false,
|
16 |
+
"dependencies" : []
|
17 |
+
},
|
18 |
+
"cherry-creator" : {
|
19 |
+
"name" : "Creator.",
|
20 |
+
"description" : "Creator.",
|
21 |
+
"doc_link" : "",
|
22 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-creator",
|
23 |
+
"compatible" : ["theme", "plugin"],
|
24 |
+
"wordpress_org" : true,
|
25 |
+
"required" : false,
|
26 |
+
"dependencies" : []
|
27 |
+
},
|
28 |
+
"cherry-customizer" : {
|
29 |
+
"name" : "Customizer",
|
30 |
+
"description" : "Customizer functionality.",
|
31 |
+
"doc_link" : "",
|
32 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-customizer",
|
33 |
+
"compatible" : ["theme", "plugin"],
|
34 |
+
"wordpress_org" : true,
|
35 |
+
"required" : false,
|
36 |
+
"dependencies" : []
|
37 |
+
},
|
38 |
+
"cherry-dynamic-css" : {
|
39 |
+
"name" : "Dynamic Css",
|
40 |
+
"description" : "Generate Css.",
|
41 |
+
"doc_link" : "",
|
42 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-dynamic-css",
|
43 |
+
"compatible" : ["theme", "plugin"],
|
44 |
+
"wordpress_org" : true,
|
45 |
+
"required" : false,
|
46 |
+
"dependencies" : []
|
47 |
+
},
|
48 |
+
"cherry-google-fonts-loader" : {
|
49 |
+
"name" : "Google Fonts Loader",
|
50 |
+
"description" : "Enqueue Google font.",
|
51 |
+
"doc_link" : "",
|
52 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-google-fonts-loader",
|
53 |
+
"compatible" : ["theme", "plugin"],
|
54 |
+
"wordpress_org" : true,
|
55 |
+
"required" : false,
|
56 |
+
"dependencies" : []
|
57 |
+
},
|
58 |
+
"cherry-js-core" : {
|
59 |
+
"name" : "JS Core",
|
60 |
+
"description" : "Initializes global JS object which provides additional plugin functionality.",
|
61 |
+
"doc_link" : "",
|
62 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-js-core",
|
63 |
+
"compatible" : ["theme", "plugin"],
|
64 |
+
"wordpress_org" : true,
|
65 |
+
"required" : false,
|
66 |
+
"dependencies" : []
|
67 |
+
},
|
68 |
+
"cherry-page-builder" : {
|
69 |
+
"name" : "Page Builder",
|
70 |
+
"description" : "Provides functionality for building custom options pages.",
|
71 |
+
"doc_link" : "",
|
72 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-page-builder",
|
73 |
+
"compatible" : ["plugin"],
|
74 |
+
"wordpress_org" : true,
|
75 |
+
"required" : false,
|
76 |
+
"dependencies" : []
|
77 |
+
},
|
78 |
+
"cherry-plugin-updater" : {
|
79 |
+
"name" : "Plugin Updater",
|
80 |
+
"description" : "Provides functionality for updating plugins.",
|
81 |
+
"doc_link" : "",
|
82 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-plugin-updater",
|
83 |
+
"compatible" : ["plugin"],
|
84 |
+
"wordpress_org" : false,
|
85 |
+
"required" : false,
|
86 |
+
"dependencies" : []
|
87 |
+
},
|
88 |
+
"cherry-post-formats-api" : {
|
89 |
+
"name" : "Post Formats API",
|
90 |
+
"description" : "API for post formats specific content.",
|
91 |
+
"doc_link" : "",
|
92 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-formats-api",
|
93 |
+
"compatible" : ["theme", "plugin"],
|
94 |
+
"wordpress_org" : true,
|
95 |
+
"required" : false,
|
96 |
+
"dependencies" : [ "cherry-js-core" ]
|
97 |
+
},
|
98 |
+
"cherry-post-meta" : {
|
99 |
+
"name" : "Post Meta",
|
100 |
+
"description" : "Manage post meta.",
|
101 |
+
"doc_link" : "",
|
102 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-meta",
|
103 |
+
"compatible" : ["theme", "plugin"],
|
104 |
+
"wordpress_org" : true,
|
105 |
+
"required" : false,
|
106 |
+
"dependencies" : [ "cherry-ui-elements" ]
|
107 |
+
},
|
108 |
+
"cherry-post-types" : {
|
109 |
+
"name" : "Post Types",
|
110 |
+
"description" : "Provides functionality for creating custom post types.",
|
111 |
+
"doc_link" : "",
|
112 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-post-types",
|
113 |
+
"compatible" : ["plugin"],
|
114 |
+
"wordpress_org" : true,
|
115 |
+
"required" : false,
|
116 |
+
"dependencies" : [ "cherry-ui-elements" ]
|
117 |
+
},
|
118 |
+
"cherry-taxonomies" : {
|
119 |
+
"name" : "Taxanomies",
|
120 |
+
"description" : "Provides functionality for creating custom taxanomies.",
|
121 |
+
"doc_link" : "",
|
122 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-taxonomies",
|
123 |
+
"compatible" : ["plugin"],
|
124 |
+
"wordpress_org" : true,
|
125 |
+
"required" : false,
|
126 |
+
"dependencies" : []
|
127 |
+
},
|
128 |
+
"cherry-term-meta" : {
|
129 |
+
"name" : "Term Meta",
|
130 |
+
"description" : "Manage term metadata.",
|
131 |
+
"doc_link" : "",
|
132 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-term-meta",
|
133 |
+
"compatible" : ["theme", "plugin"],
|
134 |
+
"wordpress_org" : true,
|
135 |
+
"required" : false,
|
136 |
+
"dependencies" : [ "cherry-ui-elements" ]
|
137 |
+
},
|
138 |
+
"cherry-theme-updater" : {
|
139 |
+
"name" : "Theme Updater",
|
140 |
+
"description" : "Provides functionality for updating themes.",
|
141 |
+
"doc_link" : "",
|
142 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-theme-updater",
|
143 |
+
"compatible" : ["theme"],
|
144 |
+
"wordpress_org" : false,
|
145 |
+
"required" : false,
|
146 |
+
"dependencies" : []
|
147 |
+
},
|
148 |
+
"cherry-ui-elements" : {
|
149 |
+
"name" : "UI Elements",
|
150 |
+
"description" : "UI Elements",
|
151 |
+
"doc_link" : "",
|
152 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-ui-elements",
|
153 |
+
"compatible" : ["theme", "plugin"],
|
154 |
+
"wordpress_org" : true,
|
155 |
+
"required" : false,
|
156 |
+
"dependencies" : [ "cherry-js-core" ]
|
157 |
+
},
|
158 |
+
"cherry-utility" : {
|
159 |
+
"name" : "Utility",
|
160 |
+
"description" : "Multiple utility functions.",
|
161 |
+
"doc_link" : "",
|
162 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-utility",
|
163 |
+
"compatible" : ["theme", "plugin"],
|
164 |
+
"wordpress_org" : true,
|
165 |
+
"required" : false,
|
166 |
+
"dependencies" : []
|
167 |
+
},
|
168 |
+
"cherry-widget-factory" : {
|
169 |
+
"name" : "Widget Factory.",
|
170 |
+
"description" : "Base widget class that simplifies creating of your own widgets.",
|
171 |
+
"doc_link" : "",
|
172 |
+
"git_link" : "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-widget-factory",
|
173 |
+
"compatible" : ["theme", "plugin"],
|
174 |
+
"wordpress_org" : true,
|
175 |
+
"required" : false,
|
176 |
+
"dependencies" : [ "cherry-ui-elements" ]
|
177 |
+
},
|
178 |
+
"cherry-toolkit": {
|
179 |
+
"name": "Framework Toolkit",
|
180 |
+
"description": "Framework Toolkit contains various PHP utilities",
|
181 |
+
"doc_link": "",
|
182 |
+
"git_link": "https://github.com/CherryFramework/cherry-framework/tree/master/modules/cherry-toolkit",
|
183 |
+
"compatible": ["theme", "plugin"],
|
184 |
+
"wordpress_org": true,
|
185 |
+
"required": true,
|
186 |
+
"dependencies": []
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
cherry-framework/modules/cherry-js-core/assets/js/cherry-js-core.js
CHANGED
@@ -1,170 +1,155 @@
|
|
1 |
-
var CherryJsCore = {};
|
2 |
-
|
3 |
-
( function( $ ) {
|
4 |
-
'use strict';
|
5 |
-
|
6 |
-
CherryJsCore = {
|
7 |
-
name: 'Cherry Js Core',
|
8 |
-
version: '1.0.0',
|
9 |
-
author: 'Cherry Team',
|
10 |
-
|
11 |
-
variable: {
|
12 |
-
$document: $( document ),
|
13 |
-
$window: $( window ),
|
14 |
-
browser: $.browser,
|
15 |
-
browser_supported: true,
|
16 |
-
security: window.cherry_ajax,
|
17 |
-
loaded_assets: {
|
18 |
-
script: window.wp_load_script,
|
19 |
-
style: window.wp_load_style
|
20 |
-
},
|
21 |
-
ui_auto_init: ( 'true' === window.ui_init_object.auto_init ) ? true : false,
|
22 |
-
ui_auto_target: window.ui_init_object.targets
|
23 |
-
},
|
24 |
-
|
25 |
-
status: {
|
26 |
-
on_load: false,
|
27 |
-
is_ready: false
|
28 |
-
},
|
29 |
-
|
30 |
-
init: function(){
|
31 |
-
|
32 |
-
CherryJsCore.set_variable();
|
33 |
-
|
34 |
-
$( document ).
|
35 |
-
|
36 |
-
$( window ).
|
37 |
-
},
|
38 |
-
|
39 |
-
set_variable: function() {
|
40 |
-
//Set variable browser_supported
|
41 |
-
CherryJsCore.variable.browser_supported = ( function (){
|
42 |
-
var uset_browser = CherryJsCore.variable.browser,
|
43 |
-
not_supported = { 'msie': [8] };
|
44 |
-
|
45 |
-
for ( var browser in not_supported ) {
|
46 |
-
if( uset_browser.browser !== 'undefined' ){
|
47 |
-
for ( var version in not_supported[ browser ] ) {
|
48 |
-
if( uset_browser.version <= not_supported [ browser ] [ version ] ){
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
return true;
|
56 |
-
}() );
|
57 |
-
},
|
58 |
-
|
59 |
-
ready: function() {
|
60 |
-
CherryJsCore.status.is_ready = true;
|
61 |
-
|
62 |
-
// UI
|
63 |
-
CherryJsCore.expressions.
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
}
|
158 |
-
|
159 |
-
if ( compressScript ) {
|
160 |
-
script = new Function( compressScript ) ();
|
161 |
-
}
|
162 |
-
|
163 |
-
return callback_function();
|
164 |
-
});
|
165 |
-
}
|
166 |
-
}
|
167 |
-
};
|
168 |
-
|
169 |
-
CherryJsCore.init();
|
170 |
-
}(jQuery));
|
1 |
+
var CherryJsCore = {};
|
2 |
+
|
3 |
+
( function( $ ) {
|
4 |
+
'use strict';
|
5 |
+
|
6 |
+
CherryJsCore = {
|
7 |
+
name: 'Cherry Js Core',
|
8 |
+
version: '1.0.0',
|
9 |
+
author: 'Cherry Team',
|
10 |
+
|
11 |
+
variable: {
|
12 |
+
$document: $( document ),
|
13 |
+
$window: $( window ),
|
14 |
+
browser: $.browser,
|
15 |
+
browser_supported: true,
|
16 |
+
security: window.cherry_ajax,
|
17 |
+
loaded_assets: {
|
18 |
+
script: window.wp_load_script,
|
19 |
+
style: window.wp_load_style
|
20 |
+
},
|
21 |
+
ui_auto_init: ( 'true' === window.ui_init_object.auto_init ) ? true : false,
|
22 |
+
ui_auto_target: window.ui_init_object.targets
|
23 |
+
},
|
24 |
+
|
25 |
+
status: {
|
26 |
+
on_load: false,
|
27 |
+
is_ready: false
|
28 |
+
},
|
29 |
+
|
30 |
+
init: function(){
|
31 |
+
|
32 |
+
CherryJsCore.set_variable();
|
33 |
+
|
34 |
+
$( document ).on( 'ready', CherryJsCore.ready );
|
35 |
+
|
36 |
+
$( window ).on( 'load', CherryJsCore.load );
|
37 |
+
},
|
38 |
+
|
39 |
+
set_variable: function() {
|
40 |
+
//Set variable browser_supported
|
41 |
+
CherryJsCore.variable.browser_supported = ( function (){
|
42 |
+
var uset_browser = CherryJsCore.variable.browser,
|
43 |
+
not_supported = { 'msie': [8] };
|
44 |
+
|
45 |
+
for ( var browser in not_supported ) {
|
46 |
+
if( uset_browser.browser !== 'undefined' ){
|
47 |
+
for ( var version in not_supported[ browser ] ) {
|
48 |
+
if( uset_browser.version <= not_supported [ browser ] [ version ] ){
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return true;
|
56 |
+
}() );
|
57 |
+
},
|
58 |
+
|
59 |
+
ready: function() {
|
60 |
+
CherryJsCore.status.is_ready = true;
|
61 |
+
|
62 |
+
// UI init after widget adding to sidebar
|
63 |
+
CherryJsCore.expressions.widget_ui_init();
|
64 |
+
},
|
65 |
+
|
66 |
+
load: function() {
|
67 |
+
CherryJsCore.status.on_load = true;
|
68 |
+
},
|
69 |
+
|
70 |
+
expressions: {
|
71 |
+
widget_ui_init: function() {
|
72 |
+
$( document ).on( 'widget-added widget-updated', function( event, data ) {
|
73 |
+
$( window ).trigger( {
|
74 |
+
type: 'cherry-ui-elements-init',
|
75 |
+
_target: data
|
76 |
+
} );
|
77 |
+
} );
|
78 |
+
},
|
79 |
+
},
|
80 |
+
|
81 |
+
utilites: {
|
82 |
+
namespace: function( space_path ) {
|
83 |
+
var parts = space_path.split( '.' ),
|
84 |
+
parent = CherryJsCore,
|
85 |
+
length = parts.length,
|
86 |
+
i = 0;
|
87 |
+
|
88 |
+
for(i = 0; i < length; i += 1 ){
|
89 |
+
if( typeof parent[ parts[ i ] ] === 'undefined' ){
|
90 |
+
parent[ parts[ i ] ] = {};
|
91 |
+
}
|
92 |
+
parent = parent[ parts[ i ] ];
|
93 |
+
}
|
94 |
+
return parent;
|
95 |
+
},
|
96 |
+
get_compress_assets: function( url, callback ) {
|
97 |
+
var data = {
|
98 |
+
action: 'get_compress_assets',
|
99 |
+
security: CherryJsCore.variable.security,
|
100 |
+
style: [],
|
101 |
+
script: []
|
102 |
+
},
|
103 |
+
reg_name = /([\S.]+\/)/gmi,
|
104 |
+
reg_type = /(\.js|\.css)/gmi,
|
105 |
+
callback_function = callback || function() {};
|
106 |
+
|
107 |
+
if( !$.isArray( url ) ){
|
108 |
+
url = [ url ];
|
109 |
+
}
|
110 |
+
|
111 |
+
for( var index in url ){
|
112 |
+
var file_url = url[ index ],
|
113 |
+
file_name = file_url.replace( reg_name, '' ),
|
114 |
+
file_type = file_url.match( reg_type )[ 0 ];
|
115 |
+
|
116 |
+
if( '.js' === file_type && -1 === $.inArray( file_name, CherryJsCore.variable.loaded_assets.script ) ){
|
117 |
+
data.script.push( file_url );
|
118 |
+
CherryJsCore.variable.loaded_assets.script.push( file_name );
|
119 |
+
}
|
120 |
+
|
121 |
+
if( '.css' === file_type && -1 === $.inArray( file_name, CherryJsCore.variable.loaded_assets.style ) ){
|
122 |
+
data.style.push( file_url );
|
123 |
+
CherryJsCore.variable.loaded_assets.style.push( file_name );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
$.get( window.ajaxurl, data, function( response ) {
|
128 |
+
var json = $.parseJSON(response),
|
129 |
+
compressStyle = json.style,
|
130 |
+
compressScript = json.script,
|
131 |
+
script = null;
|
132 |
+
|
133 |
+
if(compressStyle){
|
134 |
+
var style = document.createElement('style');
|
135 |
+
|
136 |
+
style.type = 'text/css';
|
137 |
+
style.media = 'all';
|
138 |
+
style.innerHTML = compressStyle;
|
139 |
+
|
140 |
+
$('body', document).append(style);
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
if ( compressScript ) {
|
145 |
+
script = new Function( compressScript ) ();
|
146 |
+
}
|
147 |
+
|
148 |
+
return callback_function();
|
149 |
+
});
|
150 |
+
}
|
151 |
+
}
|
152 |
+
};
|
153 |
+
|
154 |
+
CherryJsCore.init();
|
155 |
+
}(jQuery));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cherry-framework/modules/cherry-js-core/assets/js/min/cherry-js-core.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var CherryJsCore={};!function(e){"use strict";CherryJsCore={name:"Cherry Js Core",version:"1.0.0",author:"Cherry Team",variable:{$document:e(document),$window:e(window),browser:e.browser,browser_supported:!0,security:window.cherry_ajax,loaded_assets:{script:window.wp_load_script,style:window.wp_load_style},ui_auto_init:"true"===window.ui_init_object.auto_init?!0:!1,ui_auto_target:window.ui_init_object.targets},status:{on_load:!1,is_ready:!1},init:function(){CherryJsCore.set_variable(),e(document).ready
|
1 |
+
var CherryJsCore={};!function(e){"use strict";CherryJsCore={name:"Cherry Js Core",version:"1.0.0",author:"Cherry Team",variable:{$document:e(document),$window:e(window),browser:e.browser,browser_supported:!0,security:window.cherry_ajax,loaded_assets:{script:window.wp_load_script,style:window.wp_load_style},ui_auto_init:"true"===window.ui_init_object.auto_init?!0:!1,ui_auto_target:window.ui_init_object.targets},status:{on_load:!1,is_ready:!1},init:function(){CherryJsCore.set_variable(),e(document).on("ready",CherryJsCore.ready),e(window).on("load",CherryJsCore.load)},set_variable:function(){CherryJsCore.variable.browser_supported=function(){var e=CherryJsCore.variable.browser,r={msie:[8]};for(var s in r)if("undefined"!==e.browser)for(var t in r[s])if(e.version<=r[s][t])return!1;return!0}()},ready:function(){CherryJsCore.status.is_ready=!0,CherryJsCore.expressions.widget_ui_init()},load:function(){CherryJsCore.status.on_load=!0},expressions:{widget_ui_init:function(){e(document).on("widget-added widget-updated",function(r,s){e(window).trigger({type:"cherry-ui-elements-init",_target:s})})}},utilites:{namespace:function(e){var r=e.split("."),s=CherryJsCore,t=r.length,i=0;for(i=0;t>i;i+=1)"undefined"==typeof s[r[i]]&&(s[r[i]]={}),s=s[r[i]];return s},get_compress_assets:function(r,s){var t={action:"get_compress_assets",security:CherryJsCore.variable.security,style:[],script:[]},i=/([\S.]+\/)/gim,o=/(\.js|\.css)/gim,a=s||function(){};e.isArray(r)||(r=[r]);for(var n in r){var d=r[n],u=d.replace(i,""),y=d.match(o)[0];".js"===y&&-1===e.inArray(u,CherryJsCore.variable.loaded_assets.script)&&(t.script.push(d),CherryJsCore.variable.loaded_assets.script.push(u)),".css"===y&&-1===e.inArray(u,CherryJsCore.variable.loaded_assets.style)&&(t.style.push(d),CherryJsCore.variable.loaded_assets.style.push(u))}e.get(window.ajaxurl,t,function(r){var s=e.parseJSON(r),t=s.style,i=s.script,o=null;if(t){var n=document.createElement("style");n.type="text/css",n.media="all",n.innerHTML=t,e("body",document).append(n)}return i&&(o=new Function(i)()),a()})}}},CherryJsCore.init()}(jQuery);
|
cherry-framework/modules/cherry-js-core/cherry-js-core.php
CHANGED
@@ -1,184 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Module Name: JS Core
|
4 |
-
* Description: Initializes global JS object which provides additional plugin functionality
|
5 |
-
* Version: 1.1.
|
6 |
-
* Author: Cherry Team
|
7 |
-
* Author URI: http://www.cherryframework.com/
|
8 |
-
* License: GPLv3
|
9 |
-
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
-
*
|
11 |
-
* @package Cherry_Framework
|
12 |
-
* @subpackage Modules
|
13 |
-
* @version 1.1.
|
14 |
-
* @author Cherry Team <cherryframework@gmail.com>
|
15 |
-
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
16 |
-
* @link http://www.cherryframework.com/
|
17 |
-
* @license http://www.gnu.org/licenses/gpl-3.0.html
|
18 |
-
*/
|
19 |
-
|
20 |
-
// If this file is called directly, abort.
|
21 |
-
if ( ! defined( 'WPINC' ) ) {
|
22 |
-
die;
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( ! class_exists( 'Cherry_Js_Core' ) ) {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* JS-core class.
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @since 1.0.1 Removed `module_directory` and `module_directory_uri` properties.
|
32 |
-
*/
|
33 |
-
class Cherry_Js_Core {
|
34 |
-
|
35 |
-
/**
|
36 |
-
* A reference to an instance of this class.
|
37 |
-
*
|
38 |
-
* @since 1.0.0
|
39 |
-
* @var object
|
40 |
-
*/
|
41 |
-
private static $instance = null;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Module version.
|
45 |
-
*
|
46 |
-
* @since 1.0.0
|
47 |
-
* @var string
|
48 |
-
*/
|
49 |
-
private $module_version = '1.1.0';
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Default options.
|
53 |
-
*
|
54 |
-
* @since 1.0.0
|
55 |
-
* @var array
|
56 |
-
*/
|
57 |
-
private $options = array(
|
58 |
-
'product_type' => 'framework',
|
59 |
-
'src' => false,
|
60 |
-
'version' => false,
|
61 |
-
);
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Class constructor.
|
65 |
-
*
|
66 |
-
* @since 1.0.0
|
67 |
-
* @param object $core Core instance.
|
68 |
-
* @param array $args Class args.
|
69 |
-
*/
|
70 |
-
public function __construct( $core, $args = array() ) {
|
71 |
-
$this->options = array_merge( $this->options, $args );
|
72 |
-
|
73 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
|
74 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
|
75 |
-
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Register and enqueue JS-core.
|
80 |
-
*
|
81 |
-
* @since 1.0.0
|
82 |
-
*/
|
83 |
-
public function enqueue_cherry_scripts() {
|
84 |
-
|
85 |
-
if ( 'framework' === $this->options['product_type'] ) {
|
86 |
-
$src = esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-js-core.min.js', __FILE__ ) );
|
87 |
-
$version = $this->module_version;
|
88 |
-
} else {
|
89 |
-
$src = ( ! empty( $this->options['src'] ) ? esc_url( $this->options['src'] ) : false );
|
90 |
-
$version = ( ! empty( $this->options['version'] ) ? absint( $this->options['src'] ) : false );
|
91 |
-
}
|
92 |
-
|
93 |
-
wp_enqueue_script( 'cherry-js-core', $src, array( 'jquery' ), $version, true );
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Retrieve a scripts list.
|
98 |
-
*
|
99 |
-
* @since 1.0.0
|
100 |
-
* @return $array
|
101 |
-
*/
|
102 |
-
private function get_include_script() {
|
103 |
-
return $this->add_suffix( '.js', wp_scripts()->queue );
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Retrieve a styles list.
|
108 |
-
*
|
109 |
-
* @since 1.0.0
|
110 |
-
* @return $array
|
111 |
-
*/
|
112 |
-
private function get_include_style() {
|
113 |
-
return $this->add_suffix( '.css', wp_styles()->queue );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* [get_ui_init_settings]
|
118 |
-
*
|
119 |
-
* @since 1.0.0
|
120 |
-
* @return $array
|
121 |
-
*/
|
122 |
-
private function get_ui_init_settings() {
|
123 |
-
|
124 |
-
// Default auto ui init settings.
|
125 |
-
$ui_init_settings = array(
|
126 |
-
'auto_init' => false,
|
127 |
-
'targets' => array(),
|
128 |
-
);
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Filter to determine the list of selectors and the value of the automatic initialization ui js scripts
|
132 |
-
*
|
133 |
-
* @var array
|
134 |
-
*/
|
135 |
-
return apply_filters( 'cherry_core_js_ui_init_settings', $ui_init_settings );
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Add suffix to array.
|
140 |
-
*
|
141 |
-
* @since 1.0.0
|
142 |
-
*/
|
143 |
-
private function add_suffix( $suffix, $array ) {
|
144 |
-
|
145 |
-
foreach ( $array as $key => $value ) {
|
146 |
-
$array[ $key ] = $value . $suffix;
|
147 |
-
}
|
148 |
-
|
149 |
-
return $array;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Prepare data for API script.
|
154 |
-
*
|
155 |
-
* @since 1.0.0
|
156 |
-
* @return void
|
157 |
-
*/
|
158 |
-
public function localize_script() {
|
159 |
-
wp_localize_script( 'cherry-js-core', 'wp_load_style', $this->get_include_style() );
|
160 |
-
wp_localize_script( 'cherry-js-core', 'wp_load_script', $this->get_include_script() );
|
161 |
-
wp_localize_script( 'cherry-js-core', 'cherry_ajax', wp_create_nonce( 'cherry_ajax_nonce' ) );
|
162 |
-
|
163 |
-
$ui_init_settings = $this->get_ui_init_settings();
|
164 |
-
$ui_init_settings['auto_init'] = ( true == $ui_init_settings['auto_init'] ) ? 'true' : 'false';
|
165 |
-
wp_localize_script( 'cherry-js-core', 'ui_init_object', $ui_init_settings );
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Returns the instance.
|
170 |
-
*
|
171 |
-
* @since 1.0.0
|
172 |
-
* @return object
|
173 |
-
*/
|
174 |
-
public static function get_instance( $core, $args ) {
|
175 |
-
|
176 |
-
// If the single instance hasn't been set, set it now.
|
177 |
-
if ( null == self::$instance ) {
|
178 |
-
self::$instance = new self( $core, $args );
|
179 |
-
}
|
180 |
-
|
181 |
-
return self::$instance;
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Module Name: JS Core
|
4 |
+
* Description: Initializes global JS object which provides additional plugin functionality
|
5 |
+
* Version: 1.1.2
|
6 |
+
* Author: Cherry Team
|
7 |
+
* Author URI: http://www.cherryframework.com/
|
8 |
+
* License: GPLv3
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
*
|
11 |
+
* @package Cherry_Framework
|
12 |
+
* @subpackage Modules
|
13 |
+
* @version 1.1.2
|
14 |
+
* @author Cherry Team <cherryframework@gmail.com>
|
15 |
+
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
16 |
+
* @link http://www.cherryframework.com/
|
17 |
+
* @license http://www.gnu.org/licenses/gpl-3.0.html
|
18 |
+
*/
|
19 |
+
|
20 |
+
// If this file is called directly, abort.
|
21 |
+
if ( ! defined( 'WPINC' ) ) {
|
22 |
+
die;
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( ! class_exists( 'Cherry_Js_Core' ) ) {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* JS-core class.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @since 1.0.1 Removed `module_directory` and `module_directory_uri` properties.
|
32 |
+
*/
|
33 |
+
class Cherry_Js_Core {
|
34 |
+
|
35 |
+
/**
|
36 |
+
* A reference to an instance of this class.
|
37 |
+
*
|
38 |
+
* @since 1.0.0
|
39 |
+
* @var object
|
40 |
+
*/
|
41 |
+
private static $instance = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Module version.
|
45 |
+
*
|
46 |
+
* @since 1.0.0
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
private $module_version = '1.1.0';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Default options.
|
53 |
+
*
|
54 |
+
* @since 1.0.0
|
55 |
+
* @var array
|
56 |
+
*/
|
57 |
+
private $options = array(
|
58 |
+
'product_type' => 'framework',
|
59 |
+
'src' => false,
|
60 |
+
'version' => false,
|
61 |
+
);
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Class constructor.
|
65 |
+
*
|
66 |
+
* @since 1.0.0
|
67 |
+
* @param object $core Core instance.
|
68 |
+
* @param array $args Class args.
|
69 |
+
*/
|
70 |
+
public function __construct( $core, $args = array() ) {
|
71 |
+
$this->options = array_merge( $this->options, $args );
|
72 |
+
|
73 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
|
74 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
|
75 |
+
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Register and enqueue JS-core.
|
80 |
+
*
|
81 |
+
* @since 1.0.0
|
82 |
+
*/
|
83 |
+
public function enqueue_cherry_scripts() {
|
84 |
+
|
85 |
+
if ( 'framework' === $this->options['product_type'] ) {
|
86 |
+
$src = esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-js-core.min.js', __FILE__ ) );
|
87 |
+
$version = $this->module_version;
|
88 |
+
} else {
|
89 |
+
$src = ( ! empty( $this->options['src'] ) ? esc_url( $this->options['src'] ) : false );
|
90 |
+
$version = ( ! empty( $this->options['version'] ) ? absint( $this->options['src'] ) : false );
|
91 |
+
}
|
92 |
+
|
93 |
+
wp_enqueue_script( 'cherry-js-core', $src, array( 'jquery' ), $version, true );
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Retrieve a scripts list.
|
98 |
+
*
|
99 |
+
* @since 1.0.0
|
100 |
+
* @return $array
|
101 |
+
*/
|
102 |
+
private function get_include_script() {
|
103 |
+
return $this->add_suffix( '.js', wp_scripts()->queue );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Retrieve a styles list.
|
108 |
+
*
|
109 |
+
* @since 1.0.0
|
110 |
+
* @return $array
|
111 |
+
*/
|
112 |
+
private function get_include_style() {
|
113 |
+
return $this->add_suffix( '.css', wp_styles()->queue );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* [get_ui_init_settings]
|
118 |
+
*
|
119 |
+
* @since 1.0.0
|
120 |
+
* @return $array
|
121 |
+
*/
|
122 |
+
private function get_ui_init_settings() {
|
123 |
+
|
124 |
+
// Default auto ui init settings.
|
125 |
+
$ui_init_settings = array(
|
126 |
+
'auto_init' => false,
|
127 |
+
'targets' => array(),
|
128 |
+
);
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Filter to determine the list of selectors and the value of the automatic initialization ui js scripts
|
132 |
+
*
|
133 |
+
* @var array
|
134 |
+
*/
|
135 |
+
return apply_filters( 'cherry_core_js_ui_init_settings', $ui_init_settings );
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Add suffix to array.
|
140 |
+
*
|
141 |
+
* @since 1.0.0
|
142 |
+
*/
|
143 |
+
private function add_suffix( $suffix, $array ) {
|
144 |
+
|
145 |
+
foreach ( $array as $key => $value ) {
|
146 |
+
$array[ $key ] = $value . $suffix;
|
147 |
+
}
|
148 |
+
|
149 |
+
return $array;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Prepare data for API script.
|
154 |
+
*
|
155 |
+
* @since 1.0.0
|
156 |
+
* @return void
|
157 |
+
*/
|
158 |
+
public function localize_script() {
|
159 |
+
wp_localize_script( 'cherry-js-core', 'wp_load_style', $this->get_include_style() );
|
160 |
+
wp_localize_script( 'cherry-js-core', 'wp_load_script', $this->get_include_script() );
|
161 |
+
wp_localize_script( 'cherry-js-core', 'cherry_ajax', wp_create_nonce( 'cherry_ajax_nonce' ) );
|
162 |
+
|
163 |
+
$ui_init_settings = $this->get_ui_init_settings();
|
164 |
+
$ui_init_settings['auto_init'] = ( true == $ui_init_settings['auto_init'] ) ? 'true' : 'false';
|
165 |
+
wp_localize_script( 'cherry-js-core', 'ui_init_object', $ui_init_settings );
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Returns the instance.
|
170 |
+
*
|
171 |
+
* @since 1.0.0
|
172 |
+
* @return object
|
173 |
+
*/
|
174 |
+
public static function get_instance( $core, $args ) {
|
175 |
+
|
176 |
+
// If the single instance hasn't been set, set it now.
|
177 |
+
if ( null == self::$instance ) {
|
178 |
+
self::$instance = new self( $core, $args );
|
179 |
+
}
|
180 |
+
|
181 |
+
return self::$instance;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
cherry-framework/modules/cherry-ui-elements/cherry-ui-elements.php
CHANGED
@@ -1,152 +1,152 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Module Name: UI Elements
|
4 |
-
* Description: Class for the building ui elements
|
5 |
-
* Version: 1.1.
|
6 |
-
* Author: Cherry Team
|
7 |
-
* Author URI: http://www.cherryframework.com/
|
8 |
-
* License: GPLv3
|
9 |
-
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
-
*
|
11 |
-
* @package Cherry_Framework
|
12 |
-
* @subpackage Modules
|
13 |
-
* @version 1.1.
|
14 |
-
* @author Cherry Team <cherryframework@gmail.com>
|
15 |
-
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
16 |
-
* @link http://www.cherryframework.com/
|
17 |
-
* @license http://www.gnu.org/licenses/gpl-3.0.html
|
18 |
-
*/
|
19 |
-
|
20 |
-
// If this file is called directly, abort.
|
21 |
-
if ( ! defined( 'WPINC' ) ) {
|
22 |
-
die;
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( ! class_exists( 'Cherry_UI_Elements' ) ) {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Class for the building ui elements.
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @since 1.0.3 Removed `module_directory` and `module_directory_uri` properties.
|
32 |
-
*/
|
33 |
-
class Cherry_UI_Elements {
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Default arguments.
|
37 |
-
*
|
38 |
-
* @since 1.0.0
|
39 |
-
* @var array
|
40 |
-
*/
|
41 |
-
private $args = array(
|
42 |
-
'ui_elements' => array(
|
43 |
-
'text',
|
44 |
-
'textarea',
|
45 |
-
'select',
|
46 |
-
'checkbox',
|
47 |
-
'radio',
|
48 |
-
'colorpicker',
|
49 |
-
'media',
|
50 |
-
'stepper',
|
51 |
-
'switcher',
|
52 |
-
'slider',
|
53 |
-
'repeater',
|
54 |
-
'iconpicker',
|
55 |
-
),
|
56 |
-
);
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Constructor.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @param object $core Core.
|
63 |
-
* @param array $args Arguments.
|
64 |
-
*/
|
65 |
-
public function __construct( $core, $args ) {
|
66 |
-
$this->args = array_merge( $this->args, $args );
|
67 |
-
$this->ui_elements_require();
|
68 |
-
|
69 |
-
// Load admin assets.
|
70 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
|
71 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Get UI-element instance.
|
76 |
-
*
|
77 |
-
* @since 1.0.0
|
78 |
-
* @param [type] $ui_slug ui element.
|
79 |
-
* @param array $args arguments.
|
80 |
-
* @return object
|
81 |
-
*/
|
82 |
-
public function get_ui_element_instance( $ui_slug, $args ) {
|
83 |
-
|
84 |
-
if ( empty( $ui_slug ) ) {
|
85 |
-
echo '<p>Set an empty slug</p>';
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
|
89 |
-
if ( ! in_array( $ui_slug, $this->args['ui_elements'] ) ) {
|
90 |
-
echo '<p> Element <b>' . $ui_slug . '</b> has not been initialized in this instance!</p>';
|
91 |
-
return false;
|
92 |
-
}
|
93 |
-
|
94 |
-
$ui_class_name = 'UI_' . ucwords( $ui_slug );
|
95 |
-
|
96 |
-
if ( ! class_exists( $ui_class_name ) ) {
|
97 |
-
echo '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
return new $ui_class_name( $args );
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Require UI-elements.
|
105 |
-
*
|
106 |
-
* @since 1.0.0
|
107 |
-
* @return void
|
108 |
-
*/
|
109 |
-
public function ui_elements_require() {
|
110 |
-
|
111 |
-
// Add I_UI interface.
|
112 |
-
if ( ! interface_exists( 'I_UI' ) ) {
|
113 |
-
require_once( __DIR__ . '/i-ui.php' );
|
114 |
-
}
|
115 |
-
|
116 |
-
if ( ! class_exists( 'UI_Element' ) ) {
|
117 |
-
require_once( __DIR__ . '/ui-element.php' );
|
118 |
-
}
|
119 |
-
|
120 |
-
if ( ! empty( $this->args['ui_elements'] ) ) {
|
121 |
-
foreach ( $this->args['ui_elements'] as $ui_element ) {
|
122 |
-
require_once( __DIR__ . '/inc/ui-elements/ui-' . $ui_element . '/ui-' . $ui_element . '.php' );
|
123 |
-
}
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Load admin assets.
|
129 |
-
*
|
130 |
-
* @since 1.0.0
|
131 |
-
*/
|
132 |
-
public function enqueue_admin_assets() {
|
133 |
-
if ( ! empty( $this->args['ui_elements'] ) ) {
|
134 |
-
foreach ( $this->args['ui_elements'] as $ui_element ) {
|
135 |
-
$ui_class_name = 'UI_' . ucwords( $ui_element );
|
136 |
-
call_user_func( array( $ui_class_name, 'enqueue_assets' ) );
|
137 |
-
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Returns the instance.
|
144 |
-
*
|
145 |
-
* @since 1.0.0
|
146 |
-
* @return object
|
147 |
-
*/
|
148 |
-
public static function get_instance( $core, $args ) {
|
149 |
-
return new self( $core, $args );
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Module Name: UI Elements
|
4 |
+
* Description: Class for the building ui elements
|
5 |
+
* Version: 1.1.3
|
6 |
+
* Author: Cherry Team
|
7 |
+
* Author URI: http://www.cherryframework.com/
|
8 |
+
* License: GPLv3
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
*
|
11 |
+
* @package Cherry_Framework
|
12 |
+
* @subpackage Modules
|
13 |
+
* @version 1.1.3
|
14 |
+
* @author Cherry Team <cherryframework@gmail.com>
|
15 |
+
* @copyright Copyright (c) 2012 - 2016, Cherry Team
|
16 |
+
* @link http://www.cherryframework.com/
|
17 |
+
* @license http://www.gnu.org/licenses/gpl-3.0.html
|
18 |
+
*/
|
19 |
+
|
20 |
+
// If this file is called directly, abort.
|
21 |
+
if ( ! defined( 'WPINC' ) ) {
|
22 |
+
die;
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( ! class_exists( 'Cherry_UI_Elements' ) ) {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Class for the building ui elements.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @since 1.0.3 Removed `module_directory` and `module_directory_uri` properties.
|
32 |
+
*/
|
33 |
+
class Cherry_UI_Elements {
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Default arguments.
|
37 |
+
*
|
38 |
+
* @since 1.0.0
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
private $args = array(
|
42 |
+
'ui_elements' => array(
|
43 |
+
'text',
|
44 |
+
'textarea',
|
45 |
+
'select',
|
46 |
+
'checkbox',
|
47 |
+
'radio',
|
48 |
+
'colorpicker',
|
49 |
+
'media',
|
50 |
+
'stepper',
|
51 |
+
'switcher',
|
52 |
+
'slider',
|
53 |
+
'repeater',
|
54 |
+
'iconpicker',
|
55 |
+
),
|
56 |
+
);
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Constructor.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
* @param object $core Core.
|
63 |
+
* @param array $args Arguments.
|
64 |
+
*/
|
65 |
+
public function __construct( $core, $args ) {
|
66 |
+
$this->args = array_merge( $this->args, $args );
|
67 |
+
$this->ui_elements_require();
|
68 |
+
|
69 |
+
// Load admin assets.
|
70 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
|
71 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Get UI-element instance.
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
* @param [type] $ui_slug ui element.
|
79 |
+
* @param array $args arguments.
|
80 |
+
* @return object
|
81 |
+
*/
|
82 |
+
public function get_ui_element_instance( $ui_slug, $args ) {
|
83 |
+
|
84 |
+
if ( empty( $ui_slug ) ) {
|
85 |
+
echo '<p>Set an empty slug</p>';
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( ! in_array( $ui_slug, $this->args['ui_elements'] ) ) {
|
90 |
+
echo '<p> Element <b>' . $ui_slug . '</b> has not been initialized in this instance!</p>';
|
91 |
+
return false;
|
92 |
+
}
|
93 |
+
|
94 |
+
$ui_class_name = 'UI_' . ucwords( $ui_slug );
|
95 |
+
|
96 |
+
if ( ! class_exists( $ui_class_name ) ) {
|
97 |
+
echo '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
return new $ui_class_name( $args );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Require UI-elements.
|
105 |
+
*
|
106 |
+
* @since 1.0.0
|
107 |
+
* @return void
|
108 |
+
*/
|
109 |
+
public function ui_elements_require() {
|
110 |
+
|
111 |
+
// Add I_UI interface.
|
112 |
+
if ( ! interface_exists( 'I_UI' ) ) {
|
113 |
+
require_once( __DIR__ . '/i-ui.php' );
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( ! class_exists( 'UI_Element' ) ) {
|
117 |
+
require_once( __DIR__ . '/ui-element.php' );
|
118 |
+
}
|
119 |
+
|
120 |
+
if ( ! empty( $this->args['ui_elements'] ) ) {
|
121 |
+
foreach ( $this->args['ui_elements'] as $ui_element ) {
|
122 |
+
require_once( __DIR__ . '/inc/ui-elements/ui-' . $ui_element . '/ui-' . $ui_element . '.php' );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Load admin assets.
|
129 |
+
*
|
130 |
+
* @since 1.0.0
|
131 |
+
*/
|
132 |
+
public function enqueue_admin_assets() {
|
133 |
+
if ( ! empty( $this->args['ui_elements'] ) ) {
|
134 |
+
foreach ( $this->args['ui_elements'] as $ui_element ) {
|
135 |
+
$ui_class_name = 'UI_' . ucwords( $ui_element );
|
136 |
+
call_user_func( array( $ui_class_name, 'enqueue_assets' ) );
|
137 |
+
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Returns the instance.
|
144 |
+
*
|
145 |
+
* @since 1.0.0
|
146 |
+
* @return object
|
147 |
+
*/
|
148 |
+
public static function get_instance( $core, $args ) {
|
149 |
+
return new self( $core, $args );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,c){"use strict";c.utilites.namespace("ui_elements.checkbox"),c.ui_elements.checkbox={init:function(){e(window).on("cherry-ui-elements-init",this.render
|
1 |
+
!function(e,c){"use strict";c.utilites.namespace("ui_elements.checkbox"),c.ui_elements.checkbox={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(c){var i=c._target?c._target:e("body");e('.cherry-checkbox-input[type="hidden"]',i).each(function(){var c=e(this),t=c.data("slave"),s="true"===c.val();s||e("."+t,i).stop().hide()}),e(".cherry-checkbox-item",i).on("click",function(){var c=e(this).siblings('.cherry-checkbox-input[type="hidden"]'),t=c.data("slave"),s="true"===c.val();e(this).hasClass("checked")?(e(this).removeClass("checked"),c.val("false"),s=!1,e("."+t,i).hide()):(e(this).addClass("checked"),c.val("true"),s=!0,e("."+t,i).show()),c.trigger("change")}),e(".cherry-checkbox-label",i).on("click",function(){var c=e(this).siblings('.cherry-checkbox-input[type="hidden"]'),t=e(this).siblings(".cherry-checkbox-item"),s=c.data("slave"),h="true"===c.val();t.hasClass("checked")?(t.removeClass("checked"),c.val("false"),h=!1,e("."+s,i).hide()):(t.addClass("checked"),c.val("true"),h=!0,e("."+s,i).show()),c.trigger("change")})}},c.ui_elements.checkbox.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-checkbox/assets/ui-checkbox.js
CHANGED
@@ -1,73 +1,74 @@
|
|
1 |
-
/**
|
2 |
-
* Checkbox
|
3 |
-
*/
|
4 |
-
(function($, CherryJsCore){
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.checkbox');
|
8 |
-
CherryJsCore.ui_elements.checkbox = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
1 |
+
/**
|
2 |
+
* Checkbox
|
3 |
+
*/
|
4 |
+
(function($, CherryJsCore){
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.checkbox');
|
8 |
+
CherryJsCore.ui_elements.checkbox = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function ( event ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' );
|
15 |
+
|
16 |
+
$( '.cherry-checkbox-input[type="hidden"]', target ).each( function() {
|
17 |
+
var $this = $( this ),
|
18 |
+
this_slave = $this.data( 'slave' ),
|
19 |
+
state = ( $this.val() === 'true' );
|
20 |
+
|
21 |
+
if ( ! state ) {
|
22 |
+
$( '.'+ this_slave, target ).stop().hide();
|
23 |
+
}
|
24 |
+
});
|
25 |
+
|
26 |
+
$( '.cherry-checkbox-item', target ).on( 'click', function() {
|
27 |
+
var input = $( this ).siblings( '.cherry-checkbox-input[type="hidden"]' ),
|
28 |
+
slave = input.data( 'slave' ),
|
29 |
+
state = ( input.val() === 'true' );
|
30 |
+
|
31 |
+
if ( $( this ).hasClass( 'checked' ) ) {
|
32 |
+
$( this ).removeClass( 'checked' );
|
33 |
+
input.val( 'false' );
|
34 |
+
state = false;
|
35 |
+
|
36 |
+
$( '.' + slave, target ).hide();
|
37 |
+
} else {
|
38 |
+
$( this ).addClass( 'checked' );
|
39 |
+
input.val( 'true' );
|
40 |
+
state = true;
|
41 |
+
|
42 |
+
$( '.' + slave, target ).show();
|
43 |
+
}
|
44 |
+
|
45 |
+
input.trigger( 'change' );
|
46 |
+
} );
|
47 |
+
|
48 |
+
$( '.cherry-checkbox-label', target ).on( 'click', function() {
|
49 |
+
var input = $( this ).siblings( '.cherry-checkbox-input[type="hidden"]' ),
|
50 |
+
item = $( this ).siblings( '.cherry-checkbox-item' ),
|
51 |
+
slave = input.data( 'slave' ),
|
52 |
+
state = ( input.val() === 'true' );
|
53 |
+
|
54 |
+
if ( item.hasClass( 'checked' ) ) {
|
55 |
+
item.removeClass( 'checked' );
|
56 |
+
input.val( 'false' );
|
57 |
+
state = false;
|
58 |
+
|
59 |
+
$( '.' + slave, target ).hide();
|
60 |
+
} else {
|
61 |
+
item.addClass( 'checked' );
|
62 |
+
input.val( 'true' );
|
63 |
+
state = true;
|
64 |
+
|
65 |
+
$( '.' + slave, target ).show();
|
66 |
+
}
|
67 |
+
|
68 |
+
input.trigger( 'change' );
|
69 |
+
} );
|
70 |
+
}
|
71 |
+
};
|
72 |
+
|
73 |
+
CherryJsCore.ui_elements.checkbox.init();
|
74 |
+
}(jQuery, window.CherryJsCore));
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-colorpicker/assets/min/ui-colorpicker.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,
|
1 |
+
!function(e,r){"use strict";r.utilites.namespace("ui_elements.colorpicker"),r.ui_elements.colorpicker={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(r){var i=r._target?r._target:e("body"),n=e('input.cherry-ui-colorpicker:not([name*="__i__"])',i);n[0]&&n.wpColorPicker()}},r.ui_elements.colorpicker.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-colorpicker/assets/ui-colorpicker.js
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
-
/**
|
2 |
-
* ColorPicker
|
3 |
-
*/
|
4 |
-
( function( $, CherryJsCore ) {
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.colorpicker');
|
8 |
-
CherryJsCore.ui_elements.colorpicker = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
1 |
+
/**
|
2 |
+
* ColorPicker
|
3 |
+
*/
|
4 |
+
( function( $, CherryJsCore ) {
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.colorpicker');
|
8 |
+
CherryJsCore.ui_elements.colorpicker = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function ( event ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' ),
|
15 |
+
input = $( 'input.cherry-ui-colorpicker:not([name*="__i__"])', target );
|
16 |
+
|
17 |
+
if ( input[0] ) {
|
18 |
+
input.wpColorPicker();
|
19 |
+
}
|
20 |
+
}
|
21 |
+
};
|
22 |
+
|
23 |
+
CherryJsCore.ui_elements.colorpicker.init();
|
24 |
+
|
25 |
+
}( jQuery, window.CherryJsCore ));
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/jquery-iconpicker.js
ADDED
@@ -0,0 +1,1445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* Font Awesome Icon Picker
|
3 |
+
* http://mjolnic.github.io/fontawesome-iconpicker/
|
4 |
+
*
|
5 |
+
* Originally written by (c) 2014 Javier Aguilar @mjolnic
|
6 |
+
* Licensed under the MIT License
|
7 |
+
* https://github.com/mjolnic/fontawesome-iconpicker/blob/master/LICENSE
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
(function(factory) {
|
12 |
+
"use strict";
|
13 |
+
if (typeof define === 'function' && define.amd) {
|
14 |
+
define(['jquery'], factory);
|
15 |
+
} else if (window.jQuery && !window.jQuery.fn.iconpicker) {
|
16 |
+
factory(window.jQuery);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
(function($) {
|
20 |
+
'use strict';
|
21 |
+
|
22 |
+
var _helpers = {
|
23 |
+
isEmpty: function(val) {
|
24 |
+
return ((val === false) || (val === '') || (val === null) || (val === undefined));
|
25 |
+
},
|
26 |
+
isEmptyObject: function(val) {
|
27 |
+
return (this.isEmpty(val) === true) || (val.length === 0);
|
28 |
+
},
|
29 |
+
isElement: function(selector) {
|
30 |
+
return ($(selector).length > 0);
|
31 |
+
},
|
32 |
+
isString: function(val) {
|
33 |
+
return ((typeof val === 'string') || (val instanceof String));
|
34 |
+
},
|
35 |
+
isArray: function(val) {
|
36 |
+
return $.isArray(val);
|
37 |
+
},
|
38 |
+
inArray: function(val, arr) {
|
39 |
+
return ($.inArray(val, arr) !== -1);
|
40 |
+
},
|
41 |
+
throwError: function(text) {
|
42 |
+
throw "Font Awesome Icon Picker Exception: " + text;
|
43 |
+
}
|
44 |
+
};
|
45 |
+
|
46 |
+
var Iconpicker = function(element, options) {
|
47 |
+
this._id = Iconpicker._idCounter++;
|
48 |
+
this.element = $(element).addClass('iconpicker-element');
|
49 |
+
this._trigger('iconpickerCreate');
|
50 |
+
this.options = $.extend({}, Iconpicker.defaultOptions, this.element.data(), options);
|
51 |
+
this.options.templates = $.extend({}, Iconpicker.defaultOptions.templates, this.options.templates);
|
52 |
+
this.options.originalPlacement = this.options.placement;
|
53 |
+
|
54 |
+
// Iconpicker container element
|
55 |
+
this.container = (_helpers.isElement(this.options.container) ? $(this.options.container) : false);
|
56 |
+
if (this.container === false) {
|
57 |
+
if (this.element.is('.dropdown-toggle')) {
|
58 |
+
this.container = $('~ .dropdown-menu:first', this.element);
|
59 |
+
} else {
|
60 |
+
this.container = (this.element.is('input,textarea,button,.btn') ? this.element.parent() : this.element);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
this.container.addClass('iconpicker-container');
|
64 |
+
|
65 |
+
if (this.isDropdownMenu()) {
|
66 |
+
// if you try to click the dropdown, it is closed, because of that
|
67 |
+
// we'll hide some picker controls
|
68 |
+
this.options.templates.search = false;
|
69 |
+
this.options.templates.buttons = false;
|
70 |
+
this.options.placement = 'inline';
|
71 |
+
}
|
72 |
+
|
73 |
+
// Is the element an input? Should we search inside for any input?
|
74 |
+
this.input = (this.element.is('input,textarea') ? this.element.addClass('iconpicker-input') : false);
|
75 |
+
if (this.input === false) {
|
76 |
+
this.input = (this.container.find(this.options.input));
|
77 |
+
if (!this.input.is('input,textarea')) {
|
78 |
+
this.input = false;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
// Plugin as component ?
|
83 |
+
this.component = this.isDropdownMenu() ? this.container.parent().find(this.options.component) : this.container.find(this.options.component);
|
84 |
+
if (this.component.length === 0) {
|
85 |
+
this.component = false;
|
86 |
+
} else {
|
87 |
+
this.component.find('i').addClass('iconpicker-component');
|
88 |
+
}
|
89 |
+
|
90 |
+
// Create popover and iconpicker HTML
|
91 |
+
this._createPopover();
|
92 |
+
this._createIconpicker();
|
93 |
+
|
94 |
+
if (this.getAcceptButton().length === 0) {
|
95 |
+
// disable this because we don't have accept buttons
|
96 |
+
this.options.mustAccept = false;
|
97 |
+
}
|
98 |
+
|
99 |
+
// Avoid CSS issues with input-group-addon(s)
|
100 |
+
if (this.isInputGroup()) {
|
101 |
+
this.container.parent().append(this.popover);
|
102 |
+
} else {
|
103 |
+
this.container.append(this.popover);
|
104 |
+
}
|
105 |
+
|
106 |
+
// Bind events
|
107 |
+
this._bindElementEvents();
|
108 |
+
this._bindWindowEvents();
|
109 |
+
|
110 |
+
// Refresh everything
|
111 |
+
this.update(this.options.selected);
|
112 |
+
|
113 |
+
if (this.isInline()) {
|
114 |
+
this.show();
|
115 |
+
}
|
116 |
+
|
117 |
+
this._trigger('iconpickerCreated');
|
118 |
+
};
|
119 |
+
|
120 |
+
// Instance identifier counter
|
121 |
+
Iconpicker._idCounter = 0;
|
122 |
+
|
123 |
+
Iconpicker.defaultOptions = {
|
124 |
+
title: false, // Popover title (optional) only if specified in the template
|
125 |
+
selected: false, // use this value as the current item and ignore the original
|
126 |
+
defaultValue: false, // use this value as the current item if input or element value is empty
|
127 |
+
placement: 'bottom', // (has some issues with auto and CSS). auto, top, bottom, left, right
|
128 |
+
collision: 'none', // If true, the popover will be repositioned to another position when collapses with the window borders
|
129 |
+
animation: true, // fade in/out on show/hide ?
|
130 |
+
//hide iconpicker automatically when a value is picked. it is ignored if mustAccept is not false and the accept button is visible
|
131 |
+
hideOnSelect: false,
|
132 |
+
showFooter: false,
|
133 |
+
searchInFooter: false, // If true, the search will be added to the footer instead of the title
|
134 |
+
mustAccept: false, // only applicable when there's an iconpicker-btn-accept button in the popover footer
|
135 |
+
selectedCustomClass: 'bg-primary', // Appends this class when to the selected item
|
136 |
+
icons: [], // list of icon classes (declared at the bottom of this script for maintainability)
|
137 |
+
iconBaseClass: 'fa',
|
138 |
+
iconClassPrefix: 'fa-',
|
139 |
+
fullClassFormatter: function(val) {
|
140 |
+
return 'fa ' + val;
|
141 |
+
},
|
142 |
+
input: 'input,.iconpicker-input', // children input selector
|
143 |
+
inputSearch: false, // use the input as a search box too?
|
144 |
+
container: false, // Appends the popover to a specific element. If not set, the selected element or element parent is used
|
145 |
+
component: '.input-group-addon,.iconpicker-component', // children component jQuery selector or object, relative to the container element
|
146 |
+
// Plugin templates:
|
147 |
+
templates: {
|
148 |
+
popover: '<div class="iconpicker-popover popover"><div class="arrow"></div>' +
|
149 |
+
'<div class="popover-title"></div><div class="popover-content"></div></div>',
|
150 |
+
footer: '<div class="popover-footer"></div>',
|
151 |
+
buttons: '<button class="iconpicker-btn iconpicker-btn-cancel btn btn-default btn-sm">Cancel</button>' +
|
152 |
+
' <button class="iconpicker-btn iconpicker-btn-accept btn btn-primary btn-sm">Accept</button>',
|
153 |
+
search: '<input type="search" class="form-control iconpicker-search" placeholder="Type to filter" />',
|
154 |
+
iconpicker: '<div class="iconpicker"><div class="iconpicker-items"></div></div>',
|
155 |
+
iconpickerItem: '<a role="button" href="#" class="iconpicker-item"><i></i></a>',
|
156 |
+
}
|
157 |
+
};
|
158 |
+
|
159 |
+
Iconpicker.batch = function(selector, method) {
|
160 |
+
var args = Array.prototype.slice.call(arguments, 2);
|
161 |
+
return $(selector).each(function() {
|
162 |
+
var $inst = $(this).data('iconpicker');
|
163 |
+
if (!!$inst) {
|
164 |
+
$inst[method].apply($inst, args);
|
165 |
+
}
|
166 |
+
});
|
167 |
+
};
|
168 |
+
|
169 |
+
Iconpicker.prototype = {
|
170 |
+
constructor: Iconpicker,
|
171 |
+
options: {},
|
172 |
+
_id: 0, // instance identifier for bind/unbind events
|
173 |
+
_trigger: function(name, opts) {
|
174 |
+
//triggers an event bound to the element
|
175 |
+
opts = opts || {};
|
176 |
+
this.element.trigger($.extend({
|
177 |
+
type: name,
|
178 |
+
iconpickerInstance: this
|
179 |
+
}, opts));
|
180 |
+
//console.log(name + ' triggered for instance #' + this._id);
|
181 |
+
},
|
182 |
+
_createPopover: function() {
|
183 |
+
this.popover = $(this.options.templates.popover);
|
184 |
+
|
185 |
+
// title (header)
|
186 |
+
var _title = this.popover.find('.popover-title');
|
187 |
+
if (!!this.options.title) {
|
188 |
+
_title.append($('<div class="popover-title-text">' + this.options.title + '</div>'));
|
189 |
+
}
|
190 |
+
if (this.hasSeparatedSearchInput() && !this.options.searchInFooter) {
|
191 |
+
_title.append(this.options.templates.search);
|
192 |
+
} else if (!this.options.title) {
|
193 |
+
_title.remove();
|
194 |
+
}
|
195 |
+
|
196 |
+
// footer
|
197 |
+
if (this.options.showFooter && !_helpers.isEmpty(this.options.templates.footer)) {
|
198 |
+
var _footer = $(this.options.templates.footer);
|
199 |
+
if (this.hasSeparatedSearchInput() && this.options.searchInFooter) {
|
200 |
+
_footer.append($(this.options.templates.search));
|
201 |
+
}
|
202 |
+
if (!_helpers.isEmpty(this.options.templates.buttons)) {
|
203 |
+
_footer.append($(this.options.templates.buttons));
|
204 |
+
}
|
205 |
+
this.popover.append(_footer);
|
206 |
+
}
|
207 |
+
|
208 |
+
if (this.options.animation === true) {
|
209 |
+
this.popover.addClass('fade');
|
210 |
+
}
|
211 |
+
|
212 |
+
return this.popover;
|
213 |
+
},
|
214 |
+
_createIconpicker: function() {
|
215 |
+
var _self = this;
|
216 |
+
this.iconpicker = $(this.options.templates.iconpicker);
|
217 |
+
|
218 |
+
var itemClickFn = function(e) {
|
219 |
+
var $this = $(this);
|
220 |
+
|
221 |
+
if ($this.is('i')) {
|
222 |
+
$this = $this.parent();
|
223 |
+
}
|
224 |
+
|
225 |
+
_self._trigger('iconpickerSelect', {
|
226 |
+
iconpickerItem: $this,
|
227 |
+
iconpickerValue: _self.iconpickerValue
|
228 |
+
});
|
229 |
+
|
230 |
+
if (_self.options.mustAccept === false) {
|
231 |
+
_self.update($this.data('iconpickerValue'));
|
232 |
+
_self._trigger('iconpickerSelected', {
|
233 |
+
iconpickerItem: this,
|
234 |
+
iconpickerValue: _self.iconpickerValue
|
235 |
+
});
|
236 |
+
} else {
|
237 |
+
_self.update($this.data('iconpickerValue'), true);
|
238 |
+
}
|
239 |
+
|
240 |
+
if (_self.options.hideOnSelect && (_self.options.mustAccept === false)) {
|
241 |
+
// only hide when the accept button is not present
|
242 |
+
_self.hide();
|
243 |
+
}
|
244 |
+
e.preventDefault();
|
245 |
+
return false;
|
246 |
+
};
|
247 |
+
|
248 |
+
for (var i in this.options.icons) {
|
249 |
+
var itemElement = $(this.options.templates.iconpickerItem);
|
250 |
+
itemElement.find('i')
|
251 |
+
.addClass( this.options.iconBaseClass + ' ' + this.options.iconClassPrefix + this.options.icons[i]);
|
252 |
+
itemElement.data('iconpickerValue', this.options.icons[i])
|
253 |
+
.on('click.iconpicker', itemClickFn);
|
254 |
+
this.iconpicker.find('.iconpicker-items').append(itemElement
|
255 |
+
.attr('title', '.' + this.options.iconClassPrefix + this.options.icons[i]));
|
256 |
+
}
|
257 |
+
|
258 |
+
this.popover.find('.popover-content').append(this.iconpicker);
|
259 |
+
|
260 |
+
this.component.append( '<i class="' + this.options.iconBaseClass + ' ' + this.input.val() + '"></i>' );
|
261 |
+
|
262 |
+
return this.iconpicker;
|
263 |
+
},
|
264 |
+
_isEventInsideIconpicker: function(e) {
|
265 |
+
var _t = $(e.target);
|
266 |
+
|
267 |
+
if ((!_t.hasClass('iconpicker-element') ||
|
268 |
+
(_t.hasClass('iconpicker-element') && !_t.is(this.element))) &&
|
269 |
+
(_t.parents('.iconpicker-popover').length === 0)) {
|
270 |
+
return false;
|
271 |
+
}
|
272 |
+
return true;
|
273 |
+
},
|
274 |
+
_bindElementEvents: function() {
|
275 |
+
var _self = this;
|
276 |
+
|
277 |
+
this.getSearchInput().on('keyup.iconpicker', function() {
|
278 |
+
_self.filter($(this).val().toLowerCase());
|
279 |
+
});
|
280 |
+
|
281 |
+
this.getAcceptButton().on('click.iconpicker', function() {
|
282 |
+
var _picked = _self.iconpicker.find('.iconpicker-selected').get(0);
|
283 |
+
|
284 |
+
_self.update(_self.iconpickerValue);
|
285 |
+
|
286 |
+
_self._trigger('iconpickerSelected', {
|
287 |
+
iconpickerItem: _picked,
|
288 |
+
iconpickerValue: _self.iconpickerValue
|
289 |
+
});
|
290 |
+
if (!_self.isInline()) {
|
291 |
+
_self.hide();
|
292 |
+
}
|
293 |
+
});
|
294 |
+
this.getCancelButton().on('click.iconpicker', function() {
|
295 |
+
if (!_self.isInline()) {
|
296 |
+
_self.hide();
|
297 |
+
}
|
298 |
+
});
|
299 |
+
|
300 |
+
this.element.on('focus.iconpicker', function(e) {
|
301 |
+
_self.show();
|
302 |
+
e.stopPropagation();
|
303 |
+
});
|
304 |
+
|
305 |
+
if (this.hasComponent()) {
|
306 |
+
this.component.on('click.iconpicker', function() {
|
307 |
+
_self.toggle();
|
308 |
+
});
|
309 |
+
}
|
310 |
+
|
311 |
+
if (this.hasInput()) {
|
312 |
+
// Bind input keyup event
|
313 |
+
this.input.on('keyup.iconpicker', function(e) {
|
314 |
+
if (!_helpers.inArray(e.keyCode, [38, 40, 37, 39, 16, 17, 18, 9, 8, 91, 93, 20, 46, 186, 190, 46, 78, 188, 44, 86])) {
|
315 |
+
_self.update();
|
316 |
+
} else {
|
317 |
+
_self._updateFormGroupStatus(_self.getValid(this.value) !== false);
|
318 |
+
}
|
319 |
+
if (_self.options.inputSearch === true) {
|
320 |
+
_self.filter($(this).val().toLowerCase());
|
321 |
+
}
|
322 |
+
//_self.hide();
|
323 |
+
});
|
324 |
+
}
|
325 |
+
|
326 |
+
},
|
327 |
+
_bindWindowEvents: function() {
|
328 |
+
var $doc = $(window.document);
|
329 |
+
var _self = this;
|
330 |
+
|
331 |
+
// Add a namespace to the document events so they can be identified
|
332 |
+
// later for every instance separately
|
333 |
+
var _eventNs = '.iconpicker.inst' + this._id;
|
334 |
+
|
335 |
+
$(window).on('resize.iconpicker' + _eventNs + ' orientationchange.iconpicker' + _eventNs, function(e) {
|
336 |
+
// reposition popover
|
337 |
+
if (_self.popover.hasClass('in')) {
|
338 |
+
_self.updatePlacement();
|
339 |
+
}
|
340 |
+
});
|
341 |
+
|
342 |
+
|
343 |
+
if (!_self.isInline()) {
|
344 |
+
$doc.on('mouseup' + _eventNs, function(e) {
|
345 |
+
if ( !_self._isEventInsideIconpicker(e) && !_self.isInline()) {
|
346 |
+
_self.hide();
|
347 |
+
}
|
348 |
+
});
|
349 |
+
}
|
350 |
+
|
351 |
+
return false;
|
352 |
+
},
|
353 |
+
_unbindElementEvents: function() {
|
354 |
+
this.popover.off('.iconpicker');
|
355 |
+
this.element.off('.iconpicker');
|
356 |
+
|
357 |
+
if (this.hasInput()) {
|
358 |
+
this.input.off('.iconpicker');
|
359 |
+
}
|
360 |
+
|
361 |
+
if (this.hasComponent()) {
|
362 |
+
this.component.off('.iconpicker');
|
363 |
+
}
|
364 |
+
|
365 |
+
if (this.hasContainer()) {
|
366 |
+
this.container.off('.iconpicker');
|
367 |
+
}
|
368 |
+
},
|
369 |
+
_unbindWindowEvents: function() {
|
370 |
+
// destroy window and window.document bound events
|
371 |
+
$(window).off('.iconpicker.inst' + this._id);
|
372 |
+
$(window.document).off('.iconpicker.inst' + this._id);
|
373 |
+
},
|
374 |
+
updatePlacement: function(placement, collision) {
|
375 |
+
placement = placement || this.options.placement;
|
376 |
+
this.options.placement = placement; // set new placement
|
377 |
+
collision = collision || this.options.collision;
|
378 |
+
collision = (collision === true ? 'flip' : collision);
|
379 |
+
|
380 |
+
var _pos = {
|
381 |
+
// at: Defines which position (or side) on container element to align the
|
382 |
+
// popover element against: "horizontal vertical" alignment.
|
383 |
+
at: "right bottom",
|
384 |
+
// my: Defines which position (or side) on the popover being positioned to align
|
385 |
+
// with the container element: "horizontal vertical" alignment
|
386 |
+
my: "right top",
|
387 |
+
// of: Which element to position against.
|
388 |
+
of: (this.hasInput() && !this.isInputGroup()) ? this.input : this.container,
|
389 |
+
// collision: When the positioned element overflows the window (or within element)
|
390 |
+
// in some direction, move it to an alternative position.
|
391 |
+
collision: (collision === true ? 'flip' : collision),
|
392 |
+
// within: Element to position within, affecting collision detection.
|
393 |
+
within: window
|
394 |
+
};
|
395 |
+
|
396 |
+
// remove previous classes
|
397 |
+
this.popover.removeClass('inline topLeftCorner topLeft top topRight topRightCorner ' +
|
398 |
+
'rightTop right rightBottom bottomRight bottomRightCorner ' +
|
399 |
+
'bottom bottomLeft bottomLeftCorner leftBottom left leftTop');
|
400 |
+
|
401 |
+
if (typeof placement === 'object') {
|
402 |
+
// custom position ?
|
403 |
+
return this.popover.pos($.extend({}, _pos, placement));
|
404 |
+
}
|
405 |
+
|
406 |
+
switch (placement) {
|
407 |
+
case 'inline':
|
408 |
+
{
|
409 |
+
_pos = false;
|
410 |
+
}
|
411 |
+
break;
|
412 |
+
case 'topLeftCorner':
|
413 |
+
{
|
414 |
+
_pos.my = 'right bottom';
|
415 |
+
_pos.at = 'left top';
|
416 |
+
}
|
417 |
+
break;
|
418 |
+
|
419 |
+
case 'topLeft':
|
420 |
+
{
|
421 |
+
_pos.my = 'left bottom';
|
422 |
+
_pos.at = 'left top';
|
423 |
+
}
|
424 |
+
break;
|
425 |
+
|
426 |
+
case 'top':
|
427 |
+
{
|
428 |
+
_pos.my = 'center bottom';
|
429 |
+
_pos.at = 'center top';
|
430 |
+
}
|
431 |
+
break;
|
432 |
+
|
433 |
+
case 'topRight':
|
434 |
+
{
|
435 |
+
_pos.my = 'right bottom';
|
436 |
+
_pos.at = 'right top';
|
437 |
+
}
|
438 |
+
break;
|
439 |
+
|
440 |
+
case 'topRightCorner':
|
441 |
+
{
|
442 |
+
_pos.my = 'left bottom';
|
443 |
+
_pos.at = 'right top';
|
444 |
+
}
|
445 |
+
break;
|
446 |
+
|
447 |
+
case 'rightTop':
|
448 |
+
{
|
449 |
+
_pos.my = 'left bottom';
|
450 |
+
_pos.at = 'right center';
|
451 |
+
}
|
452 |
+
break;
|
453 |
+
|
454 |
+
case 'right':
|
455 |
+
{
|
456 |
+
_pos.my = 'left center';
|
457 |
+
_pos.at = 'right center';
|
458 |
+
}
|
459 |
+
break;
|
460 |
+
|
461 |
+
case 'rightBottom':
|
462 |
+
{
|
463 |
+
_pos.my = 'left top';
|
464 |
+
_pos.at = 'right center';
|
465 |
+
}
|
466 |
+
break;
|
467 |
+
|
468 |
+
case 'bottomRightCorner':
|
469 |
+
{
|
470 |
+
_pos.my = 'left top';
|
471 |
+
_pos.at = 'right bottom';
|
472 |
+
}
|
473 |
+
break;
|
474 |
+
|
475 |
+
case 'bottomRight':
|
476 |
+
{
|
477 |
+
_pos.my = 'right top';
|
478 |
+
_pos.at = 'right bottom';
|
479 |
+
}
|
480 |
+
break;
|
481 |
+
case 'bottom':
|
482 |
+
{
|
483 |
+
_pos.my = 'center top';
|
484 |
+
_pos.at = 'center bottom';
|
485 |
+
}
|
486 |
+
break;
|
487 |
+
|
488 |
+
case 'bottomLeft':
|
489 |
+
{
|
490 |
+
_pos.my = 'left top';
|
491 |
+
_pos.at = 'left bottom';
|
492 |
+
}
|
493 |
+
break;
|
494 |
+
|
495 |
+
case 'bottomLeftCorner':
|
496 |
+
{
|
497 |
+
_pos.my = 'right top';
|
498 |
+
_pos.at = 'left bottom';
|
499 |
+
}
|
500 |
+
break;
|
501 |
+
|
502 |
+
case 'leftBottom':
|
503 |
+
{
|
504 |
+
_pos.my = 'right top';
|
505 |
+
_pos.at = 'left center';
|
506 |
+
}
|
507 |
+
break;
|
508 |
+
|
509 |
+
case 'left':
|
510 |
+
{
|
511 |
+
_pos.my = 'right center';
|
512 |
+
_pos.at = 'left center';
|
513 |
+
}
|
514 |
+
break;
|
515 |
+
|
516 |
+
case 'leftTop':
|
517 |
+
{
|
518 |
+
_pos.my = 'right bottom';
|
519 |
+
_pos.at = 'left center';
|
520 |
+
}
|
521 |
+
break;
|
522 |
+
|
523 |
+
default:
|
524 |
+
{
|
525 |
+
return false;
|
526 |
+
}
|
527 |
+
break;
|
528 |
+
|
529 |
+
}
|
530 |
+
|
531 |
+
this.popover.css({
|
532 |
+
'display': (this.options.placement === 'inline') ? '' : 'block'
|
533 |
+
});
|
534 |
+
|
535 |
+
if (_pos !== false) {
|
536 |
+
this.popover.pos(_pos).css('maxWidth', $(window).width() - this.container.offset().left - 5);
|
537 |
+
} else {
|
538 |
+
//reset position
|
539 |
+
this.popover.css({
|
540 |
+
'top': 'auto',
|
541 |
+
'right': 'auto',
|
542 |
+
'bottom': 'auto',
|
543 |
+
'left': 'auto',
|
544 |
+
'maxWidth': 'none'
|
545 |
+
});
|
546 |
+
}
|
547 |
+
this.popover.addClass(this.options.placement);
|
548 |
+
|
549 |
+
return true;
|
550 |
+
},
|
551 |
+
_updateComponents: function() {
|
552 |
+
// Update selected item
|
553 |
+
this.iconpicker.find('.iconpicker-item.iconpicker-selected')
|
554 |
+
.removeClass('iconpicker-selected ' + this.options.selectedCustomClass);
|
555 |
+
|
556 |
+
if (this.iconpickerValue) {
|
557 |
+
this.iconpicker.find('.' + this.options.fullClassFormatter(this.iconpickerValue).replace(/ /g, '.')).parent()
|
558 |
+
.addClass('iconpicker-selected ' + this.options.selectedCustomClass);
|
559 |
+
}
|
560 |
+
|
561 |
+
// Update component item
|
562 |
+
if (this.hasComponent()) {
|
563 |
+
var icn = this.component.find('i');
|
564 |
+
if (icn.length > 0) {
|
565 |
+
icn.attr('class', this.options.fullClassFormatter(this.iconpickerValue));
|
566 |
+
} else {
|
567 |
+
this.component.html(this.getHtml());
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
},
|
572 |
+
_updateFormGroupStatus: function(isValid) {
|
573 |
+
if (this.hasInput()) {
|
574 |
+
if (isValid !== false) {
|
575 |
+
// Remove form-group error class if any
|
576 |
+
this.input.parents('.form-group:first').removeClass('has-error');
|
577 |
+
} else {
|
578 |
+
this.input.parents('.form-group:first').addClass('has-error');
|
579 |
+
}
|
580 |
+
return true;
|
581 |
+
}
|
582 |
+
return false;
|
583 |
+
},
|
584 |
+
getValid: function(val) {
|
585 |
+
// here we must validate the value (you may change this validation
|
586 |
+
// to suit your needs
|
587 |
+
if (!_helpers.isString(val)) {
|
588 |
+
val = '';
|
589 |
+
}
|
590 |
+
|
591 |
+
var isEmpty = (val === '');
|
592 |
+
|
593 |
+
// trim string
|
594 |
+
val = $.trim(val);
|
595 |
+
|
596 |
+
if (_helpers.inArray(val, this.options.icons) || isEmpty) {
|
597 |
+
return val;
|
598 |
+
}
|
599 |
+
return false;
|
600 |
+
},
|
601 |
+
/**
|
602 |
+
* Sets the internal item value and updates everything, excepting the input or element.
|
603 |
+
* For doing so, call setSourceValue() or update() instead
|
604 |
+
*/
|
605 |
+
setValue: function(val) {
|
606 |
+
// sanitize first
|
607 |
+
var _val = this.getValid(val);
|
608 |
+
if (_val !== false) {
|
609 |
+
this.iconpickerValue = _val;
|
610 |
+
this._trigger('iconpickerSetValue', {
|
611 |
+
iconpickerValue: _val
|
612 |
+
});
|
613 |
+
return this.iconpickerValue;
|
614 |
+
} else {
|
615 |
+
this._trigger('iconpickerInvalid', {
|
616 |
+
iconpickerValue: val
|
617 |
+
});
|
618 |
+
return false;
|
619 |
+
}
|
620 |
+
},
|
621 |
+
getHtml: function() {
|
622 |
+
return '<i class="' + this.options.fullClassFormatter(this.iconpickerValue) + '"></i>';
|
623 |
+
},
|
624 |
+
/**
|
625 |
+
* Calls setValue and if it's a valid item value, sets the input or element value
|
626 |
+
*/
|
627 |
+
setSourceValue: function(val) {
|
628 |
+
val = this.setValue(val);
|
629 |
+
|
630 |
+
if ((val !== false) && (val !== '')) {
|
631 |
+
if (this.hasInput()) {
|
632 |
+
this.input.val( this.options.iconClassPrefix + this.iconpickerValue );
|
633 |
+
} else {
|
634 |
+
this.element.data('iconpickerValue', this.iconpickerValue);
|
635 |
+
}
|
636 |
+
this._trigger('iconpickerSetSourceValue', {
|
637 |
+
iconpickerValue: val
|
638 |
+
});
|
639 |
+
}
|
640 |
+
return val;
|
641 |
+
},
|
642 |
+
/**
|
643 |
+
* Returns the input or element item value, without formatting, or defaultValue
|
644 |
+
* if it's empty string, undefined, false or null
|
645 |
+
* @param {type} defaultValue
|
646 |
+
* @returns string|mixed
|
647 |
+
*/
|
648 |
+
getSourceValue: function(defaultValue) {
|
649 |
+
// returns the input or element value, as string
|
650 |
+
defaultValue = defaultValue || this.options.defaultValue;
|
651 |
+
var val = defaultValue;
|
652 |
+
|
653 |
+
if (this.hasInput()) {
|
654 |
+
val = this.input.val();
|
655 |
+
} else {
|
656 |
+
val = this.element.data('iconpickerValue');
|
657 |
+
}
|
658 |
+
if ((val === undefined) || (val === '') || (val === null) || (val === false)) {
|
659 |
+
// if not defined or empty, return default
|
660 |
+
val = defaultValue;
|
661 |
+
}
|
662 |
+
return val;
|
663 |
+
},
|
664 |
+
hasInput: function() {
|
665 |
+
return (this.input !== false);
|
666 |
+
},
|
667 |
+
isInputSearch: function() {
|
668 |
+
return (this.hasInput() && (this.options.inputSearch === true));
|
669 |
+
},
|
670 |
+
isInputGroup: function() {
|
671 |
+
return this.container.is('.input-group');
|
672 |
+
},
|
673 |
+
isDropdownMenu: function() {
|
674 |
+
return this.container.is('.dropdown-menu');
|
675 |
+
},
|
676 |
+
hasSeparatedSearchInput: function() {
|
677 |
+
return (this.options.templates.search !== false) && (!this.isInputSearch());
|
678 |
+
},
|
679 |
+
hasComponent: function() {
|
680 |
+
return (this.component !== false);
|
681 |
+
},
|
682 |
+
hasContainer: function() {
|
683 |
+
return (this.container !== false);
|
684 |
+
},
|
685 |
+
getAcceptButton: function() {
|
686 |
+
return this.popover.find('.iconpicker-btn-accept');
|
687 |
+
},
|
688 |
+
getCancelButton: function() {
|
689 |
+
return this.popover.find('.iconpicker-btn-cancel');
|
690 |
+
},
|
691 |
+
getSearchInput: function() {
|
692 |
+
return this.popover.find('.iconpicker-search');
|
693 |
+
},
|
694 |
+
filter: function(filterText) {
|
695 |
+
if (_helpers.isEmpty(filterText)) {
|
696 |
+
this.iconpicker.find('.iconpicker-item').show();
|
697 |
+
return $(false);
|
698 |
+
} else {
|
699 |
+
var found = [];
|
700 |
+
this.iconpicker.find('.iconpicker-item').each(function() {
|
701 |
+
var $this = $(this);
|
702 |
+
var text = $this.attr('title').toLowerCase();
|
703 |
+
var regex = false;
|
704 |
+
try {
|
705 |
+
regex = new RegExp(filterText, 'g');
|
706 |
+
} catch (e) {
|
707 |
+
regex = false;
|
708 |
+
}
|
709 |
+
if ((regex !== false) && text.match(regex)) {
|
710 |
+
found.push($this);
|
711 |
+
$this.show();
|
712 |
+
} else {
|
713 |
+
$this.hide();
|
714 |
+
}
|
715 |
+
});
|
716 |
+
return found;
|
717 |
+
}
|
718 |
+
},
|
719 |
+
show: function() {
|
720 |
+
if (this.popover.hasClass('in')) {
|
721 |
+
return false;
|
722 |
+
}
|
723 |
+
// hide other non-inline pickers
|
724 |
+
$.iconpicker.batch($('.iconpicker-popover.in:not(.inline)').not(this.popover), 'hide');
|
725 |
+
|
726 |
+
this._trigger('iconpickerShow');
|
727 |
+
this.updatePlacement();
|
728 |
+
this.popover.addClass('in');
|
729 |
+
setTimeout($.proxy(function() {
|
730 |
+
this.popover.css('display', this.isInline() ? '' : 'block');
|
731 |
+
this._trigger('iconpickerShown');
|
732 |
+
}, this), this.options.animation ? 300 : 1); // animation duration
|
733 |
+
},
|
734 |
+
hide: function() {
|
735 |
+
if (!this.popover.hasClass('in')) {
|
736 |
+
return false;
|
737 |
+
}
|
738 |
+
this._trigger('iconpickerHide');
|
739 |
+
this.popover.removeClass('in');
|
740 |
+
setTimeout($.proxy(function() {
|
741 |
+
this.popover.css('display', 'none');
|
742 |
+
this.getSearchInput().val('');
|
743 |
+
this.filter(''); // clear filter
|
744 |
+
this._trigger('iconpickerHidden');
|
745 |
+
}, this), this.options.animation ? 300 : 1);
|
746 |
+
},
|
747 |
+
toggle: function() {
|
748 |
+
if (this.popover.is(":visible")) {
|
749 |
+
this.hide();
|
750 |
+
} else {
|
751 |
+
this.show(true);
|
752 |
+
}
|
753 |
+
},
|
754 |
+
update: function(val, updateOnlyInternal) {
|
755 |
+
val = (val ? val : this.getSourceValue(this.iconpickerValue));
|
756 |
+
// reads the input or element value again and tries to update the plugin
|
757 |
+
// fallback to the current selected item value
|
758 |
+
this._trigger('iconpickerUpdate');
|
759 |
+
|
760 |
+
if (updateOnlyInternal === true) {
|
761 |
+
val = this.setValue(val);
|
762 |
+
} else {
|
763 |
+
val = this.setSourceValue(val);
|
764 |
+
this._updateFormGroupStatus(val !== false);
|
765 |
+
}
|
766 |
+
|
767 |
+
if (val !== false) {
|
768 |
+
this._updateComponents();
|
769 |
+
}
|
770 |
+
|
771 |
+
this._trigger('iconpickerUpdated');
|
772 |
+
return val;
|
773 |
+
},
|
774 |
+
destroy: function() {
|
775 |
+
this._trigger('iconpickerDestroy');
|
776 |
+
|
777 |
+
// unbinds events and resets everything to the initial state,
|
778 |
+
// including component mode
|
779 |
+
this.element.removeData('iconpicker').removeData('iconpickerValue').removeClass('iconpicker-element');
|
780 |
+
|
781 |
+
this._unbindElementEvents();
|
782 |
+
this._unbindWindowEvents();
|
783 |
+
|
784 |
+
$(this.popover).remove();
|
785 |
+
|
786 |
+
this._trigger('iconpickerDestroyed');
|
787 |
+
},
|
788 |
+
disable: function() {
|
789 |
+
if (this.hasInput()) {
|
790 |
+
this.input.prop('disabled', true);
|
791 |
+
return true;
|
792 |
+
}
|
793 |
+
return false;
|
794 |
+
},
|
795 |
+
enable: function() {
|
796 |
+
if (this.hasInput()) {
|
797 |
+
this.input.prop('disabled', false);
|
798 |
+
return true;
|
799 |
+
}
|
800 |
+
return false;
|
801 |
+
},
|
802 |
+
isDisabled: function() {
|
803 |
+
if (this.hasInput()) {
|
804 |
+
return (this.input.prop('disabled') === true);
|
805 |
+
}
|
806 |
+
return false;
|
807 |
+
},
|
808 |
+
isInline: function() {
|
809 |
+
return (this.options.placement === 'inline') || (this.popover.hasClass('inline'));
|
810 |
+
}
|
811 |
+
};
|
812 |
+
|
813 |
+
$.iconpicker = Iconpicker;
|
814 |
+
|
815 |
+
// jQuery plugin
|
816 |
+
$.fn.iconpicker = function(options) {
|
817 |
+
return this.each(function() {
|
818 |
+
var $this = $(this);
|
819 |
+
if (!$this.data('iconpicker')) {
|
820 |
+
// create plugin instance (only if not exists) and expose the entire instance API
|
821 |
+
$this.data('iconpicker', new Iconpicker(this, ((typeof options === 'object') ? options : {})));
|
822 |
+
}
|
823 |
+
});
|
824 |
+
};
|
825 |
+
|
826 |
+
// List of all Font Awesome icons without class prefix
|
827 |
+
Iconpicker.defaultOptions.icons = [
|
828 |
+
'fa-500px','fa-adjust','fa-adn','fa-align-center','fa-align-justify','fa-align-left','fa-align-right','fa-amazon',
|
829 |
+
'fa-ambulance','fa-anchor','fa-android','fa-angellist','fa-angle-double-down','fa-angle-double-left','fa-angle-double-right',
|
830 |
+
'fa-angle-double-up','fa-angle-down','fa-angle-left','fa-angle-right','fa-angle-up','fa-apple','fa-archive','fa-area-chart',
|
831 |
+
'fa-arrow-circle-down','fa-arrow-circle-left','fa-arrow-circle-o-down','fa-arrow-circle-o-left','fa-arrow-circle-o-right',
|
832 |
+
'fa-arrow-circle-o-up','fa-arrow-circle-right','fa-arrow-circle-up','fa-arrow-down','fa-arrow-left','fa-arrow-right',
|
833 |
+
'fa-arrow-up','fa-arrows','fa-arrows-alt','fa-arrows-h','fa-arrows-v','fa-asterisk','fa-at','fa-automobile','fa-backward',
|
834 |
+
'fa-balance-scale','fa-ban','fa-bank','fa-bar-chart','fa-bar-chart-o','fa-barcode','fa-bars','fa-battery-0','fa-battery-1',
|
835 |
+
'fa-battery-2','fa-battery-3','fa-battery-4','fa-battery-empty','fa-battery-full','fa-battery-half','fa-battery-quarter',
|
836 |
+
'fa-battery-three-quarters','fa-bed','fa-beer','fa-behance','fa-behance-square','fa-bell','fa-bell-o','fa-bell-slash',
|
837 |
+
'fa-bell-slash-o','fa-bicycle','fa-binoculars','fa-birthday-cake','fa-bitbucket','fa-bitbucket-square','fa-bitcoin',
|
838 |
+
'fa-black-tie','fa-bold','fa-bolt','fa-bomb','fa-book','fa-bookmark','fa-bookmark-o','fa-briefcase','fa-btc','fa-bug',
|
839 |
+
'fa-building','fa-building-o','fa-bullhorn','fa-bullseye','fa-bus','fa-buysellads','fa-cab','fa-calculator','fa-calendar',
|
840 |
+
'fa-calendar-check-o','fa-calendar-minus-o','fa-calendar-o','fa-calendar-plus-o','fa-calendar-times-o','fa-camera',
|
841 |
+
'fa-camera-retro','fa-car','fa-caret-down','fa-caret-left','fa-caret-right','fa-caret-square-o-down',
|
842 |
+
'fa-caret-square-o-left','fa-caret-square-o-right','fa-caret-square-o-up','fa-caret-up','fa-cart-arrow-down','fa-cart-plus',
|
843 |
+
'fa-cc','fa-cc-amex','fa-cc-diners-club','fa-cc-discover','fa-cc-jcb','fa-cc-mastercard','fa-cc-paypal','fa-cc-stripe',
|
844 |
+
'fa-cc-visa','fa-certificate','fa-chain','fa-chain-broken','fa-check','fa-check-circle','fa-check-circle-o',
|
845 |
+
'fa-check-square','fa-check-square-o','fa-chevron-circle-down','fa-chevron-circle-left','fa-chevron-circle-right',
|
846 |
+
'fa-chevron-circle-up','fa-chevron-down','fa-chevron-left','fa-chevron-right','fa-chevron-up','fa-child','fa-chrome',
|
847 |
+
'fa-circle','fa-circle-o','fa-circle-o-notch','fa-circle-thin','fa-clipboard','fa-clock-o','fa-clone','fa-close','fa-cloud',
|
848 |
+
'fa-cloud-download','fa-cloud-upload','fa-cny','fa-code','fa-code-fork','fa-codepen','fa-coffee','fa-cog','fa-cogs',
|
849 |
+
'fa-columns','fa-comment','fa-comment-o','fa-commenting','fa-commenting-o','fa-comments','fa-comments-o','fa-compass',
|
850 |
+
'fa-compress','fa-connectdevelop','fa-contao','fa-copy','fa-copyright','fa-creative-commons','fa-credit-card','fa-crop',
|
851 |
+
'fa-crosshairs','fa-css3','fa-cube','fa-cubes','fa-cut','fa-cutlery','fa-dashboard','fa-dashcube','fa-database','fa-dedent',
|
852 |
+
'fa-delicious','fa-desktop','fa-deviantart','fa-diamond','fa-digg','fa-dollar','fa-dot-circle-o','fa-download','fa-dribbble',
|
853 |
+
'fa-dropbox','fa-drupal','fa-edit','fa-eject','fa-ellipsis-h','fa-ellipsis-v','fa-empire','fa-envelope','fa-envelope-o',
|
854 |
+
'fa-envelope-square','fa-eraser','fa-eur','fa-euro','fa-exchange','fa-exclamation','fa-exclamation-circle',
|
855 |
+
'fa-exclamation-triangle','fa-expand','fa-expeditedssl','fa-external-link','fa-external-link-square','fa-eye','fa-eye-slash',
|
856 |
+
'fa-eyedropper','fa-facebook','fa-facebook-f','fa-facebook-official','fa-facebook-square','fa-fast-backward','fa-fast-forward',
|
857 |
+
'fa-fax','fa-feed','fa-female','fa-fighter-jet','fa-file','fa-file-archive-o','fa-file-audio-o','fa-file-code-o',
|
858 |
+
'fa-file-excel-o','fa-file-image-o','fa-file-movie-o','fa-file-o','fa-file-pdf-o','fa-file-photo-o','fa-file-picture-o',
|
859 |
+
'fa-file-powerpoint-o','fa-file-sound-o','fa-file-text','fa-file-text-o','fa-file-video-o','fa-file-word-o','fa-file-zip-o',
|
860 |
+
'fa-files-o','fa-film','fa-filter','fa-fire','fa-fire-extinguisher','fa-firefox','fa-flag','fa-flag-checkered','fa-flag-o',
|
861 |
+
'fa-flash','fa-flask','fa-flickr','fa-floppy-o','fa-folder','fa-folder-o','fa-folder-open','fa-folder-open-o','fa-font',
|
862 |
+
'fa-fonticons','fa-forumbee','fa-forward','fa-foursquare','fa-frown-o','fa-futbol-o','fa-gamepad','fa-gavel','fa-gbp','fa-ge',
|
863 |
+
'fa-gear','fa-gears','fa-genderless','fa-get-pocket','fa-gg','fa-gg-circle','fa-gift','fa-git','fa-git-square','fa-github',
|
864 |
+
'fa-github-alt','fa-github-square','fa-gittip','fa-glass','fa-globe','fa-google','fa-google-plus','fa-google-plus-square',
|
865 |
+
'fa-google-wallet','fa-graduation-cap','fa-gratipay','fa-group','fa-h-square','fa-hacker-news','fa-hand-grab-o',
|
866 |
+
'fa-hand-lizard-o','fa-hand-o-down','fa-hand-o-left','fa-hand-o-right','fa-hand-o-up','fa-hand-paper-o','fa-hand-peace-o',
|
867 |
+
'fa-hand-pointer-o','fa-hand-scissors-o','fa-hand-spock-o','fa-hand-stop-o','fa-hdd-o','fa-header','fa-headphones',
|
868 |
+
'fa-heart','fa-heart-o','fa-heartbeat','fa-history','fa-home','fa-hospital-o','fa-hotel','fa-hourglass','fa-hourglass-1',
|
869 |
+
'fa-hourglass-2','fa-hourglass-3','fa-hourglass-end','fa-hourglass-half','fa-hourglass-o','fa-hourglass-start','fa-houzz',
|
870 |
+
'fa-html5','fa-i-cursor','fa-ils','fa-image','fa-inbox','fa-indent','fa-industry','fa-info','fa-info-circle','fa-inr',
|
871 |
+
'fa-instagram','fa-institution','fa-internet-explorer','fa-intersex','fa-ioxhost','fa-italic','fa-joomla','fa-jpy','fa-jsfiddle',
|
872 |
+
'fa-key','fa-keyboard-o','fa-krw','fa-language','fa-laptop','fa-lastfm','fa-lastfm-square','fa-leaf','fa-leanpub','fa-legal',
|
873 |
+
'fa-lemon-o','fa-level-down','fa-level-up','fa-life-bouy','fa-life-buoy','fa-life-ring','fa-life-saver','fa-lightbulb-o',
|
874 |
+
'fa-line-chart','fa-link','fa-linkedin','fa-linkedin-square','fa-linux','fa-list','fa-list-alt','fa-list-ol','fa-list-ul',
|
875 |
+
'fa-location-arrow','fa-lock','fa-long-arrow-down','fa-long-arrow-left','fa-long-arrow-right','fa-long-arrow-up','fa-magic',
|
876 |
+
'fa-magnet','fa-mail-forward','fa-mail-reply','fa-mail-reply-all','fa-male','fa-map','fa-map-marker','fa-map-o','fa-map-pin',
|
877 |
+
'fa-map-signs','fa-mars-double','fa-mars-stroke','fa-mars-stroke-h','fa-mars-stroke-v','fa-maxcdn','fa-meanpath','fa-medium',
|
878 |
+
'fa-medkit','fa-mercury','fa-microphone','fa-microphone-slash','fa-minus','fa-minus-circle','fa-minus-square','fa-minus-square-o',
|
879 |
+
'fa-mobile','fa-mobile-phone','fa-money','fa-moon-o','fa-mortar-board','fa-motorcycle','fa-mouse-pointer','fa-music','fa-navicon',
|
880 |
+
'fa-neuter','fa-newspaper-o','fa-object-group','fa-object-ungroup','fa-odnoklassniki','fa-odnoklassniki-square','fa-opencart',
|
881 |
+
'fa-openid','fa-opera','fa-optin-monster','fa-outdent','fa-pagelines','fa-paint-brush','fa-paper-plane','fa-paper-plane-o',
|
882 |
+
'fa-paperclip','fa-paragraph','fa-paste','fa-pause','fa-paw','fa-paypal','fa-pencil','fa-pencil-square','fa-pencil-square-o',
|
883 |
+
'fa-phone','fa-phone-square','fa-photo','fa-picture-o','fa-pie-chart','fa-pied-piper','fa-pied-piper-alt','fa-pinterest',
|
884 |
+
'fa-pinterest-p','fa-pinterest-square','fa-plane','fa-play','fa-play-circle','fa-play-circle-o','fa-plug','fa-plus','fa-plus-circle',
|
885 |
+
'fa-plus-square','fa-plus-square-o','fa-power-off','fa-print','fa-puzzle-piece','fa-qq','fa-qrcode','fa-question',
|
886 |
+
'fa-question-circle','fa-quote-left','fa-quote-right','fa-ra','fa-random','fa-rebel','fa-recycle','fa-reddit','fa-reddit-square',
|
887 |
+
'fa-refresh','fa-registered','fa-remove','fa-renren','fa-reorder','fa-repeat','fa-reply','fa-reply-all','fa-retweet','fa-rmb',
|
888 |
+
'fa-road','fa-rocket','fa-rotate-left','fa-rotate-right','fa-rouble','fa-rss','fa-rss-square','fa-rub','fa-ruble','fa-rupee',
|
889 |
+
'fa-safari','fa-save','fa-scissors','fa-search','fa-search-minus','fa-search-plus','fa-sellsy','fa-send','fa-send-o','fa-server',
|
890 |
+
'fa-share','fa-share-alt','fa-share-alt-square','fa-share-square','fa-share-square-o','fa-shekel','fa-sheqel','fa-shield',
|
891 |
+
'fa-ship','fa-shirtsinbulk','fa-shopping-cart','fa-sign-in','fa-sign-out','fa-signal','fa-simplybuilt','fa-sitemap','fa-skyatlas',
|
892 |
+
'fa-skype','fa-slack','fa-sliders','fa-slideshare','fa-smile-o','fa-soccer-ball-o','fa-sort','fa-sort-alpha-asc',
|
893 |
+
'fa-sort-alpha-desc','fa-sort-amount-asc','fa-sort-amount-desc','fa-sort-asc','fa-sort-desc','fa-sort-down','fa-sort-numeric-asc',
|
894 |
+
'fa-sort-numeric-desc','fa-sort-up','fa-soundcloud','fa-space-shuttle','fa-spinner','fa-spoon','fa-spotify','fa-square',
|
895 |
+
'fa-square-o','fa-stack-exchange','fa-stack-overflow','fa-steam','fa-steam-square','fa-star','fa-star-half','fa-star-half-empty',
|
896 |
+
'fa-star-half-full','fa-star-half-o','fa-star-o','fa-step-backward','fa-step-forward','fa-stethoscope','fa-sticky-note',
|
897 |
+
'fa-sticky-note-o','fa-stop','fa-street-view','fa-strikethrough','fa-stumbleupon','fa-stumbleupon-circle','fa-subscript',
|
898 |
+
'fa-subway','fa-suitcase','fa-sun-o','fa-superscript','fa-support','fa-table','fa-tablet','fa-tachometer','fa-tag','fa-tags',
|
899 |
+
'fa-tasks','fa-taxi','fa-television','fa-tencent-weibo','fa-terminal','fa-text-height','fa-text-width','fa-th','fa-th-large',
|
900 |
+
'fa-th-list','fa-thumb-tack','fa-thumbs-down','fa-thumbs-o-down','fa-thumbs-o-up','fa-thumbs-up','fa-ticket','fa-times',
|
901 |
+
'fa-times-circle','fa-times-circle-o','fa-tint','fa-toggle-down','fa-toggle-left','fa-toggle-off','fa-toggle-on','fa-toggle-right',
|
902 |
+
'fa-toggle-up','fa-trademark','fa-train','fa-transgender','fa-transgender-alt','fa-trash','fa-trash-o','fa-tree','fa-trello',
|
903 |
+
'fa-tripadvisor','fa-trophy','fa-truck','fa-try','fa-tty','fa-tumblr','fa-tumblr-square','fa-turkish-lira','fa-tv','fa-twitch',
|
904 |
+
'fa-twitter','fa-twitter-square','fa-umbrella','fa-underline','fa-university','fa-unlink','fa-unlock','fa-unlock-alt','fa-unsorted',
|
905 |
+
'fa-upload','fa-usd','fa-user','fa-user-md','fa-user-plus','fa-user-secret','fa-user-times','fa-users','fa-venus','fa-venus-double',
|
906 |
+
'fa-venus-mars','fa-viacoin','fa-video-camera','fa-vimeo','fa-vimeo-square','fa-vine','fa-vk','fa-volume-down','fa-volume-off',
|
907 |
+
'fa-volume-up','fa-warning','fa-wechat','fa-weibo','fa-weixin','fa-whatsapp','fa-wheelchair','fa-wifi','fa-wikipedia-w','fa-windows',
|
908 |
+
'fa-won','fa-wordpress','fa-wrench','fa-xing','fa-xing-square','fa-y-combinator','fa-y-combinator-square','fa-yahoo','fa-yc',
|
909 |
+
'fa-yc-square','fa-yelp','fa-yen','fa-youtube','fa-youtube-play','fa-youtube-square'
|
910 |
+
];
|
911 |
+
}));
|
912 |
+
|
913 |
+
/*!
|
914 |
+
* .pos() plugin based on jQuery UI Position 1.10.4, renamed to avoid
|
915 |
+
* problems with jQuery native .position(), and added some triggers when position
|
916 |
+
* collapses
|
917 |
+
*
|
918 |
+
* http://jqueryui.com
|
919 |
+
*
|
920 |
+
* Copyright 2014 jQuery Foundation and other contributors
|
921 |
+
* Released under the MIT license.
|
922 |
+
* http://jquery.org/license
|
923 |
+
*
|
924 |
+
* http://api.jqueryui.com/position/
|
925 |
+
*/
|
926 |
+
(function($, undefined) {
|
927 |
+
|
928 |
+
$.ui = $.ui || {};
|
929 |
+
|
930 |
+
var cachedScrollbarWidth,
|
931 |
+
max = Math.max,
|
932 |
+
abs = Math.abs,
|
933 |
+
round = Math.round,
|
934 |
+
rhorizontal = /left|center|right/,
|
935 |
+
rvertical = /top|center|bottom/,
|
936 |
+
roffset = /[\+\-]\d+(\.[\d]+)?%?/,
|
937 |
+
rposition = /^\w+/,
|
938 |
+
rpercent = /%$/,
|
939 |
+
_position = $.fn.pos;
|
940 |
+
|
941 |
+
function getOffsets(offsets, width, height) {
|
942 |
+
return [
|
943 |
+
parseFloat(offsets[0]) * (rpercent.test(offsets[0]) ? width / 100 : 1),
|
944 |
+
parseFloat(offsets[1]) * (rpercent.test(offsets[1]) ? height / 100 : 1)
|
945 |
+
];
|
946 |
+
}
|
947 |
+
|
948 |
+
function parseCss(element, property) {
|
949 |
+
return parseInt($.css(element, property), 10) || 0;
|
950 |
+
}
|
951 |
+
|
952 |
+
function getDimensions(elem) {
|
953 |
+
var raw = elem[0];
|
954 |
+
if (raw.nodeType === 9) {
|
955 |
+
return {
|
956 |
+
width: elem.width(),
|
957 |
+
height: elem.height(),
|
958 |
+
offset: {
|
959 |
+
top: 0,
|
960 |
+
left: 0
|
961 |
+
}
|
962 |
+
};
|
963 |
+
}
|
964 |
+
if ($.isWindow(raw)) {
|
965 |
+
return {
|
966 |
+
width: elem.width(),
|
967 |
+
height: elem.height(),
|
968 |
+
offset: {
|
969 |
+
top: elem.scrollTop(),
|
970 |
+
left: elem.scrollLeft()
|
971 |
+
}
|
972 |
+
};
|
973 |
+
}
|
974 |
+
if (raw.preventDefault) {
|
975 |
+
return {
|
976 |
+
width: 0,
|
977 |
+
height: 0,
|
978 |
+
offset: {
|
979 |
+
top: raw.pageY,
|
980 |
+
left: raw.pageX
|
981 |
+
}
|
982 |
+
};
|
983 |
+
}
|
984 |
+
return {
|
985 |
+
width: elem.outerWidth(),
|
986 |
+
height: elem.outerHeight(),
|
987 |
+
offset: elem.offset()
|
988 |
+
};
|
989 |
+
}
|
990 |
+
|
991 |
+
$.pos = {
|
992 |
+
scrollbarWidth: function() {
|
993 |
+
if (cachedScrollbarWidth !== undefined) {
|
994 |
+
return cachedScrollbarWidth;
|
995 |
+
}
|
996 |
+
var w1, w2,
|
997 |
+
div = $("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),
|
998 |
+
innerDiv = div.children()[0];
|
999 |
+
|
1000 |
+
$("body").append(div);
|
1001 |
+
w1 = innerDiv.offsetWidth;
|
1002 |
+
div.css("overflow", "scroll");
|
1003 |
+
|
1004 |
+
w2 = innerDiv.offsetWidth;
|
1005 |
+
|
1006 |
+
if (w1 === w2) {
|
1007 |
+
w2 = div[0].clientWidth;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
div.remove();
|
1011 |
+
|
1012 |
+
return (cachedScrollbarWidth = w1 - w2);
|
1013 |
+
},
|
1014 |
+
getScrollInfo: function(within) {
|
1015 |
+
var overflowX = within.isWindow || within.isDocument ? "" :
|
1016 |
+
within.element.css("overflow-x"),
|
1017 |
+
overflowY = within.isWindow || within.isDocument ? "" :
|
1018 |
+
within.element.css("overflow-y"),
|
1019 |
+
hasOverflowX = overflowX === "scroll" ||
|
1020 |
+
(overflowX === "auto" && within.width < within.element[0].scrollWidth),
|
1021 |
+
hasOverflowY = overflowY === "scroll" ||
|
1022 |
+
(overflowY === "auto" && within.height < within.element[0].scrollHeight);
|
1023 |
+
return {
|
1024 |
+
width: hasOverflowY ? $.pos.scrollbarWidth() : 0,
|
1025 |
+
height: hasOverflowX ? $.pos.scrollbarWidth() : 0
|
1026 |
+
};
|
1027 |
+
},
|
1028 |
+
getWithinInfo: function(element) {
|
1029 |
+
var withinElement = $(element || window),
|
1030 |
+
isWindow = $.isWindow(withinElement[0]),
|
1031 |
+
isDocument = !!withinElement[0] && withinElement[0].nodeType === 9;
|
1032 |
+
return {
|
1033 |
+
element: withinElement,
|
1034 |
+
isWindow: isWindow,
|
1035 |
+
isDocument: isDocument,
|
1036 |
+
offset: withinElement.offset() || {
|
1037 |
+
left: 0,
|
1038 |
+
top: 0
|
1039 |
+
},
|
1040 |
+
scrollLeft: withinElement.scrollLeft(),
|
1041 |
+
scrollTop: withinElement.scrollTop(),
|
1042 |
+
width: isWindow ? withinElement.width() : withinElement.outerWidth(),
|
1043 |
+
height: isWindow ? withinElement.height() : withinElement.outerHeight()
|
1044 |
+
};
|
1045 |
+
}
|
1046 |
+
};
|
1047 |
+
|
1048 |
+
$.fn.pos = function(options) {
|
1049 |
+
if (!options || !options.of) {
|
1050 |
+
return _position.apply(this, arguments);
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
// make a copy, we don't want to modify arguments
|
1054 |
+
options = $.extend({}, options);
|
1055 |
+
|
1056 |
+
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
|
1057 |
+
target = $(options.of),
|
1058 |
+
within = $.pos.getWithinInfo(options.within),
|
1059 |
+
scrollInfo = $.pos.getScrollInfo(within),
|
1060 |
+
collision = (options.collision || "flip").split(" "),
|
1061 |
+
offsets = {};
|
1062 |
+
|
1063 |
+
dimensions = getDimensions(target);
|
1064 |
+
if (target[0].preventDefault) {
|
1065 |
+
// force left top to allow flipping
|
1066 |
+
options.at = "left top";
|
1067 |
+
}
|
1068 |
+
targetWidth = dimensions.width;
|
1069 |
+
targetHeight = dimensions.height;
|
1070 |
+
targetOffset = dimensions.offset;
|
1071 |
+
// clone to reuse original targetOffset later
|
1072 |
+
basePosition = $.extend({}, targetOffset);
|
1073 |
+
|
1074 |
+
// force my and at to have valid horizontal and vertical positions
|
1075 |
+
// if a value is missing or invalid, it will be converted to center
|
1076 |
+
$.each(["my", "at"], function() {
|
1077 |
+
var pos = (options[this] || "").split(" "),
|
1078 |
+
horizontalOffset,
|
1079 |
+
verticalOffset;
|
1080 |
+
|
1081 |
+
if (pos.length === 1) {
|
1082 |
+
pos = rhorizontal.test(pos[0]) ?
|
1083 |
+
pos.concat(["center"]) :
|
1084 |
+
rvertical.test(pos[0]) ? ["center"].concat(pos) : ["center", "center"];
|
1085 |
+
}
|
1086 |
+
pos[0] = rhorizontal.test(pos[0]) ? pos[0] : "center";
|
1087 |
+
pos[1] = rvertical.test(pos[1]) ? pos[1] : "center";
|
1088 |
+
|
1089 |
+
// calculate offsets
|
1090 |
+
horizontalOffset = roffset.exec(pos[0]);
|
1091 |
+
verticalOffset = roffset.exec(pos[1]);
|
1092 |
+
offsets[this] = [
|
1093 |
+
horizontalOffset ? horizontalOffset[0] : 0,
|
1094 |
+
verticalOffset ? verticalOffset[0] : 0
|
1095 |
+
];
|
1096 |
+
|
1097 |
+
// reduce to just the positions without the offsets
|
1098 |
+
options[this] = [
|
1099 |
+
rposition.exec(pos[0])[0],
|
1100 |
+
rposition.exec(pos[1])[0]
|
1101 |
+
];
|
1102 |
+
});
|
1103 |
+
|
1104 |
+
// normalize collision option
|
1105 |
+
if (collision.length === 1) {
|
1106 |
+
collision[1] = collision[0];
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
if (options.at[0] === "right") {
|
1110 |
+
basePosition.left += targetWidth;
|
1111 |
+
} else if (options.at[0] === "center") {
|
1112 |
+
basePosition.left += targetWidth / 2;
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
if (options.at[1] === "bottom") {
|
1116 |
+
basePosition.top += targetHeight;
|
1117 |
+
} else if (options.at[1] === "center") {
|
1118 |
+
basePosition.top += targetHeight / 2;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
atOffset = getOffsets(offsets.at, targetWidth, targetHeight);
|
1122 |
+
basePosition.left += atOffset[0];
|
1123 |
+
basePosition.top += atOffset[1];
|
1124 |
+
|
1125 |
+
return this.each(function() {
|
1126 |
+
var collisionPosition, using,
|
1127 |
+
elem = $(this),
|
1128 |
+
elemWidth = elem.outerWidth(),
|
1129 |
+
elemHeight = elem.outerHeight(),
|
1130 |
+
marginLeft = parseCss(this, "marginLeft"),
|
1131 |
+
marginTop = parseCss(this, "marginTop"),
|
1132 |
+
collisionWidth = elemWidth + marginLeft + parseCss(this, "marginRight") + scrollInfo.width,
|
1133 |
+
collisionHeight = elemHeight + marginTop + parseCss(this, "marginBottom") + scrollInfo.height,
|
1134 |
+
position = $.extend({}, basePosition),
|
1135 |
+
myOffset = getOffsets(offsets.my, elem.outerWidth(), elem.outerHeight());
|
1136 |
+
|
1137 |
+
if (options.my[0] === "right") {
|
1138 |
+
position.left -= elemWidth;
|
1139 |
+
} else if (options.my[0] === "center") {
|
1140 |
+
position.left -= elemWidth / 2;
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
if (options.my[1] === "bottom") {
|
1144 |
+
position.top -= elemHeight;
|
1145 |
+
} else if (options.my[1] === "center") {
|
1146 |
+
position.top -= elemHeight / 2;
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
position.left += myOffset[0];
|
1150 |
+
position.top += myOffset[1];
|
1151 |
+
|
1152 |
+
// if the browser doesn't support fractions, then round for consistent results
|
1153 |
+
if (!$.support.offsetFractions) {
|
1154 |
+
position.left = round(position.left);
|
1155 |
+
position.top = round(position.top);
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
collisionPosition = {
|
1159 |
+
marginLeft: marginLeft,
|
1160 |
+
marginTop: marginTop
|
1161 |
+
};
|
1162 |
+
|
1163 |
+
$.each(["left", "top"], function(i, dir) {
|
1164 |
+
if ($.ui.pos[collision[i]]) {
|
1165 |
+
$.ui.pos[collision[i]][dir](position, {
|
1166 |
+
targetWidth: targetWidth,
|
1167 |
+
targetHeight: targetHeight,
|
1168 |
+
elemWidth: elemWidth,
|
1169 |
+
elemHeight: elemHeight,
|
1170 |
+
collisionPosition: collisionPosition,
|
1171 |
+
collisionWidth: collisionWidth,
|
1172 |
+
collisionHeight: collisionHeight,
|
1173 |
+
offset: [atOffset[0] + myOffset[0], atOffset[1] + myOffset[1]],
|
1174 |
+
my: options.my,
|
1175 |
+
at: options.at,
|
1176 |
+
within: within,
|
1177 |
+
elem: elem
|
1178 |
+
});
|
1179 |
+
}
|
1180 |
+
});
|
1181 |
+
|
1182 |
+
if (options.using) {
|
1183 |
+
// adds feedback as second argument to using callback, if present
|
1184 |
+
using = function(props) {
|
1185 |
+
var left = targetOffset.left - position.left,
|
1186 |
+
right = left + targetWidth - elemWidth,
|
1187 |
+
top = targetOffset.top - position.top,
|
1188 |
+
bottom = top + targetHeight - elemHeight,
|
1189 |
+
feedback = {
|
1190 |
+
target: {
|
1191 |
+
element: target,
|
1192 |
+
left: targetOffset.left,
|
1193 |
+
top: targetOffset.top,
|
1194 |
+
width: targetWidth,
|
1195 |
+
height: targetHeight
|
1196 |
+
},
|
1197 |
+
element: {
|
1198 |
+
element: elem,
|
1199 |
+
left: position.left,
|
1200 |
+
top: position.top,
|
1201 |
+
width: elemWidth,
|
1202 |
+
height: elemHeight
|
1203 |
+
},
|
1204 |
+
horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
|
1205 |
+
vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
|
1206 |
+
};
|
1207 |
+
if (targetWidth < elemWidth && abs(left + right) < targetWidth) {
|
1208 |
+
feedback.horizontal = "center";
|
1209 |
+
}
|
1210 |
+
if (targetHeight < elemHeight && abs(top + bottom) < targetHeight) {
|
1211 |
+
feedback.vertical = "middle";
|
1212 |
+
}
|
1213 |
+
if (max(abs(left), abs(right)) > max(abs(top), abs(bottom))) {
|
1214 |
+
feedback.important = "horizontal";
|
1215 |
+
} else {
|
1216 |
+
feedback.important = "vertical";
|
1217 |
+
}
|
1218 |
+
options.using.call(this, props, feedback);
|
1219 |
+
};
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
elem.offset($.extend(position, {
|
1223 |
+
using: using
|
1224 |
+
}));
|
1225 |
+
});
|
1226 |
+
};
|
1227 |
+
|
1228 |
+
$.ui.pos = {
|
1229 |
+
_trigger: function(position, data, name, triggered) {
|
1230 |
+
if (data.elem) {
|
1231 |
+
data.elem.trigger({
|
1232 |
+
'type': name,
|
1233 |
+
'position': position,
|
1234 |
+
'positionData': data,
|
1235 |
+
'triggered': triggered
|
1236 |
+
});
|
1237 |
+
}
|
1238 |
+
},
|
1239 |
+
fit: {
|
1240 |
+
left: function(position, data) {
|
1241 |
+
$.ui.pos._trigger(position, data, 'posCollide', 'fitLeft');
|
1242 |
+
var within = data.within,
|
1243 |
+
withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
|
1244 |
+
outerWidth = within.width,
|
1245 |
+
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
|
1246 |
+
overLeft = withinOffset - collisionPosLeft,
|
1247 |
+
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
|
1248 |
+
newOverRight;
|
1249 |
+
|
1250 |
+
// element is wider than within
|
1251 |
+
if (data.collisionWidth > outerWidth) {
|
1252 |
+
// element is initially over the left side of within
|
1253 |
+
if (overLeft > 0 && overRight <= 0) {
|
1254 |
+
newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
|
1255 |
+
position.left += overLeft - newOverRight;
|
1256 |
+
// element is initially over right side of within
|
1257 |
+
} else if (overRight > 0 && overLeft <= 0) {
|
1258 |
+
position.left = withinOffset;
|
1259 |
+
// element is initially over both left and right sides of within
|
1260 |
+
} else {
|
1261 |
+
if (overLeft > overRight) {
|
1262 |
+
position.left = withinOffset + outerWidth - data.collisionWidth;
|
1263 |
+
} else {
|
1264 |
+
position.left = withinOffset;
|
1265 |
+
}
|
1266 |
+
}
|
1267 |
+
// too far left -> align with left edge
|
1268 |
+
} else if (overLeft > 0) {
|
1269 |
+
position.left += overLeft;
|
1270 |
+
// too far right -> align with right edge
|
1271 |
+
} else if (overRight > 0) {
|
1272 |
+
position.left -= overRight;
|
1273 |
+
// adjust based on position and margin
|
1274 |
+
} else {
|
1275 |
+
position.left = max(position.left - collisionPosLeft, position.left);
|
1276 |
+
}
|
1277 |
+
$.ui.pos._trigger(position, data, 'posCollided', 'fitLeft');
|
1278 |
+
},
|
1279 |
+
top: function(position, data) {
|
1280 |
+
$.ui.pos._trigger(position, data, 'posCollide', 'fitTop');
|
1281 |
+
var within = data.within,
|
1282 |
+
withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
|
1283 |
+
outerHeight = data.within.height,
|
1284 |
+
collisionPosTop = position.top - data.collisionPosition.marginTop,
|
1285 |
+
overTop = withinOffset - collisionPosTop,
|
1286 |
+
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
|
1287 |
+
newOverBottom;
|
1288 |
+
|
1289 |
+
// element is taller than within
|
1290 |
+
if (data.collisionHeight > outerHeight) {
|
1291 |
+
// element is initially over the top of within
|
1292 |
+
if (overTop > 0 && overBottom <= 0) {
|
1293 |
+
newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
|
1294 |
+
position.top += overTop - newOverBottom;
|
1295 |
+
// element is initially over bottom of within
|
1296 |
+
} else if (overBottom > 0 && overTop <= 0) {
|
1297 |
+
position.top = withinOffset;
|
1298 |
+
// element is initially over both top and bottom of within
|
1299 |
+
} else {
|
1300 |
+
if (overTop > overBottom) {
|
1301 |
+
position.top = withinOffset + outerHeight - data.collisionHeight;
|
1302 |
+
} else {
|
1303 |
+
position.top = withinOffset;
|
1304 |
+
}
|
1305 |
+
}
|
1306 |
+
// too far up -> align with top
|
1307 |
+
} else if (overTop > 0) {
|
1308 |
+
position.top += overTop;
|
1309 |
+
// too far down -> align with bottom edge
|
1310 |
+
} else if (overBottom > 0) {
|
1311 |
+
position.top -= overBottom;
|
1312 |
+
// adjust based on position and margin
|
1313 |
+
} else {
|
1314 |
+
position.top = max(position.top - collisionPosTop, position.top);
|
1315 |
+
}
|
1316 |
+
$.ui.pos._trigger(position, data, 'posCollided', 'fitTop');
|
1317 |
+
}
|
1318 |
+
},
|
1319 |
+
flip: {
|
1320 |
+
left: function(position, data) {
|
1321 |
+
$.ui.pos._trigger(position, data, 'posCollide', 'flipLeft');
|
1322 |
+
var within = data.within,
|
1323 |
+
withinOffset = within.offset.left + within.scrollLeft,
|
1324 |
+
outerWidth = within.width,
|
1325 |
+
offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
|
1326 |
+
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
|
1327 |
+
overLeft = collisionPosLeft - offsetLeft,
|
1328 |
+
overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
|
1329 |
+
myOffset = data.my[0] === "left" ?
|
1330 |
+
-data.elemWidth :
|
1331 |
+
data.my[0] === "right" ?
|
1332 |
+
data.elemWidth :
|
1333 |
+
0,
|
1334 |
+
atOffset = data.at[0] === "left" ?
|
1335 |
+
data.targetWidth :
|
1336 |
+
data.at[0] === "right" ?
|
1337 |
+
-data.targetWidth :
|
1338 |
+
0,
|
1339 |
+
offset = -2 * data.offset[0],
|
1340 |
+
newOverRight,
|
1341 |
+
newOverLeft;
|
1342 |
+
|
1343 |
+
if (overLeft < 0) {
|
1344 |
+
newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
|
1345 |
+
if (newOverRight < 0 || newOverRight < abs(overLeft)) {
|
1346 |
+
position.left += myOffset + atOffset + offset;
|
1347 |
+
}
|
1348 |
+
} else if (overRight > 0) {
|
1349 |
+
newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
|
1350 |
+
if (newOverLeft > 0 || abs(newOverLeft) < overRight) {
|
1351 |
+
position.left += myOffset + atOffset + offset;
|
1352 |
+
}
|
1353 |
+
}
|
1354 |
+
$.ui.pos._trigger(position, data, 'posCollided', 'flipLeft');
|
1355 |
+
},
|
1356 |
+
top: function(position, data) {
|
1357 |
+
$.ui.pos._trigger(position, data, 'posCollide', 'flipTop');
|
1358 |
+
var within = data.within,
|
1359 |
+
withinOffset = within.offset.top + within.scrollTop,
|
1360 |
+
outerHeight = within.height,
|
1361 |
+
offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
|
1362 |
+
collisionPosTop = position.top - data.collisionPosition.marginTop,
|
1363 |
+
overTop = collisionPosTop - offsetTop,
|
1364 |
+
overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
|
1365 |
+
top = data.my[1] === "top",
|
1366 |
+
myOffset = top ?
|
1367 |
+
-data.elemHeight :
|
1368 |
+
data.my[1] === "bottom" ?
|
1369 |
+
data.elemHeight :
|
1370 |
+
0,
|
1371 |
+
atOffset = data.at[1] === "top" ?
|
1372 |
+
data.targetHeight :
|
1373 |
+
data.at[1] === "bottom" ?
|
1374 |
+
-data.targetHeight :
|
1375 |
+
0,
|
1376 |
+
offset = -2 * data.offset[1],
|
1377 |
+
newOverTop,
|
1378 |
+
newOverBottom;
|
1379 |
+
if (overTop < 0) {
|
1380 |
+
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
|
1381 |
+
if ((position.top + myOffset + atOffset + offset) > overTop && (newOverBottom < 0 || newOverBottom < abs(overTop))) {
|
1382 |
+
position.top += myOffset + atOffset + offset;
|
1383 |
+
}
|
1384 |
+
} else if (overBottom > 0) {
|
1385 |
+
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
|
1386 |
+
if ((position.top + myOffset + atOffset + offset) > overBottom && (newOverTop > 0 || abs(newOverTop) < overBottom)) {
|
1387 |
+
position.top += myOffset + atOffset + offset;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
$.ui.pos._trigger(position, data, 'posCollided', 'flipTop');
|
1391 |
+
}
|
1392 |
+
},
|
1393 |
+
flipfit: {
|
1394 |
+
left: function() {
|
1395 |
+
$.ui.pos.flip.left.apply(this, arguments);
|
1396 |
+
$.ui.pos.fit.left.apply(this, arguments);
|
1397 |
+
},
|
1398 |
+
top: function() {
|
1399 |
+
$.ui.pos.flip.top.apply(this, arguments);
|
1400 |
+
$.ui.pos.fit.top.apply(this, arguments);
|
1401 |
+
}
|
1402 |
+
}
|
1403 |
+
};
|
1404 |
+
|
1405 |
+
// fraction support test
|
1406 |
+
(function() {
|
1407 |
+
var testElement, testElementParent, testElementStyle, offsetLeft, i,
|
1408 |
+
body = document.getElementsByTagName("body")[0],
|
1409 |
+
div = document.createElement("div");
|
1410 |
+
|
1411 |
+
//Create a "fake body" for testing based on method used in jQuery.support
|
1412 |
+
testElement = document.createElement(body ? "div" : "body");
|
1413 |
+
testElementStyle = {
|
1414 |
+
visibility: "hidden",
|
1415 |
+
width: 0,
|
1416 |
+
height: 0,
|
1417 |
+
border: 0,
|
1418 |
+
margin: 0,
|
1419 |
+
background: "none"
|
1420 |
+
};
|
1421 |
+
if (body) {
|
1422 |
+
$.extend(testElementStyle, {
|
1423 |
+
position: "absolute",
|
1424 |
+
left: "-1000px",
|
1425 |
+
top: "-1000px"
|
1426 |
+
});
|
1427 |
+
}
|
1428 |
+
for (i in testElementStyle) {
|
1429 |
+
testElement.style[i] = testElementStyle[i];
|
1430 |
+
}
|
1431 |
+
testElement.appendChild(div);
|
1432 |
+
testElementParent = body || document.documentElement;
|
1433 |
+
testElementParent.insertBefore(testElement, testElementParent.firstChild);
|
1434 |
+
|
1435 |
+
div.style.cssText = "position: absolute; left: 10.7432222px;";
|
1436 |
+
|
1437 |
+
offsetLeft = $(div).offset().left;
|
1438 |
+
$.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
|
1439 |
+
|
1440 |
+
testElement.innerHTML = "";
|
1441 |
+
testElementParent.removeChild(testElement);
|
1442 |
+
})();
|
1443 |
+
|
1444 |
+
}(jQuery));
|
1445 |
+
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/min/jquery-iconpicker.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a,b){function c(a,b,c){return[parseFloat(a[0])*(n.test(a[0])?b/100:1),parseFloat(a[1])*(n.test(a[1])?c/100:1)]}function d(b,c){return parseInt(a.css(b,c),10)||0}function e(b){var c=b[0];return 9===c.nodeType?{width:b.width(),height:b.height(),offset:{top:0,left:0}}:a.isWindow(c)?{width:b.width(),height:b.height(),offset:{top:b.scrollTop(),left:b.scrollLeft()}}:c.preventDefault?{width:0,height:0,offset:{top:c.pageY,left:c.pageX}}:{width:b.outerWidth(),height:b.outerHeight(),offset:b.offset()}}a.ui=a.ui||{};var f,g=Math.max,h=Math.abs,i=Math.round,j=/left|center|right/,k=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,m=/^\w+/,n=/%$/,o=a.fn.pos;a.pos={scrollbarWidth:function(){if(f!==b)return f;var c,d,e=a("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),g=e.children()[0];return a("body").append(e),c=g.offsetWidth,e.css("overflow","scroll"),d=g.offsetWidth,c===d&&(d=e[0].clientWidth),e.remove(),f=c-d},getScrollInfo:function(b){var c=b.isWindow||b.isDocument?"":b.element.css("overflow-x"),d=b.isWindow||b.isDocument?"":b.element.css("overflow-y"),e="scroll"===c||"auto"===c&&b.width<b.element[0].scrollWidth,f="scroll"===d||"auto"===d&&b.height<b.element[0].scrollHeight;return{width:f?a.pos.scrollbarWidth():0,height:e?a.pos.scrollbarWidth():0}},getWithinInfo:function(b){var c=a(b||window),d=a.isWindow(c[0]),e=!!c[0]&&9===c[0].nodeType;return{element:c,isWindow:d,isDocument:e,offset:c.offset()||{left:0,top:0},scrollLeft:c.scrollLeft(),scrollTop:c.scrollTop(),width:d?c.width():c.outerWidth(),height:d?c.height():c.outerHeight()}}},a.fn.pos=function(b){if(!b||!b.of)return o.apply(this,arguments);b=a.extend({},b);var f,n,p,q,r,s,t=a(b.of),u=a.pos.getWithinInfo(b.within),v=a.pos.getScrollInfo(u),w=(b.collision||"flip").split(" "),x={};return s=e(t),t[0].preventDefault&&(b.at="left top"),n=s.width,p=s.height,q=s.offset,r=a.extend({},q),a.each(["my","at"],function(){var a,c,d=(b[this]||"").split(" ");1===d.length&&(d=j.test(d[0])?d.concat(["center"]):k.test(d[0])?["center"].concat(d):["center","center"]),d[0]=j.test(d[0])?d[0]:"center",d[1]=k.test(d[1])?d[1]:"center",a=l.exec(d[0]),c=l.exec(d[1]),x[this]=[a?a[0]:0,c?c[0]:0],b[this]=[m.exec(d[0])[0],m.exec(d[1])[0]]}),1===w.length&&(w[1]=w[0]),"right"===b.at[0]?r.left+=n:"center"===b.at[0]&&(r.left+=n/2),"bottom"===b.at[1]?r.top+=p:"center"===b.at[1]&&(r.top+=p/2),f=c(x.at,n,p),r.left+=f[0],r.top+=f[1],this.each(function(){var e,j,k=a(this),l=k.outerWidth(),m=k.outerHeight(),o=d(this,"marginLeft"),s=d(this,"marginTop"),y=l+o+d(this,"marginRight")+v.width,z=m+s+d(this,"marginBottom")+v.height,A=a.extend({},r),B=c(x.my,k.outerWidth(),k.outerHeight());"right"===b.my[0]?A.left-=l:"center"===b.my[0]&&(A.left-=l/2),"bottom"===b.my[1]?A.top-=m:"center"===b.my[1]&&(A.top-=m/2),A.left+=B[0],A.top+=B[1],a.support.offsetFractions||(A.left=i(A.left),A.top=i(A.top)),e={marginLeft:o,marginTop:s},a.each(["left","top"],function(c,d){a.ui.pos[w[c]]&&a.ui.pos[w[c]][d](A,{targetWidth:n,targetHeight:p,elemWidth:l,elemHeight:m,collisionPosition:e,collisionWidth:y,collisionHeight:z,offset:[f[0]+B[0],f[1]+B[1]],my:b.my,at:b.at,within:u,elem:k})}),b.using&&(j=function(a){var c=q.left-A.left,d=c+n-l,e=q.top-A.top,f=e+p-m,i={target:{element:t,left:q.left,top:q.top,width:n,height:p},element:{element:k,left:A.left,top:A.top,width:l,height:m},horizontal:0>d?"left":c>0?"right":"center",vertical:0>f?"top":e>0?"bottom":"middle"};l>n&&h(c+d)<n&&(i.horizontal="center"),m>p&&h(e+f)<p&&(i.vertical="middle"),i.important=g(h(c),h(d))>g(h(e),h(f))?"horizontal":"vertical",b.using.call(this,a,i)}),k.offset(a.extend(A,{using:j}))})},a.ui.pos={_trigger:function(a,b,c,d){b.elem&&b.elem.trigger({type:c,position:a,positionData:b,triggered:d})},fit:{left:function(b,c){a.ui.pos._trigger(b,c,"posCollide","fitLeft");var d,e=c.within,f=e.isWindow?e.scrollLeft:e.offset.left,h=e.width,i=b.left-c.collisionPosition.marginLeft,j=f-i,k=i+c.collisionWidth-h-f;c.collisionWidth>h?j>0&&0>=k?(d=b.left+j+c.collisionWidth-h-f,b.left+=j-d):b.left=k>0&&0>=j?f:j>k?f+h-c.collisionWidth:f:j>0?b.left+=j:k>0?b.left-=k:b.left=g(b.left-i,b.left),a.ui.pos._trigger(b,c,"posCollided","fitLeft")},top:function(b,c){a.ui.pos._trigger(b,c,"posCollide","fitTop");var d,e=c.within,f=e.isWindow?e.scrollTop:e.offset.top,h=c.within.height,i=b.top-c.collisionPosition.marginTop,j=f-i,k=i+c.collisionHeight-h-f;c.collisionHeight>h?j>0&&0>=k?(d=b.top+j+c.collisionHeight-h-f,b.top+=j-d):b.top=k>0&&0>=j?f:j>k?f+h-c.collisionHeight:f:j>0?b.top+=j:k>0?b.top-=k:b.top=g(b.top-i,b.top),a.ui.pos._trigger(b,c,"posCollided","fitTop")}},flip:{left:function(b,c){a.ui.pos._trigger(b,c,"posCollide","flipLeft");var d,e,f=c.within,g=f.offset.left+f.scrollLeft,i=f.width,j=f.isWindow?f.scrollLeft:f.offset.left,k=b.left-c.collisionPosition.marginLeft,l=k-j,m=k+c.collisionWidth-i-j,n="left"===c.my[0]?-c.elemWidth:"right"===c.my[0]?c.elemWidth:0,o="left"===c.at[0]?c.targetWidth:"right"===c.at[0]?-c.targetWidth:0,p=-2*c.offset[0];0>l?(d=b.left+n+o+p+c.collisionWidth-i-g,(0>d||d<h(l))&&(b.left+=n+o+p)):m>0&&(e=b.left-c.collisionPosition.marginLeft+n+o+p-j,(e>0||h(e)<m)&&(b.left+=n+o+p)),a.ui.pos._trigger(b,c,"posCollided","flipLeft")},top:function(b,c){a.ui.pos._trigger(b,c,"posCollide","flipTop");var d,e,f=c.within,g=f.offset.top+f.scrollTop,i=f.height,j=f.isWindow?f.scrollTop:f.offset.top,k=b.top-c.collisionPosition.marginTop,l=k-j,m=k+c.collisionHeight-i-j,n="top"===c.my[1],o=n?-c.elemHeight:"bottom"===c.my[1]?c.elemHeight:0,p="top"===c.at[1]?c.targetHeight:"bottom"===c.at[1]?-c.targetHeight:0,q=-2*c.offset[1];0>l?(e=b.top+o+p+q+c.collisionHeight-i-g,b.top+o+p+q>l&&(0>e||e<h(l))&&(b.top+=o+p+q)):m>0&&(d=b.top-c.collisionPosition.marginTop+o+p+q-j,b.top+o+p+q>m&&(d>0||h(d)<m)&&(b.top+=o+p+q)),a.ui.pos._trigger(b,c,"posCollided","flipTop")}},flipfit:{left:function(){a.ui.pos.flip.left.apply(this,arguments),a.ui.pos.fit.left.apply(this,arguments)},top:function(){a.ui.pos.flip.top.apply(this,arguments),a.ui.pos.fit.top.apply(this,arguments)}}},function(){var b,c,d,e,f,g=document.getElementsByTagName("body")[0],h=document.createElement("div");b=document.createElement(g?"div":"body"),d={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},g&&a.extend(d,{position:"absolute",left:"-1000px",top:"-1000px"});for(f in d)b.style[f]=d[f];b.appendChild(h),c=g||document.documentElement,c.insertBefore(b,c.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",e=a(h).offset().left,a.support.offsetFractions=e>10&&11>e,b.innerHTML="",c.removeChild(b)}()}(jQuery),function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):window.jQuery&&!window.jQuery.fn.iconpicker&&a(window.jQuery)}(function(a){"use strict";var b={isEmpty:function(a){return a===!1||""===a||null===a||void 0===a},isEmptyObject:function(a){return this.isEmpty(a)===!0||0===a.length},isElement:function(b){return a(b).length>0},isString:function(a){return"string"==typeof a||a instanceof String},isArray:function(b){return a.isArray(b)},inArray:function(b,c){return-1!==a.inArray(b,c)},throwError:function(a){throw"Font Awesome Icon Picker Exception: "+a}},c=function(d,e){this._id=c._idCounter++,this.element=a(d).addClass("iconpicker-element"),this._trigger("iconpickerCreate"),this.options=a.extend({},c.defaultOptions,this.element.data(),e),this.options.templates=a.extend({},c.defaultOptions.templates,this.options.templates),this.options.originalPlacement=this.options.placement,this.container=b.isElement(this.options.container)?a(this.options.container):!1,this.container===!1&&(this.container=this.element.is("input")?this.element.parent():this.element),this.container.addClass("iconpicker-container").is(".dropdown-menu")&&(this.options.placement="inline"),this.input=this.element.is("input")?this.element.addClass("iconpicker-input"):!1,this.input===!1&&(this.input=this.container.find(this.options.input)),this.component=this.container.find(this.options.component).addClass("iconpicker-component"),0===this.component.length?this.component=!1:this.component.find("i").addClass(this.options.iconComponentBaseClass),this._createPopover(),this._createIconpicker(),0===this.getAcceptButton().length&&(this.options.mustAccept=!1),this.container.is(".input-group")?this.container.parent().append(this.popover):this.container.append(this.popover),this._bindElementEvents(),this._bindWindowEvents(),this.update(this.options.selected),this.isInline()&&this.show(),this._trigger("iconpickerCreated")};c._idCounter=0,c.defaultOptions={title:!1,selected:!1,defaultValue:!1,placement:"bottom",collision:"none",animation:!0,hideOnSelect:!1,showFooter:!1,searchInFooter:!1,mustAccept:!1,selectedCustomClass:"bg-primary",icons:[],iconBaseClass:"fa",iconComponentBaseClass:"fa fa-fw",iconClassPrefix:"fa-",input:"input",component:".input-group-addon",container:!1,templates:{popover:'<div class="iconpicker-popover popover"><div class="arrow"></div><div class="popover-title"></div><div class="popover-content"></div></div>',footer:'<div class="popover-footer"></div>',buttons:'<button class="iconpicker-btn iconpicker-btn-cancel btn btn-default btn-sm">Cancel</button> <button class="iconpicker-btn iconpicker-btn-accept btn btn-primary btn-sm">Accept</button>',search:'<input type="search" class="form-control iconpicker-search" placeholder="Type to filter" />',iconpicker:'<div class="iconpicker"><div class="iconpicker-items"></div></div>',iconpickerItem:'<div class="iconpicker-item"><i></i></div>'}},c.batch=function(b,c){var d=Array.prototype.slice.call(arguments,2);return a(b).each(function(){var b=a(this).data("iconpicker");b&&b[c].apply(b,d)})},c.prototype={constructor:c,options:{},_id:0,_trigger:function(b,c){c=c||{},this.element.trigger(a.extend({type:b,iconpickerInstance:this},c))},_createPopover:function(){this.popover=a(this.options.templates.popover);var c=this.popover.find(".popover-title");if(this.options.title&&c.append(a('<div class="popover-title-text">'+this.options.title+"</div>")),this.options.searchInFooter||b.isEmpty(this.options.templates.buttons)?this.options.title||c.remove():c.append(this.options.templates.search),this.options.showFooter&&!b.isEmpty(this.options.templates.footer)){var d=a(this.options.templates.footer);!b.isEmpty(this.options.templates.search)&&this.options.searchInFooter&&d.append(a(this.options.templates.search)),b.isEmpty(this.options.templates.buttons)||d.append(a(this.options.templates.buttons)),this.popover.append(d)}return this.options.animation===!0&&this.popover.addClass("fade"),this.popover},_createIconpicker:function(){var b=this;this.iconpicker=a(this.options.templates.iconpicker);var c=function(){var c=a(this);c.is("."+b.options.iconBaseClass)&&(c=c.parent()),b._trigger("iconpickerSelect",{iconpickerItem:c,iconpickerValue:b.iconpickerValue}),b.options.mustAccept===!1?(b.update(c.data("iconpickerValue")),b._trigger("iconpickerSelected",{iconpickerItem:this,iconpickerValue:b.iconpickerValue})):b.update(c.data("iconpickerValue"),!0),b.options.hideOnSelect&&b.options.mustAccept===!1&&b.hide()};for(var d in this.options.icons){var e=a(this.options.templates.iconpickerItem);e.find("i").addClass(b.options.iconBaseClass+" "+this.options.iconClassPrefix+this.options.icons[d]),e.data("iconpickerValue",this.options.icons[d]).on("click.iconpicker",c),this.iconpicker.find(".iconpicker-items").append(e.attr("title","."+this.getValue(this.options.icons[d])))}return this.popover.find(".popover-content").append(this.iconpicker),this.iconpicker},_isEventInsideIconpicker:function(b){var c=a(b.target);return c.hasClass("iconpicker-element")&&(!c.hasClass("iconpicker-element")||c.is(this.element))||0!==c.parents(".iconpicker-popover").length?!0:!1},_bindElementEvents:function(){var c=this;this.getSearchInput().on("keyup",function(){c.filter(a(this).val().toLowerCase())}),this.getAcceptButton().on("click.iconpicker",function(){var a=c.iconpicker.find(".iconpicker-selected").get(0);c.update(c.iconpickerValue),c._trigger("iconpickerSelected",{iconpickerItem:a,iconpickerValue:c.iconpickerValue}),c.isInline()||c.hide()}),this.getCancelButton().on("click.iconpicker",function(){c.isInline()||c.hide()}),this.element.on("focus.iconpicker",function(a){c.show(),a.stopPropagation()}),this.hasComponent()&&this.component.on("click.iconpicker",function(){c.toggle()}),this.hasInput()&&this.input.on("keyup.iconpicker",function(a){b.inArray(a.keyCode,[38,40,37,39,16,17,18,9,8,91,93,20,46,186,190,46,78,188,44,86])?c._updateFormGroupStatus(c.getValid(this.value)!==!1):c.update()})},_bindWindowEvents:function(){var b=a(window.document),c=this,d=".iconpicker.inst"+this._id;return a(window).on("resize.iconpicker"+d+" orientationchange.iconpicker"+d,function(){c.popover.hasClass("in")&&c.updatePlacement()}),c.isInline()||b.on("mouseup"+d,function(a){return c._isEventInsideIconpicker(a)||c.isInline()||c.hide(),a.stopPropagation(),a.preventDefault(),!1}),!1},_unbindElementEvents:function(){this.popover.off(".iconpicker"),this.element.off(".iconpicker"),this.hasInput()&&this.input.off(".iconpicker"),this.hasComponent()&&this.component.off(".iconpicker"),this.hasContainer()&&this.container.off(".iconpicker")},_unbindWindowEvents:function(){a(window).off(".iconpicker.inst"+this._id),a(window.document).off(".iconpicker.inst"+this._id)},updatePlacement:function(b,c){b=b||this.options.placement,this.options.placement=b,c=c||this.options.collision,c=c===!0?"flip":c;var d={at:"right bottom",my:"right top",of:this.hasInput()?this.input:this.container,collision:c===!0?"flip":c,within:window};if(this.popover.removeClass("inline topLeftCorner topLeft top topRight topRightCorner rightTop right rightBottom bottomRight bottomRightCorner bottom bottomLeft bottomLeftCorner leftBottom left leftTop"),"object"==typeof b)return this.popover.pos(a.extend({},d,b));switch(b){case"inline":d=!1;break;case"topLeftCorner":d.my="right bottom",d.at="left top";break;case"topLeft":d.my="left bottom",d.at="left top";break;case"top":d.my="center bottom",d.at="center top";break;case"topRight":d.my="right bottom",d.at="right top";break;case"topRightCorner":d.my="left bottom",d.at="right top";break;case"rightTop":d.my="left bottom",d.at="right center";break;case"right":d.my="left center",d.at="right center";break;case"rightBottom":d.my="left top",d.at="right center";break;case"bottomRightCorner":d.my="left top",d.at="right bottom";break;case"bottomRight":d.my="right top",d.at="right bottom";break;case"bottom":d.my="center top",d.at="center bottom";break;case"bottomLeft":d.my="left top",d.at="left bottom";break;case"bottomLeftCorner":d.my="right top",d.at="left bottom";break;case"leftBottom":d.my="right top",d.at="left center";break;case"left":d.my="right center",d.at="left center";break;case"leftTop":d.my="right bottom",d.at="left center";break;default:return!1}return this.popover.css({display:"inline"===this.options.placement?"":"block"}),d!==!1?this.popover.pos(d).css("maxWidth",a(window).width()-this.container.offset().left-5):this.popover.css({top:"auto",right:"auto",bottom:"auto",left:"auto",maxWidth:"none"}),this.popover.addClass(this.options.placement),!0},_updateComponents:function(){if(this.iconpicker.find(".iconpicker-item.iconpicker-selected").removeClass("iconpicker-selected "+this.options.selectedCustomClass),this.iconpicker.find("."+this.options.iconBaseClass+"."+this.options.iconClassPrefix+this.iconpickerValue).parent().addClass("iconpicker-selected "+this.options.selectedCustomClass),this.hasComponent()){var a=this.component.find("i");a.length>0?a.attr("class",this.options.iconComponentBaseClass+" "+this.getValue()):this.component.html(this.getValueHtml())}},_updateFormGroupStatus:function(a){return this.hasInput()?(a!==!1?this.input.parents(".form-group:first").removeClass("has-error"):this.input.parents(".form-group:first").addClass("has-error"),!0):!1},getValid:function(c){b.isString(c)||(c="");var d=""===c;return c=a.trim(c.replace(this.options.iconClassPrefix,"")),b.inArray(c,this.options.icons)||d?c:!1},setValue:function(a){var b=this.getValid(a);return b!==!1?(this.iconpickerValue=b,this._trigger("iconpickerSetValue",{iconpickerValue:b}),this.iconpickerValue):(this._trigger("iconpickerInvalid",{iconpickerValue:a}),!1)},getValue:function(a){return this.options.iconClassPrefix+(a?a:this.iconpickerValue)},getValueHtml:function(){return'<i class="'+this.options.iconBaseClass+" "+this.getValue()+'"></i>'},setSourceValue:function(a){return a=this.setValue(a),a!==!1&&""!==a&&(this.hasInput()?this.input.val(this.getValue()):this.element.data("iconpickerValue",this.getValue()),this._trigger("iconpickerSetSourceValue",{iconpickerValue:a})),a},getSourceValue:function(a){a=a||this.options.defaultValue;var b=a;return b=this.hasInput()?this.input.val():this.element.data("iconpickerValue"),(void 0===b||""===b||null===b||b===!1)&&(b=a),b},hasInput:function(){return this.input!==!1},hasComponent:function(){return this.component!==!1},hasContainer:function(){return this.container!==!1},getAcceptButton:function(){return this.popover.find(".iconpicker-btn-accept")},getCancelButton:function(){return this.popover.find(".iconpicker-btn-cancel")},getSearchInput:function(){return this.popover.find(".iconpicker-search")},filter:function(c){if(b.isEmpty(c))return this.iconpicker.find(".iconpicker-item").show(),a(!1);var d=[];return this.iconpicker.find(".iconpicker-item").each(function(){var b=a(this),e=b.attr("title").toLowerCase(),f=!1;try{f=new RegExp(c,"g")}catch(g){f=!1}f!==!1&&e.match(f)?(d.push(b),b.show()):b.hide()}),d},show:function(){return this.popover.hasClass("in")?!1:(a.iconpicker.batch(a(".iconpicker-popover.in:not(.inline)").not(this.popover),"hide"),this._trigger("iconpickerShow"),this.updatePlacement(),this.popover.addClass("in"),void setTimeout(a.proxy(function(){this.popover.css("display",this.isInline()?"":"block"),this._trigger("iconpickerShown")},this),this.options.animation?300:1))},hide:function(){return this.popover.hasClass("in")?(this._trigger("iconpickerHide"),this.popover.removeClass("in"),void setTimeout(a.proxy(function(){this.popover.css("display","none"),this.getSearchInput().val(""),this.filter(""),this._trigger("iconpickerHidden")},this),this.options.animation?300:1)):!1},toggle:function(){this.popover.is(":visible")?this.hide():this.show(!0)},update:function(a,b){return a=a?a:this.getSourceValue(this.iconpickerValue),this._trigger("iconpickerUpdate"),b===!0?a=this.setValue(a):(a=this.setSourceValue(a),this._updateFormGroupStatus(a!==!1)),a!==!1&&this._updateComponents(),this._trigger("iconpickerUpdated"),a},destroy:function(){this._trigger("iconpickerDestroy"),this.element.removeData("iconpicker").removeData("iconpickerValue").removeClass("iconpicker-element"),this._unbindElementEvents(),this._unbindWindowEvents(),a(this.popover).remove(),this._trigger("iconpickerDestroyed")},disable:function(){return this.hasInput()?(this.input.prop("disabled",!0),!0):!1},enable:function(){return this.hasInput()?(this.input.prop("disabled",!1),!0):!1},isDisabled:function(){return this.hasInput()?this.input.prop("disabled")===!0:!1},isInline:function(){return"inline"===this.options.placement||this.popover.hasClass("inline")}},a.iconpicker=c,a.fn.iconpicker=function(b){return this.each(function(){var d=a(this);d.data("iconpicker")||d.data("iconpicker",new c(this,"object"==typeof b?b:{}))})},c.defaultOptions.icons=["adjust","adn","align-center","align-justify","align-left","align-right","ambulance","anchor","android","angle-double-down","angle-double-left","angle-double-right","angle-double-up","angle-down","angle-left","angle-right","angle-up","apple","archive","arrow-circle-down","arrow-circle-left","arrow-circle-o-down","arrow-circle-o-left","arrow-circle-o-right","arrow-circle-o-up","arrow-circle-right","arrow-circle-up","arrow-down","arrow-left","arrow-right","arrow-up","arrows","arrows-alt","arrows-h","arrows-v","asterisk","automobile","backward","ban","bank","bar-chart-o","barcode","bars","beer","behance","behance-square","bell","bell-o","bitbucket","bitbucket-square","bitcoin","bold","bolt","bomb","book","bookmark","bookmark-o","briefcase","btc","bug","building","building-o","bullhorn","bullseye","cab","calendar","calendar-o","camera","camera-retro","car","caret-down","caret-left","caret-right","caret-square-o-down","caret-square-o-left","caret-square-o-right","caret-square-o-up","caret-up","certificate","chain","chain-broken","check","check-circle","check-circle-o","check-square","check-square-o","chevron-circle-down","chevron-circle-left","chevron-circle-right","chevron-circle-up","chevron-down","chevron-left","chevron-right","chevron-up","child","circle","circle-o","circle-o-notch","circle-thin","clipboard","clock-o","cloud","cloud-download","cloud-upload","cny","code","code-fork","codepen","coffee","cog","cogs","columns","comment","comment-o","comments","comments-o","compass","compress","copy","credit-card","crop","crosshairs","css3","cube","cubes","cut","cutlery","dashboard","database","dedent","delicious","desktop","deviantart","digg","dollar","dot-circle-o","download","dribbble","dropbox","drupal","edit","eject","ellipsis-h","ellipsis-v","empire","envelope","envelope-o","envelope-square","eraser","eur","euro","exchange","exclamation","exclamation-circle","exclamation-triangle","expand","external-link","external-link-square","eye","eye-slash","facebook","facebook-square","fast-backward","fast-forward","fax","female","fighter-jet","file","file-archive-o","file-audio-o","file-code-o","file-excel-o","file-image-o","file-movie-o","file-o","file-pdf-o","file-photo-o","file-picture-o","file-powerpoint-o","file-sound-o","file-text","file-text-o","file-video-o","file-word-o","file-zip-o","files-o","film","filter","fire","fire-extinguisher","flag","flag-checkered","flag-o","flash","flask","flickr","floppy-o","folder","folder-o","folder-open","folder-open-o","font","forward","foursquare","frown-o","gamepad","gavel","gbp","ge","gear","gears","gift","git","git-square","github","github-alt","github-square","gittip","glass","globe","google","google-plus","google-plus-square","graduation-cap","group","h-square","hacker-news","hand-o-down","hand-o-left","hand-o-right","hand-o-up","hdd-o","header","headphones","heart","heart-o","history","home","hospital-o","html5","image","inbox","indent","info","info-circle","inr","instagram","institution","italic","joomla","jpy","jsfiddle","key","keyboard-o","krw","language","laptop","leaf","legal","lemon-o","level-down","level-up","life-bouy","life-ring","life-saver","lightbulb-o","link","linkedin","linkedin-square","linux","list","list-alt","list-ol","list-ul","location-arrow","lock","long-arrow-down","long-arrow-left","long-arrow-right","long-arrow-up","magic","magnet","mail-forward","mail-reply","mail-reply-all","male","map-marker","maxcdn","medkit","meh-o","microphone","microphone-slash","minus","minus-circle","minus-square","minus-square-o","mobile","mobile-phone","money","moon-o","mortar-board","music","navicon","openid","outdent","pagelines","paper-plane","paper-plane-o","paperclip","paragraph","paste","pause","paw","pencil","pencil-square","pencil-square-o","phone","phone-square","photo","picture-o","pied-piper","pied-piper-alt","pied-piper-square","pinterest","pinterest-square","plane","play","play-circle","play-circle-o","plus","plus-circle","plus-square","plus-square-o","power-off","print","puzzle-piece","qq","qrcode","question","question-circle","quote-left","quote-right","ra","random","rebel","recycle","reddit","reddit-square","refresh","renren","reorder","repeat","reply","reply-all","retweet","rmb","road","rocket","rotate-left","rotate-right","rouble","rss","rss-square","rub","ruble","rupee","save","scissors","search","search-minus","search-plus","send","send-o","share","share-alt","share-alt-square","share-square","share-square-o","shield","shopping-cart","sign-in","sign-out","signal","sitemap","skype","slack","sliders","smile-o","sort","sort-alpha-asc","sort-alpha-desc","sort-amount-asc","sort-amount-desc","sort-asc","sort-desc","sort-down","sort-numeric-asc","sort-numeric-desc","sort-up","soundcloud","space-shuttle","spinner","spoon","spotify","square","square-o","stack-exchange","stack-overflow","star","star-half","star-half-empty","star-half-full","star-half-o","star-o","steam","steam-square","step-backward","step-forward","stethoscope","stop","strikethrough","stumbleupon","stumbleupon-circle","subscript","suitcase","sun-o","superscript","support","table","tablet","tachometer","tag","tags","tasks","taxi","tencent-weibo","terminal","text-height","text-width","th","th-large","th-list","thumb-tack","thumbs-down","thumbs-o-down","thumbs-o-up","thumbs-up","ticket","times","times-circle","times-circle-o","tint","toggle-down","toggle-left","toggle-right","toggle-up","trash-o","tree","trello","trophy","truck","try","tumblr","tumblr-square","turkish-lira","twitter","twitter-square","umbrella","underline","undo","university","unlink","unlock","unlock-alt","unsorted","upload","usd","user","user-md","users","video-camera","vimeo-square","vine","vk","volume-down","volume-off","volume-up","warning","wechat","weibo","weixin","wheelchair","windows","won","wordpress","wrench","xing","xing-square","yahoo","yen","youtube","youtube-play","youtube-square"]});
|
1 |
+
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):window.jQuery&&!window.jQuery.fn.iconpicker&&t(window.jQuery)}(function(t){"use strict";var e={isEmpty:function(t){return t===!1||""===t||null===t||void 0===t},isEmptyObject:function(t){return this.isEmpty(t)===!0||0===t.length},isElement:function(e){return t(e).length>0},isString:function(t){return"string"==typeof t||t instanceof String},isArray:function(e){return t.isArray(e)},inArray:function(e,a){return-1!==t.inArray(e,a)},throwError:function(t){throw"Font Awesome Icon Picker Exception: "+t}},a=function(i,o){this._id=a._idCounter++,this.element=t(i).addClass("iconpicker-element"),this._trigger("iconpickerCreate"),this.options=t.extend({},a.defaultOptions,this.element.data(),o),this.options.templates=t.extend({},a.defaultOptions.templates,this.options.templates),this.options.originalPlacement=this.options.placement,this.container=e.isElement(this.options.container)?t(this.options.container):!1,this.container===!1&&(this.container=this.element.is(".dropdown-toggle")?t("~ .dropdown-menu:first",this.element):this.element.is("input,textarea,button,.btn")?this.element.parent():this.element),this.container.addClass("iconpicker-container"),this.isDropdownMenu()&&(this.options.templates.search=!1,this.options.templates.buttons=!1,this.options.placement="inline"),this.input=this.element.is("input,textarea")?this.element.addClass("iconpicker-input"):!1,this.input===!1&&(this.input=this.container.find(this.options.input),this.input.is("input,textarea")||(this.input=!1)),this.component=this.isDropdownMenu()?this.container.parent().find(this.options.component):this.container.find(this.options.component),0===this.component.length?this.component=!1:this.component.find("i").addClass("iconpicker-component"),this._createPopover(),this._createIconpicker(),0===this.getAcceptButton().length&&(this.options.mustAccept=!1),this.isInputGroup()?this.container.parent().append(this.popover):this.container.append(this.popover),this._bindElementEvents(),this._bindWindowEvents(),this.update(this.options.selected),this.isInline()&&this.show(),this._trigger("iconpickerCreated")};a._idCounter=0,a.defaultOptions={title:!1,selected:!1,defaultValue:!1,placement:"bottom",collision:"none",animation:!0,hideOnSelect:!1,showFooter:!1,searchInFooter:!1,mustAccept:!1,selectedCustomClass:"bg-primary",icons:[],iconBaseClass:"fa",iconClassPrefix:"fa-",fullClassFormatter:function(t){return"fa "+t},input:"input,.iconpicker-input",inputSearch:!1,container:!1,component:".input-group-addon,.iconpicker-component",templates:{popover:'<div class="iconpicker-popover popover"><div class="arrow"></div><div class="popover-title"></div><div class="popover-content"></div></div>',footer:'<div class="popover-footer"></div>',buttons:'<button class="iconpicker-btn iconpicker-btn-cancel btn btn-default btn-sm">Cancel</button> <button class="iconpicker-btn iconpicker-btn-accept btn btn-primary btn-sm">Accept</button>',search:'<input type="search" class="form-control iconpicker-search" placeholder="Type to filter" />',iconpicker:'<div class="iconpicker"><div class="iconpicker-items"></div></div>',iconpickerItem:'<a role="button" href="#" class="iconpicker-item"><i></i></a>'}},a.batch=function(e,a){var i=Array.prototype.slice.call(arguments,2);return t(e).each(function(){var e=t(this).data("iconpicker");e&&e[a].apply(e,i)})},a.prototype={constructor:a,options:{},_id:0,_trigger:function(e,a){a=a||{},this.element.trigger(t.extend({type:e,iconpickerInstance:this},a))},_createPopover:function(){this.popover=t(this.options.templates.popover);var a=this.popover.find(".popover-title");if(this.options.title&&a.append(t('<div class="popover-title-text">'+this.options.title+"</div>")),this.hasSeparatedSearchInput()&&!this.options.searchInFooter?a.append(this.options.templates.search):this.options.title||a.remove(),this.options.showFooter&&!e.isEmpty(this.options.templates.footer)){var i=t(this.options.templates.footer);this.hasSeparatedSearchInput()&&this.options.searchInFooter&&i.append(t(this.options.templates.search)),e.isEmpty(this.options.templates.buttons)||i.append(t(this.options.templates.buttons)),this.popover.append(i)}return this.options.animation===!0&&this.popover.addClass("fade"),this.popover},_createIconpicker:function(){var e=this;this.iconpicker=t(this.options.templates.iconpicker);var a=function(a){var i=t(this);return i.is("i")&&(i=i.parent()),e._trigger("iconpickerSelect",{iconpickerItem:i,iconpickerValue:e.iconpickerValue}),e.options.mustAccept===!1?(e.update(i.data("iconpickerValue")),e._trigger("iconpickerSelected",{iconpickerItem:this,iconpickerValue:e.iconpickerValue})):e.update(i.data("iconpickerValue"),!0),e.options.hideOnSelect&&e.options.mustAccept===!1&&e.hide(),a.preventDefault(),!1};for(var i in this.options.icons){var o=t(this.options.templates.iconpickerItem);o.find("i").addClass(this.options.iconBaseClass+" "+this.options.iconClassPrefix+this.options.icons[i]),o.data("iconpickerValue",this.options.icons[i]).on("click.iconpicker",a),this.iconpicker.find(".iconpicker-items").append(o.attr("title","."+this.options.iconClassPrefix+this.options.icons[i]))}return this.popover.find(".popover-content").append(this.iconpicker),this.component.append('<i class="'+this.options.iconBaseClass+" "+this.input.val()+'"></i>'),this.iconpicker},_isEventInsideIconpicker:function(e){var a=t(e.target);return a.hasClass("iconpicker-element")&&(!a.hasClass("iconpicker-element")||a.is(this.element))||0!==a.parents(".iconpicker-popover").length?!0:!1},_bindElementEvents:function(){var a=this;this.getSearchInput().on("keyup.iconpicker",function(){a.filter(t(this).val().toLowerCase())}),this.getAcceptButton().on("click.iconpicker",function(){var t=a.iconpicker.find(".iconpicker-selected").get(0);a.update(a.iconpickerValue),a._trigger("iconpickerSelected",{iconpickerItem:t,iconpickerValue:a.iconpickerValue}),a.isInline()||a.hide()}),this.getCancelButton().on("click.iconpicker",function(){a.isInline()||a.hide()}),this.element.on("focus.iconpicker",function(t){a.show(),t.stopPropagation()}),this.hasComponent()&&this.component.on("click.iconpicker",function(){a.toggle()}),this.hasInput()&&this.input.on("keyup.iconpicker",function(i){e.inArray(i.keyCode,[38,40,37,39,16,17,18,9,8,91,93,20,46,186,190,46,78,188,44,86])?a._updateFormGroupStatus(a.getValid(this.value)!==!1):a.update(),a.options.inputSearch===!0&&a.filter(t(this).val().toLowerCase())})},_bindWindowEvents:function(){var e=t(window.document),a=this,i=".iconpicker.inst"+this._id;return t(window).on("resize.iconpicker"+i+" orientationchange.iconpicker"+i,function(){a.popover.hasClass("in")&&a.updatePlacement()}),a.isInline()||e.on("mouseup"+i,function(t){a._isEventInsideIconpicker(t)||a.isInline()||a.hide()}),!1},_unbindElementEvents:function(){this.popover.off(".iconpicker"),this.element.off(".iconpicker"),this.hasInput()&&this.input.off(".iconpicker"),this.hasComponent()&&this.component.off(".iconpicker"),this.hasContainer()&&this.container.off(".iconpicker")},_unbindWindowEvents:function(){t(window).off(".iconpicker.inst"+this._id),t(window.document).off(".iconpicker.inst"+this._id)},updatePlacement:function(e,a){e=e||this.options.placement,this.options.placement=e,a=a||this.options.collision,a=a===!0?"flip":a;var i={at:"right bottom",my:"right top",of:this.hasInput()&&!this.isInputGroup()?this.input:this.container,collision:a===!0?"flip":a,within:window};if(this.popover.removeClass("inline topLeftCorner topLeft top topRight topRightCorner rightTop right rightBottom bottomRight bottomRightCorner bottom bottomLeft bottomLeftCorner leftBottom left leftTop"),"object"==typeof e)return this.popover.pos(t.extend({},i,e));switch(e){case"inline":i=!1;break;case"topLeftCorner":i.my="right bottom",i.at="left top";break;case"topLeft":i.my="left bottom",i.at="left top";break;case"top":i.my="center bottom",i.at="center top";break;case"topRight":i.my="right bottom",i.at="right top";break;case"topRightCorner":i.my="left bottom",i.at="right top";break;case"rightTop":i.my="left bottom",i.at="right center";break;case"right":i.my="left center",i.at="right center";break;case"rightBottom":i.my="left top",i.at="right center";break;case"bottomRightCorner":i.my="left top",i.at="right bottom";break;case"bottomRight":i.my="right top",i.at="right bottom";break;case"bottom":i.my="center top",i.at="center bottom";break;case"bottomLeft":i.my="left top",i.at="left bottom";break;case"bottomLeftCorner":i.my="right top",i.at="left bottom";break;case"leftBottom":i.my="right top",i.at="left center";break;case"left":i.my="right center",i.at="left center";break;case"leftTop":i.my="right bottom",i.at="left center";break;default:return!1}return this.popover.css({display:"inline"===this.options.placement?"":"block"}),i!==!1?this.popover.pos(i).css("maxWidth",t(window).width()-this.container.offset().left-5):this.popover.css({top:"auto",right:"auto",bottom:"auto",left:"auto",maxWidth:"none"}),this.popover.addClass(this.options.placement),!0},_updateComponents:function(){if(this.iconpicker.find(".iconpicker-item.iconpicker-selected").removeClass("iconpicker-selected "+this.options.selectedCustomClass),this.iconpickerValue&&this.iconpicker.find("."+this.options.fullClassFormatter(this.iconpickerValue).replace(/ /g,".")).parent().addClass("iconpicker-selected "+this.options.selectedCustomClass),this.hasComponent()){var t=this.component.find("i");t.length>0?t.attr("class",this.options.fullClassFormatter(this.iconpickerValue)):this.component.html(this.getHtml())}},_updateFormGroupStatus:function(t){return this.hasInput()?(t!==!1?this.input.parents(".form-group:first").removeClass("has-error"):this.input.parents(".form-group:first").addClass("has-error"),!0):!1},getValid:function(a){e.isString(a)||(a="");var i=""===a;return a=t.trim(a),e.inArray(a,this.options.icons)||i?a:!1},setValue:function(t){var e=this.getValid(t);return e!==!1?(this.iconpickerValue=e,this._trigger("iconpickerSetValue",{iconpickerValue:e}),this.iconpickerValue):(this._trigger("iconpickerInvalid",{iconpickerValue:t}),!1)},getHtml:function(){return'<i class="'+this.options.fullClassFormatter(this.iconpickerValue)+'"></i>'},setSourceValue:function(t){return t=this.setValue(t),t!==!1&&""!==t&&(this.hasInput()?this.input.val(this.options.iconClassPrefix+this.iconpickerValue):this.element.data("iconpickerValue",this.iconpickerValue),this._trigger("iconpickerSetSourceValue",{iconpickerValue:t})),t},getSourceValue:function(t){t=t||this.options.defaultValue;var e=t;return e=this.hasInput()?this.input.val():this.element.data("iconpickerValue"),(void 0===e||""===e||null===e||e===!1)&&(e=t),e},hasInput:function(){return this.input!==!1},isInputSearch:function(){return this.hasInput()&&this.options.inputSearch===!0},isInputGroup:function(){return this.container.is(".input-group")},isDropdownMenu:function(){return this.container.is(".dropdown-menu")},hasSeparatedSearchInput:function(){return this.options.templates.search!==!1&&!this.isInputSearch()},hasComponent:function(){return this.component!==!1},hasContainer:function(){return this.container!==!1},getAcceptButton:function(){return this.popover.find(".iconpicker-btn-accept")},getCancelButton:function(){return this.popover.find(".iconpicker-btn-cancel")},getSearchInput:function(){return this.popover.find(".iconpicker-search")},filter:function(a){if(e.isEmpty(a))return this.iconpicker.find(".iconpicker-item").show(),t(!1);var i=[];return this.iconpicker.find(".iconpicker-item").each(function(){var e=t(this),o=e.attr("title").toLowerCase(),n=!1;try{n=new RegExp(a,"g")}catch(r){n=!1}n!==!1&&o.match(n)?(i.push(e),e.show()):e.hide()}),i},show:function(){return this.popover.hasClass("in")?!1:(t.iconpicker.batch(t(".iconpicker-popover.in:not(.inline)").not(this.popover),"hide"),this._trigger("iconpickerShow"),this.updatePlacement(),this.popover.addClass("in"),void setTimeout(t.proxy(function(){this.popover.css("display",this.isInline()?"":"block"),this._trigger("iconpickerShown")},this),this.options.animation?300:1))},hide:function(){return this.popover.hasClass("in")?(this._trigger("iconpickerHide"),this.popover.removeClass("in"),void setTimeout(t.proxy(function(){this.popover.css("display","none"),this.getSearchInput().val(""),this.filter(""),this._trigger("iconpickerHidden")},this),this.options.animation?300:1)):!1},toggle:function(){this.popover.is(":visible")?this.hide():this.show(!0)},update:function(t,e){return t=t?t:this.getSourceValue(this.iconpickerValue),this._trigger("iconpickerUpdate"),e===!0?t=this.setValue(t):(t=this.setSourceValue(t),this._updateFormGroupStatus(t!==!1)),t!==!1&&this._updateComponents(),this._trigger("iconpickerUpdated"),t},destroy:function(){this._trigger("iconpickerDestroy"),this.element.removeData("iconpicker").removeData("iconpickerValue").removeClass("iconpicker-element"),this._unbindElementEvents(),this._unbindWindowEvents(),t(this.popover).remove(),this._trigger("iconpickerDestroyed")},disable:function(){return this.hasInput()?(this.input.prop("disabled",!0),!0):!1},enable:function(){return this.hasInput()?(this.input.prop("disabled",!1),!0):!1},isDisabled:function(){return this.hasInput()?this.input.prop("disabled")===!0:!1},isInline:function(){return"inline"===this.options.placement||this.popover.hasClass("inline")}},t.iconpicker=a,t.fn.iconpicker=function(e){return this.each(function(){var i=t(this);i.data("iconpicker")||i.data("iconpicker",new a(this,"object"==typeof e?e:{}))})},a.defaultOptions.icons=["fa-500px","fa-adjust","fa-adn","fa-align-center","fa-align-justify","fa-align-left","fa-align-right","fa-amazon","fa-ambulance","fa-anchor","fa-android","fa-angellist","fa-angle-double-down","fa-angle-double-left","fa-angle-double-right","fa-angle-double-up","fa-angle-down","fa-angle-left","fa-angle-right","fa-angle-up","fa-apple","fa-archive","fa-area-chart","fa-arrow-circle-down","fa-arrow-circle-left","fa-arrow-circle-o-down","fa-arrow-circle-o-left","fa-arrow-circle-o-right","fa-arrow-circle-o-up","fa-arrow-circle-right","fa-arrow-circle-up","fa-arrow-down","fa-arrow-left","fa-arrow-right","fa-arrow-up","fa-arrows","fa-arrows-alt","fa-arrows-h","fa-arrows-v","fa-asterisk","fa-at","fa-automobile","fa-backward","fa-balance-scale","fa-ban","fa-bank","fa-bar-chart","fa-bar-chart-o","fa-barcode","fa-bars","fa-battery-0","fa-battery-1","fa-battery-2","fa-battery-3","fa-battery-4","fa-battery-empty","fa-battery-full","fa-battery-half","fa-battery-quarter","fa-battery-three-quarters","fa-bed","fa-beer","fa-behance","fa-behance-square","fa-bell","fa-bell-o","fa-bell-slash","fa-bell-slash-o","fa-bicycle","fa-binoculars","fa-birthday-cake","fa-bitbucket","fa-bitbucket-square","fa-bitcoin","fa-black-tie","fa-bold","fa-bolt","fa-bomb","fa-book","fa-bookmark","fa-bookmark-o","fa-briefcase","fa-btc","fa-bug","fa-building","fa-building-o","fa-bullhorn","fa-bullseye","fa-bus","fa-buysellads","fa-cab","fa-calculator","fa-calendar","fa-calendar-check-o","fa-calendar-minus-o","fa-calendar-o","fa-calendar-plus-o","fa-calendar-times-o","fa-camera","fa-camera-retro","fa-car","fa-caret-down","fa-caret-left","fa-caret-right","fa-caret-square-o-down","fa-caret-square-o-left","fa-caret-square-o-right","fa-caret-square-o-up","fa-caret-up","fa-cart-arrow-down","fa-cart-plus","fa-cc","fa-cc-amex","fa-cc-diners-club","fa-cc-discover","fa-cc-jcb","fa-cc-mastercard","fa-cc-paypal","fa-cc-stripe","fa-cc-visa","fa-certificate","fa-chain","fa-chain-broken","fa-check","fa-check-circle","fa-check-circle-o","fa-check-square","fa-check-square-o","fa-chevron-circle-down","fa-chevron-circle-left","fa-chevron-circle-right","fa-chevron-circle-up","fa-chevron-down","fa-chevron-left","fa-chevron-right","fa-chevron-up","fa-child","fa-chrome","fa-circle","fa-circle-o","fa-circle-o-notch","fa-circle-thin","fa-clipboard","fa-clock-o","fa-clone","fa-close","fa-cloud","fa-cloud-download","fa-cloud-upload","fa-cny","fa-code","fa-code-fork","fa-codepen","fa-coffee","fa-cog","fa-cogs","fa-columns","fa-comment","fa-comment-o","fa-commenting","fa-commenting-o","fa-comments","fa-comments-o","fa-compass","fa-compress","fa-connectdevelop","fa-contao","fa-copy","fa-copyright","fa-creative-commons","fa-credit-card","fa-crop","fa-crosshairs","fa-css3","fa-cube","fa-cubes","fa-cut","fa-cutlery","fa-dashboard","fa-dashcube","fa-database","fa-dedent","fa-delicious","fa-desktop","fa-deviantart","fa-diamond","fa-digg","fa-dollar","fa-dot-circle-o","fa-download","fa-dribbble","fa-dropbox","fa-drupal","fa-edit","fa-eject","fa-ellipsis-h","fa-ellipsis-v","fa-empire","fa-envelope","fa-envelope-o","fa-envelope-square","fa-eraser","fa-eur","fa-euro","fa-exchange","fa-exclamation","fa-exclamation-circle","fa-exclamation-triangle","fa-expand","fa-expeditedssl","fa-external-link","fa-external-link-square","fa-eye","fa-eye-slash","fa-eyedropper","fa-facebook","fa-facebook-f","fa-facebook-official","fa-facebook-square","fa-fast-backward","fa-fast-forward","fa-fax","fa-feed","fa-female","fa-fighter-jet","fa-file","fa-file-archive-o","fa-file-audio-o","fa-file-code-o","fa-file-excel-o","fa-file-image-o","fa-file-movie-o","fa-file-o","fa-file-pdf-o","fa-file-photo-o","fa-file-picture-o","fa-file-powerpoint-o","fa-file-sound-o","fa-file-text","fa-file-text-o","fa-file-video-o","fa-file-word-o","fa-file-zip-o","fa-files-o","fa-film","fa-filter","fa-fire","fa-fire-extinguisher","fa-firefox","fa-flag","fa-flag-checkered","fa-flag-o","fa-flash","fa-flask","fa-flickr","fa-floppy-o","fa-folder","fa-folder-o","fa-folder-open","fa-folder-open-o","fa-font","fa-fonticons","fa-forumbee","fa-forward","fa-foursquare","fa-frown-o","fa-futbol-o","fa-gamepad","fa-gavel","fa-gbp","fa-ge","fa-gear","fa-gears","fa-genderless","fa-get-pocket","fa-gg","fa-gg-circle","fa-gift","fa-git","fa-git-square","fa-github","fa-github-alt","fa-github-square","fa-gittip","fa-glass","fa-globe","fa-google","fa-google-plus","fa-google-plus-square","fa-google-wallet","fa-graduation-cap","fa-gratipay","fa-group","fa-h-square","fa-hacker-news","fa-hand-grab-o","fa-hand-lizard-o","fa-hand-o-down","fa-hand-o-left","fa-hand-o-right","fa-hand-o-up","fa-hand-paper-o","fa-hand-peace-o","fa-hand-pointer-o","fa-hand-scissors-o","fa-hand-spock-o","fa-hand-stop-o","fa-hdd-o","fa-header","fa-headphones","fa-heart","fa-heart-o","fa-heartbeat","fa-history","fa-home","fa-hospital-o","fa-hotel","fa-hourglass","fa-hourglass-1","fa-hourglass-2","fa-hourglass-3","fa-hourglass-end","fa-hourglass-half","fa-hourglass-o","fa-hourglass-start","fa-houzz","fa-html5","fa-i-cursor","fa-ils","fa-image","fa-inbox","fa-indent","fa-industry","fa-info","fa-info-circle","fa-inr","fa-instagram","fa-institution","fa-internet-explorer","fa-intersex","fa-ioxhost","fa-italic","fa-joomla","fa-jpy","fa-jsfiddle","fa-key","fa-keyboard-o","fa-krw","fa-language","fa-laptop","fa-lastfm","fa-lastfm-square","fa-leaf","fa-leanpub","fa-legal","fa-lemon-o","fa-level-down","fa-level-up","fa-life-bouy","fa-life-buoy","fa-life-ring","fa-life-saver","fa-lightbulb-o","fa-line-chart","fa-link","fa-linkedin","fa-linkedin-square","fa-linux","fa-list","fa-list-alt","fa-list-ol","fa-list-ul","fa-location-arrow","fa-lock","fa-long-arrow-down","fa-long-arrow-left","fa-long-arrow-right","fa-long-arrow-up","fa-magic","fa-magnet","fa-mail-forward","fa-mail-reply","fa-mail-reply-all","fa-male","fa-map","fa-map-marker","fa-map-o","fa-map-pin","fa-map-signs","fa-mars-double","fa-mars-stroke","fa-mars-stroke-h","fa-mars-stroke-v","fa-maxcdn","fa-meanpath","fa-medium","fa-medkit","fa-mercury","fa-microphone","fa-microphone-slash","fa-minus","fa-minus-circle","fa-minus-square","fa-minus-square-o","fa-mobile","fa-mobile-phone","fa-money","fa-moon-o","fa-mortar-board","fa-motorcycle","fa-mouse-pointer","fa-music","fa-navicon","fa-neuter","fa-newspaper-o","fa-object-group","fa-object-ungroup","fa-odnoklassniki","fa-odnoklassniki-square","fa-opencart","fa-openid","fa-opera","fa-optin-monster","fa-outdent","fa-pagelines","fa-paint-brush","fa-paper-plane","fa-paper-plane-o","fa-paperclip","fa-paragraph","fa-paste","fa-pause","fa-paw","fa-paypal","fa-pencil","fa-pencil-square","fa-pencil-square-o","fa-phone","fa-phone-square","fa-photo","fa-picture-o","fa-pie-chart","fa-pied-piper","fa-pied-piper-alt","fa-pinterest","fa-pinterest-p","fa-pinterest-square","fa-plane","fa-play","fa-play-circle","fa-play-circle-o","fa-plug","fa-plus","fa-plus-circle","fa-plus-square","fa-plus-square-o","fa-power-off","fa-print","fa-puzzle-piece","fa-qq","fa-qrcode","fa-question","fa-question-circle","fa-quote-left","fa-quote-right","fa-ra","fa-random","fa-rebel","fa-recycle","fa-reddit","fa-reddit-square","fa-refresh","fa-registered","fa-remove","fa-renren","fa-reorder","fa-repeat","fa-reply","fa-reply-all","fa-retweet","fa-rmb","fa-road","fa-rocket","fa-rotate-left","fa-rotate-right","fa-rouble","fa-rss","fa-rss-square","fa-rub","fa-ruble","fa-rupee","fa-safari","fa-save","fa-scissors","fa-search","fa-search-minus","fa-search-plus","fa-sellsy","fa-send","fa-send-o","fa-server","fa-share","fa-share-alt","fa-share-alt-square","fa-share-square","fa-share-square-o","fa-shekel","fa-sheqel","fa-shield","fa-ship","fa-shirtsinbulk","fa-shopping-cart","fa-sign-in","fa-sign-out","fa-signal","fa-simplybuilt","fa-sitemap","fa-skyatlas","fa-skype","fa-slack","fa-sliders","fa-slideshare","fa-smile-o","fa-soccer-ball-o","fa-sort","fa-sort-alpha-asc","fa-sort-alpha-desc","fa-sort-amount-asc","fa-sort-amount-desc","fa-sort-asc","fa-sort-desc","fa-sort-down","fa-sort-numeric-asc","fa-sort-numeric-desc","fa-sort-up","fa-soundcloud","fa-space-shuttle","fa-spinner","fa-spoon","fa-spotify","fa-square","fa-square-o","fa-stack-exchange","fa-stack-overflow","fa-steam","fa-steam-square","fa-star","fa-star-half","fa-star-half-empty","fa-star-half-full","fa-star-half-o","fa-star-o","fa-step-backward","fa-step-forward","fa-stethoscope","fa-sticky-note","fa-sticky-note-o","fa-stop","fa-street-view","fa-strikethrough","fa-stumbleupon","fa-stumbleupon-circle","fa-subscript","fa-subway","fa-suitcase","fa-sun-o","fa-superscript","fa-support","fa-table","fa-tablet","fa-tachometer","fa-tag","fa-tags","fa-tasks","fa-taxi","fa-television","fa-tencent-weibo","fa-terminal","fa-text-height","fa-text-width","fa-th","fa-th-large","fa-th-list","fa-thumb-tack","fa-thumbs-down","fa-thumbs-o-down","fa-thumbs-o-up","fa-thumbs-up","fa-ticket","fa-times","fa-times-circle","fa-times-circle-o","fa-tint","fa-toggle-down","fa-toggle-left","fa-toggle-off","fa-toggle-on","fa-toggle-right","fa-toggle-up","fa-trademark","fa-train","fa-transgender","fa-transgender-alt","fa-trash","fa-trash-o","fa-tree","fa-trello","fa-tripadvisor","fa-trophy","fa-truck","fa-try","fa-tty","fa-tumblr","fa-tumblr-square","fa-turkish-lira","fa-tv","fa-twitch","fa-twitter","fa-twitter-square","fa-umbrella","fa-underline","fa-university","fa-unlink","fa-unlock","fa-unlock-alt","fa-unsorted","fa-upload","fa-usd","fa-user","fa-user-md","fa-user-plus","fa-user-secret","fa-user-times","fa-users","fa-venus","fa-venus-double","fa-venus-mars","fa-viacoin","fa-video-camera","fa-vimeo","fa-vimeo-square","fa-vine","fa-vk","fa-volume-down","fa-volume-off","fa-volume-up","fa-warning","fa-wechat","fa-weibo","fa-weixin","fa-whatsapp","fa-wheelchair","fa-wifi","fa-wikipedia-w","fa-windows","fa-won","fa-wordpress","fa-wrench","fa-xing","fa-xing-square","fa-y-combinator","fa-y-combinator-square","fa-yahoo","fa-yc","fa-yc-square","fa-yelp","fa-yen","fa-youtube","fa-youtube-play","fa-youtube-square"]}),function(t,e){function a(t,e,a){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?a/100:1)]}function i(e,a){return parseInt(t.css(e,a),10)||0}function o(e){var a=e[0];return 9===a.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(a)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:a.preventDefault?{width:0,height:0,offset:{top:a.pageY,left:a.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}t.ui=t.ui||{};var n,r=Math.max,s=Math.abs,f=Math.round,c=/left|center|right/,l=/top|center|bottom/,p=/[\+\-]\d+(\.[\d]+)?%?/,h=/^\w+/,u=/%$/,d=t.fn.pos;t.pos={scrollbarWidth:function(){if(n!==e)return n;var a,i,o=t("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),r=o.children()[0];return t("body").append(o),a=r.offsetWidth,o.css("overflow","scroll"),i=r.offsetWidth,a===i&&(i=o[0].clientWidth),o.remove(),n=a-i},getScrollInfo:function(e){var a=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),i=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),o="scroll"===a||"auto"===a&&e.width<e.element[0].scrollWidth,n="scroll"===i||"auto"===i&&e.height<e.element[0].scrollHeight;return{width:n?t.pos.scrollbarWidth():0,height:o?t.pos.scrollbarWidth():0}},getWithinInfo:function(e){var a=t(e||window),i=t.isWindow(a[0]),o=!!a[0]&&9===a[0].nodeType;return{element:a,isWindow:i,isDocument:o,offset:a.offset()||{left:0,top:0},scrollLeft:a.scrollLeft(),scrollTop:a.scrollTop(),width:i?a.width():a.outerWidth(),height:i?a.height():a.outerHeight()}}},t.fn.pos=function(e){if(!e||!e.of)return d.apply(this,arguments);e=t.extend({},e);var n,u,m,g,b,k,v=t(e.of),w=t.pos.getWithinInfo(e.within),y=t.pos.getScrollInfo(w),C=(e.collision||"flip").split(" "),x={};return k=o(v),v[0].preventDefault&&(e.at="left top"),u=k.width,m=k.height,g=k.offset,b=t.extend({},g),t.each(["my","at"],function(){var t,a,i=(e[this]||"").split(" ");1===i.length&&(i=c.test(i[0])?i.concat(["center"]):l.test(i[0])?["center"].concat(i):["center","center"]),i[0]=c.test(i[0])?i[0]:"center",i[1]=l.test(i[1])?i[1]:"center",t=p.exec(i[0]),a=p.exec(i[1]),x[this]=[t?t[0]:0,a?a[0]:0],e[this]=[h.exec(i[0])[0],h.exec(i[1])[0]]}),1===C.length&&(C[1]=C[0]),"right"===e.at[0]?b.left+=u:"center"===e.at[0]&&(b.left+=u/2),"bottom"===e.at[1]?b.top+=m:"center"===e.at[1]&&(b.top+=m/2),n=a(x.at,u,m),b.left+=n[0],b.top+=n[1],this.each(function(){var o,c,l=t(this),p=l.outerWidth(),h=l.outerHeight(),d=i(this,"marginLeft"),k=i(this,"marginTop"),q=p+d+i(this,"marginRight")+y.width,_=h+k+i(this,"marginBottom")+y.height,I=t.extend({},b),W=a(x.my,l.outerWidth(),l.outerHeight());"right"===e.my[0]?I.left-=p:"center"===e.my[0]&&(I.left-=p/2),"bottom"===e.my[1]?I.top-=h:"center"===e.my[1]&&(I.top-=h/2),I.left+=W[0],I.top+=W[1],t.support.offsetFractions||(I.left=f(I.left),I.top=f(I.top)),o={marginLeft:d,marginTop:k},t.each(["left","top"],function(a,i){t.ui.pos[C[a]]&&t.ui.pos[C[a]][i](I,{targetWidth:u,targetHeight:m,elemWidth:p,elemHeight:h,collisionPosition:o,collisionWidth:q,collisionHeight:_,offset:[n[0]+W[0],n[1]+W[1]],my:e.my,at:e.at,within:w,elem:l})}),e.using&&(c=function(t){var a=g.left-I.left,i=a+u-p,o=g.top-I.top,n=o+m-h,f={target:{element:v,left:g.left,top:g.top,width:u,height:m},element:{element:l,left:I.left,top:I.top,width:p,height:h},horizontal:0>i?"left":a>0?"right":"center",vertical:0>n?"top":o>0?"bottom":"middle"};p>u&&s(a+i)<u&&(f.horizontal="center"),h>m&&s(o+n)<m&&(f.vertical="middle"),f.important=r(s(a),s(i))>r(s(o),s(n))?"horizontal":"vertical",e.using.call(this,t,f)}),l.offset(t.extend(I,{using:c}))})},t.ui.pos={_trigger:function(t,e,a,i){e.elem&&e.elem.trigger({type:a,position:t,positionData:e,triggered:i})},fit:{left:function(e,a){t.ui.pos._trigger(e,a,"posCollide","fitLeft");var i,o=a.within,n=o.isWindow?o.scrollLeft:o.offset.left,s=o.width,f=e.left-a.collisionPosition.marginLeft,c=n-f,l=f+a.collisionWidth-s-n;a.collisionWidth>s?c>0&&0>=l?(i=e.left+c+a.collisionWidth-s-n,e.left+=c-i):e.left=l>0&&0>=c?n:c>l?n+s-a.collisionWidth:n:c>0?e.left+=c:l>0?e.left-=l:e.left=r(e.left-f,e.left),t.ui.pos._trigger(e,a,"posCollided","fitLeft")},top:function(e,a){t.ui.pos._trigger(e,a,"posCollide","fitTop");var i,o=a.within,n=o.isWindow?o.scrollTop:o.offset.top,s=a.within.height,f=e.top-a.collisionPosition.marginTop,c=n-f,l=f+a.collisionHeight-s-n;a.collisionHeight>s?c>0&&0>=l?(i=e.top+c+a.collisionHeight-s-n,e.top+=c-i):e.top=l>0&&0>=c?n:c>l?n+s-a.collisionHeight:n:c>0?e.top+=c:l>0?e.top-=l:e.top=r(e.top-f,e.top),t.ui.pos._trigger(e,a,"posCollided","fitTop")}},flip:{left:function(e,a){t.ui.pos._trigger(e,a,"posCollide","flipLeft");var i,o,n=a.within,r=n.offset.left+n.scrollLeft,f=n.width,c=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-a.collisionPosition.marginLeft,p=l-c,h=l+a.collisionWidth-f-c,u="left"===a.my[0]?-a.elemWidth:"right"===a.my[0]?a.elemWidth:0,d="left"===a.at[0]?a.targetWidth:"right"===a.at[0]?-a.targetWidth:0,m=-2*a.offset[0];0>p?(i=e.left+u+d+m+a.collisionWidth-f-r,(0>i||i<s(p))&&(e.left+=u+d+m)):h>0&&(o=e.left-a.collisionPosition.marginLeft+u+d+m-c,(o>0||s(o)<h)&&(e.left+=u+d+m)),t.ui.pos._trigger(e,a,"posCollided","flipLeft")},top:function(e,a){t.ui.pos._trigger(e,a,"posCollide","flipTop");var i,o,n=a.within,r=n.offset.top+n.scrollTop,f=n.height,c=n.isWindow?n.scrollTop:n.offset.top,l=e.top-a.collisionPosition.marginTop,p=l-c,h=l+a.collisionHeight-f-c,u="top"===a.my[1],d=u?-a.elemHeight:"bottom"===a.my[1]?a.elemHeight:0,m="top"===a.at[1]?a.targetHeight:"bottom"===a.at[1]?-a.targetHeight:0,g=-2*a.offset[1];0>p?(o=e.top+d+m+g+a.collisionHeight-f-r,e.top+d+m+g>p&&(0>o||o<s(p))&&(e.top+=d+m+g)):h>0&&(i=e.top-a.collisionPosition.marginTop+d+m+g-c,e.top+d+m+g>h&&(i>0||s(i)<h)&&(e.top+=d+m+g)),t.ui.pos._trigger(e,a,"posCollided","flipTop")}},flipfit:{left:function(){t.ui.pos.flip.left.apply(this,arguments),t.ui.pos.fit.left.apply(this,arguments)},top:function(){t.ui.pos.flip.top.apply(this,arguments),t.ui.pos.fit.top.apply(this,arguments)}}},function(){var e,a,i,o,n,r=document.getElementsByTagName("body")[0],s=document.createElement("div");e=document.createElement(r?"div":"body"),i={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&t.extend(i,{position:"absolute",left:"-1000px",top:"-1000px"});for(n in i)e.style[n]=i[n];e.appendChild(s),a=r||document.documentElement,a.insertBefore(e,a.firstChild),s.style.cssText="position: absolute; left: 10.7432222px;",o=t(s).offset().left,t.support.offsetFractions=o>10&&11>o,e.innerHTML="",a.removeChild(e)}()}(jQuery);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/min/ui-iconpicker.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,i){"use strict";i.utilites.namespace("ui_elements.iconpicker"),i.ui_elements.iconpicker={init:function(){e(window).on("cherry-ui-elements-init",this.render
|
1 |
+
!function(e,i){"use strict";i.utilites.namespace("ui_elements.iconpicker"),i.ui_elements.iconpicker={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(i){var n,t,c,r=i._target?i._target:e("body"),o=e('.cherry-ui-iconpicker:not([name*="__i__"])',r);o.each(function(){n=e(this),t=n.data("set"),c=window[t],n.length&&c.icons&&n.iconpicker({icons:c.icons,iconBaseClass:c.iconBase,iconClassPrefix:c.iconPrefix,fullClassFormatter:function(e){return c.iconBase+" "+c.iconPrefix+e}}).on("iconpickerUpdated",function(){e(this).trigger("change")}),c&&e("body").append('<link rel="stylesheet" type="text/css" href="'+c.iconCSS+'"">')})}},i.ui_elements.iconpicker.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/assets/ui-iconpicker.js
CHANGED
@@ -1,37 +1,47 @@
|
|
1 |
-
/**
|
2 |
-
* Iconpicker
|
3 |
-
*/
|
4 |
-
(function( $, CherryJsCore ) {
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace( 'ui_elements.iconpicker' );
|
8 |
-
CherryJsCore.ui_elements.iconpicker = {
|
9 |
-
init: function() {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Iconpicker
|
3 |
+
*/
|
4 |
+
(function( $, CherryJsCore ) {
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace( 'ui_elements.iconpicker' );
|
8 |
+
CherryJsCore.ui_elements.iconpicker = {
|
9 |
+
init: function() {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function( event ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' ),
|
15 |
+
$picker = $( '.cherry-ui-iconpicker:not([name*="__i__"])', target ),
|
16 |
+
$this,
|
17 |
+
set,
|
18 |
+
setData;
|
19 |
+
|
20 |
+
$picker.each( function() {
|
21 |
+
$this = $( this );
|
22 |
+
set = $this.data( 'set' );
|
23 |
+
setData = window[set];
|
24 |
+
|
25 |
+
if ( $this.length && setData.icons ) {
|
26 |
+
$this.iconpicker({
|
27 |
+
icons: setData.icons,
|
28 |
+
iconBaseClass: setData.iconBase,
|
29 |
+
iconClassPrefix: setData.iconPrefix,
|
30 |
+
fullClassFormatter: function( val ) {
|
31 |
+
return setData.iconBase + ' ' + setData.iconPrefix + val;
|
32 |
+
}
|
33 |
+
}).on( 'iconpickerUpdated', function() {
|
34 |
+
$( this ).trigger( 'change' );
|
35 |
+
});
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( setData ) {
|
39 |
+
$( 'body' ).append( '<link rel="stylesheet" type="text/css" href="' + setData.iconCSS + '"">' );
|
40 |
+
}
|
41 |
+
} );
|
42 |
+
}
|
43 |
+
};
|
44 |
+
|
45 |
+
CherryJsCore.ui_elements.iconpicker.init();
|
46 |
+
|
47 |
+
}( jQuery, window.CherryJsCore ) );
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-iconpicker/ui-iconpicker.php
CHANGED
@@ -1,279 +1,293 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for the building ui-iconpicker elements.
|
4 |
-
*
|
5 |
-
* @package Cherry_Framework
|
6 |
-
* @subpackage Class
|
7 |
-
* @author Cherry Team <support@cherryframework.com>
|
8 |
-
* @copyright Copyright (c) 2012 - 2015, Cherry Team
|
9 |
-
* @link http://www.cherryframework.com/
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
// If this file is called directly, abort.
|
14 |
-
if ( ! defined( 'WPINC' ) ) {
|
15 |
-
die;
|
16 |
-
}
|
17 |
-
|
18 |
-
if ( ! class_exists( 'UI_Iconpicker' ) ) {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for the building ui-iconpicker elements.
|
22 |
-
*/
|
23 |
-
class UI_Iconpicker extends UI_Element implements I_UI {
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Default settings
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
private $defaults_settings = array(
|
31 |
-
'type' => 'iconpicker',
|
32 |
-
'id' => 'cherry-ui-input-id',
|
33 |
-
'name' => 'cherry-ui-input-name',
|
34 |
-
'value' => '',
|
35 |
-
'placeholder' => '',
|
36 |
-
'icon_data' => array(),
|
37 |
-
'auto_parse' => false,
|
38 |
-
'label' => '',
|
39 |
-
'class' => '',
|
40 |
-
'master' => '',
|
41 |
-
'required' => false,
|
42 |
-
);
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Default icon data settings
|
46 |
-
*
|
47 |
-
* @var array
|
48 |
-
*/
|
49 |
-
private $default_icon_data = array(
|
50 |
-
'icon_set' => '',
|
51 |
-
'icon_css' => '',
|
52 |
-
'icon_base' => 'icon',
|
53 |
-
'icon_prefix' => '',
|
54 |
-
'icons' => '',
|
55 |
-
);
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Icons sets
|
59 |
-
*
|
60 |
-
* @var array
|
61 |
-
*/
|
62 |
-
public static $sets = array();
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Check if sets already printed
|
66 |
-
*
|
67 |
-
* @var boolean
|
68 |
-
*/
|
69 |
-
public static $printed = false;
|
70 |
-
|
71 |
-
/**
|
72 |
-
*
|
73 |
-
*
|
74 |
-
* @
|
75 |
-
*/
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
)
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
if (
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
'ui-iconpicker',
|
272 |
-
|
273 |
-
|
274 |
-
'
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for the building ui-iconpicker elements.
|
4 |
+
*
|
5 |
+
* @package Cherry_Framework
|
6 |
+
* @subpackage Class
|
7 |
+
* @author Cherry Team <support@cherryframework.com>
|
8 |
+
* @copyright Copyright (c) 2012 - 2015, Cherry Team
|
9 |
+
* @link http://www.cherryframework.com/
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
// If this file is called directly, abort.
|
14 |
+
if ( ! defined( 'WPINC' ) ) {
|
15 |
+
die;
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( ! class_exists( 'UI_Iconpicker' ) ) {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Class for the building ui-iconpicker elements.
|
22 |
+
*/
|
23 |
+
class UI_Iconpicker extends UI_Element implements I_UI {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Default settings
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
private $defaults_settings = array(
|
31 |
+
'type' => 'iconpicker',
|
32 |
+
'id' => 'cherry-ui-input-id',
|
33 |
+
'name' => 'cherry-ui-input-name',
|
34 |
+
'value' => '',
|
35 |
+
'placeholder' => '',
|
36 |
+
'icon_data' => array(),
|
37 |
+
'auto_parse' => false,
|
38 |
+
'label' => '',
|
39 |
+
'class' => '',
|
40 |
+
'master' => '',
|
41 |
+
'required' => false,
|
42 |
+
);
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Default icon data settings
|
46 |
+
*
|
47 |
+
* @var array
|
48 |
+
*/
|
49 |
+
private $default_icon_data = array(
|
50 |
+
'icon_set' => '',
|
51 |
+
'icon_css' => '',
|
52 |
+
'icon_base' => 'icon',
|
53 |
+
'icon_prefix' => '',
|
54 |
+
'icons' => '',
|
55 |
+
);
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Icons sets
|
59 |
+
*
|
60 |
+
* @var array
|
61 |
+
*/
|
62 |
+
public static $sets = array();
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Check if sets already printed
|
66 |
+
*
|
67 |
+
* @var boolean
|
68 |
+
*/
|
69 |
+
public static $printed = false;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Array of already printed sets to check it before printing current
|
73 |
+
*
|
74 |
+
* @var array
|
75 |
+
*/
|
76 |
+
public static $printed_sets = array();
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Constructor method for the UI_Text class.
|
80 |
+
*
|
81 |
+
* @since 4.0.0
|
82 |
+
*/
|
83 |
+
function __construct( $args = array() ) {
|
84 |
+
$this->defaults_settings['id'] = 'cherry-ui-input-icon-'.uniqid();
|
85 |
+
$this->settings = wp_parse_args( $args, $this->defaults_settings );
|
86 |
+
|
87 |
+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
|
88 |
+
add_action( 'admin_footer', array( $this, 'print_icon_set' ), 1 );
|
89 |
+
add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_icon_set' ), 9999 );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Get required attribute
|
94 |
+
*
|
95 |
+
* @return string required attribute
|
96 |
+
*/
|
97 |
+
public function get_required() {
|
98 |
+
if ( $this->settings['required'] ) {
|
99 |
+
return 'required="required"';
|
100 |
+
}
|
101 |
+
return '';
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Render html UI_Text.
|
106 |
+
*
|
107 |
+
* @since 4.0.0
|
108 |
+
*/
|
109 |
+
public function render() {
|
110 |
+
$html = '';
|
111 |
+
|
112 |
+
$html .= '<div class="cherry-ui-container ' . esc_attr( $this->settings['master'] ) . '">';
|
113 |
+
if ( '' !== $this->settings['label'] ) {
|
114 |
+
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
|
115 |
+
}
|
116 |
+
|
117 |
+
$this->settings['icon_data'] = wp_parse_args(
|
118 |
+
$this->settings['icon_data'],
|
119 |
+
$this->default_icon_data
|
120 |
+
);
|
121 |
+
|
122 |
+
$this->maybe_parse_set_from_css();
|
123 |
+
|
124 |
+
$html .= '<div class="cherry-ui-iconpicker-group">';
|
125 |
+
|
126 |
+
if ( $this->validate_icon_data( $this->settings['icon_data'] ) ) {
|
127 |
+
$html .= $this->render_picker();
|
128 |
+
} else {
|
129 |
+
$html .= 'Incorrect Icon Data Settings';
|
130 |
+
}
|
131 |
+
|
132 |
+
$html .= '</div>';
|
133 |
+
$html .= '</div>';
|
134 |
+
return $html;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Returns iconpicker html markup
|
139 |
+
*
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
private function render_picker() {
|
143 |
+
|
144 |
+
$format = '<span class="input-group-addon"></span><input type="text" name="%1$s" id="%2$s" value="%3$s" class="widefat cherry-ui-text cherry-ui-iconpicker %4$s" data-set="%5$s">';
|
145 |
+
|
146 |
+
$this->prepare_icon_set();
|
147 |
+
|
148 |
+
return sprintf(
|
149 |
+
$format,
|
150 |
+
$this->settings['name'],
|
151 |
+
$this->settings['id'],
|
152 |
+
$this->settings['value'],
|
153 |
+
$this->settings['class'],
|
154 |
+
$this->settings['icon_data']['icon_set']
|
155 |
+
);
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Return JS markup for icon set variable.
|
161 |
+
*
|
162 |
+
* @return void
|
163 |
+
*/
|
164 |
+
public function prepare_icon_set() {
|
165 |
+
|
166 |
+
if ( ! array_key_exists( $this->settings['icon_data']['icon_set'], self::$sets ) ) {
|
167 |
+
self::$sets[ $this->settings['icon_data']['icon_set'] ] = array(
|
168 |
+
'iconCSS' => $this->settings['icon_data']['icon_css'],
|
169 |
+
'iconBase' => $this->settings['icon_data']['icon_base'],
|
170 |
+
'iconPrefix' => $this->settings['icon_data']['icon_prefix'],
|
171 |
+
'icons' => $this->settings['icon_data']['icons'],
|
172 |
+
);
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Check if 'parse_set' is true and try to get icons set from CSS file
|
179 |
+
*
|
180 |
+
* @return void
|
181 |
+
*/
|
182 |
+
private function maybe_parse_set_from_css() {
|
183 |
+
|
184 |
+
if ( true !== $this->settings['auto_parse'] || empty( $this->settings['icon_data']['icon_css'] ) ) {
|
185 |
+
return;
|
186 |
+
}
|
187 |
+
|
188 |
+
ob_start();
|
189 |
+
|
190 |
+
$path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $this->settings['icon_data']['icon_css'] );
|
191 |
+
if ( file_exists( $path ) ) {
|
192 |
+
include $path;
|
193 |
+
}
|
194 |
+
|
195 |
+
$result = ob_get_clean();
|
196 |
+
|
197 |
+
preg_match_all( '/\.([-a-zA-Z0-9]+):before[, {]/', $result, $matches );
|
198 |
+
|
199 |
+
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
|
200 |
+
return;
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( is_array( $this->settings['icon_data']['icons'] ) ) {
|
204 |
+
$this->settings['icon_data']['icons'] = array_merge(
|
205 |
+
$this->settings['icon_data']['icons'],
|
206 |
+
$matches[1]
|
207 |
+
);
|
208 |
+
} else {
|
209 |
+
$this->settings['icon_data']['icons'] = $matches[1];
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Checks if all required icon data fields are passed
|
216 |
+
*
|
217 |
+
* @param array $data Icon data.
|
218 |
+
* @return bool
|
219 |
+
*/
|
220 |
+
private function validate_icon_data( $data ) {
|
221 |
+
|
222 |
+
$validate = array_diff( $this->default_icon_data, array( 'icon_base', 'icon_prefix' ) );
|
223 |
+
|
224 |
+
foreach ( $validate as $key => $field ) {
|
225 |
+
|
226 |
+
if ( empty( $data[ $key ] ) ) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
|
230 |
+
return true;
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Print icon sets
|
237 |
+
*
|
238 |
+
* @return void
|
239 |
+
*/
|
240 |
+
public function print_icon_set() {
|
241 |
+
|
242 |
+
if ( empty( self::$sets ) || true === self::$printed ) {
|
243 |
+
return;
|
244 |
+
}
|
245 |
+
|
246 |
+
self::$printed = true;
|
247 |
+
|
248 |
+
foreach ( self::$sets as $set => $data ) {
|
249 |
+
|
250 |
+
if ( in_array( $set, self::$printed_sets ) ) {
|
251 |
+
continue;
|
252 |
+
}
|
253 |
+
|
254 |
+
self::$printed_sets[] = $set;
|
255 |
+
$json = json_encode( $data );
|
256 |
+
|
257 |
+
printf( '<script>window.%1$s = %2$s</script>', $set, $json );
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Enqueue javascript and stylesheet UI_Text
|
264 |
+
*
|
265 |
+
* @since 4.0.0
|
266 |
+
*/
|
267 |
+
public static function enqueue_assets() {
|
268 |
+
|
269 |
+
wp_enqueue_style(
|
270 |
+
'ui-iconpicker',
|
271 |
+
esc_url( Cherry_Core::base_url( 'assets/min/ui-iconpicker.min.css', __FILE__ ) ),
|
272 |
+
array(),
|
273 |
+
'1.0.0',
|
274 |
+
'all'
|
275 |
+
);
|
276 |
+
|
277 |
+
wp_enqueue_script(
|
278 |
+
'jquery-iconpicker',
|
279 |
+
esc_url( Cherry_Core::base_url( 'assets/min/jquery-iconpicker.min.js', __FILE__ ) ),
|
280 |
+
array( 'jquery' ),
|
281 |
+
'1.0.0',
|
282 |
+
true
|
283 |
+
);
|
284 |
+
wp_enqueue_script(
|
285 |
+
'ui-iconpicker',
|
286 |
+
esc_url( Cherry_Core::base_url( 'assets/min/ui-iconpicker.min.js', __FILE__ ) ),
|
287 |
+
array( 'jquery' ),
|
288 |
+
'1.0.0',
|
289 |
+
true
|
290 |
+
);
|
291 |
+
}
|
292 |
+
}
|
293 |
+
}
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-media/assets/min/ui-media.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,
|
1 |
+
!function(e,a){"use strict";a.utilites.namespace("ui_elements.media"),a.ui_elements.media={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(a){var i=a._target?a._target:e("body"),r=e(".upload-button",i);r.each(function(){var a=e(this),i=a.closest(".cherry-ui-media-wrap"),r={input:e(".cherry-upload-input",i),img_holder:e(".cherry-upload-preview",i),title_text:a.data("title"),multiple:a.data("multi-upload"),library_type:a.data("library-type")},t=wp.media.frames.file_frame=wp.media({title:r.title_text,button:{text:r.title_text},multiple:r.multiple,library:{type:r.library_type}});a.on("click",function(){return t.open(),!1}),t.on("select",function(){var a=t.state().get("selection").toJSON(),i=0,n="",c=e(".cherry-all-images-wrap",r.img_holder),l="",o="";for(r.multiple&&(n=r.input.val(),o=",",l=c.html());a[i];){var d=a[i],u=d.id,p=d.mime,m="",h="";switch(p){case"image/jpeg":case"image/png":case"image/gif":void 0!==d.sizes&&(m=d.sizes.thumbnail?d.sizes.thumbnail.url:d.sizes.full.url),h='<img src="'+m+'" alt="" data-img-attr="'+u+'">';break;case"image/x-icon":h='<span class="dashicons dashicons-format-image"></span>';break;case"video/mpeg":case"video/mp4":case"video/quicktime":case"video/webm":case"video/ogg":h='<span class="dashicons dashicons-format-video"></span>';break;case"audio/mpeg":case"audio/wav":case"audio/ogg":h='<span class="dashicons dashicons-format-audio"></span>'}l+='<div class="cherry-image-wrap"><div class="inner"><div class="preview-holder" data-id-attr="'+u+'"><div class="centered">'+h+'</div></div><a class="cherry-remove-image" href="#"><i class="dashicons dashicons-no"></i></a><span class="title">'+d.title+"</span></div></div>",n+=o+u,i++}r.input.val(n.replace(/(^,)/,"")).trigger("change"),c.html(l),e(".cherry-remove-image").on("click",function(){return s(e(this)),!1})});var s=function(e){var a=e.closest(".cherry-ui-media-wrap"),i=jQuery(".cherry-upload-input",a),r=e.parent().parent(".cherry-image-wrap"),t=jQuery(".preview-holder",r).data("id-attr"),s=i.attr("value"),n=new RegExp(""+t+"(,*)","i");s=s.replace(n,""),s=s.replace(/(,$)/,""),i.attr({value:s}).trigger("change"),r.remove()};jQuery(".cherry-remove-image",i).on("click",function(){return s(jQuery(this)),!1})}),jQuery(".cherry-all-images-wrap",i).sortable({items:"div.cherry-image-wrap",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"cherry-media-thumb-sortable-placeholder",start:function(){},stop:function(){},update:function(){var e="";jQuery(".cherry-image-wrap",this).each(function(){var a=jQuery(".preview-holder",this).data("id-attr");e=e+a+","}),e=e.substr(0,e.lastIndexOf(",")),jQuery(this).parent().siblings(".cherry-element-wrap").find("input.cherry-upload-input").val(e).trigger("change")}})}},a.ui_elements.media.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-media/assets/ui-media.js
CHANGED
@@ -1,158 +1,159 @@
|
|
1 |
-
/**
|
2 |
-
* Media
|
3 |
-
*/
|
4 |
-
(function( $, CherryJsCore){
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.media');
|
8 |
-
CherryJsCore.ui_elements.media = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
case 'image/
|
62 |
-
case 'image/
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
case 'video/
|
73 |
-
case 'video/
|
74 |
-
case 'video/
|
75 |
-
case 'video/
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
case 'audio/
|
80 |
-
case 'audio/
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
'<
|
89 |
-
'<
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
input_value = input_value.replace(
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
1 |
+
/**
|
2 |
+
* Media
|
3 |
+
*/
|
4 |
+
(function( $, CherryJsCore){
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.media');
|
8 |
+
CherryJsCore.ui_elements.media = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function ( event ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' ),
|
15 |
+
buttons = $('.upload-button', target);
|
16 |
+
|
17 |
+
buttons.each( function() {
|
18 |
+
var button = $( this ),
|
19 |
+
button_parent = button.closest('.cherry-ui-media-wrap'),
|
20 |
+
settings = {
|
21 |
+
input: $('.cherry-upload-input', button_parent),
|
22 |
+
img_holder: $('.cherry-upload-preview', button_parent),
|
23 |
+
title_text: button.data('title'),
|
24 |
+
multiple: button.data('multi-upload'),
|
25 |
+
library_type: button.data('library-type'),
|
26 |
+
},
|
27 |
+
cherry_uploader = wp.media.frames.file_frame = wp.media({
|
28 |
+
title: settings.title_text,
|
29 |
+
button: { text: settings.title_text },
|
30 |
+
multiple: settings.multiple,
|
31 |
+
library : { type : settings.library_type }
|
32 |
+
});
|
33 |
+
|
34 |
+
button.on( 'click', function() {
|
35 |
+
cherry_uploader.open();
|
36 |
+
return !1;
|
37 |
+
} ); // end click
|
38 |
+
|
39 |
+
cherry_uploader.on('select', function() {
|
40 |
+
var attachment = cherry_uploader.state().get('selection').toJSON(),
|
41 |
+
count = 0,
|
42 |
+
input_value = '',
|
43 |
+
new_img_object = $('.cherry-all-images-wrap', settings.img_holder),
|
44 |
+
new_img = '',
|
45 |
+
delimiter = '';
|
46 |
+
|
47 |
+
if ( settings.multiple ) {
|
48 |
+
input_value = settings.input.val();
|
49 |
+
delimiter = ',';
|
50 |
+
new_img = new_img_object.html();
|
51 |
+
}
|
52 |
+
|
53 |
+
while( attachment[ count ] ) {
|
54 |
+
var img_data = attachment[count],
|
55 |
+
return_data = img_data.id,
|
56 |
+
mimeType = img_data.mime,
|
57 |
+
img_src = '',
|
58 |
+
thumb = '';
|
59 |
+
|
60 |
+
switch (mimeType) {
|
61 |
+
case 'image/jpeg':
|
62 |
+
case 'image/png':
|
63 |
+
case 'image/gif':
|
64 |
+
if( img_data.sizes !== undefined){
|
65 |
+
img_src = img_data.sizes.thumbnail ? img_data.sizes.thumbnail.url : img_data.sizes.full.url;
|
66 |
+
}
|
67 |
+
thumb = '<img src="' + img_src + '" alt="" data-img-attr="'+return_data+'">';
|
68 |
+
break;
|
69 |
+
case 'image/x-icon':
|
70 |
+
thumb = '<span class="dashicons dashicons-format-image"></span>';
|
71 |
+
break;
|
72 |
+
case 'video/mpeg':
|
73 |
+
case 'video/mp4':
|
74 |
+
case 'video/quicktime':
|
75 |
+
case 'video/webm':
|
76 |
+
case 'video/ogg':
|
77 |
+
thumb = '<span class="dashicons dashicons-format-video"></span>';
|
78 |
+
break;
|
79 |
+
case 'audio/mpeg':
|
80 |
+
case 'audio/wav':
|
81 |
+
case 'audio/ogg':
|
82 |
+
thumb = '<span class="dashicons dashicons-format-audio"></span>';
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
|
86 |
+
new_img += '<div class="cherry-image-wrap">'+
|
87 |
+
'<div class="inner">'+
|
88 |
+
'<div class="preview-holder" data-id-attr="' + return_data +'"><div class="centered">' + thumb + '</div></div>'+
|
89 |
+
'<a class="cherry-remove-image" href="#"><i class="dashicons dashicons-no"></i></a>'+
|
90 |
+
'<span class="title">' + img_data.title + '</span>'+
|
91 |
+
'</div>'+
|
92 |
+
'</div>';
|
93 |
+
|
94 |
+
input_value += delimiter+return_data;
|
95 |
+
count++;
|
96 |
+
}
|
97 |
+
|
98 |
+
settings.input.val(input_value.replace(/(^,)/, '')).trigger( 'change' );
|
99 |
+
new_img_object.html(new_img);
|
100 |
+
|
101 |
+
$('.cherry-remove-image').on('click', function () {
|
102 |
+
removeMediaPreview( $(this) );
|
103 |
+
return !1;
|
104 |
+
});
|
105 |
+
} );
|
106 |
+
|
107 |
+
var removeMediaPreview = function( item ) {
|
108 |
+
var button_parent = item.closest('.cherry-ui-media-wrap'),
|
109 |
+
input = jQuery('.cherry-upload-input', button_parent),
|
110 |
+
img_holder = item.parent().parent('.cherry-image-wrap'),
|
111 |
+
img_attr = jQuery('.preview-holder', img_holder).data('id-attr'),
|
112 |
+
input_value = input.attr('value'),
|
113 |
+
pattern = new RegExp(''+img_attr+'(,*)', 'i');
|
114 |
+
|
115 |
+
input_value = input_value.replace(pattern, '');
|
116 |
+
input_value = input_value.replace(/(,$)/, '');
|
117 |
+
input.attr({'value':input_value}).trigger( 'change' );
|
118 |
+
img_holder.remove();
|
119 |
+
|
120 |
+
};
|
121 |
+
|
122 |
+
// This function remove upload image
|
123 |
+
jQuery('.cherry-remove-image', button_parent).on('click', function () {
|
124 |
+
removeMediaPreview( jQuery(this) );
|
125 |
+
return !1;
|
126 |
+
});
|
127 |
+
} ); // end each
|
128 |
+
|
129 |
+
// Image ordering
|
130 |
+
jQuery('.cherry-all-images-wrap', target).sortable( {
|
131 |
+
items: 'div.cherry-image-wrap',
|
132 |
+
cursor: 'move',
|
133 |
+
scrollSensitivity: 40,
|
134 |
+
forcePlaceholderSize: true,
|
135 |
+
forceHelperSize: false,
|
136 |
+
helper: 'clone',
|
137 |
+
opacity: 0.65,
|
138 |
+
placeholder: 'cherry-media-thumb-sortable-placeholder',
|
139 |
+
start:function(){},
|
140 |
+
stop:function(){},
|
141 |
+
update: function() {
|
142 |
+
var attachment_ids = '';
|
143 |
+
jQuery('.cherry-image-wrap', this).each(
|
144 |
+
function() {
|
145 |
+
var attachment_id = jQuery('.preview-holder', this).data( 'id-attr' );
|
146 |
+
attachment_ids = attachment_ids + attachment_id + ',';
|
147 |
+
}
|
148 |
+
);
|
149 |
+
attachment_ids = attachment_ids.substr(0, attachment_ids.lastIndexOf(',') );
|
150 |
+
jQuery(this).parent().siblings('.cherry-element-wrap').find('input.cherry-upload-input').val( attachment_ids ).trigger( 'change' );
|
151 |
+
}
|
152 |
+
} );
|
153 |
+
// End Image ordering
|
154 |
+
}
|
155 |
+
};
|
156 |
+
|
157 |
+
CherryJsCore.ui_elements.media.init();
|
158 |
+
|
159 |
+
}(jQuery , window.CherryJsCore));
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-radio/assets/min/ui-radio.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,
|
1 |
+
!function(e,r){"use strict";r.utilites.namespace("ui_elements.radio"),r.ui_elements.radio={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(r){var i=r._target?r._target:e("body");e(".cherry-radio-group",i).each(function(){e('.cherry-radio-input[type="radio"]',this).each(function(){var r=e(this),t=r.data("slave");r.is(":checked")||e("."+t,i).stop().hide()})}),e('.cherry-radio-input[type="radio"]',i).on("change",function(){var r=e(this),t=r.data("slave"),a=r.parents(".cherry-radio-group"),n=e('.cherry-radio-input[type="radio"]',a);r.parents(".cherry-radio-group").find(".checked").removeClass("checked"),r.parent().addClass("checked"),e("."+t,i).show(),n.each(function(){var r=e(this),a=r.data("slave");a!==t&&e("."+a,i).hide()}),r.trigger("radio_change_event",[t,n])})}},r.ui_elements.radio.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-radio/assets/ui-radio.js
CHANGED
@@ -1,52 +1,53 @@
|
|
1 |
-
/**
|
2 |
-
* Radio
|
3 |
-
*/
|
4 |
-
( function( $, CherryJsCore ){
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.radio');
|
8 |
-
CherryJsCore.ui_elements.radio = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$this.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
1 |
+
/**
|
2 |
+
* Radio
|
3 |
+
*/
|
4 |
+
( function( $, CherryJsCore ){
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.radio');
|
8 |
+
CherryJsCore.ui_elements.radio = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function ( event ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' );
|
15 |
+
|
16 |
+
$( '.cherry-radio-group', target ).each( function() {
|
17 |
+
$( '.cherry-radio-input[type="radio"]', this ).each( function() {
|
18 |
+
var $this = $(this),
|
19 |
+
this_slave = $this.data('slave');
|
20 |
+
|
21 |
+
if ( ! $this.is( ':checked' ) ) {
|
22 |
+
$( '.' + this_slave, target ).stop().hide();
|
23 |
+
}
|
24 |
+
} );
|
25 |
+
} );
|
26 |
+
|
27 |
+
$( '.cherry-radio-input[type="radio"]', target ).on( 'change', function() {
|
28 |
+
var $this = $(this),
|
29 |
+
slave = $this.data('slave'),
|
30 |
+
radio_group = $this.parents('.cherry-radio-group'),
|
31 |
+
radio_group_list = $('.cherry-radio-input[type="radio"]', radio_group);
|
32 |
+
|
33 |
+
$this.parents('.cherry-radio-group').find('.checked').removeClass('checked');
|
34 |
+
$this.parent().addClass('checked');
|
35 |
+
|
36 |
+
$('.' + slave, target).show();
|
37 |
+
radio_group_list.each(function(){
|
38 |
+
var $this = $(this),
|
39 |
+
this_slave = $this.data('slave');
|
40 |
+
|
41 |
+
if( this_slave !== slave ){
|
42 |
+
$('.' + this_slave, target).hide();
|
43 |
+
}
|
44 |
+
});
|
45 |
+
|
46 |
+
$this.trigger( 'radio_change_event', [slave, radio_group_list] );
|
47 |
+
});
|
48 |
+
}
|
49 |
+
};
|
50 |
+
|
51 |
+
CherryJsCore.ui_elements.radio.init();
|
52 |
+
|
53 |
+
}( jQuery, window.CherryJsCore ) );
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-repeater/assets/min/ui-repeater.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){"use strict";t.utilites.namespace("ui_elements.repeater"),t.ui_elements.repeater={repeaterContainerClass:".cherry-ui-repeater-container",repeaterListClass:".cherry-ui-repeater-list",repeaterItemClass:".cherry-ui-repeater-item",repeaterItemHandleClass:".cherry-ui-repeater-actions-box",repeaterTitleClass:".cherry-ui-repeater-title",addItemButtonClass:".cherry-ui-repeater-add",removeItemButtonClass:".cherry-ui-repeater-remove",toggleItemButtonClass:".cherry-ui-repeater-toggle",minItemClass:"cherry-ui-repeater-min",sortablePlaceholderClass:"sortable-placeholder",init:function(){e(document).on("ready",this.addEvents.bind(this))},addEvents:function(){e("body").on("click",this.addItemButtonClass,{self:this},this.addItem).on("click",this.removeItemButtonClass,{self:this},this.removeItem).on("click",this.toggleItemButtonClass,{self:this},this.toggleItem).on("change",this.repeaterListClass+" input, "+this.repeaterListClass+" textarea, "+this.repeaterListClass+" select",{self:this},this.changeWrapperLable).on("sortable-init",{self:this},this.sortableItem),e(window).on("cherry-ui-elements-init",{self:this},this.sortableItem),this.triggers()},triggers:function(t){return e("body").trigger("sortable-init"),t&&e(window).trigger("cherry-ui-elements-init",{target:t}),this},addItem:function(t){var s=t.data.self,a=e(this).prev(s.repeaterListClass),r=a.data("index"),i=a.data("name"),l=wp.template(i),n=a.data("widget-id"),o={index:r};n&&(o.widgetId=n),a.append(l(o)),r++,a.data("index",r),s.triggers(e(s.repeaterItemClass,a)).stopDefaultEvent(t)},removeItem:function(t){var s=t.data.self,a=e(this).closest(s.repeaterListClass);s.applyChanges(a),e(this).closest(s.repeaterItemClass).remove(),s.triggers().stopDefaultEvent(t)},toggleItem:function(t){var s=t.data.self,a=e(this).closest(s.repeaterItemClass);a.toggleClass(s.minItemClass),s.stopDefaultEvent(t)},sortableItem:function(t){var s,a,r=t.data.self,i=e(r.repeaterListClass);i.each(function(t,i){s=e(i),a=e(i).data("sortable-init"),s.sortable(a?"refresh":{items:r.repeaterItemClass,handle:r.repeaterItemHandleClass,cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:r.sortablePlaceholderClass,create:function(){s.data("sortable-init",!0)},update:function(t){var s=e(t.target);r.applyChanges(s)}})})},changeWrapperLable:function(t){var s,a,r=t.data.self,i=e(r.repeaterListClass),l=i.data("title-field"),n=e(this);l&&n.closest("."+l+"-wrap")[0]&&(s=n.val(),a=n.closest(r.repeaterItemClass),e(r.repeaterTitleClass,a).html(s)),r.stopDefaultEvent(t)},applyChanges:function(t){return void 0!==wp.customize&&e("input[name]:first, select[name]:first",t).change(),this},stopDefaultEvent:function(e){return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this}},t.ui_elements.repeater.init()}(jQuery,window.CherryJsCore);
|
1 |
+
!function(e,t){"use strict";t.utilites.namespace("ui_elements.repeater"),t.ui_elements.repeater={repeaterContainerClass:".cherry-ui-repeater-container",repeaterListClass:".cherry-ui-repeater-list",repeaterItemClass:".cherry-ui-repeater-item",repeaterItemHandleClass:".cherry-ui-repeater-actions-box",repeaterTitleClass:".cherry-ui-repeater-title",addItemButtonClass:".cherry-ui-repeater-add",removeItemButtonClass:".cherry-ui-repeater-remove",toggleItemButtonClass:".cherry-ui-repeater-toggle",minItemClass:"cherry-ui-repeater-min",sortablePlaceholderClass:"sortable-placeholder",init:function(){e(document).on("ready",this.addEvents.bind(this))},addEvents:function(){e("body").on("click",this.addItemButtonClass,{self:this},this.addItem).on("click",this.removeItemButtonClass,{self:this},this.removeItem).on("click",this.toggleItemButtonClass,{self:this},this.toggleItem).on("change",this.repeaterListClass+" input, "+this.repeaterListClass+" textarea, "+this.repeaterListClass+" select",{self:this},this.changeWrapperLable).on("sortable-init",{self:this},this.sortableItem),e(window).on("cherry-ui-elements-init",{self:this},this.sortableItem),this.triggers()},triggers:function(t){return e("body").trigger("sortable-init"),t&&e(window).trigger("cherry-ui-elements-init",{target:t}),this},addItem:function(t){var s=t.data.self,a=e(this).prev(s.repeaterListClass),r=a.data("index"),i=a.data("name"),l=wp.template(i),n=a.data("widget-id"),o={index:r};n&&(o.widgetId=n),a.append(l(o)),r++,a.data("index",r),s.triggers(e(s.repeaterItemClass+":last",a)).stopDefaultEvent(t)},removeItem:function(t){var s=t.data.self,a=e(this).closest(s.repeaterListClass);s.applyChanges(a),e(this).closest(s.repeaterItemClass).remove(),s.triggers().stopDefaultEvent(t)},toggleItem:function(t){var s=t.data.self,a=e(this).closest(s.repeaterItemClass);a.toggleClass(s.minItemClass),s.stopDefaultEvent(t)},sortableItem:function(t){var s,a,r=t.data.self,i=e(r.repeaterListClass);i.each(function(t,i){s=e(i),a=e(i).data("sortable-init"),s.sortable(a?"refresh":{items:r.repeaterItemClass,handle:r.repeaterItemHandleClass,cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:r.sortablePlaceholderClass,create:function(){s.data("sortable-init",!0)},update:function(t){var s=e(t.target);r.applyChanges(s)}})})},changeWrapperLable:function(t){var s,a,r=t.data.self,i=e(r.repeaterListClass),l=i.data("title-field"),n=e(this);l&&n.closest("."+l+"-wrap")[0]&&(s=n.val(),a=n.closest(r.repeaterItemClass),e(r.repeaterTitleClass,a).html(s)),r.stopDefaultEvent(t)},applyChanges:function(t){return void 0!==wp.customize&&e("input[name]:first, select[name]:first",t).change(),this},stopDefaultEvent:function(e){return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this}},t.ui_elements.repeater.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-repeater/assets/ui-repeater.js
CHANGED
@@ -1,174 +1,174 @@
|
|
1 |
-
/**
|
2 |
-
* Repeater
|
3 |
-
*/
|
4 |
-
(function( $, CherryJsCore ) {
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace( 'ui_elements.repeater' );
|
8 |
-
|
9 |
-
CherryJsCore.ui_elements.repeater = {
|
10 |
-
|
11 |
-
repeaterContainerClass: '.cherry-ui-repeater-container',
|
12 |
-
repeaterListClass: '.cherry-ui-repeater-list',
|
13 |
-
repeaterItemClass: '.cherry-ui-repeater-item',
|
14 |
-
repeaterItemHandleClass: '.cherry-ui-repeater-actions-box',
|
15 |
-
repeaterTitleClass: '.cherry-ui-repeater-title',
|
16 |
-
|
17 |
-
addItemButtonClass: '.cherry-ui-repeater-add',
|
18 |
-
removeItemButtonClass: '.cherry-ui-repeater-remove',
|
19 |
-
toggleItemButtonClass: '.cherry-ui-repeater-toggle',
|
20 |
-
|
21 |
-
minItemClass: 'cherry-ui-repeater-min',
|
22 |
-
sortablePlaceholderClass: 'sortable-placeholder',
|
23 |
-
|
24 |
-
init: function() {
|
25 |
-
$( document ).on( 'ready', this.addEvents.bind( this ) );
|
26 |
-
},
|
27 |
-
|
28 |
-
addEvents: function() {
|
29 |
-
$( 'body' )
|
30 |
-
|
31 |
-
// Delegate events
|
32 |
-
.on( 'click', this.addItemButtonClass, { 'self': this }, this.addItem )
|
33 |
-
.on( 'click', this.removeItemButtonClass, { 'self': this }, this.removeItem )
|
34 |
-
.on( 'click', this.toggleItemButtonClass, { 'self': this }, this.toggleItem )
|
35 |
-
.on( 'change', this.repeaterListClass + ' input, ' + this.repeaterListClass + ' textarea, ' + this.repeaterListClass + ' select', { 'self': this }, this.changeWrapperLable )
|
36 |
-
|
37 |
-
// Custom events
|
38 |
-
.on( 'sortable-init', { 'self': this }, this.sortableItem );
|
39 |
-
|
40 |
-
$( window )
|
41 |
-
.on( 'cherry-ui-elements-init', { 'self': this }, this.sortableItem );
|
42 |
-
|
43 |
-
this.triggers();
|
44 |
-
},
|
45 |
-
|
46 |
-
triggers: function( $target ) {
|
47 |
-
$( 'body' ).trigger( 'sortable-init' );
|
48 |
-
|
49 |
-
if ( $target ) {
|
50 |
-
$( window ).trigger( 'cherry-ui-elements-init', { 'target': $target } );
|
51 |
-
}
|
52 |
-
|
53 |
-
return this;
|
54 |
-
},
|
55 |
-
|
56 |
-
addItem: function( event ) {
|
57 |
-
var self = event.data.self,
|
58 |
-
$list = $( this ).prev( self.repeaterListClass ),
|
59 |
-
index = $list.data( 'index' ),
|
60 |
-
tmplName = $list.data( 'name' ),
|
61 |
-
rowTemplate = wp.template( tmplName ),
|
62 |
-
widgetId = $list.data( 'widget-id' ),
|
63 |
-
data = { index: index };
|
64 |
-
|
65 |
-
if ( widgetId ) {
|
66 |
-
data.widgetId = widgetId;
|
67 |
-
}
|
68 |
-
|
69 |
-
$list.append( rowTemplate( data ) );
|
70 |
-
|
71 |
-
index++;
|
72 |
-
$list.data( 'index', index );
|
73 |
-
|
74 |
-
self
|
75 |
-
.triggers( $( self.repeaterItemClass, $list ) )
|
76 |
-
.stopDefaultEvent( event );
|
77 |
-
},
|
78 |
-
|
79 |
-
removeItem: function( event ) {
|
80 |
-
var self = event.data.self,
|
81 |
-
$list = $( this ).closest( self.repeaterListClass );
|
82 |
-
|
83 |
-
self.applyChanges( $list );
|
84 |
-
|
85 |
-
$( this ).closest( self.repeaterItemClass ).remove();
|
86 |
-
|
87 |
-
self
|
88 |
-
.triggers()
|
89 |
-
.stopDefaultEvent( event );
|
90 |
-
},
|
91 |
-
|
92 |
-
toggleItem: function( event ) {
|
93 |
-
var self = event.data.self,
|
94 |
-
$container = $( this ).closest( self.repeaterItemClass );
|
95 |
-
|
96 |
-
$container.toggleClass( self.minItemClass );
|
97 |
-
|
98 |
-
self.stopDefaultEvent( event );
|
99 |
-
},
|
100 |
-
|
101 |
-
sortableItem: function( event ) {
|
102 |
-
var self = event.data.self,
|
103 |
-
$list = $( self.repeaterListClass ),
|
104 |
-
$this,
|
105 |
-
initFlag;
|
106 |
-
|
107 |
-
$list.each( function( indx, element ) {
|
108 |
-
$this = $( element );
|
109 |
-
initFlag = $( element ).data( 'sortable-init' );
|
110 |
-
|
111 |
-
if ( ! initFlag ) {
|
112 |
-
$this.sortable( {
|
113 |
-
items: self.repeaterItemClass,
|
114 |
-
handle: self.repeaterItemHandleClass,
|
115 |
-
cursor: 'move',
|
116 |
-
scrollSensitivity: 40,
|
117 |
-
forcePlaceholderSize: true,
|
118 |
-
forceHelperSize: false,
|
119 |
-
helper: 'clone',
|
120 |
-
opacity: 0.65,
|
121 |
-
placeholder: self.sortablePlaceholderClass,
|
122 |
-
create: function() {
|
123 |
-
$this.data( 'sortable-init', true );
|
124 |
-
},
|
125 |
-
update: function( event ) {
|
126 |
-
var target = $( event.target );
|
127 |
-
|
128 |
-
self.applyChanges( target );
|
129 |
-
}
|
130 |
-
} );
|
131 |
-
} else {
|
132 |
-
$this.sortable( 'refresh' );
|
133 |
-
}
|
134 |
-
} );
|
135 |
-
},
|
136 |
-
|
137 |
-
changeWrapperLable: function( event ) {
|
138 |
-
var self = event.data.self,
|
139 |
-
$list = $( self.repeaterListClass ),
|
140 |
-
titleFilds = $list.data( 'title-field' ),
|
141 |
-
$this = $( this ),
|
142 |
-
value,
|
143 |
-
parentItem;
|
144 |
-
|
145 |
-
if ( titleFilds && $this.closest( '.' + titleFilds + '-wrap' )[0] ) {
|
146 |
-
value = $this.val(),
|
147 |
-
parentItem = $this.closest( self.repeaterItemClass );
|
148 |
-
|
149 |
-
$( self.repeaterTitleClass, parentItem ).html( value );
|
150 |
-
}
|
151 |
-
|
152 |
-
self.stopDefaultEvent( event );
|
153 |
-
},
|
154 |
-
|
155 |
-
applyChanges: function( target ) {
|
156 |
-
if ( undefined !== wp.customize ) {
|
157 |
-
$( 'input[name]:first, select[name]:first', target ).change();
|
158 |
-
}
|
159 |
-
|
160 |
-
return this;
|
161 |
-
},
|
162 |
-
|
163 |
-
stopDefaultEvent: function( event ) {
|
164 |
-
event.preventDefault();
|
165 |
-
event.stopImmediatePropagation();
|
166 |
-
event.stopPropagation();
|
167 |
-
|
168 |
-
return this;
|
169 |
-
}
|
170 |
-
};
|
171 |
-
|
172 |
-
CherryJsCore.ui_elements.repeater.init();
|
173 |
-
|
174 |
-
}( jQuery, window.CherryJsCore ) );
|
1 |
+
/**
|
2 |
+
* Repeater
|
3 |
+
*/
|
4 |
+
(function( $, CherryJsCore ) {
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace( 'ui_elements.repeater' );
|
8 |
+
|
9 |
+
CherryJsCore.ui_elements.repeater = {
|
10 |
+
|
11 |
+
repeaterContainerClass: '.cherry-ui-repeater-container',
|
12 |
+
repeaterListClass: '.cherry-ui-repeater-list',
|
13 |
+
repeaterItemClass: '.cherry-ui-repeater-item',
|
14 |
+
repeaterItemHandleClass: '.cherry-ui-repeater-actions-box',
|
15 |
+
repeaterTitleClass: '.cherry-ui-repeater-title',
|
16 |
+
|
17 |
+
addItemButtonClass: '.cherry-ui-repeater-add',
|
18 |
+
removeItemButtonClass: '.cherry-ui-repeater-remove',
|
19 |
+
toggleItemButtonClass: '.cherry-ui-repeater-toggle',
|
20 |
+
|
21 |
+
minItemClass: 'cherry-ui-repeater-min',
|
22 |
+
sortablePlaceholderClass: 'sortable-placeholder',
|
23 |
+
|
24 |
+
init: function() {
|
25 |
+
$( document ).on( 'ready', this.addEvents.bind( this ) );
|
26 |
+
},
|
27 |
+
|
28 |
+
addEvents: function() {
|
29 |
+
$( 'body' )
|
30 |
+
|
31 |
+
// Delegate events
|
32 |
+
.on( 'click', this.addItemButtonClass, { 'self': this }, this.addItem )
|
33 |
+
.on( 'click', this.removeItemButtonClass, { 'self': this }, this.removeItem )
|
34 |
+
.on( 'click', this.toggleItemButtonClass, { 'self': this }, this.toggleItem )
|
35 |
+
.on( 'change', this.repeaterListClass + ' input, ' + this.repeaterListClass + ' textarea, ' + this.repeaterListClass + ' select', { 'self': this }, this.changeWrapperLable )
|
36 |
+
|
37 |
+
// Custom events
|
38 |
+
.on( 'sortable-init', { 'self': this }, this.sortableItem );
|
39 |
+
|
40 |
+
$( window )
|
41 |
+
.on( 'cherry-ui-elements-init', { 'self': this }, this.sortableItem );
|
42 |
+
|
43 |
+
this.triggers();
|
44 |
+
},
|
45 |
+
|
46 |
+
triggers: function( $target ) {
|
47 |
+
$( 'body' ).trigger( 'sortable-init' );
|
48 |
+
|
49 |
+
if ( $target ) {
|
50 |
+
$( window ).trigger( 'cherry-ui-elements-init', { 'target': $target } );
|
51 |
+
}
|
52 |
+
|
53 |
+
return this;
|
54 |
+
},
|
55 |
+
|
56 |
+
addItem: function( event ) {
|
57 |
+
var self = event.data.self,
|
58 |
+
$list = $( this ).prev( self.repeaterListClass ),
|
59 |
+
index = $list.data( 'index' ),
|
60 |
+
tmplName = $list.data( 'name' ),
|
61 |
+
rowTemplate = wp.template( tmplName ),
|
62 |
+
widgetId = $list.data( 'widget-id' ),
|
63 |
+
data = { index: index };
|
64 |
+
|
65 |
+
if ( widgetId ) {
|
66 |
+
data.widgetId = widgetId;
|
67 |
+
}
|
68 |
+
|
69 |
+
$list.append( rowTemplate( data ) );
|
70 |
+
|
71 |
+
index++;
|
72 |
+
$list.data( 'index', index );
|
73 |
+
|
74 |
+
self
|
75 |
+
.triggers( $( self.repeaterItemClass + ':last', $list ) )
|
76 |
+
.stopDefaultEvent( event );
|
77 |
+
},
|
78 |
+
|
79 |
+
removeItem: function( event ) {
|
80 |
+
var self = event.data.self,
|
81 |
+
$list = $( this ).closest( self.repeaterListClass );
|
82 |
+
|
83 |
+
self.applyChanges( $list );
|
84 |
+
|
85 |
+
$( this ).closest( self.repeaterItemClass ).remove();
|
86 |
+
|
87 |
+
self
|
88 |
+
.triggers()
|
89 |
+
.stopDefaultEvent( event );
|
90 |
+
},
|
91 |
+
|
92 |
+
toggleItem: function( event ) {
|
93 |
+
var self = event.data.self,
|
94 |
+
$container = $( this ).closest( self.repeaterItemClass );
|
95 |
+
|
96 |
+
$container.toggleClass( self.minItemClass );
|
97 |
+
|
98 |
+
self.stopDefaultEvent( event );
|
99 |
+
},
|
100 |
+
|
101 |
+
sortableItem: function( event ) {
|
102 |
+
var self = event.data.self,
|
103 |
+
$list = $( self.repeaterListClass ),
|
104 |
+
$this,
|
105 |
+
initFlag;
|
106 |
+
|
107 |
+
$list.each( function( indx, element ) {
|
108 |
+
$this = $( element );
|
109 |
+
initFlag = $( element ).data( 'sortable-init' );
|
110 |
+
|
111 |
+
if ( ! initFlag ) {
|
112 |
+
$this.sortable( {
|
113 |
+
items: self.repeaterItemClass,
|
114 |
+
handle: self.repeaterItemHandleClass,
|
115 |
+
cursor: 'move',
|
116 |
+
scrollSensitivity: 40,
|
117 |
+
forcePlaceholderSize: true,
|
118 |
+
forceHelperSize: false,
|
119 |
+
helper: 'clone',
|
120 |
+
opacity: 0.65,
|
121 |
+
placeholder: self.sortablePlaceholderClass,
|
122 |
+
create: function() {
|
123 |
+
$this.data( 'sortable-init', true );
|
124 |
+
},
|
125 |
+
update: function( event ) {
|
126 |
+
var target = $( event.target );
|
127 |
+
|
128 |
+
self.applyChanges( target );
|
129 |
+
}
|
130 |
+
} );
|
131 |
+
} else {
|
132 |
+
$this.sortable( 'refresh' );
|
133 |
+
}
|
134 |
+
} );
|
135 |
+
},
|
136 |
+
|
137 |
+
changeWrapperLable: function( event ) {
|
138 |
+
var self = event.data.self,
|
139 |
+
$list = $( self.repeaterListClass ),
|
140 |
+
titleFilds = $list.data( 'title-field' ),
|
141 |
+
$this = $( this ),
|
142 |
+
value,
|
143 |
+
parentItem;
|
144 |
+
|
145 |
+
if ( titleFilds && $this.closest( '.' + titleFilds + '-wrap' )[0] ) {
|
146 |
+
value = $this.val(),
|
147 |
+
parentItem = $this.closest( self.repeaterItemClass );
|
148 |
+
|
149 |
+
$( self.repeaterTitleClass, parentItem ).html( value );
|
150 |
+
}
|
151 |
+
|
152 |
+
self.stopDefaultEvent( event );
|
153 |
+
},
|
154 |
+
|
155 |
+
applyChanges: function( target ) {
|
156 |
+
if ( undefined !== wp.customize ) {
|
157 |
+
$( 'input[name]:first, select[name]:first', target ).change();
|
158 |
+
}
|
159 |
+
|
160 |
+
return this;
|
161 |
+
},
|
162 |
+
|
163 |
+
stopDefaultEvent: function( event ) {
|
164 |
+
event.preventDefault();
|
165 |
+
event.stopImmediatePropagation();
|
166 |
+
event.stopPropagation();
|
167 |
+
|
168 |
+
return this;
|
169 |
+
}
|
170 |
+
};
|
171 |
+
|
172 |
+
CherryJsCore.ui_elements.repeater.init();
|
173 |
+
|
174 |
+
}( jQuery, window.CherryJsCore ) );
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-select/assets/min/ui-select.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){"use strict";t.utilites.namespace("ui_elements.select"),t.ui_elements.select={init:function(){e(window).on("cherry-ui-elements-init",this.render
|
1 |
+
!function(e,t){"use strict";t.utilites.namespace("ui_elements.select"),t.ui_elements.select={init:function(){e(document).on("ready",this.render),e(window).on("cherry-ui-elements-init",this.render)},render:function(t){var i=t._target?t._target:e("body");e('.cherry-ui-select[data-filter="true"]:not([name*="__i__"]), .cherry-ui-select[multiple]:not([name*="__i__"])',i).each(function(){var t=e(this);t.select2({placeholder:t.attr("placeholder")})})}},t.ui_elements.select.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-select/assets/ui-select.js
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
-
/**
|
2 |
-
* Select
|
3 |
-
*/
|
4 |
-
( function( $, CherryJsCore ){
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.select');
|
8 |
-
CherryJsCore.ui_elements.select = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
1 |
+
/**
|
2 |
+
* Select
|
3 |
+
*/
|
4 |
+
( function( $, CherryJsCore ){
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.select');
|
8 |
+
CherryJsCore.ui_elements.select = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.render );
|
12 |
+
},
|
13 |
+
render: function ( event, data ) {
|
14 |
+
var target = ( event._target ) ? event._target : $( 'body' );
|
15 |
+
|
16 |
+
// init filter-select
|
17 |
+
$( '.cherry-ui-select[data-filter="true"]:not([name*="__i__"]), .cherry-ui-select[multiple]:not([name*="__i__"])', target ).each( function() {
|
18 |
+
var $this = $( this );
|
19 |
+
|
20 |
+
$this.select2( {
|
21 |
+
placeholder: $this.attr('placeholder')
|
22 |
+
} );
|
23 |
+
} );
|
24 |
+
}
|
25 |
+
};
|
26 |
+
|
27 |
+
CherryJsCore.ui_elements.select.init();
|
28 |
+
|
29 |
+
}( jQuery, window.CherryJsCore ) );
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-slider/assets/min/ui-slider.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,
|
1 |
+
!function(e,i){"use strict";i.utilites.namespace("ui_elements.slider"),i.ui_elements.slider={init:function(){e(document).on("ready",this.render.bind(this))},render:function(){e("body").on("input change",".cherry-slider-unit, .cherry-ui-stepper-input",this.changeHandler)},changeHandler:function(){var i=e(this),r=i.hasClass("cherry-slider-unit")?".cherry-ui-stepper-input":".cherry-slider-unit",n=i.closest(".cherry-slider-wrap");e(r,n).val(i.val())}},i.ui_elements.slider.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-slider/assets/ui-slider.js
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
/**
|
2 |
-
* Slider
|
3 |
-
*/
|
4 |
-
( function( $, CherryJsCore ) {
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.slider');
|
8 |
-
CherryJsCore.ui_elements.slider = {
|
9 |
-
init: function () {
|
10 |
-
$( document ).on('ready', this.render.bind( this
|
11 |
-
},
|
12 |
-
render: function ( event, data ) {
|
13 |
-
$(
|
14 |
-
},
|
15 |
-
changeHandler: function () {
|
16 |
-
var $this = $( this ),
|
17 |
-
targetClass = ( ! $this.hasClass('cherry-slider-unit') ) ? '.cherry-slider-unit' : '.cherry-ui-stepper-input' ,
|
18 |
-
$sliderWrapper = $this.closest('.cherry-slider-wrap');
|
19 |
-
|
20 |
-
$( targetClass, $sliderWrapper ).val( $this.val() );
|
21 |
-
}
|
22 |
-
};
|
23 |
-
|
24 |
-
CherryJsCore.ui_elements.slider.init();
|
25 |
-
}( jQuery, window.CherryJsCore ) );
|
1 |
+
/**
|
2 |
+
* Slider
|
3 |
+
*/
|
4 |
+
( function( $, CherryJsCore ) {
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.slider');
|
8 |
+
CherryJsCore.ui_elements.slider = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render.bind( this ) );
|
11 |
+
},
|
12 |
+
render: function ( event, data ) {
|
13 |
+
$( 'body' ).on( 'input change', '.cherry-slider-unit, .cherry-ui-stepper-input', this.changeHandler );
|
14 |
+
},
|
15 |
+
changeHandler: function () {
|
16 |
+
var $this = $( this ),
|
17 |
+
targetClass = ( ! $this.hasClass('cherry-slider-unit') ) ? '.cherry-slider-unit' : '.cherry-ui-stepper-input' ,
|
18 |
+
$sliderWrapper = $this.closest('.cherry-slider-wrap');
|
19 |
+
|
20 |
+
$( targetClass, $sliderWrapper ).val( $this.val() );
|
21 |
+
}
|
22 |
+
};
|
23 |
+
|
24 |
+
CherryJsCore.ui_elements.slider.init();
|
25 |
+
}( jQuery, window.CherryJsCore ) );
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/assets/min/ui-switcher.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e,t){"use strict";t.utilites.namespace("ui_elements.switcher"),t.ui_elements.switcher={init:function(){e(window).on("cherry-ui-elements-init",this.render.
|
1 |
+
!function(e,t){"use strict";t.utilites.namespace("ui_elements.switcher"),t.ui_elements.switcher={init:function(){e(document).on("ready",this.render.bind(this)),e(window).on("cherry-ui-elements-init",this.master_slave_init)},render:function(){e("body").on("click",".cherry-switcher-wrap",this.swiperHandler)},master_slave_init:function(t){var i=t._target?t._target:e("body");e(".cherry-switcher-wrap",i).each(function(){var t=e(this),r=e(".cherry-input-switcher",t),a="true"===r.val(),n="undefined"!=typeof r.data("true-slave")?r.data("true-slave"):null,s="undefined"!=typeof r.data("false-slave")?r.data("false-slave"):null;a?e("."+s,i)[0]&&e("."+s,i).hide():e("."+n,i)[0]&&e("."+n,i).hide()})},swiperHandler:function(){var t=e(this),i=e(".cherry-input-switcher",t),r=i.data("true-slave"),a=i.data("false-slave");t.toggleClass("selected"),i.attr("value","true"===i.val()?!1:!0).trigger("change").trigger("switcher_disabled_event",[r,a]),e("."+r).toggle(),e("."+a).toggle()}},t.ui_elements.switcher.init()}(jQuery,window.CherryJsCore);
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/assets/ui-switcher.js
CHANGED
@@ -1,60 +1,57 @@
|
|
1 |
-
/**
|
2 |
-
* Switcher
|
3 |
-
*/
|
4 |
-
( function( $, CherryJsCore ){
|
5 |
-
'use strict';
|
6 |
-
|
7 |
-
CherryJsCore.utilites.namespace('ui_elements.switcher');
|
8 |
-
CherryJsCore.ui_elements.switcher = {
|
9 |
-
init: function () {
|
10 |
-
$(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
if ( $( '.' + false_slave, target )[0] ) {
|
32 |
-
$( '.' + false_slave, target ).hide();
|
33 |
-
}
|
34 |
-
}
|
35 |
-
});
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
CherryJsCore.ui_elements.switcher.init();
|
60 |
-
}( jQuery, window.CherryJsCore ) );
|
1 |
+
/**
|
2 |
+
* Switcher
|
3 |
+
*/
|
4 |
+
( function( $, CherryJsCore ){
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
CherryJsCore.utilites.namespace('ui_elements.switcher');
|
8 |
+
CherryJsCore.ui_elements.switcher = {
|
9 |
+
init: function () {
|
10 |
+
$( document ).on( 'ready', this.render.bind( this ) );
|
11 |
+
$( window ).on( 'cherry-ui-elements-init', this.master_slave_init );
|
12 |
+
},
|
13 |
+
render: function ( event, data ) {
|
14 |
+
$( 'body' ).on( 'click', '.cherry-switcher-wrap', this.swiperHandler );
|
15 |
+
},
|
16 |
+
master_slave_init: function ( event, data ) {
|
17 |
+
var target = ( event._target ) ? event._target : $( 'body' );
|
18 |
+
|
19 |
+
$( '.cherry-switcher-wrap', target ).each( function() {
|
20 |
+
var $this = $( this ),
|
21 |
+
$input = $( '.cherry-input-switcher', $this ),
|
22 |
+
inputValue = ( $input.val() === 'true' ),
|
23 |
+
true_slave = ( typeof $input.data('true-slave') !== 'undefined' ) ? $input.data( 'true-slave' ) : null,
|
24 |
+
false_slave = ( typeof $input.data('false-slave') !== 'undefined' ) ? $input.data( 'false-slave' ) : null;
|
25 |
+
|
26 |
+
if ( ! inputValue ) {
|
27 |
+
if ( $( '.' + true_slave, target )[0] ) {
|
28 |
+
$( '.' + true_slave, target ).hide();
|
29 |
+
}
|
30 |
+
} else {
|
31 |
+
if ( $( '.' + false_slave, target )[0] ) {
|
32 |
+
$( '.' + false_slave, target ).hide();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
});
|
36 |
+
},
|
37 |
+
swiperHandler: function ( event ) {
|
38 |
+
var $this = $( this ),
|
39 |
+
$input = $( '.cherry-input-switcher', $this ),
|
40 |
+
true_slave = $input.data('true-slave'),
|
41 |
+
false_slave = $input.data('false-slave');
|
42 |
+
|
43 |
+
$this.toggleClass('selected');
|
44 |
+
|
45 |
+
$input
|
46 |
+
.attr( 'value', ( $input.val() === 'true' ) ? false : true )
|
47 |
+
.trigger( 'change' )
|
48 |
+
.trigger( 'switcher_disabled_event', [ true_slave, false_slave ] );
|
49 |
+
|
50 |
+
|
51 |
+
$( '.' + true_slave ).toggle();
|
52 |
+
$( '.' + false_slave ).toggle();
|
53 |
+
}
|
54 |
+
};
|
55 |
+
|
56 |
+
CherryJsCore.ui_elements.switcher.init();
|
57 |
+
}( jQuery, window.CherryJsCore ) );
|
|
|
|
|
|
cherry-framework/modules/cherry-ui-elements/inc/ui-elements/ui-switcher/ui-switcher.php
CHANGED
@@ -1,107 +1,110 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for the building ui swither elements .
|
4 |
-
*
|
5 |
-
* @package Cherry_Framework
|
6 |
-
* @subpackage Class
|
7 |
-
* @author Cherry Team <support@cherryframework.com>
|
8 |
-
* @copyright Copyright (c) 2012 - 2015, Cherry Team
|
9 |
-
* @link http://www.cherryframework.com/
|
10 |
-
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
-
*/
|
12 |
-
|
13 |
-
// If this file is called directly, abort.
|
14 |
-
if ( ! defined( 'WPINC' ) ) {
|
15 |
-
die;
|
16 |
-
}
|
17 |
-
|
18 |
-
if ( ! class_exists( 'UI_Switcher' ) ) {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Class for the building UI_Switcher elements.
|
22 |
-
*/
|
23 |
-
class UI_Switcher extends UI_Element implements I_UI {
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Default settings
|
27 |
-
*
|
28 |
-
* @var array
|
29 |
-
*/
|
30 |
-
private $defaults_settings = array(
|
31 |
-
'id' => 'cherry-ui-swither-id',
|
32 |
-
'name' => 'cherry-ui-swither-name',
|
33 |
-
'value' => 'true',
|
34 |
-
'toggle' => array(
|
35 |
-
'true_toggle' => 'On',
|
36 |
-
'false_toggle' => 'Off',
|
37 |
-
'true_slave' => '',
|
38 |
-
'false_slave' => '',
|
39 |
-
),
|
40 |
-
'style' => 'normal',
|
41 |
-
'label' => '',
|
42 |
-
'class' => '',
|
43 |
-
'master' => '',
|
44 |
-
);
|
45 |
-
/**
|
46 |
-
* Constructor method for the UI_Switcher class.
|
47 |
-
*
|
48 |
-
* @since 4.0.0
|
49 |
-
*/
|
50 |
-
function __construct( $args = array() ) {
|
51 |
-
$this->defaults_settings['id'] = 'cherry-ui-swither-'.uniqid();
|
52 |
-
$this->settings = wp_parse_args( $args, $this->defaults_settings );
|
53 |
-
|
54 |
-
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Render html UI_Switcher.
|
59 |
-
*
|
60 |
-
* @since 4.0.0
|
61 |
-
*/
|
62 |
-
public function render() {
|
63 |
-
$data_attr_line = ( ! empty( $this->settings['toggle']['true_slave'] ) ) ? 'data-true-slave="' . $this->settings['toggle']['true_slave'] . '"' : '';
|
64 |
-
$data_attr_line .= ( ! empty( $this->settings['toggle']['false_slave'] ) ) ? ' data-false-slave="' . $this->settings['toggle']['false_slave'] . '"' : '';
|
65 |
-
|
66 |
-
$html = '';
|
67 |
-
|
68 |
-
$master_class = ! empty( $this->settings['master'] ) && isset( $this->settings['master'] ) ? esc_html( $this->settings['master'] ) : '';
|
69 |
-
|
70 |
-
$html .= '<div class="cherry-ui-container ' . $master_class . '">';
|
71 |
-
if ( '' !== $this->settings['label'] ) {
|
72 |
-
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
|
73 |
-
}
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$html .= '<
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
'
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
'
|
103 |
-
'
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for the building ui swither elements .
|
4 |
+
*
|
5 |
+
* @package Cherry_Framework
|
6 |
+
* @subpackage Class
|
7 |
+
* @author Cherry Team <support@cherryframework.com>
|
8 |
+
* @copyright Copyright (c) 2012 - 2015, Cherry Team
|
9 |
+
* @link http://www.cherryframework.com/
|
10 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
// If this file is called directly, abort.
|
14 |
+
if ( ! defined( 'WPINC' ) ) {
|
15 |
+
die;
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( ! class_exists( 'UI_Switcher' ) ) {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Class for the building UI_Switcher elements.
|
22 |
+
*/
|
23 |
+
class UI_Switcher extends UI_Element implements I_UI {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Default settings
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
private $defaults_settings = array(
|
31 |
+
'id' => 'cherry-ui-swither-id',
|
32 |
+
'name' => 'cherry-ui-swither-name',
|
33 |
+
'value' => 'true',
|
34 |
+
'toggle' => array(
|
35 |
+
'true_toggle' => 'On',
|
36 |
+
'false_toggle' => 'Off',
|
37 |
+
'true_slave' => '',
|
38 |
+
'false_slave' => '',
|
39 |
+
),
|
40 |
+
'style' => 'normal',
|
41 |
+
'label' => '',
|
42 |
+
'class' => '',
|
43 |
+
'master' => '',
|
44 |
+
);
|
45 |
+
/**
|
46 |
+
* Constructor method for the UI_Switcher class.
|
47 |
+
*
|
48 |
+
* @since 4.0.0
|
49 |
+
*/
|
50 |
+
function __construct( $args = array() ) {
|
51 |
+
$this->defaults_settings['id'] = 'cherry-ui-swither-'.uniqid();
|
52 |
+
$this->settings = wp_parse_args( $args, $this->defaults_settings );
|
53 |
+
|
54 |
+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Render html UI_Switcher.
|
59 |
+
*
|
60 |
+
* @since 4.0.0
|
61 |
+
*/
|
62 |
+
public function render() {
|
63 |
+
$data_attr_line = ( ! empty( $this->settings['toggle']['true_slave'] ) ) ? 'data-true-slave="' . $this->settings['toggle']['true_slave'] . '"' : '';
|
64 |
+
$data_attr_line .= ( ! empty( $this->settings['toggle']['false_slave'] ) ) ? ' data-false-slave="' . $this->settings['toggle']['false_slave'] . '"' : '';
|
65 |
+
|
66 |
+
$html = '';
|
67 |
+
|
68 |
+
$master_class = ! empty( $this->settings['master'] ) && isset( $this->settings['master'] ) ? esc_html( $this->settings['master'] ) : '';
|
69 |
+
|
70 |
+
$html .= '<div class="cherry-ui-container ' . $master_class . '">';
|
71 |
+
if ( '' !== $this->settings['label'] ) {
|
72 |
+
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
|
73 |
+
}
|
74 |
+
|
75 |
+
$selected_class = filter_var( $this->settings['value'], FILTER_VALIDATE_BOOLEAN ) ? 'selected' : '';
|
76 |
+
|
77 |
+
$html .= '<div class="cherry-switcher-wrap size-' . esc_attr( $this->settings['style'] ) . ' ' . esc_attr( $this->settings['class'] ) . ' ' . $selected_class .'">';
|
78 |
+
$html .= '<label class="sw-enable"><span>' . esc_html( $this->settings['toggle']['true_toggle'] ) . '</span></label>';
|
79 |
+
$html .= '<label class="sw-disable"><span>' . esc_html( $this->settings['toggle']['false_toggle'] ) . '</span></label>';
|
80 |
+
$html .= '<span class="state-marker"></span>';
|
81 |
+
$html .= '<input id="' . esc_attr( $this->settings['id'] ) . '" type="hidden" class="cherry-input-switcher" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( 'true', $this->settings['value'], false ) . ' value="' . esc_html( $this->settings['value'] ) . '" ' . $data_attr_line . '>';
|
82 |
+
$html .= '</div>';
|
83 |
+
$html .= '</div>';
|
84 |
+
|
85 |
+
return $html;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Enqueue javascript and stylesheet UI_Switcher.
|
90 |
+
*
|
91 |
+
* @since 4.0.0
|
92 |
+
*/
|
93 |
+
public static function enqueue_assets() {
|
94 |
+
wp_enqueue_script(
|
95 |
+
'ui-switcher-min',
|
96 |
+
esc_url( Cherry_Core::base_url( 'assets/min/ui-switcher.min.js', __FILE__ ) ),
|
97 |
+
array( 'jquery' ),
|
98 |
+
'1.0.0',
|
99 |
+
true
|
100 |
+
);
|
101 |
+
wp_enqueue_style(
|
102 |
+
'ui-switcher-min',
|
103 |
+
esc_url( Cherry_Core::base_url( 'assets/min/ui-switcher.min.css', __FILE__ ) ),
|
104 |
+
array(),
|
105 |
+
'1.0.0',
|
106 |
+
'all'
|
107 |
+
);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
cherry-sidebars.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Cherry Sidebars
|
4 |
* Plugin URI: http://www.cherryframework.com/
|
5 |
* Description: Plugin for creating and managing sidebars in WordPress.
|
6 |
-
* Version: 1.0.
|
7 |
* Author: Template Monster
|
8 |
* Author URI: http://www.templatemonster.com/
|
9 |
* Text Domain: cherry-sidebars
|
@@ -63,7 +63,6 @@ if ( ! class_exists( 'Cherry_Sidebars' ) ) {
|
|
63 |
|
64 |
// Load the core functions/classes required by the rest of the theme.
|
65 |
add_action( 'after_setup_theme', array( $this, 'get_core' ), 1 );
|
66 |
-
add_action( 'after_setup_theme', array( 'Cherry_Core', 'load_all_modules' ), 2 );
|
67 |
|
68 |
// Internationalize the text strings used.
|
69 |
add_action( 'plugins_loaded', array( $this, 'lang' ), 3 );
|
@@ -166,12 +165,17 @@ if ( ! class_exists( 'Cherry_Sidebars' ) ) {
|
|
166 |
*/
|
167 |
do_action( 'cherry_core_before' );
|
168 |
|
|
|
|
|
169 |
if ( null !== $this->core ) {
|
170 |
return $this->core;
|
171 |
}
|
172 |
|
173 |
-
if (
|
174 |
-
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
$this->core = new Cherry_Core( array(
|
3 |
* Plugin Name: Cherry Sidebars
|
4 |
* Plugin URI: http://www.cherryframework.com/
|
5 |
* Description: Plugin for creating and managing sidebars in WordPress.
|
6 |
+
* Version: 1.0.3
|
7 |
* Author: Template Monster
|
8 |
* Author URI: http://www.templatemonster.com/
|
9 |
* Text Domain: cherry-sidebars
|
63 |
|
64 |
// Load the core functions/classes required by the rest of the theme.
|
65 |
add_action( 'after_setup_theme', array( $this, 'get_core' ), 1 );
|
|
|
66 |
|
67 |
// Internationalize the text strings used.
|
68 |
add_action( 'plugins_loaded', array( $this, 'lang' ), 3 );
|
165 |
*/
|
166 |
do_action( 'cherry_core_before' );
|
167 |
|
168 |
+
global $chery_core_version;
|
169 |
+
|
170 |
if ( null !== $this->core ) {
|
171 |
return $this->core;
|
172 |
}
|
173 |
|
174 |
+
if ( 0 < sizeof( $chery_core_version ) ) {
|
175 |
+
$core_paths = array_values( $chery_core_version );
|
176 |
+
require_once( $core_paths[0] );
|
177 |
+
} else {
|
178 |
+
die( 'Class Cherry_Core not found' );
|
179 |
}
|
180 |
|
181 |
$this->core = new Cherry_Core( array(
|
includes/class-cherry-include-sidebars.php
CHANGED
@@ -1,97 +1,97 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class for including custom sidebars.
|
4 |
-
*
|
5 |
-
* @package Cherry_Sidebars
|
6 |
-
* @author Template Monster
|
7 |
-
* @license GPL-3.0+
|
8 |
-
* @copyright 2002-2016, Template Monster
|
9 |
-
*/
|
10 |
-
|
11 |
-
if ( ! class_exists( 'Cherry_Include_Sidebars' ) ) {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Class for including custom sidebars.
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
class Cherry_Include_Sidebars {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Holds the instances of this class.
|
22 |
-
*
|
23 |
-
* @since 1.0.0
|
24 |
-
* @var object
|
25 |
-
*/
|
26 |
-
private static $instance = null;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Sets up our actions/filters.
|
30 |
-
*
|
31 |
-
* @since 1.0.0
|
32 |
-
* @return void
|
33 |
-
*/
|
34 |
-
public function __construct() {
|
35 |
-
add_filter( 'sidebars_widgets', array( $this, 'set_custom_sidebar' ), 10, 1 );
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Set custom sidebar in global array $wp_registered_sidebars.
|
40 |
-
*
|
41 |
-
* @since 1.0.0
|
42 |
-
* @param array $widgets Sidebar widgets.
|
43 |
-
* @return array
|
44 |
-
*/
|
45 |
-
public function set_custom_sidebar( $widgets ) {
|
46 |
-
global $wp_registered_sidebars, $wp_query;
|
47 |
-
|
48 |
-
if ( ! is_object( $wp_query ) ) {
|
49 |
-
return $widgets;
|
50 |
-
}
|
51 |
-
|
52 |
-
$object_id = get_queried_object_id();
|
53 |
-
|
54 |
-
if ( function_exists( 'is_shop' ) ) {
|
55 |
-
if ( is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
|
56 |
-
$object_id = wc_get_page_id( 'shop' );
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
$post_sidebars = get_post_meta( apply_filters( 'cherry_sidebar_manager_object_id', $object_id ), 'post_sidebar', true );
|
61 |
-
|
62 |
-
if ( $post_sidebars && ! empty( $post_sidebars ) ) {
|
63 |
-
|
64 |
-
$instance = new Cherry_Sidebar_Utils();
|
65 |
-
$custom_sidebar = $instance->get_custom_sidebar_array();
|
66 |
-
|
67 |
-
foreach ( $post_sidebars as $sidebar => $sidebar_value ) {
|
68 |
-
if ( ! empty( $sidebar_value ) &&
|
69 |
-
( array_key_exists( $sidebar_value, $wp_registered_sidebars ) || array_key_exists( $sidebar_value, $custom_sidebar ) ) &&
|
70 |
-
isset( $widgets[ $sidebar ] ) ) {
|
71 |
-
$widgets[ $sidebar ] = $widgets[ $sidebar_value ];
|
72 |
-
}
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
return $widgets;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Returns the instance.
|
81 |
-
*
|
82 |
-
* @since 1.0.0
|
83 |
-
* @return object
|
84 |
-
*/
|
85 |
-
public static function get_instance() {
|
86 |
-
|
87 |
-
// If the single instance hasn't been set, set it now.
|
88 |
-
if ( null == self::$instance ) {
|
89 |
-
self::$instance = new self;
|
90 |
-
}
|
91 |
-
|
92 |
-
return self::$instance;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
Cherry_Include_Sidebars::get_instance();
|
97 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for including custom sidebars.
|
4 |
+
*
|
5 |
+
* @package Cherry_Sidebars
|
6 |
+
* @author Template Monster
|
7 |
+
* @license GPL-3.0+
|
8 |
+
* @copyright 2002-2016, Template Monster
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! class_exists( 'Cherry_Include_Sidebars' ) ) {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class for including custom sidebars.
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
*/
|
18 |
+
class Cherry_Include_Sidebars {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Holds the instances of this class.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
* @var object
|
25 |
+
*/
|
26 |
+
private static $instance = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Sets up our actions/filters.
|
30 |
+
*
|
31 |
+
* @since 1.0.0
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
add_filter( 'sidebars_widgets', array( $this, 'set_custom_sidebar' ), 10, 1 );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Set custom sidebar in global array $wp_registered_sidebars.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
* @param array $widgets Sidebar widgets.
|
43 |
+
* @return array
|
44 |
+
*/
|
45 |
+
public function set_custom_sidebar( $widgets ) {
|
46 |
+
global $wp_registered_sidebars, $wp_query;
|
47 |
+
|
48 |
+
if ( ! is_object( $wp_query ) ) {
|
49 |
+
return $widgets;
|
50 |
+
}
|
51 |
+
|
52 |
+
$object_id = get_queried_object_id();
|
53 |
+
|
54 |
+
if ( function_exists( 'is_shop' ) ) {
|
55 |
+
if ( is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
|
56 |
+
$object_id = wc_get_page_id( 'shop' );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
$post_sidebars = get_post_meta( apply_filters( 'cherry_sidebar_manager_object_id', $object_id ), 'post_sidebar', true );
|
61 |
+
|
62 |
+
if ( $post_sidebars && ! empty( $post_sidebars ) ) {
|
63 |
+
|
64 |
+
$instance = new Cherry_Sidebar_Utils();
|
65 |
+
$custom_sidebar = $instance->get_custom_sidebar_array();
|
66 |
+
|
67 |
+
foreach ( $post_sidebars as $sidebar => $sidebar_value ) {
|
68 |
+
if ( ! empty( $sidebar_value ) &&
|
69 |
+
( array_key_exists( $sidebar_value, $wp_registered_sidebars ) || array_key_exists( $sidebar_value, $custom_sidebar ) ) &&
|
70 |
+
isset( $widgets[ $sidebar ] ) ) {
|
71 |
+
$widgets[ $sidebar ] = $widgets[ $sidebar_value ];
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
return $widgets;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns the instance.
|
81 |
+
*
|
82 |
+
* @since 1.0.0
|
83 |
+
* @return object
|
84 |
+
*/
|
85 |
+
public static function get_instance() {
|
86 |
+
|
87 |
+
// If the single instance hasn't been set, set it now.
|
88 |
+
if ( null == self::$instance ) {
|
89 |
+
self::$instance = new self;
|
90 |
+
}
|
91 |
+
|
92 |
+
return self::$instance;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
Cherry_Include_Sidebars::get_instance();
|
97 |
+
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Contributors: TemplateMonster 2002
|
4 |
Tags: sidebar, sidebar manager, cherry framework, custom sidebars, widget area, group widgets, page custom sidebar, post custom sidebar
|
5 |
Requires at least: 4.4
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -42,9 +42,19 @@ The plugin can be useful for certain posts or pages, where you want your content
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
45 |
= 1.0.2 =
|
46 |
-
|
47 |
-
* FIX:
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
= 1.0.0 =
|
50 |
|
3 |
Contributors: TemplateMonster 2002
|
4 |
Tags: sidebar, sidebar manager, cherry framework, custom sidebars, widget area, group widgets, page custom sidebar, post custom sidebar
|
5 |
Requires at least: 4.4
|
6 |
+
Tested up to: 4.6
|
7 |
+
Stable tag: 1.0.3
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.0.3 =
|
46 |
+
|
47 |
+
* UPD: Update Cherry Framework up to 1.1.1
|
48 |
+
|
49 |
= 1.0.2 =
|
50 |
+
|
51 |
+
* FIX: Custom sidebars option name
|
52 |
+
|
53 |
+
= 1.0.1 =
|
54 |
+
|
55 |
+
* FIX: sidebar_widgets filter should check WP_Query (WooCommerce Ajax navigation)
|
56 |
+
* FIX: assets initialization
|
57 |
+
* FIX: remove duplicates from allowed post types list
|
58 |
|
59 |
= 1.0.0 =
|
60 |
|