From f4478ab647a04d680c18f7d69338ca4c8f556e41 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Mon, 24 Sep 2012 02:18:15 +0000 Subject: [PATCH] Improve documentation for wp.mce.view.add(). Store view id in view options. see #21812. git-svn-id: http://core.svn.wordpress.org/trunk@21962 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/mce-view.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index f46181f193..a1954a6c13 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -20,12 +20,25 @@ if ( typeof wp === 'undefined' ) // // Accepts a unique `id` and an `options` object. // - // `options` - // If `view` is an object, it will automatically be passed to - // `wp.mce.View.extend( view, properties )` to create a new view class. + // `options` accepts the following properties: // - // If the `view` provided is already a constructor, the `properties` - // variable is ignored. + // `pattern` is the regular expression used to scan the content and + // detect matching views. + // + // `view` is a `Backbone.View` constructor. If a plain object is + // provided, it will automatically extend the parent constructor + // (usually `Backbone.View`). Views are instantiated when the `pattern` + // is successfully matched. The instance's `options` object is provided + // with the `original` matched value, the match `results` including + // capture groups, and the `viewType`, which is the constructor's `id`. + // + // `extend` an existing view by passing in its `id`. The current + // view will inherit all properties from the parent view, and if + // `view` is set to a plain object, it will extend the parent `view` + // constructor. + // + // `text` is a method that accepts an instance of the `view` + // constructor and transforms it into a text representation. add: function( id, options ) { var parent; @@ -34,6 +47,7 @@ if ( typeof wp === 'undefined' ) // Extend the `options` object with the parent's properties. _.defaults( options, parent ); + options.id = id; // If the `view` provided was an object, automatically create // a new `Backbone.View` constructor, using the parent's `view`