hueman/assets/czr/js/czr-preview-base.min.js
2017-02-24 16:17:43 +01:00

1 line
No EOL
5.1 KiB
JavaScript

!function(a,b,c){b(function(){a.preview.bind("sync",function(b){a.preview.send("czr-skopes-synced",{czr_skopes:_wpCustomizeSettings.czr_skopes||[],isChangesetDirty:_wpCustomizeSettings.isChangesetDirty||!1,skopeGlobalDBOpt:_wpCustomizeSettings.skopeGlobalDBOpt||[]})})}),wp.customize.bind("preview-ready",function(){wp.customize.preview.bind("edit_sek",function(a){c.has(a,"id")&&b('[data-sek-id="'+a.id+'"]').length&&b("html, body").animate({scrollTop:b('[data-sek-id="'+a.id+'"]').offset().top-50},"slow")}),wp.customize.preview.bind("start_hovering_sek",function(a){if(c.has(a,"id")&&b('[data-sek-id="'+a.id+'"]').length){var d=b('[data-sek-id="'+a.id+'"]'),e=d.outerWidth(),f=d.outerHeight();d.closest(".czr-sektion").find(".czr-hover-placeholder").each(function(){b(this).remove()}),b.when(d.append(b("<div/>",{"class":"czr-hover-placeholder",style:"width:"+e+"px;height:"+f+"px;line-height:"+f+"px;",html:'<i class="material-icons">create</i>'}))).done(function(){b(".czr-hover-placeholder").css("opacity",1).fitText(.3,{minFontSize:"50px",maxFontSize:"100px"})})}}),wp.customize.preview.bind("stop_hovering_sek",function(a){if(c.has(a,"id")&&b('[data-sek-id="'+a.id+'"]').length){var d=b('[data-sek-id="'+a.id+'"]');b.when(d.find(".czr-hover-placeholder").fadeOut(200)).done(function(){d.find(".czr-hover-placeholder").remove()})}}),wp.customize.preview.bind("edit_module",function(a){c.has(a,"id")&&b('[data-module-id="'+a.id+'"]').length&&b("html, body").animate({scrollTop:b('[data-module-id="'+a.id+'"]').offset().top-50},"slow")}),wp.customize.preview.bind("start_hovering_module",function(a){if(c.has(a,"id")&&b('[data-module-id="'+a.id+'"]').length){var d=b('[data-module-id="'+a.id+'"]'),e=d.outerWidth(),f=d.outerHeight();d.closest(".czr-sektion").find(".czr-hover-placeholder").each(function(){b(this).remove()}),b.when(d.append(b("<div/>",{"class":"czr-hover-placeholder",style:"width:"+e+"px;height:"+f+"px;line-height:"+f+"px;",html:'<i class="material-icons">create</i>'}))).done(function(){b(".czr-hover-placeholder").css("opacity",1).fitText(.3,{minFontSize:"50px",maxFontSize:"100px"})})}}),wp.customize.preview.bind("stop_hovering_module",function(a){if(c.has(a,"id")&&b('[data-module-id="'+a.id+'"]').length){var d=b('[data-module-id="'+a.id+'"]');b.when(d.find(".czr-hover-placeholder").fadeOut(200)).done(function(){d.find(".czr-hover-placeholder").remove()})}})}),CZRPreviewParams&&!CZRPreviewParams.preview_ready_event_exists?a.czr_preview=new a.CZR_preview:a.bind("preview-ready",function(){a.preview.bind("active",function(){a.czr_preview=new a.CZR_preview})}),a.CZR_preview=a.Class.extend({setting_cbs:{},subsetting_cbs:{},input_cbs:{},_wp_sets:CZRPreviewParams.wpBuiltinSettings||[],_theme_options_name:CZRPreviewParams.themeOptions,initialize:function(){var a=this;this.pre_setting_cbs=c.extend(a.pre_setting_cbs,a.getPreSettingCbs()),this.setting_cbs=c.extend(a.setting_cbs,a.getSettingCbs()),this.subsetting_cbs=c.extend(a.subsetting_cbs,a.getSubSettingCbs()),this.input_cbs=c.extend(a.input_cbs,a.getInputCbs()),this.syncData(),this.addCbs(),b("body").removeClass("wp-customizer-unloading")},getPreSettingCbs:function(){return{}},getSettingCbs:function(){return{}},getSubSettingCbs:function(){return{}},getInputCbs:function(){return{}},syncData:function(){a.preview.send("czr-query-data-ready",a.settings.czr_wpQueryInfos),a.preview.send("houston-widget-settings",c.extend(_wpWidgetCustomizerPreviewSettings,{availableWidgetLocations:c.values(a.settings.availableWidgetLocations)})),a.preview.send("czr-partial-refresh-data","undefined"==typeof _customizePartialRefreshExports?{}:_customizePartialRefreshExports.partials)},addCbs:function(){var b=this;a.preview.bind("pre_setting",function(d){d=d||{};var e=d.set_id;if(a.has(b._build_setId(e))){var f=b._get_option_name(d.set_id);c.has(b.pre_setting_cbs,f)&&c.isFunction(b.pre_setting_cbs[f])&&b.pre_setting_cbs[f](d)}}),c.each(b.setting_cbs,function(d,e){a.has(b._build_setId(e))&&c.isFunction(b.setting_cbs[e])&&a(b._build_setId(e)).bind(b.setting_cbs[e])}),a.preview.bind("sub_setting",function(a){var d=b._get_option_name(a.set_id);c.has(b.subsetting_cbs,d)&&c.has(b.subsetting_cbs[d],a.changed_prop)&&b.subsetting_cbs[d][a.changed_prop](a)}),a.preview.bind("czr_input",function(a){var d={set_id:"",module_id:"",item_id:"",input_id:"",value:null};a=c.extend(d,a);var e=b._get_option_name(a.set_id);c.has(b.input_cbs,e)&&c.has(b.input_cbs[e],a.input_id)&&b.input_cbs[e][a.input_id](a)}),a.selectiveRefresh.bind("partial-content-rendered",function(d){if(c.has(d,"partial")&&c.has(d.partial,"id")){d.partial.id;a.preview.send("czr-partial-refresh-done",{set_id:b._build_setId(d.partial.id)})}})},_build_setId:function(a){var b=this;return c.contains(b._wp_sets,a)?a:-1==a.indexOf(b._theme_options_name)?[b._theme_options_name+"[",a,"]"].join(""):a},_get_option_name:function(a){var b=this;return a.replace(/\[|\]/g,"").replace(b._theme_options_name,"")},_is_external:function(a){var c=b.trim(a),d=location.host.split(".").slice(-2).join("."),e=new RegExp(d);if(""!==c&&"#"!=c&&_isValidURL(c))return!e.test(c)},_isValidURL:function(a){var b=/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return b.test(a)}})}(wp.customize,jQuery,_);