Version Description
- Code architecture update:
- Add
object_id
property to the meta box object. Used to connect the meta box to the post object. Not heavily used yet. - Add RWMB_Meta_Box_Registry and RWMB_Field_Registry to store all registered meta boxes and fields. Used to future access these objects. Use internally only. 3rd-party code should not use it as it's still experimental and can change in the future.
- Deprecated RWMB_Core::get_meta_boxes() due to the meta box registry above. This function was made for internally use only. 3rd-party code should not rely on it.
- Add magic method __get to the meta box object to quick access to meta box configuration.
- Add
- UI update:
- Make the field label bold (similar to WordPress settings page).
- Increase margin between fields and change color for remove clone button (also reduce minus size)
- Remove style for checkbox (default is good).
- Improve styles for checkbox/radio list
- A little smaller padding for select box. Also remove default size for select[multiple]
- Add a little space between the map canvas and the "Find Address" button
- Media fields:
- Media field update: Hidden field for media fields now no longer disabled. If media field js not loaded properly, code will default to hidden field and process accordingly. Issue #1088.
- Better and simpler way to handle HTML file upload using
media_handle_upload
function. - Rewrite JS for "file", simpler and modular. Also fix bug when add/remove items that doesn't toggle the Add more link correctly.
- Improve JS code for media field, using MediaList instead of item views (Backbone JS code).
- Add support for image sizes in image_advanced and image_upload. Default is thumbnail. Fixes #425.
- Clone:
- Add new parameter
add_button
for the add new clone button text. Better than use filter. - Fix position for remove clone button in RTL languages
- Update margin between clones and set clone placeholder
- Add new parameter
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.11 |
Comparing to | |
See all releases |
Code changes from version 4.10.4 to 4.11
- css/checkbox.css +0 -4
- css/file.css +0 -16
- css/image-advanced.css +11 -2
- css/input-list.css +13 -14
- css/jqueryui/jquery-ui-timepicker-addon.min.css +3 -3
- css/map.css +1 -0
- css/select.css +1 -1
- css/style-rtl.css +5 -1
- css/style.css +11 -4
- inc/autoloader.php +4 -2
- inc/clone.php +1 -1
- inc/core.php +25 -57
- inc/field-registry.php +61 -0
- inc/field.php +18 -6
- inc/fields/autocomplete.php +19 -20
- inc/fields/checkbox.php +0 -17
- inc/fields/date.php +1 -1
- inc/fields/datetime.php +4 -3
- inc/fields/file.php +25 -59
- inc/fields/image-advanced.php +9 -1
- inc/fields/map.php +4 -2
- inc/fields/media.php +10 -7
- inc/fields/select.php +0 -2
- inc/functions.php +69 -11
- inc/helper.php +0 -136
- inc/loader.php +4 -3
- inc/media-modal.php +3 -6
- inc/meta-box-registry.php +48 -0
- inc/meta-box.php +55 -35
- inc/templates/image-advanced.php +3 -3
- inc/templates/media.php +1 -1
- inc/templates/video.php +1 -1
- inc/wpml.php +29 -23
- js/clone.js +2 -2
- js/color.js +1 -1
- js/file.js +70 -122
- js/image-advanced.js +6 -2
- js/jqueryui/jquery-ui-timepicker-addon-i18n.min.js +3 -3
- js/jqueryui/jquery-ui-timepicker-addon.min.js +4 -4
- js/map.js +12 -7
- js/media.js +187 -164
- meta-box.php +1 -1
- readme.txt +36 -2
css/checkbox.css
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
.rwmb-checkbox-wrapper .description {
|
2 |
-
display: inline;
|
3 |
-
font-style: normal;
|
4 |
-
}
|
|
|
|
|
|
|
|
css/file.css
CHANGED
@@ -34,19 +34,3 @@
|
|
34 |
.rwmb-file-wrapper .rwmb-uploaded .rwmb-info {
|
35 |
margin: 0 0 2px 2px;
|
36 |
}
|
37 |
-
.rwmb-file-wrapper .rwmb-uploaded li.removed {
|
38 |
-
width: 0;
|
39 |
-
margin: 0;
|
40 |
-
opacity: 0;
|
41 |
-
}
|
42 |
-
.rwmb-file-wrapper .rwmb-uploaded li.removed:after {
|
43 |
-
content: ' ';
|
44 |
-
position: absolute;
|
45 |
-
top: 0;
|
46 |
-
left: 0;
|
47 |
-
right: 0;
|
48 |
-
bottom: 0;
|
49 |
-
z-index: 2;
|
50 |
-
opacity: .4;
|
51 |
-
background-color: #f00;
|
52 |
-
}
|
34 |
.rwmb-file-wrapper .rwmb-uploaded .rwmb-info {
|
35 |
margin: 0 0 2px 2px;
|
36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/image-advanced.css
CHANGED
@@ -5,11 +5,20 @@
|
|
5 |
padding: 0;
|
6 |
margin: 0 5px 5px 0;
|
7 |
box-sizing: border-box;
|
8 |
-
width: 150px;
|
9 |
}
|
10 |
-
.rwmb-image-item .rwmb-media-preview
|
|
|
11 |
width: 150px;
|
12 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
.rwmb-image-item .dashicons {
|
14 |
font-size: 20px;
|
15 |
width: 20px;
|
5 |
padding: 0;
|
6 |
margin: 0 5px 5px 0;
|
7 |
box-sizing: border-box;
|
|
|
8 |
}
|
9 |
+
.rwmb-image-item.thumbnail .rwmb-media-preview,
|
10 |
+
.rwmb-image-item.thumbnail{
|
11 |
width: 150px;
|
12 |
}
|
13 |
+
.rwmb-image-item.medium .rwmb-media-preview,
|
14 |
+
.rwmb-image-item.medium {
|
15 |
+
width: 300px;
|
16 |
+
}
|
17 |
+
.rwmb-image-item.large .rwmb-media-preview,
|
18 |
+
.rwmb-image-item.large {
|
19 |
+
width: 1024px;
|
20 |
+
}
|
21 |
+
|
22 |
.rwmb-image-item .dashicons {
|
23 |
font-size: 20px;
|
24 |
width: 20px;
|
css/input-list.css
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
-
.rwmb-input-list
|
2 |
-
|
|
|
3 |
}
|
4 |
-
|
5 |
-
|
6 |
-
display:inline-block;
|
7 |
-
margin-right: 0;
|
8 |
-
line-height:1;
|
9 |
}
|
10 |
-
.rwmb-input-list
|
11 |
-
margin-
|
12 |
}
|
13 |
-
|
14 |
.rwmb-input-list.inline {
|
15 |
-
|
16 |
}
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
}
|
1 |
+
.rwmb-input-list {
|
2 |
+
margin: 0;
|
3 |
+
line-height: 1.8;
|
4 |
}
|
5 |
+
li .rwmb-input-list {
|
6 |
+
margin-left: 20px;
|
|
|
|
|
|
|
7 |
}
|
8 |
+
.rwmb-input-list li {
|
9 |
+
margin-bottom: 0;
|
10 |
}
|
|
|
11 |
.rwmb-input-list.inline {
|
12 |
+
line-height: inherit;
|
13 |
}
|
14 |
+
.rwmb-input-list.inline li {
|
15 |
+
display: inline-block;
|
16 |
+
}
|
17 |
+
.rwmb-input-list.inline li:not(:last-child) {
|
18 |
+
margin-right: 20px;
|
19 |
}
|
css/jqueryui/jquery-ui-timepicker-addon.min.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
/*! jQuery Timepicker Addon - v1.
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
-
* Copyright (c)
|
4 |
|
5 |
-
.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{float:left;clear:left;padding:0 0 0 5px}.ui-timepicker-div dl dd{margin:0 10px 10px 40%}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0 0;border:0;margin:0;padding:0}.ui-timepicker-rtl{direction:rtl}.ui-timepicker-rtl dl{text-align:right;padding:0 5px 0 0}.ui-timepicker-rtl dl dt{float:right;clear:right}.ui-timepicker-rtl dl dd{margin:0 40% 10px 10px}
|
1 |
+
/*! jQuery Timepicker Addon - v1.6.3 - 2016-04-20
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
+
* Copyright (c) 2016 Trent Richardson; Licensed MIT */
|
4 |
|
5 |
+
.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{float:left;clear:left;padding:0 0 0 5px}.ui-timepicker-div dl dd{margin:0 10px 10px 40%}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0 0;border:0;margin:0;padding:0}.ui-timepicker-div .ui_tpicker_unit_hide{display:none}.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input{background:0 0;color:inherit;border:0;outline:0;border-bottom:solid 1px #555;width:95%}.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus{border-bottom-color:#aaa}.ui-timepicker-rtl{direction:rtl}.ui-timepicker-rtl dl{text-align:right;padding:0 5px 0 0}.ui-timepicker-rtl dl dt{float:right;clear:right}.ui-timepicker-rtl dl dd{margin:0 40% 10px 10px}.ui-timepicker-div.ui-timepicker-oneLine{padding-right:2px}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,.ui-timepicker-div.ui-timepicker-oneLine dt{display:none}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label{display:block;padding-top:2px}.ui-timepicker-div.ui-timepicker-oneLine dl{text-align:right}.ui-timepicker-div.ui-timepicker-oneLine dl dd,.ui-timepicker-div.ui-timepicker-oneLine dl dd>div{display:inline-block;margin:0}.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before{content:':';display:inline-block}.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before{content:'.';display:inline-block}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{display:none}
|
css/map.css
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
.rwmb-map-canvas {
|
2 |
width: 100%;
|
3 |
height: 400px;
|
|
|
4 |
}
|
1 |
.rwmb-map-canvas {
|
2 |
width: 100%;
|
3 |
height: 400px;
|
4 |
+
margin-bottom: 10px;
|
5 |
}
|
css/select.css
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
min-width: 160px;
|
3 |
}
|
4 |
.rwmb-select option {
|
5 |
-
padding: .
|
6 |
}
|
7 |
.rwmb-select-all-none {
|
8 |
display: block;
|
2 |
min-width: 160px;
|
3 |
}
|
4 |
.rwmb-select option {
|
5 |
+
padding: .5em 1em;;
|
6 |
}
|
7 |
.rwmb-select-all-none {
|
8 |
display: block;
|
css/style-rtl.css
CHANGED
@@ -4,4 +4,8 @@
|
|
4 |
label.error{
|
5 |
padding-left: auto;
|
6 |
padding-right: 3px;
|
7 |
-
}
|
|
|
|
|
|
|
|
4 |
label.error{
|
5 |
padding-left: auto;
|
6 |
padding-right: 3px;
|
7 |
+
}
|
8 |
+
.rwmb-button.remove-clone {
|
9 |
+
right: auto;
|
10 |
+
left: 0;
|
11 |
+
}
|
css/style.css
CHANGED
@@ -10,10 +10,10 @@
|
|
10 |
.rwmb-field:after {
|
11 |
clear: both;
|
12 |
}
|
13 |
-
.rwmb-field {
|
14 |
*zoom: 1;
|
15 |
|
16 |
-
margin: 0 0
|
17 |
}
|
18 |
.rwmb-label,
|
19 |
.rwmb-input {
|
@@ -23,6 +23,9 @@
|
|
23 |
.rwmb-label {
|
24 |
width: 25%;
|
25 |
}
|
|
|
|
|
|
|
26 |
.rwmb-label.required > span {
|
27 |
color: #c00;
|
28 |
font-weight: bold;
|
@@ -46,7 +49,7 @@
|
|
46 |
/* Clone */
|
47 |
.rwmb-clone {
|
48 |
min-height: 24px;
|
49 |
-
margin-bottom:
|
50 |
position: relative;
|
51 |
clear: both;
|
52 |
background: #fff;
|
@@ -58,13 +61,17 @@
|
|
58 |
.rwmb-button.remove-clone {
|
59 |
text-decoration: none;
|
60 |
color: #fff;
|
61 |
-
background: #
|
62 |
border-radius: 50%;
|
63 |
display: inline-block;
|
64 |
position: absolute;
|
65 |
top: 0;
|
66 |
right: 0;
|
67 |
}
|
|
|
|
|
|
|
|
|
68 |
.remove-clone:focus {
|
69 |
outline: 0;
|
70 |
box-shadow: none;
|
10 |
.rwmb-field:after {
|
11 |
clear: both;
|
12 |
}
|
13 |
+
.rwmb-field:not(:last-of-type) {
|
14 |
*zoom: 1;
|
15 |
|
16 |
+
margin: 0 0 12px;
|
17 |
}
|
18 |
.rwmb-label,
|
19 |
.rwmb-input {
|
23 |
.rwmb-label {
|
24 |
width: 25%;
|
25 |
}
|
26 |
+
.rwmb-label > label {
|
27 |
+
font-weight: 600;
|
28 |
+
}
|
29 |
.rwmb-label.required > span {
|
30 |
color: #c00;
|
31 |
font-weight: bold;
|
49 |
/* Clone */
|
50 |
.rwmb-clone {
|
51 |
min-height: 24px;
|
52 |
+
margin-bottom: 12px;
|
53 |
position: relative;
|
54 |
clear: both;
|
55 |
background: #fff;
|
61 |
.rwmb-button.remove-clone {
|
62 |
text-decoration: none;
|
63 |
color: #fff;
|
64 |
+
background: #e74c3c;
|
65 |
border-radius: 50%;
|
66 |
display: inline-block;
|
67 |
position: absolute;
|
68 |
top: 0;
|
69 |
right: 0;
|
70 |
}
|
71 |
+
.rwmb-button.remove-clone .dashicons {
|
72 |
+
font-size: 14px;
|
73 |
+
line-height: 20px;
|
74 |
+
}
|
75 |
.remove-clone:focus {
|
76 |
outline: 0;
|
77 |
box-shadow: none;
|
inc/autoloader.php
CHANGED
@@ -82,11 +82,12 @@ class RWMB_Autoloader {
|
|
82 |
// Core.
|
83 |
'core',
|
84 |
'clone',
|
85 |
-
'helper',
|
86 |
'meta-box',
|
|
|
87 |
'validation',
|
88 |
-
'
|
89 |
'media-modal',
|
|
|
90 |
|
91 |
// Walkers.
|
92 |
'walkers/walker',
|
@@ -96,6 +97,7 @@ class RWMB_Autoloader {
|
|
96 |
|
97 |
// Fields.
|
98 |
'field',
|
|
|
99 |
|
100 |
'fields/multiple-values',
|
101 |
'fields/autocomplete',
|
82 |
// Core.
|
83 |
'core',
|
84 |
'clone',
|
|
|
85 |
'meta-box',
|
86 |
+
'meta-box-registry',
|
87 |
'validation',
|
88 |
+
'sanitizer',
|
89 |
'media-modal',
|
90 |
+
'wpml',
|
91 |
|
92 |
// Walkers.
|
93 |
'walkers/walker',
|
97 |
|
98 |
// Fields.
|
99 |
'field',
|
100 |
+
'field-registry',
|
101 |
|
102 |
'fields/multiple-values',
|
103 |
'fields/autocomplete',
|
inc/clone.php
CHANGED
@@ -94,7 +94,7 @@ class RWMB_Clone {
|
|
94 |
if ( ! $field['clone'] ) {
|
95 |
return '';
|
96 |
}
|
97 |
-
$text = RWMB_Field::filter( 'add_clone_button_text',
|
98 |
return '<a href="#" class="rwmb-button button-primary add-clone">' . esc_html( $text ) . '</a>';
|
99 |
}
|
100 |
|
94 |
if ( ! $field['clone'] ) {
|
95 |
return '';
|
96 |
}
|
97 |
+
$text = RWMB_Field::filter( 'add_clone_button_text', $field['add_button'] );
|
98 |
return '<a href="#" class="rwmb-button button-primary add-clone">' . esc_html( $text ) . '</a>';
|
99 |
}
|
100 |
|
inc/core.php
CHANGED
@@ -11,21 +11,13 @@
|
|
11 |
* @package Meta Box
|
12 |
*/
|
13 |
class RWMB_Core {
|
14 |
-
|
15 |
/**
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @var array
|
19 |
*/
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
* Register hooks.
|
24 |
-
*/
|
25 |
-
public function __construct() {
|
26 |
-
$plugin = 'meta-box/meta-box.php';
|
27 |
-
add_filter( "plugin_action_links_$plugin", array( $this, 'plugin_links' ) );
|
28 |
-
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
29 |
add_action( 'init', array( $this, 'register_meta_boxes' ) );
|
30 |
add_action( 'edit_page_form', array( $this, 'fix_page_template' ) );
|
31 |
}
|
@@ -38,18 +30,11 @@ class RWMB_Core {
|
|
38 |
* @return array
|
39 |
*/
|
40 |
public function plugin_links( $links ) {
|
41 |
-
$links[] = '<a href="https://metabox.io/docs/">' .
|
42 |
-
$links[] = '<a href="https://metabox.io/plugins/">' .
|
43 |
return $links;
|
44 |
}
|
45 |
|
46 |
-
/**
|
47 |
-
* Load plugin translation.
|
48 |
-
*/
|
49 |
-
public function load_textdomain() {
|
50 |
-
load_plugin_textdomain( 'meta-box', false, plugin_basename( RWMB_DIR ) . '/languages/' );
|
51 |
-
}
|
52 |
-
|
53 |
/**
|
54 |
* Register meta boxes.
|
55 |
* Advantages:
|
@@ -57,43 +42,14 @@ class RWMB_Core {
|
|
57 |
* - no need to check for class existences.
|
58 |
*/
|
59 |
public function register_meta_boxes() {
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
* Get registered meta boxes via a filter.
|
68 |
-
* Advantages:
|
69 |
-
* - prevents duplicated global variables.
|
70 |
-
* - allows users to remove/hide registered meta boxes.
|
71 |
-
*/
|
72 |
-
public static function get_meta_boxes() {
|
73 |
-
if ( null === self::$meta_boxes ) {
|
74 |
-
self::$meta_boxes = apply_filters( 'rwmb_meta_boxes', array() );
|
75 |
-
self::$meta_boxes = empty( self::$meta_boxes ) || ! is_array( self::$meta_boxes ) ? array() : self::$meta_boxes;
|
76 |
}
|
77 |
-
return self::$meta_boxes;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Get all registered fields.
|
82 |
-
*
|
83 |
-
* @return array
|
84 |
-
*/
|
85 |
-
public static function get_fields() {
|
86 |
-
$fields = array();
|
87 |
-
|
88 |
-
foreach ( self::$meta_boxes as $meta_box ) {
|
89 |
-
foreach ( $meta_box['fields'] as $field ) {
|
90 |
-
if ( ! empty( $field['id'] ) ) {
|
91 |
-
$fields[ $field['id'] ] = $field;
|
92 |
-
}
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
return $fields;
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -113,4 +69,16 @@ class RWMB_Core {
|
|
113 |
delete_post_meta( $post->ID, '_wp_page_template' );
|
114 |
}
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
11 |
* @package Meta Box
|
12 |
*/
|
13 |
class RWMB_Core {
|
|
|
14 |
/**
|
15 |
+
* Initialization.
|
|
|
|
|
16 |
*/
|
17 |
+
public function init() {
|
18 |
+
load_plugin_textdomain( 'meta-box', false, plugin_basename( RWMB_DIR ) . '/languages/' );
|
19 |
|
20 |
+
add_filter( 'plugin_action_links_meta-box/meta-box.php', array( $this, 'plugin_links' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
add_action( 'init', array( $this, 'register_meta_boxes' ) );
|
22 |
add_action( 'edit_page_form', array( $this, 'fix_page_template' ) );
|
23 |
}
|
30 |
* @return array
|
31 |
*/
|
32 |
public function plugin_links( $links ) {
|
33 |
+
$links[] = '<a href="https://metabox.io/docs/">' . esc_html__( 'Documentation', 'meta-box' ) . '</a>';
|
34 |
+
$links[] = '<a href="https://metabox.io/plugins/">' . esc_html__( 'Extensions', 'meta-box' ) . '</a>';
|
35 |
return $links;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* Register meta boxes.
|
40 |
* Advantages:
|
42 |
* - no need to check for class existences.
|
43 |
*/
|
44 |
public function register_meta_boxes() {
|
45 |
+
$configs = apply_filters( 'rwmb_meta_boxes', array() );
|
46 |
+
$meta_boxes = rwmb_get_registry( 'meta_box' );
|
47 |
+
$fields = rwmb_get_registry( 'field' );
|
48 |
+
foreach ( $configs as $config ) {
|
49 |
+
$meta_box = new RW_Meta_Box( $config );
|
50 |
+
$meta_boxes->add( $meta_box );
|
51 |
+
$fields->add_from_meta_box( $meta_box );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
69 |
delete_post_meta( $post->ID, '_wp_page_template' );
|
70 |
}
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get registered meta boxes via a filter.
|
75 |
+
*
|
76 |
+
* @deprecated No longer used. Keep for backward-compatibility with extensions.
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
public static function get_meta_boxes() {
|
81 |
+
$meta_boxes = rwmb_get_registry( 'meta_box' )->all();
|
82 |
+
return wp_list_pluck( $meta_boxes, 'meta_box' );
|
83 |
+
}
|
84 |
}
|
inc/field-registry.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A registry for storing all fields.
|
4 |
+
*
|
5 |
+
* @link https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html
|
6 |
+
* @package Meta Box
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Field registry class.
|
11 |
+
*/
|
12 |
+
class RWMB_Field_Registry {
|
13 |
+
/**
|
14 |
+
* Internal data storage.
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
private $data = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Add all fields in a meta box to the registry.
|
22 |
+
*
|
23 |
+
* @param RW_Meta_Box $meta_box Meta box object.
|
24 |
+
*/
|
25 |
+
public function add_from_meta_box( RW_Meta_Box $meta_box ) {
|
26 |
+
foreach ( $meta_box->fields as $field ) {
|
27 |
+
foreach ( $meta_box->post_types as $post_type ) {
|
28 |
+
$this->add( $field, $post_type );
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Add a single field to the registry.
|
35 |
+
*
|
36 |
+
* @param array $field Field configuration.
|
37 |
+
* @param string $post_type Post type which the field belongs to.
|
38 |
+
*/
|
39 |
+
public function add( $field, $post_type ) {
|
40 |
+
if ( ! isset( $field['id'] ) ) {
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
if ( empty( $this->data[ $post_type ] ) ) {
|
44 |
+
$this->data[ $post_type ] = array();
|
45 |
+
}
|
46 |
+
$this->data[ $post_type ][ $field['id'] ] = $field;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Retrieve a field.
|
51 |
+
*
|
52 |
+
* @param string $id A meta box instance id.
|
53 |
+
* @param string $post_type Post type which the field belongs to.
|
54 |
+
*
|
55 |
+
* @return bool|array False or field configuration.
|
56 |
+
*/
|
57 |
+
public function get( $id, $post_type = null ) {
|
58 |
+
$post_type = $post_type ? $post_type : get_post_type();
|
59 |
+
return isset( $this->data[ $post_type ][ $id ] ) ? $this->data[ $post_type ][ $id ] : false;
|
60 |
+
}
|
61 |
+
}
|
inc/field.php
CHANGED
@@ -48,13 +48,11 @@ abstract class RWMB_Field {
|
|
48 |
* That ensures the returned value are always been applied filters.
|
49 |
* This method is not meant to be overwritten in specific fields.
|
50 |
*
|
51 |
-
* @param array $field
|
52 |
-
* @param bool $saved
|
|
|
53 |
*/
|
54 |
-
public static function show( $field, $saved ) {
|
55 |
-
$post = get_post();
|
56 |
-
$post_id = isset( $post->ID ) ? $post->ID : 0;
|
57 |
-
|
58 |
$meta = self::call( $field, 'meta', $post_id, $saved );
|
59 |
$meta = self::filter( 'field_meta', $meta, $field, $saved );
|
60 |
|
@@ -213,6 +211,17 @@ abstract class RWMB_Field {
|
|
213 |
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run).
|
214 |
$meta = ! $saved ? $field['std'] : $meta;
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
// Escape attributes.
|
217 |
$meta = self::call( $field, 'esc_meta', $meta );
|
218 |
|
@@ -290,6 +299,8 @@ abstract class RWMB_Field {
|
|
290 |
|
291 |
// If field is multiple, value is saved as multiple entries in the database (WordPress behaviour).
|
292 |
if ( $field['multiple'] ) {
|
|
|
|
|
293 |
$new_values = array_diff( $new, $old );
|
294 |
foreach ( $new_values as $new_value ) {
|
295 |
add_post_meta( $post_id, $name, $new_value, false );
|
@@ -329,6 +340,7 @@ abstract class RWMB_Field {
|
|
329 |
'clone' => false,
|
330 |
'max_clone' => 0,
|
331 |
'sort_clone' => false,
|
|
|
332 |
|
333 |
'class' => '',
|
334 |
'disabled' => false,
|
48 |
* That ensures the returned value are always been applied filters.
|
49 |
* This method is not meant to be overwritten in specific fields.
|
50 |
*
|
51 |
+
* @param array $field Field parameters.
|
52 |
+
* @param bool $saved Whether the meta box is saved at least once.
|
53 |
+
* @param int $post_id Post ID.
|
54 |
*/
|
55 |
+
public static function show( $field, $saved, $post_id = 0 ) {
|
|
|
|
|
|
|
56 |
$meta = self::call( $field, 'meta', $post_id, $saved );
|
57 |
$meta = self::filter( 'field_meta', $meta, $field, $saved );
|
58 |
|
211 |
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run).
|
212 |
$meta = ! $saved ? $field['std'] : $meta;
|
213 |
|
214 |
+
// Ensue multiple fields are arrays.
|
215 |
+
if ( $field['multiple'] ) {
|
216 |
+
if ( $field['clone'] ) {
|
217 |
+
$meta = (array) $meta;
|
218 |
+
foreach ( $meta as $key => $m ) {
|
219 |
+
$meta[ $key ] = (array) $m;
|
220 |
+
}
|
221 |
+
} else {
|
222 |
+
$meta = (array) $meta;
|
223 |
+
}
|
224 |
+
}
|
225 |
// Escape attributes.
|
226 |
$meta = self::call( $field, 'esc_meta', $meta );
|
227 |
|
299 |
|
300 |
// If field is multiple, value is saved as multiple entries in the database (WordPress behaviour).
|
301 |
if ( $field['multiple'] ) {
|
302 |
+
$old = (array) $old;
|
303 |
+
$new = (array) $new;
|
304 |
$new_values = array_diff( $new, $old );
|
305 |
foreach ( $new_values as $new_value ) {
|
306 |
add_post_meta( $post_id, $name, $new_value, false );
|
340 |
'clone' => false,
|
341 |
'max_clone' => 0,
|
342 |
'sort_clone' => false,
|
343 |
+
'add_button' => __( '+ Add more', 'meta-box' ),
|
344 |
|
345 |
'class' => '',
|
346 |
'disabled' => false,
|
inc/fields/autocomplete.php
CHANGED
@@ -13,7 +13,7 @@ class RWMB_Autocomplete_Field extends RWMB_Multiple_Values_Field {
|
|
13 |
* Enqueue scripts and styles.
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
-
wp_enqueue_style( 'rwmb-autocomplete', RWMB_CSS_URL . 'autocomplete.css',
|
17 |
wp_enqueue_script( 'rwmb-autocomplete', RWMB_JS_URL . 'autocomplete.js', array( 'jquery-ui-autocomplete' ), RWMB_VER, true );
|
18 |
|
19 |
self::localize_script( 'rwmb-autocomplete', 'RWMB_Autocomplete', array(
|
@@ -36,9 +36,9 @@ class RWMB_Autocomplete_Field extends RWMB_Multiple_Values_Field {
|
|
36 |
$field = apply_filters( 'rwmb_autocomplete_field', $field, $meta );
|
37 |
$options = $field['options'];
|
38 |
|
39 |
-
if (
|
40 |
$options = array();
|
41 |
-
foreach (
|
42 |
$options[] = array(
|
43 |
'value' => $value,
|
44 |
'label' => $label,
|
@@ -53,8 +53,8 @@ class RWMB_Autocomplete_Field extends RWMB_Multiple_Values_Field {
|
|
53 |
$html = sprintf(
|
54 |
'<input type="text" class="rwmb-autocomplete-search" size="%s">
|
55 |
<input type="hidden" name="%s" class="rwmb-autocomplete" data-options="%s" disabled>',
|
56 |
-
$field['size'],
|
57 |
-
$field['field_name'],
|
58 |
esc_attr( $options )
|
59 |
);
|
60 |
|
@@ -72,28 +72,27 @@ class RWMB_Autocomplete_Field extends RWMB_Multiple_Values_Field {
|
|
72 |
|
73 |
if ( is_array( $field['options'] ) ) {
|
74 |
foreach ( $field['options'] as $value => $label ) {
|
75 |
-
if ( in_array( $value, $meta ) ) {
|
76 |
-
|
77 |
-
$tpl,
|
78 |
-
$label,
|
79 |
-
__( 'Delete', 'meta-box' ),
|
80 |
-
$field['field_name'],
|
81 |
-
$value
|
82 |
-
);
|
83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
} else {
|
|
|
86 |
foreach ( $meta as $value ) {
|
87 |
-
if ( empty( $value ) ) {
|
88 |
-
continue;
|
89 |
-
}
|
90 |
$label = apply_filters( 'rwmb_autocomplete_result_label', $value, $field );
|
91 |
$html .= sprintf(
|
92 |
$tpl,
|
93 |
-
$label,
|
94 |
-
|
95 |
-
$field['field_name'],
|
96 |
-
$value
|
97 |
);
|
98 |
}
|
99 |
}
|
13 |
* Enqueue scripts and styles.
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
+
wp_enqueue_style( 'rwmb-autocomplete', RWMB_CSS_URL . 'autocomplete.css', '', RWMB_VER );
|
17 |
wp_enqueue_script( 'rwmb-autocomplete', RWMB_JS_URL . 'autocomplete.js', array( 'jquery-ui-autocomplete' ), RWMB_VER, true );
|
18 |
|
19 |
self::localize_script( 'rwmb-autocomplete', 'RWMB_Autocomplete', array(
|
36 |
$field = apply_filters( 'rwmb_autocomplete_field', $field, $meta );
|
37 |
$options = $field['options'];
|
38 |
|
39 |
+
if ( is_array( $field['options'] ) ) {
|
40 |
$options = array();
|
41 |
+
foreach ( $field['options'] as $value => $label ) {
|
42 |
$options[] = array(
|
43 |
'value' => $value,
|
44 |
'label' => $label,
|
53 |
$html = sprintf(
|
54 |
'<input type="text" class="rwmb-autocomplete-search" size="%s">
|
55 |
<input type="hidden" name="%s" class="rwmb-autocomplete" data-options="%s" disabled>',
|
56 |
+
esc_attr( $field['size'] ),
|
57 |
+
esc_attr( $field['field_name'] ),
|
58 |
esc_attr( $options )
|
59 |
);
|
60 |
|
72 |
|
73 |
if ( is_array( $field['options'] ) ) {
|
74 |
foreach ( $field['options'] as $value => $label ) {
|
75 |
+
if ( ! in_array( $value, $meta ) ) {
|
76 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
+
$html .= sprintf(
|
79 |
+
$tpl,
|
80 |
+
esc_html( $label ),
|
81 |
+
esc_html__( 'Delete', 'meta-box' ),
|
82 |
+
esc_attr( $field['field_name'] ),
|
83 |
+
esc_attr( $value )
|
84 |
+
);
|
85 |
}
|
86 |
} else {
|
87 |
+
$meta = array_filter( $meta );
|
88 |
foreach ( $meta as $value ) {
|
|
|
|
|
|
|
89 |
$label = apply_filters( 'rwmb_autocomplete_result_label', $value, $field );
|
90 |
$html .= sprintf(
|
91 |
$tpl,
|
92 |
+
esc_html( $label ),
|
93 |
+
esc_html__( 'Delete', 'meta-box' ),
|
94 |
+
esc_attr( $field['field_name'] ),
|
95 |
+
esc_attr( $value )
|
96 |
);
|
97 |
}
|
98 |
}
|
inc/fields/checkbox.php
CHANGED
@@ -9,13 +9,6 @@
|
|
9 |
* Checkbox field class.
|
10 |
*/
|
11 |
class RWMB_Checkbox_Field extends RWMB_Input_Field {
|
12 |
-
/**
|
13 |
-
* Enqueue scripts and styles.
|
14 |
-
*/
|
15 |
-
public static function admin_enqueue_scripts() {
|
16 |
-
wp_enqueue_style( 'rwmb-checkbox', RWMB_CSS_URL . 'checkbox.css', array(), RWMB_VER );
|
17 |
-
}
|
18 |
-
|
19 |
/**
|
20 |
* Get field HTML.
|
21 |
*
|
@@ -46,16 +39,6 @@ class RWMB_Checkbox_Field extends RWMB_Input_Field {
|
|
46 |
return '';
|
47 |
}
|
48 |
|
49 |
-
/**
|
50 |
-
* Do not show field label description.
|
51 |
-
*
|
52 |
-
* @param array $field Field parameters.
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
public static function label_description( $field ) {
|
56 |
-
return '';
|
57 |
-
}
|
58 |
-
|
59 |
/**
|
60 |
* Format a single value for the helper functions.
|
61 |
*
|
9 |
* Checkbox field class.
|
10 |
*/
|
11 |
class RWMB_Checkbox_Field extends RWMB_Input_Field {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Get field HTML.
|
14 |
*
|
39 |
return '';
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* Format a single value for the helper functions.
|
44 |
*
|
inc/fields/date.php
CHANGED
@@ -14,7 +14,7 @@ class RWMB_Date_Field extends RWMB_Datetime_Field {
|
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
parent::admin_register_scripts();
|
17 |
-
wp_enqueue_style( '
|
18 |
wp_enqueue_script( 'rwmb-date' );
|
19 |
}
|
20 |
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
parent::admin_register_scripts();
|
17 |
+
wp_enqueue_style( 'rwmb-date' );
|
18 |
wp_enqueue_script( 'rwmb-date' );
|
19 |
}
|
20 |
|
inc/fields/datetime.php
CHANGED
@@ -57,10 +57,11 @@ class RWMB_Datetime_Field extends RWMB_Text_Field {
|
|
57 |
$url = RWMB_CSS_URL . 'jqueryui';
|
58 |
wp_register_style( 'jquery-ui-core', "$url/jquery.ui.core.css", array(), '1.8.17' );
|
59 |
wp_register_style( 'jquery-ui-theme', "$url/jquery.ui.theme.css", array(), '1.8.17' );
|
60 |
-
wp_register_style( '
|
61 |
-
wp_register_style( '
|
|
|
62 |
wp_register_style( 'jquery-ui-slider', "$url/jquery.ui.slider.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
|
63 |
-
wp_register_style( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.css", array( '
|
64 |
|
65 |
$url = RWMB_JS_URL . 'jqueryui';
|
66 |
wp_register_script( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '1.5.0', true );
|
57 |
$url = RWMB_CSS_URL . 'jqueryui';
|
58 |
wp_register_style( 'jquery-ui-core', "$url/jquery.ui.core.css", array(), '1.8.17' );
|
59 |
wp_register_style( 'jquery-ui-theme', "$url/jquery.ui.theme.css", array(), '1.8.17' );
|
60 |
+
wp_register_style( 'jquery-ui-datepicker', "$url/jquery.ui.datepicker.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
|
61 |
+
wp_register_style( 'rwmb-date', RWMB_CSS_URL . 'datepicker.css', array( 'jquery-ui-datepicker' ), '1.8.17' );
|
62 |
+
|
63 |
wp_register_style( 'jquery-ui-slider', "$url/jquery.ui.slider.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
|
64 |
+
wp_register_style( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.css", array( 'rwmb-date', 'jquery-ui-slider' ), '1.5.0' );
|
65 |
|
66 |
$url = RWMB_JS_URL . 'jqueryui';
|
67 |
wp_register_script( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '1.5.0', true );
|
inc/fields/file.php
CHANGED
@@ -88,25 +88,18 @@ class RWMB_File_Field extends RWMB_Field {
|
|
88 |
* @return string
|
89 |
*/
|
90 |
public static function html( $meta, $field ) {
|
91 |
-
$
|
|
|
92 |
$i18n_more = apply_filters( 'rwmb_file_add_string', _x( '+ Add new file', 'file upload', 'meta-box' ), $field );
|
93 |
|
94 |
-
|
95 |
-
$html = self::get_uploaded_files( $meta, $field );
|
96 |
-
$classes = 'new-files';
|
97 |
-
if ( ! empty( $field['max_file_uploads'] ) && count( $meta ) >= (int) $field['max_file_uploads'] ) {
|
98 |
-
$classes .= ' hidden';
|
99 |
-
}
|
100 |
|
101 |
// Show form upload.
|
102 |
$html .= sprintf(
|
103 |
-
'<div class="
|
104 |
-
<
|
105 |
-
<div class="file-input"><input type="file" name="%s[]" /></div>
|
106 |
<a class="rwmb-add-file" href="#"><strong>%s</strong></a>
|
107 |
</div>',
|
108 |
-
$classes,
|
109 |
-
$i18n_title,
|
110 |
$field['id'],
|
111 |
$i18n_more
|
112 |
);
|
@@ -125,17 +118,11 @@ class RWMB_File_Field extends RWMB_Field {
|
|
125 |
$reorder_nonce = wp_create_nonce( "rwmb-reorder-files_{$field['id']}" );
|
126 |
$delete_nonce = wp_create_nonce( "rwmb-delete-file_{$field['id']}" );
|
127 |
|
128 |
-
$classes = 'rwmb-uploaded';
|
129 |
-
if ( count( $files ) <= 0 ) {
|
130 |
-
$classes .= ' hidden';
|
131 |
-
}
|
132 |
-
|
133 |
foreach ( (array) $files as $k => $file ) {
|
134 |
$files[ $k ] = self::call( $field, 'file_html', $file );
|
135 |
}
|
136 |
return sprintf(
|
137 |
-
'<ul class="
|
138 |
-
$classes,
|
139 |
$field['id'],
|
140 |
$delete_nonce,
|
141 |
$reorder_nonce,
|
@@ -196,59 +183,38 @@ class RWMB_File_Field extends RWMB_Field {
|
|
196 |
}
|
197 |
|
198 |
$new = array();
|
199 |
-
|
200 |
-
$
|
201 |
-
|
202 |
-
|
|
|
|
|
203 |
}
|
204 |
|
205 |
return array_filter( array_unique( array_merge( (array) $old, $new ) ) );
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
-
*
|
210 |
*
|
211 |
-
* @param
|
212 |
-
* @param int $post Post parent ID.
|
213 |
-
* @return int Attachment ID on success, false on failure.
|
214 |
-
*/
|
215 |
-
protected static function upload( $file, $post ) {
|
216 |
-
$file = wp_handle_upload( $file, array(
|
217 |
-
'test_form' => false,
|
218 |
-
) );
|
219 |
-
if ( ! isset( $file['file'] ) ) {
|
220 |
-
return false;
|
221 |
-
}
|
222 |
-
|
223 |
-
$attachment = wp_insert_attachment( array(
|
224 |
-
'post_mime_type' => $file['type'],
|
225 |
-
'guid' => $file['url'],
|
226 |
-
'post_parent' => $post,
|
227 |
-
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file['file'] ) ),
|
228 |
-
'post_content' => '',
|
229 |
-
), $file['file'], $post );
|
230 |
-
if ( is_wp_error( $attachment ) || ! $attachment ) {
|
231 |
-
return false;
|
232 |
-
}
|
233 |
-
wp_update_attachment_metadata( $attachment, wp_generate_attachment_metadata( $attachment, $file['file'] ) );
|
234 |
-
return $attachment;
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Transform $_FILES from $_FILES['field']['key']['index'] to $_FILES['field']['index']['key'].
|
239 |
*
|
240 |
-
* @
|
241 |
-
* @return array
|
242 |
*/
|
243 |
-
protected static function transform( $
|
244 |
-
|
245 |
-
foreach ( $
|
246 |
foreach ( $list as $index => $value ) {
|
247 |
-
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
}
|
250 |
|
251 |
-
|
|
|
252 |
}
|
253 |
|
254 |
/**
|
88 |
* @return string
|
89 |
*/
|
90 |
public static function html( $meta, $field ) {
|
91 |
+
$meta = (array) $meta;
|
92 |
+
$meta = array_filter( $meta );
|
93 |
$i18n_more = apply_filters( 'rwmb_file_add_string', _x( '+ Add new file', 'file upload', 'meta-box' ), $field );
|
94 |
|
95 |
+
$html = self::get_uploaded_files( $meta, $field );
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
// Show form upload.
|
98 |
$html .= sprintf(
|
99 |
+
'<div class="rwmb-new-files">
|
100 |
+
<div class="rwmb-file-input"><input type="file" name="%s[]" /></div>
|
|
|
101 |
<a class="rwmb-add-file" href="#"><strong>%s</strong></a>
|
102 |
</div>',
|
|
|
|
|
103 |
$field['id'],
|
104 |
$i18n_more
|
105 |
);
|
118 |
$reorder_nonce = wp_create_nonce( "rwmb-reorder-files_{$field['id']}" );
|
119 |
$delete_nonce = wp_create_nonce( "rwmb-delete-file_{$field['id']}" );
|
120 |
|
|
|
|
|
|
|
|
|
|
|
121 |
foreach ( (array) $files as $k => $file ) {
|
122 |
$files[ $k ] = self::call( $field, 'file_html', $file );
|
123 |
}
|
124 |
return sprintf(
|
125 |
+
'<ul class="rwmb-uploaded" data-field_id="%s" data-delete_nonce="%s" data-reorder_nonce="%s" data-force_delete="%s" data-max_file_uploads="%s" data-mime_type="%s">%s</ul>',
|
|
|
126 |
$field['id'],
|
127 |
$delete_nonce,
|
128 |
$reorder_nonce,
|
183 |
}
|
184 |
|
185 |
$new = array();
|
186 |
+
$count = self::transform( $field['id'] );
|
187 |
+
for ( $i = 0; $i <= $count; $i ++ ) {
|
188 |
+
$attachment = media_handle_upload( "{$field['id']}_{$i}", $post_id );
|
189 |
+
if ( ! is_wp_error( $attachment ) ) {
|
190 |
+
$new[] = $attachment;
|
191 |
+
}
|
192 |
}
|
193 |
|
194 |
return array_filter( array_unique( array_merge( (array) $old, $new ) ) );
|
195 |
}
|
196 |
|
197 |
/**
|
198 |
+
* Transform $_FILES from $_FILES['field']['key']['index'] to $_FILES['field_index']['key'].
|
199 |
*
|
200 |
+
* @param string $field_id The field ID.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
*
|
202 |
+
* @return int The number of uploaded files.
|
|
|
203 |
*/
|
204 |
+
protected static function transform( $field_id ) {
|
205 |
+
// @codingStandardsIgnoreLine
|
206 |
+
foreach ( $_FILES[ $field_id ] as $key => $list ) {
|
207 |
foreach ( $list as $index => $value ) {
|
208 |
+
// @codingStandardsIgnoreLine
|
209 |
+
if ( ! isset( $_FILES[ "{$field_id}_{$index}" ] ) ) {
|
210 |
+
$_FILES[ "{$field_id}_{$index}" ] = array();
|
211 |
+
}
|
212 |
+
$_FILES[ "{$field_id}_{$index}" ][ $key ] = $value;
|
213 |
}
|
214 |
}
|
215 |
|
216 |
+
// @codingStandardsIgnoreLine
|
217 |
+
return count( $_FILES[ $field_id ]['name'] );
|
218 |
}
|
219 |
|
220 |
/**
|
inc/fields/image-advanced.php
CHANGED
@@ -27,7 +27,15 @@ class RWMB_Image_Advanced_Field extends RWMB_Media_Field {
|
|
27 |
*/
|
28 |
public static function normalize( $field ) {
|
29 |
$field['mime_type'] = 'image';
|
30 |
-
$field =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
return $field;
|
33 |
}
|
27 |
*/
|
28 |
public static function normalize( $field ) {
|
29 |
$field['mime_type'] = 'image';
|
30 |
+
$field = wp_parse_args( $field, array(
|
31 |
+
'image_size' => 'thumbnail',
|
32 |
+
) );
|
33 |
+
|
34 |
+
$field = parent::normalize( $field );
|
35 |
+
|
36 |
+
$field['js_options'] = wp_parse_args( $field['js_options'], array(
|
37 |
+
'imageSize' => $field['image_size'],
|
38 |
+
) );
|
39 |
|
40 |
return $field;
|
41 |
}
|
inc/fields/map.php
CHANGED
@@ -46,9 +46,10 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
46 |
$html = '<div class="rwmb-map-field">';
|
47 |
|
48 |
$html .= sprintf(
|
49 |
-
'<div class="rwmb-map-canvas" data-default-loc="%s"></div>
|
50 |
<input type="hidden" name="%s" class="rwmb-map-coordinate" value="%s">',
|
51 |
esc_attr( $field['std'] ),
|
|
|
52 |
esc_attr( $field['field_name'] ),
|
53 |
esc_attr( $meta )
|
54 |
);
|
@@ -58,7 +59,7 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
58 |
$html .= sprintf(
|
59 |
'<button class="button rwmb-map-goto-address-button" value="%s">%s</button>',
|
60 |
is_array( $address ) ? implode( ',', $address ) : $address,
|
61 |
-
|
62 |
);
|
63 |
}
|
64 |
|
@@ -79,6 +80,7 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
79 |
$field = wp_parse_args( $field, array(
|
80 |
'std' => '',
|
81 |
'address_field' => '',
|
|
|
82 |
|
83 |
// Default API key, required by Google Maps since June 2016.
|
84 |
// Users should overwrite this key with their own key.
|
46 |
$html = '<div class="rwmb-map-field">';
|
47 |
|
48 |
$html .= sprintf(
|
49 |
+
'<div class="rwmb-map-canvas" data-default-loc="%s" data-region="%s"></div>
|
50 |
<input type="hidden" name="%s" class="rwmb-map-coordinate" value="%s">',
|
51 |
esc_attr( $field['std'] ),
|
52 |
+
esc_attr( $field['region'] ),
|
53 |
esc_attr( $field['field_name'] ),
|
54 |
esc_attr( $meta )
|
55 |
);
|
59 |
$html .= sprintf(
|
60 |
'<button class="button rwmb-map-goto-address-button" value="%s">%s</button>',
|
61 |
is_array( $address ) ? implode( ',', $address ) : $address,
|
62 |
+
esc_html__( 'Find Address', 'meta-box' )
|
63 |
);
|
64 |
}
|
65 |
|
80 |
$field = wp_parse_args( $field, array(
|
81 |
'std' => '',
|
82 |
'address_field' => '',
|
83 |
+
'region' => '',
|
84 |
|
85 |
// Default API key, required by Google Maps since June 2016.
|
86 |
// Users should overwrite this key with their own key.
|
inc/fields/media.php
CHANGED
@@ -14,6 +14,9 @@ class RWMB_Media_Field extends RWMB_File_Field {
|
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
wp_enqueue_media();
|
|
|
|
|
|
|
17 |
wp_enqueue_style( 'rwmb-media', RWMB_CSS_URL . 'media.css', array(), RWMB_VER );
|
18 |
wp_enqueue_script( 'rwmb-media', RWMB_JS_URL . 'media.js', array( 'jquery-ui-sortable', 'underscore', 'backbone', 'media-grid' ), RWMB_VER, true );
|
19 |
|
@@ -104,12 +107,11 @@ class RWMB_Media_Field extends RWMB_File_Field {
|
|
104 |
* @return array
|
105 |
*/
|
106 |
public static function get_attributes( $field, $value = null ) {
|
107 |
-
$attributes
|
108 |
-
$attributes['type']
|
109 |
-
$attributes['name']
|
110 |
-
$attributes['
|
111 |
-
$attributes['
|
112 |
-
$attributes['value'] = $value;
|
113 |
|
114 |
return $attributes;
|
115 |
}
|
@@ -123,7 +125,7 @@ class RWMB_Media_Field extends RWMB_File_Field {
|
|
123 |
$mime_types = wp_get_mime_types();
|
124 |
$extensions = array();
|
125 |
foreach ( $mime_types as $ext => $mime ) {
|
126 |
-
$ext
|
127 |
$extensions[ $mime ] = $ext;
|
128 |
|
129 |
$mime_parts = explode( '/', $mime );
|
@@ -148,6 +150,7 @@ class RWMB_Media_Field extends RWMB_File_Field {
|
|
148 |
* @return array|mixed
|
149 |
*/
|
150 |
public static function value( $new, $old, $post_id, $field ) {
|
|
|
151 |
array_walk( $new, 'absint' );
|
152 |
return array_filter( array_unique( $new ) );
|
153 |
}
|
14 |
*/
|
15 |
public static function admin_enqueue_scripts() {
|
16 |
wp_enqueue_media();
|
17 |
+
if ( ! is_admin() ) {
|
18 |
+
wp_register_script( 'media-grid', includes_url( 'js/media-grid.min.js' ), array( 'media-editor' ), '', true );
|
19 |
+
}
|
20 |
wp_enqueue_style( 'rwmb-media', RWMB_CSS_URL . 'media.css', array(), RWMB_VER );
|
21 |
wp_enqueue_script( 'rwmb-media', RWMB_JS_URL . 'media.js', array( 'jquery-ui-sortable', 'underscore', 'backbone', 'media-grid' ), RWMB_VER, true );
|
22 |
|
107 |
* @return array
|
108 |
*/
|
109 |
public static function get_attributes( $field, $value = null ) {
|
110 |
+
$attributes = parent::get_attributes( $field, $value );
|
111 |
+
$attributes['type'] = 'hidden';
|
112 |
+
$attributes['name'] = $field['clone'] ? str_replace( '[]', '', $attributes['name'] ) : $attributes['name'];
|
113 |
+
$attributes['id'] = false;
|
114 |
+
$attributes['value'] = $value;
|
|
|
115 |
|
116 |
return $attributes;
|
117 |
}
|
125 |
$mime_types = wp_get_mime_types();
|
126 |
$extensions = array();
|
127 |
foreach ( $mime_types as $ext => $mime ) {
|
128 |
+
$ext = explode( '|', $ext );
|
129 |
$extensions[ $mime ] = $ext;
|
130 |
|
131 |
$mime_parts = explode( '/', $mime );
|
150 |
* @return array|mixed
|
151 |
*/
|
152 |
public static function value( $new, $old, $post_id, $field ) {
|
153 |
+
$new = ! is_array( $new ) && is_string( $new ) ? explode( ',', $new ) : $new;
|
154 |
array_walk( $new, 'absint' );
|
155 |
return array_filter( array_unique( $new ) );
|
156 |
}
|
inc/fields/select.php
CHANGED
@@ -53,7 +53,6 @@ class RWMB_Select_Field extends RWMB_Choice_Field {
|
|
53 |
$field = parent::normalize( $field );
|
54 |
$field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize( $field ) : $field;
|
55 |
$field = wp_parse_args( $field, array(
|
56 |
-
'size' => $field['multiple'] ? 5 : 0,
|
57 |
'select_all_none' => false,
|
58 |
) );
|
59 |
|
@@ -72,7 +71,6 @@ class RWMB_Select_Field extends RWMB_Choice_Field {
|
|
72 |
$attributes = parent::get_attributes( $field, $value );
|
73 |
$attributes = wp_parse_args( $attributes, array(
|
74 |
'multiple' => $field['multiple'],
|
75 |
-
'size' => $field['size'],
|
76 |
) );
|
77 |
|
78 |
return $attributes;
|
53 |
$field = parent::normalize( $field );
|
54 |
$field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize( $field ) : $field;
|
55 |
$field = wp_parse_args( $field, array(
|
|
|
56 |
'select_all_none' => false,
|
57 |
) );
|
58 |
|
71 |
$attributes = parent::get_attributes( $field, $value );
|
72 |
$attributes = wp_parse_args( $attributes, array(
|
73 |
'multiple' => $field['multiple'],
|
|
|
74 |
) );
|
75 |
|
76 |
return $attributes;
|
inc/functions.php
CHANGED
@@ -16,20 +16,15 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
|
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function rwmb_meta( $key, $args = array(), $post_id = null ) {
|
19 |
-
$args
|
20 |
-
|
21 |
-
/*
|
22 |
-
* If meta boxes is registered in the backend only, we can't get field's params.
|
23 |
-
* This is for backward compatibility with version < 4.8.0.
|
24 |
-
*/
|
25 |
-
$field = RWMB_Helper::find_field( $key, $post_id );
|
26 |
|
27 |
/*
|
28 |
* If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
|
29 |
* Then fallback to the old method to retrieve meta (which uses get_post_meta() as the latest fallback).
|
30 |
*/
|
31 |
if ( false === $field ) {
|
32 |
-
return apply_filters( 'rwmb_meta',
|
33 |
}
|
34 |
$meta = in_array( $field['type'], array( 'oembed', 'map' ), true ) ?
|
35 |
rwmb_the_value( $key, $args, $post_id, false ) :
|
@@ -38,6 +33,46 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
|
|
38 |
}
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
if ( ! function_exists( 'rwmb_get_value' ) ) {
|
42 |
/**
|
43 |
* Get value of custom field.
|
@@ -51,7 +86,7 @@ if ( ! function_exists( 'rwmb_get_value' ) ) {
|
|
51 |
*/
|
52 |
function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
|
53 |
$args = wp_parse_args( $args );
|
54 |
-
$field =
|
55 |
|
56 |
// Get field value.
|
57 |
$value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
|
@@ -84,7 +119,7 @@ if ( ! function_exists( 'rwmb_the_value' ) ) {
|
|
84 |
*/
|
85 |
function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
|
86 |
$args = wp_parse_args( $args );
|
87 |
-
$field =
|
88 |
|
89 |
if ( ! $field ) {
|
90 |
return '';
|
@@ -109,7 +144,7 @@ if ( ! function_exists( 'rwmb_the_value' ) ) {
|
|
109 |
|
110 |
return $output;
|
111 |
}
|
112 |
-
}// End if().
|
113 |
|
114 |
if ( ! function_exists( 'rwmb_meta_shortcode' ) ) {
|
115 |
/**
|
@@ -136,3 +171,26 @@ if ( ! function_exists( 'rwmb_meta_shortcode' ) ) {
|
|
136 |
|
137 |
add_shortcode( 'rwmb_meta', 'rwmb_meta_shortcode' );
|
138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function rwmb_meta( $key, $args = array(), $post_id = null ) {
|
19 |
+
$args = wp_parse_args( $args );
|
20 |
+
$field = rwmb_get_registry( 'field' )->get( $key, get_post_type( $post_id ) );
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
/*
|
23 |
* If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
|
24 |
* Then fallback to the old method to retrieve meta (which uses get_post_meta() as the latest fallback).
|
25 |
*/
|
26 |
if ( false === $field ) {
|
27 |
+
return apply_filters( 'rwmb_meta', rwmb_meta_legacy( $key, $args, $post_id ) );
|
28 |
}
|
29 |
$meta = in_array( $field['type'], array( 'oembed', 'map' ), true ) ?
|
30 |
rwmb_the_value( $key, $args, $post_id, false ) :
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
if ( ! function_exists( 'rwmb_meta_legacy' ) ) {
|
37 |
+
/**
|
38 |
+
* Get post meta.
|
39 |
+
*
|
40 |
+
* @param string $key Meta key. Required.
|
41 |
+
* @param array $args Array of arguments. Optional.
|
42 |
+
* @param int|null $post_id Post ID. null for current post. Optional.
|
43 |
+
*
|
44 |
+
* @return mixed
|
45 |
+
*/
|
46 |
+
function rwmb_meta_legacy( $key, $args = array(), $post_id = null ) {
|
47 |
+
$args = wp_parse_args( $args, array(
|
48 |
+
'type' => 'text',
|
49 |
+
'multiple' => false,
|
50 |
+
'clone' => false,
|
51 |
+
) );
|
52 |
+
$field = array(
|
53 |
+
'id' => $key,
|
54 |
+
'type' => $args['type'],
|
55 |
+
'clone' => $args['clone'],
|
56 |
+
'multiple' => $args['multiple'],
|
57 |
+
);
|
58 |
+
|
59 |
+
$method = 'get_value';
|
60 |
+
switch ( $args['type'] ) {
|
61 |
+
case 'taxonomy':
|
62 |
+
case 'taxonomy_advanced':
|
63 |
+
$field['taxonomy'] = $args['taxonomy'];
|
64 |
+
break;
|
65 |
+
case 'map':
|
66 |
+
case 'oembed':
|
67 |
+
$method = 'the_value';
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
$field = RWMB_Field::call( 'normalize', $field );
|
71 |
+
|
72 |
+
return RWMB_Field::call( $method, $field, $args, $post_id );
|
73 |
+
}
|
74 |
+
} // End if().
|
75 |
+
|
76 |
if ( ! function_exists( 'rwmb_get_value' ) ) {
|
77 |
/**
|
78 |
* Get value of custom field.
|
86 |
*/
|
87 |
function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
|
88 |
$args = wp_parse_args( $args );
|
89 |
+
$field = rwmb_get_registry( 'field' )->get( $field_id, get_post_type( $post_id ) );
|
90 |
|
91 |
// Get field value.
|
92 |
$value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
|
119 |
*/
|
120 |
function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
|
121 |
$args = wp_parse_args( $args );
|
122 |
+
$field = rwmb_get_registry( 'field' )->get( $field_id, get_post_type( $post_id ) );
|
123 |
|
124 |
if ( ! $field ) {
|
125 |
return '';
|
144 |
|
145 |
return $output;
|
146 |
}
|
147 |
+
} // End if().
|
148 |
|
149 |
if ( ! function_exists( 'rwmb_meta_shortcode' ) ) {
|
150 |
/**
|
171 |
|
172 |
add_shortcode( 'rwmb_meta', 'rwmb_meta_shortcode' );
|
173 |
}
|
174 |
+
|
175 |
+
if ( ! function_exists( 'rwmb_get_registry' ) ) {
|
176 |
+
/**
|
177 |
+
* Get the registry by type.
|
178 |
+
* Always return the same instance of the registry.
|
179 |
+
*
|
180 |
+
* @param string $type Registry type.
|
181 |
+
*
|
182 |
+
* @return object
|
183 |
+
*/
|
184 |
+
function rwmb_get_registry( $type ) {
|
185 |
+
static $data = array();
|
186 |
+
|
187 |
+
$type = str_replace( array( '-', '_' ), ' ', $type );
|
188 |
+
$class = 'RWMB_' . ucwords( $type ) . '_Registry';
|
189 |
+
$class = str_replace( ' ', '_', $class );
|
190 |
+
if ( ! isset( $data[ $type ] ) ) {
|
191 |
+
$data[ $type ] = new $class;
|
192 |
+
}
|
193 |
+
|
194 |
+
return $data[ $type ];
|
195 |
+
}
|
196 |
+
}
|
inc/helper.php
DELETED
@@ -1,136 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The helper class.
|
4 |
-
*
|
5 |
-
* @package Meta Box
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Wrapper class for helper functions.
|
10 |
-
*/
|
11 |
-
class RWMB_Helper {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Stores all registered fields.
|
15 |
-
*
|
16 |
-
* @var array
|
17 |
-
*/
|
18 |
-
private static $fields = array();
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Hash all fields into an indexed array for search.
|
22 |
-
*
|
23 |
-
* @param string $post_type Post type.
|
24 |
-
*/
|
25 |
-
public static function hash_fields( $post_type ) {
|
26 |
-
self::$fields[ $post_type ] = array();
|
27 |
-
|
28 |
-
$meta_boxes = RWMB_Core::get_meta_boxes();
|
29 |
-
foreach ( $meta_boxes as $meta_box ) {
|
30 |
-
$meta_box = RW_Meta_Box::normalize( $meta_box );
|
31 |
-
if ( ! in_array( $post_type, $meta_box['post_types'], true ) ) {
|
32 |
-
continue;
|
33 |
-
}
|
34 |
-
foreach ( $meta_box['fields'] as $field ) {
|
35 |
-
if ( ! empty( $field['id'] ) ) {
|
36 |
-
self::$fields[ $post_type ][ $field['id'] ] = $field;
|
37 |
-
}
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Find field by field ID.
|
44 |
-
* This function finds field in meta boxes registered by 'rwmb_meta_boxes' filter.
|
45 |
-
*
|
46 |
-
* @param string $field_id Field ID.
|
47 |
-
* @param int $post_id Post ID.
|
48 |
-
* @return array|false Field params (array) if success. False otherwise.
|
49 |
-
*/
|
50 |
-
public static function find_field( $field_id, $post_id = null ) {
|
51 |
-
$post_type = get_post_type( $post_id );
|
52 |
-
if ( empty( self::$fields[ $post_type ] ) ) {
|
53 |
-
self::hash_fields( $post_type );
|
54 |
-
}
|
55 |
-
$fields = self::$fields[ $post_type ];
|
56 |
-
if ( ! isset( $fields[ $field_id ] ) ) {
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
$field = $fields[ $field_id ];
|
60 |
-
return RWMB_Field::call( 'normalize', $field );
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Get post meta.
|
65 |
-
*
|
66 |
-
* @param string $key Meta key. Required.
|
67 |
-
* @param array $args Array of arguments. Optional.
|
68 |
-
* @param int|null $post_id Post ID. null for current post. Optional.
|
69 |
-
*
|
70 |
-
* @return mixed
|
71 |
-
*/
|
72 |
-
public static function meta( $key, $args = array(), $post_id = null ) {
|
73 |
-
$post_id = empty( $post_id ) ? get_the_ID() : $post_id;
|
74 |
-
$args = wp_parse_args( $args, array(
|
75 |
-
'type' => 'text',
|
76 |
-
'multiple' => false,
|
77 |
-
'clone' => false,
|
78 |
-
) );
|
79 |
-
// Always set 'multiple' true for following field types.
|
80 |
-
if ( in_array( $args['type'], array(
|
81 |
-
'checkbox_list',
|
82 |
-
'autocomplete',
|
83 |
-
'file',
|
84 |
-
'file_advanced',
|
85 |
-
'file_upload',
|
86 |
-
'image',
|
87 |
-
'image_advanced',
|
88 |
-
'image_upload',
|
89 |
-
'plupload_image',
|
90 |
-
'thickbox_image',
|
91 |
-
), true ) ) {
|
92 |
-
$args['multiple'] = true;
|
93 |
-
}
|
94 |
-
|
95 |
-
$field = array(
|
96 |
-
'id' => $key,
|
97 |
-
'type' => $args['type'],
|
98 |
-
'clone' => $args['clone'],
|
99 |
-
'multiple' => $args['multiple'],
|
100 |
-
);
|
101 |
-
|
102 |
-
switch ( $args['type'] ) {
|
103 |
-
case 'taxonomy_advanced':
|
104 |
-
if ( empty( $args['taxonomy'] ) ) {
|
105 |
-
break;
|
106 |
-
}
|
107 |
-
$meta = get_post_meta( $post_id, $key, ! $args['multiple'] );
|
108 |
-
$term_ids = wp_parse_id_list( $meta );
|
109 |
-
// Allow to pass more arguments to "get_terms".
|
110 |
-
$func_args = wp_parse_args( array(
|
111 |
-
'include' => $term_ids,
|
112 |
-
'hide_empty' => false,
|
113 |
-
), $args );
|
114 |
-
unset( $func_args['type'], $func_args['taxonomy'], $func_args['multiple'] );
|
115 |
-
$meta = get_terms( $args['taxonomy'], $func_args );
|
116 |
-
break;
|
117 |
-
case 'taxonomy':
|
118 |
-
$meta = empty( $args['taxonomy'] ) ? array() : get_the_terms( $post_id, $args['taxonomy'] );
|
119 |
-
break;
|
120 |
-
case 'map':
|
121 |
-
$field = array(
|
122 |
-
'id' => $key,
|
123 |
-
'multiple' => false,
|
124 |
-
'clone' => false,
|
125 |
-
);
|
126 |
-
$meta = RWMB_Map_Field::the_value( $field, $args, $post_id );
|
127 |
-
break;
|
128 |
-
case 'oembed':
|
129 |
-
$meta = RWMB_OEmbed_Field::the_value( $field, $args, $post_id );
|
130 |
-
break;
|
131 |
-
default:
|
132 |
-
$meta = RWMB_Field::call( 'get_value', $field, $args, $post_id );
|
133 |
-
}
|
134 |
-
return apply_filters( 'rwmb_meta', $meta, $key, $args, $post_id );
|
135 |
-
}
|
136 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/loader.php
CHANGED
@@ -18,7 +18,7 @@ class RWMB_Loader {
|
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
-
define( 'RWMB_VER', '4.
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
@@ -43,7 +43,7 @@ class RWMB_Loader {
|
|
43 |
public static function get_path( $path = '' ) {
|
44 |
// Plugin base path.
|
45 |
$path = wp_normalize_path( untrailingslashit( $path ) );
|
46 |
-
$themes_dir = wp_normalize_path( untrailingslashit( dirname(
|
47 |
|
48 |
// Default URL.
|
49 |
$url = plugins_url( '', $path . '/' . basename( $path ) . '.php' );
|
@@ -80,7 +80,8 @@ class RWMB_Loader {
|
|
80 |
$autoloader->register();
|
81 |
|
82 |
// Plugin core.
|
83 |
-
new RWMB_Core;
|
|
|
84 |
|
85 |
if ( is_admin() ) {
|
86 |
// Validation module.
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
+
define( 'RWMB_VER', '4.11' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
43 |
public static function get_path( $path = '' ) {
|
44 |
// Plugin base path.
|
45 |
$path = wp_normalize_path( untrailingslashit( $path ) );
|
46 |
+
$themes_dir = wp_normalize_path( untrailingslashit( dirname( get_stylesheet_directory() ) ) );
|
47 |
|
48 |
// Default URL.
|
49 |
$url = plugins_url( '', $path . '/' . basename( $path ) . '.php' );
|
80 |
$autoloader->register();
|
81 |
|
82 |
// Plugin core.
|
83 |
+
$core = new RWMB_Core;
|
84 |
+
$core->init();
|
85 |
|
86 |
if ( is_admin() ) {
|
87 |
// Validation module.
|
inc/media-modal.php
CHANGED
@@ -32,13 +32,10 @@ class RWMB_Media_Modal {
|
|
32 |
* Get list of custom fields and store in the current object for future use.
|
33 |
*/
|
34 |
public function get_fields() {
|
35 |
-
$meta_boxes =
|
36 |
foreach ( $meta_boxes as $meta_box ) {
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
if ( $this->is_in_modal( $meta_box ) ) {
|
41 |
-
$this->fields = array_merge( $this->fields, array_values( $meta_box['fields'] ) );
|
42 |
}
|
43 |
}
|
44 |
}
|
32 |
* Get list of custom fields and store in the current object for future use.
|
33 |
*/
|
34 |
public function get_fields() {
|
35 |
+
$meta_boxes = rwmb_get_registry( 'meta_box' )->all();
|
36 |
foreach ( $meta_boxes as $meta_box ) {
|
37 |
+
if ( $this->is_in_modal( $meta_box->meta_box ) ) {
|
38 |
+
$this->fields = array_merge( $this->fields, array_values( $meta_box->fields ) );
|
|
|
|
|
|
|
39 |
}
|
40 |
}
|
41 |
}
|
inc/meta-box-registry.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A registry for storing all meta boxes.
|
4 |
+
*
|
5 |
+
* @link https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html
|
6 |
+
* @package Meta Box
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Meta box registry class.
|
11 |
+
*/
|
12 |
+
class RWMB_Meta_Box_Registry {
|
13 |
+
/**
|
14 |
+
* Internal data storage.
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
private $data = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Add a meta box to the registry.
|
22 |
+
*
|
23 |
+
* @param RW_Meta_Box $meta_box Meta box instance.
|
24 |
+
*/
|
25 |
+
public function add( RW_Meta_Box $meta_box ) {
|
26 |
+
$this->data[ $meta_box->id ] = $meta_box;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Retrieve a meta box by id.
|
31 |
+
*
|
32 |
+
* @param string $id Meta box id.
|
33 |
+
*
|
34 |
+
* @return RW_Meta_Box|bool False or meta box object.
|
35 |
+
*/
|
36 |
+
public function get( $id ) {
|
37 |
+
return isset( $this->data[ $id ] ) ? $this->data[ $id ] : false;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Retrieve all meta boxes.
|
42 |
+
*
|
43 |
+
* @return array
|
44 |
+
*/
|
45 |
+
public function all() {
|
46 |
+
return $this->data;
|
47 |
+
}
|
48 |
+
}
|
inc/meta-box.php
CHANGED
@@ -21,13 +21,6 @@ class RW_Meta_Box {
|
|
21 |
*/
|
22 |
public $meta_box;
|
23 |
|
24 |
-
/**
|
25 |
-
* Fields parameters.
|
26 |
-
*
|
27 |
-
* @var array
|
28 |
-
*/
|
29 |
-
public $fields;
|
30 |
-
|
31 |
/**
|
32 |
* Detect whether the meta box is saved at least once.
|
33 |
* Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
|
@@ -36,6 +29,13 @@ class RW_Meta_Box {
|
|
36 |
*/
|
37 |
public $saved = false;
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
/**
|
40 |
* Create meta box based on given data.
|
41 |
*
|
@@ -46,7 +46,6 @@ class RW_Meta_Box {
|
|
46 |
$meta_box['fields'] = self::normalize_fields( $meta_box['fields'] );
|
47 |
|
48 |
$this->meta_box = $meta_box;
|
49 |
-
$this->fields = &$this->meta_box['fields'];
|
50 |
|
51 |
if ( $this->is_shown() ) {
|
52 |
$this->global_hooks();
|
@@ -65,7 +64,7 @@ class RW_Meta_Box {
|
|
65 |
protected function is_shown() {
|
66 |
$show = apply_filters( 'rwmb_show', true, $this->meta_box );
|
67 |
|
68 |
-
return apply_filters( "rwmb_show_{$this->
|
69 |
}
|
70 |
|
71 |
/**
|
@@ -93,7 +92,7 @@ class RW_Meta_Box {
|
|
93 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'hide' ), 10, 2 );
|
94 |
|
95 |
// Save post meta.
|
96 |
-
foreach ( $this->
|
97 |
if ( 'attachment' === $post_type ) {
|
98 |
// Attachment uses other hooks.
|
99 |
// @see wp_update_post(), wp_insert_attachment().
|
@@ -109,7 +108,7 @@ class RW_Meta_Box {
|
|
109 |
* Enqueue common scripts and styles.
|
110 |
*/
|
111 |
public function enqueue() {
|
112 |
-
if ( ! $this->is_edit_screen() ) {
|
113 |
return;
|
114 |
}
|
115 |
|
@@ -132,7 +131,7 @@ class RW_Meta_Box {
|
|
132 |
}
|
133 |
|
134 |
// Auto save.
|
135 |
-
if ( $this->
|
136 |
wp_enqueue_script( 'rwmb-autosave', RWMB_JS_URL . 'autosave.js', array( 'jquery' ), RWMB_VER, true );
|
137 |
}
|
138 |
|
@@ -148,14 +147,14 @@ class RW_Meta_Box {
|
|
148 |
* Add meta box for multiple post types
|
149 |
*/
|
150 |
public function add_meta_boxes() {
|
151 |
-
foreach ( $this->
|
152 |
add_meta_box(
|
153 |
-
$this->
|
154 |
-
$this->
|
155 |
array( $this, 'show' ),
|
156 |
$post_type,
|
157 |
-
$this->
|
158 |
-
$this->
|
159 |
);
|
160 |
}
|
161 |
}
|
@@ -169,8 +168,8 @@ class RW_Meta_Box {
|
|
169 |
* @return array
|
170 |
*/
|
171 |
public function hide( $hidden, $screen ) {
|
172 |
-
if ( $this->is_edit_screen( $screen ) && $this->
|
173 |
-
$hidden[] = $this->
|
174 |
}
|
175 |
|
176 |
return $hidden;
|
@@ -180,31 +179,32 @@ class RW_Meta_Box {
|
|
180 |
* Callback function to show fields in meta box
|
181 |
*/
|
182 |
public function show() {
|
|
|
183 |
$saved = $this->is_saved();
|
184 |
|
185 |
// Container.
|
186 |
printf(
|
187 |
'<div class="rwmb-meta-box" data-autosave="%s">',
|
188 |
-
$this->
|
189 |
);
|
190 |
|
191 |
-
wp_nonce_field( "rwmb-save-{$this->
|
192 |
|
193 |
// Allow users to add custom code before meta box content.
|
194 |
// 1st action applies to all meta boxes.
|
195 |
// 2nd action applies to only current meta box.
|
196 |
do_action( 'rwmb_before', $this );
|
197 |
-
do_action( "rwmb_before_{$this->
|
198 |
|
199 |
foreach ( $this->fields as $field ) {
|
200 |
-
RWMB_Field::call( 'show', $field, $saved );
|
201 |
}
|
202 |
|
203 |
// Allow users to add custom code after meta box content.
|
204 |
// 1st action applies to all meta boxes.
|
205 |
// 2nd action applies to only current meta box.
|
206 |
do_action( 'rwmb_after', $this );
|
207 |
-
do_action( "rwmb_after_{$this->
|
208 |
|
209 |
// End container.
|
210 |
echo '</div>';
|
@@ -229,7 +229,7 @@ class RW_Meta_Box {
|
|
229 |
|
230 |
// Before save action.
|
231 |
do_action( 'rwmb_before_save_post', $post_id );
|
232 |
-
do_action( "rwmb_{$this->
|
233 |
|
234 |
foreach ( $this->fields as $field ) {
|
235 |
$single = $field['clone'] || ! $field['multiple'];
|
@@ -252,7 +252,7 @@ class RW_Meta_Box {
|
|
252 |
|
253 |
// After save action.
|
254 |
do_action( 'rwmb_after_save_post', $post_id );
|
255 |
-
do_action( "rwmb_{$this->
|
256 |
}
|
257 |
|
258 |
/**
|
@@ -263,13 +263,13 @@ class RW_Meta_Box {
|
|
263 |
*
|
264 |
* @return bool
|
265 |
*/
|
266 |
-
|
267 |
-
$nonce =
|
268 |
|
269 |
return
|
270 |
-
|
271 |
-
&& ( ! defined( 'DOING_AUTOSAVE' ) || $this->
|
272 |
-
&& wp_verify_nonce( $nonce, "rwmb-save-{$this->
|
273 |
}
|
274 |
|
275 |
/**
|
@@ -334,13 +334,11 @@ class RW_Meta_Box {
|
|
334 |
* @return bool
|
335 |
*/
|
336 |
public function is_saved() {
|
337 |
-
$post = get_post();
|
338 |
-
|
339 |
foreach ( $this->fields as $field ) {
|
340 |
if ( empty( $field['id'] ) ) {
|
341 |
continue;
|
342 |
}
|
343 |
-
$value = RWMB_Field::call( $field, 'raw_meta', $
|
344 |
if (
|
345 |
( ! $field['multiple'] && '' !== $value )
|
346 |
|| ( $field['multiple'] && array() !== $value )
|
@@ -364,6 +362,28 @@ class RW_Meta_Box {
|
|
364 |
$screen = get_current_screen();
|
365 |
}
|
366 |
|
367 |
-
return 'post' === $screen->base && in_array( $screen->post_type, $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
}
|
21 |
*/
|
22 |
public $meta_box;
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
/**
|
25 |
* Detect whether the meta box is saved at least once.
|
26 |
* Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
|
29 |
*/
|
30 |
public $saved = false;
|
31 |
|
32 |
+
/**
|
33 |
+
* The object ID.
|
34 |
+
*
|
35 |
+
* @var int
|
36 |
+
*/
|
37 |
+
private $object_id = null;
|
38 |
+
|
39 |
/**
|
40 |
* Create meta box based on given data.
|
41 |
*
|
46 |
$meta_box['fields'] = self::normalize_fields( $meta_box['fields'] );
|
47 |
|
48 |
$this->meta_box = $meta_box;
|
|
|
49 |
|
50 |
if ( $this->is_shown() ) {
|
51 |
$this->global_hooks();
|
64 |
protected function is_shown() {
|
65 |
$show = apply_filters( 'rwmb_show', true, $this->meta_box );
|
66 |
|
67 |
+
return apply_filters( "rwmb_show_{$this->id}", $show, $this->meta_box );
|
68 |
}
|
69 |
|
70 |
/**
|
92 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'hide' ), 10, 2 );
|
93 |
|
94 |
// Save post meta.
|
95 |
+
foreach ( $this->post_types as $post_type ) {
|
96 |
if ( 'attachment' === $post_type ) {
|
97 |
// Attachment uses other hooks.
|
98 |
// @see wp_update_post(), wp_insert_attachment().
|
108 |
* Enqueue common scripts and styles.
|
109 |
*/
|
110 |
public function enqueue() {
|
111 |
+
if ( is_admin() && ! $this->is_edit_screen() ) {
|
112 |
return;
|
113 |
}
|
114 |
|
131 |
}
|
132 |
|
133 |
// Auto save.
|
134 |
+
if ( $this->autosave ) {
|
135 |
wp_enqueue_script( 'rwmb-autosave', RWMB_JS_URL . 'autosave.js', array( 'jquery' ), RWMB_VER, true );
|
136 |
}
|
137 |
|
147 |
* Add meta box for multiple post types
|
148 |
*/
|
149 |
public function add_meta_boxes() {
|
150 |
+
foreach ( $this->post_types as $post_type ) {
|
151 |
add_meta_box(
|
152 |
+
$this->id,
|
153 |
+
$this->title,
|
154 |
array( $this, 'show' ),
|
155 |
$post_type,
|
156 |
+
$this->context,
|
157 |
+
$this->priority
|
158 |
);
|
159 |
}
|
160 |
}
|
168 |
* @return array
|
169 |
*/
|
170 |
public function hide( $hidden, $screen ) {
|
171 |
+
if ( $this->is_edit_screen( $screen ) && $this->default_hidden ) {
|
172 |
+
$hidden[] = $this->id;
|
173 |
}
|
174 |
|
175 |
return $hidden;
|
179 |
* Callback function to show fields in meta box
|
180 |
*/
|
181 |
public function show() {
|
182 |
+
$this->set_object_id();
|
183 |
$saved = $this->is_saved();
|
184 |
|
185 |
// Container.
|
186 |
printf(
|
187 |
'<div class="rwmb-meta-box" data-autosave="%s">',
|
188 |
+
$this->autosave ? 'true' : 'false'
|
189 |
);
|
190 |
|
191 |
+
wp_nonce_field( "rwmb-save-{$this->id}", "nonce_{$this->id}" );
|
192 |
|
193 |
// Allow users to add custom code before meta box content.
|
194 |
// 1st action applies to all meta boxes.
|
195 |
// 2nd action applies to only current meta box.
|
196 |
do_action( 'rwmb_before', $this );
|
197 |
+
do_action( "rwmb_before_{$this->id}", $this );
|
198 |
|
199 |
foreach ( $this->fields as $field ) {
|
200 |
+
RWMB_Field::call( 'show', $field, $saved, $this->object_id );
|
201 |
}
|
202 |
|
203 |
// Allow users to add custom code after meta box content.
|
204 |
// 1st action applies to all meta boxes.
|
205 |
// 2nd action applies to only current meta box.
|
206 |
do_action( 'rwmb_after', $this );
|
207 |
+
do_action( "rwmb_after_{$this->id}", $this );
|
208 |
|
209 |
// End container.
|
210 |
echo '</div>';
|
229 |
|
230 |
// Before save action.
|
231 |
do_action( 'rwmb_before_save_post', $post_id );
|
232 |
+
do_action( "rwmb_{$this->id}_before_save_post", $post_id );
|
233 |
|
234 |
foreach ( $this->fields as $field ) {
|
235 |
$single = $field['clone'] || ! $field['multiple'];
|
252 |
|
253 |
// After save action.
|
254 |
do_action( 'rwmb_after_save_post', $post_id );
|
255 |
+
do_action( "rwmb_{$this->id}_after_save_post", $post_id );
|
256 |
}
|
257 |
|
258 |
/**
|
263 |
*
|
264 |
* @return bool
|
265 |
*/
|
266 |
+
public function validate() {
|
267 |
+
$nonce = filter_input( INPUT_POST, "nonce_{$this->id}", FILTER_SANITIZE_STRING );
|
268 |
|
269 |
return
|
270 |
+
! $this->saved
|
271 |
+
&& ( ! defined( 'DOING_AUTOSAVE' ) || $this->autosave )
|
272 |
+
&& wp_verify_nonce( $nonce, "rwmb-save-{$this->id}" );
|
273 |
}
|
274 |
|
275 |
/**
|
334 |
* @return bool
|
335 |
*/
|
336 |
public function is_saved() {
|
|
|
|
|
337 |
foreach ( $this->fields as $field ) {
|
338 |
if ( empty( $field['id'] ) ) {
|
339 |
continue;
|
340 |
}
|
341 |
+
$value = RWMB_Field::call( $field, 'raw_meta', $this->object_id );
|
342 |
if (
|
343 |
( ! $field['multiple'] && '' !== $value )
|
344 |
|| ( $field['multiple'] && array() !== $value )
|
362 |
$screen = get_current_screen();
|
363 |
}
|
364 |
|
365 |
+
return 'post' === $screen->base && in_array( $screen->post_type, $this->post_types, true );
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Magic function to get meta box property.
|
370 |
+
*
|
371 |
+
* @param string $key Meta box property name.
|
372 |
+
*
|
373 |
+
* @return mixed
|
374 |
+
*/
|
375 |
+
public function __get( $key ) {
|
376 |
+
return isset( $this->meta_box[ $key ] ) ? $this->meta_box[ $key ] : false;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Set the object ID.
|
381 |
+
*
|
382 |
+
* @param null|int $id Object ID. null means the current object ID.
|
383 |
+
*/
|
384 |
+
public function set_object_id( $id = null ) {
|
385 |
+
if ( null === $this->object_id ) {
|
386 |
+
$this->object_id = null === $id ? get_the_ID() : $id;
|
387 |
+
}
|
388 |
}
|
389 |
}
|
inc/templates/image-advanced.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<script id="tmpl-rwmb-image-item" type="text/html">
|
2 |
-
<input type="hidden" name="{{{ data.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
6 |
<# if ( 'image' === data.type && data.sizes ) { #>
|
7 |
-
<# if ( data.sizes.
|
8 |
-
<img src="{{{ data.sizes.
|
9 |
<# } else { #>
|
10 |
<img src="{{{ data.sizes.full.url }}}">
|
11 |
<# } #>
|
1 |
<script id="tmpl-rwmb-image-item" type="text/html">
|
2 |
+
<input type="hidden" name="{{{ data.controller.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
6 |
<# if ( 'image' === data.type && data.sizes ) { #>
|
7 |
+
<# if ( data.sizes[data.controller.imageSize] ) { #>
|
8 |
+
<img src="{{{ data.sizes[data.controller.imageSize].url }}}">
|
9 |
<# } else { #>
|
10 |
<img src="{{{ data.sizes.full.url }}}">
|
11 |
<# } #>
|
inc/templates/media.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<script id="tmpl-rwmb-media-item" type="text/html">
|
2 |
-
<input type="hidden" name="{{{ data.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
1 |
<script id="tmpl-rwmb-media-item" type="text/html">
|
2 |
+
<input type="hidden" name="{{{ data.controller.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
inc/templates/video.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<script id="tmpl-rwmb-video-item" type="text/html">
|
2 |
-
<input type="hidden" name="{{{ data.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
1 |
<script id="tmpl-rwmb-video-item" type="text/html">
|
2 |
+
<input type="hidden" name="{{{ data.controller.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
|
3 |
<div class="rwmb-media-preview">
|
4 |
<div class="rwmb-media-content">
|
5 |
<div class="centered">
|
inc/wpml.php
CHANGED
@@ -9,6 +9,13 @@
|
|
9 |
* WPML compatibility class
|
10 |
*/
|
11 |
class RWMB_WPML {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Initialize.
|
14 |
*/
|
@@ -28,7 +35,7 @@ class RWMB_WPML {
|
|
28 |
if ( ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
29 |
return;
|
30 |
}
|
31 |
-
add_filter( 'wpml_duplicate_generic_string', array( $this, '
|
32 |
add_filter( 'rwmb_normalize_field', array( $this, 'modify_field' ) );
|
33 |
}
|
34 |
|
@@ -40,35 +47,34 @@ class RWMB_WPML {
|
|
40 |
* @param array $meta_data Meta arguments.
|
41 |
* @return mixed
|
42 |
*/
|
43 |
-
public function
|
44 |
-
$
|
45 |
-
|
46 |
-
|
47 |
-
if ( ! in_array( $field['type'], array( 'post', 'taxonomy_advanced' ), true ) || $field['id'] !== $meta_data['key'] ) {
|
48 |
-
continue;
|
49 |
-
}
|
50 |
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
$value = apply_filters( 'wpml_object_id', $value, $post_type, true, $target_language );
|
57 |
-
return $value;
|
58 |
-
}
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
$
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
|
|
72 |
return $value;
|
73 |
}
|
74 |
|
9 |
* WPML compatibility class
|
10 |
*/
|
11 |
class RWMB_WPML {
|
12 |
+
/**
|
13 |
+
* List of fields that need to translate values (because they're saved as IDs).
|
14 |
+
*
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
protected $field_types = array( 'post', 'taxonomy_advanced' );
|
18 |
+
|
19 |
/**
|
20 |
* Initialize.
|
21 |
*/
|
35 |
if ( ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
36 |
return;
|
37 |
}
|
38 |
+
add_filter( 'wpml_duplicate_generic_string', array( $this, 'translate_ids' ), 10, 3 );
|
39 |
add_filter( 'rwmb_normalize_field', array( $this, 'modify_field' ) );
|
40 |
}
|
41 |
|
47 |
* @param array $meta_data Meta arguments.
|
48 |
* @return mixed
|
49 |
*/
|
50 |
+
public function translate_ids( $value, $target_language, $meta_data ) {
|
51 |
+
if ( 'custom_field' !== $meta_data['context'] ) {
|
52 |
+
return $value;
|
53 |
+
}
|
|
|
|
|
|
|
54 |
|
55 |
+
$field = rwmb_get_registry( 'field' )->get( $meta_data['key'], get_post_type( $meta_data['master_post_id'] ) );
|
56 |
+
if ( false !== $field || ! in_array( $field['type'], $this->field_types, true ) ) {
|
57 |
+
return $value;
|
58 |
+
}
|
59 |
|
60 |
+
// Object type needed for WPML filter differs between fields.
|
61 |
+
$object_type = 'taxonomy_advanced' === $field['type'] ? $field['taxonomy'] : $field['post_type'];
|
|
|
|
|
|
|
62 |
|
63 |
+
// Translating values, whether are stored as comma separated strings or not.
|
64 |
+
if ( false === strpos( $value, ',' ) ) {
|
65 |
+
$value = apply_filters( 'wpml_object_id', $value, $object_type, true, $target_language );
|
66 |
+
return $value;
|
67 |
+
}
|
68 |
|
69 |
+
// Dealing with IDs stored as comma separated strings.
|
70 |
+
$translated_values = array();
|
71 |
+
$values = explode( ',', $value );
|
72 |
|
73 |
+
foreach ( $values as $v ) {
|
74 |
+
$translated_values[] = apply_filters( 'wpml_object_id', $v, $object_type, true, $target_language );
|
75 |
}
|
76 |
|
77 |
+
$value = implode( ',', $translated_values );
|
78 |
return $value;
|
79 |
}
|
80 |
|
js/clone.js
CHANGED
@@ -148,7 +148,7 @@ jQuery( function ( $ ) {
|
|
148 |
$button.toggle( isNaN( maxClone ) || ( maxClone && numClone < maxClone ) );
|
149 |
}
|
150 |
|
151 |
-
$(
|
152 |
// Add clones
|
153 |
.on( 'click', '.add-clone', function ( e ) {
|
154 |
e.preventDefault();
|
@@ -189,7 +189,7 @@ jQuery( function ( $ ) {
|
|
189 |
items: '.rwmb-clone',
|
190 |
start: function ( event, ui ) {
|
191 |
// Make the placeholder has the same height as dragged item
|
192 |
-
ui.placeholder.height( ui.item.
|
193 |
}
|
194 |
} );
|
195 |
} );
|
148 |
$button.toggle( isNaN( maxClone ) || ( maxClone && numClone < maxClone ) );
|
149 |
}
|
150 |
|
151 |
+
$( document )
|
152 |
// Add clones
|
153 |
.on( 'click', '.add-clone', function ( e ) {
|
154 |
e.preventDefault();
|
189 |
items: '.rwmb-clone',
|
190 |
start: function ( event, ui ) {
|
191 |
// Make the placeholder has the same height as dragged item
|
192 |
+
ui.placeholder.height( ui.item.outerHeight() );
|
193 |
}
|
194 |
} );
|
195 |
} );
|
js/color.js
CHANGED
@@ -31,5 +31,5 @@ jQuery( function ( $ ) {
|
|
31 |
}
|
32 |
|
33 |
$( '.rwmb-color' ).each( update );
|
34 |
-
$(
|
35 |
} );
|
31 |
}
|
32 |
|
33 |
$( '.rwmb-color' ).each( update );
|
34 |
+
$( document ).on( 'clone', '.rwmb-color', update );
|
35 |
} );
|
js/file.js
CHANGED
@@ -1,142 +1,61 @@
|
|
1 |
-
|
|
|
2 |
'use strict';
|
3 |
|
|
|
|
|
4 |
/**
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
|
|
8 |
*/
|
9 |
-
function
|
10 |
-
|
11 |
-
el = document.createElement( 'fakeelement' ),
|
12 |
-
transitions = {
|
13 |
-
'transition': 'transitionend',
|
14 |
-
'OTransition': 'oTransitionEnd',
|
15 |
-
'MozTransition': 'transitionend',
|
16 |
-
'WebkitTransition': 'webkitTransitionEnd'
|
17 |
-
};
|
18 |
-
|
19 |
-
for ( t in transitions ) {
|
20 |
-
if ( el.style[t] !== undefined ) {
|
21 |
-
return transitions[t];
|
22 |
-
}
|
23 |
-
}
|
24 |
-
return '';
|
25 |
-
}
|
26 |
-
|
27 |
|
28 |
-
var $uploaded = $( '.rwmb-uploaded' ),
|
29 |
-
event = whichTransitionEvent();
|
30 |
-
|
31 |
-
|
32 |
-
// Add more file
|
33 |
-
$( '.rwmb-add-file' ).each( function () {
|
34 |
var $this = $( this ),
|
35 |
-
$
|
36 |
-
$first = $uploads.first(),
|
37 |
-
uploadCount = $uploads.length,
|
38 |
-
$fileList = $this.closest( '.rwmb-input' ).find( '.rwmb-uploaded' ),
|
39 |
-
fileCount = $fileList.children( 'li' ).length,
|
40 |
-
maxFileUploads = $fileList.data( 'max_file_uploads' );
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
$this.hide();
|
46 |
-
}
|
47 |
-
if ( fileCount >= maxFileUploads ) {
|
48 |
-
$uploads.hide();
|
49 |
-
}
|
50 |
-
}
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$this.hide();
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
return false;
|
65 |
-
} );
|
66 |
-
} );
|
67 |
|
68 |
-
// Delete file via Ajax
|
69 |
-
$uploaded.on( 'click', '.rwmb-delete-file', function () {
|
70 |
var $this = $( this ),
|
71 |
-
$
|
72 |
-
$
|
73 |
data = {
|
74 |
action: 'rwmb_delete_file',
|
75 |
-
_ajax_nonce: $
|
76 |
post_id: $( '#post_ID' ).val(),
|
77 |
-
field_id: $
|
78 |
attachment_id: $this.data( 'attachment_id' ),
|
79 |
-
force_delete: $
|
80 |
};
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
alert( r.data );
|
85 |
-
return;
|
86 |
-
}
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
if ( ! event ) {
|
92 |
-
$parent.remove();
|
93 |
-
$container.trigger( 'update.rwmbFile' );
|
94 |
}
|
95 |
-
|
96 |
-
// If transition is supported
|
97 |
-
$( '.rwmb-uploaded' ).on( event, 'li.removed', function () {
|
98 |
-
$( this ).remove();
|
99 |
-
$container.trigger( 'update.rwmbFile' );
|
100 |
-
} );
|
101 |
}, 'json' );
|
|
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
$( this ).remove();
|
109 |
-
} );
|
110 |
-
|
111 |
-
$( 'body' ).on( 'update.rwmbFile', '.rwmb-uploaded', function () {
|
112 |
-
var $fileList = $( this ),
|
113 |
-
maxFileUploads = $fileList.data( 'max_file_uploads' ),
|
114 |
-
$uploader = $fileList.siblings( '.new-files' ),
|
115 |
-
numFiles = $fileList.children().length;
|
116 |
-
|
117 |
-
if ( numFiles > 0 ) {
|
118 |
-
$fileList.removeClass( 'hidden' );
|
119 |
-
} else {
|
120 |
-
$fileList.addClass( 'hidden' );
|
121 |
-
}
|
122 |
-
|
123 |
-
// Return if maxFileUpload = 0
|
124 |
-
if ( maxFileUploads === 0 ) {
|
125 |
-
return false;
|
126 |
-
}
|
127 |
-
|
128 |
-
// Hide files button if reach max file uploads
|
129 |
-
if ( numFiles >= maxFileUploads ) {
|
130 |
-
$uploader.addClass( 'hidden' );
|
131 |
-
} else {
|
132 |
-
$uploader.removeClass( 'hidden' );
|
133 |
-
}
|
134 |
-
|
135 |
-
return false;
|
136 |
-
} );
|
137 |
-
|
138 |
-
// Reorder files
|
139 |
-
$uploaded.each( function () {
|
140 |
var $this = $( this ),
|
141 |
data = {
|
142 |
action: 'rwmb_reorder_files',
|
@@ -148,11 +67,40 @@ jQuery( function ( $ ) {
|
|
148 |
placeholder: 'ui-state-highlight',
|
149 |
items: 'li',
|
150 |
update: function () {
|
151 |
-
|
152 |
data.order = $this.sortable( 'serialize' );
|
153 |
-
|
154 |
$.post( ajaxurl, data );
|
155 |
}
|
156 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
} );
|
158 |
-
} );
|
1 |
+
/* global jQuery */
|
2 |
+
( function ( $, document ) {
|
3 |
'use strict';
|
4 |
|
5 |
+
var file = {};
|
6 |
+
|
7 |
/**
|
8 |
+
* Handles a click on add new file.
|
9 |
+
* Expects `this` to equal the clicked element.
|
10 |
+
*
|
11 |
+
* @param event Click event.
|
12 |
*/
|
13 |
+
file.addHandler = function ( event ) {
|
14 |
+
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
var $this = $( this ),
|
17 |
+
$clone = $this.siblings( '.rwmb-file-input:last' ).clone();
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
$clone.insertBefore( this );
|
20 |
+
file.updateVisibility.call( $this.closest( '.rwmb-input' ).find( '.rwmb-uploaded' )[0] );
|
21 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
/**
|
24 |
+
* Handles a click on delete new file.
|
25 |
+
* Expects `this` to equal the clicked element.
|
26 |
+
*
|
27 |
+
* @param event Click event.
|
28 |
+
*/
|
29 |
+
file.deleteHandler = function ( event ) {
|
30 |
+
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
|
|
|
|
32 |
var $this = $( this ),
|
33 |
+
$item = $this.closest( 'li' ),
|
34 |
+
$uploaded = $this.closest( '.rwmb-uploaded' ),
|
35 |
data = {
|
36 |
action: 'rwmb_delete_file',
|
37 |
+
_ajax_nonce: $uploaded.data( 'delete_nonce' ),
|
38 |
post_id: $( '#post_ID' ).val(),
|
39 |
+
field_id: $uploaded.data( 'field_id' ),
|
40 |
attachment_id: $this.data( 'attachment_id' ),
|
41 |
+
force_delete: $uploaded.data( 'force_delete' )
|
42 |
};
|
43 |
|
44 |
+
$item.remove();
|
45 |
+
file.updateVisibility.call( $uploaded );
|
|
|
|
|
|
|
46 |
|
47 |
+
$.post( ajaxurl, data, function ( response ) {
|
48 |
+
if ( ! response.success ) {
|
49 |
+
alert( response.data );
|
|
|
|
|
|
|
50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}, 'json' );
|
52 |
+
};
|
53 |
|
54 |
+
/**
|
55 |
+
* Sort uploaded files.
|
56 |
+
* Expects `this` to equal the uploaded file list.
|
57 |
+
*/
|
58 |
+
file.sort = function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
var $this = $( this ),
|
60 |
data = {
|
61 |
action: 'rwmb_reorder_files',
|
67 |
placeholder: 'ui-state-highlight',
|
68 |
items: 'li',
|
69 |
update: function () {
|
|
|
70 |
data.order = $this.sortable( 'serialize' );
|
|
|
71 |
$.post( ajaxurl, data );
|
72 |
}
|
73 |
} );
|
74 |
+
};
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Update visibility of upload inputs and Add new file link.
|
78 |
+
* Expect this equal to the uploaded file list.
|
79 |
+
*/
|
80 |
+
file.updateVisibility = function () {
|
81 |
+
var $uploaded = $( this ),
|
82 |
+
max = parseInt( $uploaded.data( 'max_file_uploads' ), 10 ),
|
83 |
+
$uploader = $uploaded.siblings( '.rwmb-new-files' ),
|
84 |
+
$addMore = $uploader.find( '.rwmb-add-file' ),
|
85 |
+
numFiles = $uploaded.children().length,
|
86 |
+
numInputs = $uploader.find( '.rwmb-file-input' ).length;
|
87 |
+
|
88 |
+
$uploaded.toggle( 0 < numFiles );
|
89 |
+
if ( 0 === max ) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
$uploader.toggle( numFiles < max );
|
93 |
+
$addMore.toggle( numFiles + numInputs < max );
|
94 |
+
};
|
95 |
+
|
96 |
+
// Initialize when document ready.
|
97 |
+
$( function ( $ ) {
|
98 |
+
$( document )
|
99 |
+
.on( 'click', '.rwmb-add-file', file.addHandler )
|
100 |
+
.on( 'click', '.rwmb-delete-file', file.deleteHandler );
|
101 |
+
|
102 |
+
var $uploaded = $( '.rwmb-uploaded' );
|
103 |
+
$uploaded.each( file.sort );
|
104 |
+
$uploaded.each( file.updateVisibility );
|
105 |
} );
|
106 |
+
} )( jQuery, document );
|
js/image-advanced.js
CHANGED
@@ -15,7 +15,11 @@ jQuery( function ( $ ) {
|
|
15 |
controller: this.controller,
|
16 |
itemView: MediaItem.extend( {
|
17 |
className: 'rwmb-image-item',
|
18 |
-
template: wp.template( 'rwmb-image-item' )
|
|
|
|
|
|
|
|
|
19 |
} )
|
20 |
} );
|
21 |
}
|
@@ -29,5 +33,5 @@ jQuery( function ( $ ) {
|
|
29 |
}
|
30 |
|
31 |
$( 'input.rwmb-image_advanced' ).each( initImageField );
|
32 |
-
$(
|
33 |
} );
|
15 |
controller: this.controller,
|
16 |
itemView: MediaItem.extend( {
|
17 |
className: 'rwmb-image-item',
|
18 |
+
template: wp.template( 'rwmb-image-item' ),
|
19 |
+
initialize: function( models, options ) {
|
20 |
+
MediaItem.prototype.initialize.call( this, models, options );
|
21 |
+
this.$el.addClass( this.controller.get( 'imageSize' ) );
|
22 |
+
}
|
23 |
} )
|
24 |
} );
|
25 |
}
|
33 |
}
|
34 |
|
35 |
$( 'input.rwmb-image_advanced' ).each( initImageField );
|
36 |
+
$( document ).on( 'clone', 'input.rwmb-image_advanced', initImageField )
|
37 |
} );
|
js/jqueryui/jquery-ui-timepicker-addon-i18n.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/*! jQuery Timepicker Addon - v1.
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
-
* Copyright (c)
|
4 |
-
(function(e){e.timepicker.regional.af={timeOnlyTitle:"Kies Tyd",timeText:"Tyd ",hourText:"Ure ",minuteText:"Minute",secondText:"Sekondes",millisecText:"Millisekondes",microsecText:"Mikrosekondes",timezoneText:"Tydsone",currentText:"Huidige Tyd",closeText:"Klaar",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.am={timeOnlyTitle:"Ընտրեք ժամանակը",timeText:"Ժամանակը",hourText:"Ժամ",minuteText:"Րոպե",secondText:"Վարկյան",millisecText:"Միլիվարկյան",microsecText:"Միկրովարկյան",timezoneText:"Ժամային գոտին",currentText:"Այժմ",closeText:"Փակել",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.bg={timeOnlyTitle:"Изберете време",timeText:"Време",hourText:"Час",minuteText:"Минути",secondText:"Секунди",millisecText:"Милисекунди",microsecText:"Микросекунди",timezoneText:"Часови пояс",currentText:"Сега",closeText:"Затвори",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.ca={timeOnlyTitle:"Escollir una hora",timeText:"Hora",hourText:"Hores",minuteText:"Minuts",secondText:"Segons",millisecText:"Milisegons",microsecText:"Microsegons",timezoneText:"Fus horari",currentText:"Ara",closeText:"Tancar",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.cs={timeOnlyTitle:"Vyberte čas",timeText:"Čas",hourText:"Hodiny",minuteText:"Minuty",secondText:"Vteřiny",millisecText:"Milisekundy",microsecText:"Mikrosekundy",timezoneText:"Časové pásmo",currentText:"Nyní",closeText:"Zavřít",timeFormat:"HH:mm",amNames:["dop.","AM","A"],pmNames:["odp.","PM","P"],isRTL:!1},e.timepicker.regional.da={timeOnlyTitle:"Vælg tid",timeText:"Tid",hourText:"Time",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekund",microsecText:"Mikrosekund",timezoneText:"Tidszone",currentText:"Nu",closeText:"Luk",timeFormat:"HH:mm",amNames:["am","AM","A"],pmNames:["pm","PM","P"],isRTL:!1},e.timepicker.regional.de={timeOnlyTitle:"Zeit wählen",timeText:"Zeit",hourText:"Stunde",minuteText:"Minute",secondText:"Sekunde",millisecText:"Millisekunde",microsecText:"Mikrosekunde",timezoneText:"Zeitzone",currentText:"Jetzt",closeText:"Fertig",timeFormat:"HH:mm",amNames:["vorm.","AM","A"],pmNames:["nachm.","PM","P"],isRTL:!1},e.timepicker.regional.el={timeOnlyTitle:"Επιλογή ώρας",timeText:"Ώρα",hourText:"Ώρες",minuteText:"Λεπτά",secondText:"Δευτερόλεπτα",millisecText:"μιλιδευτερόλεπτο",microsecText:"Microseconds",timezoneText:"Ζώνη ώρας",currentText:"Τώρα",closeText:"Κλείσιμο",timeFormat:"HH:mm",amNames:["π.μ.","AM","A"],pmNames:["μ.μ.","PM","P"],isRTL:!1},e.timepicker.regional.es={timeOnlyTitle:"Elegir una hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milisegundos",microsecText:"Microsegundos",timezoneText:"Uso horario",currentText:"Hoy",closeText:"Cerrar",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.et={timeOnlyTitle:"Vali aeg",timeText:"Aeg",hourText:"Tund",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekundis",microsecText:"Mikrosekundis",timezoneText:"Ajavöönd",currentText:"Praegu",closeText:"Valmis",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.eu={timeOnlyTitle:"Aukeratu ordua",timeText:"Ordua",hourText:"Orduak",minuteText:"Minutuak",secondText:"Segundoak",millisecText:"Milisegundoak",microsecText:"Mikrosegundoak",timezoneText:"Ordu-eremua",currentText:"Orain",closeText:"Itxi",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.fi={timeOnlyTitle:"Valitse aika",timeText:"Aika",hourText:"Tunti",minuteText:"Minuutti",secondText:"Sekunti",millisecText:"Millisekunnin",microsecText:"Mikrosekuntia",timezoneText:"Aikavyöhyke",currentText:"Nyt",closeText:"Sulje",timeFormat:"HH:mm",amNames:["ap.","AM","A"],pmNames:["ip.","PM","P"],isRTL:!1},e.timepicker.regional.fr={timeOnlyTitle:"Choisir une heure",timeText:"Heure",hourText:"Heures",minuteText:"Minutes",secondText:"Secondes",millisecText:"Millisecondes",microsecText:"Microsecondes",timezoneText:"Fuseau horaire",currentText:"Maintenant",closeText:"Terminé",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.gl={timeOnlyTitle:"Elixir unha hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milisegundos",microsecText:"Microssegundos",timezoneText:"Fuso horario",currentText:"Agora",closeText:"Pechar",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.he={timeOnlyTitle:"בחירת זמן",timeText:"שעה",hourText:"שעות",minuteText:"דקות",secondText:"שניות",millisecText:"אלפית השנייה",microsecText:"מיקרו",timezoneText:"אזור זמן",currentText:"עכשיו",closeText:"סגור",timeFormat:"HH:mm",amNames:['לפנה"צ',"AM","A"],pmNames:['אחה"צ',"PM","P"],isRTL:!0},e.timepicker.regional.hr={timeOnlyTitle:"Odaberi vrijeme",timeText:"Vrijeme",hourText:"Sati",minuteText:"Minute",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Vremenska zona",currentText:"Sada",closeText:"Gotovo",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.hu={timeOnlyTitle:"Válasszon időpontot",timeText:"Idő",hourText:"Óra",minuteText:"Perc",secondText:"Másodperc",millisecText:"Milliszekundumos",microsecText:"Ezredmásodperc",timezoneText:"Időzóna",currentText:"Most",closeText:"Kész",timeFormat:"HH:mm",amNames:["de.","AM","A"],pmNames:["du.","PM","P"],isRTL:!1},e.timepicker.regional.id={timeOnlyTitle:"Pilih Waktu",timeText:"Waktu",hourText:"Pukul",minuteText:"Menit",secondText:"Detik",millisecText:"Milidetik",microsecText:"Mikrodetik",timezoneText:"Zona Waktu",currentText:"Sekarang",closeText:"OK",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.it={timeOnlyTitle:"Scegli orario",timeText:"Orario",hourText:"Ora",minuteText:"Minuti",secondText:"Secondi",millisecText:"Millisecondi",microsecText:"Microsecondi",timezoneText:"Fuso orario",currentText:"Adesso",closeText:"Chiudi",timeFormat:"HH:mm",amNames:["m.","AM","A"],pmNames:["p.","PM","P"],isRTL:!1},e.timepicker.regional.ja={timeOnlyTitle:"時間を選択",timeText:"時間",hourText:"時",minuteText:"分",secondText:"秒",millisecText:"ミリ秒",microsecText:"マイクロ秒",timezoneText:"タイムゾーン",currentText:"現時刻",closeText:"閉じる",timeFormat:"HH:mm",amNames:["午前","AM","A"],pmNames:["午後","PM","P"],isRTL:!1},e.timepicker.regional.ko={timeOnlyTitle:"시간 선택",timeText:"시간",hourText:"시",minuteText:"분",secondText:"초",millisecText:"밀리초",microsecText:"마이크로",timezoneText:"표준 시간대",currentText:"현재 시각",closeText:"닫기",timeFormat:"tt h:mm",amNames:["오전","AM","A"],pmNames:["오후","PM","P"],isRTL:!1},e.timepicker.regional.lt={timeOnlyTitle:"Pasirinkite laiką",timeText:"Laikas",hourText:"Valandos",minuteText:"Minutės",secondText:"Sekundės",millisecText:"Milisekundės",microsecText:"Mikrosekundės",timezoneText:"Laiko zona",currentText:"Dabar",closeText:"Uždaryti",timeFormat:"HH:mm",amNames:["priešpiet","AM","A"],pmNames:["popiet","PM","P"],isRTL:!1},e.timepicker.regional.nl={timeOnlyTitle:"Tijdstip",timeText:"Tijd",hourText:"Uur",minuteText:"Minuut",secondText:"Seconde",millisecText:"Milliseconde",microsecText:"Microseconde",timezoneText:"Tijdzone",currentText:"Vandaag",closeText:"Sluiten",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.no={timeOnlyTitle:"Velg tid",timeText:"Tid",hourText:"Time",minuteText:"Minutt",secondText:"Sekund",millisecText:"Millisekund",microsecText:"mikrosekund",timezoneText:"Tidssone",currentText:"Nå",closeText:"Lukk",timeFormat:"HH:mm",amNames:["am","AM","A"],pmNames:["pm","PM","P"],isRTL:!1},e.timepicker.regional.pl={timeOnlyTitle:"Wybierz godzinę",timeText:"Czas",hourText:"Godzina",minuteText:"Minuta",secondText:"Sekunda",millisecText:"Milisekunda",microsecText:"Mikrosekunda",timezoneText:"Strefa czasowa",currentText:"Teraz",closeText:"Gotowe",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional["pt-BR"]={timeOnlyTitle:"Escolha o horário",timeText:"Horário",hourText:"Hora",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milissegundos",microsecText:"Microssegundos",timezoneText:"Fuso horário",currentText:"Agora",closeText:"Fechar",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.pt={timeOnlyTitle:"Escolha uma hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milissegundos",microsecText:"Microssegundos",timezoneText:"Fuso horário",currentText:"Agora",closeText:"Fechar",timeFormat:"HH:mm",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},e.timepicker.regional.ro={timeOnlyTitle:"Alegeţi o oră",timeText:"Timp",hourText:"Ore",minuteText:"Minute",secondText:"Secunde",millisecText:"Milisecunde",microsecText:"Microsecunde",timezoneText:"Fus orar",currentText:"Acum",closeText:"Închide",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.ru={timeOnlyTitle:"Выберите время",timeText:"Время",hourText:"Часы",minuteText:"Минуты",secondText:"Секунды",millisecText:"Миллисекунды",microsecText:"Микросекунды",timezoneText:"Часовой пояс",currentText:"Сейчас",closeText:"Закрыть",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.sk={timeOnlyTitle:"Zvoľte čas",timeText:"Čas",hourText:"Hodiny",minuteText:"Minúty",secondText:"Sekundy",millisecText:"Milisekundy",microsecText:"Mikrosekundy",timezoneText:"Časové pásmo",currentText:"Teraz",closeText:"Zavrieť",timeFormat:"H:m",amNames:["dop.","AM","A"],pmNames:["pop.","PM","P"],isRTL:!1},e.timepicker.regional.sl={timeOnlyTitle:"Izberite čas",timeText:"Čas",hourText:"Ura",minuteText:"Minute",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Časovni pas",currentText:"Sedaj",closeText:"Zapri",timeFormat:"HH:mm",amNames:["dop.","AM","A"],pmNames:["pop.","PM","P"],isRTL:!1},e.timepicker.regional["sr-RS"]={timeOnlyTitle:"Одаберите време",timeText:"Време",hourText:"Сати",minuteText:"Минути",secondText:"Секунде",millisecText:"Милисекунде",microsecText:"Микросекунде",timezoneText:"Временска зона",currentText:"Сада",closeText:"Затвори",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional["sr-YU"]={timeOnlyTitle:"Odaberite vreme",timeText:"Vreme",hourText:"Sati",minuteText:"Minuti",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Vremenska zona",currentText:"Sada",closeText:"Zatvori",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.sv={timeOnlyTitle:"Välj en tid",timeText:"Tid",hourText:"Timme",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekund",microsecText:"Mikrosekund",timezoneText:"Tidszon",currentText:"Nu",closeText:"Stäng",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.th={timeOnlyTitle:"เลือกเวลา",timeText:"เวลา ",hourText:"ชั่วโมง ",minuteText:"นาที",secondText:"วินาที",millisecText:"มิลลิวินาที",microsecText:"ไมโคริวินาที",timezoneText:"เขตเวลา",currentText:"เวลาปัจจุบัน",closeText:"ปิด",timeFormat:"hh:mm tt"},e.timepicker.regional.tr={timeOnlyTitle:"Zaman Seçiniz",timeText:"Zaman",hourText:"Saat",minuteText:"Dakika",secondText:"Saniye",millisecText:"Milisaniye",microsecText:"Mikrosaniye",timezoneText:"Zaman Dilimi",currentText:"Şu an",closeText:"Tamam",timeFormat:"HH:mm",amNames:["ÖÖ","Ö"],pmNames:["ÖS","S"],isRTL:!1},e.timepicker.regional.uk={timeOnlyTitle:"Виберіть час",timeText:"Час",hourText:"Години",minuteText:"Хвилини",secondText:"Секунди",millisecText:"Мілісекунди",microsecText:"Мікросекунди",timezoneText:"Часовий пояс",currentText:"Зараз",closeText:"Закрити",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional.vi={timeOnlyTitle:"Chọn giờ",timeText:"Thời gian",hourText:"Giờ",minuteText:"Phút",secondText:"Giây",millisecText:"Mili giây",microsecText:"Micrô giây",timezoneText:"Múi giờ",currentText:"Hiện thời",closeText:"Đóng",timeFormat:"HH:mm",amNames:["SA","S"],pmNames:["CH","C"],isRTL:!1},e.timepicker.regional["zh-CN"]={timeOnlyTitle:"选择时间",timeText:"时间",hourText:"小时",minuteText:"分钟",secondText:"秒钟",millisecText:"毫秒",microsecText:"微秒",timezoneText:"时区",currentText:"现在时间",closeText:"关闭",timeFormat:"HH:mm",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},e.timepicker.regional["zh-TW"]={timeOnlyTitle:"選擇時分秒",timeText:"時間",hourText:"時",minuteText:"分",secondText:"秒",millisecText:"毫秒",microsecText:"微秒",timezoneText:"時區",currentText:"現在時間",closeText:"確定",timeFormat:"HH:mm",amNames:["上午","AM","A"],pmNames:["下午","PM","P"],isRTL:!1}})(jQuery);
|
1 |
+
/*! jQuery Timepicker Addon - v1.6.3 - 2016-04-20
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
+
* Copyright (c) 2016 Trent Richardson; Licensed MIT */
|
4 |
+
!function(a){a.timepicker.regional.af={timeOnlyTitle:"Kies Tyd",timeText:"Tyd ",hourText:"Ure ",minuteText:"Minute",secondText:"Sekondes",millisecText:"Millisekondes",microsecText:"Mikrosekondes",timezoneText:"Tydsone",currentText:"Huidige Tyd",closeText:"Klaar",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.am={timeOnlyTitle:"Ընտրեք ժամանակը",timeText:"Ժամանակը",hourText:"Ժամ",minuteText:"Րոպե",secondText:"Վարկյան",millisecText:"Միլիվարկյան",microsecText:"Միկրովարկյան",timezoneText:"Ժամային գոտին",currentText:"Այժմ",closeText:"Փակել",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.bg={timeOnlyTitle:"Изберете време",timeText:"Време",hourText:"Час",minuteText:"Минути",secondText:"Секунди",millisecText:"Милисекунди",microsecText:"Микросекунди",timezoneText:"Часови пояс",currentText:"Сега",closeText:"Затвори",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.ca={timeOnlyTitle:"Escollir una hora",timeText:"Hora",hourText:"Hores",minuteText:"Minuts",secondText:"Segons",millisecText:"Milisegons",microsecText:"Microsegons",timezoneText:"Fus horari",currentText:"Ara",closeText:"Tancar",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.cs={timeOnlyTitle:"Vyberte čas",timeText:"Čas",hourText:"Hodiny",minuteText:"Minuty",secondText:"Vteřiny",millisecText:"Milisekundy",microsecText:"Mikrosekundy",timezoneText:"Časové pásmo",currentText:"Nyní",closeText:"Zavřít",timeFormat:"HH:mm",timeSuffix:"",amNames:["dop.","AM","A"],pmNames:["odp.","PM","P"],isRTL:!1},a.timepicker.regional.da={timeOnlyTitle:"Vælg tid",timeText:"Tid",hourText:"Time",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekund",microsecText:"Mikrosekund",timezoneText:"Tidszone",currentText:"Nu",closeText:"Luk",timeFormat:"HH:mm",timeSuffix:"",amNames:["am","AM","A"],pmNames:["pm","PM","P"],isRTL:!1},a.timepicker.regional.de={timeOnlyTitle:"Zeit wählen",timeText:"Zeit",hourText:"Stunde",minuteText:"Minute",secondText:"Sekunde",millisecText:"Millisekunde",microsecText:"Mikrosekunde",timezoneText:"Zeitzone",currentText:"Jetzt",closeText:"Fertig",timeFormat:"HH:mm",timeSuffix:"",amNames:["vorm.","AM","A"],pmNames:["nachm.","PM","P"],isRTL:!1},a.timepicker.regional.el={timeOnlyTitle:"Επιλογή ώρας",timeText:"Ώρα",hourText:"Ώρες",minuteText:"Λεπτά",secondText:"Δευτερόλεπτα",millisecText:"Χιλιοστοδευτερόλεπτα",microsecText:"Μικροδευτερόλεπτα",timezoneText:"Ζώνη ώρας",currentText:"Τώρα",closeText:"Κλείσιμο",timeFormat:"HH:mm",timeSuffix:"",amNames:["π.μ.","AM","A"],pmNames:["μ.μ.","PM","P"],isRTL:!1},a.timepicker.regional.es={timeOnlyTitle:"Elegir una hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milisegundos",microsecText:"Microsegundos",timezoneText:"Uso horario",currentText:"Hoy",closeText:"Cerrar",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.et={timeOnlyTitle:"Vali aeg",timeText:"Aeg",hourText:"Tund",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekundis",microsecText:"Mikrosekundis",timezoneText:"Ajavöönd",currentText:"Praegu",closeText:"Valmis",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.eu={timeOnlyTitle:"Aukeratu ordua",timeText:"Ordua",hourText:"Orduak",minuteText:"Minutuak",secondText:"Segundoak",millisecText:"Milisegundoak",microsecText:"Mikrosegundoak",timezoneText:"Ordu-eremua",currentText:"Orain",closeText:"Itxi",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.fa={timeOnlyTitle:"انتخاب زمان",timeText:"زمان",hourText:"ساعت",minuteText:"دقیقه",secondText:"ثانیه",millisecText:"میلی ثانیه",microsecText:"میکرو ثانیه",timezoneText:"منطقه زمانی",currentText:"الان",closeText:"انتخاب",timeFormat:"HH:mm",timeSuffix:"",amNames:["قبل ظهر","AM","A"],pmNames:["بعد ظهر","PM","P"],isRTL:!0},a.timepicker.regional.fi={timeOnlyTitle:"Valitse aika",timeText:"Aika",hourText:"Tunti",minuteText:"Minuutti",secondText:"Sekunti",millisecText:"Millisekunnin",microsecText:"Mikrosekuntia",timezoneText:"Aikavyöhyke",currentText:"Nyt",closeText:"Sulje",timeFormat:"HH:mm",timeSuffix:"",amNames:["ap.","AM","A"],pmNames:["ip.","PM","P"],isRTL:!1},a.timepicker.regional.fr={timeOnlyTitle:"Choisir une heure",timeText:"Heure",hourText:"Heures",minuteText:"Minutes",secondText:"Secondes",millisecText:"Millisecondes",microsecText:"Microsecondes",timezoneText:"Fuseau horaire",currentText:"Maintenant",closeText:"Terminé",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.gl={timeOnlyTitle:"Elixir unha hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milisegundos",microsecText:"Microssegundos",timezoneText:"Fuso horario",currentText:"Agora",closeText:"Pechar",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.he={timeOnlyTitle:"בחירת זמן",timeText:"שעה",hourText:"שעות",minuteText:"דקות",secondText:"שניות",millisecText:"אלפית השנייה",microsecText:"מיקרו",timezoneText:"אזור זמן",currentText:"עכשיו",closeText:"סגור",timeFormat:"HH:mm",timeSuffix:"",amNames:['לפנה"צ',"AM","A"],pmNames:['אחה"צ',"PM","P"],isRTL:!0},a.timepicker.regional.hr={timeOnlyTitle:"Odaberi vrijeme",timeText:"Vrijeme",hourText:"Sati",minuteText:"Minute",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Vremenska zona",currentText:"Sada",closeText:"Gotovo",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.hu={timeOnlyTitle:"Válasszon időpontot",timeText:"Idő",hourText:"Óra",minuteText:"Perc",secondText:"Másodperc",millisecText:"Milliszekundumos",microsecText:"Ezredmásodperc",timezoneText:"Időzóna",currentText:"Most",closeText:"Kész",timeFormat:"HH:mm",timeSuffix:"",amNames:["de.","AM","A"],pmNames:["du.","PM","P"],isRTL:!1},a.timepicker.regional.id={timeOnlyTitle:"Pilih Waktu",timeText:"Waktu",hourText:"Pukul",minuteText:"Menit",secondText:"Detik",millisecText:"Milidetik",microsecText:"Mikrodetik",timezoneText:"Zona Waktu",currentText:"Sekarang",closeText:"OK",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.it={timeOnlyTitle:"Scegli orario",timeText:"Orario",hourText:"Ora",minuteText:"Minuti",secondText:"Secondi",millisecText:"Millisecondi",microsecText:"Microsecondi",timezoneText:"Fuso orario",currentText:"Adesso",closeText:"Chiudi",timeFormat:"HH:mm",timeSuffix:"",amNames:["m.","AM","A"],pmNames:["p.","PM","P"],isRTL:!1},a.timepicker.regional.ja={timeOnlyTitle:"時間を選択",timeText:"時間",hourText:"時",minuteText:"分",secondText:"秒",millisecText:"ミリ秒",microsecText:"マイクロ秒",timezoneText:"タイムゾーン",currentText:"現時刻",closeText:"閉じる",timeFormat:"HH:mm",timeSuffix:"",amNames:["午前","AM","A"],pmNames:["午後","PM","P"],isRTL:!1},a.timepicker.regional.ko={timeOnlyTitle:"시간 선택",timeText:"시간",hourText:"시",minuteText:"분",secondText:"초",millisecText:"밀리초",microsecText:"마이크로",timezoneText:"표준 시간대",currentText:"현재 시각",closeText:"닫기",timeFormat:"tt h:mm",timeSuffix:"",amNames:["오전","AM","A"],pmNames:["오후","PM","P"],isRTL:!1},a.timepicker.regional.lt={timeOnlyTitle:"Pasirinkite laiką",timeText:"Laikas",hourText:"Valandos",minuteText:"Minutės",secondText:"Sekundės",millisecText:"Milisekundės",microsecText:"Mikrosekundės",timezoneText:"Laiko zona",currentText:"Dabar",closeText:"Uždaryti",timeFormat:"HH:mm",timeSuffix:"",amNames:["priešpiet","AM","A"],pmNames:["popiet","PM","P"],isRTL:!1},a.timepicker.regional.lv={timeOnlyTitle:"Ievadiet laiku",timeText:"Laiks",hourText:"Stundas",minuteText:"Minūtes",secondText:"Sekundes",millisecText:"Milisekundes",microsecText:"Mikrosekundes",timezoneText:"Laika josla",currentText:"Tagad",closeText:"Aizvērt",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","AM","A"],pmNames:["PM","PM","P"],isRTL:!1},a.timepicker.regional.mk={timeOnlyTitle:"Одберете време",timeText:"Време",hourText:"Час",minuteText:"Минути",secondText:"Секунди",millisecText:"Милисекунди",microsecText:"Микросекунди",timezoneText:"Временска зона",currentText:"Сега",closeText:"Затвори",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.nl={timeOnlyTitle:"Tijdstip",timeText:"Tijd",hourText:"Uur",minuteText:"Minuut",secondText:"Seconde",millisecText:"Milliseconde",microsecText:"Microseconde",timezoneText:"Tijdzone",currentText:"Vandaag",closeText:"Sluiten",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.no={timeOnlyTitle:"Velg tid",timeText:"Tid",hourText:"Time",minuteText:"Minutt",secondText:"Sekund",millisecText:"Millisekund",microsecText:"mikrosekund",timezoneText:"Tidssone",currentText:"Nå",closeText:"Lukk",timeFormat:"HH:mm",timeSuffix:"",amNames:["am","AM","A"],pmNames:["pm","PM","P"],isRTL:!1},a.timepicker.regional.pl={timeOnlyTitle:"Wybierz godzinę",timeText:"Czas",hourText:"Godzina",minuteText:"Minuta",secondText:"Sekunda",millisecText:"Milisekunda",microsecText:"Mikrosekunda",timezoneText:"Strefa czasowa",currentText:"Teraz",closeText:"Gotowe",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional["pt-BR"]={timeOnlyTitle:"Escolha o horário",timeText:"Horário",hourText:"Hora",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milissegundos",microsecText:"Microssegundos",timezoneText:"Fuso horário",currentText:"Agora",closeText:"Fechar",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.pt={timeOnlyTitle:"Escolha uma hora",timeText:"Hora",hourText:"Horas",minuteText:"Minutos",secondText:"Segundos",millisecText:"Milissegundos",microsecText:"Microssegundos",timezoneText:"Fuso horário",currentText:"Agora",closeText:"Fechar",timeFormat:"HH:mm",timeSuffix:"",amNames:["a.m.","AM","A"],pmNames:["p.m.","PM","P"],isRTL:!1},a.timepicker.regional.ro={timeOnlyTitle:"Alegeţi o oră",timeText:"Timp",hourText:"Ore",minuteText:"Minute",secondText:"Secunde",millisecText:"Milisecunde",microsecText:"Microsecunde",timezoneText:"Fus orar",currentText:"Acum",closeText:"Închide",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.ru={timeOnlyTitle:"Выберите время",timeText:"Время",hourText:"Часы",minuteText:"Минуты",secondText:"Секунды",millisecText:"Миллисекунды",microsecText:"Микросекунды",timezoneText:"Часовой пояс",currentText:"Сейчас",closeText:"Закрыть",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.sk={timeOnlyTitle:"Zvoľte čas",timeText:"Čas",hourText:"Hodiny",minuteText:"Minúty",secondText:"Sekundy",millisecText:"Milisekundy",microsecText:"Mikrosekundy",timezoneText:"Časové pásmo",currentText:"Teraz",closeText:"Zavrieť",timeFormat:"H:m",timeSuffix:"",amNames:["dop.","AM","A"],pmNames:["pop.","PM","P"],isRTL:!1},a.timepicker.regional.sl={timeOnlyTitle:"Izberite čas",timeText:"Čas",hourText:"Ura",minuteText:"Minute",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Časovni pas",currentText:"Sedaj",closeText:"Zapri",timeFormat:"HH:mm",timeSuffix:"",amNames:["dop.","AM","A"],pmNames:["pop.","PM","P"],isRTL:!1},a.timepicker.regional.sq={timeOnlyTitle:"Zgjidh orarin",timeText:"Orari",hourText:"Ora",minuteText:"Minuta",secondText:"Sekonda",millisecText:"Minisekonda",microsecText:"Mikrosekonda",timezoneText:"Zona kohore",currentText:"Tani",closeText:"Mbyll",timeFormat:"HH:mm",timeSuffix:"",amNames:["m.","AM","A"],pmNames:["p.","PM","P"],isRTL:!1},a.timepicker.regional["sr-RS"]={timeOnlyTitle:"Одаберите време",timeText:"Време",hourText:"Сати",minuteText:"Минути",secondText:"Секунде",millisecText:"Милисекунде",microsecText:"Микросекунде",timezoneText:"Временска зона",currentText:"Сада",closeText:"Затвори",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional["sr-YU"]={timeOnlyTitle:"Odaberite vreme",timeText:"Vreme",hourText:"Sati",minuteText:"Minuti",secondText:"Sekunde",millisecText:"Milisekunde",microsecText:"Mikrosekunde",timezoneText:"Vremenska zona",currentText:"Sada",closeText:"Zatvori",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.sv={timeOnlyTitle:"Välj en tid",timeText:"Tid",hourText:"Timme",minuteText:"Minut",secondText:"Sekund",millisecText:"Millisekund",microsecText:"Mikrosekund",timezoneText:"Tidszon",currentText:"Nu",closeText:"Stäng",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.th={timeOnlyTitle:"เลือกเวลา",timeText:"เวลา ",hourText:"ชั่วโมง ",minuteText:"นาที",secondText:"วินาที",millisecText:"มิลลิวินาที",microsecText:"ไมโคริวินาที",timezoneText:"เขตเวลา",currentText:"เวลาปัจจุบัน",closeText:"ปิด",timeFormat:"hh:mm tt",timeSuffix:""},a.timepicker.regional.tr={timeOnlyTitle:"Zaman Seçiniz",timeText:"Zaman",hourText:"Saat",minuteText:"Dakika",secondText:"Saniye",millisecText:"Milisaniye",microsecText:"Mikrosaniye",timezoneText:"Zaman Dilimi",currentText:"Şu an",closeText:"Tamam",timeFormat:"HH:mm",timeSuffix:"",amNames:["ÖÖ","Ö"],pmNames:["ÖS","S"],isRTL:!1},a.timepicker.regional.uk={timeOnlyTitle:"Виберіть час",timeText:"Час",hourText:"Години",minuteText:"Хвилини",secondText:"Секунди",millisecText:"Мілісекунди",microsecText:"Мікросекунди",timezoneText:"Часовий пояс",currentText:"Зараз",closeText:"Закрити",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional.vi={timeOnlyTitle:"Chọn giờ",timeText:"Thời gian",hourText:"Giờ",minuteText:"Phút",secondText:"Giây",millisecText:"Mili giây",microsecText:"Micrô giây",timezoneText:"Múi giờ",currentText:"Hiện thời",closeText:"Đóng",timeFormat:"HH:mm",timeSuffix:"",amNames:["SA","S"],pmNames:["CH","C"],isRTL:!1},a.timepicker.regional["zh-CN"]={timeOnlyTitle:"选择时间",timeText:"时间",hourText:"小时",minuteText:"分钟",secondText:"秒钟",millisecText:"毫秒",microsecText:"微秒",timezoneText:"时区",currentText:"现在时间",closeText:"关闭",timeFormat:"HH:mm",timeSuffix:"",amNames:["AM","A"],pmNames:["PM","P"],isRTL:!1},a.timepicker.regional["zh-TW"]={timeOnlyTitle:"選擇時分秒",timeText:"時間",hourText:"時",minuteText:"分",secondText:"秒",millisecText:"毫秒",microsecText:"微秒",timezoneText:"時區",currentText:"現在時間",closeText:"確定",timeFormat:"HH:mm",timeSuffix:"",amNames:["上午","AM","A"],pmNames:["下午","PM","P"],isRTL:!1}}(jQuery);
|
js/jqueryui/jquery-ui-timepicker-addon.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
/*! jQuery Timepicker Addon - v1.
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
-
* Copyright (c)
|
4 |
-
(function($){if($.ui.timepicker=$.ui.timepicker||{},!$.ui.timepicker.version){$.extend($.ui,{timepicker:{version:"1.5.0"}});var Timepicker=function(){this.regional=[],this.regional[""]={currentText:"Now",closeText:"Done",amNames:["AM","A"],pmNames:["PM","P"],timeFormat:"HH:mm",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",millisecText:"Millisecond",microsecText:"Microsecond",timezoneText:"Time Zone",isRTL:!1},this._defaults={showButtonPanel:!0,timeOnly:!1,timeOnlyShowDate:!1,showHour:null,showMinute:null,showSecond:null,showMillisec:null,showMicrosec:null,showTimezone:null,showTime:!0,stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1,stepMicrosec:1,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMin:0,minuteMin:0,secondMin:0,millisecMin:0,microsecMin:0,hourMax:23,minuteMax:59,secondMax:59,millisecMax:999,microsecMax:999,minDateTime:null,maxDateTime:null,maxTime:null,minTime:null,onSelect:null,hourGrid:0,minuteGrid:0,secondGrid:0,millisecGrid:0,microsecGrid:0,alwaysSetTime:!0,separator:" ",altFieldTimeOnly:!0,altTimeFormat:null,altSeparator:null,altTimeSuffix:null,altRedirectFocus:!0,pickerTimeFormat:null,pickerTimeSuffix:null,showTimepicker:!0,timezoneList:null,addSliderAccess:!1,sliderAccessArgs:null,controlType:"slider",defaultValue:null,parse:"strict"},$.extend(this._defaults,this.regional[""])};$.extend(Timepicker.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,millisec_slider:null,microsec_slider:null,timezone_select:null,maxTime:null,minTime:null,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,millisecMinOriginal:null,microsecMinOriginal:null,hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,millisecMaxOriginal:null,microsecMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:null,units:["hour","minute","second","millisec","microsec"],support:{},control:null,setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_newInst:function($input,opts){var tp_inst=new Timepicker,inlineSettings={},fns={},overrides,i;for(var attrName in this._defaults)if(this._defaults.hasOwnProperty(attrName)){var attrValue=$input.attr("time:"+attrName);if(attrValue)try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}overrides={beforeShow:function(e,t){return $.isFunction(tp_inst._defaults.evnts.beforeShow)?tp_inst._defaults.evnts.beforeShow.call($input[0],e,t,tp_inst):void 0},onChangeMonthYear:function(e,t,i){tp_inst._updateDateTime(i),$.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)&&tp_inst._defaults.evnts.onChangeMonthYear.call($input[0],e,t,i,tp_inst)},onClose:function(e,t){tp_inst.timeDefined===!0&&""!==$input.val()&&tp_inst._updateDateTime(t),$.isFunction(tp_inst._defaults.evnts.onClose)&&tp_inst._defaults.evnts.onClose.call($input[0],e,t,tp_inst)}};for(i in overrides)overrides.hasOwnProperty(i)&&(fns[i]=opts[i]||null);tp_inst._defaults=$.extend({},this._defaults,inlineSettings,opts,overrides,{evnts:fns,timepicker:tp_inst}),tp_inst.amNames=$.map(tp_inst._defaults.amNames,function(e){return e.toUpperCase()}),tp_inst.pmNames=$.map(tp_inst._defaults.pmNames,function(e){return e.toUpperCase()}),tp_inst.support=detectSupport(tp_inst._defaults.timeFormat+(tp_inst._defaults.pickerTimeFormat?tp_inst._defaults.pickerTimeFormat:"")+(tp_inst._defaults.altTimeFormat?tp_inst._defaults.altTimeFormat:"")),"string"==typeof tp_inst._defaults.controlType?("slider"===tp_inst._defaults.controlType&&$.ui.slider===void 0&&(tp_inst._defaults.controlType="select"),tp_inst.control=tp_inst._controls[tp_inst._defaults.controlType]):tp_inst.control=tp_inst._defaults.controlType;var timezoneList=[-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];null!==tp_inst._defaults.timezoneList&&(timezoneList=tp_inst._defaults.timezoneList);var tzl=timezoneList.length,tzi=0,tzv=null;if(tzl>0&&"object"!=typeof timezoneList[0])for(;tzl>tzi;tzi++)tzv=timezoneList[tzi],timezoneList[tzi]={value:tzv,label:$.timepicker.timezoneOffsetString(tzv,tp_inst.support.iso8601)};return tp_inst._defaults.timezoneList=timezoneList,tp_inst.timezone=null!==tp_inst._defaults.timezone?$.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone):-1*(new Date).getTimezoneOffset(),tp_inst.hour=tp_inst._defaults.hour<tp_inst._defaults.hourMin?tp_inst._defaults.hourMin:tp_inst._defaults.hour>tp_inst._defaults.hourMax?tp_inst._defaults.hourMax:tp_inst._defaults.hour,tp_inst.minute=tp_inst._defaults.minute<tp_inst._defaults.minuteMin?tp_inst._defaults.minuteMin:tp_inst._defaults.minute>tp_inst._defaults.minuteMax?tp_inst._defaults.minuteMax:tp_inst._defaults.minute,tp_inst.second=tp_inst._defaults.second<tp_inst._defaults.secondMin?tp_inst._defaults.secondMin:tp_inst._defaults.second>tp_inst._defaults.secondMax?tp_inst._defaults.secondMax:tp_inst._defaults.second,tp_inst.millisec=tp_inst._defaults.millisec<tp_inst._defaults.millisecMin?tp_inst._defaults.millisecMin:tp_inst._defaults.millisec>tp_inst._defaults.millisecMax?tp_inst._defaults.millisecMax:tp_inst._defaults.millisec,tp_inst.microsec=tp_inst._defaults.microsec<tp_inst._defaults.microsecMin?tp_inst._defaults.microsecMin:tp_inst._defaults.microsec>tp_inst._defaults.microsecMax?tp_inst._defaults.microsecMax:tp_inst._defaults.microsec,tp_inst.ampm="",tp_inst.$input=$input,tp_inst._defaults.altField&&(tp_inst.$altInput=$(tp_inst._defaults.altField),tp_inst._defaults.altRedirectFocus===!0&&tp_inst.$altInput.css({cursor:"pointer"}).focus(function(){$input.trigger("focus")})),(0===tp_inst._defaults.minDate||0===tp_inst._defaults.minDateTime)&&(tp_inst._defaults.minDate=new Date),(0===tp_inst._defaults.maxDate||0===tp_inst._defaults.maxDateTime)&&(tp_inst._defaults.maxDate=new Date),void 0!==tp_inst._defaults.minDate&&tp_inst._defaults.minDate instanceof Date&&(tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime())),void 0!==tp_inst._defaults.minDateTime&&tp_inst._defaults.minDateTime instanceof Date&&(tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime())),void 0!==tp_inst._defaults.maxDate&&tp_inst._defaults.maxDate instanceof Date&&(tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime())),void 0!==tp_inst._defaults.maxDateTime&&tp_inst._defaults.maxDateTime instanceof Date&&(tp_inst._defaults.maxDate=new Date(tp_inst._defaults.maxDateTime.getTime())),tp_inst.$input.bind("focus",function(){tp_inst._onFocus()}),tp_inst},_addTimePicker:function(e){var t=this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val();this.timeDefined=this._parseTime(t),this._limitMinMaxDateTime(e,!1),this._injectTimePicker()},_parseTime:function(e,t){if(this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),t||!this._defaults.timeOnly){var i=$.datepicker._get(this.inst,"dateFormat");try{var s=parseDateTimeInternal(i,this._defaults.timeFormat,e,$.datepicker._getFormatConfig(this.inst),this._defaults);if(!s.timeObj)return!1;$.extend(this,s.timeObj)}catch(a){return $.timepicker.log("Error parsing the date/time string: "+a+"\ndate/time string = "+e+"\ntimeFormat = "+this._defaults.timeFormat+"\ndateFormat = "+i),!1}return!0}var n=$.datepicker.parseTime(this._defaults.timeFormat,e,this._defaults);return n?($.extend(this,n),!0):!1},_injectTimePicker:function(){var e=this.inst.dpDiv,t=this.inst.settings,i=this,s="",a="",n=null,r={},l={},o=null,c=0,u=0;if(0===e.find("div.ui-timepicker-div").length&&t.showTimepicker){var m=' style="display:none;"',d='<div class="ui-timepicker-div'+(t.isRTL?" ui-timepicker-rtl":"")+'"><dl>'+'<dt class="ui_tpicker_time_label"'+(t.showTime?"":m)+">"+t.timeText+"</dt>"+'<dd class="ui_tpicker_time"'+(t.showTime?"":m)+"></dd>";for(c=0,u=this.units.length;u>c;c++){if(s=this.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],r[s]=parseInt(t[s+"Max"]-(t[s+"Max"]-t[s+"Min"])%t["step"+a],10),l[s]=0,d+='<dt class="ui_tpicker_'+s+'_label"'+(n?"":m)+">"+t[s+"Text"]+"</dt>"+'<dd class="ui_tpicker_'+s+'"><div class="ui_tpicker_'+s+'_slider"'+(n?"":m)+"></div>",n&&t[s+"Grid"]>0){if(d+='<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>',"hour"===s)for(var h=t[s+"Min"];r[s]>=h;h+=parseInt(t[s+"Grid"],10)){l[s]++;var p=$.datepicker.formatTime(this.support.ampm?"hht":"HH",{hour:h},t);d+='<td data-for="'+s+'">'+p+"</td>"}else for(var _=t[s+"Min"];r[s]>=_;_+=parseInt(t[s+"Grid"],10))l[s]++,d+='<td data-for="'+s+'">'+(10>_?"0":"")+_+"</td>";d+="</tr></table></div>"}d+="</dd>"}var f=null!==t.showTimezone?t.showTimezone:this.support.timezone;d+='<dt class="ui_tpicker_timezone_label"'+(f?"":m)+">"+t.timezoneText+"</dt>",d+='<dd class="ui_tpicker_timezone" '+(f?"":m)+"></dd>",d+="</dl></div>";var g=$(d);for(t.timeOnly===!0&&(g.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">'+t.timeOnlyTitle+"</div>"+"</div>"),e.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()),c=0,u=i.units.length;u>c;c++)s=i.units[c],a=s.substr(0,1).toUpperCase()+s.substr(1),n=null!==t["show"+a]?t["show"+a]:this.support[s],i[s+"_slider"]=i.control.create(i,g.find(".ui_tpicker_"+s+"_slider"),s,i[s],t[s+"Min"],r[s],t["step"+a]),n&&t[s+"Grid"]>0&&(o=100*l[s]*t[s+"Grid"]/(r[s]-t[s+"Min"]),g.find(".ui_tpicker_"+s+" table").css({width:o+"%",marginLeft:t.isRTL?"0":o/(-2*l[s])+"%",marginRight:t.isRTL?o/(-2*l[s])+"%":"0",borderCollapse:"collapse"}).find("td").click(function(){var e=$(this),t=e.html(),a=parseInt(t.replace(/[^0-9]/g),10),n=t.replace(/[^apm]/gi),r=e.data("for");"hour"===r&&(-1!==n.indexOf("p")&&12>a?a+=12:-1!==n.indexOf("a")&&12===a&&(a=0)),i.control.value(i,i[r+"_slider"],s,a),i._onTimeChange(),i._onSelectHandler()}).css({cursor:"pointer",width:100/l[s]+"%",textAlign:"center",overflow:"hidden"}));if(this.timezone_select=g.find(".ui_tpicker_timezone").append("<select></select>").find("select"),$.fn.append.apply(this.timezone_select,$.map(t.timezoneList,function(e){return $("<option />").val("object"==typeof e?e.value:e).text("object"==typeof e?e.label:e)})),this.timezone!==void 0&&null!==this.timezone&&""!==this.timezone){var M=-1*new Date(this.inst.selectedYear,this.inst.selectedMonth,this.inst.selectedDay,12).getTimezoneOffset();M===this.timezone?selectLocalTimezone(i):this.timezone_select.val(this.timezone)}else this.hour!==void 0&&null!==this.hour&&""!==this.hour?this.timezone_select.val(t.timezone):selectLocalTimezone(i);this.timezone_select.change(function(){i._onTimeChange(),i._onSelectHandler()});var v=e.find(".ui-datepicker-buttonpane");if(v.length?v.before(g):e.append(g),this.$timeObj=g.find(".ui_tpicker_time"),null!==this.inst){var k=this.timeDefined;this._onTimeChange(),this.timeDefined=k}if(this._defaults.addSliderAccess){var T=this._defaults.sliderAccessArgs,D=this._defaults.isRTL;T.isRTL=D,setTimeout(function(){if(0===g.find(".ui-slider-access").length){g.find(".ui-slider:visible").sliderAccess(T);var e=g.find(".ui-slider-access:eq(0)").outerWidth(!0);e&&g.find("table:visible").each(function(){var t=$(this),i=t.outerWidth(),s=(""+t.css(D?"marginRight":"marginLeft")).replace("%",""),a=i-e,n=s*a/i+"%",r={width:a,marginRight:0,marginLeft:0};r[D?"marginRight":"marginLeft"]=n,t.css(r)})}},10)}i._limitMinMaxDateTime(this.inst,!0)}},_limitMinMaxDateTime:function(e,t){var i=this._defaults,s=new Date(e.selectedYear,e.selectedMonth,e.selectedDay);if(this._defaults.showTimepicker){if(null!==$.datepicker._get(e,"minDateTime")&&void 0!==$.datepicker._get(e,"minDateTime")&&s){var a=$.datepicker._get(e,"minDateTime"),n=new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0,0);(null===this.hourMinOriginal||null===this.minuteMinOriginal||null===this.secondMinOriginal||null===this.millisecMinOriginal||null===this.microsecMinOriginal)&&(this.hourMinOriginal=i.hourMin,this.minuteMinOriginal=i.minuteMin,this.secondMinOriginal=i.secondMin,this.millisecMinOriginal=i.millisecMin,this.microsecMinOriginal=i.microsecMin),e.settings.timeOnly||n.getTime()===s.getTime()?(this._defaults.hourMin=a.getHours(),this.hour<=this._defaults.hourMin?(this.hour=this._defaults.hourMin,this._defaults.minuteMin=a.getMinutes(),this.minute<=this._defaults.minuteMin?(this.minute=this._defaults.minuteMin,this._defaults.secondMin=a.getSeconds(),this.second<=this._defaults.secondMin?(this.second=this._defaults.secondMin,this._defaults.millisecMin=a.getMilliseconds(),this.millisec<=this._defaults.millisecMin?(this.millisec=this._defaults.millisecMin,this._defaults.microsecMin=a.getMicroseconds()):(this.microsec<this._defaults.microsecMin&&(this.microsec=this._defaults.microsecMin),this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.hourMin=this.hourMinOriginal,this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)}if(null!==$.datepicker._get(e,"maxDateTime")&&void 0!==$.datepicker._get(e,"maxDateTime")&&s){var r=$.datepicker._get(e,"maxDateTime"),l=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0,0);(null===this.hourMaxOriginal||null===this.minuteMaxOriginal||null===this.secondMaxOriginal||null===this.millisecMaxOriginal)&&(this.hourMaxOriginal=i.hourMax,this.minuteMaxOriginal=i.minuteMax,this.secondMaxOriginal=i.secondMax,this.millisecMaxOriginal=i.millisecMax,this.microsecMaxOriginal=i.microsecMax),e.settings.timeOnly||l.getTime()===s.getTime()?(this._defaults.hourMax=r.getHours(),this.hour>=this._defaults.hourMax?(this.hour=this._defaults.hourMax,this._defaults.minuteMax=r.getMinutes(),this.minute>=this._defaults.minuteMax?(this.minute=this._defaults.minuteMax,this._defaults.secondMax=r.getSeconds(),this.second>=this._defaults.secondMax?(this.second=this._defaults.secondMax,this._defaults.millisecMax=r.getMilliseconds(),this.millisec>=this._defaults.millisecMax?(this.millisec=this._defaults.millisecMax,this._defaults.microsecMax=r.getMicroseconds()):(this.microsec>this._defaults.microsecMax&&(this.microsec=this._defaults.microsecMax),this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.hourMax=this.hourMaxOriginal,this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)}if(null!==e.settings.minTime){var o=new Date("01/01/1970 "+e.settings.minTime);this.hour<o.getHours()?(this.hour=this._defaults.hourMin=o.getHours(),this.minute=this._defaults.minuteMin=o.getMinutes()):this.hour===o.getHours()&&this.minute<o.getMinutes()?this.minute=this._defaults.minuteMin=o.getMinutes():this._defaults.hourMin<o.getHours()?(this._defaults.hourMin=o.getHours(),this._defaults.minuteMin=o.getMinutes()):this._defaults.minuteMin=this._defaults.hourMin===o.getHours()===this.hour&&this._defaults.minuteMin<o.getMinutes()?o.getMinutes():0}if(null!==e.settings.maxTime){var c=new Date("01/01/1970 "+e.settings.maxTime);this.hour>c.getHours()?(this.hour=this._defaults.hourMax=c.getHours(),this.minute=this._defaults.minuteMax=c.getMinutes()):this.hour===c.getHours()&&this.minute>c.getMinutes()?this.minute=this._defaults.minuteMax=c.getMinutes():this._defaults.hourMax>c.getHours()?(this._defaults.hourMax=c.getHours(),this._defaults.minuteMax=c.getMinutes()):this._defaults.minuteMax=this._defaults.hourMax===c.getHours()===this.hour&&this._defaults.minuteMax>c.getMinutes()?c.getMinutes():59}if(void 0!==t&&t===!0){var u=parseInt(this._defaults.hourMax-(this._defaults.hourMax-this._defaults.hourMin)%this._defaults.stepHour,10),m=parseInt(this._defaults.minuteMax-(this._defaults.minuteMax-this._defaults.minuteMin)%this._defaults.stepMinute,10),d=parseInt(this._defaults.secondMax-(this._defaults.secondMax-this._defaults.secondMin)%this._defaults.stepSecond,10),h=parseInt(this._defaults.millisecMax-(this._defaults.millisecMax-this._defaults.millisecMin)%this._defaults.stepMillisec,10),p=parseInt(this._defaults.microsecMax-(this._defaults.microsecMax-this._defaults.microsecMin)%this._defaults.stepMicrosec,10);this.hour_slider&&(this.control.options(this,this.hour_slider,"hour",{min:this._defaults.hourMin,max:u,step:this._defaults.stepHour}),this.control.value(this,this.hour_slider,"hour",this.hour-this.hour%this._defaults.stepHour)),this.minute_slider&&(this.control.options(this,this.minute_slider,"minute",{min:this._defaults.minuteMin,max:m,step:this._defaults.stepMinute}),this.control.value(this,this.minute_slider,"minute",this.minute-this.minute%this._defaults.stepMinute)),this.second_slider&&(this.control.options(this,this.second_slider,"second",{min:this._defaults.secondMin,max:d,step:this._defaults.stepSecond}),this.control.value(this,this.second_slider,"second",this.second-this.second%this._defaults.stepSecond)),this.millisec_slider&&(this.control.options(this,this.millisec_slider,"millisec",{min:this._defaults.millisecMin,max:h,step:this._defaults.stepMillisec}),this.control.value(this,this.millisec_slider,"millisec",this.millisec-this.millisec%this._defaults.stepMillisec)),this.microsec_slider&&(this.control.options(this,this.microsec_slider,"microsec",{min:this._defaults.microsecMin,max:p,step:this._defaults.stepMicrosec}),this.control.value(this,this.microsec_slider,"microsec",this.microsec-this.microsec%this._defaults.stepMicrosec))}}},_onTimeChange:function(){if(this._defaults.showTimepicker){var e=this.hour_slider?this.control.value(this,this.hour_slider,"hour"):!1,t=this.minute_slider?this.control.value(this,this.minute_slider,"minute"):!1,i=this.second_slider?this.control.value(this,this.second_slider,"second"):!1,s=this.millisec_slider?this.control.value(this,this.millisec_slider,"millisec"):!1,a=this.microsec_slider?this.control.value(this,this.microsec_slider,"microsec"):!1,n=this.timezone_select?this.timezone_select.val():!1,r=this._defaults,l=r.pickerTimeFormat||r.timeFormat,o=r.pickerTimeSuffix||r.timeSuffix;"object"==typeof e&&(e=!1),"object"==typeof t&&(t=!1),"object"==typeof i&&(i=!1),"object"==typeof s&&(s=!1),"object"==typeof a&&(a=!1),"object"==typeof n&&(n=!1),e!==!1&&(e=parseInt(e,10)),t!==!1&&(t=parseInt(t,10)),i!==!1&&(i=parseInt(i,10)),s!==!1&&(s=parseInt(s,10)),a!==!1&&(a=parseInt(a,10)),n!==!1&&(n=""+n);var c=r[12>e?"amNames":"pmNames"][0],u=e!==parseInt(this.hour,10)||t!==parseInt(this.minute,10)||i!==parseInt(this.second,10)||s!==parseInt(this.millisec,10)||a!==parseInt(this.microsec,10)||this.ampm.length>0&&12>e!=(-1!==$.inArray(this.ampm.toUpperCase(),this.amNames))||null!==this.timezone&&n!==""+this.timezone;u&&(e!==!1&&(this.hour=e),t!==!1&&(this.minute=t),i!==!1&&(this.second=i),s!==!1&&(this.millisec=s),a!==!1&&(this.microsec=a),n!==!1&&(this.timezone=n),this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),this._limitMinMaxDateTime(this.inst,!0)),this.support.ampm&&(this.ampm=c),this.formattedTime=$.datepicker.formatTime(r.timeFormat,this,r),this.$timeObj&&(l===r.timeFormat?this.$timeObj.text(this.formattedTime+o):this.$timeObj.text($.datepicker.formatTime(l,this,r)+o)),this.timeDefined=!0,u&&this._updateDateTime()}},_onSelectHandler:function(){var e=this._defaults.onSelect||this.inst.settings.onSelect,t=this.$input?this.$input[0]:null;e&&t&&e.apply(t,[this.formattedDateTime,this])},_updateDateTime:function(e){e=this.inst||e;var t=e.currentYear>0?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(e.selectedYear,e.selectedMonth,e.selectedDay),i=$.datepicker._daylightSavingAdjust(t),s=$.datepicker._get(e,"dateFormat"),a=$.datepicker._getFormatConfig(e),n=null!==i&&this.timeDefined;this.formattedDate=$.datepicker.formatDate(s,null===i?new Date:i,a);var r=this.formattedDate;if(""===e.lastVal&&(e.currentYear=e.selectedYear,e.currentMonth=e.selectedMonth,e.currentDay=e.selectedDay),this._defaults.timeOnly===!0&&this._defaults.timeOnlyShowDate===!1?r=this.formattedTime:(this._defaults.timeOnly!==!0&&(this._defaults.alwaysSetTime||n)||this._defaults.timeOnly===!0&&this._defaults.timeOnlyShowDate===!0)&&(r+=this._defaults.separator+this.formattedTime+this._defaults.timeSuffix),this.formattedDateTime=r,this._defaults.showTimepicker)if(this.$altInput&&this._defaults.timeOnly===!1&&this._defaults.altFieldTimeOnly===!0)this.$altInput.val(this.formattedTime),this.$input.val(this.formattedDate);else if(this.$altInput){this.$input.val(r);var l="",o=null!==this._defaults.altSeparator?this._defaults.altSeparator:this._defaults.separator,c=null!==this._defaults.altTimeSuffix?this._defaults.altTimeSuffix:this._defaults.timeSuffix;this._defaults.timeOnly||(l=this._defaults.altFormat?$.datepicker.formatDate(this._defaults.altFormat,null===i?new Date:i,a):this.formattedDate,l&&(l+=o)),l+=null!==this._defaults.altTimeFormat?$.datepicker.formatTime(this._defaults.altTimeFormat,this,this._defaults)+c:this.formattedTime+c,this.$altInput.val(l)}else this.$input.val(r);else this.$input.val(this.formattedDate);this.$input.trigger("change")},_onFocus:function(){if(!this.$input.val()&&this._defaults.defaultValue){this.$input.val(this._defaults.defaultValue);var e=$.datepicker._getInst(this.$input.get(0)),t=$.datepicker._get(e,"timepicker");if(t&&t._defaults.timeOnly&&e.input.val()!==e.lastVal)try{$.datepicker._updateDatepicker(e)}catch(i){$.timepicker.log(i)}}},_controls:{slider:{create:function(e,t,i,s,a,n,r){var l=e._defaults.isRTL;return t.prop("slide",null).slider({orientation:"horizontal",value:l?-1*s:s,min:l?-1*n:a,max:l?-1*a:n,step:r,slide:function(t,s){e.control.value(e,$(this),i,l?-1*s.value:s.value),e._onTimeChange()},stop:function(){e._onSelectHandler()}})},options:function(e,t,i,s,a){if(e._defaults.isRTL){if("string"==typeof s)return"min"===s||"max"===s?void 0!==a?t.slider(s,-1*a):Math.abs(t.slider(s)):t.slider(s);var n=s.min,r=s.max;return s.min=s.max=null,void 0!==n&&(s.max=-1*n),void 0!==r&&(s.min=-1*r),t.slider(s)}return"string"==typeof s&&void 0!==a?t.slider(s,a):t.slider(s)},value:function(e,t,i,s){return e._defaults.isRTL?void 0!==s?t.slider("value",-1*s):Math.abs(t.slider("value")):void 0!==s?t.slider("value",s):t.slider("value")}},select:{create:function(e,t,i,s,a,n,r){for(var l='<select class="ui-timepicker-select ui-state-default ui-corner-all" data-unit="'+i+'" data-min="'+a+'" data-max="'+n+'" data-step="'+r+'">',o=e._defaults.pickerTimeFormat||e._defaults.timeFormat,c=a;n>=c;c+=r)l+='<option value="'+c+'"'+(c===s?" selected":"")+">",l+="hour"===i?$.datepicker.formatTime($.trim(o.replace(/[^ht ]/gi,"")),{hour:c},e._defaults):"millisec"===i||"microsec"===i||c>=10?c:"0"+(""+c),l+="</option>";return l+="</select>",t.children("select").remove(),$(l).appendTo(t).change(function(){e._onTimeChange(),e._onSelectHandler()}),t},options:function(e,t,i,s,a){var n={},r=t.children("select");if("string"==typeof s){if(void 0===a)return r.data(s);n[s]=a}else n=s;return e.control.create(e,t,r.data("unit"),r.val(),n.min||r.data("min"),n.max||r.data("max"),n.step||r.data("step"))},value:function(e,t,i,s){var a=t.children("select");return void 0!==s?a.val(s):a.val()}}}}),$.fn.extend({timepicker:function(e){e=e||{};var t=Array.prototype.slice.call(arguments);return"object"==typeof e&&(t[0]=$.extend(e,{timeOnly:!0})),$(this).each(function(){$.fn.datetimepicker.apply($(this),t)})},datetimepicker:function(e){e=e||{};var t=arguments;return"string"==typeof e?"getDate"===e||"option"===e&&2===t.length&&"string"==typeof t[1]?$.fn.datepicker.apply($(this[0]),t):this.each(function(){var e=$(this);e.datepicker.apply(e,t)}):this.each(function(){var t=$(this);t.datepicker($.timepicker._newInst(t,e)._defaults)})}}),$.datepicker.parseDateTime=function(e,t,i,s,a){var n=parseDateTimeInternal(e,t,i,s,a);if(n.timeObj){var r=n.timeObj;n.date.setHours(r.hour,r.minute,r.second,r.millisec),n.date.setMicroseconds(r.microsec)}return n.date},$.datepicker.parseTime=function(e,t,i){var s=extendRemove(extendRemove({},$.timepicker._defaults),i||{});-1!==e.replace(/\'.*?\'/g,"").indexOf("Z");var a=function(e,t,i){var s,a=function(e,t){var i=[];return e&&$.merge(i,e),t&&$.merge(i,t),i=$.map(i,function(e){return e.replace(/[.*+?|()\[\]{}\\]/g,"\\$&")}),"("+i.join("|")+")?"},n=function(e){var t=e.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),i={h:-1,m:-1,s:-1,l:-1,c:-1,t:-1,z:-1};if(t)for(var s=0;t.length>s;s++)-1===i[(""+t[s]).charAt(0)]&&(i[(""+t[s]).charAt(0)]=s+1);return i},r="^"+(""+e).replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){var t=e.length;switch(e.charAt(0).toLowerCase()){case"h":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"m":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"s":return 1===t?"(\\d?\\d)":"(\\d{"+t+"})";case"l":return"(\\d?\\d?\\d)";case"c":return"(\\d?\\d?\\d)";case"z":return"(z|[-+]\\d\\d:?\\d\\d|\\S+)?";case"t":return a(i.amNames,i.pmNames);default:return"("+e.replace(/\'/g,"").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g,function(e){return"\\"+e})+")?"}}).replace(/\s/g,"\\s?")+i.timeSuffix+"$",l=n(e),o="";s=t.match(RegExp(r,"i"));var c={hour:0,minute:0,second:0,millisec:0,microsec:0};return s?(-1!==l.t&&(void 0===s[l.t]||0===s[l.t].length?(o="",c.ampm=""):(o=-1!==$.inArray(s[l.t].toUpperCase(),i.amNames)?"AM":"PM",c.ampm=i["AM"===o?"amNames":"pmNames"][0])),-1!==l.h&&(c.hour="AM"===o&&"12"===s[l.h]?0:"PM"===o&&"12"!==s[l.h]?parseInt(s[l.h],10)+12:Number(s[l.h])),-1!==l.m&&(c.minute=Number(s[l.m])),-1!==l.s&&(c.second=Number(s[l.s])),-1!==l.l&&(c.millisec=Number(s[l.l])),-1!==l.c&&(c.microsec=Number(s[l.c])),-1!==l.z&&void 0!==s[l.z]&&(c.timezone=$.timepicker.timezoneOffsetNumber(s[l.z])),c):!1},n=function(e,t,i){try{var s=new Date("2012-01-01 "+t);if(isNaN(s.getTime())&&(s=new Date("2012-01-01T"+t),isNaN(s.getTime())&&(s=new Date("01/01/2012 "+t),isNaN(s.getTime()))))throw"Unable to parse time with native Date: "+t;return{hour:s.getHours(),minute:s.getMinutes(),second:s.getSeconds(),millisec:s.getMilliseconds(),microsec:s.getMicroseconds(),timezone:-1*s.getTimezoneOffset()}}catch(n){try{return a(e,t,i)}catch(r){$.timepicker.log("Unable to parse \ntimeString: "+t+"\ntimeFormat: "+e)}}return!1};return"function"==typeof s.parse?s.parse(e,t,s):"loose"===s.parse?n(e,t,s):a(e,t,s)},$.datepicker.formatTime=function(e,t,i){i=i||{},i=$.extend({},$.timepicker._defaults,i),t=$.extend({hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null},t);var s=e,a=i.amNames[0],n=parseInt(t.hour,10);return n>11&&(a=i.pmNames[0]),s=s.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(e){switch(e){case"HH":return("0"+n).slice(-2);case"H":return n;case"hh":return("0"+convert24to12(n)).slice(-2);case"h":return convert24to12(n);case"mm":return("0"+t.minute).slice(-2);case"m":return t.minute;case"ss":return("0"+t.second).slice(-2);case"s":return t.second;case"l":return("00"+t.millisec).slice(-3);case"c":return("00"+t.microsec).slice(-3);case"z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!1);case"Z":return $.timepicker.timezoneOffsetString(null===t.timezone?i.timezone:t.timezone,!0);case"T":return a.charAt(0).toUpperCase();case"TT":return a.toUpperCase();case"t":return a.charAt(0).toLowerCase();case"tt":return a.toLowerCase();default:return e.replace(/'/g,"")}})},$.datepicker._base_selectDate=$.datepicker._selectDate,$.datepicker._selectDate=function(e,t){var i,s=this._getInst($(e)[0]),a=this._get(s,"timepicker");a&&s.settings.showTimepicker?(a._limitMinMaxDateTime(s,!0),i=s.inline,s.inline=s.stay_open=!0,this._base_selectDate(e,t),s.inline=i,s.stay_open=!1,this._notifyChange(s),this._updateDatepicker(s)):this._base_selectDate(e,t)},$.datepicker._base_updateDatepicker=$.datepicker._updateDatepicker,$.datepicker._updateDatepicker=function(e){var t=e.input[0];if(!($.datepicker._curInst&&$.datepicker._curInst!==e&&$.datepicker._datepickerShowing&&$.datepicker._lastInput!==t||"boolean"==typeof e.stay_open&&e.stay_open!==!1)){this._base_updateDatepicker(e);var i=this._get(e,"timepicker");i&&i._addTimePicker(e)}},$.datepicker._base_doKeyPress=$.datepicker._doKeyPress,$.datepicker._doKeyPress=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&$.datepicker._get(t,"constrainInput")){var s=i.support.ampm,a=null!==i._defaults.showTimezone?i._defaults.showTimezone:i.support.timezone,n=$.datepicker._possibleChars($.datepicker._get(t,"dateFormat")),r=(""+i._defaults.timeFormat).replace(/[hms]/g,"").replace(/TT/g,s?"APM":"").replace(/Tt/g,s?"AaPpMm":"").replace(/tT/g,s?"AaPpMm":"").replace(/T/g,s?"AP":"").replace(/tt/g,s?"apm":"").replace(/t/g,s?"ap":"")+" "+i._defaults.separator+i._defaults.timeSuffix+(a?i._defaults.timezoneList.join(""):"")+i._defaults.amNames.join("")+i._defaults.pmNames.join("")+n,l=String.fromCharCode(void 0===e.charCode?e.keyCode:e.charCode);return e.ctrlKey||" ">l||!n||r.indexOf(l)>-1}return $.datepicker._base_doKeyPress(e)},$.datepicker._base_updateAlternate=$.datepicker._updateAlternate,$.datepicker._updateAlternate=function(e){var t=this._get(e,"timepicker");if(t){var i=t._defaults.altField;if(i){var s=(t._defaults.altFormat||t._defaults.dateFormat,this._getDate(e)),a=$.datepicker._getFormatConfig(e),n="",r=t._defaults.altSeparator?t._defaults.altSeparator:t._defaults.separator,l=t._defaults.altTimeSuffix?t._defaults.altTimeSuffix:t._defaults.timeSuffix,o=null!==t._defaults.altTimeFormat?t._defaults.altTimeFormat:t._defaults.timeFormat;n+=$.datepicker.formatTime(o,t,t._defaults)+l,t._defaults.timeOnly||t._defaults.altFieldTimeOnly||null===s||(n=t._defaults.altFormat?$.datepicker.formatDate(t._defaults.altFormat,s,a)+r+n:t.formattedDate+r+n),$(i).val(e.input.val()?n:"")}}else $.datepicker._base_updateAlternate(e)},$.datepicker._base_doKeyUp=$.datepicker._doKeyUp,$.datepicker._doKeyUp=function(e){var t=$.datepicker._getInst(e.target),i=$.datepicker._get(t,"timepicker");if(i&&i._defaults.timeOnly&&t.input.val()!==t.lastVal)try{$.datepicker._updateDatepicker(t)}catch(s){$.timepicker.log(s)}return $.datepicker._base_doKeyUp(e)},$.datepicker._base_gotoToday=$.datepicker._gotoToday,$.datepicker._gotoToday=function(e){var t=this._getInst($(e)[0]);t.dpDiv,this._base_gotoToday(e);var i=this._get(t,"timepicker");selectLocalTimezone(i);var s=new Date;this._setTime(t,s),this._setDate(t,s)},$.datepicker._disableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!1,i._defaults.showTimepicker=!1,i._updateDateTime(t))}},$.datepicker._enableTimepickerDatepicker=function(e){var t=this._getInst(e);if(t){var i=this._get(t,"timepicker");$(e).datepicker("getDate"),i&&(t.settings.showTimepicker=!0,i._defaults.showTimepicker=!0,i._addTimePicker(t),i._updateDateTime(t))}},$.datepicker._setTime=function(e,t){var i=this._get(e,"timepicker");if(i){var s=i._defaults;
|
5 |
-
|
1 |
+
/*! jQuery Timepicker Addon - v1.6.3 - 2016-04-20
|
2 |
* http://trentrichardson.com/examples/timepicker
|
3 |
+
* Copyright (c) 2016 Trent Richardson; Licensed MIT */
|
4 |
+
!function(a){"function"==typeof define&&define.amd?define(["jquery","jquery-ui"],a):a(jQuery)}(function($){if($.ui.timepicker=$.ui.timepicker||{},!$.ui.timepicker.version){$.extend($.ui,{timepicker:{version:"1.6.3"}});var Timepicker=function(){this.regional=[],this.regional[""]={currentText:"Now",closeText:"Done",amNames:["AM","A"],pmNames:["PM","P"],timeFormat:"HH:mm",timeSuffix:"",timeOnlyTitle:"Choose Time",timeText:"Time",hourText:"Hour",minuteText:"Minute",secondText:"Second",millisecText:"Millisecond",microsecText:"Microsecond",timezoneText:"Time Zone",isRTL:!1},this._defaults={showButtonPanel:!0,timeOnly:!1,timeOnlyShowDate:!1,showHour:null,showMinute:null,showSecond:null,showMillisec:null,showMicrosec:null,showTimezone:null,showTime:!0,stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1,stepMicrosec:1,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMin:0,minuteMin:0,secondMin:0,millisecMin:0,microsecMin:0,hourMax:23,minuteMax:59,secondMax:59,millisecMax:999,microsecMax:999,minDateTime:null,maxDateTime:null,maxTime:null,minTime:null,onSelect:null,hourGrid:0,minuteGrid:0,secondGrid:0,millisecGrid:0,microsecGrid:0,alwaysSetTime:!0,separator:" ",altFieldTimeOnly:!0,altTimeFormat:null,altSeparator:null,altTimeSuffix:null,altRedirectFocus:!0,pickerTimeFormat:null,pickerTimeSuffix:null,showTimepicker:!0,timezoneList:null,addSliderAccess:!1,sliderAccessArgs:null,controlType:"slider",oneLine:!1,defaultValue:null,parse:"strict",afterInject:null},$.extend(this._defaults,this.regional[""])};$.extend(Timepicker.prototype,{$input:null,$altInput:null,$timeObj:null,inst:null,hour_slider:null,minute_slider:null,second_slider:null,millisec_slider:null,microsec_slider:null,timezone_select:null,maxTime:null,minTime:null,hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null,hourMinOriginal:null,minuteMinOriginal:null,secondMinOriginal:null,millisecMinOriginal:null,microsecMinOriginal:null,hourMaxOriginal:null,minuteMaxOriginal:null,secondMaxOriginal:null,millisecMaxOriginal:null,microsecMaxOriginal:null,ampm:"",formattedDate:"",formattedTime:"",formattedDateTime:"",timezoneList:null,units:["hour","minute","second","millisec","microsec"],support:{},control:null,setDefaults:function(a){return extendRemove(this._defaults,a||{}),this},_newInst:function($input,opts){var tp_inst=new Timepicker,inlineSettings={},fns={},overrides,i;for(var attrName in this._defaults)if(this._defaults.hasOwnProperty(attrName)){var attrValue=$input.attr("time:"+attrName);if(attrValue)try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}overrides={beforeShow:function(a,b){return $.isFunction(tp_inst._defaults.evnts.beforeShow)?tp_inst._defaults.evnts.beforeShow.call($input[0],a,b,tp_inst):void 0},onChangeMonthYear:function(a,b,c){$.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)&&tp_inst._defaults.evnts.onChangeMonthYear.call($input[0],a,b,c,tp_inst)},onClose:function(a,b){tp_inst.timeDefined===!0&&""!==$input.val()&&tp_inst._updateDateTime(b),$.isFunction(tp_inst._defaults.evnts.onClose)&&tp_inst._defaults.evnts.onClose.call($input[0],a,b,tp_inst)}};for(i in overrides)overrides.hasOwnProperty(i)&&(fns[i]=opts[i]||this._defaults[i]||null);tp_inst._defaults=$.extend({},this._defaults,inlineSettings,opts,overrides,{evnts:fns,timepicker:tp_inst}),tp_inst.amNames=$.map(tp_inst._defaults.amNames,function(a){return a.toUpperCase()}),tp_inst.pmNames=$.map(tp_inst._defaults.pmNames,function(a){return a.toUpperCase()}),tp_inst.support=detectSupport(tp_inst._defaults.timeFormat+(tp_inst._defaults.pickerTimeFormat?tp_inst._defaults.pickerTimeFormat:"")+(tp_inst._defaults.altTimeFormat?tp_inst._defaults.altTimeFormat:"")),"string"==typeof tp_inst._defaults.controlType?("slider"===tp_inst._defaults.controlType&&"undefined"==typeof $.ui.slider&&(tp_inst._defaults.controlType="select"),tp_inst.control=tp_inst._controls[tp_inst._defaults.controlType]):tp_inst.control=tp_inst._defaults.controlType;var timezoneList=[-720,-660,-600,-570,-540,-480,-420,-360,-300,-270,-240,-210,-180,-120,-60,0,60,120,180,210,240,270,300,330,345,360,390,420,480,525,540,570,600,630,660,690,720,765,780,840];null!==tp_inst._defaults.timezoneList&&(timezoneList=tp_inst._defaults.timezoneList);var tzl=timezoneList.length,tzi=0,tzv=null;if(tzl>0&&"object"!=typeof timezoneList[0])for(;tzl>tzi;tzi++)tzv=timezoneList[tzi],timezoneList[tzi]={value:tzv,label:$.timepicker.timezoneOffsetString(tzv,tp_inst.support.iso8601)};return tp_inst._defaults.timezoneList=timezoneList,tp_inst.timezone=null!==tp_inst._defaults.timezone?$.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone):-1*(new Date).getTimezoneOffset(),tp_inst.hour=tp_inst._defaults.hour<tp_inst._defaults.hourMin?tp_inst._defaults.hourMin:tp_inst._defaults.hour>tp_inst._defaults.hourMax?tp_inst._defaults.hourMax:tp_inst._defaults.hour,tp_inst.minute=tp_inst._defaults.minute<tp_inst._defaults.minuteMin?tp_inst._defaults.minuteMin:tp_inst._defaults.minute>tp_inst._defaults.minuteMax?tp_inst._defaults.minuteMax:tp_inst._defaults.minute,tp_inst.second=tp_inst._defaults.second<tp_inst._defaults.secondMin?tp_inst._defaults.secondMin:tp_inst._defaults.second>tp_inst._defaults.secondMax?tp_inst._defaults.secondMax:tp_inst._defaults.second,tp_inst.millisec=tp_inst._defaults.millisec<tp_inst._defaults.millisecMin?tp_inst._defaults.millisecMin:tp_inst._defaults.millisec>tp_inst._defaults.millisecMax?tp_inst._defaults.millisecMax:tp_inst._defaults.millisec,tp_inst.microsec=tp_inst._defaults.microsec<tp_inst._defaults.microsecMin?tp_inst._defaults.microsecMin:tp_inst._defaults.microsec>tp_inst._defaults.microsecMax?tp_inst._defaults.microsecMax:tp_inst._defaults.microsec,tp_inst.ampm="",tp_inst.$input=$input,tp_inst._defaults.altField&&(tp_inst.$altInput=$(tp_inst._defaults.altField),tp_inst._defaults.altRedirectFocus===!0&&tp_inst.$altInput.css({cursor:"pointer"}).focus(function(){$input.trigger("focus")})),(0===tp_inst._defaults.minDate||0===tp_inst._defaults.minDateTime)&&(tp_inst._defaults.minDate=new Date),(0===tp_inst._defaults.maxDate||0===tp_inst._defaults.maxDateTime)&&(tp_inst._defaults.maxDate=new Date),void 0!==tp_inst._defaults.minDate&&tp_inst._defaults.minDate instanceof Date&&(tp_inst._defaults.minDateTime=new Date(tp_inst._defaults.minDate.getTime())),void 0!==tp_inst._defaults.minDateTime&&tp_inst._defaults.minDateTime instanceof Date&&(tp_inst._defaults.minDate=new Date(tp_inst._defaults.minDateTime.getTime())),void 0!==tp_inst._defaults.maxDate&&tp_inst._defaults.maxDate instanceof Date&&(tp_inst._defaults.maxDateTime=new Date(tp_inst._defaults.maxDate.getTime())),void 0!==tp_inst._defaults.maxDateTime&&tp_inst._defaults.maxDateTime instanceof Date&&(tp_inst._defaults.maxDate=new Date(tp_inst._defaults.maxDateTime.getTime())),tp_inst.$input.bind("focus",function(){tp_inst._onFocus()}),tp_inst},_addTimePicker:function(a){var b=$.trim(this.$altInput&&this._defaults.altFieldTimeOnly?this.$input.val()+" "+this.$altInput.val():this.$input.val());this.timeDefined=this._parseTime(b),this._limitMinMaxDateTime(a,!1),this._injectTimePicker(),this._afterInject()},_parseTime:function(a,b){if(this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),b||!this._defaults.timeOnly){var c=$.datepicker._get(this.inst,"dateFormat");try{var d=parseDateTimeInternal(c,this._defaults.timeFormat,a,$.datepicker._getFormatConfig(this.inst),this._defaults);if(!d.timeObj)return!1;$.extend(this,d.timeObj)}catch(e){return $.timepicker.log("Error parsing the date/time string: "+e+"\ndate/time string = "+a+"\ntimeFormat = "+this._defaults.timeFormat+"\ndateFormat = "+c),!1}return!0}var f=$.datepicker.parseTime(this._defaults.timeFormat,a,this._defaults);return f?($.extend(this,f),!0):!1},_afterInject:function(){var a=this.inst.settings;$.isFunction(a.afterInject)&&a.afterInject.call(this)},_injectTimePicker:function(){var a=this.inst.dpDiv,b=this.inst.settings,c=this,d="",e="",f=null,g={},h={},i=null,j=0,k=0;if(0===a.find("div.ui-timepicker-div").length&&b.showTimepicker){var l=" ui_tpicker_unit_hide",m='<div class="ui-timepicker-div'+(b.isRTL?" ui-timepicker-rtl":"")+(b.oneLine&&"select"===b.controlType?" ui-timepicker-oneLine":"")+'"><dl><dt class="ui_tpicker_time_label'+(b.showTime?"":l)+'">'+b.timeText+'</dt><dd class="ui_tpicker_time '+(b.showTime?"":l)+'"><input class="ui_tpicker_time_input" '+(b.timeInput?"":"disabled")+"/></dd>";for(j=0,k=this.units.length;k>j;j++){if(d=this.units[j],e=d.substr(0,1).toUpperCase()+d.substr(1),f=null!==b["show"+e]?b["show"+e]:this.support[d],g[d]=parseInt(b[d+"Max"]-(b[d+"Max"]-b[d+"Min"])%b["step"+e],10),h[d]=0,m+='<dt class="ui_tpicker_'+d+"_label"+(f?"":l)+'">'+b[d+"Text"]+'</dt><dd class="ui_tpicker_'+d+(f?"":l)+'"><div class="ui_tpicker_'+d+"_slider"+(f?"":l)+'"></div>',f&&b[d+"Grid"]>0){if(m+='<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>',"hour"===d)for(var n=b[d+"Min"];n<=g[d];n+=parseInt(b[d+"Grid"],10)){h[d]++;var o=$.datepicker.formatTime(this.support.ampm?"hht":"HH",{hour:n},b);m+='<td data-for="'+d+'">'+o+"</td>"}else for(var p=b[d+"Min"];p<=g[d];p+=parseInt(b[d+"Grid"],10))h[d]++,m+='<td data-for="'+d+'">'+(10>p?"0":"")+p+"</td>";m+="</tr></table></div>"}m+="</dd>"}var q=null!==b.showTimezone?b.showTimezone:this.support.timezone;m+='<dt class="ui_tpicker_timezone_label'+(q?"":l)+'">'+b.timezoneText+"</dt>",m+='<dd class="ui_tpicker_timezone'+(q?"":l)+'"></dd>',m+="</dl></div>";var r=$(m);for(b.timeOnly===!0&&(r.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all"><div class="ui-datepicker-title">'+b.timeOnlyTitle+"</div></div>"),a.find(".ui-datepicker-header, .ui-datepicker-calendar").hide()),j=0,k=c.units.length;k>j;j++)d=c.units[j],e=d.substr(0,1).toUpperCase()+d.substr(1),f=null!==b["show"+e]?b["show"+e]:this.support[d],c[d+"_slider"]=c.control.create(c,r.find(".ui_tpicker_"+d+"_slider"),d,c[d],b[d+"Min"],g[d],b["step"+e]),f&&b[d+"Grid"]>0&&(i=100*h[d]*b[d+"Grid"]/(g[d]-b[d+"Min"]),r.find(".ui_tpicker_"+d+" table").css({width:i+"%",marginLeft:b.isRTL?"0":i/(-2*h[d])+"%",marginRight:b.isRTL?i/(-2*h[d])+"%":"0",borderCollapse:"collapse"}).find("td").click(function(a){var b=$(this),e=b.html(),f=parseInt(e.replace(/[^0-9]/g),10),g=e.replace(/[^apm]/gi),h=b.data("for");"hour"===h&&(-1!==g.indexOf("p")&&12>f?f+=12:-1!==g.indexOf("a")&&12===f&&(f=0)),c.control.value(c,c[h+"_slider"],d,f),c._onTimeChange(),c._onSelectHandler()}).css({cursor:"pointer",width:100/h[d]+"%",textAlign:"center",overflow:"hidden"}));if(this.timezone_select=r.find(".ui_tpicker_timezone").append("<select></select>").find("select"),$.fn.append.apply(this.timezone_select,$.map(b.timezoneList,function(a,b){return $("<option />").val("object"==typeof a?a.value:a).text("object"==typeof a?a.label:a)})),"undefined"!=typeof this.timezone&&null!==this.timezone&&""!==this.timezone){var s=-1*new Date(this.inst.selectedYear,this.inst.selectedMonth,this.inst.selectedDay,12).getTimezoneOffset();s===this.timezone?selectLocalTimezone(c):this.timezone_select.val(this.timezone)}else"undefined"!=typeof this.hour&&null!==this.hour&&""!==this.hour?this.timezone_select.val(b.timezone):selectLocalTimezone(c);this.timezone_select.change(function(){c._onTimeChange(),c._onSelectHandler(),c._afterInject()});var t=a.find(".ui-datepicker-buttonpane");if(t.length?t.before(r):a.append(r),this.$timeObj=r.find(".ui_tpicker_time_input"),this.$timeObj.change(function(){var a=c.inst.settings.timeFormat,b=$.datepicker.parseTime(a,this.value),d=new Date;b?(d.setHours(b.hour),d.setMinutes(b.minute),d.setSeconds(b.second),$.datepicker._setTime(c.inst,d)):(this.value=c.formattedTime,this.blur())}),null!==this.inst){var u=this.timeDefined;this._onTimeChange(),this.timeDefined=u}if(this._defaults.addSliderAccess){var v=this._defaults.sliderAccessArgs,w=this._defaults.isRTL;v.isRTL=w,setTimeout(function(){if(0===r.find(".ui-slider-access").length){r.find(".ui-slider:visible").sliderAccess(v);var a=r.find(".ui-slider-access:eq(0)").outerWidth(!0);a&&r.find("table:visible").each(function(){var b=$(this),c=b.outerWidth(),d=b.css(w?"marginRight":"marginLeft").toString().replace("%",""),e=c-a,f=d*e/c+"%",g={width:e,marginRight:0,marginLeft:0};g[w?"marginRight":"marginLeft"]=f,b.css(g)})}},10)}c._limitMinMaxDateTime(this.inst,!0)}},_limitMinMaxDateTime:function(a,b){var c=this._defaults,d=new Date(a.selectedYear,a.selectedMonth,a.selectedDay);if(this._defaults.showTimepicker){if(null!==$.datepicker._get(a,"minDateTime")&&void 0!==$.datepicker._get(a,"minDateTime")&&d){var e=$.datepicker._get(a,"minDateTime"),f=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0);(null===this.hourMinOriginal||null===this.minuteMinOriginal||null===this.secondMinOriginal||null===this.millisecMinOriginal||null===this.microsecMinOriginal)&&(this.hourMinOriginal=c.hourMin,this.minuteMinOriginal=c.minuteMin,this.secondMinOriginal=c.secondMin,this.millisecMinOriginal=c.millisecMin,this.microsecMinOriginal=c.microsecMin),a.settings.timeOnly||f.getTime()===d.getTime()?(this._defaults.hourMin=e.getHours(),this.hour<=this._defaults.hourMin?(this.hour=this._defaults.hourMin,this._defaults.minuteMin=e.getMinutes(),this.minute<=this._defaults.minuteMin?(this.minute=this._defaults.minuteMin,this._defaults.secondMin=e.getSeconds(),this.second<=this._defaults.secondMin?(this.second=this._defaults.secondMin,this._defaults.millisecMin=e.getMilliseconds(),this.millisec<=this._defaults.millisecMin?(this.millisec=this._defaults.millisecMin,this._defaults.microsecMin=e.getMicroseconds()):(this.microsec<this._defaults.microsecMin&&(this.microsec=this._defaults.microsecMin),this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)):(this._defaults.hourMin=this.hourMinOriginal,this._defaults.minuteMin=this.minuteMinOriginal,this._defaults.secondMin=this.secondMinOriginal,this._defaults.millisecMin=this.millisecMinOriginal,this._defaults.microsecMin=this.microsecMinOriginal)}if(null!==$.datepicker._get(a,"maxDateTime")&&void 0!==$.datepicker._get(a,"maxDateTime")&&d){var g=$.datepicker._get(a,"maxDateTime"),h=new Date(g.getFullYear(),g.getMonth(),g.getDate(),0,0,0,0);(null===this.hourMaxOriginal||null===this.minuteMaxOriginal||null===this.secondMaxOriginal||null===this.millisecMaxOriginal)&&(this.hourMaxOriginal=c.hourMax,this.minuteMaxOriginal=c.minuteMax,this.secondMaxOriginal=c.secondMax,this.millisecMaxOriginal=c.millisecMax,this.microsecMaxOriginal=c.microsecMax),a.settings.timeOnly||h.getTime()===d.getTime()?(this._defaults.hourMax=g.getHours(),this.hour>=this._defaults.hourMax?(this.hour=this._defaults.hourMax,this._defaults.minuteMax=g.getMinutes(),this.minute>=this._defaults.minuteMax?(this.minute=this._defaults.minuteMax,this._defaults.secondMax=g.getSeconds(),this.second>=this._defaults.secondMax?(this.second=this._defaults.secondMax,this._defaults.millisecMax=g.getMilliseconds(),this.millisec>=this._defaults.millisecMax?(this.millisec=this._defaults.millisecMax,this._defaults.microsecMax=g.getMicroseconds()):(this.microsec>this._defaults.microsecMax&&(this.microsec=this._defaults.microsecMax),this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)):(this._defaults.hourMax=this.hourMaxOriginal,this._defaults.minuteMax=this.minuteMaxOriginal,this._defaults.secondMax=this.secondMaxOriginal,this._defaults.millisecMax=this.millisecMaxOriginal,this._defaults.microsecMax=this.microsecMaxOriginal)}if(null!==a.settings.minTime){var i=new Date("01/01/1970 "+a.settings.minTime);this.hour<i.getHours()?(this.hour=this._defaults.hourMin=i.getHours(),this.minute=this._defaults.minuteMin=i.getMinutes()):this.hour===i.getHours()&&this.minute<i.getMinutes()?this.minute=this._defaults.minuteMin=i.getMinutes():this._defaults.hourMin<i.getHours()?(this._defaults.hourMin=i.getHours(),this._defaults.minuteMin=i.getMinutes()):this._defaults.hourMin===i.getHours()===this.hour&&this._defaults.minuteMin<i.getMinutes()?this._defaults.minuteMin=i.getMinutes():this._defaults.minuteMin=0}if(null!==a.settings.maxTime){var j=new Date("01/01/1970 "+a.settings.maxTime);this.hour>j.getHours()?(this.hour=this._defaults.hourMax=j.getHours(),this.minute=this._defaults.minuteMax=j.getMinutes()):this.hour===j.getHours()&&this.minute>j.getMinutes()?this.minute=this._defaults.minuteMax=j.getMinutes():this._defaults.hourMax>j.getHours()?(this._defaults.hourMax=j.getHours(),this._defaults.minuteMax=j.getMinutes()):this._defaults.hourMax===j.getHours()===this.hour&&this._defaults.minuteMax>j.getMinutes()?this._defaults.minuteMax=j.getMinutes():this._defaults.minuteMax=59}if(void 0!==b&&b===!0){var k=parseInt(this._defaults.hourMax-(this._defaults.hourMax-this._defaults.hourMin)%this._defaults.stepHour,10),l=parseInt(this._defaults.minuteMax-(this._defaults.minuteMax-this._defaults.minuteMin)%this._defaults.stepMinute,10),m=parseInt(this._defaults.secondMax-(this._defaults.secondMax-this._defaults.secondMin)%this._defaults.stepSecond,10),n=parseInt(this._defaults.millisecMax-(this._defaults.millisecMax-this._defaults.millisecMin)%this._defaults.stepMillisec,10),o=parseInt(this._defaults.microsecMax-(this._defaults.microsecMax-this._defaults.microsecMin)%this._defaults.stepMicrosec,10);this.hour_slider&&(this.control.options(this,this.hour_slider,"hour",{min:this._defaults.hourMin,max:k,step:this._defaults.stepHour}),this.control.value(this,this.hour_slider,"hour",this.hour-this.hour%this._defaults.stepHour)),this.minute_slider&&(this.control.options(this,this.minute_slider,"minute",{min:this._defaults.minuteMin,max:l,step:this._defaults.stepMinute}),this.control.value(this,this.minute_slider,"minute",this.minute-this.minute%this._defaults.stepMinute)),this.second_slider&&(this.control.options(this,this.second_slider,"second",{min:this._defaults.secondMin,max:m,step:this._defaults.stepSecond}),this.control.value(this,this.second_slider,"second",this.second-this.second%this._defaults.stepSecond)),this.millisec_slider&&(this.control.options(this,this.millisec_slider,"millisec",{min:this._defaults.millisecMin,max:n,step:this._defaults.stepMillisec}),this.control.value(this,this.millisec_slider,"millisec",this.millisec-this.millisec%this._defaults.stepMillisec)),this.microsec_slider&&(this.control.options(this,this.microsec_slider,"microsec",{min:this._defaults.microsecMin,max:o,step:this._defaults.stepMicrosec}),this.control.value(this,this.microsec_slider,"microsec",this.microsec-this.microsec%this._defaults.stepMicrosec))}}},_onTimeChange:function(){if(this._defaults.showTimepicker){var a=this.hour_slider?this.control.value(this,this.hour_slider,"hour"):!1,b=this.minute_slider?this.control.value(this,this.minute_slider,"minute"):!1,c=this.second_slider?this.control.value(this,this.second_slider,"second"):!1,d=this.millisec_slider?this.control.value(this,this.millisec_slider,"millisec"):!1,e=this.microsec_slider?this.control.value(this,this.microsec_slider,"microsec"):!1,f=this.timezone_select?this.timezone_select.val():!1,g=this._defaults,h=g.pickerTimeFormat||g.timeFormat,i=g.pickerTimeSuffix||g.timeSuffix;"object"==typeof a&&(a=!1),"object"==typeof b&&(b=!1),"object"==typeof c&&(c=!1),"object"==typeof d&&(d=!1),"object"==typeof e&&(e=!1),"object"==typeof f&&(f=!1),a!==!1&&(a=parseInt(a,10)),b!==!1&&(b=parseInt(b,10)),c!==!1&&(c=parseInt(c,10)),d!==!1&&(d=parseInt(d,10)),e!==!1&&(e=parseInt(e,10)),f!==!1&&(f=f.toString());var j=g[12>a?"amNames":"pmNames"][0],k=a!==parseInt(this.hour,10)||b!==parseInt(this.minute,10)||c!==parseInt(this.second,10)||d!==parseInt(this.millisec,10)||e!==parseInt(this.microsec,10)||this.ampm.length>0&&12>a!=(-1!==$.inArray(this.ampm.toUpperCase(),this.amNames))||null!==this.timezone&&f!==this.timezone.toString();if(k&&(a!==!1&&(this.hour=a),b!==!1&&(this.minute=b),c!==!1&&(this.second=c),d!==!1&&(this.millisec=d),e!==!1&&(this.microsec=e),f!==!1&&(this.timezone=f),this.inst||(this.inst=$.datepicker._getInst(this.$input[0])),this._limitMinMaxDateTime(this.inst,!0)),this.support.ampm&&(this.ampm=j),this.formattedTime=$.datepicker.formatTime(g.timeFormat,this,g),this.$timeObj&&(this.$timeObj.val(h===g.timeFormat?this.formattedTime+i:$.datepicker.formatTime(h,this,g)+i),this.$timeObj[0].setSelectionRange)){var l=this.$timeObj[0].selectionStart,m=this.$timeObj[0].selectionEnd;this.$timeObj[0].setSelectionRange(l,m)}this.timeDefined=!0,k&&this._updateDateTime()}},_onSelectHandler:function(){var a=this._defaults.onSelect||this.inst.settings.onSelect,b=this.$input?this.$input[0]:null;a&&b&&a.apply(b,[this.formattedDateTime,this])},_updateDateTime:function(a){a=this.inst||a;var b=a.currentYear>0?new Date(a.currentYear,a.currentMonth,a.currentDay):new Date(a.selectedYear,a.selectedMonth,a.selectedDay),c=$.datepicker._daylightSavingAdjust(b),d=$.datepicker._get(a,"dateFormat"),e=$.datepicker._getFormatConfig(a),f=null!==c&&this.timeDefined;this.formattedDate=$.datepicker.formatDate(d,null===c?new Date:c,e);var g=this.formattedDate;if(""===a.lastVal&&(a.currentYear=a.selectedYear,a.currentMonth=a.selectedMonth,a.currentDay=a.selectedDay),this._defaults.timeOnly===!0&&this._defaults.timeOnlyShowDate===!1?g=this.formattedTime:(this._defaults.timeOnly!==!0&&(this._defaults.alwaysSetTime||f)||this._defaults.timeOnly===!0&&this._defaults.timeOnlyShowDate===!0)&&(g+=this._defaults.separator+this.formattedTime+this._defaults.timeSuffix),this.formattedDateTime=g,this._defaults.showTimepicker)if(this.$altInput&&this._defaults.timeOnly===!1&&this._defaults.altFieldTimeOnly===!0)this.$altInput.val(this.formattedTime),this.$input.val(this.formattedDate);else if(this.$altInput){this.$input.val(g);var h="",i=null!==this._defaults.altSeparator?this._defaults.altSeparator:this._defaults.separator,j=null!==this._defaults.altTimeSuffix?this._defaults.altTimeSuffix:this._defaults.timeSuffix;this._defaults.timeOnly||(h=this._defaults.altFormat?$.datepicker.formatDate(this._defaults.altFormat,null===c?new Date:c,e):this.formattedDate,h&&(h+=i)),h+=null!==this._defaults.altTimeFormat?$.datepicker.formatTime(this._defaults.altTimeFormat,this,this._defaults)+j:this.formattedTime+j,this.$altInput.val(h)}else this.$input.val(g);else this.$input.val(this.formattedDate);this.$input.trigger("change")},_onFocus:function(){if(!this.$input.val()&&this._defaults.defaultValue){this.$input.val(this._defaults.defaultValue);var a=$.datepicker._getInst(this.$input.get(0)),b=$.datepicker._get(a,"timepicker");if(b&&b._defaults.timeOnly&&a.input.val()!==a.lastVal)try{$.datepicker._updateDatepicker(a)}catch(c){$.timepicker.log(c)}}},_controls:{slider:{create:function(a,b,c,d,e,f,g){var h=a._defaults.isRTL;return b.prop("slide",null).slider({orientation:"horizontal",value:h?-1*d:d,min:h?-1*f:e,max:h?-1*e:f,step:g,slide:function(b,d){a.control.value(a,$(this),c,h?-1*d.value:d.value),a._onTimeChange()},stop:function(b,c){a._onSelectHandler()}})},options:function(a,b,c,d,e){if(a._defaults.isRTL){if("string"==typeof d)return"min"===d||"max"===d?void 0!==e?b.slider(d,-1*e):Math.abs(b.slider(d)):b.slider(d);var f=d.min,g=d.max;return d.min=d.max=null,void 0!==f&&(d.max=-1*f),void 0!==g&&(d.min=-1*g),b.slider(d)}return"string"==typeof d&&void 0!==e?b.slider(d,e):b.slider(d)},value:function(a,b,c,d){return a._defaults.isRTL?void 0!==d?b.slider("value",-1*d):Math.abs(b.slider("value")):void 0!==d?b.slider("value",d):b.slider("value")}},select:{create:function(a,b,c,d,e,f,g){for(var h='<select class="ui-timepicker-select ui-state-default ui-corner-all" data-unit="'+c+'" data-min="'+e+'" data-max="'+f+'" data-step="'+g+'">',i=a._defaults.pickerTimeFormat||a._defaults.timeFormat,j=e;f>=j;j+=g)h+='<option value="'+j+'"'+(j===d?" selected":"")+">",h+="hour"===c?$.datepicker.formatTime($.trim(i.replace(/[^ht ]/gi,"")),{hour:j},a._defaults):"millisec"===c||"microsec"===c||j>=10?j:"0"+j.toString(),h+="</option>";return h+="</select>",b.children("select").remove(),$(h).appendTo(b).change(function(b){a._onTimeChange(),a._onSelectHandler(),a._afterInject()}),b},options:function(a,b,c,d,e){var f={},g=b.children("select");if("string"==typeof d){if(void 0===e)return g.data(d);f[d]=e}else f=d;return a.control.create(a,b,g.data("unit"),g.val(),f.min>=0?f.min:g.data("min"),f.max||g.data("max"),f.step||g.data("step"))},value:function(a,b,c,d){var e=b.children("select");return void 0!==d?e.val(d):e.val()}}}}),$.fn.extend({timepicker:function(a){a=a||{};var b=Array.prototype.slice.call(arguments);return"object"==typeof a&&(b[0]=$.extend(a,{timeOnly:!0})),$(this).each(function(){$.fn.datetimepicker.apply($(this),b)})},datetimepicker:function(a){a=a||{};var b=arguments;return"string"==typeof a?"getDate"===a||"option"===a&&2===b.length&&"string"==typeof b[1]?$.fn.datepicker.apply($(this[0]),b):this.each(function(){var a=$(this);a.datepicker.apply(a,b)}):this.each(function(){var b=$(this);b.datepicker($.timepicker._newInst(b,a)._defaults)})}}),$.datepicker.parseDateTime=function(a,b,c,d,e){var f=parseDateTimeInternal(a,b,c,d,e);if(f.timeObj){var g=f.timeObj;f.date.setHours(g.hour,g.minute,g.second,g.millisec),f.date.setMicroseconds(g.microsec)}return f.date},$.datepicker.parseTime=function(a,b,c){var d=extendRemove(extendRemove({},$.timepicker._defaults),c||{}),e=(-1!==a.replace(/\'.*?\'/g,"").indexOf("Z"),function(a,b,c){var d,e=function(a,b){var c=[];return a&&$.merge(c,a),b&&$.merge(c,b),c=$.map(c,function(a){return a.replace(/[.*+?|()\[\]{}\\]/g,"\\$&")}),"("+c.join("|")+")?"},f=function(a){var b=a.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),c={h:-1,m:-1,s:-1,l:-1,c:-1,t:-1,z:-1};if(b)for(var d=0;d<b.length;d++)-1===c[b[d].toString().charAt(0)]&&(c[b[d].toString().charAt(0)]=d+1);return c},g="^"+a.toString().replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(a){var b=a.length;switch(a.charAt(0).toLowerCase()){case"h":return 1===b?"(\\d?\\d)":"(\\d{"+b+"})";case"m":return 1===b?"(\\d?\\d)":"(\\d{"+b+"})";case"s":return 1===b?"(\\d?\\d)":"(\\d{"+b+"})";case"l":return"(\\d?\\d?\\d)";case"c":return"(\\d?\\d?\\d)";case"z":return"(z|[-+]\\d\\d:?\\d\\d|\\S+)?";case"t":return e(c.amNames,c.pmNames);default:return"("+a.replace(/\'/g,"").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g,function(a){return"\\"+a})+")?"}}).replace(/\s/g,"\\s?")+c.timeSuffix+"$",h=f(a),i="";d=b.match(new RegExp(g,"i"));var j={hour:0,minute:0,second:0,millisec:0,microsec:0};return d?(-1!==h.t&&(void 0===d[h.t]||0===d[h.t].length?(i="",j.ampm=""):(i=-1!==$.inArray(d[h.t].toUpperCase(),$.map(c.amNames,function(a,b){return a.toUpperCase()}))?"AM":"PM",j.ampm=c["AM"===i?"amNames":"pmNames"][0])),-1!==h.h&&("AM"===i&&"12"===d[h.h]?j.hour=0:"PM"===i&&"12"!==d[h.h]?j.hour=parseInt(d[h.h],10)+12:j.hour=Number(d[h.h])),-1!==h.m&&(j.minute=Number(d[h.m])),-1!==h.s&&(j.second=Number(d[h.s])),-1!==h.l&&(j.millisec=Number(d[h.l])),-1!==h.c&&(j.microsec=Number(d[h.c])),-1!==h.z&&void 0!==d[h.z]&&(j.timezone=$.timepicker.timezoneOffsetNumber(d[h.z])),j):!1}),f=function(a,b,c){try{var d=new Date("2012-01-01 "+b);if(isNaN(d.getTime())&&(d=new Date("2012-01-01T"+b),isNaN(d.getTime())&&(d=new Date("01/01/2012 "+b),isNaN(d.getTime()))))throw"Unable to parse time with native Date: "+b;return{hour:d.getHours(),minute:d.getMinutes(),second:d.getSeconds(),millisec:d.getMilliseconds(),microsec:d.getMicroseconds(),timezone:-1*d.getTimezoneOffset()}}catch(f){try{return e(a,b,c)}catch(g){$.timepicker.log("Unable to parse \ntimeString: "+b+"\ntimeFormat: "+a)}}return!1};return"function"==typeof d.parse?d.parse(a,b,d):"loose"===d.parse?f(a,b,d):e(a,b,d)},$.datepicker.formatTime=function(a,b,c){c=c||{},c=$.extend({},$.timepicker._defaults,c),b=$.extend({hour:0,minute:0,second:0,millisec:0,microsec:0,timezone:null},b);var d=a,e=c.amNames[0],f=parseInt(b.hour,10);return f>11&&(e=c.pmNames[0]),d=d.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g,function(a){switch(a){case"HH":return("0"+f).slice(-2);case"H":return f;case"hh":return("0"+convert24to12(f)).slice(-2);case"h":return convert24to12(f);case"mm":return("0"+b.minute).slice(-2);case"m":return b.minute;case"ss":return("0"+b.second).slice(-2);case"s":return b.second;case"l":return("00"+b.millisec).slice(-3);case"c":return("00"+b.microsec).slice(-3);case"z":return $.timepicker.timezoneOffsetString(null===b.timezone?c.timezone:b.timezone,!1);case"Z":return $.timepicker.timezoneOffsetString(null===b.timezone?c.timezone:b.timezone,!0);case"T":return e.charAt(0).toUpperCase();case"TT":return e.toUpperCase();case"t":return e.charAt(0).toLowerCase();case"tt":return e.toLowerCase();default:return a.replace(/'/g,"")}})},$.datepicker._base_selectDate=$.datepicker._selectDate,$.datepicker._selectDate=function(a,b){var c,d=this._getInst($(a)[0]),e=this._get(d,"timepicker");e&&d.settings.showTimepicker?(e._limitMinMaxDateTime(d,!0),c=d.inline,d.inline=d.stay_open=!0,this._base_selectDate(a,b),d.inline=c,d.stay_open=!1,this._notifyChange(d),this._updateDatepicker(d)):this._base_selectDate(a,b)},$.datepicker._base_updateDatepicker=$.datepicker._updateDatepicker,$.datepicker._updateDatepicker=function(a){var b=a.input[0];if(!($.datepicker._curInst&&$.datepicker._curInst!==a&&$.datepicker._datepickerShowing&&$.datepicker._lastInput!==b||"boolean"==typeof a.stay_open&&a.stay_open!==!1)){this._base_updateDatepicker(a);var c=this._get(a,"timepicker");c&&c._addTimePicker(a)}},$.datepicker._base_doKeyPress=$.datepicker._doKeyPress,$.datepicker._doKeyPress=function(a){var b=$.datepicker._getInst(a.target),c=$.datepicker._get(b,"timepicker");if(c&&$.datepicker._get(b,"constrainInput")){var d=c.support.ampm,e=null!==c._defaults.showTimezone?c._defaults.showTimezone:c.support.timezone,f=$.datepicker._possibleChars($.datepicker._get(b,"dateFormat")),g=c._defaults.timeFormat.toString().replace(/[hms]/g,"").replace(/TT/g,d?"APM":"").replace(/Tt/g,d?"AaPpMm":"").replace(/tT/g,d?"AaPpMm":"").replace(/T/g,d?"AP":"").replace(/tt/g,d?"apm":"").replace(/t/g,d?"ap":"")+" "+c._defaults.separator+c._defaults.timeSuffix+(e?c._defaults.timezoneList.join(""):"")+c._defaults.amNames.join("")+c._defaults.pmNames.join("")+f,h=String.fromCharCode(void 0===a.charCode?a.keyCode:a.charCode);return a.ctrlKey||" ">h||!f||g.indexOf(h)>-1}return $.datepicker._base_doKeyPress(a)},$.datepicker._base_updateAlternate=$.datepicker._updateAlternate,$.datepicker._updateAlternate=function(a){var b=this._get(a,"timepicker");if(b){var c=b._defaults.altField;if(c){var d=(b._defaults.altFormat||b._defaults.dateFormat,this._getDate(a)),e=$.datepicker._getFormatConfig(a),f="",g=b._defaults.altSeparator?b._defaults.altSeparator:b._defaults.separator,h=b._defaults.altTimeSuffix?b._defaults.altTimeSuffix:b._defaults.timeSuffix,i=null!==b._defaults.altTimeFormat?b._defaults.altTimeFormat:b._defaults.timeFormat;f+=$.datepicker.formatTime(i,b,b._defaults)+h,b._defaults.timeOnly||b._defaults.altFieldTimeOnly||null===d||(f=b._defaults.altFormat?$.datepicker.formatDate(b._defaults.altFormat,d,e)+g+f:b.formattedDate+g+f),$(c).val(a.input.val()?f:"")}}else $.datepicker._base_updateAlternate(a)},$.datepicker._base_doKeyUp=$.datepicker._doKeyUp,$.datepicker._doKeyUp=function(a){var b=$.datepicker._getInst(a.target),c=$.datepicker._get(b,"timepicker");
|
5 |
+
if(c&&c._defaults.timeOnly&&b.input.val()!==b.lastVal)try{$.datepicker._updateDatepicker(b)}catch(d){$.timepicker.log(d)}return $.datepicker._base_doKeyUp(a)},$.datepicker._base_gotoToday=$.datepicker._gotoToday,$.datepicker._gotoToday=function(a){var b=this._getInst($(a)[0]);this._base_gotoToday(a);var c=this._get(b,"timepicker");if(c){var d=$.timepicker.timezoneOffsetNumber(c.timezone),e=new Date;e.setMinutes(e.getMinutes()+e.getTimezoneOffset()+parseInt(d,10)),this._setTime(b,e),this._setDate(b,e),c._onSelectHandler()}},$.datepicker._disableTimepickerDatepicker=function(a){var b=this._getInst(a);if(b){var c=this._get(b,"timepicker");$(a).datepicker("getDate"),c&&(b.settings.showTimepicker=!1,c._defaults.showTimepicker=!1,c._updateDateTime(b))}},$.datepicker._enableTimepickerDatepicker=function(a){var b=this._getInst(a);if(b){var c=this._get(b,"timepicker");$(a).datepicker("getDate"),c&&(b.settings.showTimepicker=!0,c._defaults.showTimepicker=!0,c._addTimePicker(b),c._updateDateTime(b))}},$.datepicker._setTime=function(a,b){var c=this._get(a,"timepicker");if(c){var d=c._defaults;c.hour=b?b.getHours():d.hour,c.minute=b?b.getMinutes():d.minute,c.second=b?b.getSeconds():d.second,c.millisec=b?b.getMilliseconds():d.millisec,c.microsec=b?b.getMicroseconds():d.microsec,c._limitMinMaxDateTime(a,!0),c._onTimeChange(),c._updateDateTime(a)}},$.datepicker._setTimeDatepicker=function(a,b,c){var d=this._getInst(a);if(d){var e=this._get(d,"timepicker");if(e){this._setDateFromField(d);var f;b&&("string"==typeof b?(e._parseTime(b,c),f=new Date,f.setHours(e.hour,e.minute,e.second,e.millisec),f.setMicroseconds(e.microsec)):(f=new Date(b.getTime()),f.setMicroseconds(b.getMicroseconds())),"Invalid Date"===f.toString()&&(f=void 0),this._setTime(d,f))}}},$.datepicker._base_setDateDatepicker=$.datepicker._setDateDatepicker,$.datepicker._setDateDatepicker=function(a,b){var c=this._getInst(a),d=b;if(c){"string"==typeof b&&(d=new Date(b),d.getTime()||(this._base_setDateDatepicker.apply(this,arguments),d=$(a).datepicker("getDate")));var e,f=this._get(c,"timepicker");d instanceof Date?(e=new Date(d.getTime()),e.setMicroseconds(d.getMicroseconds())):e=d,f&&e&&(f.support.timezone||null!==f._defaults.timezone||(f.timezone=-1*e.getTimezoneOffset()),d=$.timepicker.timezoneAdjust(d,$.timepicker.timezoneOffsetString(-d.getTimezoneOffset()),f.timezone),e=$.timepicker.timezoneAdjust(e,$.timepicker.timezoneOffsetString(-e.getTimezoneOffset()),f.timezone)),this._updateDatepicker(c),this._base_setDateDatepicker.apply(this,arguments),this._setTimeDatepicker(a,e,!0)}},$.datepicker._base_getDateDatepicker=$.datepicker._getDateDatepicker,$.datepicker._getDateDatepicker=function(a,b){var c=this._getInst(a);if(c){var d=this._get(c,"timepicker");if(d){void 0===c.lastVal&&this._setDateFromField(c,b);var e=this._getDate(c),f=null;return f=d.$altInput&&d._defaults.altFieldTimeOnly?d.$input.val()+" "+d.$altInput.val():"INPUT"!==d.$input.get(0).tagName&&d.$altInput?d.$altInput.val():d.$input.val(),e&&d._parseTime(f,!c.settings.timeOnly)&&(e.setHours(d.hour,d.minute,d.second,d.millisec),e.setMicroseconds(d.microsec),null!=d.timezone&&(d.support.timezone||null!==d._defaults.timezone||(d.timezone=-1*e.getTimezoneOffset()),e=$.timepicker.timezoneAdjust(e,d.timezone,$.timepicker.timezoneOffsetString(-e.getTimezoneOffset())))),e}return this._base_getDateDatepicker(a,b)}},$.datepicker._base_parseDate=$.datepicker.parseDate,$.datepicker.parseDate=function(a,b,c){var d;try{d=this._base_parseDate(a,b,c)}catch(e){if(!(e.indexOf(":")>=0))throw e;d=this._base_parseDate(a,b.substring(0,b.length-(e.length-e.indexOf(":")-2)),c),$.timepicker.log("Error parsing the date string: "+e+"\ndate string = "+b+"\ndate format = "+a)}return d},$.datepicker._base_formatDate=$.datepicker._formatDate,$.datepicker._formatDate=function(a,b,c,d){var e=this._get(a,"timepicker");return e?(e._updateDateTime(a),e.$input.val()):this._base_formatDate(a)},$.datepicker._base_optionDatepicker=$.datepicker._optionDatepicker,$.datepicker._optionDatepicker=function(a,b,c){var d,e=this._getInst(a);if(!e)return null;var f=this._get(e,"timepicker");if(f){var g,h,i,j,k=null,l=null,m=null,n=f._defaults.evnts,o={};if("string"==typeof b){if("minDate"===b||"minDateTime"===b)k=c;else if("maxDate"===b||"maxDateTime"===b)l=c;else if("onSelect"===b)m=c;else if(n.hasOwnProperty(b)){if("undefined"==typeof c)return n[b];o[b]=c,d={}}}else if("object"==typeof b){b.minDate?k=b.minDate:b.minDateTime?k=b.minDateTime:b.maxDate?l=b.maxDate:b.maxDateTime&&(l=b.maxDateTime);for(g in n)n.hasOwnProperty(g)&&b[g]&&(o[g]=b[g])}for(g in o)o.hasOwnProperty(g)&&(n[g]=o[g],d||(d=$.extend({},b)),delete d[g]);if(d&&isEmptyObject(d))return;if(k?(k=0===k?new Date:new Date(k),f._defaults.minDate=k,f._defaults.minDateTime=k):l?(l=0===l?new Date:new Date(l),f._defaults.maxDate=l,f._defaults.maxDateTime=l):m&&(f._defaults.onSelect=m),k||l)return j=$(a),i=j.datetimepicker("getDate"),h=this._base_optionDatepicker.call($.datepicker,a,d||b,c),j.datetimepicker("setDate",i),h}return void 0===c?this._base_optionDatepicker.call($.datepicker,a,b):this._base_optionDatepicker.call($.datepicker,a,d||b,c)};var isEmptyObject=function(a){var b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0},extendRemove=function(a,b){$.extend(a,b);for(var c in b)(null===b[c]||void 0===b[c])&&(a[c]=b[c]);return a},detectSupport=function(a){var b=a.replace(/'.*?'/g,"").toLowerCase(),c=function(a,b){return-1!==a.indexOf(b)?!0:!1};return{hour:c(b,"h"),minute:c(b,"m"),second:c(b,"s"),millisec:c(b,"l"),microsec:c(b,"c"),timezone:c(b,"z"),ampm:c(b,"t")&&c(a,"h"),iso8601:c(a,"Z")}},convert24to12=function(a){return a%=12,0===a&&(a=12),String(a)},computeEffectiveSetting=function(a,b){return a&&a[b]?a[b]:$.timepicker._defaults[b]},splitDateTime=function(a,b){var c=computeEffectiveSetting(b,"separator"),d=computeEffectiveSetting(b,"timeFormat"),e=d.split(c),f=e.length,g=a.split(c),h=g.length;return h>1?{dateString:g.splice(0,h-f).join(c),timeString:g.splice(0,f).join(c)}:{dateString:a,timeString:""}},parseDateTimeInternal=function(a,b,c,d,e){var f,g,h;if(g=splitDateTime(c,e),f=$.datepicker._base_parseDate(a,g.dateString,d),""===g.timeString)return{date:f};if(h=$.datepicker.parseTime(b,g.timeString,e),!h)throw"Wrong time format";return{date:f,timeObj:h}},selectLocalTimezone=function(a,b){if(a&&a.timezone_select){var c=b||new Date;a.timezone_select.val(-c.getTimezoneOffset())}};$.timepicker=new Timepicker,$.timepicker.timezoneOffsetString=function(a,b){if(isNaN(a)||a>840||-720>a)return a;var c=a,d=c%60,e=(c-d)/60,f=b?":":"",g=(c>=0?"+":"-")+("0"+Math.abs(e)).slice(-2)+f+("0"+Math.abs(d)).slice(-2);return"+00:00"===g?"Z":g},$.timepicker.timezoneOffsetNumber=function(a){var b=a.toString().replace(":","");return"Z"===b.toUpperCase()?0:/^(\-|\+)\d{4}$/.test(b)?("-"===b.substr(0,1)?-1:1)*(60*parseInt(b.substr(1,2),10)+parseInt(b.substr(3,2),10)):parseInt(a,10)},$.timepicker.timezoneAdjust=function(a,b,c){var d=$.timepicker.timezoneOffsetNumber(b),e=$.timepicker.timezoneOffsetNumber(c);return isNaN(e)||a.setMinutes(a.getMinutes()+-d- -e),a},$.timepicker.timeRange=function(a,b,c){return $.timepicker.handleRange("timepicker",a,b,c)},$.timepicker.datetimeRange=function(a,b,c){$.timepicker.handleRange("datetimepicker",a,b,c)},$.timepicker.dateRange=function(a,b,c){$.timepicker.handleRange("datepicker",a,b,c)},$.timepicker.handleRange=function(a,b,c,d){function e(e,f){var g=b[a]("getDate"),h=c[a]("getDate"),i=e[a]("getDate");if(null!==g){var j=new Date(g.getTime()),k=new Date(g.getTime());j.setMilliseconds(j.getMilliseconds()+d.minInterval),k.setMilliseconds(k.getMilliseconds()+d.maxInterval),d.minInterval>0&&j>h?c[a]("setDate",j):d.maxInterval>0&&h>k?c[a]("setDate",k):g>h&&f[a]("setDate",i)}}function f(b,c,e){if(b.val()){var f=b[a].call(b,"getDate");null!==f&&d.minInterval>0&&("minDate"===e&&f.setMilliseconds(f.getMilliseconds()+d.minInterval),"maxDate"===e&&f.setMilliseconds(f.getMilliseconds()-d.minInterval)),f.getTime&&c[a].call(c,"option",e,f)}}d=$.extend({},{minInterval:0,maxInterval:0,start:{},end:{}},d);var g=!1;return"timepicker"===a&&(g=!0,a="datetimepicker"),$.fn[a].call(b,$.extend({timeOnly:g,onClose:function(a,b){e($(this),c)},onSelect:function(a){f($(this),c,"minDate")}},d,d.start)),$.fn[a].call(c,$.extend({timeOnly:g,onClose:function(a,c){e($(this),b)},onSelect:function(a){f($(this),b,"maxDate")}},d,d.end)),e(b,c),f(b,c,"minDate"),f(c,b,"maxDate"),$([b.get(0),c.get(0)])},$.timepicker.log=function(){window.console&&window.console.log&&window.console.log.apply&&window.console.log.apply(window.console,Array.prototype.slice.call(arguments))},$.timepicker._util={_extendRemove:extendRemove,_isEmptyObject:isEmptyObject,_convert24to12:convert24to12,_detectSupport:detectSupport,_selectLocalTimezone:selectLocalTimezone,_computeEffectiveSetting:computeEffectiveSetting,_splitDateTime:splitDateTime,_parseDateTimeInternal:parseDateTimeInternal},Date.prototype.getMicroseconds||(Date.prototype.microseconds=0,Date.prototype.getMicroseconds=function(){return this.microseconds},Date.prototype.setMicroseconds=function(a){return this.setMilliseconds(this.getMilliseconds()+Math.floor(a/1e3)),this.microseconds=a%1e3,this}),$.timepicker.version="1.6.3"}});
|
js/map.js
CHANGED
@@ -20,7 +20,8 @@
|
|
20 |
|
21 |
// Initialize DOM elements
|
22 |
initDomElements: function () {
|
23 |
-
this
|
|
|
24 |
this.$coordinate = this.$container.find( '.rwmb-map-coordinate' );
|
25 |
this.$findButton = this.$container.find( '.rwmb-map-goto-address-button' );
|
26 |
this.addressField = this.$findButton.val();
|
@@ -28,7 +29,7 @@
|
|
28 |
|
29 |
// Initialize map elements
|
30 |
initMapElements: function () {
|
31 |
-
var defaultLoc =
|
32 |
latLng;
|
33 |
|
34 |
defaultLoc = defaultLoc ? defaultLoc.split( ',' ) : [53.346881, - 6.258860];
|
@@ -126,20 +127,24 @@
|
|
126 |
return;
|
127 |
}
|
128 |
|
|
|
|
|
129 |
// If Meta Box Geo Location installed. Do not run auto complete.
|
130 |
if ( $( '.rwmb-geo-binding' ).length ) {
|
131 |
-
$
|
132 |
that.$findButton.trigger( 'click' );
|
133 |
} );
|
134 |
|
135 |
return false;
|
136 |
}
|
137 |
|
138 |
-
$
|
139 |
source: function ( request, response ) {
|
140 |
-
|
141 |
-
'address': request.term
|
142 |
-
|
|
|
|
|
143 |
response( $.map( results, function ( item ) {
|
144 |
return {
|
145 |
label: item.formatted_address,
|
20 |
|
21 |
// Initialize DOM elements
|
22 |
initDomElements: function () {
|
23 |
+
this.$canvas = this.$container.find( '.rwmb-map-canvas' );
|
24 |
+
this.canvas = this.$canvas[0];
|
25 |
this.$coordinate = this.$container.find( '.rwmb-map-coordinate' );
|
26 |
this.$findButton = this.$container.find( '.rwmb-map-goto-address-button' );
|
27 |
this.addressField = this.$findButton.val();
|
29 |
|
30 |
// Initialize map elements
|
31 |
initMapElements: function () {
|
32 |
+
var defaultLoc = this.$canvas.data( 'default-loc' ),
|
33 |
latLng;
|
34 |
|
35 |
defaultLoc = defaultLoc ? defaultLoc.split( ',' ) : [53.346881, - 6.258860];
|
127 |
return;
|
128 |
}
|
129 |
|
130 |
+
var $address = $( '#' + this.addressField );
|
131 |
+
|
132 |
// If Meta Box Geo Location installed. Do not run auto complete.
|
133 |
if ( $( '.rwmb-geo-binding' ).length ) {
|
134 |
+
$address.on( 'selected_address', function () {
|
135 |
that.$findButton.trigger( 'click' );
|
136 |
} );
|
137 |
|
138 |
return false;
|
139 |
}
|
140 |
|
141 |
+
$address.autocomplete( {
|
142 |
source: function ( request, response ) {
|
143 |
+
var options = {
|
144 |
+
'address': request.term,
|
145 |
+
'region': that.$canvas.data( 'region' )
|
146 |
+
};
|
147 |
+
that.geocoder.geocode( options, function ( results ) {
|
148 |
response( $.map( results, function ( item ) {
|
149 |
return {
|
150 |
label: item.formatted_address,
|
js/media.js
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
window.rwmb = window.rwmb || {};
|
2 |
|
3 |
jQuery( function ( $ ) {
|
@@ -8,7 +10,7 @@ jQuery( function ( $ ) {
|
|
8 |
MediaCollection, Controller, MediaField, MediaList, MediaItem, MediaButton, MediaStatus, EditMedia, MediaDetails;
|
9 |
|
10 |
MediaCollection = models.MediaCollection = wp.media.model.Attachments.extend( {
|
11 |
-
initialize: function( models, options ) {
|
12 |
this.controller = options.controller || new models.Controller;
|
13 |
this.on( 'add remove reset', function () {
|
14 |
var max = this.controller.get( 'maxFiles' );
|
@@ -19,7 +21,7 @@ jQuery( function ( $ ) {
|
|
19 |
wp.media.model.Attachments.prototype.initialize.call( this, models, options );
|
20 |
},
|
21 |
|
22 |
-
add: function( models, options ) {
|
23 |
var max = this.controller.get( 'maxFiles' ),
|
24 |
left = max - this.length;
|
25 |
|
@@ -27,14 +29,14 @@ jQuery( function ( $ ) {
|
|
27 |
return this;
|
28 |
}
|
29 |
|
30 |
-
if( !models.hasOwnProperty( 'length' ) ){
|
31 |
models = [models];
|
32 |
}
|
33 |
-
else if( models instanceof wp.media.model.Attachments ) {
|
34 |
models = models.models;
|
35 |
}
|
36 |
|
37 |
-
if( left > 0 ) {
|
38 |
models = _.difference( models, this.models );
|
39 |
models = _.first( models, left );
|
40 |
}
|
@@ -42,20 +44,20 @@ jQuery( function ( $ ) {
|
|
42 |
return wp.media.model.Attachments.prototype.add.call( this, models, options );
|
43 |
},
|
44 |
|
45 |
-
remove: function( models, options ) {
|
46 |
-
|
47 |
if ( this.controller.get( 'forceDelete' ) === true ) {
|
48 |
-
models = !_.isArray( models ) ? [models] : models;
|
49 |
-
_.each( models, function( model ) {
|
50 |
-
|
51 |
-
});
|
52 |
}
|
53 |
},
|
54 |
|
55 |
-
destroyAll: function() {
|
56 |
-
_.each( _.clone( this.models), function( model ) {
|
57 |
-
|
58 |
-
});
|
59 |
}
|
60 |
} );
|
61 |
|
@@ -75,16 +77,15 @@ jQuery( function ( $ ) {
|
|
75 |
},
|
76 |
|
77 |
//Initialize Controller model
|
78 |
-
initialize: function (
|
79 |
-
var that = this;
|
80 |
// All numbers, no 0 ids
|
81 |
this.set( 'ids', _.without( _.map( this.get( 'ids' ), Number ), 0, - 1 ) );
|
82 |
|
83 |
// Create items collection
|
84 |
-
this.set( 'items', new MediaCollection( [], {
|
85 |
|
86 |
// Listen for destroy event on controller, delete all models when triggered
|
87 |
-
this.on( 'destroy', function (
|
88 |
if ( this.get( 'forceDelete' ) ) {
|
89 |
this.get( 'items' ).destroyAll();
|
90 |
}
|
@@ -92,22 +93,21 @@ jQuery( function ( $ ) {
|
|
92 |
},
|
93 |
|
94 |
|
95 |
-
//
|
96 |
load: function () {
|
97 |
-
|
98 |
-
|
99 |
-
if ( ! _.isEmpty( this.get( 'ids' ) ) ) {
|
100 |
-
this.get( 'items' ).props.set( {
|
101 |
-
query: true,
|
102 |
-
include: this.get( 'ids' ),
|
103 |
-
orderby: 'post__in',
|
104 |
-
order: 'ASC',
|
105 |
-
type: this.get( 'mimeType' ),
|
106 |
-
perPage: this.get( 'maxFiles' ) || - 1
|
107 |
-
} );
|
108 |
-
// Get more then trigger ready
|
109 |
-
this.get( 'items' ).more();
|
110 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
} );
|
113 |
|
@@ -121,7 +121,7 @@ jQuery( function ( $ ) {
|
|
121 |
this.$input = $( options.input );
|
122 |
this.controller = new Controller( _.extend(
|
123 |
{
|
124 |
-
fieldName: this.$input.attr( 'name' ),
|
125 |
ids: this.$input.val().split( ',' )
|
126 |
},
|
127 |
this.$el.data( 'options' )
|
@@ -143,9 +143,13 @@ jQuery( function ( $ ) {
|
|
143 |
this.controller.destroy();
|
144 |
} );
|
145 |
|
146 |
-
this.controller.get( 'items' ).on( 'add remove reset', _.debounce( function (
|
147 |
that.$input.trigger( 'change' );
|
148 |
}, 500 ) );
|
|
|
|
|
|
|
|
|
149 |
},
|
150 |
|
151 |
// Creates media list
|
@@ -182,15 +186,46 @@ jQuery( function ( $ ) {
|
|
182 |
tagName: 'ul',
|
183 |
className: 'rwmb-media-list',
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
//Add item view
|
186 |
addItemView: function ( item ) {
|
187 |
-
var index = this.
|
188 |
itemEl = this.getItemView( item ).el;
|
189 |
|
190 |
-
if( 0 >= index ) {
|
191 |
this.$el.prepend( itemEl );
|
192 |
}
|
193 |
-
else if( this.$el.children().length <= index ) {
|
194 |
this.$el.append( itemEl )
|
195 |
}
|
196 |
else {
|
@@ -198,30 +233,68 @@ jQuery( function ( $ ) {
|
|
198 |
}
|
199 |
},
|
200 |
|
201 |
-
//Remove item view
|
202 |
removeItemView: function ( item ) {
|
203 |
-
this.getItemView(item).$el.detach();
|
204 |
},
|
205 |
|
206 |
-
|
207 |
-
this.
|
208 |
-
|
209 |
-
this.getItemView = _.memoize(
|
210 |
-
function( item ) {
|
211 |
-
return new this.itemView( {
|
212 |
-
model: item,
|
213 |
-
controller: this.controller
|
214 |
-
} );
|
215 |
-
},
|
216 |
-
function( item ) {
|
217 |
-
return item.cid;
|
218 |
-
} );
|
219 |
-
|
220 |
-
this.listenTo( this.controller.get( 'items' ), 'add', this.addItemView );
|
221 |
-
this.listenTo( this.controller.get( 'items' ), 'remove', this.removeItemView );
|
222 |
|
223 |
-
|
224 |
-
this.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
},
|
226 |
|
227 |
initSortable: function () {
|
@@ -290,7 +363,7 @@ jQuery( function ( $ ) {
|
|
290 |
|
291 |
/***
|
292 |
* Media Button
|
293 |
-
* Selects and adds
|
294 |
*/
|
295 |
MediaButton = views.MediaButton = Backbone.View.extend( {
|
296 |
tagName: 'div',
|
@@ -323,13 +396,13 @@ jQuery( function ( $ ) {
|
|
323 |
}
|
324 |
},
|
325 |
render: function () {
|
326 |
-
|
327 |
-
this.$el.html( this.template( attrs ) );
|
328 |
return this;
|
329 |
},
|
330 |
|
331 |
initialize: function ( options ) {
|
332 |
this.controller = options.controller;
|
|
|
333 |
|
334 |
// Auto hide if you reach the max number of media
|
335 |
this.listenTo( this.controller, 'change:full', function () {
|
@@ -360,75 +433,26 @@ jQuery( function ( $ ) {
|
|
360 |
|
361 |
|
362 |
events: {
|
363 |
-
'click .rwmb-switch': function(
|
364 |
-
|
365 |
-
//this.stopListening( this._frame );
|
366 |
-
this._frame.dispose();
|
367 |
-
}
|
368 |
-
this._frame = wp.media( {
|
369 |
-
className: 'media-frame rwmb-media-frame',
|
370 |
-
multiple: false,
|
371 |
-
title: i18nRwmbMedia.select,
|
372 |
-
editing: true,
|
373 |
-
library: {
|
374 |
-
type: this.controller.get( 'mimeType' )
|
375 |
-
}
|
376 |
-
} );
|
377 |
-
|
378 |
-
this._frame.on( 'select', function () {
|
379 |
-
var selection = this._frame.state().get( 'selection' ),
|
380 |
-
collection = this.controller.get( 'items' ),
|
381 |
-
index = collection.indexOf( this.model );
|
382 |
-
if( !_.isEmpty( selection ) ) {
|
383 |
-
collection.remove( this.model );
|
384 |
-
collection.add( selection, { at: index } );
|
385 |
-
}
|
386 |
-
}, this );
|
387 |
-
|
388 |
-
this._frame.open();
|
389 |
return false;
|
390 |
},
|
391 |
|
392 |
// Event when remove button clicked
|
393 |
-
'click .rwmb-remove-media': function (
|
394 |
-
this.
|
395 |
return false;
|
396 |
},
|
397 |
|
398 |
-
'click .rwmb-edit-media': function (
|
399 |
-
|
400 |
-
if ( this._frame ) {
|
401 |
-
//this.stopListening( this._frame );
|
402 |
-
this._frame.dispose();
|
403 |
-
}
|
404 |
-
|
405 |
-
// Trigger the media frame to open the correct item
|
406 |
-
this._frame = new EditMedia( {
|
407 |
-
frame : 'edit-attachments',
|
408 |
-
controller: {
|
409 |
-
// Needed to trick Edit modal to think there is a gridRouter
|
410 |
-
gridRouter: {
|
411 |
-
navigate: function ( destination )
|
412 |
-
{
|
413 |
-
},
|
414 |
-
baseUrl : function ( url )
|
415 |
-
{
|
416 |
-
}
|
417 |
-
}
|
418 |
-
},
|
419 |
-
library : this.controller.get( 'items' ),
|
420 |
-
model : this.model
|
421 |
-
} );
|
422 |
-
|
423 |
-
this._frame.open();
|
424 |
-
|
425 |
return false;
|
426 |
}
|
427 |
},
|
428 |
|
429 |
render: function () {
|
430 |
var attrs = _.clone( this.model.attributes );
|
431 |
-
attrs.
|
432 |
this.$el.html( this.template( attrs ) );
|
433 |
return this;
|
434 |
}
|
@@ -438,52 +462,52 @@ jQuery( function ( $ ) {
|
|
438 |
* Extend media frames to make things work right
|
439 |
*/
|
440 |
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
|
488 |
/**
|
489 |
* Initialize media fields
|
@@ -493,7 +517,6 @@ jQuery( function ( $ ) {
|
|
493 |
new MediaField( {input: this, el: $( this ).siblings( 'div.rwmb-media-view' )} );
|
494 |
}
|
495 |
|
496 |
-
|
497 |
$( ':input.rwmb-file_advanced' ).each( initMediaField );
|
498 |
$( '.rwmb-input' )
|
499 |
.on( 'clone', ':input.rwmb-file_advanced', initMediaField );
|
1 |
+
/* global jQuery, _,i18nRwmbMedia */
|
2 |
+
|
3 |
window.rwmb = window.rwmb || {};
|
4 |
|
5 |
jQuery( function ( $ ) {
|
10 |
MediaCollection, Controller, MediaField, MediaList, MediaItem, MediaButton, MediaStatus, EditMedia, MediaDetails;
|
11 |
|
12 |
MediaCollection = models.MediaCollection = wp.media.model.Attachments.extend( {
|
13 |
+
initialize: function ( models, options ) {
|
14 |
this.controller = options.controller || new models.Controller;
|
15 |
this.on( 'add remove reset', function () {
|
16 |
var max = this.controller.get( 'maxFiles' );
|
21 |
wp.media.model.Attachments.prototype.initialize.call( this, models, options );
|
22 |
},
|
23 |
|
24 |
+
add: function ( models, options ) {
|
25 |
var max = this.controller.get( 'maxFiles' ),
|
26 |
left = max - this.length;
|
27 |
|
29 |
return this;
|
30 |
}
|
31 |
|
32 |
+
if ( ! models.hasOwnProperty( 'length' ) ) {
|
33 |
models = [models];
|
34 |
}
|
35 |
+
else if ( models instanceof wp.media.model.Attachments ) {
|
36 |
models = models.models;
|
37 |
}
|
38 |
|
39 |
+
if ( left > 0 ) {
|
40 |
models = _.difference( models, this.models );
|
41 |
models = _.first( models, left );
|
42 |
}
|
44 |
return wp.media.model.Attachments.prototype.add.call( this, models, options );
|
45 |
},
|
46 |
|
47 |
+
remove: function ( models, options ) {
|
48 |
+
models = wp.media.model.Attachments.prototype.remove.call( this, models, options );
|
49 |
if ( this.controller.get( 'forceDelete' ) === true ) {
|
50 |
+
models = ! _.isArray( models ) ? [models] : models;
|
51 |
+
_.each( models, function ( model ) {
|
52 |
+
model.destroy();
|
53 |
+
} );
|
54 |
}
|
55 |
},
|
56 |
|
57 |
+
destroyAll: function () {
|
58 |
+
_.each( _.clone( this.models ), function ( model ) {
|
59 |
+
model.destroy();
|
60 |
+
} );
|
61 |
}
|
62 |
} );
|
63 |
|
77 |
},
|
78 |
|
79 |
//Initialize Controller model
|
80 |
+
initialize: function () {
|
|
|
81 |
// All numbers, no 0 ids
|
82 |
this.set( 'ids', _.without( _.map( this.get( 'ids' ), Number ), 0, - 1 ) );
|
83 |
|
84 |
// Create items collection
|
85 |
+
this.set( 'items', new MediaCollection( [], {controller: this} ) );
|
86 |
|
87 |
// Listen for destroy event on controller, delete all models when triggered
|
88 |
+
this.on( 'destroy', function () {
|
89 |
if ( this.get( 'forceDelete' ) ) {
|
90 |
this.get( 'items' ).destroyAll();
|
91 |
}
|
93 |
},
|
94 |
|
95 |
|
96 |
+
// Load initial media
|
97 |
load: function () {
|
98 |
+
if ( _.isEmpty( this.get( 'ids' ) ) ) {
|
99 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
+
this.get( 'items' ).props.set( {
|
102 |
+
query: true,
|
103 |
+
include: this.get( 'ids' ),
|
104 |
+
orderby: 'post__in',
|
105 |
+
order: 'ASC',
|
106 |
+
type: this.get( 'mimeType' ),
|
107 |
+
perPage: this.get( 'maxFiles' ) || - 1
|
108 |
+
} );
|
109 |
+
// Get more then trigger ready
|
110 |
+
this.get( 'items' ).more();
|
111 |
}
|
112 |
} );
|
113 |
|
121 |
this.$input = $( options.input );
|
122 |
this.controller = new Controller( _.extend(
|
123 |
{
|
124 |
+
fieldName: this.$input.attr( 'name' ) + '[]',
|
125 |
ids: this.$input.val().split( ',' )
|
126 |
},
|
127 |
this.$el.data( 'options' )
|
143 |
this.controller.destroy();
|
144 |
} );
|
145 |
|
146 |
+
this.controller.get( 'items' ).on( 'add remove reset', _.debounce( function () {
|
147 |
that.$input.trigger( 'change' );
|
148 |
}, 500 ) );
|
149 |
+
|
150 |
+
this.controller.get( 'items' ).on( 'remove', _.debounce( function () {
|
151 |
+
that.$input.val( '' );
|
152 |
+
}, 500 ) );
|
153 |
},
|
154 |
|
155 |
// Creates media list
|
186 |
tagName: 'ul',
|
187 |
className: 'rwmb-media-list',
|
188 |
|
189 |
+
initialize: function ( options ) {
|
190 |
+
this.controller = options.controller;
|
191 |
+
this.collection = this.controller.get( 'items' );
|
192 |
+
this.itemView = options.itemView || MediaItem;
|
193 |
+
this.getItemView = _.memoize( function ( item ) {
|
194 |
+
var itemView = new this.itemView( {
|
195 |
+
model: item,
|
196 |
+
controller: this.controller
|
197 |
+
} );
|
198 |
+
|
199 |
+
this.listenToItemView( itemView );
|
200 |
+
|
201 |
+
return itemView;
|
202 |
+
},
|
203 |
+
function ( item ) {
|
204 |
+
return item.cid;
|
205 |
+
} );
|
206 |
+
|
207 |
+
this.listenTo( this.collection, 'add', this.addItemView );
|
208 |
+
this.listenTo( this.collection, 'remove', this.removeItemView );
|
209 |
+
|
210 |
+
// Sort media using sortable
|
211 |
+
this.initSortable();
|
212 |
+
},
|
213 |
+
|
214 |
+
listenToItemView: function ( itemView ) {
|
215 |
+
this.listenTo( itemView, 'click:remove', this.removeItem );
|
216 |
+
this.listenTo( itemView, 'click:switch', this.switchItem );
|
217 |
+
this.listenTo( itemView, 'click:edit', this.editItem );
|
218 |
+
},
|
219 |
+
|
220 |
//Add item view
|
221 |
addItemView: function ( item ) {
|
222 |
+
var index = this.collection.indexOf( item ),
|
223 |
itemEl = this.getItemView( item ).el;
|
224 |
|
225 |
+
if ( 0 >= index ) {
|
226 |
this.$el.prepend( itemEl );
|
227 |
}
|
228 |
+
else if ( this.$el.children().length <= index ) {
|
229 |
this.$el.append( itemEl )
|
230 |
}
|
231 |
else {
|
233 |
}
|
234 |
},
|
235 |
|
236 |
+
// Remove item view
|
237 |
removeItemView: function ( item ) {
|
238 |
+
this.getItemView( item ).$el.detach();
|
239 |
},
|
240 |
|
241 |
+
removeItem: function ( item ) {
|
242 |
+
this.collection.remove( item );
|
243 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
+
switchItem: function () {
|
246 |
+
if ( this._switchFrame ) {
|
247 |
+
//this.stopListening( this._frame );
|
248 |
+
this._switchFrame.dispose();
|
249 |
+
}
|
250 |
+
this._switchFrame = wp.media( {
|
251 |
+
className: 'media-frame rwmb-media-frame',
|
252 |
+
multiple: false,
|
253 |
+
title: i18nRwmbMedia.select,
|
254 |
+
editing: true,
|
255 |
+
library: {
|
256 |
+
type: this.controller.get( 'mimeType' )
|
257 |
+
}
|
258 |
+
} );
|
259 |
+
|
260 |
+
this._switchFrame.on( 'select', function () {
|
261 |
+
var selection = this._switchFrame.state().get( 'selection' ),
|
262 |
+
collection = this.collection,
|
263 |
+
index = collection.indexOf( this.model );
|
264 |
+
if ( ! _.isEmpty( selection ) ) {
|
265 |
+
collection.remove( this.model );
|
266 |
+
collection.add( selection, {at: index} );
|
267 |
+
}
|
268 |
+
}, this );
|
269 |
+
|
270 |
+
this._switchFrame.open();
|
271 |
+
return false;
|
272 |
+
},
|
273 |
+
|
274 |
+
editItem: function ( item ) {
|
275 |
+
// Destroy the previous collection frame.
|
276 |
+
if ( this._editFrame ) {
|
277 |
+
//this.stopListening( this._frame );
|
278 |
+
this._editFrame.dispose();
|
279 |
+
}
|
280 |
+
|
281 |
+
// Trigger the media frame to open the correct item
|
282 |
+
this._editFrame = new EditMedia( {
|
283 |
+
frame: 'edit-attachments',
|
284 |
+
controller: {
|
285 |
+
// Needed to trick Edit modal to think there is a gridRouter
|
286 |
+
gridRouter: {
|
287 |
+
navigate: function ( destination ) {
|
288 |
+
},
|
289 |
+
baseUrl: function ( url ) {
|
290 |
+
}
|
291 |
+
}
|
292 |
+
},
|
293 |
+
library: this.collection,
|
294 |
+
model: item
|
295 |
+
} );
|
296 |
+
|
297 |
+
this._editFrame.open();
|
298 |
},
|
299 |
|
300 |
initSortable: function () {
|
363 |
|
364 |
/***
|
365 |
* Media Button
|
366 |
+
* Selects and adds media to controller
|
367 |
*/
|
368 |
MediaButton = views.MediaButton = Backbone.View.extend( {
|
369 |
tagName: 'div',
|
396 |
}
|
397 |
},
|
398 |
render: function () {
|
399 |
+
this.$el.html( this.template( {text: i18nRwmbMedia.add} ) );
|
|
|
400 |
return this;
|
401 |
},
|
402 |
|
403 |
initialize: function ( options ) {
|
404 |
this.controller = options.controller;
|
405 |
+
this.collection = this.controller.get( 'items' );
|
406 |
|
407 |
// Auto hide if you reach the max number of media
|
408 |
this.listenTo( this.controller, 'change:full', function () {
|
433 |
|
434 |
|
435 |
events: {
|
436 |
+
'click .rwmb-switch': function () {
|
437 |
+
this.trigger( 'click:switch', this.model );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
return false;
|
439 |
},
|
440 |
|
441 |
// Event when remove button clicked
|
442 |
+
'click .rwmb-remove-media': function () {
|
443 |
+
this.trigger( 'click:remove', this.model );
|
444 |
return false;
|
445 |
},
|
446 |
|
447 |
+
'click .rwmb-edit-media': function () {
|
448 |
+
this.trigger( 'click:edit', this.model );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
return false;
|
450 |
}
|
451 |
},
|
452 |
|
453 |
render: function () {
|
454 |
var attrs = _.clone( this.model.attributes );
|
455 |
+
attrs.controller = _.clone( this.controller.attributes );
|
456 |
this.$el.html( this.template( attrs ) );
|
457 |
return this;
|
458 |
}
|
462 |
* Extend media frames to make things work right
|
463 |
*/
|
464 |
|
465 |
+
/**
|
466 |
+
* MediaDetails
|
467 |
+
* Custom version of TwoColumn view to prevent all video and audio from being unset
|
468 |
+
*/
|
469 |
+
MediaDetails = views.MediaDetails = wp.media.view.Attachment.Details.TwoColumn.extend( {
|
470 |
+
render: function () {
|
471 |
+
var that = this;
|
472 |
+
wp.media.view.Attachment.Details.prototype.render.apply( this, arguments );
|
473 |
+
this.players = this.players || [];
|
474 |
+
|
475 |
+
wp.media.mixin.unsetPlayers.call( this );
|
476 |
+
|
477 |
+
this.$( 'audio, video' ).each( function ( i, elem ) {
|
478 |
+
var el = wp.media.view.MediaDetails.prepareSrc( elem );
|
479 |
+
that.players.push( new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings ) );
|
480 |
+
} );
|
481 |
+
}
|
482 |
+
} );
|
483 |
+
|
484 |
+
/***
|
485 |
+
* EditMedia
|
486 |
+
* Custom version of EditAttachments frame to prevent all video and audio from being unset
|
487 |
+
*/
|
488 |
+
EditMedia = views.EditMedia = wp.media.view.MediaFrame.EditAttachments.extend( {
|
489 |
+
/**
|
490 |
+
* Content region rendering callback for the `edit-metadata` mode.
|
491 |
+
*
|
492 |
+
* @param {Object} contentRegion Basic object with a `view` property, which
|
493 |
+
* should be set with the proper region view.
|
494 |
+
*/
|
495 |
+
editMetadataMode: function ( contentRegion ) {
|
496 |
+
contentRegion.view = new MediaDetails( {
|
497 |
+
controller: this,
|
498 |
+
model: this.model
|
499 |
+
} );
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Attach a subview to display fields added via the
|
503 |
+
* `attachment_fields_to_edit` filter.
|
504 |
+
*/
|
505 |
+
contentRegion.view.views.set( '.attachment-compat', new wp.media.view.AttachmentCompat( {
|
506 |
+
controller: this,
|
507 |
+
model: this.model
|
508 |
+
} ) );
|
509 |
+
}
|
510 |
+
} );
|
511 |
|
512 |
/**
|
513 |
* Initialize media fields
|
517 |
new MediaField( {input: this, el: $( this ).siblings( 'div.rwmb-media-view' )} );
|
518 |
}
|
519 |
|
|
|
520 |
$( ':input.rwmb-file_advanced' ).each( initMediaField );
|
521 |
$( '.rwmb-input' )
|
522 |
.on( 'clone', ':input.rwmb-file_advanced', initMediaField );
|
meta-box.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
-
* Version: 4.
|
7 |
* Author: Anh Tran
|
8 |
* Author URI: http://www.deluxeblogtips.com
|
9 |
* License: GPL2+
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
+
* Version: 4.11
|
7 |
* Author: Anh Tran
|
8 |
* Author URI: http://www.deluxeblogtips.com
|
9 |
* License: GPL2+
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: metabox, rilwis, fitwp, f-j-kaiser, funkatronic, PerWiklander, rua
|
|
3 |
Donate link: http://paypal.me/anhtnt
|
4 |
Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.1
|
6 |
-
Tested up to: 4.7.
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
|
@@ -91,6 +91,40 @@ To getting started with the plugin API, please read [this tutorial](https://meta
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= 4.10.4 =
|
95 |
* Improvement: Add support for validate user edit and term edit forms (requires MB Term Meta or MB User Meta extension).
|
96 |
* Improvement: Add new parameter `label_description` for fields to display a description below field label (name).
|
3 |
Donate link: http://paypal.me/anhtnt
|
4 |
Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.1
|
6 |
+
Tested up to: 4.7.3
|
7 |
+
Stable tag: 4.11
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 4.11 =
|
95 |
+
|
96 |
+
* Code architecture update:
|
97 |
+
* Add `object_id` property to the meta box object. Used to connect the meta box to the post object. Not heavily used yet.
|
98 |
+
* Add RWMB_Meta_Box_Registry and RWMB_Field_Registry to store all registered meta boxes and fields. Used to future access these objects. Use internally only. 3rd-party code should not use it as it's still experimental and can change in the future.
|
99 |
+
* Deprecated RWMB_Core::get_meta_boxes() due to the meta box registry above. This function was made for internally use only. 3rd-party code should not rely on it.
|
100 |
+
* Add magic method __get to the meta box object to quick access to meta box configuration.
|
101 |
+
* UI update:
|
102 |
+
* Make the field label bold (similar to WordPress settings page).
|
103 |
+
* Increase margin between fields and change color for remove clone button (also reduce minus size)
|
104 |
+
* Remove style for checkbox (default is good).
|
105 |
+
* Improve styles for checkbox/radio list
|
106 |
+
* A little smaller padding for select box. Also remove default size for select[multiple]
|
107 |
+
* Add a little space between the map canvas and the "Find Address" button
|
108 |
+
* Media fields:
|
109 |
+
* Media field update: Hidden field for media fields now no longer disabled. If media field js not loaded properly, code will default to hidden field and process
|
110 |
+
accordingly. Issue #1088.
|
111 |
+
* Better and simpler way to handle HTML file upload using `media_handle_upload` function.
|
112 |
+
* Rewrite JS for "file", simpler and modular. Also fix bug when add/remove items that doesn't toggle the Add more link correctly.
|
113 |
+
* Improve JS code for media field, using MediaList instead of item views (Backbone JS code).
|
114 |
+
* Add support for image sizes in image_advanced and image_upload. Default is thumbnail. Fixes #425.
|
115 |
+
* Clone:
|
116 |
+
* Add new parameter `add_button` for the add new clone button text. Better than use filter.
|
117 |
+
* Fix position for remove clone button in RTL languages
|
118 |
+
* Update margin between clones and set clone placeholder = outer height of the cloned element.
|
119 |
+
* Scripts and styles:
|
120 |
+
* Check condition for enqueueing scripts & styles only in the admin.
|
121 |
+
* Update the time picker library to the latest version (1.6.3) to supports "select" control for time picker. [See demo](http://trentrichardson.com/examples/timepicker/#slider_examples).
|
122 |
+
* Better dependencies for date picker CSS, autocomplete field.
|
123 |
+
* Other improvements:
|
124 |
+
* Remove the static helper class because of a bad OOP code.
|
125 |
+
* Fix get plugin URL symlink when plugin is put in a theme and symlinked. Props @tutv95.
|
126 |
+
* Add support for "region" in the map field to limit autocomplete from wrong entries (to help preventing from entering wrong address or country). See https://developers.google.com/maps/documentation/geocoding/intro#RegionCodes
|
127 |
+
|
128 |
= 4.10.4 =
|
129 |
* Improvement: Add support for validate user edit and term edit forms (requires MB Term Meta or MB User Meta extension).
|
130 |
* Improvement: Add new parameter `label_description` for fields to display a description below field label (name).
|