<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29450] trunk/src/wp-includes/js: Add some docs to Customizer JS.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/29450">29450</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-08-08 22:09:46 +0000 (Fri, 08 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add some docs to Customizer JS.

Props ericlewis.
See <a href="http://core.trac.wordpress.org/ticket/29157">#29157</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjscustomizebasejs">trunk/src/wp-includes/js/customize-base.js</a></li>
<li><a href="#trunksrcwpincludesjscustomizeloaderjs">trunk/src/wp-includes/js/customize-loader.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjscustomizebasejs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/customize-base.js (29449 => 29450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/customize-base.js       2014-08-08 21:17:15 UTC (rev 29449)
+++ trunk/src/wp-includes/js/customize-base.js  2014-08-08 22:09:46 UTC (rev 29450)
</span><span class="lines">@@ -1,25 +1,22 @@
</span><span class="cx"> window.wp = window.wp || {};
</span><span class="cx"> 
</span><span class="cx"> (function( exports, $ ){
</span><del>-       var api, extend, ctor, inherits,
</del><ins>+        var api = {}, ctor, inherits,
</ins><span class="cx">           slice = Array.prototype.slice;
</span><span class="cx"> 
</span><del>-       /* =====================================================================
-        * Micro-inheritance - thank you, backbone.js.
-        * ===================================================================== */
-
-       extend = function( protoProps, classProps ) {
-               var child = inherits( this, protoProps, classProps );
-               child.extend = this.extend;
-               return child;
-       };
-
</del><span class="cx">   // Shared empty constructor function to aid in prototype-chain creation.
</span><span class="cx">  ctor = function() {};
</span><span class="cx"> 
</span><del>-       // Helper function to correctly set up the prototype chain, for subclasses.
-       // Similar to `goog.inherits`, but uses a hash of prototype properties and
-       // class properties to be extended.
</del><ins>+        /**
+        * Helper function to correctly set up the prototype chain, for subclasses.
+        * Similar to `goog.inherits`, but uses a hash of prototype properties and
+        * class properties to be extended.
+        *
+        * @param  object parent      Parent class constructor to inherit from.
+        * @param  object protoProps  Properties to apply to the prototype for use as class instance properties.
+        * @param  object staticProps Properties to apply directly to the class constructor.
+        * @return child              The subclassed constructor.
+        */
</ins><span class="cx">   inherits = function( parent, protoProps, staticProps ) {
</span><span class="cx">          var child;
</span><span class="cx"> 
</span><span class="lines">@@ -65,12 +62,9 @@
</span><span class="cx">          return child;
</span><span class="cx">  };
</span><span class="cx"> 
</span><del>-       api = {};
-
-       /* =====================================================================
-        * Base class.
-        * ===================================================================== */
-
</del><ins>+        /**
+        * Base class for object inheritance.
+        */
</ins><span class="cx">   api.Class = function( applicator, argsArray, options ) {
</span><span class="cx">          var magic, args = arguments;
</span><span class="cx"> 
</span><span class="lines">@@ -92,6 +86,19 @@
</span><span class="cx">          return magic;
</span><span class="cx">  };
</span><span class="cx"> 
</span><ins>+       /**
+        * Creates a subclass of the class.
+        *
+        * @param  object protoProps  Properties to apply to the prototype.
+        * @param  object staticProps Properties to apply directly to the class.
+        * @return child              The subclass.
+        */
+       api.Class.extend = function( protoProps, classProps ) {
+               var child = inherits( this, protoProps, classProps );
+               child.extend = this.extend;
+               return child;
+       };
+
</ins><span class="cx">   api.Class.applicator = {};
</span><span class="cx"> 
</span><span class="cx">  api.Class.prototype.initialize = function() {};
</span><span class="lines">@@ -116,12 +123,11 @@
</span><span class="cx">          return false;
</span><span class="cx">  };
</span><span class="cx"> 
</span><del>-       api.Class.extend = extend;
-
-       /* =====================================================================
-        * Events mixin.
-        * ===================================================================== */
-
</del><ins>+        /**
+        * An events manager object, offering the ability to bind to and trigger events.
+        *
+        * Used as a mixin.
+        */
</ins><span class="cx">   api.Events = {
</span><span class="cx">          trigger: function( id ) {
</span><span class="cx">                  if ( this.topics && this.topics[ id ] )
</span><span class="lines">@@ -143,10 +149,11 @@
</span><span class="cx">          }
</span><span class="cx">  };
</span><span class="cx"> 
</span><del>-       /* =====================================================================
</del><ins>+        /**
</ins><span class="cx">    * Observable values that support two-way binding.
</span><del>-        * ===================================================================== */
-
</del><ins>+         *
+        * @constuctor
+        */
</ins><span class="cx">   api.Value = api.Class.extend({
</span><span class="cx">          initialize: function( initial, options ) {
</span><span class="cx">                  this._value = initial; // @todo: potentially change this to a this.set() call.
</span><span class="lines">@@ -254,10 +261,13 @@
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="cx"> 
</span><del>-       /* =====================================================================
</del><ins>+        /**
</ins><span class="cx">    * A collection of observable values.
</span><del>-        * ===================================================================== */
-
</del><ins>+         *
+        * @constuctor
+        * @augments wp.customize.Class
+        * @mixes wp.customize.Events
+        */
</ins><span class="cx">   api.Values = api.Class.extend({
</span><span class="cx">          defaultConstructor: api.Value,
</span><span class="cx"> 
</span><span class="lines">@@ -379,16 +389,25 @@
</span><span class="cx"> 
</span><span class="cx">  $.extend( api.Values.prototype, api.Events );
</span><span class="cx"> 
</span><del>-       /* =====================================================================
-        * An observable value that syncs with an element.
</del><ins>+
+       /**
+        * Cast a string to a jQuery collection if it isn't already.
</ins><span class="cx">    *
</span><del>-        * Handles inputs, selects, and textareas by default.
-        * ===================================================================== */
-
</del><ins>+         * @param {string|jQuery collection} element
+        */
</ins><span class="cx">   api.ensure = function( element ) {
</span><span class="cx">          return typeof element == 'string' ? $( element ) : element;
</span><span class="cx">  };
</span><span class="cx"> 
</span><ins>+       /**
+        * An observable value that syncs with an element.
+        *
+        * Handles inputs, selects, and textareas by default.
+        *
+        * @constuctor
+        * @augments wp.customize.Value
+        * @augments wp.customize.Class
+        */
</ins><span class="cx">   api.Element = api.Value.extend({
</span><span class="cx">          initialize: function( element, options ) {
</span><span class="cx">                  var self = this,
</span><span class="lines">@@ -442,7 +461,7 @@
</span><span class="cx"> 
</span><span class="cx">  api.Element.synchronizer = {};
</span><span class="cx"> 
</span><del>-       $.each( [ 'html', 'val' ], function( i, method ) {
</del><ins>+        $.each( [ 'html', 'val' ], function( index, method ) {
</ins><span class="cx">           api.Element.synchronizer[ method ] = {
</span><span class="cx">                  update: function( to ) {
</span><span class="cx">                          this.element[ method ]( to );
</span><span class="lines">@@ -473,13 +492,24 @@
</span><span class="cx">          }
</span><span class="cx">  };
</span><span class="cx"> 
</span><del>-       /* =====================================================================
-        * Messenger for postMessage.
-        * ===================================================================== */
-
</del><span class="cx">   $.support.postMessage = !! window.postMessage;
</span><span class="cx"> 
</span><ins>+       /**
+        * Messenger for postMessage.
+        *
+        * @constuctor
+        * @augments wp.customize.Class
+        * @mixes wp.customize.Events
+        */
</ins><span class="cx">   api.Messenger = api.Class.extend({
</span><ins>+               /**
+                * Create a new Value.
+                *
+                * @param  {string} key     Unique identifier.
+                * @param  {mixed}  initial Initial value.
+                * @param  {mixed}  options Options hash. Optional.
+                * @return {Value}          Class instance of the Value.
+                */
</ins><span class="cx">           add: function( key, initial, options ) {
</span><span class="cx">                  return this[ key ] = new api.Value( initial, options );
</span><span class="cx">          },
</span><span class="lines">@@ -570,10 +600,7 @@
</span><span class="cx">  // Add the Events mixin to api.Messenger.
</span><span class="cx">  $.extend( api.Messenger.prototype, api.Events );
</span><span class="cx"> 
</span><del>-       /* =====================================================================
-        * Core customize object.
-        * ===================================================================== */
-
</del><ins>+        // Core customize object.
</ins><span class="cx">   api = $.extend( new api.Values(), api );
</span><span class="cx">  api.get = function() {
</span><span class="cx">          var result = {};
</span><span class="lines">@@ -585,6 +612,6 @@
</span><span class="cx">          return result;
</span><span class="cx">  };
</span><span class="cx"> 
</span><del>-       // Expose the API to the world.
</del><ins>+        // Expose the API publicly on window.wp.customize
</ins><span class="cx">   exports.customize = api;
</span><span class="cx"> })( wp, jQuery );
</span></span></pre></div>
<a id="trunksrcwpincludesjscustomizeloaderjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/customize-loader.js (29449 => 29450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/customize-loader.js     2014-08-08 21:17:15 UTC (rev 29449)
+++ trunk/src/wp-includes/js/customize-loader.js        2014-08-08 22:09:46 UTC (rev 29450)
</span><span class="lines">@@ -10,7 +10,20 @@
</span><span class="cx">          hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7)
</span><span class="cx">  });
</span><span class="cx"> 
</span><ins>+       /**
+        * Allows the Customizer to be overlayed on any page.
+        *
+        * By default, any element in the body with the load-customize class will open
+        * the Customizer overlay with the URL specified.
+        *
+        *     e.g. <a class="load-customize" href="http://siteurl.com/2014/01/02/post">Open customizer</a>
+        *
+        * @augments wp.customize.Events
+        */
</ins><span class="cx">   Loader = $.extend( {}, api.Events, {
</span><ins>+               /**
+                * Setup the Loader; triggered on document#ready.
+                */
</ins><span class="cx">           initialize: function() {
</span><span class="cx">                  this.body = $( document.body );
</span><span class="cx"> 
</span><span class="lines">@@ -23,9 +36,12 @@
</span><span class="cx">                  this.window  = $( window );
</span><span class="cx">                  this.element = $( '<div id="customize-container" />' ).appendTo( this.body );
</span><span class="cx"> 
</span><ins>+                       // Bind events for opening and closing the overlay.
</ins><span class="cx">                   this.bind( 'open', this.overlay.show );
</span><span class="cx">                  this.bind( 'close', this.overlay.hide );
</span><span class="cx"> 
</span><ins>+                       // Any element in the body with the `load-customize` class opens
+                       // the Customizer.
</ins><span class="cx">                   $('#wpbody').on( 'click', '.load-customize', function( event ) {
</span><span class="cx">                          event.preventDefault();
</span><span class="cx"> 
</span><span class="lines">@@ -73,6 +89,11 @@
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Open the customizer overlay for a specific URL.
+                *
+                * @param  string src URL to load in the Customizer.
+                */
</ins><span class="cx">           open: function( src ) {
</span><span class="cx"> 
</span><span class="cx">                  if ( this.active ) {
</span><span class="lines">@@ -148,10 +169,16 @@
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Callback after the customizer has been opened.
+                */
</ins><span class="cx">           opened: function() {
</span><span class="cx">                  Loader.body.addClass( 'customize-active full-overlay-active' );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Close the Customizer overlay and return focus to the link that opened it.
+                */
</ins><span class="cx">           close: function() {
</span><span class="cx">                  if ( ! this.active ) {
</span><span class="cx">                          return;
</span><span class="lines">@@ -174,6 +201,9 @@
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Callback after the customizer has been closed.
+                */
</ins><span class="cx">           closed: function() {
</span><span class="cx">                  Loader.iframe.remove();
</span><span class="cx">                  Loader.messenger.destroy();
</span><span class="lines">@@ -184,10 +214,16 @@
</span><span class="cx">                  $( window ).off( 'beforeunload', Loader.beforeunload );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Callback for the `load` event on the Customizer iframe.
+                */
</ins><span class="cx">           loaded: function() {
</span><span class="cx">                  Loader.body.removeClass('customize-loading');
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Overlay hide/show utility methods.
+                */
</ins><span class="cx">           overlay: {
</span><span class="cx">                  show: function() {
</span><span class="cx">                          this.element.fadeIn( 200, Loader.opened );
</span><span class="lines">@@ -199,11 +235,12 @@
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="cx"> 
</span><ins>+       // Bootstrap the Loader on document#ready.
</ins><span class="cx">   $( function() {
</span><span class="cx">          Loader.settings = _wpCustomizeLoaderSettings;
</span><span class="cx">          Loader.initialize();
</span><span class="cx">  });
</span><span class="cx"> 
</span><del>-       // Expose the API to the world.
</del><ins>+        // Expose the API publicly on window.wp.customize.Loader
</ins><span class="cx">   api.Loader = Loader;
</span><span class="cx"> })( wp, jQuery );
</span></span></pre>
</div>
</div>

</body>
</html>