2012-03-28 06:58:24 +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.element.link(this);this.link(this.element);this.bind(this.sync)},sync: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.container=c("#customize-control-"+i);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.link(m).bind(function(n){m(n)})})})},ready:function(){}});b.ColorControl=b.Control.extend({ready:function(){var g=this,e,f,h,d,i;e=this.container.find(".color-picker");f=e.find(".color-picker-controls");d=e.find("a");i=function(j){j="#"+j;d.css("background",j);g.farbtastic.setColor(j)};e.on("click","a",function(){f.toggle()});this.farbtastic=c.farbtastic(e.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(g,e,d){var f=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(h){f.library.toggle();h.preventDefault()});this.library.on("click","li",function(i){var h=c(this),j=h.data("customizeTab");i.preventDefault();if(h.hasClass("library-selected")){return}h.siblings(".library-selected").removeClass("library-selected");h.addClass("library-selected");f.library.find("div").hide().filter(function(){return c(this).data("customizeTab")===j}).show()});this.library.on("click","a",function(h){f.setting.set(c(this).attr("href"));h.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(e,d){c.extend(this,d||{});this.loaded=c.proxy(this.loaded,this);this.loaderUuid=0;this.refresh=(function(f){var g=f.refresh,i=function(){h=null;g.call(f)},h;return function(){if(typeof h!=="number"){if(f.loading){f.loading.remove();delete f.loading;f.loader()}else{return i()}}clearTimeout(h);h=setTimeout(i,f.refreshBuffer)}})(this);this.iframe=b.ensure(e.iframe);this.form=b.ensure(e.form);this.name=this.iframe.prop("name");this.container=this.iframe.parent();b.Messenger.prototype.initialize.call(this,e.url,this.iframe[0].contentWindow);this._formOriginalProps={target:this.form.prop("target"),action:this.form.prop("action")};this.bind("url",function(f){if(this
|