Skip to content
Permalink
Browse files

Fixed code style in asynchronous publishing JavaScript code

  • Loading branch information...
dpobel committed Jul 30, 2014
1 parent 8b7e61e commit 72b677ac7db624dd2635bad3fd4d072b89e81af5
Showing with 59 additions and 70 deletions.
  1. +59 −70 design/standard/javascript/ezasynchronouspublishing.js
@@ -1,81 +1,70 @@
var eZAsynchronousPublishingApp = function() {
var ret = {};
var Y;
/* jshint camelcase: false */
/* global YUI3_config */
/* exported eZAsynchronousPublishingApp */
var eZAsynchronousPublishingApp = (function() {
var ret = {}, Y, publishQueueUpdater, ajaxURI,
yCallback = function (yui, result) {
Y = yui;
Y.on("contentready", function (e) {
updateStatus(Y);
publishQueueUpdater = Y.later(1000, null, updateStatus, null, true);
}, '#ezap-message-publishing');
},
updateStatus = function () {
Y.io.ez(ajaxURI, {
on: {
success: function (id, r) {
var status;

// Y.later object, used to stop the timer
var publishQueueUpdater;
if ( r.responseJSON.error_text ) {
toggle('#ezap-error');
Y.one('#ezap-error').setContent( r.responseJSON.error_text );
} else {
status = r.responseJSON.content.status;

var ajaxURI;

var yCallback = function( yui, result ) {
Y = yui;
Y.on( "contentready", function( e )
{
updateStatus( Y );
publishQueueUpdater = Y.later( 1000, null, updateStatus, null, true );
}, '#ezap-message-publishing' );

};

var updateStatus = function updateStatus()
{
Y.io.ez( ajaxUri, {
on: {success: function( id,r )
{
if ( r.responseJSON.error_text )
{
toggle( '#ezap-error' );
Y.one( '#ezap-error' ).setContent( r.responseJSON.error_text );
}
else
{
var status = r.responseJSON.content.status;
// publishing finished
if ( status == 'finished' )
{
if ( publishQueueUpdater ) {
publishQueueUpdater.cancel();
}

// publishing finished
if ( status == 'finished' )
{
if ( publishQueueUpdater != null )
publishQueueUpdater.cancel();
if ( ret.cfg.redirect_uri !== false ) {
window.location = ret.cfg.redirect_uri;
} else {
toggle('#ezap-message-finished');
Y.one('#ezap-message-finished #ezap-contentview-uri').set(
'href', r.responseJSON.content.node_uri
);
}
} else if ( status == 'deferred' ) {
// deferred to crontab
if ( publishQueueUpdater ) {
publishQueueUpdater.cancel();
}

if ( ret.cfg.redirect_uri != false )
{
window.location = ret.cfg.redirect_uri;
toggle('#ezap-message-deferred');
Y.one('#ezap-message-finished #ezap-contentview-uri').set(
'href', r.responseJSON.content.versionview_uri
);
}
else
{
toggle( '#ezap-message-finished' );
Y.one( '#ezap-message-finished #ezap-contentview-uri' )
.set( 'href', r.responseJSON.content.node_uri );
}
}
// deferred to crontab
else if ( status == 'deferred' )
{
if ( publishQueueUpdater != null )
publishQueueUpdater.cancel();

toggle( '#ezap-message-deferred' );
Y.one( '#ezap-message-finished #ezap-contentview-uri' )
.set( 'href', r.responseJSON.content.versionview_uri );
}
}
}
}
, method: 'GET'});
};

toggle = function( id ) {
Y.one( '.ezap-placeholder' ).setStyle( 'display', 'none' );
Y.one( id ).setStyle( 'display', 'block' );
}
},
method: 'GET'
});
},
toggle = function(id) {
Y.one('.ezap-placeholder').setStyle('display', 'none');
Y.one(id).setStyle('display', 'block');
};

ret.cfg = {}
ret.cfg = {};

ret.init = function()
{
ajaxUri = 'ezpublishingqueue::status::' + ret.cfg.contentobject_id + '::' + ret.cfg.version;
var ins = YUI( YUI3_config ).use('node', 'io-ez', yCallback );
}
ret.init = function() {
ajaxURI = 'ezpublishingqueue::status::' + ret.cfg.contentobject_id + '::' + ret.cfg.version;
YUI(YUI3_config).use('node', 'io-ez', yCallback);
};

return ret;
}();
})();

0 comments on commit 72b677a

Please sign in to comment.
You can’t perform that action at this time.