window.wp=window.wp||{},function(a,b,c){"use strict";function d(a){return g.innerHTML=a,a=g.value,g.innerHTML=g.value="",a}var e={},f={},g=document.createElement("textarea");b.mce=b.mce||{},b.mce.views={register:function(a,c){e[a]=b.mce.View.extend(_.extend(c,{type:a}))},unregister:function(a){delete e[a]},get:function(a){return e[a]},unbind:function(){_.each(f,function(a){a.unbind()})},setMarkers:function(a){var b,c=[{content:d(a)}],f=this;return _.each(e,function(a,d){b=c.slice(),c=[],_.each(b,function(b){var e,g=b.content;if(b.processed)return void c.push(b);for(;g&&(e=a.prototype.match(g));)e.index&&c.push({content:g.substring(0,e.index)}),f.createInstance(d,e.content,e.options),c.push({content:'
'+e.content+"
",processed:!0}),g=g.slice(e.index+e.content.length);g&&c.push({content:g})})}),_.pluck(c,"content").join("")},createInstance:function(a,b,c){var d=this.get(a),e=encodeURIComponent(b),g=this.getInstance(e);return g?g:(c=_.extend(c||{},{text:b,encodedText:e}),f[e]=new d(c))},getInstance:function(a){return"string"==typeof a?f[encodeURIComponent(a)]:f[c(a).data("wpview-text")]},getText:function(a){return decodeURIComponent(c(a).data("wpview-text")||"")},render:function(a){_.each(f,function(b){b.render(a)})},update:function(a,b,c){var d=this.getInstance(c);d&&d.update(a,b,c)},edit:function(a,b){var c=this.getInstance(b);c&&c.edit&&c.edit(c.text,function(d){c.update(d,a,b)})},remove:function(a,b){var c=this.getInstance(b);c&&c.remove(a,b)}},b.mce.View=function(a){_.extend(this,a),this.initialize()},b.mce.View.extend=Backbone.View.extend,_.extend(b.mce.View.prototype,{content:null,loader:!0,initialize:function(){},getContent:function(){return this.content},render:function(a){(this.loader||this.getContent())&&(a&&this.unbind(),this.replaceMarkers(),this.getContent()?this.setContent(this.getContent(),function(a,b){c(b).data("rendered",!0).trigger("wp-mce-view-bind")},a?null:!1):this.setLoader())},unbind:function(){this.getNodes(function(a,b){c(b).trigger("wp-mce-view-unbind")},!0)},getEditors:function(a){_.each(tinymce.editors,function(b){b.plugins.wpview&&a.call(this,b)},this)},getNodes:function(a,b){this.getEditors(function(d){var e=this;c(d.getBody()).find('[data-wpview-text="'+e.encodedText+'"]').filter(function(){var a;return null==b?!0:(a=c(this).data("rendered")===!0,b?a:!a)}).each(function(){a.call(e,d,this,c(this).find(".wpview-content").get(0))})})},getMarkers:function(a){this.getEditors(function(b){var d=this;c(b.getBody()).find('[data-wpview-marker="'+this.encodedText+'"]').each(function(){a.call(d,b,this)})})},replaceMarkers:function(){this.getMarkers(function(a,b){return c(b).text()!==this.text?void a.dom.setAttrib(b,"data-wpview-marker",null):void a.dom.replace(a.dom.createFragment('