mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 08:36:04 +01:00
e7f164297f
git-svn-id: http://core.svn.wordpress.org/trunk@21964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
1.2 KiB
JavaScript
1 line
1.2 KiB
JavaScript
if(typeof wp==="undefined"){var wp={}}(function(b){var a={},c={};wp.mce={};wp.mce.view={defaults:{view:Backbone.View,text:function(d){return d.options.original}},add:function(f,d){var e;e=d.extend?wp.mce.view.get(d.extend):wp.mce.view.defaults;_.defaults(d,e);d.id=f;if(!_.isFunction(d.view)){d.view=e.view.extend(d.view)}a[f]=d},get:function(d){return a[d]},remove:function(d){delete a[d]},toViews:function(d){_.each(a,function(f,e){if(!f.pattern){return}d=d.replace(f.pattern,function(i){var h,j,g;h=new f.view({original:i,results:_.toArray(arguments),viewType:e});j=h.el.id=h.el.id||_.uniqueId("__wpmce-");c[j]=h;g="span"===h.tagName?"span":"div";return"<"+g+' class="wp-view-wrap" data-wp-view="'+j+'" contenteditable="false"></'+g+">"})});return 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></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):""})}}}(jQuery)); |