web/wp-includes/js/customize-base.js
author Anthony Ly <anthonyly.com@gmail.com>
Wed, 19 Dec 2012 17:50:20 -0800
changeset 205 a4f7897e21a9
parent 204 09a1c134465b
permissions -rw-r--r--
dump sql
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
204
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     1
window.wp = window.wp || {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     2
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     3
(function( exports, $ ){
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     4
	var api, extend, ctor, inherits,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     5
		slice = Array.prototype.slice;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     6
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     7
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     8
	 * Micro-inheritance - thank you, backbone.js.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
     9
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    10
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    11
	extend = function( protoProps, classProps ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    12
		var child = inherits( this, protoProps, classProps );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    13
		child.extend = this.extend;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    14
		return child;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    15
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    16
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    17
	// Shared empty constructor function to aid in prototype-chain creation.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    18
	ctor = function() {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    19
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    20
	// Helper function to correctly set up the prototype chain, for subclasses.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    21
	// Similar to `goog.inherits`, but uses a hash of prototype properties and
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    22
	// class properties to be extended.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    23
	inherits = function( parent, protoProps, staticProps ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    24
		var child;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    25
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    26
		// The constructor function for the new subclass is either defined by you
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    27
		// (the "constructor" property in your `extend` definition), or defaulted
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    28
		// by us to simply call `super()`.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    29
		if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    30
			child = protoProps.constructor;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    31
		} else {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    32
			child = function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    33
				// Storing the result `super()` before returning the value
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    34
				// prevents a bug in Opera where, if the constructor returns
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    35
				// a function, Opera will reject the return value in favor of
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    36
				// the original object. This causes all sorts of trouble.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    37
				var result = parent.apply( this, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    38
				return result;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    39
			};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    40
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    41
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    42
		// Inherit class (static) properties from parent.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    43
		$.extend( child, parent );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    44
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    45
		// Set the prototype chain to inherit from `parent`, without calling
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    46
		// `parent`'s constructor function.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    47
		ctor.prototype  = parent.prototype;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    48
		child.prototype = new ctor();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    49
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    50
		// Add prototype properties (instance properties) to the subclass,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    51
		// if supplied.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    52
		if ( protoProps )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    53
			$.extend( child.prototype, protoProps );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    54
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    55
		// Add static properties to the constructor function, if supplied.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    56
		if ( staticProps )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    57
			$.extend( child, staticProps );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    58
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    59
		// Correctly set child's `prototype.constructor`.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    60
		child.prototype.constructor = child;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    61
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    62
		// Set a convenience property in case the parent's prototype is needed later.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    63
		child.__super__ = parent.prototype;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    64
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    65
		return child;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    66
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    67
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    68
	api = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    69
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    70
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    71
	 * Base class.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    72
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    73
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    74
	api.Class = function( applicator, argsArray, options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    75
		var magic, args = arguments;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    76
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    77
		if ( applicator && argsArray && api.Class.applicator === applicator ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    78
			args = argsArray;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    79
			$.extend( this, options || {} );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    80
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    81
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    82
		magic = this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    83
		if ( this.instance ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    84
			magic = function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    85
				return magic.instance.apply( magic, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    86
			};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    87
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    88
			$.extend( magic, this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    89
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    90
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    91
		magic.initialize.apply( magic, args );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    92
		return magic;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    93
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    94
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    95
	api.Class.applicator = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    96
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    97
	api.Class.prototype.initialize = function() {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    98
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
    99
	/*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   100
	 * Checks whether a given instance extended a constructor.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   101
	 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   102
	 * The magic surrounding the instance parameter causes the instanceof
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   103
	 * keyword to return inaccurate results; it defaults to the function's
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   104
	 * prototype instead of the constructor chain. Hence this function.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   105
	 */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   106
	api.Class.prototype.extended = function( constructor ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   107
		var proto = this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   108
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   109
		while ( typeof proto.constructor !== 'undefined' ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   110
			if ( proto.constructor === constructor )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   111
				return true;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   112
			if ( typeof proto.constructor.__super__ === 'undefined' )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   113
				return false;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   114
			proto = proto.constructor.__super__;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   115
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   116
		return false;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   117
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   118
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   119
	api.Class.extend = extend;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   120
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   121
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   122
	 * Events mixin.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   123
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   124
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   125
	api.Events = {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   126
		trigger: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   127
			if ( this.topics && this.topics[ id ] )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   128
				this.topics[ id ].fireWith( this, slice.call( arguments, 1 ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   129
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   130
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   131
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   132
		bind: function( id, callback ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   133
			this.topics = this.topics || {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   134
			this.topics[ id ] = this.topics[ id ] || $.Callbacks();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   135
			this.topics[ id ].add.apply( this.topics[ id ], slice.call( arguments, 1 ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   136
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   137
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   138
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   139
		unbind: function( id, callback ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   140
			if ( this.topics && this.topics[ id ] )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   141
				this.topics[ id ].remove.apply( this.topics[ id ], slice.call( arguments, 1 ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   142
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   143
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   144
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   145
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   146
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   147
	 * Observable values that support two-way binding.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   148
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   149
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   150
	api.Value = api.Class.extend({
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   151
		initialize: function( initial, options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   152
			this._value = initial; // @todo: potentially change this to a this.set() call.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   153
			this.callbacks = $.Callbacks();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   154
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   155
			$.extend( this, options || {} );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   156
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   157
			this.set = $.proxy( this.set, this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   158
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   159
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   160
		/*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   161
		 * Magic. Returns a function that will become the instance.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   162
		 * Set to null to prevent the instance from extending a function.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   163
		 */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   164
		instance: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   165
			return arguments.length ? this.set.apply( this, arguments ) : this.get();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   166
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   167
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   168
		get: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   169
			return this._value;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   170
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   171
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   172
		set: function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   173
			var from = this._value;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   174
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   175
			to = this._setter.apply( this, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   176
			to = this.validate( to );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   177
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   178
			// Bail if the sanitized value is null or unchanged.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   179
			if ( null === to || this._value === to )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   180
				return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   181
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   182
			this._value = to;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   183
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   184
			this.callbacks.fireWith( this, [ to, from ] );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   185
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   186
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   187
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   188
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   189
		_setter: function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   190
			return to;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   191
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   192
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   193
		setter: function( callback ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   194
			var from = this.get();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   195
			this._setter = callback;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   196
			// Temporarily clear value so setter can decide if it's valid.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   197
			this._value = null;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   198
			this.set( from );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   199
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   200
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   201
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   202
		resetSetter: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   203
			this._setter = this.constructor.prototype._setter;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   204
			this.set( this.get() );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   205
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   206
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   207
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   208
		validate: function( value ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   209
			return value;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   210
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   211
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   212
		bind: function( callback ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   213
			this.callbacks.add.apply( this.callbacks, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   214
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   215
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   216
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   217
		unbind: function( callback ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   218
			this.callbacks.remove.apply( this.callbacks, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   219
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   220
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   221
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   222
		link: function() { // values*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   223
			var set = this.set;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   224
			$.each( arguments, function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   225
				this.bind( set );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   226
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   227
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   228
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   229
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   230
		unlink: function() { // values*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   231
			var set = this.set;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   232
			$.each( arguments, function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   233
				this.unbind( set );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   234
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   235
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   236
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   237
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   238
		sync: function() { // values*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   239
			var that = this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   240
			$.each( arguments, function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   241
				that.link( this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   242
				this.link( that );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   243
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   244
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   245
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   246
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   247
		unsync: function() { // values*
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   248
			var that = this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   249
			$.each( arguments, function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   250
				that.unlink( this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   251
				this.unlink( that );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   252
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   253
			return this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   254
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   255
	});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   256
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   257
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   258
	 * A collection of observable values.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   259
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   260
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   261
	api.Values = api.Class.extend({
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   262
		defaultConstructor: api.Value,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   263
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   264
		initialize: function( options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   265
			$.extend( this, options || {} );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   266
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   267
			this._value = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   268
			this._deferreds = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   269
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   270
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   271
		instance: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   272
			if ( arguments.length === 1 )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   273
				return this.value( id );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   274
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   275
			return this.when.apply( this, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   276
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   277
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   278
		value: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   279
			return this._value[ id ];
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   280
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   281
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   282
		has: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   283
			return typeof this._value[ id ] !== 'undefined';
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   284
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   285
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   286
		add: function( id, value ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   287
			if ( this.has( id ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   288
				return this.value( id );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   289
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   290
			this._value[ id ] = value;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   291
			value.parent = this;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   292
			if ( value.extended( api.Value ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   293
				value.bind( this._change );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   294
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   295
			this.trigger( 'add', value );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   296
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   297
			if ( this._deferreds[ id ] )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   298
				this._deferreds[ id ].resolve();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   299
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   300
			return this._value[ id ];
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   301
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   302
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   303
		create: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   304
			return this.add( id, new this.defaultConstructor( api.Class.applicator, slice.call( arguments, 1 ) ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   305
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   306
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   307
		each: function( callback, context ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   308
			context = typeof context === 'undefined' ? this : context;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   309
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   310
			$.each( this._value, function( key, obj ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   311
				callback.call( context, obj, key );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   312
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   313
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   314
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   315
		remove: function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   316
			var value;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   317
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   318
			if ( this.has( id ) ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   319
				value = this.value( id );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   320
				this.trigger( 'remove', value );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   321
				if ( value.extended( api.Value ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   322
					value.unbind( this._change );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   323
				delete value.parent;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   324
			}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   325
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   326
			delete this._value[ id ];
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   327
			delete this._deferreds[ id ];
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   328
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   329
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   330
		/**
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   331
		 * Runs a callback once all requested values exist.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   332
		 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   333
		 * when( ids*, [callback] );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   334
		 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   335
		 * For example:
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   336
		 *     when( id1, id2, id3, function( value1, value2, value3 ) {} );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   337
		 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   338
		 * @returns $.Deferred.promise();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   339
		 */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   340
		when: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   341
			var self = this,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   342
				ids  = slice.call( arguments ),
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   343
				dfd  = $.Deferred();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   344
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   345
			// If the last argument is a callback, bind it to .done()
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   346
			if ( $.isFunction( ids[ ids.length - 1 ] ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   347
				dfd.done( ids.pop() );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   348
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   349
			$.when.apply( $, $.map( ids, function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   350
				if ( self.has( id ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   351
					return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   352
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   353
				return self._deferreds[ id ] = self._deferreds[ id ] || $.Deferred();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   354
			})).done( function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   355
				var values = $.map( ids, function( id ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   356
						return self( id );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   357
					});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   358
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   359
				// If a value is missing, we've used at least one expired deferred.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   360
				// Call Values.when again to generate a new deferred.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   361
				if ( values.length !== ids.length ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   362
					// ids.push( callback );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   363
					self.when.apply( self, ids ).done( function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   364
						dfd.resolveWith( self, values );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   365
					});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   366
					return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   367
				}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   368
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   369
				dfd.resolveWith( self, values );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   370
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   371
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   372
			return dfd.promise();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   373
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   374
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   375
		_change: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   376
			this.parent.trigger( 'change', this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   377
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   378
	});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   379
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   380
	$.extend( api.Values.prototype, api.Events );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   381
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   382
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   383
	 * An observable value that syncs with an element.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   384
	 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   385
	 * Handles inputs, selects, and textareas by default.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   386
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   387
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   388
	api.ensure = function( element ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   389
		return typeof element == 'string' ? $( element ) : element;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   390
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   391
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   392
	api.Element = api.Value.extend({
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   393
		initialize: function( element, options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   394
			var self = this,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   395
				synchronizer = api.Element.synchronizer.html,
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   396
				type, update, refresh;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   397
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   398
			this.element = api.ensure( element );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   399
			this.events = '';
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   400
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   401
			if ( this.element.is('input, select, textarea') ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   402
				this.events += 'change';
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   403
				synchronizer = api.Element.synchronizer.val;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   404
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   405
				if ( this.element.is('input') ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   406
					type = this.element.prop('type');
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   407
					if ( api.Element.synchronizer[ type ] )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   408
						synchronizer = api.Element.synchronizer[ type ];
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   409
					if ( 'text' === type || 'password' === type )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   410
						this.events += ' keyup';
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   411
				} else if ( this.element.is('textarea') ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   412
					this.events += ' keyup';
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   413
				}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   414
			}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   415
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   416
			api.Value.prototype.initialize.call( this, null, $.extend( options || {}, synchronizer ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   417
			this._value = this.get();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   418
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   419
			update  = this.update;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   420
			refresh = this.refresh;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   421
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   422
			this.update = function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   423
				if ( to !== refresh.call( self ) )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   424
					update.apply( this, arguments );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   425
			};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   426
			this.refresh = function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   427
				self.set( refresh.call( self ) );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   428
			};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   429
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   430
			this.bind( this.update );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   431
			this.element.bind( this.events, this.refresh );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   432
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   433
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   434
		find: function( selector ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   435
			return $( selector, this.element );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   436
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   437
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   438
		refresh: function() {},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   439
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   440
		update: function() {}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   441
	});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   442
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   443
	api.Element.synchronizer = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   444
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   445
	$.each( [ 'html', 'val' ], function( i, method ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   446
		api.Element.synchronizer[ method ] = {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   447
			update: function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   448
				this.element[ method ]( to );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   449
			},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   450
			refresh: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   451
				return this.element[ method ]();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   452
			}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   453
		};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   454
	});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   455
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   456
	api.Element.synchronizer.checkbox = {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   457
		update: function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   458
			this.element.prop( 'checked', to );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   459
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   460
		refresh: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   461
			return this.element.prop( 'checked' );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   462
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   463
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   464
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   465
	api.Element.synchronizer.radio = {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   466
		update: function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   467
			this.element.filter( function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   468
				return this.value === to;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   469
			}).prop( 'checked', true );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   470
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   471
		refresh: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   472
			return this.element.filter( ':checked' ).val();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   473
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   474
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   475
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   476
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   477
	 * Messenger for postMessage.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   478
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   479
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   480
	$.support.postMessage = !! window.postMessage;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   481
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   482
	api.Messenger = api.Class.extend({
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   483
		add: function( key, initial, options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   484
			return this[ key ] = new api.Value( initial, options );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   485
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   486
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   487
		/**
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   488
		 * Initialize Messenger.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   489
		 *
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   490
		 * @param  {object} params        Parameters to configure the messenger.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   491
		 *         {string} .url          The URL to communicate with.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   492
		 *         {window} .targetWindow The window instance to communicate with. Default window.parent.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   493
		 *         {string} .channel      If provided, will send the channel with each message and only accept messages a matching channel.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   494
		 * @param  {object} options       Extend any instance parameter or method with this object.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   495
		 */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   496
		initialize: function( params, options ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   497
			// Target the parent frame by default, but only if a parent frame exists.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   498
			var defaultTarget = window.parent == window ? null : window.parent;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   499
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   500
			$.extend( this, options || {} );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   501
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   502
			this.add( 'channel', params.channel );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   503
			this.add( 'url', params.url || '' );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   504
			this.add( 'targetWindow', params.targetWindow || defaultTarget );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   505
			this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   506
				return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   507
			});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   508
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   509
			// Since we want jQuery to treat the receive function as unique
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   510
			// to this instance, we give the function a new guid.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   511
			//
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   512
			// This will prevent every Messenger's receive function from being
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   513
			// unbound when calling $.off( 'message', this.receive );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   514
			this.receive = $.proxy( this.receive, this );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   515
			this.receive.guid = $.guid++;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   516
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   517
			$( window ).on( 'message', this.receive );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   518
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   519
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   520
		destroy: function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   521
			$( window ).off( 'message', this.receive );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   522
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   523
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   524
		receive: function( event ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   525
			var message;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   526
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   527
			event = event.originalEvent;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   528
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   529
			if ( ! this.targetWindow() )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   530
				return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   531
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   532
			// Check to make sure the origin is valid.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   533
			if ( this.origin() && event.origin !== this.origin() )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   534
				return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   535
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   536
			message = JSON.parse( event.data );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   537
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   538
			// Check required message properties.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   539
			if ( ! message || ! message.id || typeof message.data === 'undefined' )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   540
				return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   541
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   542
			// Check if channel names match.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   543
			if ( ( message.channel || this.channel() ) && this.channel() !== message.channel )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   544
				return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   545
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   546
			this.trigger( message.id, message.data );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   547
		},
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   548
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   549
		send: function( id, data ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   550
			var message;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   551
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   552
			data = typeof data === 'undefined' ? null : data;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   553
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   554
			if ( ! this.url() || ! this.targetWindow() )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   555
				return;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   556
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   557
			message = { id: id, data: data };
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   558
			if ( this.channel() )
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   559
				message.channel = this.channel();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   560
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   561
			this.targetWindow().postMessage( JSON.stringify( message ), this.origin() );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   562
		}
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   563
	});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   564
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   565
	// Add the Events mixin to api.Messenger.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   566
	$.extend( api.Messenger.prototype, api.Events );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   567
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   568
	/* =====================================================================
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   569
	 * Core customize object.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   570
	 * ===================================================================== */
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   571
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   572
	api = $.extend( new api.Values(), api );
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   573
	api.get = function() {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   574
		var result = {};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   575
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   576
		this.each( function( obj, key ) {
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   577
			result[ key ] = obj.get();
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   578
		});
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   579
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   580
		return result;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   581
	};
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   582
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   583
	// Expose the API to the world.
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   584
	exports.customize = api;
09a1c134465b man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents: 194
diff changeset
   585
})( wp, jQuery );