Make WordPress Core

Changeset 21962


Ignore:
Timestamp:
09/24/2012 02:18:15 AM (14 years ago)
Author:
koopersmith
Message:

Improve documentation for wp.mce.view.add(). Store view id in view options. see #21812.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/mce-view.js

    r21961 r21962  
    2121                // Accepts a unique `id` and an `options` object.
    2222                //
    23                 // `options`
    24                 // If `view` is an object, it will automatically be passed to
    25                 // `wp.mce.View.extend( view, properties )` to create a new view class.
     23                // `options` accepts the following properties:
    2624                //
    27                 // If the `view` provided is already a constructor, the `properties`
    28                 // variable is ignored.
     25                // `pattern` is the regular expression used to scan the content and
     26                // detect matching views.
     27                //
     28                // `view` is a `Backbone.View` constructor. If a plain object is
     29                // provided, it will automatically extend the parent constructor
     30                // (usually `Backbone.View`). Views are instantiated when the `pattern`
     31                // is successfully matched. The instance's `options` object is provided
     32                // with the `original` matched value, the match `results` including
     33                // capture groups, and the `viewType`, which is the constructor's `id`.
     34                //
     35                // `extend` an existing view by passing in its `id`. The current
     36                // view will inherit all properties from the parent view, and if
     37                // `view` is set to a plain object, it will extend the parent `view`
     38                // constructor.
     39                //
     40                // `text` is a method that accepts an instance of the `view`
     41                // constructor and transforms it into a text representation.
    2942                add: function( id, options ) {
    3043                        var parent;
    … …  
    3548                        // Extend the `options` object with the parent's properties.
    3649                        _.defaults( options, parent );
     50                        options.id = id;
    3751
    3852                        // If the `view` provided was an object, automatically create
Note: See TracChangeset for help on using the changeset viewer.