Version Description
- Google Map: Added new 'acf/fields/google_map/api' filter
Download this release
Release Info
Developer | elliotcondon |
Plugin | Advanced Custom Fields |
Version | 4.4.8 |
Comparing to | |
See all releases |
Code changes from version 4.4.7 to 4.4.8
- acf.php +2 -2
- core/controllers/addons.php +1 -1
- core/fields/google-map.php +46 -0
- js/input.js +13 -5
- js/input.min.js +2 -2
- js/input/_listener.js +0 -0
- js/input/_listener.min.js +0 -0
- js/input/acf.js +0 -942
- js/input/ajax.js +0 -325
- js/input/color-picker.js +0 -79
- js/input/date-picker.js +0 -134
- js/input/file.js +0 -373
- js/input/google-map.js +0 -558
- js/input/image.js +0 -416
- js/input/radio.js +0 -70
- js/input/relationship.js +0 -361
- js/input/tab.js +0 -280
- js/input/validation.js +0 -432
- js/input/wysiwyg.js +0 -556
- readme.txt +6 -3
acf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
-
Version: 4.4.
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
@@ -43,7 +43,7 @@ class acf
|
|
43 |
'path' => apply_filters('acf/helpers/get_path', __FILE__),
|
44 |
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
|
45 |
'hook' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ),
|
46 |
-
'version' => '4.4.
|
47 |
'upgrade_version' => '3.4.1',
|
48 |
'include_3rd_party' => false
|
49 |
);
|
3 |
Plugin Name: Advanced Custom Fields
|
4 |
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
+
Version: 4.4.8
|
7 |
Author: Elliot Condon
|
8 |
Author URI: http://www.elliotcondon.com/
|
9 |
License: GPL
|
43 |
'path' => apply_filters('acf/helpers/get_path', __FILE__),
|
44 |
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
|
45 |
'hook' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ),
|
46 |
+
'version' => '4.4.8',
|
47 |
'upgrade_version' => '3.4.1',
|
48 |
'include_3rd_party' => false
|
49 |
);
|
core/controllers/addons.php
CHANGED
@@ -253,7 +253,7 @@ class acf_addons
|
|
253 |
<script type="text/javascript">
|
254 |
(function($) {
|
255 |
|
256 |
-
$(window).load
|
257 |
|
258 |
$('#add-ons .add-on-group').each(function(){
|
259 |
|
253 |
<script type="text/javascript">
|
254 |
(function($) {
|
255 |
|
256 |
+
$(window).on('load', function(){
|
257 |
|
258 |
$('#add-ons .add-on-group').each(function(){
|
259 |
|
core/fields/google-map.php
CHANGED
@@ -265,6 +265,52 @@ class acf_field_google_map extends acf_field
|
|
265 |
return $value;
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
new acf_field_google_map();
|
265 |
return $value;
|
266 |
}
|
267 |
|
268 |
+
|
269 |
+
/*
|
270 |
+
* input_admin_footer
|
271 |
+
*
|
272 |
+
* description
|
273 |
+
*
|
274 |
+
* @type function
|
275 |
+
* @date 6/03/2014
|
276 |
+
* @since 5.0.0
|
277 |
+
*
|
278 |
+
* @param $post_id (int)
|
279 |
+
* @return $post_id (int)
|
280 |
+
*/
|
281 |
+
|
282 |
+
function input_admin_head() {
|
283 |
+
|
284 |
+
add_action( 'admin_footer', array( $this, 'input_admin_footer') );
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
function input_admin_footer() {
|
289 |
+
|
290 |
+
// vars
|
291 |
+
$api = array(
|
292 |
+
'libraries' => 'places',
|
293 |
+
'key' => '',
|
294 |
+
'client' => ''
|
295 |
+
);
|
296 |
+
|
297 |
+
|
298 |
+
// filter
|
299 |
+
$api = apply_filters('acf/fields/google_map/api', $api);
|
300 |
+
|
301 |
+
|
302 |
+
// remove empty
|
303 |
+
if( empty($api['key']) ) unset($api['key']);
|
304 |
+
if( empty($api['client']) ) unset($api['client']);
|
305 |
+
|
306 |
+
|
307 |
+
?>
|
308 |
+
<script type="text/javascript">
|
309 |
+
acf.fields.google_map.api = <?php echo json_encode($api); ?>;
|
310 |
+
</script>
|
311 |
+
<?php
|
312 |
+
|
313 |
+
}
|
314 |
}
|
315 |
|
316 |
new acf_field_google_map();
|
js/input.js
CHANGED
@@ -884,7 +884,7 @@ var acf = {
|
|
884 |
* @created: 22/12/12
|
885 |
*/
|
886 |
|
887 |
-
$(window).load
|
888 |
|
889 |
// init
|
890 |
acf.media.init();
|
@@ -1876,6 +1876,10 @@ var acf = {
|
|
1876 |
$input : null,
|
1877 |
|
1878 |
o : {},
|
|
|
|
|
|
|
|
|
1879 |
|
1880 |
ready : false,
|
1881 |
geocoder : false,
|
@@ -2267,8 +2271,12 @@ var acf = {
|
|
2267 |
|
2268 |
$(document).on('acf/setup_fields', function(e, el){
|
2269 |
|
|
|
|
|
|
|
|
|
2270 |
// vars
|
2271 |
-
$fields = $(el).find('.acf-google-map');
|
2272 |
|
2273 |
|
2274 |
// validate
|
@@ -2282,7 +2290,7 @@ var acf = {
|
|
2282 |
$.getScript('https://www.google.com/jsapi', function(){
|
2283 |
|
2284 |
// load maps
|
2285 |
-
|
2286 |
|
2287 |
$fields.each(function(){
|
2288 |
|
@@ -2302,7 +2310,7 @@ var acf = {
|
|
2302 |
// no maps or places
|
2303 |
if( !acf.helpers.isset(window, 'google', 'maps', 'places') ) {
|
2304 |
|
2305 |
-
google.load('maps', '3', { other_params:
|
2306 |
|
2307 |
$fields.each(function(){
|
2308 |
|
@@ -4456,7 +4464,7 @@ var acf = {
|
|
4456 |
* @created: 22/12/12
|
4457 |
*/
|
4458 |
|
4459 |
-
$(window).load
|
4460 |
|
4461 |
// validate
|
4462 |
if( ! _wysiwyg.has_tinymce() )
|
884 |
* @created: 22/12/12
|
885 |
*/
|
886 |
|
887 |
+
$(window).on('load', function(){
|
888 |
|
889 |
// init
|
890 |
acf.media.init();
|
1876 |
$input : null,
|
1877 |
|
1878 |
o : {},
|
1879 |
+
api: {
|
1880 |
+
sensor: false,
|
1881 |
+
libraries: 'places'
|
1882 |
+
},
|
1883 |
|
1884 |
ready : false,
|
1885 |
geocoder : false,
|
2271 |
|
2272 |
$(document).on('acf/setup_fields', function(e, el){
|
2273 |
|
2274 |
+
// reference
|
2275 |
+
var self = acf.fields.google_map;
|
2276 |
+
|
2277 |
+
|
2278 |
// vars
|
2279 |
+
var $fields = $(el).find('.acf-google-map');
|
2280 |
|
2281 |
|
2282 |
// validate
|
2290 |
$.getScript('https://www.google.com/jsapi', function(){
|
2291 |
|
2292 |
// load maps
|
2293 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
2294 |
|
2295 |
$fields.each(function(){
|
2296 |
|
2310 |
// no maps or places
|
2311 |
if( !acf.helpers.isset(window, 'google', 'maps', 'places') ) {
|
2312 |
|
2313 |
+
google.load('maps', '3', { other_params: $.param(self.api), callback: function(){
|
2314 |
|
2315 |
$fields.each(function(){
|
2316 |
|
4464 |
* @created: 22/12/12
|
4465 |
*/
|
4466 |
|
4467 |
+
$(window).on('load', function(){
|
4468 |
|
4469 |
// validate
|
4470 |
if( ! _wysiwyg.has_tinymce() )
|
js/input.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
var acf={ajaxurl:"",admin_url:"",wp_version:"",post_id:0,nonce:"",l10n:null,o:null,helpers:{get_atts:null,version_compare:null,uniqid:null,sortable:null,add_message:null,is_clone_field:null,url_to_object:null},validation:null,conditional_logic:null,media:null,fields:{date_picker:null,color_picker:null,Image:null,file:null,wysiwyg:null,gallery:null,relationship:null}};!function($){acf.helpers.isset=function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i<t;i++){if(e[i]===n||a[e[i]]===n)return!1;a=a[e[i]]}return!0},acf.helpers.get_atts=function(e){var t={};return $.each(e[0].attributes,function(e,i){"data-"==i.name.substr(0,5)&&(t[i.name.replace("data-","")]=i.value)}),t},acf.helpers.version_compare=function(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),n=0,s=Math.max(i.length,a.length);s>n;n++){if(i[n]&&!a[n]&&parseInt(i[n])>0||parseInt(i[n])>parseInt(a[n]))return 1;if(a[n]&&!i[n]&&parseInt(a[n])>0||parseInt(i[n])<parseInt(a[n]))return-1}return 0},acf.helpers.uniqid=function(){var e=new Date;return e.getTime()},acf.helpers.url_to_object=function(e){var t={},a=e.split("&");for(i in a){var n=a[i].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t},acf.helpers.sortable=function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},acf.helpers.is_clone_field=function(e){return e.attr("name")&&-1!=e.attr("name").indexOf("[acfcloneindex]")?!0:!1},acf.helpers.add_message=function(e,t){var e=$('<div class="acf-message-wrapper"><div class="message updated"><p>'+e+"</p></div></div>");t.prepend(e),setTimeout(function(){e.animate({opacity:0},250,function(){e.remove()})},1500)},$.fn.exists=function(){return $(this).length>0},acf.media={div:null,frame:null,render_timout:null,clear_frame:function(){this.frame&&(this.frame.detach(),this.frame.dispose(),this.frame=null)},type:function(){var e="thickbox";return"undefined"!=typeof wp&&(e="backbone"),e},init:function(){if("backbone"!==this.type())return!1;if(!acf.helpers.isset(wp,"media","view","AttachmentCompat","prototype"))return!1;var e=wp.media.view.AttachmentCompat.prototype;e.orig_render=e.render,e.orig_dispose=e.dispose,e.className="compat-item acf_postbox no_box",e.render=function(){var e=this;return e.ignore_render?this:(this.orig_render(),setTimeout(function(){var t=e.$el.closest(".media-modal");if(!t.hasClass("acf-media-modal")&&!t.find(".media-frame-router .acf-expand-details").exists()){var i=$(['<a href="#" class="acf-expand-details">','<span class="icon"></span>','<span class="is-closed">'+acf.l10n.core.expand_details+"</span>",'<span class="is-open">'+acf.l10n.core.collapse_details+"</span>","</a>"].join(""));i.on("click",function(e){e.preventDefault(),t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),t.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){$(document).trigger("acf/setup_fields",[e.$el])},50),this)},e.dispose=function(){$(document).trigger("acf/remove_fields",[this.$el]),this.orig_dispose()},e.save=function(e){var t={},i={};e&&e.preventDefault(),_.each(this.$el.serializeArray(),function(e){"[]"===e.name.slice(-2)&&(e.name=e.name.replace("[]",""),"undefined"==typeof i[e.name]&&(i[e.name]=-1),i[e.name]++,e.name+="["+i[e.name]+"]"),t[e.name]=e.value}),this.ignore_render=!0,this.model.saveCompat(t)}}},acf.conditional_logic={items:[],init:function(){var e=this;$(document).on("change",".field input, .field textarea, .field select",function(){$("#acf-has-changed").exists()&&$("#acf-has-changed").val(1),e.change($(this))}),$(document).on("acf/setup_fields",function(t,i){e.refresh($(i))}),e.refresh()},change:function(e){var t=this,i=e.closest(".field"),a=i.attr("data-field_key");$.each(this.items,function(e,i){$.each(i.rules,function(e,n){n.field==a&&t.refresh_field(i)})})},refresh_field:function(e){var t=this,i=$(".field_key-"+e.field);i.each(function(){var i=!0;"any"==e.allorany&&(i=!1);var a=$(this),n=!0;$.each(e.rules,function(s,o){var l=$(".field_key-"+o.field);l.hasClass("sub_field")&&(l=a.siblings(".field_key-"+o.field),n=!1,l.exists()||(a.parents("tr").each(function(){return l=$(this).find(".field_key-"+o.field),l.exists()?!1:void 0}),n=!0));var r=a.parent("tr").parent().parent("table").parent(".layout");r.exists()&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest(".layout").find("td.field_key-"+o.field)));var r=a.parent("tr").parent().parent("table").parent(".repeater");r.exists()&&"1"==r.attr("data-max_rows")&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest("table").find("td.field_key-"+o.field)));var c=t.calculate(o,l,a);if("all"==e.allorany){if(0==c)return i=!1,!1}else if(1==c)return i=!0,!1}),a.removeClass("acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank"),i?(a.find("input, textarea, select").removeAttr("disabled"),a.addClass("acf-conditional_logic-show"),$(document).trigger("acf/conditional_logic/show",[a,e])):(a.find("input, textarea, select").attr("disabled","disabled"),a.addClass("acf-conditional_logic-hide"),n||a.addClass("acf-show-blank"),$(document).trigger("acf/conditional_logic/hide",[a,e]))})},refresh:function(e){e=e||$("body");var t=this;$.each(this.items,function(i,a){$.each(a.rules,function(i,n){e.find('.field[data-field_key="'+a.field+'"]').exists()&&t.refresh_field(a)})})},calculate:function(e,t,i){var a=!1;if(t.hasClass("field_type-true_false")||t.hasClass("field_type-checkbox")||t.hasClass("field_type-radio")){var n=t.find('input[value="'+e.value+'"]:checked').exists();"=="==e.operator?n&&(a=!0):n||(a=!0)}else{var s=t.find("input, textarea, select").last().val();$.isArray(s)||(s=[s]),"=="==e.operator?$.inArray(e.value,s)>-1&&(a=!0):$.inArray(e.value,s)<0&&(a=!0)}return a}},$(document).ready(function(){acf.conditional_logic.init(),$(".acf_postbox > .inside > .options").each(function(){$(this).closest(".acf_postbox").addClass($(this).attr("data-layout"))}),$('#metakeyselect option[value^="field_"]').remove()}),$(window).load(function(){acf.media.init(),setTimeout(function(){try{$.isNumeric(acf.o.post_id)&&(wp.media.view.settings.post.id=acf.o.post_id)}catch(e){}$(document).trigger("acf/setup_fields",[$("#poststuff")])},10)}),acf.fields.gallery={add:function(){},edit:function(){},update_count:function(){},hide_selected_items:function(){},text:{title_add:"Select Images"}}}(jQuery),function($){function e(){var e=[];$(".categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected").each(function(){$(this).is(":hidden")||$(this).is(":disabled")||$(this).closest(".media-frame").exists()||$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-load_save")||-1===e.indexOf($(this).val())&&e.push($(this).val())}),acf.screen.post_category=e,acf.screen.taxonomy=e,$(document).trigger("acf/update_field_groups")}acf.screen={action:"acf/location/match_field_groups_ajax",post_id:0,page_template:0,page_parent:0,page_type:0,post_category:0,post_format:0,taxonomy:0,lang:0,nonce:0},$(document).ready(function(){if(acf.screen.post_id=acf.o.post_id,acf.screen.nonce=acf.o.nonce,$("#icl-als-first").length>0){var e=$("#icl-als-first").children("a").attr("href"),t=new RegExp("lang=([^&#]*)"),i=t.exec(e);acf.screen.lang=i[1]}}),$(document).on("acf/update_field_groups",function(){return acf.screen.post_id&&$.isNumeric(acf.screen.post_id)?void $.ajax({url:ajaxurl,data:acf.screen,type:"post",dataType:"json",success:function(e){return e?($(".acf_postbox").addClass("acf-hidden"),$(".acf_postbox-toggle").addClass("acf-hidden"),0==e.length?!1:($.each(e,function(e,t){var i=$("#acf_"+t),a=$('#adv-settings .acf_postbox-toggle[for="acf_'+t+'-hide"]');i.removeClass("acf-hidden hide-if-js"),a.removeClass("acf-hidden"),a.find('input[type="checkbox"]').attr("checked","checked"),i.find(".acf-replace-with-fields").each(function(){var e=$(this);$.ajax({url:ajaxurl,data:{action:"acf/post/render_fields",acf_id:t,post_id:acf.o.post_id,nonce:acf.o.nonce},type:"post",dataType:"html",success:function(t){e.replaceWith(t),$(document).trigger("acf/setup_fields",i)}})})}),void $.ajax({url:ajaxurl,data:{action:"acf/post/get_style",acf_id:e[0],nonce:acf.o.nonce},type:"post",dataType:"html",success:function(e){$("#acf_style").html(e)}}))):!1}}):!1}),$(document).on("change","#page_template",function(){acf.screen.page_template=$(this).val(),$(document).trigger("acf/update_field_groups")}),$(document).on("change","#parent_id",function(){var e=$(this).val();""!=e?(acf.screen.page_type="child",acf.screen.page_parent=e):(acf.screen.page_type="parent",acf.screen.page_parent=0),$(document).trigger("acf/update_field_groups")}),$(document).on("change",'#post-formats-select input[type="radio"]',function(){var e=$(this).val();"0"==e&&(e="standard"),acf.screen.post_format=e,$(document).trigger("acf/update_field_groups")}),$(document).on("change",".categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select",function(){$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-save")||$(this).closest(".media-frame").exists()||setTimeout(function(){e()},1)})}(jQuery),function($){var e=acf.fields.color_picker={$el:null,$input:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this},init:function(){var e=this.$input;acf.helpers.is_clone_field(e)||this.$input.wpColorPicker()}};$(document).on("acf/setup_fields",function(t,i){$(i).find(".acf-color_picker").each(function(){e.set({$el:$(this)}).init()})})}(jQuery),function($){acf.fields.date_picker={$el:null,$input:null,$hidden:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this},init:function(){if(!acf.helpers.is_clone_field(this.$hidden)){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:this.o.save_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").length>0&&$("#ui-datepicker-div").wrap('<div class="ui-acf" />')}},blur:function(){this.$input.val()||this.$hidden.val("")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-date_picker").each(function(){acf.fields.date_picker.set({$el:$(this)}).init()})}),$(document).on("blur",'.acf-date_picker input[type="text"]',function(e){acf.fields.date_picker.set({$el:$(this).parent()}).blur()})}(jQuery),function($){var e=acf.media;acf.fields.file={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=this.$el.closest(".repeater").exists()?!0:!1,this.o.query={},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-file-icon").attr("src",t.icon),i.find(".acf-file-title").text(t.title),i.find(".acf-file-name").text(t.name).attr("href",t.url),i.find(".acf-file-size").text(t.size),i.find(".acf-file-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.file.edit,multiple:!1,button:{text:acf.l10n.file.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-file-icon").attr("src",""),this.$el.find(".acf-file-title").text(""),this.$el.find(".acf-file-name").text("").attr("href",""),this.$el.find(".acf-file-size").text(""),this.$el.find(".acf-file-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.file.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?void("uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.file.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id}))):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var t=0;selection.each(function(i){if(t++,t>1){var a=e.div.closest("td"),n=a.closest(".row"),s=n.closest(".repeater"),o=a.attr("data-field_key"),l="td .acf-file-uploader:first";o&&(l='td[data-field_key="'+o+'"] .acf-file-uploader'),n.next(".row").exists()||s.find(".add-row-end").trigger("click"),e.div=n.next(".row").find(l)}var r={id:i.id,title:i.attributes.title,name:i.attributes.filename,url:i.attributes.url,icon:i.attributes.icon,size:i.attributes.filesize};acf.fields.file.add(r)})}}),acf.media.frame.open(),!1}},$(document).on("click",".acf-file-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).edit()}),$(document).on("click",".acf-file-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).remove()}),$(document).on("click",".acf-file-uploader .add-file",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).popup()})}(jQuery),function($){acf.fields.google_map={$el:null,$input:null,o:{},ready:!1,geocoder:!1,map:!1,maps:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find(".input-address"),this.o=acf.helpers.get_atts(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id]),this},init:function(){this.geocoder||(this.geocoder=new google.maps.Geocoder),this.ready=!0,acf.helpers.is_clone_field(this.$input)||this.render()},render:function(){var e=this,t=this.$el,i={zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP};this.map=new google.maps.Map(this.$el.find(".canvas")[0],i);var a=new google.maps.places.Autocomplete(this.$el.find(".search")[0]);a.map=this.map,a.bindTo("bounds",this.map),this.map.marker=new google.maps.Marker({draggable:!0,raiseOnDrag:!0,map:this.map}),this.map.$el=this.$el;var n=this.$el.find(".input-lat").val(),s=this.$el.find(".input-lng").val();n&&s&&this.update(n,s).center(),google.maps.event.addListener(a,"place_changed",function(t){var i=this.map.$el,a=i.find(".search").val();i.find(".input-address").val(a),i.find(".title h4").text(a);var n=this.getPlace();if(n.geometry){var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()}else e.geocoder.geocode({address:a},function(t,a){if(a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!t[0])return void console.log("No results found");n=t[0];var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()})}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.$el,i=this.map.marker.getPosition(),a=i.lat(),n=i.lng();e.set({$el:t}).update(a,n).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=this.$el,a=t.latLng.lat(),n=t.latLng.lng();e.set({$el:i}).update(a,n).sync()}),this.maps[this.o.id]=this.map},update:function(e,t){var i=new google.maps.LatLng(e,t);return this.$el.find(".input-lat").val(e),this.$el.find(".input-lng").val(t).trigger("change"),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("active"),this.$el.closest(".field").removeClass("error"),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this.$el,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.geocoder.geocode({latLng:i},function(t,i){if(i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.find(".title h4").text(a.formatted_address),e.find(".input-address").val(a.formatted_address).trigger("change")}),this},locate:function(){var e=this,t=this.$el;return navigator.geolocation?(t.find(".title h4").text(acf.l10n.google_map.locating+"..."),t.addClass("active"),void navigator.geolocation.getCurrentPosition(function(i){var a=i.coords.latitude,n=i.coords.longitude;e.set({$el:t}).update(a,n).sync().center()})):(alert(acf.l10n.google_map.browser_support),this)},clear:function(){this.$el.removeClass("active"),this.$el.find(".search").val(""),this.$el.find(".input-address").val(""),this.$el.find(".input-lat").val(""),this.$el.find(".input-lng").val(""),this.map.marker.setVisible(!1)},edit:function(){this.$el.removeClass("active");var e=this.$el.find(".title h4").text();this.$el.find(".search").val(e).focus()},refresh:function(){google.maps.event.trigger(this.map,"resize"),this.center()}},$(document).on("acf/setup_fields",function(e,t){return $fields=$(t).find(".acf-google-map"),$fields.exists()?acf.helpers.isset(window,"google","load")?acf.helpers.isset(window,"google","maps","places")?($fields.each(function(){acf.fields.google_map.set({$el:$(this)}).init()}),!0):(google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){$fields.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}}),!1):($.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){$fields.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}})}),!1):!1}),$(document).on("click",".acf-google-map .acf-sprite-remove",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).clear(),$(this).blur()}),$(document).on("click",".acf-google-map .acf-sprite-locate",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).locate(),$(this).blur()}),$(document).on("click",".acf-google-map .title h4",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).edit()}),$(document).on("keydown",".acf-google-map .search",function(e){return 13==e.which?!1:void 0}),$(document).on("blur",".acf-google-map .search",function(e){var t=$(this).closest(".acf-google-map");t.find(".input-lat").val()&&t.addClass("active")}),$(document).on("acf/fields/tab/show acf/conditional_logic/show",function(e,t){acf.fields.google_map.ready&&"google_map"==t.attr("data-field_type")&&acf.fields.google_map.set({$el:t.find(".acf-google-map")}).refresh()})}(jQuery),function($){var e=acf.media;acf.fields.image={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=this.$el.closest(".repeater").exists()?!0:!1,this.o.query={type:"image"},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-image-image").attr("src",t.url),i.find(".acf-image-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.image.edit,multiple:!1,button:{text:acf.l10n.image.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-image-image").attr("src",""),this.$el.find(".acf-image-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.image.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?($.each(i.filters,function(e,t){t.props.type="image"}),"uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.image.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id})),i.$el.find("option").each(function(){var e=$(this).attr("value");("uploaded"!=e||"all"!=t.o.library)&&-1===e.indexOf("image")&&$(this).remove()}),void i.$el.val("image").trigger("change")):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var i=0;selection.each(function(a){if(i++,i>1){var n=e.div.closest("td"),s=n.closest(".row"),o=s.closest(".repeater"),l=n.attr("data-field_key"),r="td .acf-image-uploader:first";l&&(r='td[data-field_key="'+l+'"] .acf-image-uploader'),s.next(".row").exists()||o.find(".add-row-end").trigger("click"),e.div=s.next(".row").find(r)}var c={id:a.id,url:a.attributes.url};a.attributes.sizes&&a.attributes.sizes[t.o.preview_size]&&(c.url=a.attributes.sizes[t.o.preview_size].url),acf.fields.image.add(c)})}}),acf.media.frame.open(),!1},text:{title_add:"Select Image",title_edit:"Edit Image"}},$(document).on("click",".acf-image-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).edit()}),$(document).on("click",".acf-image-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).remove()}),$(document).on("click",".acf-image-uploader .add-image",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).popup()})}(jQuery),function($){acf.fields.radio={$el:null,$input:null,$other:null,farbtastic:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="radio"]:checked'),this.$other=this.$el.find('input[type="text"]'),this},change:function(){"other"==this.$input.val()?(this.$other.attr("name",this.$input.attr("name")),this.$other.show()):(this.$other.attr("name",""),this.$other.hide())}},$(document).on("change",'.acf-radio-list input[type="radio"]',function(e){acf.fields.radio.set({$el:$(this).closest(".acf-radio-list")}).change()})}(jQuery),function($){acf.fields.relationship={$el:null,$input:null,$left:null,$right:null,o:{},timeout:null,set:function(e){return $.extend(this,e),this.$input=this.$el.children('input[type="hidden"]'),this.$left=this.$el.find(".relationship_left"),this.$right=this.$el.find(".relationship_right"),this.o=acf.helpers.get_atts(this.$el),this},init:function(){var e=this;if(!acf.helpers.is_clone_field(this.$input)){this.$right.find(".relationship_list").height(this.$left.height()-2),this.$right.find(".relationship_list").sortable({axis:"y",items:"> li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){e.$input.trigger("change")}});var t=this.$el;this.$left.find(".relationship_list").scrollTop(0).on("scroll",function(i){if(!t.hasClass("loading")&&!t.hasClass("no-results")&&$(this).scrollTop()+$(this).innerHeight()>=$(this).get(0).scrollHeight){var a=parseInt(t.attr("data-paged"));t.attr("data-paged",a+1),e.set({$el:t}).fetch()}}),this.fetch()}},fetch:function(){var e=this,t=this.$el;t.addClass("loading"),$.ajax({url:acf.o.ajaxurl,type:"post",dataType:"json",data:$.extend({action:"acf/fields/relationship/query_posts",post_id:acf.o.post_id,nonce:acf.o.nonce},this.o),success:function(i){e.set({$el:t}).render(i)}})},render:function(e){var t=this;return this.$el.removeClass("no-results").removeClass("loading"),1==this.o.paged&&this.$el.find(".relationship_left li:not(.load-more)").remove(),e&&e.html?(this.$el.find(".relationship_left .load-more").before(e.html),e.next_page_exists||this.$el.addClass("no-results"),void this.$left.find("a").each(function(){var e=$(this).attr("data-post_id");t.$right.find('a[data-post_id="'+e+'"]').exists()&&$(this).parent().addClass("hide")})):void this.$el.addClass("no-results")},add:function(e){var t=e.attr("data-post_id"),i=e.html();if(this.$right.find("a").length>=this.o.max)return alert(acf.l10n.relationship.max.replace("{max}",this.o.max)),!1;if(e.parent().hasClass("hide"))return!1;e.parent().addClass("hide");var a=["<li>",'<a href="#" data-post_id="'+e.attr("data-post_id")+'">',e.html()+'<span class="acf-button-remove"></span>',"</a>",'<input type="hidden" name="'+this.$input.attr("name")+'[]" value="'+e.attr("data-post_id")+'" />',"</li>"].join("");this.$right.find(".relationship_list").append(a),this.$input.trigger("change"),this.$el.closest(".field").removeClass("error")},remove:function(e){e.parent().remove(),this.$left.find('a[data-post_id="'+e.attr("data-post_id")+'"]').parent("li").removeClass("hide"),this.$input.trigger("change")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf_relationship").each(function(){acf.fields.relationship.set({$el:$(this)}).init()})}),$(document).on("change",".acf_relationship .select-post_type",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-post_type",t),i.attr("data-paged",1),acf.fields.relationship.set({$el:i}).fetch()}),$(document).on("click",".acf_relationship .relationship_left .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).add($(this)),$(this).blur()}),$(document).on("click",".acf_relationship .relationship_right .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).remove($(this)),$(this).blur()}),$(document).on("keyup",".acf_relationship input.relationship_search",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-s",t),i.attr("data-paged",1),clearTimeout(acf.fields.relationship.timeout),acf.fields.relationship.timeout=setTimeout(function(){acf.fields.relationship.set({$el:i}).fetch()},500)}),$(document).on("keypress",".acf_relationship input.relationship_search",function(e){13==e.which&&e.preventDefault()})}(jQuery),function($){acf.fields.tab={add_group:function(e){var t="";t=e.is("tbody")?'<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>':'<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>',e.children(".field_type-tab:first").before(t)},add_tab:function(e){var t=e.closest(".field"),i=t.parent(),a=t.attr("data-field_key"),n=e.text();i.children(".acf-tab-wrap").exists()||this.add_group(i),i.children(".acf-tab-wrap").find(".acf-tab-group").append('<li><a class="acf-tab-button" href="#" data-key="'+a+'">'+n+"</a></li>")},toggle:function(e){var t=this,i=e.closest(".acf-tab-wrap").parent(),a=e.attr("data-key");e.parent("li").addClass("active").siblings("li").removeClass("active"),i.children(".field_type-tab").each(function(){var e=$(this);e.attr("data-field_key")==a?t.show_tab_fields($(this)):t.hide_tab_fields($(this))})},show_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-hide").addClass("acf-tab_group-show"),$(document).trigger("acf/fields/tab/show",[$(this)])})},hide_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-show").addClass("acf-tab_group-hide"),$(document).trigger("acf/fields/tab/hide",[$(this)])})},refresh:function(e){var t=this;e.find(".acf-tab-group").each(function(){$(this).find(".acf-tab-button:first").each(function(){t.toggle($(this))})})}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-tab").each(function(){acf.fields.tab.add_tab($(this))}),acf.fields.tab.refresh($(t))}),$(document).on("click",".acf-tab-button",function(e){e.preventDefault(),acf.fields.tab.toggle($(this)),$(this).trigger("blur")}),$(document).on("acf/conditional_logic/hide",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');a.is(":hidden")||(a.parent().hide(),a.parent().siblings(":visible").exists()?a.parent().siblings(":visible").first().children("a").trigger("click"):acf.fields.tab.hide_tab_fields(t))}}),$(document).on("acf/conditional_logic/show",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');if(!a.is(":visible"))return a.parent().show(),a.parent().hasClass("active")?void a.trigger("click"):a.parent().siblings(".active").is(":hidden")?void a.trigger("click"):void 0}})}(jQuery),function($){acf.validation={status:!0,disabled:!1,run:function(){var e=this;e.status=!0,$(".field.required, .form-field.required").each(function(){e.validate($(this))})},show_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},validate:function(e){var t=!1,i=null;if(e.data("validation",!0),e.is(":hidden")&&(t=!0,e.hasClass("acf-tab_group-hide"))){t=!1;var a=e.prevAll(".field_type-tab:first"),n=e.prevAll(".acf-tab-wrap:first");a.hasClass("acf-conditional_logic-hide")?t=!0:i=n.find('.acf-tab-button[data-key="'+a.attr("data-field_key")+'"]')}if(e.hasClass("acf-conditional_logic-hide")&&(t=!0),e.closest(".postbox.acf-hidden").exists()&&(t=!0),!t){if(""==e.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val()&&e.data("validation",!1),e.find(".acf_wysiwyg").exists()&&"object"==typeof tinyMCE){e.data("validation",!0);var s=e.find(".wp-editor-area").attr("id"),o=tinyMCE.get(s);o&&!o.getContent()&&e.data("validation",!1)}if(e.find("select").exists()&&(e.data("validation",!0),"null"!=e.find("select").val()&&e.find("select").val()||e.data("validation",!1)),e.find('input[type="radio"]').exists()&&(e.data("validation",!1),e.find('input[type="radio"]:checked').exists()&&e.data("validation",!0)),e.find('input[type="checkbox"]').exists()&&(e.data("validation",!1),e.find('input[type="checkbox"]:checked').exists()&&e.data("validation",!0)),e.find(".acf_relationship").exists()&&(e.data("validation",!1),e.find(".acf_relationship .relationship_right input").exists()&&e.data("validation",!0)),e.find(".repeater").exists()&&(e.data("validation",!1),e.find(".repeater tr.row").exists()&&e.data("validation",!0)),e.find(".acf-gallery").exists()&&(e.data("validation",!1),e.find(".acf-gallery .thumbnail").exists()&&e.data("validation",!0)),$(document).trigger("acf/validate_field",[e]),!e.data("validation")){if(this.status=!1,e.closest(".field").addClass("error"),e.data("validation_message")){var l=e.find("p.label:first"),r=null;l.children(".acf-error-message").remove(),l.append('<span class="acf-error-message"><i class="bit"></i>'+e.data("validation_message")+"</span>")}i&&i.trigger("click")}}}},$(document).on("focus click",".field.required input, .field.required textarea, .field.required select",function(e){
|
2 |
-
$(this).closest(".field").removeClass("error")}),$(document).on("click","#save-post",function(){acf.validation.disabled=!0}),$(document).on("submit","#post",function(){if(acf.validation.disabled)return!0;if(acf.validation.run(),!acf.validation.status){var e=$(this);return e.siblings("#message").remove(),e.before('<div id="message" class="error"><p>'+acf.l10n.validation.error+"</p></div>"),$("#submitdiv").exists()&&($("#submitdiv").find(".disabled").removeClass("disabled"),$("#submitdiv").find(".button-disabled").removeClass("button-disabled"),$("#submitdiv").find(".button-primary-disabled").removeClass("button-primary-disabled"),acf.validation.hide_spinner($("#submitdiv .spinner"))),!1}return $(".acf_postbox.acf-hidden").remove(),!0})}(jQuery),function($){var e=acf.fields.wysiwyg={$el:null,$textarea:null,o:{},set:function(e){return $.extend(this,e),this.$textarea=this.$el.find("textarea"),this.o=acf.helpers.get_atts(this.$el),this.o.id=this.$textarea.attr("id"),this},has_tinymce:function(){var e=!1;return"object"==typeof tinyMCE&&(e=!0),e},get_toolbar:function(){return acf.helpers.isset(this,"toolbars",this.o.toolbar)?this.toolbars[this.o.toolbar]:!1},init:function(){if(!acf.helpers.is_clone_field(this.$textarea)){var e=this.get_toolbar(),t="mceAddControl",i="theme_advanced_buttons{i}",a=$.extend({},tinyMCE.settings);if(4==tinymce.majorVersion&&(t="mceAddEditor",i="toolbar{i}"),e)for(var n=1;5>n;n++){var s="";acf.helpers.isset(e,"theme_advanced_buttons"+n)&&(s=e["theme_advanced_buttons"+n]),tinyMCE.settings[i.replace("{i}",n)]=s}tinyMCE.execCommand(t,!1,this.o.id),$(document).trigger("acf/wysiwyg/load",this.o.id),this.add_events(),tinyMCE.settings=a,wpActiveEditor=null}},add_events:function(){var e=this.o.id,t=tinyMCE.get(e);if(t){var i=$("#wp-"+e+"-wrap"),a=$(t.getBody());i.on("click",function(){$(document).trigger("acf/wysiwyg/click",e)}),a.on("focus",function(){$(document).trigger("acf/wysiwyg/focus",e)}),a.on("blur",function(){$(document).trigger("acf/wysiwyg/blur",e)})}},destroy:function(){var e=this.o.id,t="mceRemoveControl";try{var i=tinyMCE.get(e);if(!i)return;4==tinymce.majorVersion&&(t="mceRemoveEditor");var a=i.getContent();tinyMCE.execCommand(t,!1,e),this.$textarea.val(a)}catch(n){}wpActiveEditor=null}};$(document).on("acf/setup_fields",function(t,i){e.has_tinymce()&&($(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()}),setTimeout(function(){$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})},0))}),$(document).on("acf/remove_fields",function(t,i){e.has_tinymce()&&i.find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/wysiwyg/click",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/focus",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/blur",function(e,t){wpActiveEditor=null;var i=tinyMCE.get(t);if(i){var a=i.getElement();i.save(),$(a).trigger("change")}}),$(document).on("acf/sortable_start",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/sortable_stop",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})}),$(window).load
|
1 |
+
var acf={ajaxurl:"",admin_url:"",wp_version:"",post_id:0,nonce:"",l10n:null,o:null,helpers:{get_atts:null,version_compare:null,uniqid:null,sortable:null,add_message:null,is_clone_field:null,url_to_object:null},validation:null,conditional_logic:null,media:null,fields:{date_picker:null,color_picker:null,Image:null,file:null,wysiwyg:null,gallery:null,relationship:null}};!function($){acf.helpers.isset=function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i<t;i++){if(e[i]===n||a[e[i]]===n)return!1;a=a[e[i]]}return!0},acf.helpers.get_atts=function(e){var t={};return $.each(e[0].attributes,function(e,i){"data-"==i.name.substr(0,5)&&(t[i.name.replace("data-","")]=i.value)}),t},acf.helpers.version_compare=function(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),n=0,s=Math.max(i.length,a.length);s>n;n++){if(i[n]&&!a[n]&&parseInt(i[n])>0||parseInt(i[n])>parseInt(a[n]))return 1;if(a[n]&&!i[n]&&parseInt(a[n])>0||parseInt(i[n])<parseInt(a[n]))return-1}return 0},acf.helpers.uniqid=function(){var e=new Date;return e.getTime()},acf.helpers.url_to_object=function(e){var t={},a=e.split("&");for(i in a){var n=a[i].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t},acf.helpers.sortable=function(e,t){return t.children().each(function(){$(this).width($(this).width())}),t},acf.helpers.is_clone_field=function(e){return!(!e.attr("name")||-1==e.attr("name").indexOf("[acfcloneindex]"))},acf.helpers.add_message=function(e,t){var e=$('<div class="acf-message-wrapper"><div class="message updated"><p>'+e+"</p></div></div>");t.prepend(e),setTimeout(function(){e.animate({opacity:0},250,function(){e.remove()})},1500)},$.fn.exists=function(){return $(this).length>0},acf.media={div:null,frame:null,render_timout:null,clear_frame:function(){this.frame&&(this.frame.detach(),this.frame.dispose(),this.frame=null)},type:function(){var e="thickbox";return"undefined"!=typeof wp&&(e="backbone"),e},init:function(){if("backbone"!==this.type())return!1;if(!acf.helpers.isset(wp,"media","view","AttachmentCompat","prototype"))return!1;var e=wp.media.view.AttachmentCompat.prototype;e.orig_render=e.render,e.orig_dispose=e.dispose,e.className="compat-item acf_postbox no_box",e.render=function(){var e=this;return e.ignore_render?this:(this.orig_render(),setTimeout(function(){var t=e.$el.closest(".media-modal");if(!t.hasClass("acf-media-modal")&&!t.find(".media-frame-router .acf-expand-details").exists()){var i=$(['<a href="#" class="acf-expand-details">','<span class="icon"></span>','<span class="is-closed">'+acf.l10n.core.expand_details+"</span>",'<span class="is-open">'+acf.l10n.core.collapse_details+"</span>","</a>"].join(""));i.on("click",function(e){e.preventDefault(),t.hasClass("acf-expanded")?t.removeClass("acf-expanded"):t.addClass("acf-expanded")}),t.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){$(document).trigger("acf/setup_fields",[e.$el])},50),this)},e.dispose=function(){$(document).trigger("acf/remove_fields",[this.$el]),this.orig_dispose()},e.save=function(e){var t={},i={};e&&e.preventDefault(),_.each(this.$el.serializeArray(),function(e){"[]"===e.name.slice(-2)&&(e.name=e.name.replace("[]",""),"undefined"==typeof i[e.name]&&(i[e.name]=-1),i[e.name]++,e.name+="["+i[e.name]+"]"),t[e.name]=e.value}),this.ignore_render=!0,this.model.saveCompat(t)}}},acf.conditional_logic={items:[],init:function(){var e=this;$(document).on("change",".field input, .field textarea, .field select",function(){$("#acf-has-changed").exists()&&$("#acf-has-changed").val(1),e.change($(this))}),$(document).on("acf/setup_fields",function(t,i){e.refresh($(i))}),e.refresh()},change:function(e){var t=this,i=e.closest(".field"),a=i.attr("data-field_key");$.each(this.items,function(e,i){$.each(i.rules,function(e,n){n.field==a&&t.refresh_field(i)})})},refresh_field:function(e){var t=this,i=$(".field_key-"+e.field);i.each(function(){var i=!0;"any"==e.allorany&&(i=!1);var a=$(this),n=!0;$.each(e.rules,function(s,o){var l=$(".field_key-"+o.field);l.hasClass("sub_field")&&(l=a.siblings(".field_key-"+o.field),n=!1,l.exists()||(a.parents("tr").each(function(){return l=$(this).find(".field_key-"+o.field),l.exists()?!1:void 0}),n=!0));var r=a.parent("tr").parent().parent("table").parent(".layout");r.exists()&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest(".layout").find("td.field_key-"+o.field)));var r=a.parent("tr").parent().parent("table").parent(".repeater");r.exists()&&"1"==r.attr("data-max_rows")&&(n=!0,a.is("th")&&l.is("th")&&(l=a.closest("table").find("td.field_key-"+o.field)));var c=t.calculate(o,l,a);if("all"==e.allorany){if(0==c)return i=!1,!1}else if(1==c)return i=!0,!1}),a.removeClass("acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank"),i?(a.find("input, textarea, select").removeAttr("disabled"),a.addClass("acf-conditional_logic-show"),$(document).trigger("acf/conditional_logic/show",[a,e])):(a.find("input, textarea, select").attr("disabled","disabled"),a.addClass("acf-conditional_logic-hide"),n||a.addClass("acf-show-blank"),$(document).trigger("acf/conditional_logic/hide",[a,e]))})},refresh:function(e){e=e||$("body");var t=this;$.each(this.items,function(i,a){$.each(a.rules,function(i,n){e.find('.field[data-field_key="'+a.field+'"]').exists()&&t.refresh_field(a)})})},calculate:function(e,t,i){var a=!1;if(t.hasClass("field_type-true_false")||t.hasClass("field_type-checkbox")||t.hasClass("field_type-radio")){var n=t.find('input[value="'+e.value+'"]:checked').exists();"=="==e.operator?n&&(a=!0):n||(a=!0)}else{var s=t.find("input, textarea, select").last().val();$.isArray(s)||(s=[s]),"=="==e.operator?$.inArray(e.value,s)>-1&&(a=!0):$.inArray(e.value,s)<0&&(a=!0)}return a}},$(document).ready(function(){acf.conditional_logic.init(),$(".acf_postbox > .inside > .options").each(function(){$(this).closest(".acf_postbox").addClass($(this).attr("data-layout"))}),$('#metakeyselect option[value^="field_"]').remove()}),$(window).on("load",function(){acf.media.init(),setTimeout(function(){try{$.isNumeric(acf.o.post_id)&&(wp.media.view.settings.post.id=acf.o.post_id)}catch(e){}$(document).trigger("acf/setup_fields",[$("#poststuff")])},10)}),acf.fields.gallery={add:function(){},edit:function(){},update_count:function(){},hide_selected_items:function(){},text:{title_add:"Select Images"}}}(jQuery),function($){function e(){var e=[];$(".categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected").each(function(){$(this).is(":hidden")||$(this).is(":disabled")||$(this).closest(".media-frame").exists()||$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-load_save")||-1===e.indexOf($(this).val())&&e.push($(this).val())}),acf.screen.post_category=e,acf.screen.taxonomy=e,$(document).trigger("acf/update_field_groups")}acf.screen={action:"acf/location/match_field_groups_ajax",post_id:0,page_template:0,page_parent:0,page_type:0,post_category:0,post_format:0,taxonomy:0,lang:0,nonce:0},$(document).ready(function(){if(acf.screen.post_id=acf.o.post_id,acf.screen.nonce=acf.o.nonce,$("#icl-als-first").length>0){var e=$("#icl-als-first").children("a").attr("href"),t=new RegExp("lang=([^&#]*)"),i=t.exec(e);acf.screen.lang=i[1]}}),$(document).on("acf/update_field_groups",function(){return acf.screen.post_id&&$.isNumeric(acf.screen.post_id)?void $.ajax({url:ajaxurl,data:acf.screen,type:"post",dataType:"json",success:function(e){return e?($(".acf_postbox").addClass("acf-hidden"),$(".acf_postbox-toggle").addClass("acf-hidden"),0==e.length?!1:($.each(e,function(e,t){var i=$("#acf_"+t),a=$('#adv-settings .acf_postbox-toggle[for="acf_'+t+'-hide"]');i.removeClass("acf-hidden hide-if-js"),a.removeClass("acf-hidden"),a.find('input[type="checkbox"]').attr("checked","checked"),i.find(".acf-replace-with-fields").each(function(){var e=$(this);$.ajax({url:ajaxurl,data:{action:"acf/post/render_fields",acf_id:t,post_id:acf.o.post_id,nonce:acf.o.nonce},type:"post",dataType:"html",success:function(t){e.replaceWith(t),$(document).trigger("acf/setup_fields",i)}})})}),void $.ajax({url:ajaxurl,data:{action:"acf/post/get_style",acf_id:e[0],nonce:acf.o.nonce},type:"post",dataType:"html",success:function(e){$("#acf_style").html(e)}}))):!1}}):!1}),$(document).on("change","#page_template",function(){acf.screen.page_template=$(this).val(),$(document).trigger("acf/update_field_groups")}),$(document).on("change","#parent_id",function(){var e=$(this).val();""!=e?(acf.screen.page_type="child",acf.screen.page_parent=e):(acf.screen.page_type="parent",acf.screen.page_parent=0),$(document).trigger("acf/update_field_groups")}),$(document).on("change",'#post-formats-select input[type="radio"]',function(){var e=$(this).val();"0"==e&&(e="standard"),acf.screen.post_format=e,$(document).trigger("acf/update_field_groups")}),$(document).on("change",".categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select",function(){$(this).closest(".acf-taxonomy-field").exists()&&"0"==$(this).closest(".acf-taxonomy-field").attr("data-save")||$(this).closest(".media-frame").exists()||setTimeout(function(){e()},1)})}(jQuery),function($){var e=acf.fields.color_picker={$el:null,$input:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this},init:function(){var e=this.$input;acf.helpers.is_clone_field(e)||this.$input.wpColorPicker()}};$(document).on("acf/setup_fields",function(t,i){$(i).find(".acf-color_picker").each(function(){e.set({$el:$(this)}).init()})})}(jQuery),function($){acf.fields.date_picker={$el:null,$input:null,$hidden:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this},init:function(){if(!acf.helpers.is_clone_field(this.$hidden)){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:this.o.save_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").length>0&&$("#ui-datepicker-div").wrap('<div class="ui-acf" />')}},blur:function(){this.$input.val()||this.$hidden.val("")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-date_picker").each(function(){acf.fields.date_picker.set({$el:$(this)}).init()})}),$(document).on("blur",'.acf-date_picker input[type="text"]',function(e){acf.fields.date_picker.set({$el:$(this).parent()}).blur()})}(jQuery),function($){var e=acf.media;acf.fields.file={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=!!this.$el.closest(".repeater").exists(),this.o.query={},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-file-icon").attr("src",t.icon),i.find(".acf-file-title").text(t.title),i.find(".acf-file-name").text(t.name).attr("href",t.url),i.find(".acf-file-size").text(t.size),i.find(".acf-file-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.file.edit,multiple:!1,button:{text:acf.l10n.file.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-file-icon").attr("src",""),this.$el.find(".acf-file-title").text(""),this.$el.find(".acf-file-name").text("").attr("href",""),this.$el.find(".acf-file-size").text(""),this.$el.find(".acf-file-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.file.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?void("uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.file.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id}))):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var t=0;selection.each(function(i){if(t++,t>1){var a=e.div.closest("td"),n=a.closest(".row"),s=n.closest(".repeater"),o=a.attr("data-field_key"),l="td .acf-file-uploader:first";o&&(l='td[data-field_key="'+o+'"] .acf-file-uploader'),n.next(".row").exists()||s.find(".add-row-end").trigger("click"),e.div=n.next(".row").find(l)}var r={id:i.id,title:i.attributes.title,name:i.attributes.filename,url:i.attributes.url,icon:i.attributes.icon,size:i.attributes.filesize};acf.fields.file.add(r)})}}),acf.media.frame.open(),!1}},$(document).on("click",".acf-file-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).edit()}),$(document).on("click",".acf-file-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).remove()}),$(document).on("click",".acf-file-uploader .add-file",function(e){e.preventDefault(),acf.fields.file.set({$el:$(this).closest(".acf-file-uploader")}).popup()})}(jQuery),function($){acf.fields.google_map={$el:null,$input:null,o:{},api:{sensor:!1,libraries:"places"},ready:!1,geocoder:!1,map:!1,maps:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find(".input-address"),this.o=acf.helpers.get_atts(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id]),this},init:function(){this.geocoder||(this.geocoder=new google.maps.Geocoder),this.ready=!0,acf.helpers.is_clone_field(this.$input)||this.render()},render:function(){var e=this,t=this.$el,i={zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP};this.map=new google.maps.Map(this.$el.find(".canvas")[0],i);var a=new google.maps.places.Autocomplete(this.$el.find(".search")[0]);a.map=this.map,a.bindTo("bounds",this.map),this.map.marker=new google.maps.Marker({draggable:!0,raiseOnDrag:!0,map:this.map}),this.map.$el=this.$el;var n=this.$el.find(".input-lat").val(),s=this.$el.find(".input-lng").val();n&&s&&this.update(n,s).center(),google.maps.event.addListener(a,"place_changed",function(t){var i=this.map.$el,a=i.find(".search").val();i.find(".input-address").val(a),i.find(".title h4").text(a);var n=this.getPlace();if(n.geometry){var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()}else e.geocoder.geocode({address:a},function(t,a){if(a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!t[0])return void console.log("No results found");n=t[0];var s=n.geometry.location.lat(),o=n.geometry.location.lng();e.set({$el:i}).update(s,o).center()})}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.$el,i=this.map.marker.getPosition(),a=i.lat(),n=i.lng();e.set({$el:t}).update(a,n).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=this.$el,a=t.latLng.lat(),n=t.latLng.lng();e.set({$el:i}).update(a,n).sync()}),this.maps[this.o.id]=this.map},update:function(e,t){var i=new google.maps.LatLng(e,t);return this.$el.find(".input-lat").val(e),this.$el.find(".input-lng").val(t).trigger("change"),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("active"),this.$el.closest(".field").removeClass("error"),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this.$el,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.geocoder.geocode({latLng:i},function(t,i){if(i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.find(".title h4").text(a.formatted_address),e.find(".input-address").val(a.formatted_address).trigger("change")}),this},locate:function(){var e=this,t=this.$el;return navigator.geolocation?(t.find(".title h4").text(acf.l10n.google_map.locating+"..."),t.addClass("active"),void navigator.geolocation.getCurrentPosition(function(i){var a=i.coords.latitude,n=i.coords.longitude;e.set({$el:t}).update(a,n).sync().center()})):(alert(acf.l10n.google_map.browser_support),this)},clear:function(){this.$el.removeClass("active"),this.$el.find(".search").val(""),this.$el.find(".input-address").val(""),this.$el.find(".input-lat").val(""),this.$el.find(".input-lng").val(""),this.map.marker.setVisible(!1)},edit:function(){this.$el.removeClass("active");var e=this.$el.find(".title h4").text();this.$el.find(".search").val(e).focus()},refresh:function(){google.maps.event.trigger(this.map,"resize"),this.center()}},$(document).on("acf/setup_fields",function(e,t){var i=acf.fields.google_map,a=$(t).find(".acf-google-map");return a.exists()?acf.helpers.isset(window,"google","load")?acf.helpers.isset(window,"google","maps","places")?(a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()}),!0):(google.load("maps","3",{other_params:$.param(i.api),callback:function(){a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}}),!1):($.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:$.param(i.api),callback:function(){a.each(function(){acf.fields.google_map.set({$el:$(this)}).init()})}})}),!1):!1}),$(document).on("click",".acf-google-map .acf-sprite-remove",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).clear(),$(this).blur()}),$(document).on("click",".acf-google-map .acf-sprite-locate",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).locate(),$(this).blur()}),$(document).on("click",".acf-google-map .title h4",function(e){e.preventDefault(),acf.fields.google_map.set({$el:$(this).closest(".acf-google-map")}).edit()}),$(document).on("keydown",".acf-google-map .search",function(e){return 13==e.which?!1:void 0}),$(document).on("blur",".acf-google-map .search",function(e){var t=$(this).closest(".acf-google-map");t.find(".input-lat").val()&&t.addClass("active")}),$(document).on("acf/fields/tab/show acf/conditional_logic/show",function(e,t){acf.fields.google_map.ready&&"google_map"==t.attr("data-field_type")&&acf.fields.google_map.set({$el:t.find(".acf-google-map")}).refresh()})}(jQuery),function($){var e=acf.media;acf.fields.image={$el:null,$input:null,o:{},set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="hidden"]'),this.o=acf.helpers.get_atts(this.$el),this.o.multiple=!!this.$el.closest(".repeater").exists(),this.o.query={type:"image"},"uploadedTo"==this.o.library&&(this.o.query.uploadedTo=acf.o.post_id),this},init:function(){acf.helpers.is_clone_field(this.$input)},add:function(t){var i=e.div;i.find(".acf-image-image").attr("src",t.url),i.find(".acf-image-value").val(t.id).trigger("change"),i.addClass("active"),i.closest(".field").removeClass("error")},edit:function(){var t=this.$input.val();e.div=this.$el,e.clear_frame(),e.frame=wp.media({title:acf.l10n.image.edit,multiple:!1,button:{text:acf.l10n.image.update}}),e.frame.on("open",function(){"browse"!=e.frame.content._mode&&e.frame.content.mode("browse"),e.frame.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var i=e.frame.state().get("selection"),a=wp.media.attachment(t);$.isEmptyObject(a.changed)&&a.fetch(),i.add(a)}),e.frame.on("close",function(){e.frame.$el.closest(".media-modal").removeClass("acf-media-modal")}),acf.media.frame.open()},remove:function(){this.$el.find(".acf-image-image").attr("src",""),this.$el.find(".acf-image-value").val("").trigger("change"),this.$el.removeClass("active")},popup:function(){var t=this;return e.div=this.$el,e.clear_frame(),e.frame=wp.media({states:[new wp.media.controller.Library({library:wp.media.query(t.o.query),multiple:t.o.multiple,title:acf.l10n.image.select,priority:20,filterable:"all"})]}),acf.media.frame.on("content:activate",function(){var e=null,i=null;try{e=acf.media.frame.content.get().toolbar,i=e.get("filters")}catch(a){}return i?($.each(i.filters,function(e,t){t.props.type="image"}),"uploadedTo"==t.o.library&&(i.$el.find('option[value="uploaded"]').remove(),i.$el.after("<span>"+acf.l10n.image.uploadedTo+"</span>"),$.each(i.filters,function(e,t){t.props.uploadedTo=acf.o.post_id})),i.$el.find("option").each(function(){var e=$(this).attr("value");"uploaded"==e&&"all"==t.o.library||-1===e.indexOf("image")&&$(this).remove()}),void i.$el.val("image").trigger("change")):!1}),acf.media.frame.on("select",function(){if(selection=e.frame.state().get("selection"),selection){var i=0;selection.each(function(a){if(i++,i>1){var n=e.div.closest("td"),s=n.closest(".row"),o=s.closest(".repeater"),l=n.attr("data-field_key"),r="td .acf-image-uploader:first";l&&(r='td[data-field_key="'+l+'"] .acf-image-uploader'),s.next(".row").exists()||o.find(".add-row-end").trigger("click"),e.div=s.next(".row").find(r)}var c={id:a.id,url:a.attributes.url};a.attributes.sizes&&a.attributes.sizes[t.o.preview_size]&&(c.url=a.attributes.sizes[t.o.preview_size].url),acf.fields.image.add(c)})}}),acf.media.frame.open(),!1},text:{title_add:"Select Image",title_edit:"Edit Image"}},$(document).on("click",".acf-image-uploader .acf-button-edit",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).edit()}),$(document).on("click",".acf-image-uploader .acf-button-delete",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).remove()}),$(document).on("click",".acf-image-uploader .add-image",function(e){e.preventDefault(),acf.fields.image.set({$el:$(this).closest(".acf-image-uploader")}).popup()})}(jQuery),function($){acf.fields.radio={$el:null,$input:null,$other:null,farbtastic:null,set:function(e){return $.extend(this,e),this.$input=this.$el.find('input[type="radio"]:checked'),this.$other=this.$el.find('input[type="text"]'),this},change:function(){"other"==this.$input.val()?(this.$other.attr("name",this.$input.attr("name")),this.$other.show()):(this.$other.attr("name",""),this.$other.hide())}},$(document).on("change",'.acf-radio-list input[type="radio"]',function(e){acf.fields.radio.set({$el:$(this).closest(".acf-radio-list")}).change()})}(jQuery),function($){acf.fields.relationship={$el:null,$input:null,$left:null,$right:null,o:{},timeout:null,set:function(e){return $.extend(this,e),this.$input=this.$el.children('input[type="hidden"]'),this.$left=this.$el.find(".relationship_left"),this.$right=this.$el.find(".relationship_right"),this.o=acf.helpers.get_atts(this.$el),this},init:function(){var e=this;if(!acf.helpers.is_clone_field(this.$input)){this.$right.find(".relationship_list").height(this.$left.height()-2),this.$right.find(".relationship_list").sortable({axis:"y",items:"> li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){e.$input.trigger("change")}});var t=this.$el;this.$left.find(".relationship_list").scrollTop(0).on("scroll",function(i){if(!t.hasClass("loading")&&!t.hasClass("no-results")&&$(this).scrollTop()+$(this).innerHeight()>=$(this).get(0).scrollHeight){var a=parseInt(t.attr("data-paged"));t.attr("data-paged",a+1),e.set({$el:t}).fetch()}}),this.fetch()}},fetch:function(){var e=this,t=this.$el;t.addClass("loading"),$.ajax({url:acf.o.ajaxurl,type:"post",dataType:"json",data:$.extend({action:"acf/fields/relationship/query_posts",post_id:acf.o.post_id,nonce:acf.o.nonce},this.o),success:function(i){e.set({$el:t}).render(i)}})},render:function(e){var t=this;return this.$el.removeClass("no-results").removeClass("loading"),1==this.o.paged&&this.$el.find(".relationship_left li:not(.load-more)").remove(),e&&e.html?(this.$el.find(".relationship_left .load-more").before(e.html),e.next_page_exists||this.$el.addClass("no-results"),void this.$left.find("a").each(function(){var e=$(this).attr("data-post_id");t.$right.find('a[data-post_id="'+e+'"]').exists()&&$(this).parent().addClass("hide")})):void this.$el.addClass("no-results")},add:function(e){var t=e.attr("data-post_id"),i=e.html();if(this.$right.find("a").length>=this.o.max)return alert(acf.l10n.relationship.max.replace("{max}",this.o.max)),!1;if(e.parent().hasClass("hide"))return!1;e.parent().addClass("hide");var a=["<li>",'<a href="#" data-post_id="'+e.attr("data-post_id")+'">',e.html()+'<span class="acf-button-remove"></span>',"</a>",'<input type="hidden" name="'+this.$input.attr("name")+'[]" value="'+e.attr("data-post_id")+'" />',"</li>"].join("");this.$right.find(".relationship_list").append(a),this.$input.trigger("change"),this.$el.closest(".field").removeClass("error")},remove:function(e){e.parent().remove(),this.$left.find('a[data-post_id="'+e.attr("data-post_id")+'"]').parent("li").removeClass("hide"),this.$input.trigger("change")}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf_relationship").each(function(){acf.fields.relationship.set({$el:$(this)}).init()})}),$(document).on("change",".acf_relationship .select-post_type",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-post_type",t),i.attr("data-paged",1),acf.fields.relationship.set({$el:i}).fetch()}),$(document).on("click",".acf_relationship .relationship_left .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).add($(this)),$(this).blur()}),$(document).on("click",".acf_relationship .relationship_right .relationship_list a",function(e){e.preventDefault(),acf.fields.relationship.set({$el:$(this).closest(".acf_relationship")}).remove($(this)),$(this).blur()}),$(document).on("keyup",".acf_relationship input.relationship_search",function(e){var t=$(this).val(),i=$(this).closest(".acf_relationship");i.attr("data-s",t),i.attr("data-paged",1),clearTimeout(acf.fields.relationship.timeout),acf.fields.relationship.timeout=setTimeout(function(){acf.fields.relationship.set({$el:i}).fetch()},500)}),$(document).on("keypress",".acf_relationship input.relationship_search",function(e){13==e.which&&e.preventDefault()})}(jQuery),function($){acf.fields.tab={add_group:function(e){var t="";t=e.is("tbody")?'<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>':'<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>',e.children(".field_type-tab:first").before(t)},add_tab:function(e){var t=e.closest(".field"),i=t.parent(),a=t.attr("data-field_key"),n=e.text();i.children(".acf-tab-wrap").exists()||this.add_group(i),i.children(".acf-tab-wrap").find(".acf-tab-group").append('<li><a class="acf-tab-button" href="#" data-key="'+a+'">'+n+"</a></li>")},toggle:function(e){var t=this,i=e.closest(".acf-tab-wrap").parent(),a=e.attr("data-key");e.parent("li").addClass("active").siblings("li").removeClass("active"),i.children(".field_type-tab").each(function(){var e=$(this);e.attr("data-field_key")==a?t.show_tab_fields($(this)):t.hide_tab_fields($(this))})},show_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-hide").addClass("acf-tab_group-show"),$(document).trigger("acf/fields/tab/show",[$(this)])})},hide_tab_fields:function(e){e.nextUntil(".field_type-tab").each(function(){$(this).removeClass("acf-tab_group-show").addClass("acf-tab_group-hide"),$(document).trigger("acf/fields/tab/hide",[$(this)])})},refresh:function(e){var t=this;e.find(".acf-tab-group").each(function(){$(this).find(".acf-tab-button:first").each(function(){t.toggle($(this))})})}},$(document).on("acf/setup_fields",function(e,t){$(t).find(".acf-tab").each(function(){acf.fields.tab.add_tab($(this))}),acf.fields.tab.refresh($(t))}),$(document).on("click",".acf-tab-button",function(e){e.preventDefault(),acf.fields.tab.toggle($(this)),$(this).trigger("blur")}),$(document).on("acf/conditional_logic/hide",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');a.is(":hidden")||(a.parent().hide(),a.parent().siblings(":visible").exists()?a.parent().siblings(":visible").first().children("a").trigger("click"):acf.fields.tab.hide_tab_fields(t))}}),$(document).on("acf/conditional_logic/show",function(e,t,i){if("tab"==t.attr("data-field_type")){var a=t.siblings(".acf-tab-wrap").find('a[data-key="'+t.attr("data-field_key")+'"]');if(!a.is(":visible"))return a.parent().show(),a.parent().hasClass("active")?void a.trigger("click"):a.parent().siblings(".active").is(":hidden")?void a.trigger("click"):void 0}})}(jQuery),function($){acf.validation={status:!0,disabled:!1,run:function(){var e=this;e.status=!0,$(".field.required, .form-field.required").each(function(){e.validate($(this))})},show_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.o.wp_version;parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},validate:function(e){var t=!1,i=null;if(e.data("validation",!0),e.is(":hidden")&&(t=!0,e.hasClass("acf-tab_group-hide"))){t=!1;var a=e.prevAll(".field_type-tab:first"),n=e.prevAll(".acf-tab-wrap:first");a.hasClass("acf-conditional_logic-hide")?t=!0:i=n.find('.acf-tab-button[data-key="'+a.attr("data-field_key")+'"]')}if(e.hasClass("acf-conditional_logic-hide")&&(t=!0),e.closest(".postbox.acf-hidden").exists()&&(t=!0),!t){if(""==e.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val()&&e.data("validation",!1),e.find(".acf_wysiwyg").exists()&&"object"==typeof tinyMCE){e.data("validation",!0);var s=e.find(".wp-editor-area").attr("id"),o=tinyMCE.get(s);o&&!o.getContent()&&e.data("validation",!1)}if(e.find("select").exists()&&(e.data("validation",!0),"null"!=e.find("select").val()&&e.find("select").val()||e.data("validation",!1)),e.find('input[type="radio"]').exists()&&(e.data("validation",!1),e.find('input[type="radio"]:checked').exists()&&e.data("validation",!0)),e.find('input[type="checkbox"]').exists()&&(e.data("validation",!1),e.find('input[type="checkbox"]:checked').exists()&&e.data("validation",!0)),e.find(".acf_relationship").exists()&&(e.data("validation",!1),e.find(".acf_relationship .relationship_right input").exists()&&e.data("validation",!0)),e.find(".repeater").exists()&&(e.data("validation",!1),e.find(".repeater tr.row").exists()&&e.data("validation",!0)),e.find(".acf-gallery").exists()&&(e.data("validation",!1),e.find(".acf-gallery .thumbnail").exists()&&e.data("validation",!0)),$(document).trigger("acf/validate_field",[e]),!e.data("validation")){if(this.status=!1,e.closest(".field").addClass("error"),e.data("validation_message")){var l=e.find("p.label:first"),r=null;l.children(".acf-error-message").remove(),l.append('<span class="acf-error-message"><i class="bit"></i>'+e.data("validation_message")+"</span>")}i&&i.trigger("click")}}}},$(document).on("focus click",".field.required input, .field.required textarea, .field.required select",function(e){
|
2 |
+
$(this).closest(".field").removeClass("error")}),$(document).on("click","#save-post",function(){acf.validation.disabled=!0}),$(document).on("submit","#post",function(){if(acf.validation.disabled)return!0;if(acf.validation.run(),!acf.validation.status){var e=$(this);return e.siblings("#message").remove(),e.before('<div id="message" class="error"><p>'+acf.l10n.validation.error+"</p></div>"),$("#submitdiv").exists()&&($("#submitdiv").find(".disabled").removeClass("disabled"),$("#submitdiv").find(".button-disabled").removeClass("button-disabled"),$("#submitdiv").find(".button-primary-disabled").removeClass("button-primary-disabled"),acf.validation.hide_spinner($("#submitdiv .spinner"))),!1}return $(".acf_postbox.acf-hidden").remove(),!0})}(jQuery),function($){var e=acf.fields.wysiwyg={$el:null,$textarea:null,o:{},set:function(e){return $.extend(this,e),this.$textarea=this.$el.find("textarea"),this.o=acf.helpers.get_atts(this.$el),this.o.id=this.$textarea.attr("id"),this},has_tinymce:function(){var e=!1;return"object"==typeof tinyMCE&&(e=!0),e},get_toolbar:function(){return acf.helpers.isset(this,"toolbars",this.o.toolbar)?this.toolbars[this.o.toolbar]:!1},init:function(){if(!acf.helpers.is_clone_field(this.$textarea)){var e=this.get_toolbar(),t="mceAddControl",i="theme_advanced_buttons{i}",a=$.extend({},tinyMCE.settings);if(4==tinymce.majorVersion&&(t="mceAddEditor",i="toolbar{i}"),e)for(var n=1;5>n;n++){var s="";acf.helpers.isset(e,"theme_advanced_buttons"+n)&&(s=e["theme_advanced_buttons"+n]),tinyMCE.settings[i.replace("{i}",n)]=s}tinyMCE.execCommand(t,!1,this.o.id),$(document).trigger("acf/wysiwyg/load",this.o.id),this.add_events(),tinyMCE.settings=a,wpActiveEditor=null}},add_events:function(){var e=this.o.id,t=tinyMCE.get(e);if(t){var i=$("#wp-"+e+"-wrap"),a=$(t.getBody());i.on("click",function(){$(document).trigger("acf/wysiwyg/click",e)}),a.on("focus",function(){$(document).trigger("acf/wysiwyg/focus",e)}),a.on("blur",function(){$(document).trigger("acf/wysiwyg/blur",e)})}},destroy:function(){var e=this.o.id,t="mceRemoveControl";try{var i=tinyMCE.get(e);if(!i)return;4==tinymce.majorVersion&&(t="mceRemoveEditor");var a=i.getContent();tinyMCE.execCommand(t,!1,e),this.$textarea.val(a)}catch(n){}wpActiveEditor=null}};$(document).on("acf/setup_fields",function(t,i){e.has_tinymce()&&($(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()}),setTimeout(function(){$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})},0))}),$(document).on("acf/remove_fields",function(t,i){e.has_tinymce()&&i.find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/wysiwyg/click",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/focus",function(e,t){wpActiveEditor=t,container=$("#wp-"+t+"-wrap").closest(".field").removeClass("error")}),$(document).on("acf/wysiwyg/blur",function(e,t){wpActiveEditor=null;var i=tinyMCE.get(t);if(i){var a=i.getElement();i.save(),$(a).trigger("change")}}),$(document).on("acf/sortable_start",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).destroy()})}),$(document).on("acf/sortable_stop",function(t,i){e.has_tinymce()&&$(i).find(".acf_wysiwyg").each(function(){e.set({$el:$(this)}).init()})}),$(window).on("load",function(){if(e.has_tinymce()){var t=$("#wp-content-wrap").exists(),i=$("#wp-acf_settings-wrap").exists();mode="tmce",i&&$("#wp-acf_settings-wrap").hasClass("html-active")&&(mode="html"),setTimeout(function(){i&&"html"==mode&&$("#acf_settings-tmce").trigger("click")},1),setTimeout(function(){i&&"html"==mode&&$("#acf_settings-html").trigger("click"),t&&e.set({$el:$("#wp-content-wrap")}).add_events()},11)}}),$(document).on("click",".acf_wysiwyg a.mce_fullscreen",function(){var e=$(this).closest(".acf_wysiwyg"),t=e.attr("data-upload");"no"==t&&$("#mce_fullscreen_container td.mceToolbar .mce_add_media").remove()})}(jQuery);
|
js/input/_listener.js
DELETED
File without changes
|
js/input/_listener.min.js
DELETED
File without changes
|
js/input/acf.js
DELETED
@@ -1,942 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* input.js
|
3 |
-
*
|
4 |
-
* All javascript needed for ACF to work
|
5 |
-
*
|
6 |
-
* @type awesome
|
7 |
-
* @date 1/08/13
|
8 |
-
*
|
9 |
-
* @param N/A
|
10 |
-
* @return N/A
|
11 |
-
*/
|
12 |
-
|
13 |
-
var acf = {
|
14 |
-
|
15 |
-
// vars
|
16 |
-
ajaxurl : '',
|
17 |
-
admin_url : '',
|
18 |
-
wp_version : '',
|
19 |
-
post_id : 0,
|
20 |
-
nonce : '',
|
21 |
-
l10n : null,
|
22 |
-
o : null,
|
23 |
-
|
24 |
-
// helper functions
|
25 |
-
helpers : {
|
26 |
-
get_atts : null,
|
27 |
-
version_compare : null,
|
28 |
-
uniqid : null,
|
29 |
-
sortable : null,
|
30 |
-
add_message : null,
|
31 |
-
is_clone_field : null,
|
32 |
-
url_to_object : null
|
33 |
-
},
|
34 |
-
|
35 |
-
|
36 |
-
// modules
|
37 |
-
validation : null,
|
38 |
-
conditional_logic : null,
|
39 |
-
media : null,
|
40 |
-
|
41 |
-
|
42 |
-
// fields
|
43 |
-
fields : {
|
44 |
-
date_picker : null,
|
45 |
-
color_picker : null,
|
46 |
-
Image : null,
|
47 |
-
file : null,
|
48 |
-
wysiwyg : null,
|
49 |
-
gallery : null,
|
50 |
-
relationship : null
|
51 |
-
}
|
52 |
-
};
|
53 |
-
|
54 |
-
(function($){
|
55 |
-
|
56 |
-
|
57 |
-
/*
|
58 |
-
* acf.helpers.isset
|
59 |
-
*
|
60 |
-
* description
|
61 |
-
*
|
62 |
-
* @type function
|
63 |
-
* @date 20/07/13
|
64 |
-
*
|
65 |
-
* @param {mixed} arguments
|
66 |
-
* @return {boolean}
|
67 |
-
*/
|
68 |
-
|
69 |
-
acf.helpers.isset = function(){
|
70 |
-
|
71 |
-
var a = arguments,
|
72 |
-
l = a.length,
|
73 |
-
c = null,
|
74 |
-
undef;
|
75 |
-
|
76 |
-
if (l === 0) {
|
77 |
-
throw new Error('Empty isset');
|
78 |
-
}
|
79 |
-
|
80 |
-
c = a[0];
|
81 |
-
|
82 |
-
for (i = 1; i < l; i++) {
|
83 |
-
|
84 |
-
if (a[i] === undef || c[ a[i] ] === undef) {
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
|
88 |
-
c = c[ a[i] ];
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
return true;
|
93 |
-
|
94 |
-
};
|
95 |
-
|
96 |
-
|
97 |
-
/*
|
98 |
-
* acf.helpers.get_atts
|
99 |
-
*
|
100 |
-
* description
|
101 |
-
*
|
102 |
-
* @type function
|
103 |
-
* @date 1/06/13
|
104 |
-
*
|
105 |
-
* @param {el} $el
|
106 |
-
* @return {object} atts
|
107 |
-
*/
|
108 |
-
|
109 |
-
acf.helpers.get_atts = function( $el ){
|
110 |
-
|
111 |
-
var atts = {};
|
112 |
-
|
113 |
-
$.each( $el[0].attributes, function( index, attr ) {
|
114 |
-
|
115 |
-
if( attr.name.substr(0, 5) == 'data-' )
|
116 |
-
{
|
117 |
-
atts[ attr.name.replace('data-', '') ] = attr.value;
|
118 |
-
}
|
119 |
-
});
|
120 |
-
|
121 |
-
return atts;
|
122 |
-
|
123 |
-
};
|
124 |
-
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Simply compares two string version values.
|
128 |
-
*
|
129 |
-
* Example:
|
130 |
-
* versionCompare('1.1', '1.2') => -1
|
131 |
-
* versionCompare('1.1', '1.1') => 0
|
132 |
-
* versionCompare('1.2', '1.1') => 1
|
133 |
-
* versionCompare('2.23.3', '2.22.3') => 1
|
134 |
-
*
|
135 |
-
* Returns:
|
136 |
-
* -1 = left is LOWER than right
|
137 |
-
* 0 = they are equal
|
138 |
-
* 1 = left is GREATER = right is LOWER
|
139 |
-
* And FALSE if one of input versions are not valid
|
140 |
-
*
|
141 |
-
* @function
|
142 |
-
* @param {String} left Version #1
|
143 |
-
* @param {String} right Version #2
|
144 |
-
* @return {Integer|Boolean}
|
145 |
-
* @author Alexey Bass (albass)
|
146 |
-
* @since 2011-07-14
|
147 |
-
*/
|
148 |
-
|
149 |
-
acf.helpers.version_compare = function(left, right)
|
150 |
-
{
|
151 |
-
if (typeof left + typeof right != 'stringstring')
|
152 |
-
return false;
|
153 |
-
|
154 |
-
var a = left.split('.')
|
155 |
-
, b = right.split('.')
|
156 |
-
, i = 0, len = Math.max(a.length, b.length);
|
157 |
-
|
158 |
-
for (; i < len; i++) {
|
159 |
-
if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
|
160 |
-
return 1;
|
161 |
-
} else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
|
162 |
-
return -1;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
|
166 |
-
return 0;
|
167 |
-
};
|
168 |
-
|
169 |
-
|
170 |
-
/*
|
171 |
-
* Helper: uniqid
|
172 |
-
*
|
173 |
-
* @description:
|
174 |
-
* @since: 3.5.8
|
175 |
-
* @created: 17/01/13
|
176 |
-
*/
|
177 |
-
|
178 |
-
acf.helpers.uniqid = function()
|
179 |
-
{
|
180 |
-
var newDate = new Date;
|
181 |
-
return newDate.getTime();
|
182 |
-
};
|
183 |
-
|
184 |
-
|
185 |
-
/*
|
186 |
-
* Helper: url_to_object
|
187 |
-
*
|
188 |
-
* @description:
|
189 |
-
* @since: 4.0.0
|
190 |
-
* @created: 17/01/13
|
191 |
-
*/
|
192 |
-
|
193 |
-
acf.helpers.url_to_object = function( url ){
|
194 |
-
|
195 |
-
// vars
|
196 |
-
var obj = {},
|
197 |
-
pairs = url.split('&');
|
198 |
-
|
199 |
-
|
200 |
-
for( i in pairs )
|
201 |
-
{
|
202 |
-
var split = pairs[i].split('=');
|
203 |
-
obj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
|
204 |
-
}
|
205 |
-
|
206 |
-
return obj;
|
207 |
-
|
208 |
-
};
|
209 |
-
|
210 |
-
|
211 |
-
/*
|
212 |
-
* Sortable Helper
|
213 |
-
*
|
214 |
-
* @description: keeps widths of td's inside a tr
|
215 |
-
* @since 3.5.1
|
216 |
-
* @created: 10/11/12
|
217 |
-
*/
|
218 |
-
|
219 |
-
acf.helpers.sortable = function(e, ui)
|
220 |
-
{
|
221 |
-
ui.children().each(function(){
|
222 |
-
$(this).width($(this).width());
|
223 |
-
});
|
224 |
-
return ui;
|
225 |
-
};
|
226 |
-
|
227 |
-
|
228 |
-
/*
|
229 |
-
* is_clone_field
|
230 |
-
*
|
231 |
-
* @description:
|
232 |
-
* @since: 3.5.8
|
233 |
-
* @created: 17/01/13
|
234 |
-
*/
|
235 |
-
|
236 |
-
acf.helpers.is_clone_field = function( input )
|
237 |
-
{
|
238 |
-
if( input.attr('name') && input.attr('name').indexOf('[acfcloneindex]') != -1 )
|
239 |
-
{
|
240 |
-
return true;
|
241 |
-
}
|
242 |
-
|
243 |
-
return false;
|
244 |
-
};
|
245 |
-
|
246 |
-
|
247 |
-
/*
|
248 |
-
* acf.helpers.add_message
|
249 |
-
*
|
250 |
-
* @description:
|
251 |
-
* @since: 3.2.7
|
252 |
-
* @created: 10/07/2012
|
253 |
-
*/
|
254 |
-
|
255 |
-
acf.helpers.add_message = function( message, div ){
|
256 |
-
|
257 |
-
var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
|
258 |
-
|
259 |
-
div.prepend( message );
|
260 |
-
|
261 |
-
setTimeout(function(){
|
262 |
-
|
263 |
-
message.animate({
|
264 |
-
opacity : 0
|
265 |
-
}, 250, function(){
|
266 |
-
message.remove();
|
267 |
-
});
|
268 |
-
|
269 |
-
}, 1500);
|
270 |
-
|
271 |
-
};
|
272 |
-
|
273 |
-
|
274 |
-
/*
|
275 |
-
* Exists
|
276 |
-
*
|
277 |
-
* @description: returns true / false
|
278 |
-
* @created: 1/03/2011
|
279 |
-
*/
|
280 |
-
|
281 |
-
$.fn.exists = function()
|
282 |
-
{
|
283 |
-
return $(this).length>0;
|
284 |
-
};
|
285 |
-
|
286 |
-
|
287 |
-
/*
|
288 |
-
* 3.5 Media
|
289 |
-
*
|
290 |
-
* @description:
|
291 |
-
* @since: 3.5.7
|
292 |
-
* @created: 16/01/13
|
293 |
-
*/
|
294 |
-
|
295 |
-
acf.media = {
|
296 |
-
|
297 |
-
div : null,
|
298 |
-
frame : null,
|
299 |
-
render_timout : null,
|
300 |
-
|
301 |
-
clear_frame : function(){
|
302 |
-
|
303 |
-
// validate
|
304 |
-
if( !this.frame )
|
305 |
-
{
|
306 |
-
return;
|
307 |
-
}
|
308 |
-
|
309 |
-
|
310 |
-
// detach
|
311 |
-
this.frame.detach();
|
312 |
-
this.frame.dispose();
|
313 |
-
|
314 |
-
|
315 |
-
// reset var
|
316 |
-
this.frame = null;
|
317 |
-
|
318 |
-
},
|
319 |
-
type : function(){
|
320 |
-
|
321 |
-
// default
|
322 |
-
var type = 'thickbox';
|
323 |
-
|
324 |
-
|
325 |
-
// if wp exists
|
326 |
-
if( typeof wp !== 'undefined' )
|
327 |
-
{
|
328 |
-
type = 'backbone';
|
329 |
-
}
|
330 |
-
|
331 |
-
|
332 |
-
// return
|
333 |
-
return type;
|
334 |
-
|
335 |
-
},
|
336 |
-
init : function(){
|
337 |
-
|
338 |
-
// validate
|
339 |
-
if( this.type() !== 'backbone' )
|
340 |
-
{
|
341 |
-
return false;
|
342 |
-
}
|
343 |
-
|
344 |
-
|
345 |
-
// validate prototype
|
346 |
-
if( ! acf.helpers.isset(wp, 'media', 'view', 'AttachmentCompat', 'prototype') )
|
347 |
-
{
|
348 |
-
return false;
|
349 |
-
}
|
350 |
-
|
351 |
-
|
352 |
-
// vars
|
353 |
-
var _prototype = wp.media.view.AttachmentCompat.prototype;
|
354 |
-
|
355 |
-
|
356 |
-
// orig
|
357 |
-
_prototype.orig_render = _prototype.render;
|
358 |
-
_prototype.orig_dispose = _prototype.dispose;
|
359 |
-
|
360 |
-
|
361 |
-
// update class
|
362 |
-
_prototype.className = 'compat-item acf_postbox no_box';
|
363 |
-
|
364 |
-
|
365 |
-
// modify render
|
366 |
-
_prototype.render = function() {
|
367 |
-
|
368 |
-
// reference
|
369 |
-
var _this = this;
|
370 |
-
|
371 |
-
|
372 |
-
// validate
|
373 |
-
if( _this.ignore_render )
|
374 |
-
{
|
375 |
-
return this;
|
376 |
-
}
|
377 |
-
|
378 |
-
|
379 |
-
// run the old render function
|
380 |
-
this.orig_render();
|
381 |
-
|
382 |
-
|
383 |
-
// add button
|
384 |
-
setTimeout(function(){
|
385 |
-
|
386 |
-
// vars
|
387 |
-
var $media_model = _this.$el.closest('.media-modal');
|
388 |
-
|
389 |
-
|
390 |
-
// is this an edit only modal?
|
391 |
-
if( $media_model.hasClass('acf-media-modal') )
|
392 |
-
{
|
393 |
-
return;
|
394 |
-
}
|
395 |
-
|
396 |
-
|
397 |
-
// does button already exist?
|
398 |
-
if( $media_model.find('.media-frame-router .acf-expand-details').exists() )
|
399 |
-
{
|
400 |
-
return;
|
401 |
-
}
|
402 |
-
|
403 |
-
|
404 |
-
// create button
|
405 |
-
var button = $([
|
406 |
-
'<a href="#" class="acf-expand-details">',
|
407 |
-
'<span class="icon"></span>',
|
408 |
-
'<span class="is-closed">' + acf.l10n.core.expand_details + '</span>',
|
409 |
-
'<span class="is-open">' + acf.l10n.core.collapse_details + '</span>',
|
410 |
-
'</a>'
|
411 |
-
].join(''));
|
412 |
-
|
413 |
-
|
414 |
-
// add events
|
415 |
-
button.on('click', function( e ){
|
416 |
-
|
417 |
-
e.preventDefault();
|
418 |
-
|
419 |
-
if( $media_model.hasClass('acf-expanded') )
|
420 |
-
{
|
421 |
-
$media_model.removeClass('acf-expanded');
|
422 |
-
}
|
423 |
-
else
|
424 |
-
{
|
425 |
-
$media_model.addClass('acf-expanded');
|
426 |
-
}
|
427 |
-
|
428 |
-
});
|
429 |
-
|
430 |
-
|
431 |
-
// append
|
432 |
-
$media_model.find('.media-frame-router').append( button );
|
433 |
-
|
434 |
-
|
435 |
-
}, 0);
|
436 |
-
|
437 |
-
|
438 |
-
// setup fields
|
439 |
-
// The clearTimout is needed to prevent many setup functions from running at the same time
|
440 |
-
clearTimeout( acf.media.render_timout );
|
441 |
-
acf.media.render_timout = setTimeout(function(){
|
442 |
-
|
443 |
-
$(document).trigger( 'acf/setup_fields', [ _this.$el ] );
|
444 |
-
|
445 |
-
}, 50);
|
446 |
-
|
447 |
-
|
448 |
-
// return based on the origional render function
|
449 |
-
return this;
|
450 |
-
};
|
451 |
-
|
452 |
-
|
453 |
-
// modify dispose
|
454 |
-
_prototype.dispose = function() {
|
455 |
-
|
456 |
-
// remove
|
457 |
-
$(document).trigger('acf/remove_fields', [ this.$el ]);
|
458 |
-
|
459 |
-
|
460 |
-
// run the old render function
|
461 |
-
this.orig_dispose();
|
462 |
-
|
463 |
-
};
|
464 |
-
|
465 |
-
|
466 |
-
// override save
|
467 |
-
_prototype.save = function( event ) {
|
468 |
-
|
469 |
-
var data = {},
|
470 |
-
names = {};
|
471 |
-
|
472 |
-
if ( event )
|
473 |
-
event.preventDefault();
|
474 |
-
|
475 |
-
|
476 |
-
_.each( this.$el.serializeArray(), function( pair ) {
|
477 |
-
|
478 |
-
// initiate name
|
479 |
-
if( pair.name.slice(-2) === '[]' )
|
480 |
-
{
|
481 |
-
// remove []
|
482 |
-
pair.name = pair.name.replace('[]', '');
|
483 |
-
|
484 |
-
|
485 |
-
// initiate counter
|
486 |
-
if( typeof names[ pair.name ] === 'undefined'){
|
487 |
-
|
488 |
-
names[ pair.name ] = -1;
|
489 |
-
//console.log( names[ pair.name ] );
|
490 |
-
|
491 |
-
}
|
492 |
-
|
493 |
-
|
494 |
-
names[ pair.name ]++
|
495 |
-
|
496 |
-
pair.name += '[' + names[ pair.name ] +']';
|
497 |
-
|
498 |
-
|
499 |
-
}
|
500 |
-
|
501 |
-
data[ pair.name ] = pair.value;
|
502 |
-
});
|
503 |
-
|
504 |
-
this.ignore_render = true;
|
505 |
-
this.model.saveCompat( data );
|
506 |
-
|
507 |
-
};
|
508 |
-
}
|
509 |
-
};
|
510 |
-
|
511 |
-
|
512 |
-
/*
|
513 |
-
* Conditional Logic Calculate
|
514 |
-
*
|
515 |
-
* @description:
|
516 |
-
* @since 3.5.1
|
517 |
-
* @created: 15/10/12
|
518 |
-
*/
|
519 |
-
|
520 |
-
acf.conditional_logic = {
|
521 |
-
|
522 |
-
items : [],
|
523 |
-
|
524 |
-
init : function(){
|
525 |
-
|
526 |
-
// reference
|
527 |
-
var _this = this;
|
528 |
-
|
529 |
-
|
530 |
-
// events
|
531 |
-
$(document).on('change', '.field input, .field textarea, .field select', function(){
|
532 |
-
|
533 |
-
// preview hack
|
534 |
-
if( $('#acf-has-changed').exists() )
|
535 |
-
{
|
536 |
-
$('#acf-has-changed').val(1);
|
537 |
-
}
|
538 |
-
|
539 |
-
_this.change( $(this) );
|
540 |
-
|
541 |
-
});
|
542 |
-
|
543 |
-
|
544 |
-
$(document).on('acf/setup_fields', function(e, el){
|
545 |
-
|
546 |
-
//console.log('acf/setup_fields calling acf.conditional_logic.refresh()');
|
547 |
-
_this.refresh( $(el) );
|
548 |
-
|
549 |
-
});
|
550 |
-
|
551 |
-
//console.log('acf.conditional_logic.init() calling acf.conditional_logic.refresh()');
|
552 |
-
_this.refresh();
|
553 |
-
|
554 |
-
},
|
555 |
-
change : function( $el ){
|
556 |
-
|
557 |
-
//console.log('change %o', $el);
|
558 |
-
// reference
|
559 |
-
var _this = this;
|
560 |
-
|
561 |
-
|
562 |
-
// vars
|
563 |
-
var $field = $el.closest('.field'),
|
564 |
-
key = $field.attr('data-field_key');
|
565 |
-
|
566 |
-
|
567 |
-
// loop through items and find rules where this field key is a trigger
|
568 |
-
$.each(this.items, function( k, item ){
|
569 |
-
|
570 |
-
$.each(item.rules, function( k2, rule ){
|
571 |
-
|
572 |
-
// compare rule against the changed $field
|
573 |
-
if( rule.field == key )
|
574 |
-
{
|
575 |
-
_this.refresh_field( item );
|
576 |
-
}
|
577 |
-
|
578 |
-
});
|
579 |
-
|
580 |
-
});
|
581 |
-
|
582 |
-
},
|
583 |
-
|
584 |
-
refresh_field : function( item ){
|
585 |
-
|
586 |
-
//console.log( 'refresh_field: %o ', item );
|
587 |
-
// reference
|
588 |
-
var _this = this;
|
589 |
-
|
590 |
-
|
591 |
-
// vars
|
592 |
-
var $targets = $('.field_key-' + item.field);
|
593 |
-
|
594 |
-
|
595 |
-
// may be multiple targets (sub fields)
|
596 |
-
$targets.each(function(){
|
597 |
-
|
598 |
-
//console.log('target %o', $(this));
|
599 |
-
|
600 |
-
// vars
|
601 |
-
var show = true;
|
602 |
-
|
603 |
-
|
604 |
-
// if 'any' was selected, start of as false and any match will result in show = true
|
605 |
-
if( item.allorany == 'any' )
|
606 |
-
{
|
607 |
-
show = false;
|
608 |
-
}
|
609 |
-
|
610 |
-
|
611 |
-
// vars
|
612 |
-
var $target = $(this),
|
613 |
-
hide_all = true;
|
614 |
-
|
615 |
-
|
616 |
-
// loop through rules
|
617 |
-
$.each(item.rules, function( k2, rule ){
|
618 |
-
|
619 |
-
// vars
|
620 |
-
var $toggle = $('.field_key-' + rule.field);
|
621 |
-
|
622 |
-
|
623 |
-
// are any of $toggle a sub field?
|
624 |
-
if( $toggle.hasClass('sub_field') )
|
625 |
-
{
|
626 |
-
// toggle may be a sibling sub field.
|
627 |
-
// if so ,show an empty td but keep the column
|
628 |
-
$toggle = $target.siblings('.field_key-' + rule.field);
|
629 |
-
hide_all = false;
|
630 |
-
|
631 |
-
|
632 |
-
// if no toggle was found, we need to look at parent sub fields.
|
633 |
-
// if so, hide the entire column
|
634 |
-
if( ! $toggle.exists() )
|
635 |
-
{
|
636 |
-
// loop through all the parents that could contain sub fields
|
637 |
-
$target.parents('tr').each(function(){
|
638 |
-
|
639 |
-
// attempt to update $toggle to this parent sub field
|
640 |
-
$toggle = $(this).find('.field_key-' + rule.field)
|
641 |
-
|
642 |
-
// if the parent sub field actuallly exists, great! Stop the loop
|
643 |
-
if( $toggle.exists() )
|
644 |
-
{
|
645 |
-
return false;
|
646 |
-
}
|
647 |
-
|
648 |
-
});
|
649 |
-
|
650 |
-
hide_all = true;
|
651 |
-
}
|
652 |
-
|
653 |
-
}
|
654 |
-
|
655 |
-
|
656 |
-
// if this sub field is within a flexible content layout, hide the entire column because
|
657 |
-
// there will never be another row added to this table
|
658 |
-
var parent = $target.parent('tr').parent().parent('table').parent('.layout');
|
659 |
-
if( parent.exists() )
|
660 |
-
{
|
661 |
-
hide_all = true;
|
662 |
-
|
663 |
-
if( $target.is('th') && $toggle.is('th') )
|
664 |
-
{
|
665 |
-
$toggle = $target.closest('.layout').find('td.field_key-' + rule.field);
|
666 |
-
}
|
667 |
-
|
668 |
-
}
|
669 |
-
|
670 |
-
// if this sub field is within a repeater field which has a max row of 1, hide the entire column because
|
671 |
-
// there will never be another row added to this table
|
672 |
-
var parent = $target.parent('tr').parent().parent('table').parent('.repeater');
|
673 |
-
if( parent.exists() && parent.attr('data-max_rows') == '1' )
|
674 |
-
{
|
675 |
-
hide_all = true;
|
676 |
-
|
677 |
-
if( $target.is('th') && $toggle.is('th') )
|
678 |
-
{
|
679 |
-
$toggle = $target.closest('table').find('td.field_key-' + rule.field);
|
680 |
-
}
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
|
685 |
-
var calculate = _this.calculate( rule, $toggle, $target );
|
686 |
-
|
687 |
-
if( item.allorany == 'all' )
|
688 |
-
{
|
689 |
-
if( calculate == false )
|
690 |
-
{
|
691 |
-
show = false;
|
692 |
-
|
693 |
-
// end loop
|
694 |
-
return false;
|
695 |
-
}
|
696 |
-
}
|
697 |
-
else
|
698 |
-
{
|
699 |
-
if( calculate == true )
|
700 |
-
{
|
701 |
-
show = true;
|
702 |
-
|
703 |
-
// end loop
|
704 |
-
return false;
|
705 |
-
}
|
706 |
-
}
|
707 |
-
|
708 |
-
});
|
709 |
-
// $.each(item.rules, function( k2, rule ){
|
710 |
-
|
711 |
-
|
712 |
-
// clear classes
|
713 |
-
$target.removeClass('acf-conditional_logic-hide acf-conditional_logic-show acf-show-blank');
|
714 |
-
|
715 |
-
|
716 |
-
// hide / show field
|
717 |
-
if( show )
|
718 |
-
{
|
719 |
-
// remove "disabled"
|
720 |
-
$target.find('input, textarea, select').removeAttr('disabled');
|
721 |
-
|
722 |
-
$target.addClass('acf-conditional_logic-show');
|
723 |
-
|
724 |
-
// hook
|
725 |
-
$(document).trigger('acf/conditional_logic/show', [ $target, item ]);
|
726 |
-
|
727 |
-
}
|
728 |
-
else
|
729 |
-
{
|
730 |
-
// add "disabled"
|
731 |
-
$target.find('input, textarea, select').attr('disabled', 'disabled');
|
732 |
-
|
733 |
-
$target.addClass('acf-conditional_logic-hide');
|
734 |
-
|
735 |
-
if( !hide_all )
|
736 |
-
{
|
737 |
-
$target.addClass('acf-show-blank');
|
738 |
-
}
|
739 |
-
|
740 |
-
// hook
|
741 |
-
$(document).trigger('acf/conditional_logic/hide', [ $target, item ]);
|
742 |
-
}
|
743 |
-
|
744 |
-
|
745 |
-
});
|
746 |
-
|
747 |
-
},
|
748 |
-
|
749 |
-
refresh : function( $el ){
|
750 |
-
|
751 |
-
// defaults
|
752 |
-
$el = $el || $('body');
|
753 |
-
|
754 |
-
|
755 |
-
// reference
|
756 |
-
var _this = this;
|
757 |
-
|
758 |
-
|
759 |
-
// loop through items and find rules where this field key is a trigger
|
760 |
-
$.each(this.items, function( k, item ){
|
761 |
-
|
762 |
-
$.each(item.rules, function( k2, rule ){
|
763 |
-
|
764 |
-
// is this field within the $el
|
765 |
-
// this will increase performance by ignoring conditional logic outside of this newly appended element ($el)
|
766 |
-
if( ! $el.find('.field[data-field_key="' + item.field + '"]').exists() )
|
767 |
-
{
|
768 |
-
return;
|
769 |
-
}
|
770 |
-
|
771 |
-
_this.refresh_field( item );
|
772 |
-
|
773 |
-
});
|
774 |
-
|
775 |
-
});
|
776 |
-
|
777 |
-
},
|
778 |
-
|
779 |
-
calculate : function( rule, $toggle, $target ){
|
780 |
-
|
781 |
-
// vars
|
782 |
-
var r = false;
|
783 |
-
|
784 |
-
|
785 |
-
// compare values
|
786 |
-
if( $toggle.hasClass('field_type-true_false') || $toggle.hasClass('field_type-checkbox') || $toggle.hasClass('field_type-radio') )
|
787 |
-
{
|
788 |
-
var exists = $toggle.find('input[value="' + rule.value + '"]:checked').exists();
|
789 |
-
|
790 |
-
|
791 |
-
if( rule.operator == "==" )
|
792 |
-
{
|
793 |
-
if( exists )
|
794 |
-
{
|
795 |
-
r = true;
|
796 |
-
}
|
797 |
-
}
|
798 |
-
else
|
799 |
-
{
|
800 |
-
if( ! exists )
|
801 |
-
{
|
802 |
-
r = true;
|
803 |
-
}
|
804 |
-
}
|
805 |
-
|
806 |
-
}
|
807 |
-
else
|
808 |
-
{
|
809 |
-
// get val and make sure it is an array
|
810 |
-
var val = $toggle.find('input, textarea, select').last().val();
|
811 |
-
|
812 |
-
if( ! $.isArray(val) )
|
813 |
-
{
|
814 |
-
val = [ val ];
|
815 |
-
}
|
816 |
-
|
817 |
-
|
818 |
-
if( rule.operator == "==" )
|
819 |
-
{
|
820 |
-
if( $.inArray(rule.value, val) > -1 )
|
821 |
-
{
|
822 |
-
r = true;
|
823 |
-
}
|
824 |
-
}
|
825 |
-
else
|
826 |
-
{
|
827 |
-
if( $.inArray(rule.value, val) < 0 )
|
828 |
-
{
|
829 |
-
r = true;
|
830 |
-
}
|
831 |
-
}
|
832 |
-
|
833 |
-
}
|
834 |
-
|
835 |
-
|
836 |
-
// return
|
837 |
-
return r;
|
838 |
-
|
839 |
-
}
|
840 |
-
|
841 |
-
};
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
/*
|
848 |
-
* Document Ready
|
849 |
-
*
|
850 |
-
* @description:
|
851 |
-
* @since: 3.5.8
|
852 |
-
* @created: 17/01/13
|
853 |
-
*/
|
854 |
-
|
855 |
-
$(document).ready(function(){
|
856 |
-
|
857 |
-
|
858 |
-
// conditional logic
|
859 |
-
acf.conditional_logic.init();
|
860 |
-
|
861 |
-
|
862 |
-
// fix for older options page add-on
|
863 |
-
$('.acf_postbox > .inside > .options').each(function(){
|
864 |
-
|
865 |
-
$(this).closest('.acf_postbox').addClass( $(this).attr('data-layout') );
|
866 |
-
|
867 |
-
});
|
868 |
-
|
869 |
-
|
870 |
-
// Remove 'field_123' from native custom field metabox
|
871 |
-
$('#metakeyselect option[value^="field_"]').remove();
|
872 |
-
|
873 |
-
|
874 |
-
});
|
875 |
-
|
876 |
-
|
877 |
-
/*
|
878 |
-
* window load
|
879 |
-
*
|
880 |
-
* @description:
|
881 |
-
* @since: 3.5.5
|
882 |
-
* @created: 22/12/12
|
883 |
-
*/
|
884 |
-
|
885 |
-
$(window).load(function(){
|
886 |
-
|
887 |
-
// init
|
888 |
-
acf.media.init();
|
889 |
-
|
890 |
-
|
891 |
-
setTimeout(function(){
|
892 |
-
|
893 |
-
// Hack for CPT without a content editor
|
894 |
-
try
|
895 |
-
{
|
896 |
-
// post_id may be string (user_1) and therefore, the uploaded image cannot be attached to the post
|
897 |
-
if( $.isNumeric(acf.o.post_id) )
|
898 |
-
{
|
899 |
-
wp.media.view.settings.post.id = acf.o.post_id;
|
900 |
-
}
|
901 |
-
|
902 |
-
}
|
903 |
-
catch(e)
|
904 |
-
{
|
905 |
-
// one of the objects was 'undefined'...
|
906 |
-
}
|
907 |
-
|
908 |
-
|
909 |
-
// setup fields
|
910 |
-
$(document).trigger('acf/setup_fields', [ $('#poststuff') ]);
|
911 |
-
|
912 |
-
}, 10);
|
913 |
-
|
914 |
-
});
|
915 |
-
|
916 |
-
|
917 |
-
/*
|
918 |
-
* Gallery field Add-on Fix
|
919 |
-
*
|
920 |
-
* Gallery field v1.0.0 required some data in the acf object.
|
921 |
-
* Now not required, but older versions of gallery field need this.
|
922 |
-
*
|
923 |
-
* @type object
|
924 |
-
* @date 1/08/13
|
925 |
-
*
|
926 |
-
* @param N/A
|
927 |
-
* @return N/A
|
928 |
-
*/
|
929 |
-
|
930 |
-
acf.fields.gallery = {
|
931 |
-
add : function(){},
|
932 |
-
edit : function(){},
|
933 |
-
update_count : function(){},
|
934 |
-
hide_selected_items : function(){},
|
935 |
-
text : {
|
936 |
-
title_add : "Select Images"
|
937 |
-
}
|
938 |
-
};
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 1/03/2011
|
11 |
-
*
|
12 |
-
* @param N/A
|
13 |
-
* @return N/A
|
14 |
-
*/
|
15 |
-
|
16 |
-
acf.screen = {
|
17 |
-
action : 'acf/location/match_field_groups_ajax',
|
18 |
-
post_id : 0,
|
19 |
-
page_template : 0,
|
20 |
-
page_parent : 0,
|
21 |
-
page_type : 0,
|
22 |
-
post_category : 0,
|
23 |
-
post_format : 0,
|
24 |
-
taxonomy : 0,
|
25 |
-
lang : 0,
|
26 |
-
nonce : 0
|
27 |
-
};
|
28 |
-
|
29 |
-
|
30 |
-
/*
|
31 |
-
* Document Ready
|
32 |
-
*
|
33 |
-
* Updates acf.screen with more data
|
34 |
-
*
|
35 |
-
* @type function
|
36 |
-
* @date 1/03/2011
|
37 |
-
*
|
38 |
-
* @param N/A
|
39 |
-
* @return N/A
|
40 |
-
*/
|
41 |
-
|
42 |
-
$(document).ready(function(){
|
43 |
-
|
44 |
-
|
45 |
-
// update post_id
|
46 |
-
acf.screen.post_id = acf.o.post_id;
|
47 |
-
acf.screen.nonce = acf.o.nonce;
|
48 |
-
|
49 |
-
|
50 |
-
// MPML
|
51 |
-
if( $('#icl-als-first').length > 0 )
|
52 |
-
{
|
53 |
-
var href = $('#icl-als-first').children('a').attr('href'),
|
54 |
-
regex = new RegExp( "lang=([^&#]*)" ),
|
55 |
-
results = regex.exec( href );
|
56 |
-
|
57 |
-
// lang
|
58 |
-
acf.screen.lang = results[1];
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
});
|
63 |
-
|
64 |
-
|
65 |
-
/*
|
66 |
-
* acf/update_field_groups
|
67 |
-
*
|
68 |
-
* finds the new id's for metaboxes and show's hides metaboxes
|
69 |
-
*
|
70 |
-
* @type event
|
71 |
-
* @date 1/03/2011
|
72 |
-
*
|
73 |
-
* @param N/A
|
74 |
-
* @return N/A
|
75 |
-
*/
|
76 |
-
|
77 |
-
$(document).on('acf/update_field_groups', function(){
|
78 |
-
|
79 |
-
// Only for a post.
|
80 |
-
// This is an attempt to stop the action running on the options page add-on.
|
81 |
-
if( ! acf.screen.post_id || ! $.isNumeric(acf.screen.post_id) )
|
82 |
-
{
|
83 |
-
return false;
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
$.ajax({
|
88 |
-
url: ajaxurl,
|
89 |
-
data: acf.screen,
|
90 |
-
type: 'post',
|
91 |
-
dataType: 'json',
|
92 |
-
success: function(result){
|
93 |
-
|
94 |
-
// validate
|
95 |
-
if( !result )
|
96 |
-
{
|
97 |
-
return false;
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
// hide all metaboxes
|
102 |
-
$('.acf_postbox').addClass('acf-hidden');
|
103 |
-
$('.acf_postbox-toggle').addClass('acf-hidden');
|
104 |
-
|
105 |
-
|
106 |
-
// dont bother loading style or html for inputs
|
107 |
-
if( result.length == 0 )
|
108 |
-
{
|
109 |
-
return false;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
// show the new postboxes
|
114 |
-
$.each(result, function(k, v) {
|
115 |
-
|
116 |
-
|
117 |
-
// vars
|
118 |
-
var $el = $('#acf_' + v),
|
119 |
-
$toggle = $('#adv-settings .acf_postbox-toggle[for="acf_' + v + '-hide"]');
|
120 |
-
|
121 |
-
|
122 |
-
// classes
|
123 |
-
$el.removeClass('acf-hidden hide-if-js');
|
124 |
-
$toggle.removeClass('acf-hidden');
|
125 |
-
$toggle.find('input[type="checkbox"]').attr('checked', 'checked');
|
126 |
-
|
127 |
-
|
128 |
-
// load fields if needed
|
129 |
-
$el.find('.acf-replace-with-fields').each(function(){
|
130 |
-
|
131 |
-
var $replace = $(this);
|
132 |
-
|
133 |
-
$.ajax({
|
134 |
-
url : ajaxurl,
|
135 |
-
data : {
|
136 |
-
action : 'acf/post/render_fields',
|
137 |
-
acf_id : v,
|
138 |
-
post_id : acf.o.post_id,
|
139 |
-
nonce : acf.o.nonce
|
140 |
-
},
|
141 |
-
type : 'post',
|
142 |
-
dataType : 'html',
|
143 |
-
success : function( html ){
|
144 |
-
|
145 |
-
$replace.replaceWith( html );
|
146 |
-
|
147 |
-
$(document).trigger('acf/setup_fields', $el);
|
148 |
-
|
149 |
-
}
|
150 |
-
});
|
151 |
-
|
152 |
-
});
|
153 |
-
});
|
154 |
-
|
155 |
-
|
156 |
-
// load style
|
157 |
-
$.ajax({
|
158 |
-
url : ajaxurl,
|
159 |
-
data : {
|
160 |
-
action : 'acf/post/get_style',
|
161 |
-
acf_id : result[0],
|
162 |
-
nonce : acf.o.nonce
|
163 |
-
},
|
164 |
-
type : 'post',
|
165 |
-
dataType : 'html',
|
166 |
-
success : function( result ){
|
167 |
-
|
168 |
-
$('#acf_style').html( result );
|
169 |
-
|
170 |
-
}
|
171 |
-
});
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
}
|
176 |
-
});
|
177 |
-
});
|
178 |
-
|
179 |
-
|
180 |
-
/*
|
181 |
-
* Events
|
182 |
-
*
|
183 |
-
* Updates acf.screen with more data and triggers the update event
|
184 |
-
*
|
185 |
-
* @type function
|
186 |
-
* @date 1/03/2011
|
187 |
-
*
|
188 |
-
* @param N/A
|
189 |
-
* @return N/A
|
190 |
-
*/
|
191 |
-
|
192 |
-
$(document).on('change', '#page_template', function(){
|
193 |
-
|
194 |
-
acf.screen.page_template = $(this).val();
|
195 |
-
|
196 |
-
$(document).trigger('acf/update_field_groups');
|
197 |
-
|
198 |
-
});
|
199 |
-
|
200 |
-
|
201 |
-
$(document).on('change', '#parent_id', function(){
|
202 |
-
|
203 |
-
var val = $(this).val();
|
204 |
-
|
205 |
-
|
206 |
-
// set page_type / page_parent
|
207 |
-
if( val != "" )
|
208 |
-
{
|
209 |
-
acf.screen.page_type = 'child';
|
210 |
-
acf.screen.page_parent = val;
|
211 |
-
}
|
212 |
-
else
|
213 |
-
{
|
214 |
-
acf.screen.page_type = 'parent';
|
215 |
-
acf.screen.page_parent = 0;
|
216 |
-
}
|
217 |
-
|
218 |
-
|
219 |
-
$(document).trigger('acf/update_field_groups');
|
220 |
-
|
221 |
-
});
|
222 |
-
|
223 |
-
|
224 |
-
$(document).on('change', '#post-formats-select input[type="radio"]', function(){
|
225 |
-
|
226 |
-
var val = $(this).val();
|
227 |
-
|
228 |
-
if( val == '0' )
|
229 |
-
{
|
230 |
-
val = 'standard';
|
231 |
-
}
|
232 |
-
|
233 |
-
acf.screen.post_format = val;
|
234 |
-
|
235 |
-
$(document).trigger('acf/update_field_groups');
|
236 |
-
|
237 |
-
});
|
238 |
-
|
239 |
-
|
240 |
-
function _sync_taxonomy_terms() {
|
241 |
-
|
242 |
-
// vars
|
243 |
-
var values = [];
|
244 |
-
|
245 |
-
|
246 |
-
$('.categorychecklist input:checked, .acf-taxonomy-field input:checked, .acf-taxonomy-field option:selected').each(function(){
|
247 |
-
|
248 |
-
// validate
|
249 |
-
if( $(this).is(':hidden') || $(this).is(':disabled') )
|
250 |
-
{
|
251 |
-
return;
|
252 |
-
}
|
253 |
-
|
254 |
-
|
255 |
-
// validate media popup
|
256 |
-
if( $(this).closest('.media-frame').exists() )
|
257 |
-
{
|
258 |
-
return;
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
// validate acf
|
263 |
-
if( $(this).closest('.acf-taxonomy-field').exists() )
|
264 |
-
{
|
265 |
-
if( $(this).closest('.acf-taxonomy-field').attr('data-load_save') == '0' )
|
266 |
-
{
|
267 |
-
return;
|
268 |
-
}
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
// append
|
273 |
-
if( values.indexOf( $(this).val() ) === -1 )
|
274 |
-
{
|
275 |
-
values.push( $(this).val() );
|
276 |
-
}
|
277 |
-
|
278 |
-
});
|
279 |
-
|
280 |
-
|
281 |
-
// update screen
|
282 |
-
acf.screen.post_category = values;
|
283 |
-
acf.screen.taxonomy = values;
|
284 |
-
|
285 |
-
|
286 |
-
// trigger change
|
287 |
-
$(document).trigger('acf/update_field_groups');
|
288 |
-
|
289 |
-
}
|
290 |
-
|
291 |
-
|
292 |
-
$(document).on('change', '.categorychecklist input, .acf-taxonomy-field input, .acf-taxonomy-field select', function(){
|
293 |
-
|
294 |
-
// a taxonomy field may trigger this change event, however, the value selected is not
|
295 |
-
// actually a term relatinoship, it is meta data
|
296 |
-
if( $(this).closest('.acf-taxonomy-field').exists() )
|
297 |
-
{
|
298 |
-
if( $(this).closest('.acf-taxonomy-field').attr('data-save') == '0' )
|
299 |
-
{
|
300 |
-
return;
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
// this may be triggered from editing an imgae in a popup. Popup does not support correct metaboxes so ignore this
|
306 |
-
if( $(this).closest('.media-frame').exists() )
|
307 |
-
{
|
308 |
-
return;
|
309 |
-
}
|
310 |
-
|
311 |
-
|
312 |
-
// set timeout to fix issue with chrome which does not register the change has yet happened
|
313 |
-
setTimeout(function(){
|
314 |
-
|
315 |
-
_sync_taxonomy_terms();
|
316 |
-
|
317 |
-
}, 1);
|
318 |
-
|
319 |
-
|
320 |
-
});
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
-
|
15 |
-
var _cp = acf.fields.color_picker = {
|
16 |
-
|
17 |
-
$el : null,
|
18 |
-
$input : null,
|
19 |
-
|
20 |
-
set : function( o ){
|
21 |
-
|
22 |
-
// merge in new option
|
23 |
-
$.extend( this, o );
|
24 |
-
|
25 |
-
|
26 |
-
// find input
|
27 |
-
this.$input = this.$el.find('input[type="text"]');
|
28 |
-
|
29 |
-
|
30 |
-
// return this for chaining
|
31 |
-
return this;
|
32 |
-
|
33 |
-
},
|
34 |
-
init : function(){
|
35 |
-
|
36 |
-
// vars (reference)
|
37 |
-
var $input = this.$input;
|
38 |
-
|
39 |
-
|
40 |
-
// is clone field?
|
41 |
-
if( acf.helpers.is_clone_field($input) )
|
42 |
-
{
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
this.$input.wpColorPicker();
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
}
|
52 |
-
};
|
53 |
-
|
54 |
-
|
55 |
-
/*
|
56 |
-
* acf/setup_fields
|
57 |
-
*
|
58 |
-
* run init function on all elements for this field
|
59 |
-
*
|
60 |
-
* @type event
|
61 |
-
* @date 20/07/13
|
62 |
-
*
|
63 |
-
* @param {object} e event object
|
64 |
-
* @param {object} el DOM object which may contain new ACF elements
|
65 |
-
* @return N/A
|
66 |
-
*/
|
67 |
-
|
68 |
-
$(document).on('acf/setup_fields', function(e, el){
|
69 |
-
|
70 |
-
$(el).find('.acf-color_picker').each(function(){
|
71 |
-
|
72 |
-
_cp.set({ $el : $(this) }).init();
|
73 |
-
|
74 |
-
});
|
75 |
-
|
76 |
-
});
|
77 |
-
|
78 |
-
|
79 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/date-picker.js
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Date Picker
|
5 |
-
*
|
6 |
-
* static model for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
acf.fields.date_picker = {
|
14 |
-
|
15 |
-
$el : null,
|
16 |
-
$input : null,
|
17 |
-
$hidden : null,
|
18 |
-
|
19 |
-
o : {},
|
20 |
-
|
21 |
-
set : function( o ){
|
22 |
-
|
23 |
-
// merge in new option
|
24 |
-
$.extend( this, o );
|
25 |
-
|
26 |
-
|
27 |
-
// find input
|
28 |
-
this.$input = this.$el.find('input[type="text"]');
|
29 |
-
this.$hidden = this.$el.find('input[type="hidden"]');
|
30 |
-
|
31 |
-
|
32 |
-
// get options
|
33 |
-
this.o = acf.helpers.get_atts( this.$el );
|
34 |
-
|
35 |
-
|
36 |
-
// return this for chaining
|
37 |
-
return this;
|
38 |
-
|
39 |
-
},
|
40 |
-
init : function(){
|
41 |
-
|
42 |
-
// is clone field?
|
43 |
-
if( acf.helpers.is_clone_field(this.$hidden) )
|
44 |
-
{
|
45 |
-
return;
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
// get and set value from alt field
|
50 |
-
this.$input.val( this.$hidden.val() );
|
51 |
-
|
52 |
-
|
53 |
-
// create options
|
54 |
-
var options = $.extend( {}, acf.l10n.date_picker, {
|
55 |
-
dateFormat : this.o.save_format,
|
56 |
-
altField : this.$hidden,
|
57 |
-
altFormat : this.o.save_format,
|
58 |
-
changeYear : true,
|
59 |
-
yearRange : "-100:+100",
|
60 |
-
changeMonth : true,
|
61 |
-
showButtonPanel : true,
|
62 |
-
firstDay : this.o.first_day
|
63 |
-
});
|
64 |
-
|
65 |
-
|
66 |
-
// add date picker
|
67 |
-
this.$input.addClass('active').datepicker( options );
|
68 |
-
|
69 |
-
|
70 |
-
// now change the format back to how it should be.
|
71 |
-
this.$input.datepicker( "option", "dateFormat", this.o.display_format );
|
72 |
-
|
73 |
-
|
74 |
-
// wrap the datepicker (only if it hasn't already been wrapped)
|
75 |
-
if( $('body > #ui-datepicker-div').length > 0 )
|
76 |
-
{
|
77 |
-
$('#ui-datepicker-div').wrap('<div class="ui-acf" />');
|
78 |
-
}
|
79 |
-
|
80 |
-
},
|
81 |
-
blur : function(){
|
82 |
-
|
83 |
-
if( !this.$input.val() )
|
84 |
-
{
|
85 |
-
this.$hidden.val('');
|
86 |
-
}
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
};
|
91 |
-
|
92 |
-
|
93 |
-
/*
|
94 |
-
* acf/setup_fields
|
95 |
-
*
|
96 |
-
* run init function on all elements for this field
|
97 |
-
*
|
98 |
-
* @type event
|
99 |
-
* @date 20/07/13
|
100 |
-
*
|
101 |
-
* @param {object} e event object
|
102 |
-
* @param {object} el DOM object which may contain new ACF elements
|
103 |
-
* @return N/A
|
104 |
-
*/
|
105 |
-
|
106 |
-
$(document).on('acf/setup_fields', function(e, el){
|
107 |
-
|
108 |
-
$(el).find('.acf-date_picker').each(function(){
|
109 |
-
|
110 |
-
acf.fields.date_picker.set({ $el : $(this) }).init();
|
111 |
-
|
112 |
-
});
|
113 |
-
|
114 |
-
});
|
115 |
-
|
116 |
-
|
117 |
-
/*
|
118 |
-
* Events
|
119 |
-
*
|
120 |
-
* jQuery events for this field
|
121 |
-
*
|
122 |
-
* @type event
|
123 |
-
* @date 1/06/13
|
124 |
-
*
|
125 |
-
*/
|
126 |
-
|
127 |
-
$(document).on('blur', '.acf-date_picker input[type="text"]', function( e ){
|
128 |
-
|
129 |
-
acf.fields.date_picker.set({ $el : $(this).parent() }).blur();
|
130 |
-
|
131 |
-
});
|
132 |
-
|
133 |
-
|
134 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/file.js
DELETED
@@ -1,373 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* File
|
5 |
-
*
|
6 |
-
* static model for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
// reference
|
15 |
-
var _media = acf.media;
|
16 |
-
|
17 |
-
|
18 |
-
acf.fields.file = {
|
19 |
-
|
20 |
-
$el : null,
|
21 |
-
$input : null,
|
22 |
-
|
23 |
-
o : {},
|
24 |
-
|
25 |
-
set : function( o ){
|
26 |
-
|
27 |
-
// merge in new option
|
28 |
-
$.extend( this, o );
|
29 |
-
|
30 |
-
|
31 |
-
// find input
|
32 |
-
this.$input = this.$el.find('input[type="hidden"]');
|
33 |
-
|
34 |
-
|
35 |
-
// get options
|
36 |
-
this.o = acf.helpers.get_atts( this.$el );
|
37 |
-
|
38 |
-
|
39 |
-
// multiple?
|
40 |
-
this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
|
41 |
-
|
42 |
-
|
43 |
-
// wp library query
|
44 |
-
this.o.query = {};
|
45 |
-
|
46 |
-
|
47 |
-
// library
|
48 |
-
if( this.o.library == 'uploadedTo' )
|
49 |
-
{
|
50 |
-
this.o.query.uploadedTo = acf.o.post_id;
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
// return this for chaining
|
55 |
-
return this;
|
56 |
-
|
57 |
-
},
|
58 |
-
init : function(){
|
59 |
-
|
60 |
-
// is clone field?
|
61 |
-
if( acf.helpers.is_clone_field(this.$input) )
|
62 |
-
{
|
63 |
-
return;
|
64 |
-
}
|
65 |
-
|
66 |
-
},
|
67 |
-
add : function( file ){
|
68 |
-
|
69 |
-
// this function must reference a global div variable due to the pre WP 3.5 uploader
|
70 |
-
// vars
|
71 |
-
var div = _media.div;
|
72 |
-
|
73 |
-
|
74 |
-
// set atts
|
75 |
-
div.find('.acf-file-icon').attr( 'src', file.icon );
|
76 |
-
div.find('.acf-file-title').text( file.title );
|
77 |
-
div.find('.acf-file-name').text( file.name ).attr( 'href', file.url );
|
78 |
-
div.find('.acf-file-size').text( file.size );
|
79 |
-
div.find('.acf-file-value').val( file.id ).trigger('change');
|
80 |
-
|
81 |
-
|
82 |
-
// set div class
|
83 |
-
div.addClass('active');
|
84 |
-
|
85 |
-
|
86 |
-
// validation
|
87 |
-
div.closest('.field').removeClass('error');
|
88 |
-
|
89 |
-
},
|
90 |
-
edit : function(){
|
91 |
-
|
92 |
-
// vars
|
93 |
-
var id = this.$input.val();
|
94 |
-
|
95 |
-
|
96 |
-
// set global var
|
97 |
-
_media.div = this.$el;
|
98 |
-
|
99 |
-
|
100 |
-
// clear the frame
|
101 |
-
_media.clear_frame();
|
102 |
-
|
103 |
-
|
104 |
-
// create the media frame
|
105 |
-
_media.frame = wp.media({
|
106 |
-
title : acf.l10n.file.edit,
|
107 |
-
multiple : false,
|
108 |
-
button : { text : acf.l10n.file.update }
|
109 |
-
});
|
110 |
-
|
111 |
-
|
112 |
-
// log events
|
113 |
-
/*
|
114 |
-
acf.media.frame.on('all', function(e){
|
115 |
-
|
116 |
-
console.log( e );
|
117 |
-
|
118 |
-
});
|
119 |
-
*/
|
120 |
-
|
121 |
-
|
122 |
-
// open
|
123 |
-
_media.frame.on('open',function() {
|
124 |
-
|
125 |
-
// set to browse
|
126 |
-
if( _media.frame.content._mode != 'browse' )
|
127 |
-
{
|
128 |
-
_media.frame.content.mode('browse');
|
129 |
-
}
|
130 |
-
|
131 |
-
|
132 |
-
// add class
|
133 |
-
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
|
134 |
-
|
135 |
-
|
136 |
-
// set selection
|
137 |
-
var selection = _media.frame.state().get('selection'),
|
138 |
-
attachment = wp.media.attachment( id );
|
139 |
-
|
140 |
-
|
141 |
-
// to fetch or not to fetch
|
142 |
-
if( $.isEmptyObject(attachment.changed) )
|
143 |
-
{
|
144 |
-
attachment.fetch();
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
selection.add( attachment );
|
149 |
-
|
150 |
-
});
|
151 |
-
|
152 |
-
|
153 |
-
// close
|
154 |
-
_media.frame.on('close',function(){
|
155 |
-
|
156 |
-
// remove class
|
157 |
-
_media.frame.$el.closest('.media-modal').removeClass('acf-media-modal');
|
158 |
-
|
159 |
-
});
|
160 |
-
|
161 |
-
|
162 |
-
// Finally, open the modal
|
163 |
-
acf.media.frame.open();
|
164 |
-
|
165 |
-
},
|
166 |
-
remove : function()
|
167 |
-
{
|
168 |
-
|
169 |
-
// set atts
|
170 |
-
this.$el.find('.acf-file-icon').attr( 'src', '' );
|
171 |
-
this.$el.find('.acf-file-title').text( '' );
|
172 |
-
this.$el.find('.acf-file-name').text( '' ).attr( 'href', '' );
|
173 |
-
this.$el.find('.acf-file-size').text( '' );
|
174 |
-
this.$el.find('.acf-file-value').val( '' ).trigger('change');
|
175 |
-
|
176 |
-
|
177 |
-
// remove class
|
178 |
-
this.$el.removeClass('active');
|
179 |
-
|
180 |
-
},
|
181 |
-
popup : function()
|
182 |
-
{
|
183 |
-
// reference
|
184 |
-
var t = this;
|
185 |
-
|
186 |
-
|
187 |
-
// set global var
|
188 |
-
_media.div = this.$el;
|
189 |
-
|
190 |
-
|
191 |
-
// clear the frame
|
192 |
-
_media.clear_frame();
|
193 |
-
|
194 |
-
|
195 |
-
// Create the media frame
|
196 |
-
_media.frame = wp.media({
|
197 |
-
states : [
|
198 |
-
new wp.media.controller.Library({
|
199 |
-
library : wp.media.query( t.o.query ),
|
200 |
-
multiple : t.o.multiple,
|
201 |
-
title : acf.l10n.file.select,
|
202 |
-
priority : 20,
|
203 |
-
filterable : 'all'
|
204 |
-
})
|
205 |
-
]
|
206 |
-
});
|
207 |
-
|
208 |
-
|
209 |
-
// customize model / view
|
210 |
-
acf.media.frame.on('content:activate', function(){
|
211 |
-
|
212 |
-
// vars
|
213 |
-
var toolbar = null,
|
214 |
-
filters = null;
|
215 |
-
|
216 |
-
|
217 |
-
// populate above vars making sure to allow for failure
|
218 |
-
try
|
219 |
-
{
|
220 |
-
toolbar = acf.media.frame.content.get().toolbar;
|
221 |
-
filters = toolbar.get('filters');
|
222 |
-
}
|
223 |
-
catch(e)
|
224 |
-
{
|
225 |
-
// one of the objects was 'undefined'... perhaps the frame open is Upload Files
|
226 |
-
//console.log( e );
|
227 |
-
}
|
228 |
-
|
229 |
-
|
230 |
-
// validate
|
231 |
-
if( !filters )
|
232 |
-
{
|
233 |
-
return false;
|
234 |
-
}
|
235 |
-
|
236 |
-
|
237 |
-
// no need for 'uploaded' filter
|
238 |
-
if( t.o.library == 'uploadedTo' )
|
239 |
-
{
|
240 |
-
filters.$el.find('option[value="uploaded"]').remove();
|
241 |
-
filters.$el.after('<span>' + acf.l10n.file.uploadedTo + '</span>')
|
242 |
-
|
243 |
-
$.each( filters.filters, function( k, v ){
|
244 |
-
|
245 |
-
v.props.uploadedTo = acf.o.post_id;
|
246 |
-
|
247 |
-
});
|
248 |
-
}
|
249 |
-
|
250 |
-
});
|
251 |
-
|
252 |
-
|
253 |
-
// When an image is selected, run a callback.
|
254 |
-
acf.media.frame.on( 'select', function() {
|
255 |
-
|
256 |
-
// get selected images
|
257 |
-
selection = _media.frame.state().get('selection');
|
258 |
-
|
259 |
-
if( selection )
|
260 |
-
{
|
261 |
-
var i = 0;
|
262 |
-
|
263 |
-
selection.each(function(attachment){
|
264 |
-
|
265 |
-
// counter
|
266 |
-
i++;
|
267 |
-
|
268 |
-
|
269 |
-
// select / add another file field?
|
270 |
-
if( i > 1 )
|
271 |
-
{
|
272 |
-
// vars
|
273 |
-
var $td = _media.div.closest('td'),
|
274 |
-
$tr = $td.closest('.row'),
|
275 |
-
$repeater = $tr.closest('.repeater'),
|
276 |
-
key = $td.attr('data-field_key'),
|
277 |
-
selector = 'td .acf-file-uploader:first';
|
278 |
-
|
279 |
-
|
280 |
-
// key only exists for repeater v1.0.1 +
|
281 |
-
if( key )
|
282 |
-
{
|
283 |
-
selector = 'td[data-field_key="' + key + '"] .acf-file-uploader';
|
284 |
-
}
|
285 |
-
|
286 |
-
|
287 |
-
// add row?
|
288 |
-
if( ! $tr.next('.row').exists() )
|
289 |
-
{
|
290 |
-
$repeater.find('.add-row-end').trigger('click');
|
291 |
-
|
292 |
-
}
|
293 |
-
|
294 |
-
|
295 |
-
// update current div
|
296 |
-
_media.div = $tr.next('.row').find( selector );
|
297 |
-
|
298 |
-
}
|
299 |
-
|
300 |
-
|
301 |
-
// vars
|
302 |
-
var file = {
|
303 |
-
id : attachment.id,
|
304 |
-
title : attachment.attributes.title,
|
305 |
-
name : attachment.attributes.filename,
|
306 |
-
url : attachment.attributes.url,
|
307 |
-
icon : attachment.attributes.icon,
|
308 |
-
size : attachment.attributes.filesize
|
309 |
-
};
|
310 |
-
|
311 |
-
|
312 |
-
// add file to field
|
313 |
-
acf.fields.file.add( file );
|
314 |
-
|
315 |
-
|
316 |
-
});
|
317 |
-
// selection.each(function(attachment){
|
318 |
-
}
|
319 |
-
// if( selection )
|
320 |
-
|
321 |
-
});
|
322 |
-
// acf.media.frame.on( 'select', function() {
|
323 |
-
|
324 |
-
|
325 |
-
// Finally, open the modal
|
326 |
-
acf.media.frame.open();
|
327 |
-
|
328 |
-
|
329 |
-
return false;
|
330 |
-
}
|
331 |
-
|
332 |
-
};
|
333 |
-
|
334 |
-
|
335 |
-
/*
|
336 |
-
* Events
|
337 |
-
*
|
338 |
-
* jQuery events for this field
|
339 |
-
*
|
340 |
-
* @type function
|
341 |
-
* @date 1/03/2011
|
342 |
-
*
|
343 |
-
* @param N/A
|
344 |
-
* @return N/A
|
345 |
-
*/
|
346 |
-
|
347 |
-
$(document).on('click', '.acf-file-uploader .acf-button-edit', function( e ){
|
348 |
-
|
349 |
-
e.preventDefault();
|
350 |
-
|
351 |
-
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).edit();
|
352 |
-
|
353 |
-
});
|
354 |
-
|
355 |
-
$(document).on('click', '.acf-file-uploader .acf-button-delete', function( e ){
|
356 |
-
|
357 |
-
e.preventDefault();
|
358 |
-
|
359 |
-
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).remove();
|
360 |
-
|
361 |
-
});
|
362 |
-
|
363 |
-
|
364 |
-
$(document).on('click', '.acf-file-uploader .add-file', function( e ){
|
365 |
-
|
366 |
-
e.preventDefault();
|
367 |
-
|
368 |
-
acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).popup();
|
369 |
-
|
370 |
-
});
|
371 |
-
|
372 |
-
|
373 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/google-map.js
DELETED
@@ -1,558 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Location
|
5 |
-
*
|
6 |
-
* static model for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
acf.fields.google_map = {
|
14 |
-
|
15 |
-
$el : null,
|
16 |
-
$input : null,
|
17 |
-
|
18 |
-
o : {},
|
19 |
-
|
20 |
-
ready : false,
|
21 |
-
geocoder : false,
|
22 |
-
map : false,
|
23 |
-
maps : {},
|
24 |
-
|
25 |
-
set : function( o ){
|
26 |
-
|
27 |
-
// merge in new option
|
28 |
-
$.extend( this, o );
|
29 |
-
|
30 |
-
|
31 |
-
// find input
|
32 |
-
this.$input = this.$el.find('.input-address');
|
33 |
-
|
34 |
-
|
35 |
-
// get options
|
36 |
-
this.o = acf.helpers.get_atts( this.$el );
|
37 |
-
|
38 |
-
|
39 |
-
// get map
|
40 |
-
if( this.maps[ this.o.id ] )
|
41 |
-
{
|
42 |
-
this.map = this.maps[ this.o.id ];
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
// return this for chaining
|
47 |
-
return this;
|
48 |
-
|
49 |
-
},
|
50 |
-
init : function(){
|
51 |
-
|
52 |
-
// geocode
|
53 |
-
if( !this.geocoder )
|
54 |
-
{
|
55 |
-
this.geocoder = new google.maps.Geocoder();
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
// google maps is loaded and ready
|
60 |
-
this.ready = true;
|
61 |
-
|
62 |
-
|
63 |
-
// is clone field?
|
64 |
-
if( acf.helpers.is_clone_field(this.$input) )
|
65 |
-
{
|
66 |
-
return;
|
67 |
-
}
|
68 |
-
|
69 |
-
this.render();
|
70 |
-
|
71 |
-
},
|
72 |
-
render : function(){
|
73 |
-
|
74 |
-
// reference
|
75 |
-
var _this = this,
|
76 |
-
_$el = this.$el;
|
77 |
-
|
78 |
-
|
79 |
-
// vars
|
80 |
-
var args = {
|
81 |
-
zoom : parseInt(this.o.zoom),
|
82 |
-
center : new google.maps.LatLng(this.o.lat, this.o.lng),
|
83 |
-
mapTypeId : google.maps.MapTypeId.ROADMAP
|
84 |
-
};
|
85 |
-
|
86 |
-
// create map
|
87 |
-
this.map = new google.maps.Map( this.$el.find('.canvas')[0], args);
|
88 |
-
|
89 |
-
|
90 |
-
// add search
|
91 |
-
var autocomplete = new google.maps.places.Autocomplete( this.$el.find('.search')[0] );
|
92 |
-
autocomplete.map = this.map;
|
93 |
-
autocomplete.bindTo('bounds', this.map);
|
94 |
-
|
95 |
-
|
96 |
-
// add dummy marker
|
97 |
-
this.map.marker = new google.maps.Marker({
|
98 |
-
draggable : true,
|
99 |
-
raiseOnDrag : true,
|
100 |
-
map : this.map,
|
101 |
-
});
|
102 |
-
|
103 |
-
|
104 |
-
// add references
|
105 |
-
this.map.$el = this.$el;
|
106 |
-
|
107 |
-
|
108 |
-
// value exists?
|
109 |
-
var lat = this.$el.find('.input-lat').val(),
|
110 |
-
lng = this.$el.find('.input-lng').val();
|
111 |
-
|
112 |
-
if( lat && lng )
|
113 |
-
{
|
114 |
-
this.update( lat, lng ).center();
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
// events
|
119 |
-
google.maps.event.addListener(autocomplete, 'place_changed', function( e ) {
|
120 |
-
|
121 |
-
// reference
|
122 |
-
var $el = this.map.$el;
|
123 |
-
|
124 |
-
|
125 |
-
// manually update address
|
126 |
-
var address = $el.find('.search').val();
|
127 |
-
$el.find('.input-address').val( address );
|
128 |
-
$el.find('.title h4').text( address );
|
129 |
-
|
130 |
-
|
131 |
-
// vars
|
132 |
-
var place = this.getPlace();
|
133 |
-
|
134 |
-
|
135 |
-
// validate
|
136 |
-
if( place.geometry )
|
137 |
-
{
|
138 |
-
var lat = place.geometry.location.lat(),
|
139 |
-
lng = place.geometry.location.lng();
|
140 |
-
|
141 |
-
|
142 |
-
_this.set({ $el : $el }).update( lat, lng ).center();
|
143 |
-
}
|
144 |
-
else
|
145 |
-
{
|
146 |
-
// client hit enter, manulaly get the place
|
147 |
-
_this.geocoder.geocode({ 'address' : address }, function( results, status ){
|
148 |
-
|
149 |
-
// validate
|
150 |
-
if( status != google.maps.GeocoderStatus.OK )
|
151 |
-
{
|
152 |
-
console.log('Geocoder failed due to: ' + status);
|
153 |
-
return;
|
154 |
-
}
|
155 |
-
|
156 |
-
if( !results[0] )
|
157 |
-
{
|
158 |
-
console.log('No results found');
|
159 |
-
return;
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
// get place
|
164 |
-
place = results[0];
|
165 |
-
|
166 |
-
var lat = place.geometry.location.lat(),
|
167 |
-
lng = place.geometry.location.lng();
|
168 |
-
|
169 |
-
|
170 |
-
_this.set({ $el : $el }).update( lat, lng ).center();
|
171 |
-
|
172 |
-
});
|
173 |
-
}
|
174 |
-
|
175 |
-
});
|
176 |
-
|
177 |
-
|
178 |
-
google.maps.event.addListener( this.map.marker, 'dragend', function(){
|
179 |
-
|
180 |
-
// reference
|
181 |
-
var $el = this.map.$el;
|
182 |
-
|
183 |
-
|
184 |
-
// vars
|
185 |
-
var position = this.map.marker.getPosition(),
|
186 |
-
lat = position.lat(),
|
187 |
-
lng = position.lng();
|
188 |
-
|
189 |
-
_this.set({ $el : $el }).update( lat, lng ).sync();
|
190 |
-
|
191 |
-
});
|
192 |
-
|
193 |
-
|
194 |
-
google.maps.event.addListener( this.map, 'click', function( e ) {
|
195 |
-
|
196 |
-
// reference
|
197 |
-
var $el = this.$el;
|
198 |
-
|
199 |
-
|
200 |
-
// vars
|
201 |
-
var lat = e.latLng.lat(),
|
202 |
-
lng = e.latLng.lng();
|
203 |
-
|
204 |
-
|
205 |
-
_this.set({ $el : $el }).update( lat, lng ).sync();
|
206 |
-
|
207 |
-
});
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
// add to maps
|
212 |
-
this.maps[ this.o.id ] = this.map;
|
213 |
-
|
214 |
-
|
215 |
-
},
|
216 |
-
|
217 |
-
update : function( lat, lng ){
|
218 |
-
|
219 |
-
// vars
|
220 |
-
var latlng = new google.maps.LatLng( lat, lng );
|
221 |
-
|
222 |
-
|
223 |
-
// update inputs
|
224 |
-
this.$el.find('.input-lat').val( lat );
|
225 |
-
this.$el.find('.input-lng').val( lng ).trigger('change');
|
226 |
-
|
227 |
-
|
228 |
-
// update marker
|
229 |
-
this.map.marker.setPosition( latlng );
|
230 |
-
|
231 |
-
|
232 |
-
// show marker
|
233 |
-
this.map.marker.setVisible( true );
|
234 |
-
|
235 |
-
|
236 |
-
// update class
|
237 |
-
this.$el.addClass('active');
|
238 |
-
|
239 |
-
|
240 |
-
// validation
|
241 |
-
this.$el.closest('.field').removeClass('error');
|
242 |
-
|
243 |
-
|
244 |
-
// return for chaining
|
245 |
-
return this;
|
246 |
-
},
|
247 |
-
|
248 |
-
center : function(){
|
249 |
-
|
250 |
-
// vars
|
251 |
-
var position = this.map.marker.getPosition(),
|
252 |
-
lat = this.o.lat,
|
253 |
-
lng = this.o.lng;
|
254 |
-
|
255 |
-
|
256 |
-
// if marker exists, center on the marker
|
257 |
-
if( position )
|
258 |
-
{
|
259 |
-
lat = position.lat();
|
260 |
-
lng = position.lng();
|
261 |
-
}
|
262 |
-
|
263 |
-
|
264 |
-
var latlng = new google.maps.LatLng( lat, lng );
|
265 |
-
|
266 |
-
|
267 |
-
// set center of map
|
268 |
-
this.map.setCenter( latlng );
|
269 |
-
},
|
270 |
-
|
271 |
-
sync : function(){
|
272 |
-
|
273 |
-
// reference
|
274 |
-
var $el = this.$el;
|
275 |
-
|
276 |
-
|
277 |
-
// vars
|
278 |
-
var position = this.map.marker.getPosition(),
|
279 |
-
latlng = new google.maps.LatLng( position.lat(), position.lng() );
|
280 |
-
|
281 |
-
|
282 |
-
this.geocoder.geocode({ 'latLng' : latlng }, function( results, status ){
|
283 |
-
|
284 |
-
// validate
|
285 |
-
if( status != google.maps.GeocoderStatus.OK )
|
286 |
-
{
|
287 |
-
console.log('Geocoder failed due to: ' + status);
|
288 |
-
return;
|
289 |
-
}
|
290 |
-
|
291 |
-
if( !results[0] )
|
292 |
-
{
|
293 |
-
console.log('No results found');
|
294 |
-
return;
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
// get location
|
299 |
-
var location = results[0];
|
300 |
-
|
301 |
-
|
302 |
-
// update h4
|
303 |
-
$el.find('.title h4').text( location.formatted_address );
|
304 |
-
|
305 |
-
|
306 |
-
// update input
|
307 |
-
$el.find('.input-address').val( location.formatted_address ).trigger('change');
|
308 |
-
|
309 |
-
});
|
310 |
-
|
311 |
-
|
312 |
-
// return for chaining
|
313 |
-
return this;
|
314 |
-
},
|
315 |
-
|
316 |
-
locate : function(){
|
317 |
-
|
318 |
-
// reference
|
319 |
-
var _this = this,
|
320 |
-
_$el = this.$el;
|
321 |
-
|
322 |
-
|
323 |
-
// Try HTML5 geolocation
|
324 |
-
if( ! navigator.geolocation )
|
325 |
-
{
|
326 |
-
alert( acf.l10n.google_map.browser_support );
|
327 |
-
return this;
|
328 |
-
}
|
329 |
-
|
330 |
-
|
331 |
-
// show loading text
|
332 |
-
_$el.find('.title h4').text(acf.l10n.google_map.locating + '...');
|
333 |
-
_$el.addClass('active');
|
334 |
-
|
335 |
-
navigator.geolocation.getCurrentPosition(function(position){
|
336 |
-
|
337 |
-
// vars
|
338 |
-
var lat = position.coords.latitude,
|
339 |
-
lng = position.coords.longitude;
|
340 |
-
|
341 |
-
_this.set({ $el : _$el }).update( lat, lng ).sync().center();
|
342 |
-
|
343 |
-
});
|
344 |
-
|
345 |
-
|
346 |
-
},
|
347 |
-
|
348 |
-
clear : function(){
|
349 |
-
|
350 |
-
// update class
|
351 |
-
this.$el.removeClass('active');
|
352 |
-
|
353 |
-
|
354 |
-
// clear search
|
355 |
-
this.$el.find('.search').val('');
|
356 |
-
|
357 |
-
|
358 |
-
// clear inputs
|
359 |
-
this.$el.find('.input-address').val('');
|
360 |
-
this.$el.find('.input-lat').val('');
|
361 |
-
this.$el.find('.input-lng').val('');
|
362 |
-
|
363 |
-
|
364 |
-
// hide marker
|
365 |
-
this.map.marker.setVisible( false );
|
366 |
-
},
|
367 |
-
|
368 |
-
edit : function(){
|
369 |
-
|
370 |
-
// update class
|
371 |
-
this.$el.removeClass('active');
|
372 |
-
|
373 |
-
|
374 |
-
// clear search
|
375 |
-
var val = this.$el.find('.title h4').text();
|
376 |
-
|
377 |
-
|
378 |
-
this.$el.find('.search').val( val ).focus();
|
379 |
-
|
380 |
-
},
|
381 |
-
|
382 |
-
refresh : function(){
|
383 |
-
|
384 |
-
// trigger resize on div
|
385 |
-
google.maps.event.trigger(this.map, 'resize');
|
386 |
-
|
387 |
-
// center map
|
388 |
-
this.center();
|
389 |
-
|
390 |
-
}
|
391 |
-
|
392 |
-
};
|
393 |
-
|
394 |
-
|
395 |
-
/*
|
396 |
-
* acf/setup_fields
|
397 |
-
*
|
398 |
-
* run init function on all elements for this field
|
399 |
-
*
|
400 |
-
* @type event
|
401 |
-
* @date 20/07/13
|
402 |
-
*
|
403 |
-
* @param {object} e event object
|
404 |
-
* @param {object} el DOM object which may contain new ACF elements
|
405 |
-
* @return N/A
|
406 |
-
*/
|
407 |
-
|
408 |
-
$(document).on('acf/setup_fields', function(e, el){
|
409 |
-
|
410 |
-
// vars
|
411 |
-
$fields = $(el).find('.acf-google-map');
|
412 |
-
|
413 |
-
|
414 |
-
// validate
|
415 |
-
if( ! $fields.exists() ) return false;
|
416 |
-
|
417 |
-
|
418 |
-
// no google
|
419 |
-
if( !acf.helpers.isset(window, 'google', 'load') ) {
|
420 |
-
|
421 |
-
// load API
|
422 |
-
$.getScript('https://www.google.com/jsapi', function(){
|
423 |
-
|
424 |
-
// load maps
|
425 |
-
google.load('maps', '3', { other_params: 'sensor=false&libraries=places', callback: function(){
|
426 |
-
|
427 |
-
$fields.each(function(){
|
428 |
-
|
429 |
-
acf.fields.google_map.set({ $el : $(this) }).init();
|
430 |
-
|
431 |
-
});
|
432 |
-
|
433 |
-
}});
|
434 |
-
|
435 |
-
});
|
436 |
-
|
437 |
-
return false;
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
|
442 |
-
// no maps or places
|
443 |
-
if( !acf.helpers.isset(window, 'google', 'maps', 'places') ) {
|
444 |
-
|
445 |
-
google.load('maps', '3', { other_params: 'sensor=false&libraries=places', callback: function(){
|
446 |
-
|
447 |
-
$fields.each(function(){
|
448 |
-
|
449 |
-
acf.fields.google_map.set({ $el : $(this) }).init();
|
450 |
-
|
451 |
-
});
|
452 |
-
|
453 |
-
}});
|
454 |
-
|
455 |
-
return false;
|
456 |
-
|
457 |
-
}
|
458 |
-
|
459 |
-
|
460 |
-
// google exists
|
461 |
-
$fields.each(function(){
|
462 |
-
|
463 |
-
acf.fields.google_map.set({ $el : $(this) }).init();
|
464 |
-
|
465 |
-
});
|
466 |
-
|
467 |
-
|
468 |
-
// return
|
469 |
-
return true;
|
470 |
-
|
471 |
-
});
|
472 |
-
|
473 |
-
|
474 |
-
/*
|
475 |
-
* Events
|
476 |
-
*
|
477 |
-
* jQuery events for this field
|
478 |
-
*
|
479 |
-
* @type function
|
480 |
-
* @date 1/03/2011
|
481 |
-
*
|
482 |
-
* @param N/A
|
483 |
-
* @return N/A
|
484 |
-
*/
|
485 |
-
|
486 |
-
$(document).on('click', '.acf-google-map .acf-sprite-remove', function( e ){
|
487 |
-
|
488 |
-
e.preventDefault();
|
489 |
-
|
490 |
-
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).clear();
|
491 |
-
|
492 |
-
$(this).blur();
|
493 |
-
|
494 |
-
});
|
495 |
-
|
496 |
-
|
497 |
-
$(document).on('click', '.acf-google-map .acf-sprite-locate', function( e ){
|
498 |
-
|
499 |
-
e.preventDefault();
|
500 |
-
|
501 |
-
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).locate();
|
502 |
-
|
503 |
-
$(this).blur();
|
504 |
-
|
505 |
-
});
|
506 |
-
|
507 |
-
$(document).on('click', '.acf-google-map .title h4', function( e ){
|
508 |
-
|
509 |
-
e.preventDefault();
|
510 |
-
|
511 |
-
acf.fields.google_map.set({ $el : $(this).closest('.acf-google-map') }).edit();
|
512 |
-
|
513 |
-
});
|
514 |
-
|
515 |
-
$(document).on('keydown', '.acf-google-map .search', function( e ){
|
516 |
-
|
517 |
-
// prevent form from submitting
|
518 |
-
if( e.which == 13 )
|
519 |
-
{
|
520 |
-
return false;
|
521 |
-
}
|
522 |
-
|
523 |
-
});
|
524 |
-
|
525 |
-
$(document).on('blur', '.acf-google-map .search', function( e ){
|
526 |
-
|
527 |
-
// vars
|
528 |
-
var $el = $(this).closest('.acf-google-map');
|
529 |
-
|
530 |
-
|
531 |
-
// has a value?
|
532 |
-
if( $el.find('.input-lat').val() )
|
533 |
-
{
|
534 |
-
$el.addClass('active');
|
535 |
-
}
|
536 |
-
|
537 |
-
});
|
538 |
-
|
539 |
-
$(document).on('acf/fields/tab/show acf/conditional_logic/show', function( e, $field ){
|
540 |
-
|
541 |
-
// validate
|
542 |
-
if( ! acf.fields.google_map.ready )
|
543 |
-
{
|
544 |
-
return;
|
545 |
-
}
|
546 |
-
|
547 |
-
|
548 |
-
// validate
|
549 |
-
if( $field.attr('data-field_type') == 'google_map' )
|
550 |
-
{
|
551 |
-
acf.fields.google_map.set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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/image.js
DELETED
@@ -1,416 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Image
|
5 |
-
*
|
6 |
-
* static model for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
|
14 |
-
// reference
|
15 |
-
var _media = acf.media;
|
16 |
-
|
17 |
-
|
18 |
-
acf.fields.image = {
|
19 |
-
|
20 |
-
$el : null,
|
21 |
-
$input : null,
|
22 |
-
|
23 |
-
o : {},
|
24 |
-
|
25 |
-
set : function( o ){
|
26 |
-
|
27 |
-
// merge in new option
|
28 |
-
$.extend( this, o );
|
29 |
-
|
30 |
-
|
31 |
-
// find input
|
32 |
-
this.$input = this.$el.find('input[type="hidden"]');
|
33 |
-
|
34 |
-
|
35 |
-
// get options
|
36 |
-
this.o = acf.helpers.get_atts( this.$el );
|
37 |
-
|
38 |
-
|
39 |
-
// multiple?
|
40 |
-
this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
|
41 |
-
|
42 |
-
|
43 |
-
// wp library query
|
44 |
-
this.o.query = {
|
45 |
-
type : 'image'
|
46 |
-
};
|
47 |
-
|
48 |
-
|
49 |
-
// library
|
50 |
-
if( this.o.library == 'uploadedTo' )
|
51 |
-
{
|
52 |
-
this.o.query.uploadedTo = acf.o.post_id;
|
53 |
-
}
|
54 |
-
|
55 |
-
|
56 |
-
// return this for chaining
|
57 |
-
return this;
|
58 |
-
|
59 |
-
},
|
60 |
-
init : function(){
|
61 |
-
|
62 |
-
// is clone field?
|
63 |
-
if( acf.helpers.is_clone_field(this.$input) )
|
64 |
-
{
|
65 |
-
return;
|
66 |
-
}
|
67 |
-
|
68 |
-
},
|
69 |
-
add : function( image ){
|
70 |
-
|
71 |
-
// this function must reference a global div variable due to the pre WP 3.5 uploader
|
72 |
-
// vars
|
73 |
-
var div = _media.div;
|
74 |
-
|
75 |
-
|
76 |
-
// set atts
|
77 |
-
div.find('.acf-image-image').attr( 'src', image.url );
|
78 |
-
div.find('.acf-image-value').val( image.id ).trigger('change');
|
79 |
-
|
80 |
-
|
81 |
-
// set div class
|
82 |
-
div.addClass('active');
|
83 |
-
|
84 |
-
|
85 |
-
// validation
|
86 |
-
div.closest('.field').removeClass('error');
|
87 |
-
|
88 |
-
},
|
89 |
-
edit : function(){
|
90 |
-
|
91 |
-
// vars
|
92 |
-
var id = this.$input.val();
|
93 |
-
|
94 |
-
|
95 |
-
// set global var
|
96 |
-
_media.div = this.$el;
|
97 |
-
|
98 |
-
|
99 |
-
// clear the frame
|
100 |
-
_media.clear_frame();
|
101 |
-
|
102 |
-
|
103 |
-
// create the media frame
|
104 |
-
_media.frame = wp.media({
|
105 |
-
title : acf.l10n.image.edit,
|
106 |
-
multiple : false,
|
107 |
-
button : { text : acf.l10n.image.update }
|
108 |
-
});
|
109 |
-
|
110 |
-
|
111 |
-
// log events
|
112 |
-
/*
|
113 |
-
acf.media.frame.on('all', function(e){
|
114 |
-
|
115 |
-
console.log( e );
|
116 |
-
|
117 |
-
});
|
118 |
-
*/
|
119 |
-
|
120 |
-
|
121 |
-
// open
|
122 |
-
_media.frame.on('open',function() {
|
123 |
-
|
124 |
-
// set to browse
|
125 |
-
if( _media.frame.content._mode != 'browse' )
|
126 |
-
{
|
127 |
-
_media.frame.content.mode('browse');
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
// add class
|
132 |
-
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
|
133 |
-
|
134 |
-
|
135 |
-
// set selection
|
136 |
-
var selection = _media.frame.state().get('selection'),
|
137 |
-
attachment = wp.media.attachment( id );
|
138 |
-
|
139 |
-
|
140 |
-
// to fetch or not to fetch
|
141 |
-
if( $.isEmptyObject(attachment.changed) )
|
142 |
-
{
|
143 |
-
attachment.fetch();
|
144 |
-
}
|
145 |
-
|
146 |
-
|
147 |
-
selection.add( attachment );
|
148 |
-
|
149 |
-
});
|
150 |
-
|
151 |
-
|
152 |
-
// close
|
153 |
-
_media.frame.on('close',function(){
|
154 |
-
|
155 |
-
// remove class
|
156 |
-
_media.frame.$el.closest('.media-modal').removeClass('acf-media-modal');
|
157 |
-
|
158 |
-
});
|
159 |
-
|
160 |
-
|
161 |
-
// Finally, open the modal
|
162 |
-
acf.media.frame.open();
|
163 |
-
|
164 |
-
},
|
165 |
-
remove : function()
|
166 |
-
{
|
167 |
-
|
168 |
-
// set atts
|
169 |
-
this.$el.find('.acf-image-image').attr( 'src', '' );
|
170 |
-
this.$el.find('.acf-image-value').val( '' ).trigger('change');
|
171 |
-
|
172 |
-
|
173 |
-
// remove class
|
174 |
-
this.$el.removeClass('active');
|
175 |
-
|
176 |
-
},
|
177 |
-
popup : function()
|
178 |
-
{
|
179 |
-
// reference
|
180 |
-
var t = this;
|
181 |
-
|
182 |
-
|
183 |
-
// set global var
|
184 |
-
_media.div = this.$el;
|
185 |
-
|
186 |
-
|
187 |
-
// clear the frame
|
188 |
-
_media.clear_frame();
|
189 |
-
|
190 |
-
|
191 |
-
// Create the media frame
|
192 |
-
_media.frame = wp.media({
|
193 |
-
states : [
|
194 |
-
new wp.media.controller.Library({
|
195 |
-
library : wp.media.query( t.o.query ),
|
196 |
-
multiple : t.o.multiple,
|
197 |
-
title : acf.l10n.image.select,
|
198 |
-
priority : 20,
|
199 |
-
filterable : 'all'
|
200 |
-
})
|
201 |
-
]
|
202 |
-
});
|
203 |
-
|
204 |
-
|
205 |
-
/*acf.media.frame.on('all', function(e){
|
206 |
-
|
207 |
-
console.log( e );
|
208 |
-
|
209 |
-
});*/
|
210 |
-
|
211 |
-
|
212 |
-
// customize model / view
|
213 |
-
acf.media.frame.on('content:activate', function(){
|
214 |
-
|
215 |
-
// vars
|
216 |
-
var toolbar = null,
|
217 |
-
filters = null;
|
218 |
-
|
219 |
-
|
220 |
-
// populate above vars making sure to allow for failure
|
221 |
-
try
|
222 |
-
{
|
223 |
-
toolbar = acf.media.frame.content.get().toolbar;
|
224 |
-
filters = toolbar.get('filters');
|
225 |
-
}
|
226 |
-
catch(e)
|
227 |
-
{
|
228 |
-
// one of the objects was 'undefined'... perhaps the frame open is Upload Files
|
229 |
-
//console.log( e );
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
// validate
|
234 |
-
if( !filters )
|
235 |
-
{
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
// filter only images
|
241 |
-
$.each( filters.filters, function( k, v ){
|
242 |
-
|
243 |
-
v.props.type = 'image';
|
244 |
-
|
245 |
-
});
|
246 |
-
|
247 |
-
|
248 |
-
// no need for 'uploaded' filter
|
249 |
-
if( t.o.library == 'uploadedTo' )
|
250 |
-
{
|
251 |
-
filters.$el.find('option[value="uploaded"]').remove();
|
252 |
-
filters.$el.after('<span>' + acf.l10n.image.uploadedTo + '</span>')
|
253 |
-
|
254 |
-
$.each( filters.filters, function( k, v ){
|
255 |
-
|
256 |
-
v.props.uploadedTo = acf.o.post_id;
|
257 |
-
|
258 |
-
});
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
// remove non image options from filter list
|
263 |
-
filters.$el.find('option').each(function(){
|
264 |
-
|
265 |
-
// vars
|
266 |
-
var v = $(this).attr('value');
|
267 |
-
|
268 |
-
|
269 |
-
// don't remove the 'uploadedTo' if the library option is 'all'
|
270 |
-
if( v == 'uploaded' && t.o.library == 'all' )
|
271 |
-
{
|
272 |
-
return;
|
273 |
-
}
|
274 |
-
|
275 |
-
if( v.indexOf('image') === -1 )
|
276 |
-
{
|
277 |
-
$(this).remove();
|
278 |
-
}
|
279 |
-
|
280 |
-
});
|
281 |
-
|
282 |
-
|
283 |
-
// set default filter
|
284 |
-
filters.$el.val('image').trigger('change');
|
285 |
-
|
286 |
-
});
|
287 |
-
|
288 |
-
|
289 |
-
// When an image is selected, run a callback.
|
290 |
-
acf.media.frame.on( 'select', function() {
|
291 |
-
|
292 |
-
// get selected images
|
293 |
-
selection = _media.frame.state().get('selection');
|
294 |
-
|
295 |
-
if( selection )
|
296 |
-
{
|
297 |
-
var i = 0;
|
298 |
-
|
299 |
-
selection.each(function(attachment){
|
300 |
-
|
301 |
-
// counter
|
302 |
-
i++;
|
303 |
-
|
304 |
-
|
305 |
-
// select / add another image field?
|
306 |
-
if( i > 1 )
|
307 |
-
{
|
308 |
-
// vars
|
309 |
-
var $td = _media.div.closest('td'),
|
310 |
-
$tr = $td.closest('.row'),
|
311 |
-
$repeater = $tr.closest('.repeater'),
|
312 |
-
key = $td.attr('data-field_key'),
|
313 |
-
selector = 'td .acf-image-uploader:first';
|
314 |
-
|
315 |
-
|
316 |
-
// key only exists for repeater v1.0.1 +
|
317 |
-
if( key )
|
318 |
-
{
|
319 |
-
selector = 'td[data-field_key="' + key + '"] .acf-image-uploader';
|
320 |
-
}
|
321 |
-
|
322 |
-
|
323 |
-
// add row?
|
324 |
-
if( ! $tr.next('.row').exists() )
|
325 |
-
{
|
326 |
-
$repeater.find('.add-row-end').trigger('click');
|
327 |
-
|
328 |
-
}
|
329 |
-
|
330 |
-
|
331 |
-
// update current div
|
332 |
-
_media.div = $tr.next('.row').find( selector );
|
333 |
-
|
334 |
-
}
|
335 |
-
|
336 |
-
|
337 |
-
// vars
|
338 |
-
var image = {
|
339 |
-
id : attachment.id,
|
340 |
-
url : attachment.attributes.url
|
341 |
-
};
|
342 |
-
|
343 |
-
// is preview size available?
|
344 |
-
if( attachment.attributes.sizes && attachment.attributes.sizes[ t.o.preview_size ] )
|
345 |
-
{
|
346 |
-
image.url = attachment.attributes.sizes[ t.o.preview_size ].url;
|
347 |
-
}
|
348 |
-
|
349 |
-
// add image to field
|
350 |
-
acf.fields.image.add( image );
|
351 |
-
|
352 |
-
|
353 |
-
});
|
354 |
-
// selection.each(function(attachment){
|
355 |
-
}
|
356 |
-
// if( selection )
|
357 |
-
|
358 |
-
});
|
359 |
-
// acf.media.frame.on( 'select', function() {
|
360 |
-
|
361 |
-
|
362 |
-
// Finally, open the modal
|
363 |
-
acf.media.frame.open();
|
364 |
-
|
365 |
-
|
366 |
-
return false;
|
367 |
-
},
|
368 |
-
|
369 |
-
// temporary gallery fix
|
370 |
-
text : {
|
371 |
-
title_add : "Select Image",
|
372 |
-
title_edit : "Edit Image"
|
373 |
-
}
|
374 |
-
|
375 |
-
};
|
376 |
-
|
377 |
-
|
378 |
-
/*
|
379 |
-
* Events
|
380 |
-
*
|
381 |
-
* jQuery events for this field
|
382 |
-
*
|
383 |
-
* @type function
|
384 |
-
* @date 1/03/2011
|
385 |
-
*
|
386 |
-
* @param N/A
|
387 |
-
* @return N/A
|
388 |
-
*/
|
389 |
-
|
390 |
-
$(document).on('click', '.acf-image-uploader .acf-button-edit', function( e ){
|
391 |
-
|
392 |
-
e.preventDefault();
|
393 |
-
|
394 |
-
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).edit();
|
395 |
-
|
396 |
-
});
|
397 |
-
|
398 |
-
$(document).on('click', '.acf-image-uploader .acf-button-delete', function( e ){
|
399 |
-
|
400 |
-
e.preventDefault();
|
401 |
-
|
402 |
-
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).remove();
|
403 |
-
|
404 |
-
});
|
405 |
-
|
406 |
-
|
407 |
-
$(document).on('click', '.acf-image-uploader .add-image', function( e ){
|
408 |
-
|
409 |
-
e.preventDefault();
|
410 |
-
|
411 |
-
acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).popup();
|
412 |
-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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/radio.js
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Radio
|
5 |
-
*
|
6 |
-
* static model and events for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
acf.fields.radio = {
|
14 |
-
|
15 |
-
$el : null,
|
16 |
-
$input : null,
|
17 |
-
$other : null,
|
18 |
-
farbtastic : null,
|
19 |
-
|
20 |
-
set : function( o ){
|
21 |
-
|
22 |
-
// merge in new option
|
23 |
-
$.extend( this, o );
|
24 |
-
|
25 |
-
|
26 |
-
// find input
|
27 |
-
this.$input = this.$el.find('input[type="radio"]:checked');
|
28 |
-
this.$other = this.$el.find('input[type="text"]');
|
29 |
-
|
30 |
-
|
31 |
-
// return this for chaining
|
32 |
-
return this;
|
33 |
-
|
34 |
-
},
|
35 |
-
change : function(){
|
36 |
-
|
37 |
-
if( this.$input.val() == 'other' )
|
38 |
-
{
|
39 |
-
this.$other.attr('name', this.$input.attr('name'));
|
40 |
-
this.$other.show();
|
41 |
-
}
|
42 |
-
else
|
43 |
-
{
|
44 |
-
this.$other.attr('name', '');
|
45 |
-
this.$other.hide();
|
46 |
-
}
|
47 |
-
}
|
48 |
-
};
|
49 |
-
|
50 |
-
|
51 |
-
/*
|
52 |
-
* Events
|
53 |
-
*
|
54 |
-
* jQuery events for this field
|
55 |
-
*
|
56 |
-
* @type function
|
57 |
-
* @date 1/03/2011
|
58 |
-
*
|
59 |
-
* @param N/A
|
60 |
-
* @return N/A
|
61 |
-
*/
|
62 |
-
|
63 |
-
$(document).on('change', '.acf-radio-list input[type="radio"]', function( e ){
|
64 |
-
|
65 |
-
acf.fields.radio.set({ $el : $(this).closest('.acf-radio-list') }).change();
|
66 |
-
|
67 |
-
});
|
68 |
-
|
69 |
-
|
70 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/relationship.js
DELETED
@@ -1,361 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Relationship
|
5 |
-
*
|
6 |
-
* static model for this field
|
7 |
-
*
|
8 |
-
* @type event
|
9 |
-
* @date 1/06/13
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
acf.fields.relationship = {
|
14 |
-
|
15 |
-
$el : null,
|
16 |
-
$input : null,
|
17 |
-
$left : null,
|
18 |
-
$right : null,
|
19 |
-
|
20 |
-
o : {},
|
21 |
-
|
22 |
-
timeout : null,
|
23 |
-
|
24 |
-
set : function( o ){
|
25 |
-
|
26 |
-
// merge in new option
|
27 |
-
$.extend( this, o );
|
28 |
-
|
29 |
-
|
30 |
-
// find elements
|
31 |
-
this.$input = this.$el.children('input[type="hidden"]');
|
32 |
-
this.$left = this.$el.find('.relationship_left'),
|
33 |
-
this.$right = this.$el.find('.relationship_right');
|
34 |
-
|
35 |
-
|
36 |
-
// get options
|
37 |
-
this.o = acf.helpers.get_atts( this.$el );
|
38 |
-
|
39 |
-
|
40 |
-
// return this for chaining
|
41 |
-
return this;
|
42 |
-
|
43 |
-
},
|
44 |
-
init : function(){
|
45 |
-
|
46 |
-
// reference
|
47 |
-
var _this = this;
|
48 |
-
|
49 |
-
|
50 |
-
// is clone field?
|
51 |
-
if( acf.helpers.is_clone_field(this.$input) )
|
52 |
-
{
|
53 |
-
return;
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
// set height of right column
|
58 |
-
this.$right.find('.relationship_list').height( this.$left.height() -2 );
|
59 |
-
|
60 |
-
|
61 |
-
// right sortable
|
62 |
-
this.$right.find('.relationship_list').sortable({
|
63 |
-
axis : 'y',
|
64 |
-
items : '> li',
|
65 |
-
forceHelperSize : true,
|
66 |
-
forcePlaceholderSize : true,
|
67 |
-
scroll : true,
|
68 |
-
update : function(){
|
69 |
-
|
70 |
-
_this.$input.trigger('change');
|
71 |
-
|
72 |
-
}
|
73 |
-
});
|
74 |
-
|
75 |
-
|
76 |
-
// load more
|
77 |
-
var $el = this.$el;
|
78 |
-
|
79 |
-
this.$left.find('.relationship_list').scrollTop( 0 ).on('scroll', function(e){
|
80 |
-
|
81 |
-
// validate
|
82 |
-
if( $el.hasClass('loading') || $el.hasClass('no-results') )
|
83 |
-
{
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
|
87 |
-
|
88 |
-
// Scrolled to bottom
|
89 |
-
if( $(this).scrollTop() + $(this).innerHeight() >= $(this).get(0).scrollHeight )
|
90 |
-
{
|
91 |
-
var paged = parseInt( $el.attr('data-paged') );
|
92 |
-
|
93 |
-
// update paged
|
94 |
-
$el.attr('data-paged', (paged + 1) );
|
95 |
-
|
96 |
-
// fetch
|
97 |
-
_this.set({ $el : $el }).fetch();
|
98 |
-
}
|
99 |
-
|
100 |
-
});
|
101 |
-
|
102 |
-
|
103 |
-
// ajax fetch values for left side
|
104 |
-
this.fetch();
|
105 |
-
|
106 |
-
},
|
107 |
-
fetch : function(){
|
108 |
-
|
109 |
-
// reference
|
110 |
-
var _this = this,
|
111 |
-
$el = this.$el;
|
112 |
-
|
113 |
-
|
114 |
-
// add loading class, stops scroll loading
|
115 |
-
$el.addClass('loading');
|
116 |
-
|
117 |
-
|
118 |
-
// get results
|
119 |
-
$.ajax({
|
120 |
-
url : acf.o.ajaxurl,
|
121 |
-
type : 'post',
|
122 |
-
dataType : 'json',
|
123 |
-
data : $.extend({
|
124 |
-
action : 'acf/fields/relationship/query_posts',
|
125 |
-
post_id : acf.o.post_id,
|
126 |
-
nonce : acf.o.nonce
|
127 |
-
}, this.o ),
|
128 |
-
success : function( json ){
|
129 |
-
|
130 |
-
|
131 |
-
// render
|
132 |
-
_this.set({ $el : $el }).render( json );
|
133 |
-
|
134 |
-
}
|
135 |
-
});
|
136 |
-
|
137 |
-
},
|
138 |
-
render : function( json ){
|
139 |
-
|
140 |
-
// reference
|
141 |
-
var _this = this;
|
142 |
-
|
143 |
-
|
144 |
-
// update classes
|
145 |
-
this.$el.removeClass('no-results').removeClass('loading');
|
146 |
-
|
147 |
-
|
148 |
-
// new search?
|
149 |
-
if( this.o.paged == 1 )
|
150 |
-
{
|
151 |
-
this.$el.find('.relationship_left li:not(.load-more)').remove();
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
-
// no results?
|
156 |
-
if( ! json || ! json.html )
|
157 |
-
{
|
158 |
-
this.$el.addClass('no-results');
|
159 |
-
return;
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
// append new results
|
164 |
-
this.$el.find('.relationship_left .load-more').before( json.html );
|
165 |
-
|
166 |
-
|
167 |
-
// next page?
|
168 |
-
if( ! json.next_page_exists )
|
169 |
-
{
|
170 |
-
this.$el.addClass('no-results');
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
// apply .hide to left li's
|
175 |
-
this.$left.find('a').each(function(){
|
176 |
-
|
177 |
-
var id = $(this).attr('data-post_id');
|
178 |
-
|
179 |
-
if( _this.$right.find('a[data-post_id="' + id + '"]').exists() )
|
180 |
-
{
|
181 |
-
$(this).parent().addClass('hide');
|
182 |
-
}
|
183 |
-
|
184 |
-
});
|
185 |
-
|
186 |
-
},
|
187 |
-
add : function( $a ){
|
188 |
-
|
189 |
-
// vars
|
190 |
-
var id = $a.attr('data-post_id'),
|
191 |
-
title = $a.html();
|
192 |
-
|
193 |
-
|
194 |
-
// max posts
|
195 |
-
if( this.$right.find('a').length >= this.o.max )
|
196 |
-
{
|
197 |
-
alert( acf.l10n.relationship.max.replace('{max}', this.o.max) );
|
198 |
-
return false;
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
// can be added?
|
203 |
-
if( $a.parent().hasClass('hide') )
|
204 |
-
{
|
205 |
-
return false;
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
// hide
|
210 |
-
$a.parent().addClass('hide');
|
211 |
-
|
212 |
-
|
213 |
-
// template
|
214 |
-
var html = [
|
215 |
-
'<li>',
|
216 |
-
'<a href="#" data-post_id="' + $a.attr('data-post_id') + '">',
|
217 |
-
$a.html() + '<span class="acf-button-remove"></span>',
|
218 |
-
'</a>',
|
219 |
-
'<input type="hidden" name="' + this.$input.attr('name') + '[]" value="' + $a.attr('data-post_id') + '" />',
|
220 |
-
'</li>'].join('');
|
221 |
-
|
222 |
-
|
223 |
-
// add new li
|
224 |
-
this.$right.find('.relationship_list').append( html )
|
225 |
-
|
226 |
-
|
227 |
-
// trigger change on new_li
|
228 |
-
this.$input.trigger('change');
|
229 |
-
|
230 |
-
|
231 |
-
// validation
|
232 |
-
this.$el.closest('.field').removeClass('error');
|
233 |
-
|
234 |
-
|
235 |
-
},
|
236 |
-
remove : function( $a ){
|
237 |
-
|
238 |
-
// remove
|
239 |
-
$a.parent().remove();
|
240 |
-
|
241 |
-
|
242 |
-
// show
|
243 |
-
this.$left.find('a[data-post_id="' + $a.attr('data-post_id') + '"]').parent('li').removeClass('hide');
|
244 |
-
|
245 |
-
|
246 |
-
// trigger change on new_li
|
247 |
-
this.$input.trigger('change');
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
};
|
252 |
-
|
253 |
-
|
254 |
-
/*
|
255 |
-
* acf/setup_fields
|
256 |
-
*
|
257 |
-
* run init function on all elements for this field
|
258 |
-
*
|
259 |
-
* @type event
|
260 |
-
* @date 20/07/13
|
261 |
-
*
|
262 |
-
* @param {object} e event object
|
263 |
-
* @param {object} el DOM object which may contain new ACF elements
|
264 |
-
* @return N/A
|
265 |
-
*/
|
266 |
-
|
267 |
-
$(document).on('acf/setup_fields', function(e, el){
|
268 |
-
|
269 |
-
$(el).find('.acf_relationship').each(function(){
|
270 |
-
|
271 |
-
acf.fields.relationship.set({ $el : $(this) }).init();
|
272 |
-
|
273 |
-
});
|
274 |
-
|
275 |
-
});
|
276 |
-
|
277 |
-
|
278 |
-
/*
|
279 |
-
* Events
|
280 |
-
*
|
281 |
-
* jQuery events for this field
|
282 |
-
*
|
283 |
-
* @type function
|
284 |
-
* @date 1/03/2011
|
285 |
-
*
|
286 |
-
* @param N/A
|
287 |
-
* @return N/A
|
288 |
-
*/
|
289 |
-
|
290 |
-
$(document).on('change', '.acf_relationship .select-post_type', function(e){
|
291 |
-
|
292 |
-
// vars
|
293 |
-
var val = $(this).val(),
|
294 |
-
$el = $(this).closest('.acf_relationship');
|
295 |
-
|
296 |
-
|
297 |
-
// update attr
|
298 |
-
$el.attr('data-post_type', val);
|
299 |
-
$el.attr('data-paged', 1);
|
300 |
-
|
301 |
-
|
302 |
-
// fetch
|
303 |
-
acf.fields.relationship.set({ $el : $el }).fetch();
|
304 |
-
|
305 |
-
});
|
306 |
-
|
307 |
-
|
308 |
-
$(document).on('click', '.acf_relationship .relationship_left .relationship_list a', function( e ){
|
309 |
-
|
310 |
-
e.preventDefault();
|
311 |
-
|
312 |
-
acf.fields.relationship.set({ $el : $(this).closest('.acf_relationship') }).add( $(this) );
|
313 |
-
|
314 |
-
$(this).blur();
|
315 |
-
|
316 |
-
});
|
317 |
-
|
318 |
-
$(document).on('click', '.acf_relationship .relationship_right .relationship_list a', function( e ){
|
319 |
-
|
320 |
-
e.preventDefault();
|
321 |
-
|
322 |
-
acf.fields.relationship.set({ $el : $(this).closest('.acf_relationship') }).remove( $(this) );
|
323 |
-
|
324 |
-
$(this).blur();
|
325 |
-
|
326 |
-
});
|
327 |
-
|
328 |
-
$(document).on('keyup', '.acf_relationship input.relationship_search', function( e ){
|
329 |
-
|
330 |
-
// vars
|
331 |
-
var val = $(this).val(),
|
332 |
-
$el = $(this).closest('.acf_relationship');
|
333 |
-
|
334 |
-
|
335 |
-
// update attr
|
336 |
-
$el.attr('data-s', val);
|
337 |
-
$el.attr('data-paged', 1);
|
338 |
-
|
339 |
-
|
340 |
-
// fetch
|
341 |
-
clearTimeout( acf.fields.relationship.timeout );
|
342 |
-
acf.fields.relationship.timeout = setTimeout(function(){
|
343 |
-
|
344 |
-
acf.fields.relationship.set({ $el : $el }).fetch();
|
345 |
-
|
346 |
-
}, 500);
|
347 |
-
|
348 |
-
});
|
349 |
-
|
350 |
-
$(document).on('keypress', '.acf_relationship input.relationship_search', function( e ){
|
351 |
-
|
352 |
-
// don't submit form
|
353 |
-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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/tab.js
DELETED
@@ -1,280 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
acf.fields.tab = {
|
4 |
-
|
5 |
-
add_group : function( $wrap ){
|
6 |
-
|
7 |
-
// vars
|
8 |
-
var html = '';
|
9 |
-
|
10 |
-
|
11 |
-
// generate html
|
12 |
-
if( $wrap.is('tbody') )
|
13 |
-
{
|
14 |
-
html = '<tr class="acf-tab-wrap"><td colspan="2"><ul class="hl clearfix acf-tab-group"></ul></td></tr>';
|
15 |
-
}
|
16 |
-
else
|
17 |
-
{
|
18 |
-
html = '<div class="acf-tab-wrap"><ul class="hl clearfix acf-tab-group"></ul></div>';
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
// append html
|
23 |
-
$wrap.children('.field_type-tab:first').before( html );
|
24 |
-
|
25 |
-
},
|
26 |
-
|
27 |
-
add_tab : function( $tab ){
|
28 |
-
|
29 |
-
// vars
|
30 |
-
var $field = $tab.closest('.field'),
|
31 |
-
$wrap = $field.parent(),
|
32 |
-
|
33 |
-
key = $field.attr('data-field_key'),
|
34 |
-
label = $tab.text();
|
35 |
-
|
36 |
-
|
37 |
-
// create tab group if it doesnt exist
|
38 |
-
if( ! $wrap.children('.acf-tab-wrap').exists() )
|
39 |
-
{
|
40 |
-
this.add_group( $wrap );
|
41 |
-
}
|
42 |
-
|
43 |
-
// add tab
|
44 |
-
$wrap.children('.acf-tab-wrap').find('.acf-tab-group').append('<li><a class="acf-tab-button" href="#" data-key="' + key + '">' + label + '</a></li>');
|
45 |
-
|
46 |
-
},
|
47 |
-
|
48 |
-
toggle : function( $a ){
|
49 |
-
|
50 |
-
// reference
|
51 |
-
var _this = this;
|
52 |
-
|
53 |
-
|
54 |
-
//console.log( 'toggle %o ', $a);
|
55 |
-
// vars
|
56 |
-
var $wrap = $a.closest('.acf-tab-wrap').parent(),
|
57 |
-
key = $a.attr('data-key');
|
58 |
-
|
59 |
-
|
60 |
-
// classes
|
61 |
-
$a.parent('li').addClass('active').siblings('li').removeClass('active');
|
62 |
-
|
63 |
-
|
64 |
-
// hide / show
|
65 |
-
$wrap.children('.field_type-tab').each(function(){
|
66 |
-
|
67 |
-
|
68 |
-
// vars
|
69 |
-
var $tab = $(this);
|
70 |
-
|
71 |
-
|
72 |
-
if( $tab.attr('data-field_key') == key )
|
73 |
-
{
|
74 |
-
_this.show_tab_fields( $(this) );
|
75 |
-
}
|
76 |
-
else
|
77 |
-
{
|
78 |
-
_this.hide_tab_fields( $(this) );
|
79 |
-
}
|
80 |
-
|
81 |
-
|
82 |
-
});
|
83 |
-
|
84 |
-
},
|
85 |
-
|
86 |
-
show_tab_fields : function( $field ) {
|
87 |
-
|
88 |
-
//console.log('show tab fields %o', $field);
|
89 |
-
$field.nextUntil('.field_type-tab').each(function(){
|
90 |
-
|
91 |
-
$(this).removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
|
92 |
-
$(document).trigger('acf/fields/tab/show', [ $(this) ]);
|
93 |
-
|
94 |
-
});
|
95 |
-
},
|
96 |
-
|
97 |
-
hide_tab_fields : function( $field ) {
|
98 |
-
|
99 |
-
$field.nextUntil('.field_type-tab').each(function(){
|
100 |
-
|
101 |
-
$(this).removeClass('acf-tab_group-show').addClass('acf-tab_group-hide');
|
102 |
-
$(document).trigger('acf/fields/tab/hide', [ $(this) ]);
|
103 |
-
|
104 |
-
});
|
105 |
-
},
|
106 |
-
|
107 |
-
refresh : function( $el ){
|
108 |
-
|
109 |
-
// reference
|
110 |
-
var _this = this;
|
111 |
-
|
112 |
-
|
113 |
-
// trigger
|
114 |
-
$el.find('.acf-tab-group').each(function(){
|
115 |
-
|
116 |
-
$(this).find('.acf-tab-button:first').each(function(){
|
117 |
-
|
118 |
-
_this.toggle( $(this) );
|
119 |
-
|
120 |
-
});
|
121 |
-
|
122 |
-
});
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
};
|
127 |
-
|
128 |
-
|
129 |
-
/*
|
130 |
-
* acf/setup_fields
|
131 |
-
*
|
132 |
-
* run init function on all elements for this field
|
133 |
-
*
|
134 |
-
* @type event
|
135 |
-
* @date 20/07/13
|
136 |
-
*
|
137 |
-
* @param {object} e event object
|
138 |
-
* @param {object} el DOM object which may contain new ACF elements
|
139 |
-
* @return N/A
|
140 |
-
*/
|
141 |
-
|
142 |
-
$(document).on('acf/setup_fields', function(e, el){
|
143 |
-
|
144 |
-
// add tabs
|
145 |
-
$(el).find('.acf-tab').each(function(){
|
146 |
-
|
147 |
-
acf.fields.tab.add_tab( $(this) );
|
148 |
-
|
149 |
-
});
|
150 |
-
|
151 |
-
|
152 |
-
// activate first tab
|
153 |
-
acf.fields.tab.refresh( $(el) );
|
154 |
-
|
155 |
-
|
156 |
-
// NOTE: this code is defined BEFORE the acf.conditional_logic action. This is becuase the 'acf/setup_fields' listener is defined INSIDE the conditional_logic.init() function which is run on doc.ready
|
157 |
-
|
158 |
-
// trigger conditional logic
|
159 |
-
// this code ( acf/setup_fields ) is run after the main acf.conditional_logic.init();
|
160 |
-
//console.log('acf/setup_fields (after tab refresh) calling acf.conditional_logic.refresh()');
|
161 |
-
//acf.conditional_logic.refresh();
|
162 |
-
|
163 |
-
});
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
/*
|
169 |
-
* Events
|
170 |
-
*
|
171 |
-
* jQuery events for this field
|
172 |
-
*
|
173 |
-
* @type function
|
174 |
-
* @date 1/03/2011
|
175 |
-
*
|
176 |
-
* @param N/A
|
177 |
-
* @return N/A
|
178 |
-
*/
|
179 |
-
|
180 |
-
$(document).on('click', '.acf-tab-button', function( e ){
|
181 |
-
|
182 |
-
e.preventDefault();
|
183 |
-
|
184 |
-
acf.fields.tab.toggle( $(this) );
|
185 |
-
|
186 |
-
$(this).trigger('blur');
|
187 |
-
|
188 |
-
});
|
189 |
-
|
190 |
-
|
191 |
-
$(document).on('acf/conditional_logic/hide', function( e, $target, item ){
|
192 |
-
|
193 |
-
// validate
|
194 |
-
if( $target.attr('data-field_type') != 'tab' )
|
195 |
-
{
|
196 |
-
return;
|
197 |
-
}
|
198 |
-
|
199 |
-
//console.log('conditional_logic/hide tab %o', $target);
|
200 |
-
|
201 |
-
|
202 |
-
// vars
|
203 |
-
var $tab = $target.siblings('.acf-tab-wrap').find('a[data-key="' + $target.attr('data-field_key') + '"]');
|
204 |
-
|
205 |
-
|
206 |
-
// if tab is already hidden, then ignore the following functiolnality
|
207 |
-
if( $tab.is(':hidden') )
|
208 |
-
{
|
209 |
-
return;
|
210 |
-
}
|
211 |
-
|
212 |
-
|
213 |
-
// visibility
|
214 |
-
$tab.parent().hide();
|
215 |
-
|
216 |
-
|
217 |
-
// if
|
218 |
-
if( $tab.parent().siblings(':visible').exists() )
|
219 |
-
{
|
220 |
-
// if the $target to be hidden is a tab button, lets toggle a sibling tab button
|
221 |
-
$tab.parent().siblings(':visible').first().children('a').trigger('click');
|
222 |
-
}
|
223 |
-
else
|
224 |
-
{
|
225 |
-
// no onther tabs
|
226 |
-
acf.fields.tab.hide_tab_fields( $target );
|
227 |
-
}
|
228 |
-
|
229 |
-
});
|
230 |
-
|
231 |
-
|
232 |
-
$(document).on('acf/conditional_logic/show', function( e, $target, item ){
|
233 |
-
|
234 |
-
// validate
|
235 |
-
if( $target.attr('data-field_type') != 'tab' )
|
236 |
-
{
|
237 |
-
return;
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
//console.log('conditional_logic/show tab %o', $target);
|
242 |
-
|
243 |
-
|
244 |
-
// vars
|
245 |
-
var $tab = $target.siblings('.acf-tab-wrap').find('a[data-key="' + $target.attr('data-field_key') + '"]');
|
246 |
-
|
247 |
-
|
248 |
-
// if tab is already visible, then ignore the following functiolnality
|
249 |
-
if( $tab.is(':visible') )
|
250 |
-
{
|
251 |
-
return;
|
252 |
-
}
|
253 |
-
|
254 |
-
|
255 |
-
// visibility
|
256 |
-
$tab.parent().show();
|
257 |
-
|
258 |
-
|
259 |
-
// if this is the active tab
|
260 |
-
if( $tab.parent().hasClass('active') )
|
261 |
-
{
|
262 |
-
$tab.trigger('click');
|
263 |
-
return;
|
264 |
-
}
|
265 |
-
|
266 |
-
|
267 |
-
// if the sibling active tab is actually hidden by conditional logic, take ownership of tabs
|
268 |
-
if( $tab.parent().siblings('.active').is(':hidden') )
|
269 |
-
{
|
270 |
-
// show this tab group
|
271 |
-
$tab.trigger('click');
|
272 |
-
return;
|
273 |
-
}
|
274 |
-
|
275 |
-
|
276 |
-
});
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 1/06/13
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
|
14 |
-
acf.validation = {
|
15 |
-
|
16 |
-
status : true,
|
17 |
-
disabled : false,
|
18 |
-
|
19 |
-
run : function(){
|
20 |
-
|
21 |
-
// reference
|
22 |
-
var _this = this;
|
23 |
-
|
24 |
-
|
25 |
-
// reset
|
26 |
-
_this.status = true;
|
27 |
-
|
28 |
-
|
29 |
-
// loop through all fields
|
30 |
-
$('.field.required, .form-field.required').each(function(){
|
31 |
-
|
32 |
-
// run validation
|
33 |
-
_this.validate( $(this) );
|
34 |
-
|
35 |
-
|
36 |
-
});
|
37 |
-
// end loop through all fields
|
38 |
-
},
|
39 |
-
|
40 |
-
/*
|
41 |
-
* show_spinner
|
42 |
-
*
|
43 |
-
* This function will show a spinner element. Logic changed in WP 4.2
|
44 |
-
*
|
45 |
-
* @type function
|
46 |
-
* @date 3/05/2015
|
47 |
-
* @since 5.2.3
|
48 |
-
*
|
49 |
-
* @param $spinner (jQuery)
|
50 |
-
* @return n/a
|
51 |
-
*/
|
52 |
-
|
53 |
-
show_spinner: function( $spinner ){
|
54 |
-
|
55 |
-
// bail early if no spinner
|
56 |
-
if( !$spinner.exists() ) {
|
57 |
-
|
58 |
-
return;
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
|
63 |
-
// vars
|
64 |
-
var wp_version = acf.o.wp_version;
|
65 |
-
|
66 |
-
|
67 |
-
// show
|
68 |
-
if( parseFloat(wp_version) >= 4.2 ) {
|
69 |
-
|
70 |
-
$spinner.addClass('is-active');
|
71 |
-
|
72 |
-
} else {
|
73 |
-
|
74 |
-
$spinner.css('display', 'inline-block');
|
75 |
-
|
76 |
-
}
|
77 |
-
|
78 |
-
},
|
79 |
-
|
80 |
-
|
81 |
-
/*
|
82 |
-
* hide_spinner
|
83 |
-
*
|
84 |
-
* This function will hide a spinner element. Logic changed in WP 4.2
|
85 |
-
*
|
86 |
-
* @type function
|
87 |
-
* @date 3/05/2015
|
88 |
-
* @since 5.2.3
|
89 |
-
*
|
90 |
-
* @param $spinner (jQuery)
|
91 |
-
* @return n/a
|
92 |
-
*/
|
93 |
-
|
94 |
-
hide_spinner: function( $spinner ){
|
95 |
-
|
96 |
-
// bail early if no spinner
|
97 |
-
if( !$spinner.exists() ) {
|
98 |
-
|
99 |
-
return;
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
// vars
|
105 |
-
var wp_version = acf.o.wp_version;
|
106 |
-
|
107 |
-
|
108 |
-
// hide
|
109 |
-
if( parseFloat(wp_version) >= 4.2 ) {
|
110 |
-
|
111 |
-
$spinner.removeClass('is-active');
|
112 |
-
|
113 |
-
} else {
|
114 |
-
|
115 |
-
$spinner.css('display', 'none');
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
},
|
120 |
-
|
121 |
-
validate : function( div ){
|
122 |
-
|
123 |
-
// var
|
124 |
-
var ignore = false,
|
125 |
-
$tab = null;
|
126 |
-
|
127 |
-
|
128 |
-
// set validation data
|
129 |
-
div.data('validation', true);
|
130 |
-
|
131 |
-
|
132 |
-
// not visible
|
133 |
-
if( div.is(':hidden') )
|
134 |
-
{
|
135 |
-
// ignore validation
|
136 |
-
ignore = true;
|
137 |
-
|
138 |
-
|
139 |
-
// if this field is hidden by a tab group, allow validation
|
140 |
-
if( div.hasClass('acf-tab_group-hide') )
|
141 |
-
{
|
142 |
-
ignore = false;
|
143 |
-
|
144 |
-
|
145 |
-
// vars
|
146 |
-
var $tab_field = div.prevAll('.field_type-tab:first'),
|
147 |
-
$tab_group = div.prevAll('.acf-tab-wrap:first');
|
148 |
-
|
149 |
-
|
150 |
-
// if the tab itself is hidden, bypass validation
|
151 |
-
if( $tab_field.hasClass('acf-conditional_logic-hide') )
|
152 |
-
{
|
153 |
-
ignore = true;
|
154 |
-
}
|
155 |
-
else
|
156 |
-
{
|
157 |
-
// activate this tab as it holds hidden required field!
|
158 |
-
$tab = $tab_group.find('.acf-tab-button[data-key="' + $tab_field.attr('data-field_key') + '"]');
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
// if is hidden by conditional logic, ignore
|
165 |
-
if( div.hasClass('acf-conditional_logic-hide') )
|
166 |
-
{
|
167 |
-
ignore = true;
|
168 |
-
}
|
169 |
-
|
170 |
-
|
171 |
-
// if field group is hidden, igrnoe
|
172 |
-
if( div.closest('.postbox.acf-hidden').exists() ) {
|
173 |
-
|
174 |
-
ignore = true;
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
|
179 |
-
if( ignore )
|
180 |
-
{
|
181 |
-
return;
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
// text / textarea
|
187 |
-
if( div.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val() == "" )
|
188 |
-
{
|
189 |
-
div.data('validation', false);
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
// wysiwyg
|
194 |
-
if( div.find('.acf_wysiwyg').exists() && typeof(tinyMCE) == "object")
|
195 |
-
{
|
196 |
-
div.data('validation', true);
|
197 |
-
|
198 |
-
var id = div.find('.wp-editor-area').attr('id'),
|
199 |
-
editor = tinyMCE.get( id );
|
200 |
-
|
201 |
-
|
202 |
-
if( editor && !editor.getContent() )
|
203 |
-
{
|
204 |
-
div.data('validation', false);
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
// select
|
210 |
-
if( div.find('select').exists() )
|
211 |
-
{
|
212 |
-
div.data('validation', true);
|
213 |
-
|
214 |
-
if( div.find('select').val() == "null" || ! div.find('select').val() )
|
215 |
-
{
|
216 |
-
div.data('validation', false);
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
// radio
|
222 |
-
if( div.find('input[type="radio"]').exists() )
|
223 |
-
{
|
224 |
-
div.data('validation', false);
|
225 |
-
|
226 |
-
if( div.find('input[type="radio"]:checked').exists() )
|
227 |
-
{
|
228 |
-
div.data('validation', true);
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
// checkbox
|
234 |
-
if( div.find('input[type="checkbox"]').exists() )
|
235 |
-
{
|
236 |
-
div.data('validation', false);
|
237 |
-
|
238 |
-
if( div.find('input[type="checkbox"]:checked').exists() )
|
239 |
-
{
|
240 |
-
div.data('validation', true);
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
|
245 |
-
// relationship
|
246 |
-
if( div.find('.acf_relationship').exists() )
|
247 |
-
{
|
248 |
-
div.data('validation', false);
|
249 |
-
|
250 |
-
if( div.find('.acf_relationship .relationship_right input').exists() )
|
251 |
-
{
|
252 |
-
div.data('validation', true);
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
|
257 |
-
// repeater
|
258 |
-
if( div.find('.repeater').exists() )
|
259 |
-
{
|
260 |
-
div.data('validation', false);
|
261 |
-
|
262 |
-
if( div.find('.repeater tr.row').exists() )
|
263 |
-
{
|
264 |
-
div.data('validation', true);
|
265 |
-
}
|
266 |
-
}
|
267 |
-
|
268 |
-
|
269 |
-
// gallery
|
270 |
-
if( div.find('.acf-gallery').exists() )
|
271 |
-
{
|
272 |
-
div.data('validation', false);
|
273 |
-
|
274 |
-
if( div.find('.acf-gallery .thumbnail').exists())
|
275 |
-
{
|
276 |
-
div.data('validation', true);
|
277 |
-
}
|
278 |
-
}
|
279 |
-
|
280 |
-
|
281 |
-
// hook for custom validation
|
282 |
-
$(document).trigger('acf/validate_field', [ div ] );
|
283 |
-
|
284 |
-
|
285 |
-
// set validation
|
286 |
-
if( ! div.data('validation') )
|
287 |
-
{
|
288 |
-
// show error
|
289 |
-
this.status = false;
|
290 |
-
div.closest('.field').addClass('error');
|
291 |
-
|
292 |
-
|
293 |
-
// custom validation message
|
294 |
-
if( div.data('validation_message') )
|
295 |
-
{
|
296 |
-
var $label = div.find('p.label:first'),
|
297 |
-
$message = null;
|
298 |
-
|
299 |
-
|
300 |
-
// remove old message
|
301 |
-
$label.children('.acf-error-message').remove();
|
302 |
-
|
303 |
-
|
304 |
-
$label.append( '<span class="acf-error-message"><i class="bit"></i>' + div.data('validation_message') + '</span>' );
|
305 |
-
}
|
306 |
-
|
307 |
-
|
308 |
-
// display field (curently hidden due to another tab being active)
|
309 |
-
if( $tab )
|
310 |
-
{
|
311 |
-
$tab.trigger('click');
|
312 |
-
}
|
313 |
-
|
314 |
-
}
|
315 |
-
}
|
316 |
-
|
317 |
-
};
|
318 |
-
|
319 |
-
|
320 |
-
/*
|
321 |
-
* Events
|
322 |
-
*
|
323 |
-
* Remove error class on focus
|
324 |
-
*
|
325 |
-
* @type function
|
326 |
-
* @date 1/03/2011
|
327 |
-
*
|
328 |
-
* @param N/A
|
329 |
-
* @return N/A
|
330 |
-
*/
|
331 |
-
|
332 |
-
$(document).on('focus click', '.field.required input, .field.required textarea, .field.required select', function( e ){
|
333 |
-
|
334 |
-
$(this).closest('.field').removeClass('error');
|
335 |
-
|
336 |
-
});
|
337 |
-
|
338 |
-
|
339 |
-
/*
|
340 |
-
$(document).on('blur change', '.field.required input, .field.required textarea, .field.required select', function( e ){
|
341 |
-
|
342 |
-
acf.validation.validate( $(this).closest('.field') );
|
343 |
-
|
344 |
-
});
|
345 |
-
*/
|
346 |
-
|
347 |
-
|
348 |
-
/*
|
349 |
-
* Save Post
|
350 |
-
*
|
351 |
-
* If user is saving a draft, allow them to bypass the validation
|
352 |
-
*
|
353 |
-
* @type function
|
354 |
-
* @date 1/03/2011
|
355 |
-
*
|
356 |
-
* @param N/A
|
357 |
-
* @return N/A
|
358 |
-
*/
|
359 |
-
|
360 |
-
$(document).on('click', '#save-post', function(){
|
361 |
-
|
362 |
-
acf.validation.disabled = true;
|
363 |
-
|
364 |
-
});
|
365 |
-
|
366 |
-
|
367 |
-
/*
|
368 |
-
* Submit Post
|
369 |
-
*
|
370 |
-
* Run validation and return true|false accordingly
|
371 |
-
*
|
372 |
-
* @type function
|
373 |
-
* @date 1/03/2011
|
374 |
-
*
|
375 |
-
* @param N/A
|
376 |
-
* @return N/A
|
377 |
-
*/
|
378 |
-
|
379 |
-
$(document).on('submit', '#post', function(){
|
380 |
-
|
381 |
-
// If disabled, bail early on the validation check
|
382 |
-
if( acf.validation.disabled )
|
383 |
-
{
|
384 |
-
return true;
|
385 |
-
}
|
386 |
-
|
387 |
-
|
388 |
-
// do validation
|
389 |
-
acf.validation.run();
|
390 |
-
|
391 |
-
|
392 |
-
if( ! acf.validation.status ) {
|
393 |
-
|
394 |
-
// vars
|
395 |
-
var $form = $(this);
|
396 |
-
|
397 |
-
|
398 |
-
// show message
|
399 |
-
$form.siblings('#message').remove();
|
400 |
-
$form.before('<div id="message" class="error"><p>' + acf.l10n.validation.error + '</p></div>');
|
401 |
-
|
402 |
-
|
403 |
-
// hide ajax stuff on submit button
|
404 |
-
if( $('#submitdiv').exists() ) {
|
405 |
-
|
406 |
-
// remove disabled classes
|
407 |
-
$('#submitdiv').find('.disabled').removeClass('disabled');
|
408 |
-
$('#submitdiv').find('.button-disabled').removeClass('button-disabled');
|
409 |
-
$('#submitdiv').find('.button-primary-disabled').removeClass('button-primary-disabled');
|
410 |
-
|
411 |
-
|
412 |
-
// remove spinner
|
413 |
-
acf.validation.hide_spinner( $('#submitdiv .spinner') );
|
414 |
-
|
415 |
-
}
|
416 |
-
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
|
420 |
-
|
421 |
-
// remove hidden postboxes
|
422 |
-
// + this will stop them from being posted to save
|
423 |
-
$('.acf_postbox.acf-hidden').remove();
|
424 |
-
|
425 |
-
|
426 |
-
// submit the form
|
427 |
-
return true;
|
428 |
-
|
429 |
-
});
|
430 |
-
|
431 |
-
|
432 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/input/wysiwyg.js
DELETED
@@ -1,556 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
/*
|
4 |
-
* WYSIWYG
|
5 |
-
*
|
6 |
-
* jQuery functionality for this field type
|
7 |
-
*
|
8 |
-
* @type object
|
9 |
-
* @date 20/07/13
|
10 |
-
*
|
11 |
-
* @param N/A
|
12 |
-
* @return N/A
|
13 |
-
*/
|
14 |
-
|
15 |
-
var _wysiwyg = acf.fields.wysiwyg = {
|
16 |
-
|
17 |
-
$el : null,
|
18 |
-
$textarea : null,
|
19 |
-
|
20 |
-
o : {},
|
21 |
-
|
22 |
-
set : function( o ){
|
23 |
-
|
24 |
-
// merge in new option
|
25 |
-
$.extend( this, o );
|
26 |
-
|
27 |
-
|
28 |
-
// find textarea
|
29 |
-
this.$textarea = this.$el.find('textarea');
|
30 |
-
|
31 |
-
|
32 |
-
// get options
|
33 |
-
this.o = acf.helpers.get_atts( this.$el );
|
34 |
-
|
35 |
-
|
36 |
-
// add ID
|
37 |
-
this.o.id = this.$textarea.attr('id');
|
38 |
-
|
39 |
-
|
40 |
-
// return this for chaining
|
41 |
-
return this;
|
42 |
-
|
43 |
-
},
|
44 |
-
has_tinymce : function(){
|
45 |
-
|
46 |
-
var r = false;
|
47 |
-
|
48 |
-
if( typeof(tinyMCE) == "object" )
|
49 |
-
{
|
50 |
-
r = true;
|
51 |
-
}
|
52 |
-
|
53 |
-
return r;
|
54 |
-
|
55 |
-
},
|
56 |
-
|
57 |
-
get_toolbar : function(){
|
58 |
-
|
59 |
-
// safely get toolbar
|
60 |
-
if( acf.helpers.isset( this, 'toolbars', this.o.toolbar ) ) {
|
61 |
-
|
62 |
-
return this.toolbars[ this.o.toolbar ];
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
// return
|
68 |
-
return false;
|
69 |
-
|
70 |
-
},
|
71 |
-
|
72 |
-
init : function(){
|
73 |
-
|
74 |
-
// is clone field?
|
75 |
-
if( acf.helpers.is_clone_field( this.$textarea ) )
|
76 |
-
{
|
77 |
-
return;
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
// vars
|
82 |
-
var toolbar = this.get_toolbar(),
|
83 |
-
command = 'mceAddControl',
|
84 |
-
setting = 'theme_advanced_buttons{i}';
|
85 |
-
|
86 |
-
|
87 |
-
// backup
|
88 |
-
var _settings = $.extend( {}, tinyMCE.settings );
|
89 |
-
|
90 |
-
|
91 |
-
// v4 settings
|
92 |
-
if( tinymce.majorVersion == 4 ) {
|
93 |
-
|
94 |
-
command = 'mceAddEditor';
|
95 |
-
setting = 'toolbar{i}';
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
// add toolbars
|
101 |
-
if( toolbar ) {
|
102 |
-
|
103 |
-
for( var i = 1; i < 5; i++ ) {
|
104 |
-
|
105 |
-
// vars
|
106 |
-
var v = '';
|
107 |
-
|
108 |
-
|
109 |
-
// load toolbar
|
110 |
-
if( acf.helpers.isset( toolbar, 'theme_advanced_buttons' + i ) ) {
|
111 |
-
|
112 |
-
v = toolbar['theme_advanced_buttons' + i];
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
// update setting
|
118 |
-
tinyMCE.settings[ setting.replace('{i}', i) ] = v;
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
|
125 |
-
// add editor
|
126 |
-
tinyMCE.execCommand( command, false, this.o.id);
|
127 |
-
|
128 |
-
|
129 |
-
// events - load
|
130 |
-
$(document).trigger('acf/wysiwyg/load', this.o.id);
|
131 |
-
|
132 |
-
|
133 |
-
// add events (click, focus, blur) for inserting image into correct editor
|
134 |
-
this.add_events();
|
135 |
-
|
136 |
-
|
137 |
-
// restore tinyMCE.settings
|
138 |
-
tinyMCE.settings = _settings;
|
139 |
-
|
140 |
-
|
141 |
-
// set active editor to null
|
142 |
-
wpActiveEditor = null;
|
143 |
-
|
144 |
-
},
|
145 |
-
add_events : function(){
|
146 |
-
|
147 |
-
// vars
|
148 |
-
var id = this.o.id,
|
149 |
-
editor = tinyMCE.get( id );
|
150 |
-
|
151 |
-
|
152 |
-
// validate
|
153 |
-
if( !editor )
|
154 |
-
{
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
// vars
|
160 |
-
var $container = $('#wp-' + id + '-wrap'),
|
161 |
-
$body = $( editor.getBody() );
|
162 |
-
|
163 |
-
|
164 |
-
// events
|
165 |
-
$container.on('click', function(){
|
166 |
-
|
167 |
-
$(document).trigger('acf/wysiwyg/click', id);
|
168 |
-
|
169 |
-
});
|
170 |
-
|
171 |
-
$body.on('focus', function(){
|
172 |
-
|
173 |
-
$(document).trigger('acf/wysiwyg/focus', id);
|
174 |
-
|
175 |
-
});
|
176 |
-
|
177 |
-
$body.on('blur', function(){
|
178 |
-
|
179 |
-
$(document).trigger('acf/wysiwyg/blur', id);
|
180 |
-
|
181 |
-
});
|
182 |
-
|
183 |
-
|
184 |
-
},
|
185 |
-
destroy : function(){
|
186 |
-
|
187 |
-
// vars
|
188 |
-
var id = this.o.id,
|
189 |
-
command = 'mceRemoveControl';
|
190 |
-
|
191 |
-
|
192 |
-
// Remove tinymcy functionality.
|
193 |
-
// Due to the media popup destroying and creating the field within such a short amount of time,
|
194 |
-
// a JS error will be thrown when launching the edit window twice in a row.
|
195 |
-
try {
|
196 |
-
|
197 |
-
// vars
|
198 |
-
var editor = tinyMCE.get( id );
|
199 |
-
|
200 |
-
|
201 |
-
// validate
|
202 |
-
if( !editor ) {
|
203 |
-
|
204 |
-
return;
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
// v4 settings
|
210 |
-
if( tinymce.majorVersion == 4 ) {
|
211 |
-
|
212 |
-
command = 'mceRemoveEditor';
|
213 |
-
|
214 |
-
}
|
215 |
-
|
216 |
-
|
217 |
-
// store value
|
218 |
-
var val = editor.getContent();
|
219 |
-
|
220 |
-
|
221 |
-
// remove editor
|
222 |
-
tinyMCE.execCommand(command, false, id);
|
223 |
-
|
224 |
-
|
225 |
-
// set value
|
226 |
-
this.$textarea.val( val );
|
227 |
-
|
228 |
-
|
229 |
-
} catch(e) {
|
230 |
-
|
231 |
-
//console.log( e );
|
232 |
-
|
233 |
-
}
|
234 |
-
|
235 |
-
|
236 |
-
// set active editor to null
|
237 |
-
wpActiveEditor = null;
|
238 |
-
|
239 |
-
}
|
240 |
-
|
241 |
-
};
|
242 |
-
|
243 |
-
|
244 |
-
/*
|
245 |
-
* acf/setup_fields
|
246 |
-
*
|
247 |
-
* run init function on all elements for this field
|
248 |
-
*
|
249 |
-
* @type event
|
250 |
-
* @date 20/07/13
|
251 |
-
*
|
252 |
-
* @param {object} e event object
|
253 |
-
* @param {object} el DOM object which may contain new ACF elements
|
254 |
-
* @return N/A
|
255 |
-
*/
|
256 |
-
|
257 |
-
$(document).on('acf/setup_fields', function(e, el){
|
258 |
-
|
259 |
-
// validate
|
260 |
-
if( ! _wysiwyg.has_tinymce() )
|
261 |
-
{
|
262 |
-
return;
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
// Destory all WYSIWYG fields
|
267 |
-
// This hack will fix a problem when the WP popup is created and hidden, then the ACF popup (image/file field) is opened
|
268 |
-
$(el).find('.acf_wysiwyg').each(function(){
|
269 |
-
|
270 |
-
_wysiwyg.set({ $el : $(this) }).destroy();
|
271 |
-
|
272 |
-
});
|
273 |
-
|
274 |
-
|
275 |
-
// Add WYSIWYG fields
|
276 |
-
setTimeout(function(){
|
277 |
-
|
278 |
-
$(el).find('.acf_wysiwyg').each(function(){
|
279 |
-
|
280 |
-
_wysiwyg.set({ $el : $(this) }).init();
|
281 |
-
|
282 |
-
});
|
283 |
-
|
284 |
-
}, 0);
|
285 |
-
|
286 |
-
});
|
287 |
-
|
288 |
-
|
289 |
-
/*
|
290 |
-
* acf/remove_fields
|
291 |
-
*
|
292 |
-
* This action is called when the $el is being removed from the DOM
|
293 |
-
*
|
294 |
-
* @type event
|
295 |
-
* @date 20/07/13
|
296 |
-
*
|
297 |
-
* @param {object} e event object
|
298 |
-
* @param {object} $el jQuery element being removed
|
299 |
-
* @return N/A
|
300 |
-
*/
|
301 |
-
|
302 |
-
$(document).on('acf/remove_fields', function(e, $el){
|
303 |
-
|
304 |
-
// validate
|
305 |
-
if( ! _wysiwyg.has_tinymce() )
|
306 |
-
{
|
307 |
-
return;
|
308 |
-
}
|
309 |
-
|
310 |
-
|
311 |
-
$el.find('.acf_wysiwyg').each(function(){
|
312 |
-
|
313 |
-
_wysiwyg.set({ $el : $(this) }).destroy();
|
314 |
-
|
315 |
-
});
|
316 |
-
|
317 |
-
});
|
318 |
-
|
319 |
-
|
320 |
-
/*
|
321 |
-
* acf/wysiwyg/click
|
322 |
-
*
|
323 |
-
* this event is run when a user clicks on a WYSIWYG field
|
324 |
-
*
|
325 |
-
* @type event
|
326 |
-
* @date 17/01/13
|
327 |
-
*
|
328 |
-
* @param {object} e event object
|
329 |
-
* @param {int} id WYSIWYG ID
|
330 |
-
* @return N/A
|
331 |
-
*/
|
332 |
-
|
333 |
-
$(document).on('acf/wysiwyg/click', function(e, id){
|
334 |
-
|
335 |
-
wpActiveEditor = id;
|
336 |
-
|
337 |
-
container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
|
338 |
-
|
339 |
-
});
|
340 |
-
|
341 |
-
|
342 |
-
/*
|
343 |
-
* acf/wysiwyg/focus
|
344 |
-
*
|
345 |
-
* this event is run when a user focuses on a WYSIWYG field body
|
346 |
-
*
|
347 |
-
* @type event
|
348 |
-
* @date 17/01/13
|
349 |
-
*
|
350 |
-
* @param {object} e event object
|
351 |
-
* @param {int} id WYSIWYG ID
|
352 |
-
* @return N/A
|
353 |
-
*/
|
354 |
-
|
355 |
-
$(document).on('acf/wysiwyg/focus', function(e, id){
|
356 |
-
|
357 |
-
wpActiveEditor = id;
|
358 |
-
|
359 |
-
container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
|
360 |
-
|
361 |
-
});
|
362 |
-
|
363 |
-
|
364 |
-
/*
|
365 |
-
* acf/wysiwyg/blur
|
366 |
-
*
|
367 |
-
* this event is run when a user loses focus on a WYSIWYG field body
|
368 |
-
*
|
369 |
-
* @type event
|
370 |
-
* @date 17/01/13
|
371 |
-
*
|
372 |
-
* @param {object} e event object
|
373 |
-
* @param {int} id WYSIWYG ID
|
374 |
-
* @return N/A
|
375 |
-
*/
|
376 |
-
|
377 |
-
$(document).on('acf/wysiwyg/blur', function(e, id){
|
378 |
-
|
379 |
-
wpActiveEditor = null;
|
380 |
-
|
381 |
-
// update the hidden textarea
|
382 |
-
// - This fixes a but when adding a taxonomy term as the form is not posted and the hidden tetarea is never populated!
|
383 |
-
var editor = tinyMCE.get( id );
|
384 |
-
|
385 |
-
|
386 |
-
// validate
|
387 |
-
if( !editor )
|
388 |
-
{
|
389 |
-
return;
|
390 |
-
}
|
391 |
-
|
392 |
-
|
393 |
-
var el = editor.getElement();
|
394 |
-
|
395 |
-
|
396 |
-
// save to textarea
|
397 |
-
editor.save();
|
398 |
-
|
399 |
-
|
400 |
-
// trigger change on textarea
|
401 |
-
$( el ).trigger('change');
|
402 |
-
|
403 |
-
});
|
404 |
-
|
405 |
-
|
406 |
-
/*
|
407 |
-
* acf/sortable_start
|
408 |
-
*
|
409 |
-
* this event is run when a element is being drag / dropped
|
410 |
-
*
|
411 |
-
* @type event
|
412 |
-
* @date 10/11/12
|
413 |
-
*
|
414 |
-
* @param {object} e event object
|
415 |
-
* @param {object} el DOM object which may contain new ACF elements
|
416 |
-
* @return N/A
|
417 |
-
*/
|
418 |
-
|
419 |
-
$(document).on('acf/sortable_start', function(e, el) {
|
420 |
-
|
421 |
-
// validate
|
422 |
-
if( ! _wysiwyg.has_tinymce() )
|
423 |
-
{
|
424 |
-
return;
|
425 |
-
}
|
426 |
-
|
427 |
-
|
428 |
-
$(el).find('.acf_wysiwyg').each(function(){
|
429 |
-
|
430 |
-
_wysiwyg.set({ $el : $(this) }).destroy();
|
431 |
-
|
432 |
-
});
|
433 |
-
|
434 |
-
});
|
435 |
-
|
436 |
-
|
437 |
-
/*
|
438 |
-
* acf/sortable_stop
|
439 |
-
*
|
440 |
-
* this event is run when a element has finnished being drag / dropped
|
441 |
-
*
|
442 |
-
* @type event
|
443 |
-
* @date 10/11/12
|
444 |
-
*
|
445 |
-
* @param {object} e event object
|
446 |
-
* @param {object} el DOM object which may contain new ACF elements
|
447 |
-
* @return N/A
|
448 |
-
*/
|
449 |
-
|
450 |
-
$(document).on('acf/sortable_stop', function(e, el) {
|
451 |
-
|
452 |
-
// validate
|
453 |
-
if( ! _wysiwyg.has_tinymce() )
|
454 |
-
{
|
455 |
-
return;
|
456 |
-
}
|
457 |
-
|
458 |
-
|
459 |
-
$(el).find('.acf_wysiwyg').each(function(){
|
460 |
-
|
461 |
-
_wysiwyg.set({ $el : $(this) }).init();
|
462 |
-
|
463 |
-
});
|
464 |
-
|
465 |
-
});
|
466 |
-
|
467 |
-
|
468 |
-
/*
|
469 |
-
* window load
|
470 |
-
*
|
471 |
-
* @description:
|
472 |
-
* @since: 3.5.5
|
473 |
-
* @created: 22/12/12
|
474 |
-
*/
|
475 |
-
|
476 |
-
$(window).load(function(){
|
477 |
-
|
478 |
-
// validate
|
479 |
-
if( ! _wysiwyg.has_tinymce() )
|
480 |
-
{
|
481 |
-
return;
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
// vars
|
486 |
-
var wp_content = $('#wp-content-wrap').exists(),
|
487 |
-
wp_acf_settings = $('#wp-acf_settings-wrap').exists()
|
488 |
-
mode = 'tmce';
|
489 |
-
|
490 |
-
|
491 |
-
// has_editor
|
492 |
-
if( wp_acf_settings )
|
493 |
-
{
|
494 |
-
// html_mode
|
495 |
-
if( $('#wp-acf_settings-wrap').hasClass('html-active') )
|
496 |
-
{
|
497 |
-
mode = 'html';
|
498 |
-
}
|
499 |
-
}
|
500 |
-
|
501 |
-
|
502 |
-
setTimeout(function(){
|
503 |
-
|
504 |
-
// trigger click on hidden wysiwyg (to get in HTML mode)
|
505 |
-
if( wp_acf_settings && mode == 'html' )
|
506 |
-
{
|
507 |
-
$('#acf_settings-tmce').trigger('click');
|
508 |
-
}
|
509 |
-
|
510 |
-
}, 1);
|
511 |
-
|
512 |
-
|
513 |
-
setTimeout(function(){
|
514 |
-
|
515 |
-
// trigger html mode for people who want to stay in HTML mode
|
516 |
-
if( wp_acf_settings && mode == 'html' )
|
517 |
-
{
|
518 |
-
$('#acf_settings-html').trigger('click');
|
519 |
-
}
|
520 |
-
|
521 |
-
// Add events to content editor
|
522 |
-
if( wp_content )
|
523 |
-
{
|
524 |
-
_wysiwyg.set({ $el : $('#wp-content-wrap') }).add_events();
|
525 |
-
}
|
526 |
-
|
527 |
-
|
528 |
-
}, 11);
|
529 |
-
|
530 |
-
|
531 |
-
});
|
532 |
-
|
533 |
-
|
534 |
-
/*
|
535 |
-
* Full screen
|
536 |
-
*
|
537 |
-
* @description: this hack will hide the 'image upload' button in the wysiwyg full screen mode if the field has disabled image uploads!
|
538 |
-
* @since: 3.6
|
539 |
-
* @created: 26/02/13
|
540 |
-
*/
|
541 |
-
|
542 |
-
$(document).on('click', '.acf_wysiwyg a.mce_fullscreen', function(){
|
543 |
-
|
544 |
-
// vars
|
545 |
-
var wysiwyg = $(this).closest('.acf_wysiwyg'),
|
546 |
-
upload = wysiwyg.attr('data-upload');
|
547 |
-
|
548 |
-
if( upload == 'no' )
|
549 |
-
{
|
550 |
-
$('#mce_fullscreen_container td.mceToolbar .mce_add_media').remove();
|
551 |
-
}
|
552 |
-
|
553 |
-
});
|
554 |
-
|
555 |
-
|
556 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: elliotcondon
|
3 |
Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
|
4 |
Requires at least: 3.5.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 4.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -116,6 +116,9 @@ http://support.advancedcustomfields.com/
|
|
116 |
|
117 |
== Changelog ==
|
118 |
|
|
|
|
|
|
|
119 |
= 4.4.7 =
|
120 |
* Relationship field: Fixed bug preventing values from being selected in WP 4.5
|
121 |
* Google Map field: Fixed bug preventing map to load within repeater field
|
@@ -774,7 +777,7 @@ http://support.advancedcustomfields.com/
|
|
774 |
* Added new French translation. Thanks to Martin Vauchel @littlbr http://littleboyrunning.com
|
775 |
* Fixed duplicate WYSIWYG in chrome bug
|
776 |
* New Location rules: add fields to a user / taxonomy / attachment
|
777 |
-
* Bug Fix: Color picker now shows color on page load. Thanks to
|
778 |
* CSS tweaks File clearfix, new style for selects with optgroups
|
779 |
* Simplified get_value to return default value if value == ""
|
780 |
* API now allows for "option" and "options" for the $post_id value in API functions
|
2 |
Contributors: elliotcondon
|
3 |
Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
|
4 |
Requires at least: 3.5.0
|
5 |
+
Tested up to: 4.7.0
|
6 |
+
Stable tag: 4.4.8
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
116 |
|
117 |
== Changelog ==
|
118 |
|
119 |
+
= 4.4.8 =
|
120 |
+
* Google Map: Added new 'acf/fields/google_map/api' filter
|
121 |
+
|
122 |
= 4.4.7 =
|
123 |
* Relationship field: Fixed bug preventing values from being selected in WP 4.5
|
124 |
* Google Map field: Fixed bug preventing map to load within repeater field
|
777 |
* Added new French translation. Thanks to Martin Vauchel @littlbr http://littleboyrunning.com
|
778 |
* Fixed duplicate WYSIWYG in chrome bug
|
779 |
* New Location rules: add fields to a user / taxonomy / attachment
|
780 |
+
* Bug Fix: Color picker now shows color on page load. Thanks to Kevin Ruscoe http://github.com/kevdotbadger"
|
781 |
* CSS tweaks File clearfix, new style for selects with optgroups
|
782 |
* Simplified get_value to return default value if value == ""
|
783 |
* API now allows for "option" and "options" for the $post_id value in API functions
|