2012-10-12 00:58:47 +02:00
|
|
|
window.wp=window.wp||{};(function(){wp.html=_.extend(wp.html||{},{attrs:function(c){var a,b;if("/"===c[c.length-1]){c=c.slice(0,-1)}a=wp.shortcode.attrs(c);b=a.named;_.each(a.numeric,function(d){if(/\s/.test(d)){return}b[d]=""});return b},string:function(a){var c="<"+a.tag,b=a.content||"";_.each(a.attrs,function(e,d){c+=" "+d;if(""===e){return}if(_.isBoolean(e)){e=e?"true":"false"}c+='="'+e+'"'});if(a.single){return c+" />"}c+=">";c+=_.isObject(b)?wp.html.string(b):b;return c+"</"+a.tag+">"}})}());(function(b){var a={},c={};wp.mce=wp.mce||{};wp.mce.view={defaults:{pattern:{view:Backbone.View,text:function(d){return d.options.original},toView:function(e){if(!this.pattern){return}this.pattern.lastIndex=0;var d=this.pattern.exec(e);if(!d){return}return{index:d.index,content:d[0],options:{original:d[0],results:d}}}},shortcode:{view:Backbone.View,text:function(d){return d.options.shortcode.string()},toView:function(e){var d=wp.shortcode.next(this.shortcode,e);if(!d){return}return{index:d.index,content:d.content,options:{shortcode:d.shortcode}}}}},add:function(i,e){var g,d,h,f;if(e.extend){g=wp.mce.view.get(e.extend)}else{if(e.shortcode){g=wp.mce.view.defaults.shortcode}else{g=wp.mce.view.defaults.pattern}}_.defaults(e,g);e.id=i;f={remove:function(){delete c[this.el.id];this.$el.parent().remove();if(d){d.apply(this,arguments)}return this}};if(_.isFunction(e.view)){h=e.view}else{h=g.view;d=e.view.remove;_.defaults(f,e.view)}if(!d&&!h._mceview){d=h.prototype.remove}e.view=h.extend(f,{_mceview:true});a[i]=e},get:function(d){return a[d]},remove:function(d){delete a[d]},toViews:function(e){var d=[{content:e}],f;_.each(a,function(h,g){f=d.slice();d=[];_.each(f,function(k){var j=k.content,i;if(k.processed){d.push(k);return}while(j&&(i=h.toView(j))){if(i.index){d.push({content:j.substring(0,i.index)})}d.push({content:wp.mce.view.toView(g,i.options),processed:true});j=j.slice(i.index+i.content.length)}if(j){d.push({content:j})}})});return _.pluck(d,"content").join("")},toView:function(f,h){var g=wp.mce.view.get(f),e,i,d;if(!g){return""}e=new g.view(_.extend(h||{},{viewType:f}));i=e.el.id=e.el.id||_.uniqueId("__wpmce-");c[i]=e;d="span"===e.tagName?"span":"div";return"<"+d+' class="wp-view-wrap" data-wp-view="'+i+'" contenteditable="false"></'+d+">"},render:function(d){b(".wp-view-wrap",d).each(function(){var g=b(this),f=g.data("wp-view"),e=c[f];if(!e){return}e.render();e.$el.detach();g.empty().append(e.el).append('<span data-wp-view-end class="wp-view-end"></span>')})},toText:function(d){return d.replace(/<(?:div|span)[^>]+data-wp-view="([^"]+)"[^>]*>.*?<span[^>]+data-wp-view-end[^>]*><\/span><\/(?:div|span)>/g,function(g,h){var e=c[h],f;if(e){f=wp.mce.view.get(e.options.viewType)}return e&&f?f.text(e):""})},removeInternalAttrs:function(e){var d={};_.each(e,function(g,f){if(-1===f.indexOf("data-mce")){d[f]=g}});return d},attrs:function(d){return wp.mce.view.removeInternalAttrs(wp.html.attrs(d))},l10n:_.isUndefined(_wpMceViewL10n)?{}:_wpMceViewL10n}}(jQuery));(function(b){var a=wp.mce.view;wp.media.string={};wp.media.string.link=function(e){var d=getUserSetting("urlbutton","post"),c={tag:"a",content:e.get("title")||e.get("filename"),attrs:{rel:"attachment wp-att-"+e.id}};c.attrs.href=(d==="file")?e.get("url"):e.get("link");return wp.html.string(c)};wp.media.string.image=function(h,g){var f,c,d,e;h=h.toJSON();g=_.defaults(g||{},{img:{},align:getUserSetting("align","none"),size:getUserSetting("imgsize","medium"),link:getUserSetting("urlbutton","post")});c=_.clone(g.img);f=c["class"]?c["class"].split(/\s+/):[];e=h.sizes?h.sizes[g.size]:{};if(!e){delete g.size;e=h}c.width=e.width;c.height=e.height;c.src=e.url;if(g.align){f.push("align"+g.align)}if(g.size){f.push("size-"+g.size)}f.push("wp-image-"+h.id);c["class"]=_.compact(f).join(" ");d={tag:"img",attrs:c,single:true};if(g.anchor){d={tag:"a",attrs:g.anchor,content:d}}return wp.html.string(d)};a.add("attachment",{pattern:new RegExp("(?:<a([^>]*)>)?<img([^>]*class=(?:\"[^\"]*|'[^']*)\\bwp-image-(\\d+)[^>]*)>(?:</a>)?"),text:function(c){var d=_.pick(c,"align","size","link","img","anchor");ret
|