AJS.toInit(function(e){var c,f=140;function b(){var m="idontthinksohal";var j=new AJS.Dialog(650,m,"update-user-status-dialog");var l=j.popup.element;var k=e(Confluence.Templates.UserStatus.dialogContent({maxChars:f}));j.addHeader("What are you working on?");j.addPanel("Set Status",k);j.addButton("Update",h,"status-update-button");j.addCancel("Cancel",function(n){n.hide();return false});j.setError=function(n){e(".error-message",l).html(n)};if(Confluence.KeyboardShortcuts&&Confluence.KeyboardShortcuts.enabled){j.addHelpText(AJS.format("Shortcut tip: Pressing \u003cb>{0}\u003c\/b> also opens this dialog box","s"))}return j}function g(k){var j;if(!k){j="You must enter a status."}else{if(!e.trim(k)){j="Whitespace is cool and all, but you might want to add a message in there, too."}else{if(k.length>f){j=AJS.format("The status message is too long. Status messages must be no longer than {0} characters.",f)}}}if(j){c.setError(j)}return !j}function d(j){e(".current-user-latest-status .status-text").html(j.text);e(".current-user-latest-status a[id^=view]").each(function(){var l=e(this),k=l.attr("href");l.attr("href",k.replace(/\d+$/,j.id)).text(j.friendlyDate).attr("title",new Date(j.date).toLocaleString())})}function i(){e.getJSON(Confluence.getContextPath()+"/status/current.action",function(j){if(j.errorMessage){c.setError(j.errorMessage)}else{d(j)}})}var h=function(){var m=c.popup.element,p=e("#status-text",m),k=e(".status-update-button",m),o=p.val(),j,n;function l(){p.blur();p.attr("disabled","disabled").attr("readonly","readonly");k.attr("disabled","disabled");return function(){p.focus();p.removeAttr("disabled").removeAttr("readonly");k.removeAttr("disabled")}}j=l();if(!g(o)){j();return false}n=AJS.safe.ajax({url:Confluence.getContextPath()+"/status/update.action",type:"POST",dataType:"json",data:{text:o}});n.done(j).fail(j);n.done(function(q){if(q.errorMessage){c.setError(q.errorMessage)}else{d(q);p.val("");m.fadeOut(200,function(){c.hide()})}});n.fail(function(s,r,q){AJS.log("Error updating status: "+r);AJS.log(q);c.setError("There was an error - "+q)});return n.promise()};var a=function(j){var l=j.popup.element,n=e("#status-text",l),m=e(".chars-left",l),k=e(".status-update-button",l);n.keydown(function(o){if(o.keyCode==13){h()}}).bind("blur focus change "+(!e.browser.msie?"paste input":"keyup"),function(){var p=e(this).val(),o=f-p.length;k[p.length?"removeAttr":"attr"]("disabled","disabled");m.text(Math.abs(o)).toggleClass("close-to-limit",o<20).toggleClass("over-limit",o<0)});e("form",l).submit(function(o){o.preventDefault();h()})};e("#set-user-status-link").click(function(k){var j=e(this).parents(".ajs-drop-down")[0];j&&j.hide();if(typeof c=="undefined"){c=b();a(c)}i();c.setError("");c.show();e("#update-user-status-dialog #status-text").removeAttr("readonly").removeAttr("disabled").focus();return AJS.stopEvent(k)})});
// This file was automatically generated from userstatus-dialog.soy.
// Please don't edit this file by hand.

if (typeof Confluence == 'undefined') { var Confluence = {}; }
if (typeof Confluence.Templates == 'undefined') { Confluence.Templates = {}; }
if (typeof Confluence.Templates.UserStatus == 'undefined') { Confluence.Templates.UserStatus = {}; }


Confluence.Templates.UserStatus.dialogContent = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<div><span class=\'error-message\'></span></div><form class="aui update-status"><fieldset><label for="status-text" class="assistive">', soy.$$escapeHtml(AJS.format("Enter your status ({0} character limit)",opt_data.maxChars)), '</label><textarea name="status-text" id="status-text"></textarea><span class="chars-left">', soy.$$escapeHtml(opt_data.maxChars), '</span></fieldset><p id="dialog-current-status" class="current-user-latest-status"><strong>', soy.$$escapeHtml("Last update:"), '</strong> <span class="status-text"></span></p></form>');
  if (!opt_sb) return output.toString();
};


