diff options
author | Andrew Nacin <nacin@git.wordpress.org> | 2013-08-07 05:25:25 +0000 |
---|---|---|
committer | Andrew Nacin <nacin@git.wordpress.org> | 2013-08-07 05:25:25 +0000 |
commit | b43712e0f79a9f5bea52217e06155e2f471c490c (patch) | |
tree | 23d331e7b2f29689571f03cfa5f9b7b3b6cafab8 /wp-includes/js/wp-util.js | |
parent | 5bbd08e1d17079a2e852517351f7405884a156b3 (diff) | |
download | wordpress-b43712e0f79a9f5bea52217e06155e2f471c490c.tar.gz wordpress-b43712e0f79a9f5bea52217e06155e2f471c490c.zip |
New develop.svn.wordpress.org repository based on the old core.svn repository.
* All WordPress files move to a src/ directory.
* New task runner (Grunt), configured to copy a built WordPress to build/.
* svn:ignore and .gitignore for Gruntfile.js, wp-config.php, and node.js.
* Remove Akismet external from develop.svn. Still exists in core.svn.
* Drop minified files from src/. The build process will now generate these.
props koop.
see #24976.
and see http://wp.me/p2AvED-1AI.
git-svn-id: https://develop.svn.wordpress.org/trunk@25001 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'wp-includes/js/wp-util.js')
-rw-r--r-- | wp-includes/js/wp-util.js | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/wp-includes/js/wp-util.js b/wp-includes/js/wp-util.js deleted file mode 100644 index 701ec3ea43..0000000000 --- a/wp-includes/js/wp-util.js +++ /dev/null @@ -1,105 +0,0 @@ -window.wp = window.wp || {}; - -(function ($) { - // Check for the utility settings. - var settings = typeof _wpUtilSettings === 'undefined' ? {} : _wpUtilSettings; - - /** - * wp.template( id ) - * - * Fetches a template by id. - * - * @param {string} id A string that corresponds to a DOM element with an id prefixed with "tmpl-". - * For example, "attachment" maps to "tmpl-attachment". - * @return {function} A function that lazily-compiles the template requested. - */ - wp.template = _.memoize(function ( id ) { - var compiled, - options = { - evaluate: /<#([\s\S]+?)#>/g, - interpolate: /\{\{\{([\s\S]+?)\}\}\}/g, - escape: /\{\{([^\}]+?)\}\}(?!\})/g, - variable: 'data' - }; - - return function ( data ) { - compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options ); - return compiled( data ); - }; - }); - - // wp.ajax - // ------ - // - // Tools for sending ajax requests with JSON responses and built in error handling. - // Mirrors and wraps jQuery's ajax APIs. - wp.ajax = { - settings: settings.ajax || {}, - - /** - * wp.ajax.post( [action], [data] ) - * - * Sends a POST request to WordPress. - * - * @param {string} action The slug of the action to fire in WordPress. - * @param {object} data The data to populate $_POST with. - * @return {$.promise} A jQuery promise that represents the request. - */ - post: function( action, data ) { - return wp.ajax.send({ - data: _.isObject( action ) ? action : _.extend( data || {}, { action: action }) - }); - }, - - /** - * wp.ajax.send( [action], [options] ) - * - * Sends a POST request to WordPress. - * - * @param {string} action The slug of the action to fire in WordPress. - * @param {object} options The options passed to jQuery.ajax. - * @return {$.promise} A jQuery promise that represents the request. - */ - send: function( action, options ) { - if ( _.isObject( action ) ) { - options = action; - } else { - options = options || {}; - options.data = _.extend( options.data || {}, { action: action }); - } - - options = _.defaults( options || {}, { - type: 'POST', - url: wp.ajax.settings.url, - context: this - }); - - return $.Deferred( function( deferred ) { - // Transfer success/error callbacks. - if ( options.success ) - deferred.done( options.success ); - if ( options.error ) - deferred.fail( options.error ); - - delete options.success; - delete options.error; - - // Use with PHP's wp_send_json_success() and wp_send_json_error() - $.ajax( options ).done( function( response ) { - // Treat a response of `1` as successful for backwards - // compatibility with existing handlers. - if ( response === '1' || response === 1 ) - response = { success: true }; - - if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) - deferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] ); - else - deferred.rejectWith( this, [response] ); - }).fail( function() { - deferred.rejectWith( this, arguments ); - }); - }).promise(); - } - }; - -}(jQuery)); |