2012-04-18 19:58:18 +02:00
|
|
|
(function(a,c){var b=wp.customize;b.Setting=b.Value.extend({initialize:function(g,f,d){var e;b.Value.prototype.initialize.call(this,f,d);this.id=g;this.method=this.method||"refresh";e=c("<input />",{type:"hidden",value:this.get(),name:b.settings.prefix+g});e.appendTo(this.previewer.form);this.element=new b.Element(e);this.sync(this.element);this.bind(this.preview)},preview:function(){switch(this.method){case"refresh":return this.previewer.refresh();case"postMessage":return this.previewer.send("setting",[this.id,this()])}}});b.Control=b.Class.extend({initialize:function(i,e){var g=this,d,h,f;this.params={};c.extend(this,e||{});this.id=i;this.selector="#customize-control-"+i.replace("]","").replace("[","-");this.container=c(this.selector);f=c.map(this.params.settings,function(j){return j});b.apply(b,f.concat(function(){var j;g.settings={};for(j in g.params.settings){g.settings[j]=b(g.params.settings[j])}g.setting=g.settings["default"]||null;g.ready()}));g.elements=[];d=this.container.find("[data-customize-setting-link]");h={};d.each(function(){var k=c(this),j;if(k.is(":radio")){j=k.prop("name");if(h[j]){return}h[j]=true;k=d.filter('[name="'+j+'"]')}b(k.data("customizeSettingLink"),function(m){var l=new b.Element(k);g.elements.push(l);l.sync(m);l.set(m())})})},ready:function(){}});b.ColorControl=b.Control.extend({ready:function(){var g=this,d,e,f,h,i;d=this.container.find(".color-picker-toggle");e=d.find(".color-picker-spot");f=this.container.find(".color-picker-control");i=function(j){j="#"+j;e.css("background",j);g.farbtastic.setColor(j)};d.on("click",function(j){f.toggle();d.toggleClass("open");j.preventDefault()});this.farbtastic=c.farbtastic(this.container.find(".farbtastic-placeholder"),function(j){g.setting.set(j.replace("#",""))});this.setting.bind(i);i(this.setting())}});b.UploadControl=b.Control.extend({ready:function(){var d=this;this.params.removed=this.params.removed||"";this.uploader=new wp.Uploader({browser:this.container.find(".upload"),success:function(e){d.setting.set(e.url)}});this.remover=this.container.find(".remove");this.remover.click(function(e){d.setting.set(d.params.removed);e.preventDefault()});this.removerVisibility=c.proxy(this.removerVisibility,this);this.setting.bind(this.removerVisibility);this.removerVisibility(this.setting.get());if(this.params.context){d.uploader.param("post_data[context]",this.params.context)}},removerVisibility:function(d){this.remover.toggle(d!=this.params.removed)}});b.ImageControl=b.UploadControl.extend({ready:function(){var d=this;b.UploadControl.prototype.ready.call(this);this.thumbnail=this.container.find(".thumbnail img");this.thumbnailSrc=c.proxy(this.thumbnailSrc,this);this.setting.bind(this.thumbnailSrc);this.library=this.container.find(".library");this.changer=this.container.find(".change");this.changer.click(function(e){d.library.toggle();e.preventDefault()});this.library.on("click","li",function(f){var e=c(this),g=e.data("customizeTab");f.preventDefault();if(e.hasClass("library-selected")){return}e.siblings(".library-selected").removeClass("library-selected");e.addClass("library-selected");d.library.find("div").hide().filter(function(){return c(this).data("customizeTab")===g}).show()});this.library.on("click","a",function(e){d.setting.set(c(this).attr("href"));e.preventDefault()})},thumbnailSrc:function(d){if(/^(https?:)?\/\//.test(d)){this.thumbnail.prop("src",d).show()}else{this.thumbnail.hide()}}});b.defaultConstructor=b.Setting;b.control=new b.Values({defaultConstructor:b.Control});b.Previewer=b.Messenger.extend({refreshBuffer:250,initialize:function(f,e){var d=this;c.extend(this,e||{});this.loaded=c.proxy(this.loaded,this);this.loaderUuid=0;this.refresh=(function(g){var h=g.refresh,j=function(){i=null;h.call(g)},i;return function(){if(typeof i!=="number"){if(g.loading){g.loading.remove();delete g.loading;g.loader()}else{return j()}}clearTimeout(i);i=setTimeout(j,g.refreshBuffer)}})(this);this.iframe=b.ensure(f.iframe);this.form=b.ensure(f.form);this.name=this.iframe.prop("name");this.container=this.iframe.parent();b.Messenger.prototype.initialize.call(
|