All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.jira-global.js Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
jQuery.namespace=function(str,noclobber){var i,a=str.split("."),o=window,callthrough=false;if(/[^a-zA-Z.]/.test(str)){return false}for(i=0;i0&&modifiers!=="shift+"){var key=keyEntered(e);if(key){return modifiers+key}}}}};function modifier(modifier){return modifier+"+"}})(AJS.$);
(function($){$.namespace("jira.mouse");jira.mouse;var MotionDetector=jira.mouse.MotionDetector=function(){this.reset()};MotionDetector.prototype.reset=function(){this._handler=null;this._x=null;this._y=null;this.moved=false};MotionDetector.prototype.wait=function(eventHandler){var instance=this;if(!instance._handler){this.reset();$(window.top.document).bind("mousemove",instance._handler=function(e){if(!instance._x&&!instance._y){instance._x=e.pageX;instance._y=e.pageY}else{if(!(e.pageX===instance._x&&e.pageY===instance._y)){instance.unbind();instance.moved=true;if(eventHandler){eventHandler.call(this,e)}}}})}};MotionDetector.prototype.unbind=function(){if(this._handler){$(window.top.document).unbind("mousemove",this._handler);this.reset()}}})(AJS.$);
AJS.copyObject=function(object,deep){var copiedObject={};AJS.$.each(object,function(name,property){if(typeof property!=="object"||property===null||property instanceof AJS.$){copiedObject[name]=property}else{if(deep!==false){copiedObject[name]=AJS.copyObject(property,deep)}}});return copiedObject};
AJS.implementsInterface=function(object,implementation){var valid=true;AJS.$.each(implementation,function(i,method){if(!AJS.$.isFunction(object[method])){valid=false;throw new Error("AJS.implementsInteface: Expected method ["+method+"] on object")}});return valid};
AJS.$.namespace("jira.app.fragments.issueActionsFragment");jira.app.fragments.issueActionsFragment=function(){function addIssueIdToReturnUrl(issueId){var matchSelectedIssueId=/selectedIssueId=[0-9]*/g;if(self!=top){return encodeURIComponent(window.top.location.href)}var url=window.location.href,newUrl=url;if(/selectedIssueId=[0-9]*/.test(url)){newUrl=url.replace(matchSelectedIssueId,"selectedIssueId="+issueId)}else{if(url.lastIndexOf("?")>=0){newUrl=url+"&"}else{newUrl=url+"?"}newUrl=newUrl+"selectedIssueId="+issueId}return encodeURIComponent(newUrl)}return function(json){var returnURL=addIssueIdToReturnUrl(json.id);var htmlParts=['
"];var hasActions=json.actions&&json.actions.length>0;var hasOperations=json.operations&&json.operations.length>0;if(hasActions){htmlParts.push(hasOperations?'
    ':'
      ');var URL_A=contextPath+"/secure/WorkflowUIDispatcher.jspa?id="+json.id+"&action=";var URL_B="&atl_token="+json.atlToken+"&returnUrl="+returnURL;AJS.$.each(json.actions,function(){htmlParts.push('
    • ',htmlEscape(this.name),"
    • ")});htmlParts.push("
    ")}if(hasOperations){htmlParts.push('
      ');URL_A="&returnUrl="+returnURL;URL_B="&atl_token="+json.atlToken;AJS.$.each(json.operations,function(){htmlParts.push('
    • ',htmlEscape(this.name),"
    • ")});htmlParts.push("
    ")}htmlParts.push("
");return AJS.$(htmlParts.join(""))}}(); (function($){$.namespace("jira.ajax");jira.ajax.SmartAjaxResult=function(xhr,requestId,statusText,data,successful,errorThrown){var status=tryIt(function(){return xhr.status},0);var result={successful:successful,status:status,statusText:statusText,errorThrown:errorThrown,readyState:xhr.readyState,hasData:data!=null&&data.length>0,data:data,xhr:xhr,aborted:xhr.aborted,requestId:requestId};result.toString=function(){return"{\n"+"successful : "+this.successful+",\n"+"status : "+this.status+",\n"+"statusText : "+this.statusText+",\n"+"hasData : "+this.hasData+",\n"+"readyState : "+this.readyState+",\n"+"requestId : "+this.requestId+",\n"+"aborted : "+this.aborted+",\n"+"}"};return result};jira.ajax.SmartAjaxResult.ERROR="error";jira.ajax.SmartAjaxResult.TIMEOUT="timeout";jira.ajax.SmartAjaxResult.NOTMODIFIED="notmodified";jira.ajax.SmartAjaxResult.PARSEERROR="parseerror";jira.ajax.makeRequest=function(ajaxOptions){var _smartAjaxResult={};var log=function(calltype,requestId,msg){if(AJS.log){var id=requestId?"["+requestId+"] ":" ";AJS.log("ajax"+id+calltype+" : "+msg)}};var generateRequestId=function(){var now=new Date();var midnight=new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0,0);var ms=(now.getTime()-midnight.getTime());return Math.max(Math.floor(ms),1)};var errorHandler=function(xhr,statusText,errorThrown,smartAjaxResult){if(!smartAjaxResult){var data=tryIt(function(){return xhr.responseText},"");smartAjaxResult=_smartAjaxResult=new jira.ajax.SmartAjaxResult(xhr,_requestId,statusText,data,false,errorThrown)}log("error",smartAjaxResult.requestId,smartAjaxResult);if($.isFunction(ajaxOptions.error)){ajaxOptions.error(xhr,statusText,errorThrown,smartAjaxResult)}};var successHandler=function(data,statusText,xhr){if(xhr.status<100){_smartAjaxResult=new jira.ajax.SmartAjaxResult(xhr,_requestId,jira.ajax.SmartAjaxResult.ERROR,"",false);errorHandler(xhr,jira.ajax.SmartAjaxResult.ERROR,undefined,_smartAjaxResult);return}_smartAjaxResult=new jira.ajax.SmartAjaxResult(xhr,_requestId,statusText,data,true);log("success",_smartAjaxResult.requestId,_smartAjaxResult);if($.isFunction(ajaxOptions.success)){ajaxOptions.success(data,statusText,xhr,_smartAjaxResult)}};var completeHandler=function(xhr,textStatus){if($.isFunction(ajaxOptions.complete)){ajaxOptions.complete(xhr,textStatus,_smartAjaxResult)}};var ourAjaxOptions={};for(var x in ajaxOptions){ourAjaxOptions[x]=ajaxOptions[x]}ourAjaxOptions.error=errorHandler;ourAjaxOptions.success=successHandler;ourAjaxOptions.complete=completeHandler;var xhr=$.ajax(ourAjaxOptions);var _requestId=generateRequestId();try{xhr.abort=function(oldabort){return function(){log("aborted",_requestId,"");xhr.aborted=true;if($.isFunction(oldabort)){try{oldabort.call(xhr)}catch(ex){}}}}(xhr.abort)}catch(ex){}log("started",_requestId,""+ourAjaxOptions.url);return xhr};jira.ajax.buildDialogErrorContent=function(smartAjaxResult,noHeader){var fourHundredClass=Math.floor(smartAjaxResult.status/100);if(smartAjaxResult.hasData&&fourHundredClass!=4){return wrapDialogErrorContent(AJS.extractBodyFromResponse(smartAjaxResult.data))}else{var errMsg=buildRawHttpErrorMessage(smartAjaxResult);return buildDialogAjaxErrorMessage(errMsg,noHeader)}};jira.ajax.buildSimpleErrorContent=function(smartAjaxResult){return buildRawHttpErrorMessage(smartAjaxResult)};function buildRawHttpErrorMessage(smartAjaxResult){var AJS=window.top.AJS;var errMsg;if(smartAjaxResult.statusText==jira.ajax.SmartAjaxResult.TIMEOUT){errMsg=AJS.params.ajaxTimeout}else{if(smartAjaxResult.status==401){errMsg=AJS.params.ajaxUnauthorised}else{if(smartAjaxResult.hasData){errMsg=AJS.params.ajaxServerError}else{errMsg=AJS.params.ajaxCommsError}}}return errMsg}function buildDialogAjaxErrorMessage(errorMessage,noHeader){var errorContent='
'+"

"+errorMessage+"

"+"

"+AJS.params.ajaxErrorCloseDialog+"

"+"
";if(!noHeader){errorContent="

"+AJS.params.ajaxErrorDialogHeading+"

"+errorContent}return wrapDialogErrorContent(errorContent)}function wrapDialogErrorContent(content){var $container=$('
');$container.append(content);return $container}})(AJS.$);AJS.$(function(){AJS.$.ajaxSetup({timeout:60000,async:true,cache:false,global:true})}); AJS.parseUri=function(uri,strict){var unesc=window.decodeURIComponent||unescape;var esc=window.encodeURIComponent||escape;function parseUri(str){var o=parseUri.options,m=o.parser[o.strictMode?"strict":"loose"].exec(str),uri={},i=14;while(i--){uri[o.key[i]]=m[i]||""}uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function($0,$1,$2){if($1){uri[o.q.name][unesc($1)]=unesc($2)}});return uri}parseUri.options={strictMode:!!strict,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};uri=parseUri(uri);uri.toString=function(){var params=[];AJS.$.each(uri.queryKey,function(name,value){params.push(esc(name)+"="+esc(value))});return uri.protocol+"://"+uri.authority+uri.path+"?"+params.join("&")+"#"+uri.anchor};return uri}; jQuery.effects||(function($){$.effects={};$.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(i,attr){$.fx.step[attr]=function(fx){if(!fx.colorInit){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end);fx.colorInit=true}fx.elem.style[attr]="rgb("+Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0],10),255),0)+","+Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1],10),255),0)+","+Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2],10),255),0)+")"}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3){return color}if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)){return[parseInt(result[1],10),parseInt(result[2],10),parseInt(result[3],10)]}if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)){return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55]}if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)){return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)]}if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)){return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)]}if(result=/rgba\(0, 0, 0, 0\)/.exec(color)){return colors["transparent"]}return colors[$.trim(color).toLowerCase()]}function getColor(elem,attr){var color;do{color=$.curCSS(elem,attr);if(color!=""&&color!="transparent"||$.nodeName(elem,"body")){break}attr="backgroundColor"}while(elem=elem.parentNode);return getRGB(color)}var colors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]};var classAnimationActions=["add","remove","toggle"],shorthandStyles={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};function getElementStyles(){var style=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,newStyle={},key,camelCase;if(style&&style.length&&style[0]&&style[style[0]]){var len=style.length;while(len--){key=style[len];if(typeof style[key]=="string"){camelCase=key.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase()});newStyle[camelCase]=style[key]}}}else{for(key in style){if(typeof style[key]==="string"){newStyle[key]=style[key]}}}return newStyle}function filterStyles(styles){var name,value;for(name in styles){value=styles[name];if(value==null||$.isFunction(value)||name in shorthandStyles||(/scrollbar/).test(name)||(!(/color/i).test(name)&&isNaN(parseFloat(value)))){delete styles[name]}}return styles}function styleDifference(oldStyle,newStyle){var diff={_:0},name;for(name in newStyle){if(oldStyle[name]!=newStyle[name]){diff[name]=newStyle[name]}}return diff}$.effects.animateClass=function(value,duration,easing,callback){if($.isFunction(easing)){callback=easing;easing=null}return this.each(function(){var that=$(this),originalStyleAttr=that.attr("style")||" ",originalStyle=filterStyles(getElementStyles.call(this)),newStyle,className=that.attr("className");$.each(classAnimationActions,function(i,action){if(value[action]){that[action+"Class"](value[action])}});newStyle=filterStyles(getElementStyles.call(this));that.attr("className",className);that.animate(styleDifference(originalStyle,newStyle),duration,easing,function(){$.each(classAnimationActions,function(i,action){if(value[action]){that[action+"Class"](value[action])}});if(typeof that.attr("style")=="object"){that.attr("style").cssText="";that.attr("style").cssText=originalStyleAttr}else{that.attr("style",originalStyleAttr)}if(callback){callback.apply(this,arguments)}})})};$.fn.extend({_addClass:$.fn.addClass,addClass:function(classNames,speed,easing,callback){return speed?$.effects.animateClass.apply(this,[{add:classNames},speed,easing,callback]):this._addClass(classNames)},_removeClass:$.fn.removeClass,removeClass:function(classNames,speed,easing,callback){return speed?$.effects.animateClass.apply(this,[{remove:classNames},speed,easing,callback]):this._removeClass(classNames)},_toggleClass:$.fn.toggleClass,toggleClass:function(classNames,force,speed,easing,callback){if(typeof force=="boolean"||force===undefined){if(!speed){return this._toggleClass(classNames,force)}else{return $.effects.animateClass.apply(this,[(force?{add:classNames}:{remove:classNames}),speed,easing,callback])}}else{return $.effects.animateClass.apply(this,[{toggle:classNames},force,speed,easing])}},switchClass:function(remove,add,speed,easing,callback){return $.effects.animateClass.apply(this,[{add:add,remove:remove},speed,easing,callback])}});$.extend($.effects,{version:"1.8rc3",save:function(element,set){for(var i=0;i
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});element.wrap(wrapper);wrapper=element.parent();if(element.css("position")=="static"){wrapper.css({position:"relative"});element.css({position:"relative"})}else{$.extend(props,{position:element.css("position"),zIndex:element.css("z-index")});$.each(["top","left","bottom","right"],function(i,pos){props[pos]=element.css(pos);if(isNaN(parseInt(props[pos],10))){props[pos]="auto"}});element.css({position:"relative",top:0,left:0})}return wrapper.css(props).show()},removeWrapper:function(element){if(element.parent().is(".ui-effects-wrapper")){return element.parent().replaceWith(element)}return element},setTransition:function(element,list,factor,value){value=value||{};$.each(list,function(i,x){unit=element.cssUnit(x);if(unit[0]>0){value[x]=unit[0]*factor+unit[1]}});return value}});function _normalizeArguments(effect,options,speed,callback){if(typeof effect=="object"){callback=options;speed=null;options=effect;effect=options.effect}if($.isFunction(options)){callback=options;speed=null;options={}}if(typeof options=="number"||$.fx.speeds[options]){callback=speed;speed=options;options={}}options=options||{};speed=speed||options.duration;speed=$.fx.off?0:typeof speed=="number"?speed:$.fx.speeds[speed]||$.fx.speeds._default;callback=callback||options.complete;return[effect,options,speed,callback]}$.fn.extend({effect:function(effect,options,speed,callback){var args=_normalizeArguments.apply(this,arguments),args2={options:args[1],duration:args[2],callback:args[3]},effectMethod=$.effects[effect];return effectMethod&&!$.fx.off?effectMethod.call(this,args2):this},_show:$.fn.show,show:function(speed){if(!speed||typeof speed=="number"||$.fx.speeds[speed]){return this._show.apply(this,arguments)}else{var args=_normalizeArguments.apply(this,arguments);args[1].mode="show";return this.effect.apply(this,args)}},_hide:$.fn.hide,hide:function(speed){if(!speed||typeof speed=="number"||$.fx.speeds[speed]){return this._hide.apply(this,arguments)}else{var args=_normalizeArguments.apply(this,arguments);args[1].mode="hide";return this.effect.apply(this,args)}},__toggle:$.fn.toggle,toggle:function(speed){if(!speed||typeof speed=="number"||$.fx.speeds[speed]||typeof speed=="boolean"||$.isFunction(speed)){return this.__toggle.apply(this,arguments)}else{var args=_normalizeArguments.apply(this,arguments);args[1].mode="toggle";return this.effect.apply(this,args)}},cssUnit:function(key){var style=this.css(key),val=[];$.each(["em","px","%","pt"],function(i,unit){if(style.indexOf(unit)>0){val=[parseFloat(style),unit]}});return val}});$.easing.jswing=$.easing.swing;$.extend($.easing,{def:"easeOutQuad",swing:function(x,t,b,c,d){return $.easing[$.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return -c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1){return c/2*t*t+b}return -c/2*((--t)*(t-2)-1)+b},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t+b}return c/2*((t-=2)*t*t+2)+b},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b},easeOutQuart:function(x,t,b,c,d){return -c*((t=t/d-1)*t*t*t-1)+b},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t*t+b}return -c/2*((t-=2)*t*t*t-2)+b},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t*t*t+b}return c/2*((t-=2)*t*t*t*t+2)+b},easeInSine:function(x,t,b,c,d){return -c*Math.cos(t/d*(Math.PI/2))+c+b},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b},easeInOutSine:function(x,t,b,c,d){return -c/2*(Math.cos(Math.PI*t/d)-1)+b},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b},easeInOutExpo:function(x,t,b,c,d){if(t==0){return b}if(t==d){return b+c}if((t/=d/2)<1){return c/2*Math.pow(2,10*(t-1))+b}return c/2*(-Math.pow(2,-10*--t)+2)+b},easeInCirc:function(x,t,b,c,d){return -c*(Math.sqrt(1-(t/=d)*t)-1)+b},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1){return -c/2*(Math.sqrt(1-t*t)-1)+b}return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0){return b}if((t/=d)==1){return b+c}if(!p){p=d*0.3}if(a1){var interfaces=AJS.$.makeArray(arguments);prop=interfaces.pop();var completeInterface;AJS.$.each(interfaces,function(i,inter){if(completeInterface){completeInterface=completeInterface.extend(inter)}else{completeInterface=inter}});return completeInterface.extend(this.prototype).extend(prop)}else{prop=arguments[0]}initializing=true;var prototype=new this();initializing=false;for(var name in prop){if(prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])){prototype[name]=(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name])}else{if(typeof _super[name]==="object"){var newObj=begetObject(prop[name]);AJS.$.each(_super[name],function(name,obj){if(!newObj[name]){newObj[name]=obj}else{if(typeof newObj[name]==="object"){var newSubObj=begetObject(newObj[name]);AJS.$.each(obj,function(subName,subObj){if(!newSubObj[subName]){newSubObj[subName]=subObj}});newObj[name]=newSubObj}}});prototype[name]=newObj}else{prototype[name]=prop[name]}}}function Class(){if(!initializing&&this.init){this.init.apply(this,arguments)}}Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class}})();var Interface=Class.extend({}); AJS.Event=Class.extend({init:function(options){this.$target=AJS.$(options.target);this.eventOwner=options.eventOwner},getEventInterface:function(){var instance=this;return{target:function(){return instance.$target},eventOwner:function(){return instance.eventOwner}}},fire:function(){var event=new AJS.$.Event(this.EVENT_NAME);AJS.$(this.$target).trigger(event,[this.getEventInterface()]);return event.result}});AJS.ContentChangeEvent=AJS.Event.extend({EVENT_NAME:"contentChange"}); jQuery.fn.scrollIntoView=function(options){if(this.length>0){options=options||{};options.marginTop=options.marginTop||options.margin||0;options.marginBottom=options.marginBottom||options.margin||0;var $window=window.top.jQuery(window.top);var $stalker=window.top.jQuery("#stalker");var scrollTop=$window.scrollTop();var scrollHeight=$window.height();var offsetTop=Math.max(0,getPageY(this[0])-options.marginTop);var offsetHeight=options.marginTop+this.outerHeight()+options.marginBottom;var newScrollTop=scrollTop;if(newScrollTop+scrollHeight0){offsetTop-=$stalker.outerHeight()+35}if(newScrollTop>offsetTop){newScrollTop=offsetTop}if(newScrollTop!==scrollTop){var $target=this;var $document=window.top.jQuery(window.top.document);$document.trigger("moveToStarted",$target);$document.find("body, html").stop(true).animate({scrollTop:newScrollTop},options.duration||100,"swing",function(){if(options.callback){options.callback()}$document.trigger("moveToFinished",$target);$stalker.trigger("positionChanged")})}else{if(options.callback){options.callback()}}}return this;function getPageY(element){var offsetTop=0;do{offsetTop+=element.offsetTop}while(element=element.offsetParent);return offsetTop}}; jQuery.getDocHeight=function(){return Math.max(jQuery(document).height(),jQuery(window).height(),document.documentElement.clientHeight)}; AJS.containDropdown=function(dropdown,containerSelector,dynamic){function getDropdownOffset(){return dropdown.$.offset().top-jQuery(containerSelector).offset().top}var container,ddOffset,availableArea,shadowOffset=25;if(dropdown.$.parents(containerSelector).length!==-1){container=jQuery(containerSelector),ddOffset=getDropdownOffset(),shadowOffset=30,availableArea=container.outerHeight()-ddOffset-shadowOffset;if(availableArea<=parseInt(dropdown.$.attr("scrollHeight"),10)){AJS.containDropdown.containHeight(dropdown,availableArea)}else{if(dynamic){AJS.containDropdown.releaseContainment(dropdown)}}dropdown.reset()}};AJS.containDropdown.containHeight=function(dropdown,availableArea){dropdown.$.css({height:availableArea});if(dropdown.$.css("overflowY")!=="scroll"){dropdown.$.css({width:15+dropdown.$.attr("scrollWidth"),overflowY:"scroll",overflowX:"hidden"})}};AJS.containDropdown.releaseContainment=function(dropdown){dropdown.$.css({height:"",width:"",overflowY:"",overflowX:""})}; (function(){var eventsToListenTo="input keyup propertychange";jQuery.fn.expandOnInput=function(maxHeight){var $textareas=this.filter("textarea");$textareas.unbind(eventsToListenTo,setHeight).bind(eventsToListenTo,setHeight);if(AJS.$.browser.mozilla||AJS.$.browser.msie){$textareas.unbind("paste",triggerKeyup).bind("paste",triggerKeyup)}$textareas.unbind("refreshInputHeight").bind("refreshInputHeight",function(){setHeight.call(AJS.$(this).css("height",""))});$textareas.data("expandOnInput_maxHeight",maxHeight);$textareas.each(function(){if(AJS.$(this).val()!==""){setHeight.call(this)}});return this};function triggerKeyup(){var $textarea=AJS.$(this),textarea=this;setTimeout(function(){$textarea.keyup();textarea.scrollTop=textarea.scrollHeight},0)}function setHeight(){var $textarea=AJS.$(this),height=parseInt($textarea.css("height"),10)||$textarea.height(),padding=$textarea.attr("clientHeight")-height;this.scrollHeight;var maxHeight=parseInt($textarea.css("maxHeight"),10)||$textarea.data("expandOnInput_maxHeight")||AJS.$(window).height()-160,newHeight=Math.max(height,this.scrollHeight-padding);if(newHeight=0){if(isNotActive(that[targ])){idx=targ;focusElement(that[idx])}}else{targ=that.length-1;if(isNotActive(that[targ])){idx=targ;focusElement(that[idx])}}}else{if(e.keyCode===39){targ=idx+1;if(targ0){AJS.$(opts.onFocusRemoveClass).removeClass(clss[1]);onDisable=function(){AJS.$(elem).addClass(clss[1])}}}enabled=true;idx=AJS.$.inArray(this,that);that.mouseover(focusBridge);if(AJS.$.browser.mozilla){AJS.$(document).keypress(keyHandler)}else{AJS.$(document).keydown(keyHandler)}AJS.$(document).mousedown(that.disableLinkedMenu);if(opts.reflectFocus){AJS.$(opts.reflectFocus).mouseover(reflectionBridge)}}};that.disableLinkedMenu=function(e){AJS.$(document).unbind("keypress",keyHandler);AJS.$(document).unbind("keydown",keyHandler);that.unbind("mouseover",focusBridge);AJS.$(document).unbind("mousedown",arguments.callee);if(opts.reflectFocus){AJS.$(opts.reflectFocus).unbind("mouseover",reflectionBridge)}if(onDisable){onDisable()}that.blur();delete AJS.$.currentLinkedMenu;window.setTimeout(function(){enabled=false},200)};opts=opts||{};that.click(enable);return that}; if(!this.JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapeable.lastIndex=0;return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==="string"){return c}return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(typeof value.length==="number"&&!value.propertyIsEnumerable("length")){length=value.length;for(i=0;i=0){return}var topWindow=getWindow().AJS;if(topWindow.currentLayerItem&&item!==topWindow.currentLayerItem&&topWindow.currentLayerItem.type!=="popup"){topWindow.currentLayerItem.hide()}if(item){topWindow.currentLayerItem=item;topWindow.currentLayerItem.type=type}}).bind("hideLayer",function(e,type,item){if(!item||item.id&&item.id.indexOf("user-hover-dialog")>=0){return}var topWindow=getWindow().AJS;if(topWindow.currentLayerItem){if(topWindow.currentLayerItem===item){topWindow.currentLayerItem=null}else{if(jQuery.contains(getLayer(item),getLayer(topWindow.currentLayerItem))){topWindow.currentLayerItem.hide()}}}}).bind("hideAllLayers",function(){var topWindow=getWindow().AJS;if(topWindow.currentLayerItem){topWindow.currentLayerItem.hide()}}).click(function(e){var topWindow=getWindow().AJS;if(topWindow.currentLayerItem&&topWindow.currentLayerItem.type!=="popup"){if(topWindow.currentLayerItem._validateClickToClose){if(topWindow.currentLayerItem._validateClickToClose(e)){topWindow.currentLayerItem.hide()}}else{topWindow.currentLayerItem.hide()}}})}$doc.bind("iframeAppended",function(e,iframe){iframe=jQuery(iframe);iframe.load(function(){listenForLayerEvents(iframe.contents())})});listenForLayerEvents($doc)})(); (function(){AJS.parseOptionsFromFieldset=function($fieldset){var parsedValues=parseFieldset($fieldset,$fieldset);$fieldset.remove();return parsedValues};function parseFieldset($fieldset,$parentFieldset){var ret={};$fieldset.children().each(function(){var itemValue,$item=jQuery(this);if($item.is("input[type=hidden]")){itemValue=parseValue($item);ret[itemValue.id]=itemValue.value}else{if($item.is("fieldset")){ret[$item.attr("title")||$item.attr("id")]=parseFieldset($item,$parentFieldset)}else{$item.insertBefore($parentFieldset)}}});return ret}function parseValue($item){var itemValue={},value=$item.val();itemValue.id=$item.attr("title")||$item.attr("id");itemValue.value=(value.match(/^(tru|fals)e$/i)?value.toLowerCase()=="true":value);return itemValue}})(); jQuery.fn.getOptionsFromAttributes=function(){var options={};if(this.length){jQuery.each(this[0].attributes,function(){var map,nodeValue=this.nodeValue,target=options;if(/^data-/.test(this.nodeName)){map=this.nodeName.replace(/^data-/,"").split("."),AJS.$.each(map,function(i,propertyName){propertyName=propertyName.replace(/([a-z])-([a-z])/gi,function(entireMatch,firstMatch,secondMatch){return firstMatch+secondMatch.toUpperCase()});propertyName=propertyName.replace(/_([a-z]+)/gi,function(entireMatch,firstMatch){return firstMatch.toUpperCase()});if(i===map.length-1){target[propertyName]=nodeValue.match(/^(tru|fals)e$/i)?nodeValue.toLowerCase()=="true":nodeValue}else{if(!target[propertyName]){target[propertyName]={}}}target=target[propertyName]})}})}return options}; AJS.Control=Class.extend({INVALID:"INVALID",_throwReadOnlyError:function(property){new Error(this.CLASS_SIGNATURE+": Sorry ["+property+"] is a read-only property")},_assignEvents:function(group,target){var key,handlers;var instance=this;this._activeEvents=this._activeEvents||{};if(typeof target==="string"){key=group+"/"+target;if(this._activeEvents[key]){return}handlers=this._activeEvents[key]={};AJS.$.each(this._events[group],function(eventType,handler){handlers[eventType]=function(event){handler.call(instance,event,AJS.$(this))};AJS.$(document).delegate(target,eventType,handlers[eventType])})}else{target=AJS.$(target);if(target.length===0){return}if(this._activeEvents[group+"/"+target[0][AJS.$.expando]]){return}handlers={};AJS.$.each(this._events[group],function(eventType,handler){handlers[eventType]=function(event){handler.call(instance,event,AJS.$(this))};target.bind(eventType,handlers[eventType])});key=group+"/"+(target[0]===window?"window":target[0][AJS.$.expando]);this._activeEvents[key]=handlers}},_unassignEvents:function(group,target){var key,handlers,eventType;this._activeEvents=this._activeEvents||{};if(typeof target==="string"){key=group+"/"+target;handlers=this._activeEvents[key];if(!handlers){return}for(eventType in handlers){AJS.$(document).undelegate(target,eventType,handlers[eventType])}}else{target=AJS.$(target);if(target.length===0){return}key=group+"/"+target[0][AJS.$.expando];handlers=this._activeEvents[key];if(!handlers){return}try{for(eventType in handlers){target.unbind(eventType,handlers[eventType])}}catch(error){var events=AJS.$.data(target[0],"events");if(events){for(eventType in handlers){var $handlers=events[eventType];if(!$handlers){continue}var i=$handlers.length;while(i--){if($handlers[i].handler===handlers[eventType]){$handlers.splice(i,1);if($handlers.length===0){delete events[eventType]}break}}}}}}delete this._activeEvents[key]},_isValidInput:function(){return true},_handleKeyEvent:function(e){var instance=this;if(instance._isValidInput(e)){var SpecialKey=jira.keyboard.SpecialKey,shortcut=jira.keyboard.shortcutEntered(e);if(shortcut){if(instance.keys[shortcut]){instance.keys[shortcut].call(instance,e);return}else{if((shortcut===SpecialKey.BACKSPACE||shortcut===SpecialKey.DELETE)&&instance.keys.onEdit){instance.keys.onEdit.call(instance,e);return}}}var character=jira.keyboard.characterEntered(e);if(character&&instance.keys.onEdit){instance.keys.onEdit.call(instance,e,character)}}},getCustomEventName:function(methodName){return(this.CLASS_SIGNATURE||"")+"_"+methodName},_getCustomEventArgs:function(){return[this]},trigger:function(event){event=new jQuery.Event(event);AJS.$(this).trigger(event);return !event.isDefaultPrevented()},_supportsBoxShadow:function(){var s=document.body.style;return s.WebkitBoxShadow!==undefined||s.MozBoxShadow!==undefined||s.boxShadow!==undefined},_setOptions:function(options){var element,optionsFromDOM;options=options||{};if(options instanceof AJS.$||typeof options==="string"){options={element:options}}element=AJS.$(options.element);optionsFromDOM=element.getOptionsFromAttributes();this.options=AJS.$.extend(true,this._getDefaultOptions(options),optionsFromDOM,options);if(element.length===0){return this.INVALID}},getCaret:function(node){var startIndex=node.selectionStart;if(startIndex>=0){return(node.selectionEnd>startIndex)?-1:startIndex}if(document.selection){var textRange1=document.selection.createRange();if(textRange1.text.length===0){var textRange2=textRange1.duplicate();textRange2.moveToElementText(node);textRange2.setEndPoint("EndToStart",textRange1);return textRange2.text.length}}return -1},_render:function(){var i,name=arguments[0],args=[];for(i=1;i0){var i=(Math.max(0,this.index)+this.items.length+offset)%this.items.length;this.items[i].trigger("focus")}},_events:{"instance":{"focus":function(){if(this.items.length===0){return}if(this.index<0){this.items[0].trigger("focus")}else{this._assignEvents("keys",document)}},"blur":function(){if(this.index>=0){this.items[this.index].trigger("blur")}else{this._unassignEvents("keys",document)}}},"keys":{"keydown keypress":function(event){this._handleKeyEvent(event)}},"item":{"focus":function(event){var index=this.index;this.index=AJS.$.inArray(event.target,this.items);if(index<0){this.trigger("focus")}else{if(index!==this.index){this.items[index].trigger("blur")}}},"blur":function(event){if(this.index===AJS.$.inArray(event.target,this.items)){this.index=-1;this.trigger("blur")}},"remove":function(event){this.removeItem(event.target)}}},keys:{}}); AJS.ListItemGroup=AJS.Group.extend({keys:{"up":function(event){this.shiftFocus(-1);event.preventDefault()},"down":function(event){this.shiftFocus(1);event.preventDefault()},"return":function(event){this.items[this.index].trigger("accept");event.preventDefault()}}}); AJS.LozengeGroup=AJS.Group.extend({keys:{"left":function(){if(this.index>0){this.shiftFocus(-1)}},"right":function(){if(this.index===this.items.length-1){this.items[this.index].trigger("blur")}else{this.shiftFocus(1)}},"backspace":function(){var index=this.index;if(index>0){this.shiftFocus(-1)}else{if(this.items.length>1){this.shiftFocus(1)}}this.items[index].trigger("remove")},"del":function(){var index=this.index;if(index+1")},"removeButton":function(){return AJS.$('')}},_events:{"instance":{"focus":function(){this.$lozenge.addClass(this.options.focusClass)},"blur":function(){this.$lozenge.removeClass(this.options.focusClass)},"remove":function(){this.$lozenge.remove()}},"lozenge":{"click":function(){this.trigger("focus")}},"removeButton":{"click":function(){this.trigger("remove")}}}}); AJS.ListItem=AJS.Control.extend({init:function(options){this._setOptions(options);this.$element=AJS.$(this.options.element);this.hasFocus=false;this._assignEvents("instance",this);this._assignEvents("element",this.$element)},_getDefaultOptions:function(){return{element:null,focusClass:AJS.ACTIVE_CLASS}},_events:{"instance":{"focus":function(event){this.hasFocus=true;this.$element.addClass(this.options.focusClass);if(!event.noscrolling){AJS.ListItem.MOTION_DETECTOR.unbind();this.$element.scrollIntoView(AJS.ListItem.SCROLL_INTO_VIEW_OPTIONS)}},"blur":function(){this.hasFocus=false;this.$element.removeClass(this.options.focusClass)},"accept":function(){var event=new jQuery.Event("click");var $target=this.$element.is("a[href]")?this.$element:this.$element.find("a[href]");$target.trigger(event);if(!event.isDefaultPrevented()){window.top.location=$target.attr("href")}}},"element":{"mousemove":function(){if(AJS.ListItem.MOTION_DETECTOR.moved&&!this.hasFocus){this.trigger({type:"focus",noscrolling:true})}}}}});AJS.ListItem.MOTION_DETECTOR=new jira.mouse.MotionDetector();AJS.ListItem.SCROLL_INTO_VIEW_OPTIONS={duration:100,callback:function(){AJS.ListItem.MOTION_DETECTOR.wait()}}; AJS.InlineLayer=AJS.Control.extend({CLASS_SIGNATURE:"AJS_InlineLayer",SCROLL_HIDE_EVENT:"scroll.hide-dropdown",init:function(options){var instance=this;if(!(options instanceof AJS.InlineLayer.Descriptor)){this.options=new AJS.InlineLayer.Descriptor(options)}else{this.options=options}this.offsetTarget(this.options.offsetTarget());this.contentRetriever=this.options.contentRetriever();this.positionController=this.options.positioningController();if(!(this.contentRetriever instanceof AJS.ContentRetrieverInterface)){throw new Error("AJS.InlineLayer: Failed construction, Content retriever does not implement interface "+"[AJS.ContentRetrieverInterface]")}this.contentRetriever.startingRequest(function(){instance._showLoading()});this.contentRetriever.finishedRequest(function(){instance._hideLoading()});this.$layer=this._render("layer",this.options.alignment())},content:function(arg){var instance=this;if(AJS.$.isFunction(arg)){if(this.contentRetriever.isLocked()){throw new Error(this.CLASS_SIGNATURE+".content() : Illegal operation, trying to access content while it is "+"locked. If you are seeing this error it is most likely because we are waiting for an request to "+"come back from the server that builds content")}this.contentRetriever.content(function(content){instance.$content=content;arg.call(instance)})}else{return this.$content}},offsetTarget:function(offsetTarget){if(offsetTarget){this.$offsetTarget=AJS.$(offsetTarget)}else{return this.$offsetTarget}},contentChange:function(callback){var event,instance=this;if(AJS.$.isFunction(callback)){if(!this.contentChangeCallback){this.contentChangeCallback=[]}this.contentChangeCallback.push(callback)}else{if(!callback&&this.contentChangeCallback){AJS.$.each(this.contentChangeCallback,function(i,callback){callback(instance)});event=new AJS.ContentChangeEvent({target:this.layer(),eventOwner:AJS.InlineLayer});event.fire()}}},onhide:function(callback){var instance=this;if(AJS.$.isFunction(callback)){if(!this.hideCallback){this.hideCallback=[]}this.hideCallback.push(callback)}else{if(!callback&&this.hideCallback){AJS.$.each(this.hideCallback,function(i,callback){callback(instance)})}}},layer:function(layer){if(layer){this.$layer=layer}else{return this.$layer}},placeholder:function(placeholder){if(placeholder){this._throwReadOnlyError("placeholder")}else{return this.$placeholder}},isVisible:function(visible){if(typeof visible!=="undefined"){this._throwReadOnlyError("visible")}else{return this.visible}},scrollableContainer:function(scrollableContainer){if(scrollableContainer){this._throwReadOnlyError("scrollableContainer")}else{return this.$scrollableContainer}},isInitialized:function(initialised){if(initialised){this._throwReadOnlyError("initialized")}else{return this.initialized}},hide:function(){if(!this.isVisible()){return false}this.visible=false;this.layer().removeClass(AJS.ACTIVE_CLASS).hide();var positionController=this.positionController;setTimeout(function(){positionController.appendToPlaceholder()},0);this._unbindEvents();this.onhide();AJS.$(document).trigger("hideLayer",[this.CLASS_SIGNATURE,this]);AJS.InlineLayer.current=null},refreshContent:function(callback){var instance=this;this.content(function(){this.layer().empty().append(this.content());if(AJS.$.isFunction(callback)){callback.call(instance)}this.contentChange()})},show:function(){var instance=this;if(this.isVisible()){return}if(!this.isInitialized()){this._lazyInit(function(){instance._show()})}else{if(this.contentRetriever.cache()===false){this.refreshContent(function(){instance._show()})}else{instance._show()}}},setPosition:function(){var offset,scrollTop,maxHeight,newOffsetTop;if(!this.isInitialized()||!this.offsetTarget()||this.offsetTarget().length===0){return}offset=this.positionController.offset();newOffsetTop=offset.top+this.offsetTarget().outerHeight();if(AJS.dim.dim){scrollTop=Math.max(document.body.scrollTop,document.documentElement.scrollTop);maxHeight=AJS.$(window).height()+scrollTop-newOffsetTop-this.options.cushion()}this.layer().css({top:newOffsetTop,maxHeight:maxHeight||""});if(this.options.alignment()===AJS.RIGHT){this._positionRight(offset)}else{if(this.options.alignment()===AJS.LEFT){this._positionLeft(offset)}else{if(this.options.alignment()===AJS.INTELLIGENT_GUESS){if((offset.left+this.layer().outerWidth()/2)>AJS.$(window).width()/2){this._positionRight(offset)}else{this._positionLeft(offset)}}}}},setWidth:function(width,showhorizontalScroll){var contentScrollWidth=this.content().attr("scrollWidth");if(!(this.content().hasClass("error")||this.content().hasClass("warn"))){this.content().css({whiteSpace:"nowrap",overflowX:"",width:"auto"})}if(contentScrollWidth<=width){this.layer().css({width:width,whiteSpace:""})}else{if(showhorizontalScroll){this.layer().css({width:width,overflowX:"auto",whiteSpace:""})}else{this.layer().css({width:width,overflowX:"hidden",whiteSpace:""})}}},_offset:function(){var iframeOffset,offsetInDocument=this.offsetTarget().offset();if(window.top){iframeOffset=AJS.$("iframe[name="+window.name+"]",window.top.document).offset();return{left:iframeOffset.left+10+offsetInDocument.left,top:iframeOffset.top+offsetInDocument.top}}else{return offsetInDocument}},_lazyInit:function(callback){this.initialized=true;this.refreshContent(function(){var instance=this;this.layer().insertAfter(this.offsetTarget());if(this._supportsBoxShadow()){this.layer().addClass(AJS.BOX_SHADOW_CLASS)}this.$placeholder=AJS.$("
").insertAfter(this.offsetTarget());this.$scrollableContainer=this.offsetTarget().closest(this.options.hideOnScroll());this.positionController.set(this.layer(),this.offsetTarget(),this.placeholder());this.positionController.rebuilt(function(layer){instance.layer(layer)});callback()})},_show:function(){if(AJS.InlineLayer.current){AJS.InlineLayer.current.hide()}this.visible=true;this.content().show();this.positionController.appendToBody();this.layer().addClass(AJS.ACTIVE_CLASS);this.layer().show();this.setWidth(this.options.width());this.setPosition();this._bindEvents();if(!AJS.dim.dim){this.positionController.scrollTo()}AJS.InlineLayer.current=this;AJS.$(document).trigger("showLayer",[this.CLASS_SIGNATURE,this])},_positionLeft:function(offset){var newLeft=offset.left;this.currentPositioning=AJS.LEFT;this.layer().css({left:newLeft})},_positionRight:function(offset){var newLeft=offset.left-this.layer().outerWidth()+this.offsetTarget().outerWidth();this.currentPositioning=AJS.RIGHT;this.layer().css({left:newLeft})},_hideLoading:function(){this.$layer.removeClass(AJS.LOADING_CLASS);this.$offsetTarget.removeClass(AJS.LOADING_CLASS)},_showLoading:function(){this.$layer.addClass(AJS.LOADING_CLASS);this.$offsetTarget.addClass(AJS.LOADING_CLASS)},_unbindEvents:function(){this.$scrollableContainer.unbind(this.SCROLL_HIDE_EVENT);this._unassignEvents("container",document);this._unassignEvents("win",window)},_bindEvents:function(){var instance=this;this.$scrollableContainer.one(this.SCROLL_HIDE_EVENT,function(){instance.hide()});this._assignEvents("container",document);this._assignEvents("win",window)},_validateClickToClose:function(e){if(e.target===this.offsetTarget()[0]){return false}else{if(e.target===this.layer()[0]){return false}else{if(this.offsetTarget().has(e.target).length>0){return false}else{if(this.layer().has(e.target).length>0){return false}}}}return true},_events:{container:{keydown:function(e){if(jira.keyboard.specialKeyEntered(e)===jira.keyboard.SpecialKey.ESC){this.hide()}},keypress:function(e){if(jira.keyboard.specialKeyEntered(e)===jira.keyboard.SpecialKey.ESC){this.hide()}},click:function(e){if(this._validateClickToClose(e)){this.hide()}}},win:{resize:function(){this.setPosition()}}},_renders:{layer:function(){return AJS.$("
").addClass("ajs-layer")}}}); AJS.InlineLayer.Descriptor=AJS.Descriptor.extend({init:function(properties){this._super(properties);if(!this.contentRetriever()){if(this.ajaxOptions()){this.contentRetriever(new AJS.AjaxContentRetriever(this.ajaxOptions()))}else{if(this.content()){this.contentRetriever(new AJS.DOMContentRetriever(this.content()))}else{throw new Error("AJS.InlineLayer.Descriptor: Expected either [ajaxOptions] or [contentRetriever] or [content] to be defined")}}}if(this._inIFrame()&&(AJS.$.browser.safari||(AJS.$.browser.msie&&AJS.$.browser.version<8))){this.positioningController(new AJS.InlineLayer.IframePositioningWithoutAdoptNode())}else{if(this._inIFrame()){this.positioningController(new AJS.InlineLayer.IframePositioning())}else{this.positioningController(new AJS.InlineLayer.StandardPositioning())}}if(AJS.$.browser.msie&&this.positioningController().isOffsetIncludingScroll){this.positioningController().isOffsetIncludingScroll(false)}if(!this.offsetTarget()&&this.content()){this.offsetTarget(this.content().prev())}},_inIFrame:function(){return window.top!==self&&window.top&&window.top.jQuery},_getDefaultOptions:function(){return{alignment:AJS.INTELLIGENT_GUESS,hideOnScroll:".content-body",cushion:20,width:200}},positioningController:function(positioningController){if(positioningController){this.properties.positioningController=positioningController}else{return this.properties.positioningController}},ajaxOptions:function(ajaxOptions){if(ajaxOptions){this.properties.ajaxOptions=ajaxOptions}else{return this.properties.ajaxOptions}},content:function(content){if(content){content=AJS.$(content);if(content.length){this.properties.content=content}}else{if(this.properties.content&&this.properties.content.length){return this.properties.content}}},contentRetriever:function(contentRetriever){if(contentRetriever){this.properties.contentRetriever=contentRetriever}else{return this.properties.contentRetriever}},offsetTarget:function(offsetTarget){if(offsetTarget){offsetTarget=AJS.$(offsetTarget);if(offsetTarget.length){this.properties.offsetTarget=offsetTarget}}else{if(this.properties.offsetTarget&&this.properties.offsetTarget.length){return this.properties.offsetTarget}}},cushion:function(cushion){if(cushion){this.properties.cushion=cushion}else{return this.properties.cushion}},hideOnScroll:function(hideOnScroll){if(hideOnScroll){this.properties.hideOnScroll=hideOnScroll}else{return this.properties.hideOnScroll}},alignment:function(alignment){if(alignment){this.properties.alignment=alignment}else{return this.properties.alignment}},width:function(width){if(width){this.properties.width=width}else{return this.properties.width}}}); AJS.InlineLayer.create=function(options){var inlineLayers=[];if(options.content){options.content=AJS.$(options.content);AJS.$.each(options.content,function(){var instanceOptions=AJS.copyObject(options);instanceOptions.content=AJS.$(this);inlineLayers.push(new AJS.InlineLayer(instanceOptions))})}if(inlineLayers.length==1){return inlineLayers[0]}else{return inlineLayers}}; AJS.InlineLayer.StandardPositioning=Class.extend({set:function($layer,$offsetTarget,$placeholder){this.$layer=$layer;this.$offsetTarget=$offsetTarget;this.$placeholder=$placeholder;this.rebuiltCallbacks=[]},window:function(){return window},offset:function(){return this.$offsetTarget.offset()},rebuilt:function(arg){var instance=this;if(AJS.$.isFunction(arg)){this.rebuiltCallbacks.push(arg)}else{AJS.$.each(this.rebuiltCallbacks,function(){this(instance.$layer)})}},appendToBody:function(){this.$layer.appendTo("body")},appendToPlaceholder:function(){this.$layer.appendTo(this.$placeholder)},scrollTo:function(){}}); AJS.InlineLayer.IframePositioning=AJS.InlineLayer.StandardPositioning.extend({offset:function(){var offsetInDocument=this._super(),iframeOffset=AJS.$("iframe[name="+window.name+"]",window.top.document.body).parent().offset(),topDocumentScrollTop=this._topDocumentScrollTop(),topDocumentScrollLeft=this._topDocumentScrollLeft(),iframeScrollTop=this._iframeScrollTop(),iframeScrollLeft=this._iframeScrollLeft(),scrollTopModifier=topDocumentScrollTop-iframeScrollTop,scrollLeftModifier=topDocumentScrollLeft-iframeScrollLeft;return{left:iframeOffset.left+offsetInDocument.left+scrollLeftModifier,top:iframeOffset.top+offsetInDocument.top+scrollTopModifier}},_topDocumentScrollTop:function(){return this.isOffsetIncludingScroll()?0:Math.max(window.top.document.body.scrollTop,window.top.document.documentElement.scrollTop)},_topDocumentScrollLeft:function(){return this.isOffsetIncludingScroll()?0:Math.max(window.top.document.body.scrollLeft,window.top.document.documentElement.scrollLeft)},_iframeScrollTop:function(){return this.isOffsetIncludingScroll()?2*Math.max(window.document.body.scrollTop,window.document.documentElement.scrollTop):0},_iframeScrollLeft:function(){return this.isOffsetIncludingScroll()?2*Math.max(window.document.body.scrollLeft,window.document.documentElement.scrollLeft):0},isOffsetIncludingScroll:function(offsetIncludingScroll){if(typeof this.offsetIncludingScroll==="undefined"){this.offsetIncludingScroll=true}if(typeof offsetIncludingScroll!=="undefined"){this.offsetIncludingScroll=offsetIncludingScroll}return this.offsetIncludingScroll},appendToBody:function(){window.top.jQuery("body").append(this.$layer)},window:function(){return window.top},scrollTo:function(){}}); AJS.InlineLayer.IframePositioningWithoutAdoptNode=AJS.InlineLayer.IframePositioning.extend({appendToBody:function(){this.$layer=this._rebuildLayerInParent();window.top.jQuery("body").append(this.$layer);this.rebuilt()},appendToPlaceholder:function(){this.$layer=this._rebuildLayerInIframe();this.$layer.appendTo(this.$placeholder);this.rebuilt()},_rebuildLayerInParent:function(){return window.top.jQuery("
"+this.$layer.html()+"
")},_rebuildLayerInIframe:function(){return AJS.$("
"+this.$layer.html()+"
")}}); AJS.DropDown=AJS.Control.extend({CLASS_SIGNATURE:"AJS_DROPDOWN",init:function(options){var instance=this;if(!(options instanceof AJS.DropDown.Descriptor)){this.options=new AJS.DropDown.Descriptor(options)}else{this.options=options}this.layerController=new AJS.InlineLayer(this.options.allProperties());this.listController=this.options.listController();this.layerController.onhide(function(){instance.hide()});this.layerController.contentChange(function(){instance.listController.removeAllItems();instance.layerController.layer().find("li").each(function(){instance.listController.addItem(new AJS.ListItem({element:this}))});instance.listController.shiftFocus(0)});this.trigger(this.options.trigger());this._applyIdToLayer()},show:function(){this.trigger().addClass(AJS.ACTIVE_CLASS);this.layerController.show();this.listController.shiftFocus(0)},hide:function(){this.trigger().removeClass(AJS.ACTIVE_CLASS);this.layerController.hide();this.listController.trigger("blur")},toggle:function(){if(this.layerController.isVisible()){this.hide()}else{this.show()}},content:function(content){if(content){this.layerController.content(content)}else{return this.layerController.content()}},trigger:function(trigger){if(trigger){if(this.options.trigger()){this._unassignEvents("trigger",this.options.trigger())}this.options.trigger(AJS.$(trigger));this.layerController.offsetTarget(this.options.trigger());this._assignEvents("trigger",this.options.trigger())}else{return this.options.trigger()}},_applyIdToLayer:function(){if(this.trigger().attr("id")){this.layerController.layer().attr("id",this.trigger().attr("id")+"_drop")}},_events:{trigger:{click:function(e){this.toggle();e.preventDefault()}}}});AJS.$.extend(AJS.DropDown,{TRIGGER_SELECTOR:".aui-dropdown-trigger",CONTENT_SELECTOR:".aui-dropdown-content"}); AJS.DropDown.Descriptor=AJS.Descriptor.extend({init:function(properties){this._super(properties);if(!this.content()&&!this.trigger()){throw new Error("AJS.DropDown.Descriptor: expected either [content] or [trigger] to be defined.")}if(this.content()&&this.trigger()){throw new Error("AJS.DropDown.Descriptor: expected either [content] or [trigger] to be defined, NOT both")}if(this.trigger()&&!this.content()){this.content(this.trigger().next(AJS.DropDown.CONTENT_SELECTOR))}else{if(this.content()&&!this.trigger()){this.content(this.trigger().next(AJS.DropDown.TRIGGER_SELECTOR))}}if(this.trigger()&&!this.content()){if(!this.ajaxOptions()){if(this.trigger().attr("href")){this.ajaxOptions(this.trigger().attr("href"))}}else{if(!this.ajaxOptions().url){this.ajaxOptions().url=this.trigger().attr("href")}else{throw new Error("AJS.DropDown.Descriptor: cannot establish ajaxOptions")}}this.contentRetriever(new AJS.AjaxContentRetriever(this.ajaxOptions()))}else{if(this.content()){this.contentRetriever(new AJS.DOMContentRetriever(this.content()))}}if(!this.listController()){this.listController(new AJS.ListItemGroup())}},_getDefaultOptions:function(){return{trigger:null,ajaxOptions:null}},content:function(content){if(content){content=AJS.$(content);if(content.length){this.properties.content=content}}else{return this.properties.content}},trigger:function(trigger){if(trigger){this.properties.trigger=trigger}else{return this.properties.trigger}},contentRetriever:function(contentRetriever){if(contentRetriever){this.properties.contentRetriever=contentRetriever}else{return this.properties.contentRetriever}},listController:function(listController){if(listController){this.properties.listController=listController}else{return this.properties.listController}},ajaxOptions:function(ajaxOptions){if(ajaxOptions){this.properties.ajaxOptions=ajaxOptions}else{return this.properties.ajaxOptions}},loop:function(loop){if(typeof loop!=="undefined"){this.properties.loop=loop}else{return this.properties.loop}},alignment:function(alignment){if(alignment){this.properties.alignment=alignment}else{return this.properties.alignment}},eventDelegator:function(eventDelegator){if(typeof eventDelegator!=="undefined"){this.properties.eventDelegator=eventDelegator}else{return this.properties.eventDelegator}}}); AJS.DropDown.create=function(options){var dropdowns=[];if(options.content&&!options.trigger){options.content=AJS.$(options.content);AJS.$.each(options.content,function(){var instanceOptions=AJS.copyObject(options);instanceOptions.content=AJS.$(this);dropdowns.push(new AJS.DropDown(instanceOptions))})}else{if(!options.content&&options.trigger){options.trigger=AJS.$(options.trigger);AJS.$.each(options.trigger,function(){var instanceOptions=AJS.copyObject(options);instanceOptions.trigger=AJS.$(this);dropdowns.push(new AJS.DropDown(instanceOptions))})}}return dropdowns}; AJS.ContentRetrieverInterface=Interface.extend({startingRequest:Function,finishedRequest:Function,cache:Function,isLocked:Function,content:Function}); AJS.AjaxContentRetriever=Class.extend(AJS.ContentRetrieverInterface,{init:function(options){var instance=this;this.ajaxOptions=options;if(typeof this.ajaxOptions==="string"){this.ajaxOptions={url:this.ajaxOptions}}this.ajaxOptions.success=function(data,textStatus,xhr){instance._requestComplete(xhr,textStatus,data,true,null)};this.ajaxOptions.error=function(xhr,textStatus){if(xhr.rc){xhr.status=xhr.rc}instance._requestComplete(xhr,textStatus,null,false,null)}},content:function(arg){if(AJS.$.isFunction(arg)){this.callback=arg;this._makeRequest(arg)}else{if(arg){this.callback(arg);delete this.callback}}return this.$content},startingRequest:function(callback){if(callback){this.startingCallback=callback}else{if(this.startingCallback){this.locked=true;this.startingCallback()}}},finishedRequest:function(callback){if(callback){this.finishedCallback=callback}else{if(this.finishedCallback){this.locked=false;this.finishedCallback()}}},cache:function(cache){if(typeof cache!=="undefined"){this.ajaxOptions.cache=cache}else{return this.ajaxOptions.cache}},isLocked:function(){return this.locked},_requestComplete:function(xhr,statusText,data,successful,errorThrown){var $content,smartAjaxResult;if(jira.ajax.SmartAjaxResult){smartAjaxResult=jira.ajax.SmartAjaxResult.apply(window,arguments)}if(successful){if(AJS.$.isFunction(this.ajaxOptions.formatSuccess)){$content=this.ajaxOptions.formatSuccess(data)}else{$content=AJS.$("
"+data+"
")}}else{if(AJS.$.isFunction(this.ajaxOptions.formatError)){$content=this.ajaxOptions.formatError(data)}else{if(smartAjaxResult){var errorClass=smartAjaxResult.status===401?"warn":"error";$content=AJS.$("
"+jira.ajax.buildSimpleErrorContent(smartAjaxResult)+"
")}}}this.content($content);this.finishedRequest()},_makeRequest:function(){this.startingRequest();AJS.$.ajax(this.ajaxOptions)}}); AJS.DOMContentRetriever=Class.extend(AJS.ContentRetrieverInterface,{init:function(content){this.$content=AJS.$(content)},content:function(callback){if(AJS.$.isFunction(callback)){callback(this.$content)}return this.$content},cache:function(){},isLocked:function(){},startingRequest:function(){},finishedRequest:function(){}}); AJS.QueryableDropdown=AJS.Control.extend({INVALID_KEYS:[jira.keyboard.SpecialKey.TAB,jira.keyboard.SpecialKey.ESC,jira.keyboard.SpecialKey.SHIFT,jira.keyboard.SpecialKey.RIGHT],init:function(options){var instance=this;this._setOptions(options);this._queuedRequest=0;this.suggestionsVisible=false;if(this.options.ajaxOptions.minQueryLength){this.options.ajaxOptions.minQueryLength=parseInt(this.options.ajaxOptions.minQueryLength,10)}this._createFurniture();this.dropdownController=AJS.InlineLayer.create({offsetTarget:this.$field,width:this.$field.innerWidth(),content:options.element});this.listController=new AJS.List({containerSelector:options.element,groupSelector:"ul.aui-list-section",itemSelector:"li",selectionHandler:function(){instance.$field.val(AJS.params.dotLoading).css("color","#999");instance.hideSuggestions();return true}});this._assignEventsToFurniture();if(this.options.loadOnInit){this.suggestionsDisabled=true;this._requestThenResetSuggestions()}},_getDefaultOptions:function(){return{id:"default",ajaxOptions:{data:{query:""},dataType:"json",minQueryLength:0},keyInputPeriod:75}},getAjaxOptions:function(){this.options.ajaxOptions.data.query=AJS.$.trim(this.$field.val());return AJS.copyObject(this.options.ajaxOptions)},issueRequest:function(){var instance=this,ajaxOptions=this.getAjaxOptions();ajaxOptions.complete=function(xhr,textStatus,smartAjaxResult){instance.outstandingRequest=null;if(!instance.$container.is(":visible")){return}if(smartAjaxResult.successful){instance._handleServerSuccess(smartAjaxResult)}else{if(!smartAjaxResult.aborted){instance.hideSuggestions();instance._handleServerError(smartAjaxResult)}}};this.outstandingRequest=jira.ajax.makeRequest(ajaxOptions);AJS.$(this.outstandingRequest).throbber({target:this.$dropDownIcon,isLatentThreshold:500})},_handleServerSuccess:function(smartAjaxResult){if(this.options.loadOnInit||this.$field.val()==this.options.ajaxOptions.data.query){this._handleSuggestionResponse(smartAjaxResult.data)}},_handleServerError:function(smartAjaxResult){var errMsg=jira.ajax.buildSimpleErrorContent(smartAjaxResult);alert(errMsg)},_createFurniture:function(){this.$container=this._render("container").insertBefore(this.options.element);this.$field=this._render("field").appendTo(this.$container);this.$dropDownIcon=this._render("dropdownAndLoadingIcon",this._hasDropdownButton()).appendTo(this.$container);this.$suggestionsContainer=this._render("suggestionsContainer")},_hasDropdownButton:function(){return this.options.showDropdownButton||this.options.ajaxOptions.minQueryLength===0},_assignEventsToFurniture:function(){var instance=this;this._assignEvents("ignoreBlurElement",this.$container);this._assignEvents("ignoreBlurElement",this.dropdownController.$layer);if(this._hasDropdownButton()){this._assignEvents("ignoreBlurElement",this.$dropDownIcon);this._assignEvents("dropdownAndLoadingIcon",this.$dropDownIcon)}setTimeout(function(){instance._assignEvents("field",instance.$field);instance._assignEvents("keys",instance.$field)},15)},_useCachedRequest:function(){return !!(this.cachedList&&!this.options.ajaxOptions.query)},_isValidRequest:function(){return this.options.ajaxOptions.query||(!this.cachedList&&!this.outstandingRequest)},_requestThenResetSuggestions:function(ignoreBuffer){var instance=this;this.listController._latestQuery=AJS.$.trim(this.$field.val());if(this._useCachedRequest()){this._handleSuggestionResponse(this.cachedList)}else{if(this._isValidRequest()){if(ignoreBuffer&&this.outstandingRequest){this.outstandingRequest.abort();this.outstandingRequest=null}clearTimeout(this._queuedRequest);if(!this.outstandingRequest){this.issueRequest()}else{this._queuedRequest=setTimeout(function(){instance._requestThenResetSuggestions(ignoreBuffer)},this.options.keyInputPeriod)}}}},_handleSuggestionResponse:function(data){if(data!==this.cachedList){if(this._formatResponse){data=this._formatResponse(data)}else{if(this.options.ajaxOptions.formatResponse){data=this.options.ajaxOptions.formatResponse.call(this,data)}}}this.cachedList=data;this._setSuggestions(this.cachedList)},_setSuggestions:function(data){if(this.suggestionsDisabled){this.suggestionsDisabled=false;return}this.suggestionsVisible=true;if(data){this.dropdownController.show();this.dropdownController.setWidth(this.$field.innerWidth());if(this.options.ajaxOptions.query){this.listController.generateListFromJSON(data)}else{this.listController.generateListFromJSON(data,this.$field.val())}this.listController.enable()}else{this.hideSuggestions()}},_isValidInput:function(e){return this.$field.is(":visible")&&AJS.$.inArray(jira.keyboard.specialKeyEntered(e),this.INVALID_KEYS)===-1},_handleCharacterInput:function(ignoreBuffer,ignoreQueryLength){this.suggestionsDisabled=false;if(ignoreQueryLength||AJS.$.trim(this.$field.val()).length>=this.options.ajaxOptions.minQueryLength){if(this.options.ajaxOptions.url){this.$dropDownIcon.removeClass("noloading");this._requestThenResetSuggestions(ignoreBuffer)}else{this._setSuggestions(this.model.getUnSelectedDescriptors())}}else{this._setSuggestions()}},_handleDown:function(e){if(!this.suggestionsVisible){this._handleCharacterInput(true,true);e.stopPropagation()}},_rejectPendingRequests:function(){if(this.outstandingRequest){this.outstandingRequest.abort()}clearTimeout(this._queuedRequest)},hideSuggestions:function(){if(!this.suggestionsVisible){return}this._rejectPendingRequests();this.suggestionsVisible=false;this.$dropDownIcon.addClass("noloading");this.dropdownController.hide();this.listController.disable()},_handleEscape:function(e){if(this.suggestionsVisible){e.stopPropagation();if(e.type==="keyup"){this.hideSuggestions()}}},keys:{down:function(e){if(this._hasDropdownButton()){this._handleDown(e)}},up:function(e){e.preventDefault()},"return":function(e){e.preventDefault()},onEdit:function(e,character){var instance=this;this.$field.one("keyup",function(){instance._handleCharacterInput()})}},_events:{dropdownAndLoadingIcon:{click:function(e){this.$field.focus();if(this.suggestionsVisible){this.hideSuggestions()}else{this._handleDown(e)}e.stopPropagation()}},field:{blur:function(){this.hideSuggestions()},click:function(e){e.stopPropagation()},keyup:function(e){if(e.keyCode===jira.keyboard.SpecialKey.toKeyCode(jira.keyboard.SpecialKey.ESC)){this._handleEscape(e)}},beforedeactivate:function(e){if(this.ignoreBlurEvent){this.ignoreBlurEvent=false;e.preventDefault()}}},keys:{"keydown keypress":function(e){this._handleKeyEvent(e)}},ignoreBlurElement:{mousedown:function(e){if(e.target!==this.$field[0]){this.ignoreBlurEvent=true;e.preventDefault()}}}},_renders:{field:function(){return AJS.$("")},container:function(){return AJS.$("
")},dropdownAndLoadingIcon:function(showDropdown){var $element=AJS.$('More');if(showDropdown){$element.addClass("drop-menu")}return $element},suggestionsContainer:function(){return AJS.$("
")}}}); AJS.List=AJS.Control.extend({_getDefaultOptions:function(){return{matchingStrategy:"(^|.*\\s+)({0})(.*)",containerSelector:".aui-list",itemSelector:"li"}},index:0,moveToNext:function(){if(this.index1){this.unfocusAll();this.index=0;this.focus(this.SCROLL_DOWN)}}this.motionDetector.wait()},SCROLL_UP:-1,SCROLL_DOWN:1,container:function(container){if(container){this.$container=AJS.$(container);this.containerSelector=container}else{return this.$container}},scrollContainer:function(){return this.container().parent()},unfocusAll:function(){this.$visibleItems.removeClass("active")},moveToPrevious:function(){if(this.index>0){this.unfocusAll();--this.index;this.focus(this.SCROLL_UP)}else{if(this.$visibleItems.length>0){this.unfocusAll();this.index=this.$visibleItems.length-1;this.focus(this.SCROLL_UP)}}this.motionDetector.wait()},unfocus:function(direction){if(direction!==undefined){this.scrollTo(this.$visibleItems.eq(this.index),direction)}this.$visibleItems.eq(this.index).removeClass("active")},scrollTo:function($target,direction){var $scrollContainer=this.scrollContainer(),offsetTop=$target.offset().top-this.$container.offset().top;if($target[0]===this.$visibleItems[0]){$scrollContainer.scrollTop(0)}else{if($scrollContainer.scrollTop()+$scrollContainer.height()offsetTop){if(direction===-1){$scrollContainer.scrollTop(offsetTop)}else{if(direction===1){$scrollContainer.scrollTop(offsetTop+$target.outerHeight()-$scrollContainer.height())}}}}},focus:function(direction){var $target=this.$visibleItems.eq(this.index);if(direction!==undefined){this.scrollTo($target,direction)}this.lastFocusedItemDescriptor=$target.data("descriptor");this.motionDetector.unbind();$target.addClass("active");if(!AJS.dim.dim){$target.scrollIntoView({duration:100,callback:AJS.$.proxy(this.motionDetector,"wait")})}else{this.motionDetector.wait()}},motionDetector:new jira.mouse.MotionDetector(),disable:function(){if(this.disabled){return}this._unassignEvents("document",document);this.disabled=true;this.lastFocusedItemDescriptor=null;this.motionDetector.unbind()},enable:function(){var instance=this;if(!instance.disabled){return}instance.motionDetector.wait();window.setTimeout(function(){instance._assignEvents("document",document)},0);instance.selectionManager.enable();instance.disabled=false;this.scrollContainer().scrollTop(0)},getFocused:function(){return this.$visibleItems.filter(".active")},reset:function(index){var noSuggestionsClassName=/(?:^|\s)no-suggestions(?!\S)/;var hiddenClassName=/(?:^|\s)hidden(?!\S)/;this.$container=AJS.$(this.options.containerSelector);this.items=AJS.$(this.options.itemSelector,this.$container).filter(function(){return !noSuggestionsClassName.test(this.className)});this.$visibleItems=this.items.filter(function(){return !hiddenClassName.test(this.className)});this.groups=AJS.$(this.options.groupSelector,this.$container);this.maxIndex=this.$visibleItems.length-1;this.index=this.$visibleItems[index]?index:0;this.focus()},init:function(options){options=options||{};if(options){this.options=AJS.$.extend(true,this._getDefaultOptions(options),options)}else{this.options=this._getDefaultOptions(options)}var instance=this;this.containerSelector=AJS.$(this.options.$layerContent);this.disabled=true;this.reset();this.selectionManager=new AJS.SelectionManager(document);AJS.$(this.selectionManager).bind(this.selectionManager.getCustomEventName("setNoScheme"),function(e){if(instance.getFocused().length>1){instance._handleSectionByKeyboard(e)}});if(this.options.selectionHandler){this.$container.delegate(this.options.itemSelector,"click",function(e){instance.options.selectionHandler.call(instance,e)})}this.$container.delegate(this.options.itemSelector,"mouseover",function(){if(instance.motionDetector.moved&&!instance.disabled){instance.unfocusAll();instance.index=AJS.$.inArray(this,instance.$visibleItems);instance.focus()}})},_getLinkFromItem:function(item){var link;item=AJS.$(item);if(item.is("a")){link=item}else{link=item.find("a")}if(!link.length){throw new Error("AJS.List._getLinkFromItem: could not find a link node")}else{return link}},generateListFromJSON:function(data,query){var event,$result=AJS.$("
"),instance=this,ungrouped=[],$listItems;this.suggestions=0;this.exactMatchIndex=-1;this.lastFocusedIndex=-1;this.lastQuery=query;AJS.$.each(data,function(i,descriptor){if(descriptor instanceof AJS.GroupDescriptor){if(ungrouped.length>0){$result.append(instance._generateUngroupedOptions(ungrouped,query));ungrouped=[]}$result.append(instance._generateOptGroup(descriptor,query))}else{if(this instanceof AJS.ItemDescriptor){ungrouped.push(descriptor)}}});if(ungrouped.length>0){$result.append(this._generateUngroupedOptions(ungrouped,query))}if($result.children().length===0){this.$container.html(this._render("noSuggestion"))}else{$result.find("ul:last").addClass("aui-last");this.$container.html($result.children())}this.$container.hide();$listItems=AJS.$("li > a",this.$container);$listItems.each(function(){var elem=AJS.$(this);elem.attr("title",elem.text())});$listItems.css({textOverflow:"ellipsis",overflow:"hidden"});this.$container.show();$listItems.textOverflow("…",false);event=new AJS.ContentChangeEvent({target:this.$container,eventOwner:AJS.List});event.fire();this.reset(this.exactMatchIndex>=0?this.exactMatchIndex:this.lastFocusedIndex)},_generateOption:function(item,query){var replacementText;if(query){var regexEscapedQuery=RegExp.escape(query),regex=new RegExp(AJS.format(this.options.matchingStrategy,regexEscapedQuery),"i");if(!regex.test(item.label())){return null}replacementText=item.label().replace(regex,function(_,prefix,match,suffix){return AJS.$("
").append(AJS.$("").text(prefix)).append(AJS.$("").text(match)).append(AJS.$("").text(suffix)).html()})}if(this.exactMatchIndex<0){var itemValue=AJS.$.trim(item.label()).toLowerCase();if(itemValue===AJS.$.trim(query).toLowerCase()){this.exactMatchIndex=this.suggestions}else{if(this.lastFocusedIndex<0&&this.lastFocusedItemDescriptor&&itemValue===AJS.$.trim(this.lastFocusedItemDescriptor.label()).toLowerCase()){this.lastFocusedIndex=this.suggestions}}}this.suggestions++;return this._render("suggestion",item,replacementText)},_generateUngroupedOptions:function(options,query){var hasSuggestion=false,instance=this,$container=this._render("ungroupedSuggestions");AJS.$.each(options,function(_,option){var $suggestion=instance._generateOption(option,query);if($suggestion){hasSuggestion=true;$container.append($suggestion)}});if(hasSuggestion){return $container}},_generateOptGroup:function(groupDescriptor,query){var res=AJS.$(),hasSuggestion,instance=this,optContainer=this._render("suggestionGroup",groupDescriptor);AJS.$.each(groupDescriptor.items(),function(i,option){var suggestion=instance._generateOption(option,query);if(suggestion){hasSuggestion=true,optContainer.append(suggestion)}});if(!hasSuggestion){return}if(groupDescriptor.showLabel()!==false){res=res.add(this._render("suggestionGroupHeading",groupDescriptor))}res=res.add(optContainer);return res},_events:{document:{keydown:function(e){this._handleKeyEvent(e)},keypress:function(e){this._handleKeyEvent(e)}}},_renders:{suggestion:function(descriptor,replacementText){var listElem=AJS.$('
  • '),linkElem=AJS.$("").addClass("aui-list-item-link");if(descriptor.selected()){listElem.addClass("aui-checked")}linkElem.attr("href",descriptor.href()||"#");if(descriptor.icon()&&descriptor.icon()!=="none"){linkElem.addClass("aui-iconised-link").css({backgroundImage:"url("+descriptor.icon()+")"})}if(descriptor.styleClass()){linkElem.addClass(descriptor.styleClass())}if(descriptor.html()){linkElem.html(descriptor.html())}else{if(!replacementText){linkElem.text(descriptor.label())}else{linkElem.html(replacementText)}}if(descriptor.labelSuffix()){AJS.$("").text(descriptor.labelSuffix()).appendTo(linkElem)}listElem.append(linkElem).data("descriptor",descriptor);return listElem},noSuggestion:function(){return AJS.$("
    "+AJS.params.frotherNomatches+"
    ")},ungroupedSuggestions:function(){return AJS.$("