1/*jslint browser: true */ /*global jQuery: true */ 2 3/** 4 * jQuery Cookie plugin 5 * 6 * Copyright (c) 2010 Klaus Hartl (stilbuero.de) 7 * Dual licensed under the MIT and GPL licenses: 8 * http://www.opensource.org/licenses/mit-license.php 9 * http://www.gnu.org/licenses/gpl.html 10 * 11 */ 12 13// TODO JsDoc 14 15/** 16 * Create a cookie with the given key and value and other optional parameters. 17 * 18 * @example $.cookie('the_cookie', 'the_value'); 19 * @desc Set the value of a cookie. 20 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); 21 * @desc Create a cookie with all available options. 22 * @example $.cookie('the_cookie', 'the_value'); 23 * @desc Create a session cookie. 24 * @example $.cookie('the_cookie', null); 25 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain 26 * used when the cookie was set. 27 * 28 * @param String key The key of the cookie. 29 * @param String value The value of the cookie. 30 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. 31 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. 32 * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. 33 * If set to null or omitted, the cookie will be a session cookie and will not be retained 34 * when the the browser exits. 35 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). 36 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). 37 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will 38 * require a secure protocol (like HTTPS). 39 * @type undefined 40 * 41 * @name $.cookie 42 * @cat Plugins/Cookie 43 * @author Klaus Hartl/[email protected] 44 */ 45 46/** 47 * Get the value of a cookie with the given key. 48 * 49 * @example $.cookie('the_cookie'); 50 * @desc Get the value of a cookie. 51 * 52 * @param String key The key of the cookie. 53 * @return The value of the cookie. 54 * @type String 55 * 56 * @name $.cookie 57 * @cat Plugins/Cookie 58 * @author Klaus Hartl/[email protected] 59 */ 60jQuery.cookie = function (key, value, options) { 61 62 // key and value given, set cookie... 63 if (arguments.length > 1 && (value === null || typeof value !== "object")) { 64 options = jQuery.extend({}, options); 65 66 if (value === null) { 67 options.expires = -1; 68 } 69 70 if (typeof options.expires === 'number') { 71 var days = options.expires, t = options.expires = new Date(); 72 t.setDate(t.getDate() + days); 73 } 74 75 return (document.cookie = [ 76 encodeURIComponent(key), '=', 77 options.raw ? String(value) : encodeURIComponent(String(value)), 78 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 79 options.path ? '; path=' + options.path : '', 80 options.domain ? '; domain=' + options.domain : '', 81 options.secure ? '; secure' : '' 82 ].join('')); 83 } 84 85 // key and possibly options given, get cookie... 86 options = value || {}; 87 var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; 88 return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; 89}; 90; 91/** 92 * Backport of security fixes from: 93 * https://github.com/jquery/jquery-ui/pull/1953 94 * https://github.com/jquery/jquery-ui/pull/1954 95 */ 96 97(function ($, Drupal) { 98 99 // No backport is needed if we're already on jQuery UI 1.13 or higher. 100 var versionParts = $.ui.datepicker.version.split('.'); 101 var majorVersion = parseInt(versionParts[0]); 102 var minorVersion = parseInt(versionParts[1]); 103 if ( (majorVersion > 1) || (majorVersion === 1 && minorVersion >= 13) ) { 104 return; 105 } 106 107 var fnOriginalGet = $.datepicker._get; 108 $.extend($.datepicker, { 109 110 _get: function( inst, name ) { 111 var val = fnOriginalGet.call(this, inst, name); 112 113 // @see https://github.com/jquery/jquery-ui/pull/1954 114 if (name === 'altField') { 115 val = $(document).find(val); 116 } 117 // @see https://github.com/jquery/jquery-ui/pull/1953 118 else if ($.inArray(name, ['appendText', 'buttonText', 'prevText', 'currentText', 'nextText', 'closeText']) !== -1) { 119 val = Drupal.checkPlain(val); 120 } 121 122 return val; 123 } 124 125 }) 126})(jQuery, Drupal); 127; 128(function ($) { 129 130/** 131 * Attaches language support to the jQuery UI datepicker component. 132 */ 133Drupal.behaviors.localeDatepicker = { 134 attach: function(context, settings) { 135 // This code accesses Drupal.settings and localized strings via Drupal.t(). 136 // So this code should run after these are initialized. By placing it in an 137 // attach behavior this is assured. 138 $.datepicker.regional['drupal-locale'] = $.extend({ 139 closeText: Drupal.t('Done'), 140 prevText: Drupal.t('Prev'), 141 nextText: Drupal.t('Next'), 142 currentText: Drupal.t('Today'), 143 monthNames: [ 144 Drupal.t('January'), 145 Drupal.t('February'), 146 Drupal.t('March'), 147 Drupal.t('April'), 148 Drupal.t('May'), 149 Drupal.t('June'), 150 Drupal.t('July'), 151 Drupal.t('August'), 152 Drupal.t('September'), 153 Drupal.t('October'), 154 Drupal.t('November'), 155 Drupal.t('December') 156 ], 157 monthNamesShort: [ 158 Drupal.t('Jan'), 159 Drupal.t('Feb'), 160 Drupal.t('Mar'), 161 Drupal.t('Apr'), 162 Drupal.t('May'), 163 Drupal.t('Jun'), 164 Drupal.t('Jul'), 165 Drupal.t('Aug'), 166 Drupal.t('Sep'), 167 Drupal.t('Oct'), 168 Drupal.t('Nov'), 169 Drupal.t('Dec') 170 ], 171 dayNames: [ 172 Drupal.t('Sunday'), 173 Drupal.t('Monday'), 174 Drupal.t('Tuesday'), 175 Drupal.t('Wednesday'), 176 Drupal.t('Thursday'), 177 Drupal.t('Friday'), 178 Drupal.t('Saturday') 179 ], 180 dayNamesShort: [ 181 Drupal.t('Sun'), 182 Drupal.t('Mon'), 183 Drupal.t('Tue'), 184 Drupal.t('Wed'), 185 Drupal.t('Thu'), 186 Drupal.t('Fri'), 187 Drupal.t('Sat') 188 ], 189 dayNamesMin: [ 190 Drupal.t('Su'), 191 Drupal.t('Mo'), 192 Drupal.t('Tu'), 193 Drupal.t('We'), 194 Drupal.t('Th'), 195 Drupal.t('Fr'), 196 Drupal.t('Sa') 197 ], 198 dateFormat: Drupal.t('mm/dd/yy'), 199 firstDay: 0, 200 isRTL: 0 201 }, Drupal.settings.jquery.ui.datepicker); 202 $.datepicker.setDefaults($.datepicker.regional['drupal-locale']); 203 } 204}; 205 206})(jQuery); 207; 208/* http://keith-wood.name/timeEntry.html 209 Time entry for jQuery v1.5.2. 210 Written by Keith Wood (kbwood{at}iinet.com.au) June 2007. 211 Licensed under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. 212 Please attribute the author if you use it. */ 213/* jshint ignore:start */ 214(function($){function TimeEntry(){this._disabledInputs=[];this.regional=[];this.regional['']={show24Hours:false,separator:':',ampmPrefix:'',ampmNames:['AM','PM'],spinnerTexts:['Now','Previous field','Next field','Increment','Decrement']};this._defaults={appendText:'',showSeconds:false,timeSteps:[1,1,1],initialField:0,noSeparatorEntry:false,useMouseWheel:true,defaultTime:null,minTime:null,maxTime:null,spinnerImage:'spinnerDefault.png',spinnerSize:[20,20,8],spinnerBigImage:'',spinnerBigSize:[40,40,16],spinnerIncDecOnly:false,spinnerRepeat:[500,250],beforeShow:null,beforeSetTime:null};$.extend(this._defaults,this.regional[''])}$.extend(TimeEntry.prototype,{markerClassName:'hasTimeEntry',propertyName:'timeEntry',_appendClass:'timeEntry_append',_controlClass:'timeEntry_control',_expandClass:'timeEntry_expand',setDefaults:function(a){$.extend(this._defaults,a||{});return this},_attachPlugin:function(b,c){var d=$(b);if(d.hasClass(this.markerClassName)){return}
214var e={options:$.extend({},this._defaults,c),input:d,_field:0,_selectedHour:0,_selectedMinute:0,_selectedSecond:0};d.data(this.propertyName,e).addClass(this.markerClassName).bind('focus.'+this.propertyName,this._doFocus).bind('blur.'+this.propertyName,this._doBlur).bind('click.'+this.propertyName,this._doClick).bind('keydown.'+this.propertyName,this._doKeyDown).bind('keypress.'+this.propertyName,this._doKeyPress).bind('paste.'+this.propertyName,function(a){setTimeout(function(){n._parseTime(e)},1)});this._optionPlugin(b,c)},_optionPlugin:function(a,b,c){a=$(a);var d=a.data(this.propertyName);if(!b||(typeof b=='string'&&c==null)){var e=b;b=(d||{}).options;return(b&&e?b[e]:b)}if(!a.hasClass(this.markerClassName)){return}b=b||{};if(typeof b=='string'){var e=b;b={};b[e]=c}var f=this._extractTime(d);$.extend(d.options,b);d._field=0;if(f){this._setTime(d,new Date(0,0,0,f[0],f[1],f[2]))}a.next('span.'+this._appendClass).remove();a.parent().find('span.'+this._controlClass).remove();if($.fn.mousewheel){a.unmousewheel()}var g=(!d.options.spinnerImage?null:$('<span class="'+this._controlClass+'" style="display: inline-block; '+'background: url(\''+d.options.spinnerImage+'\') 0 0 no-repeat; width: '+d.options.spinnerSize[0]+'px; height: '+d.options.spinnerSize[1]+'px;"></span>'));a.after(d.options.appendText?'<span class="'+this._appendClass+'">'+d.options.appendText+'</span>':'').after(g||'');if(d.options.useMouseWheel&&$.fn.mousewheel){a.mousewheel(this._doMouseWheel)}if(g){g.mousedown(this._handleSpinner).mouseup(this._endSpinner).mouseover(this._expandSpinner).mouseout(this._endSpinner).mousemove(this._describeSpinner)}},_enablePlugin:function(a){this._enableDisable(a,false)},_disablePlugin:function(a){this._enableDisable(a,true)},_enableDisable:function(b,c){var d=$.data(b,this.propertyName);if(!d){return}b.disabled=c;if(b.nextSibling&&b.nextSibling.nodeName.toLowerCase()=='span'){n._changeSpinner(d,b.nextSibling,(c?5:-1))}n._disabledInputs=$.map(n._disabledInputs,function(a){return(a==b?null:a)});if(c){n._disabledInputs.push(b)}},_isDisabledPlugin:function(a){return $.inArray(a,this._disabledInputs)>-1},_destroyPlugin:function(b){b=$(b);if(!b.hasClass(this.markerClassName)){return}b.removeClass(this.markerClassName).removeData(this.propertyName).unbind('.'+this.propertyName);if($.fn.mousewheel){b.unmousewheel()}this._disabledInputs=$.map(this._disabledInputs,function(a){return(a==b[0]?null:a)});b.siblings('.'+this._appendClass+',.'+this._controlClass).remove()},_setTimePlugin:function(a,b){var c=$.data(a,this.propertyName);if(c){if(b===null||b===''){c.input.val('')}else{this._setTime(c,b?(typeof b=='object'?new Date(b.getTime()):b):null)}}},_getTimePlugin:function(a){var b=$.data(a,this.propertyName);var c=(b?this._extractTime(b):null);return(!c?null:new Date(0,0,0,c[0],c[1],c[2]))},_getOffsetPlugin:function(a){var b=$.data(a,this.propertyName);var c=(b?this._extractTime(b):null);return(!c?0:(c[0]*3600+c[1]*60+c[2])*1000)},_doFocus:function(a){var b=(a.nodeName&&a.nodeName.toLowerCase()=='input'?a:this);if(n._lastInput==b||n._isDisabledPlugin(b)){n._focussed=false;return}var c=$.data(b,n.propertyName);n._focussed=true;n._lastInput=b;n._blurredInput=null;$.extend(c.options,($.isFunction(c.options.beforeShow)?c.options.beforeShow.apply(b,[b]):{}));n._parseTime(c);setTimeout(function(){n._showField(c)},10)},_doBlur:function(a){n._blurredInput=n._lastInput;n._lastInput=null},_doClick:function(b){var c=b.target;var d=$.data(c,n.propertyName);var e=d._field;if(!n._focussed){var f=d.options.separator.length+2;d._field=0;if(c.selectionStart!=null){for(var g=0;g<=Math.max(1,d._secondField,d._ampmField);g++){var h=(g!=d._ampmField?(g*f)+2:(d._ampmField*f)+d.options.ampmPrefix.length+d.options.ampmNames[0].length);d._field=g;if(c.selectionStart<h){break}}}else if(c.createTextRange){var i=$(b.srcElement);var j=c.createTextRange();var k=function(a){return{thin:2,medium:4,thick:6}[a]||a};var l=b.clientX+document.documentElement.scrollLeft-(i.offset().left+parseInt(k(i.css('border-left-width')),10))-j.offsetLeft;for(var g=0;g<=Math.max(1,d._secondField,d._ampmField);g++){var h=(g!=d._ampmField?(g*f)+2:(d._ampmField*f)+d.options.ampmPrefix.length+d.options.ampmNames[0].length);j.collapse();j.moveEnd('character',h);d._field=g;if(l<j.boundingWidth){break}}}}if(e!=d._field){d._lastChr=''}n._showField(d);n._focussed=false}
214,_doKeyDown:function(a){if(a.keyCode>=48){return true}var b=$.data(a.target,n.propertyName);switch(a.keyCode){case 9:return(a.shiftKey?n._changeField(b,-1,true):n._changeField(b,+1,true));case 35:if(a.ctrlKey){n._setValue(b,'')}else{b._field=Math.max(1,b._secondField,b._ampmField);n._adjustField(b,0)}break;case 36:if(a.ctrlKey){n._setTime(b)}else{b._field=0;n._adjustField(b,0)}break;case 37:n._changeField(b,-1,false);break;case 38:n._adjustField(b,+1);break;case 39:n._changeField(b,+1,false);break;case 40:n._adjustField(b,-1);break;case 46:n._setValue(b,'');break;default:return true}return false},_doKeyPress:function(a){var b=String.fromCharCode(a.charCode==undefined?a.keyCode:a.charCode);if(b<' '){return true}var c=$.data(a.target,n.propertyName);n._handleKeyPress(c,b);return false},_doMouseWheel:function(a,b){if(n._isDisabledPlugin(a.target)){return}var c=$.data(a.target,n.propertyName);c.input.focus();if(!c.input.val()){n._parseTime(c)}n._adjustField(c,b);a.preventDefault()},_expandSpinner:function(b){var c=n._getSpinnerTarget(b);var d=$.data(n._getInput(c),n.propertyName);if(n._isDisabledPlugin(d.input[0])){return}if(d.options.spinnerBigImage){d._expanded=true;var e=$(c).offset();var f=null;$(c).parents().each(function(){var a=$(this);if(a.css('position')=='relative'||a.css('position')=='absolute'){f=a.offset()}return!f});$('<div class="'+n._expandClass+'" style="position: absolute; left: '+(e.left-(d.options.spinnerBigSize[0]-d.options.spinnerSize[0])/2-(f?f.left:0))+'px; top: '+(e.top-(d.options.spinnerBigSize[1]-d.options.spinnerSize[1])/2-(f?f.top:0))+'px; width: '+d.options.spinnerBigSize[0]+'px; height: '+d.options.spinnerBigSize[1]+'px; background: transparent url('+d.options.spinnerBigImage+') no-repeat 0px 0px; z-index: 10;"></div>').mousedown(n._handleSpinner).mouseup(n._endSpinner).mouseout(n._endExpand).mousemove(n._describeSpinner).insertAfter(c)}},_getInput:function(a){return $(a).siblings('.'+n.markerClassName)[0]},_describeSpinner:function(a){var b=n._getSpinnerTarget(a);var c=$.data(n._getInput(b),n.propertyName);b.title=c.options.spinnerTexts[n._getSpinnerRegion(c,a)]},_handleSpinner:function(a){var b=n._getSpinnerTarget(a);var c=n._getInput(b);if(n._isDisabledPlugin(c)){return}if(c==n._blurredInput){n._lastInput=c;n._blurredInput=null}var d=$.data(c,n.propertyName);n._doFocus(c);var e=n._getSpinnerRegion(d,a);n._changeSpinner(d,b,e);n._actionSpinner(d,e);n._timer=null;n._handlingSpinner=true;if(e>=3&&d.options.spinnerRepeat[0]){n._timer=setTimeout(function(){n._repeatSpinner(d,e)},d.options.spinnerRepeat[0]);$(b).one('mouseout',n._releaseSpinner).one('mouseup',n._releaseSpinner)}},_actionSpinner:function(a,b){if(!a.input.val()){n._parseTime(a)}switch(b){case 0:this._setTime(a);break;case 1:this._changeField(a,-1,false);break;case 2:this._changeField(a,+1,false);break;case 3:this._adjustField(a,+1);break;case 4:this._adjustField(a,-1);break}},_repeatSpinner:function(a,b){if(!n._timer){return}n._lastInput=n._blurredInput;this._actionSpinner(a,b);this._timer=setTimeout(function(){n._repeatSpinner(a,b)},a.options.spinnerRepeat[1])},_releaseSpinner:function(a){clearTimeout(n._timer);n._timer=null},_endExpand:function(a){n._timer=null;var b=n._getSpinnerTarget(a);var c=n._getInput(b);var d=$.data(c,n.propertyName);$(b).remove();d._expanded=false},_endSpinner:function(a){n._timer=null;var b=n._getSpinnerTarget(a);var c=n._getInput(b);var d=$.data(c,n.propertyName);if(!n._isDisabledPlugin(c)){n._changeSpinner(d,b,-1)}if(n._handlingSpinner){n._lastInput=n._blurredInput}if(n._lastInput&&n._handlingSpinner){n._showField(d)}n._handlingSpinner=false},_getSpinnerTarget:function(a){return a.target||a.srcElement},_getSpinnerRegion:function(a,b){var c=this._getSpinnerTarget(b);var d=$(c).offset();var e=[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop];var f=(a.options.spinnerIncDecOnly?99:b.clientX+e[0]-d.left);var g=b.clientY+e[1]-d.top;var h=a.options[a._expanded?'spinnerBigSize':'spinnerSize'];var i=(a.options.spinnerIncDecOnly?99:h[0]-1-f);var j=h[1]-1-g;if(h[2]>0&&Math.abs(f-i)<=h[2]&&Math.abs(g-j)<=h[2]){return 0}var k=Math.min(f,g,i,j);return(k==f?1:(k==i?2:(k==g?3:4)))},_changeSpinner:function(a,b,c){$(b).css('background-position','-'+((c+1)*a.options[a._expanded?'spinnerBigSize':'spinnerSize'][0])+'px 0px')},_parseTime:function(a){var b=this._extractTime(a);if(b){a._selectedHour=b[0];a._selectedMinute=b[1];a._selectedSecond=b[2]}else{var c=this._constrainTime(a);a._selectedHour=c[0];a._selectedMinute=c[1];a._selectedSecond=(a.options.showSeconds?c[2]:0)}a._secondField=(a.options.showSeconds?2:-1);a._ampmField=(a.options.show24Hours?-1:(a.options.showSeconds?3:2));a._lastChr='';a._field=Math.max(0,Math.min(Math.max(1,a._secondField,a._ampmField),a.options.initialField));if(a.input.val()!=''){this._showTime(a)}},_extractTime:function(a,b){b=b||a.input.val();var c=b.split(a.options.separator);if(a.options.separator==''&&b!=''){c[0]=b.substring(0,2);c[1]=b.substring(2,4);c[2]=b.substring(4,6)}if(c.length>=2){var d=!a.options.show24Hours&&(b.indexOf(a.options.ampmNames[0])>-1);var e=!a.options.show24Hours&&(b.indexOf(a.options.ampmNames[1])>-1);var f=parseInt(c[0],10);f=(isNaN(f)?0:f);f=((d||e)&&f==12?0:f)+(e?12:0);var g=parseInt(c[1],10);g=(isNaN(g)?0:g);var h=(c.length>=3?parseInt(c[2],10):0);h=(isNaN(h)||!a.options.showSeconds?0:h);return this._constrainTime(a,[f,g,h])}return null}
214,_constrainTime:function(a,b){var c=(b!=null);if(!c){var d=this._determineTime(a.options.defaultTime,a)||new Date();b=[d.getHours(),d.getMinutes(),d.getSeconds()]}var e=false;for(var i=0;i<a.options.timeSteps.length;i++){if(e){b[i]=0}else if(a.options.timeSteps[i]>1){b[i]=Math.round(b[i]/a.options.timeSteps[i])*a.options.timeSteps[i];e=true}}return b},_showTime:function(a){var b=(this._formatNumber(a.options.show24Hours?a._selectedHour:((a._selectedHour+11)%12)+1)+a.options.separator+this._formatNumber(a._selectedMinute)+(a.options.showSeconds?a.options.separator+this._formatNumber(a._selectedSecond):'')+(a.options.show24Hours?'':a.options.ampmPrefix+a.options.ampmNames[(a._selectedHour<12?0:1)]));this._setValue(a,b);this._showField(a)},_showField:function(a){var b=a.input[0];if(a.input.is(':hidden')||n._lastInput!=b){return}var c=a.options.separator.length+2;var d=(a._field!=a._ampmField?(a._field*c):(a._ampmField*c)-a.options.separator.length+a.options.ampmPrefix.length);var e=d+(a._field!=a._ampmField?2:a.options.ampmNames[0].length);if(b.setSelectionRange){b.setSelectionRange(d,e)}else if(b.createTextRange){var f=b.createTextRange();f.moveStart('character',d);f.moveEnd('character',e-a.input.val().length);f.select()}if(!b.disabled){b.focus()}},_formatNumber:function(a){return(a<10?'0':'')+a},_setValue:function(a,b){if(b!=a.input.val()){a.input.val(b).trigger('change')}},_changeField:function(a,b,c){var d=(a.input.val()==''||a._field==(b==-1?0:Math.max(1,a._secondField,a._ampmField)));if(!d){a._field+=b}this._showField(a);a._lastChr='';return(d&&c)},_adjustField:function(a,b){if(a.input.val()==''){b=0}this._setTime(a,new Date(0,0,0,a._selectedHour+(a._field==0?b*a.options.timeSteps[0]:0)+(a._field==a._ampmField?b*12:0),a._selectedMinute+(a._field==1?b*a.options.timeSteps[1]:0),a._selectedSecond+(a._field==a._secondField?b*a.options.timeSteps[2]:0)))},_setTime:function(a,b){b=this._determineTime(b,a);var c=this._constrainTime(a,b?[b.getHours(),b.getMinutes(),b.getSeconds()]:null);b=new Date(0,0,0,c[0],c[1],c[2]);var b=this._normaliseTime(b);var d=this._normaliseTime(this._determineTime(a.options.minTime,a));var e=this._normaliseTime(this._determineTime(a.options.maxTime,a));if(d&&e&&d>e){if(b<d&&b>e){b=(Math.abs(b-d)<Math.abs(b-e)?d:e)}}else{b=(d&&b<d?d:(e&&b>e?e:b))}if($.isFunction(a.options.beforeSetTime)){b=a.options.beforeSetTime.apply(a.input[0],[this._getTimePlugin(a.input[0]),b,d,e])}a._selectedHour=b.getHours();a._selectedMinute=b.getMinutes();a._selectedSecond=b.getSeconds();this._showTime(a)},_determineTime:function(i,j){var k=function(a){var b=new Date();b.setTime(b.getTime()+a*1000);return b};var l=function(a){var b=n._extractTime(j,a);var c=new Date();var d=(b?b[0]:c.getHours());var e=(b?b[1]:c.getMinutes());var f=(b?b[2]:c.getSeconds());if(!b){var g=/([+-]?[0-9]+)\s*(s|S|m|M|h|H)?/g;var h=g.exec(a);while(h){switch(h[2]||'s'){case's':case'S':f+=parseInt(h[1],10);break;case'm':case'M':e+=parseInt(h[1],10);break;case'h':case'H':d+=parseInt(h[1],10);break}h=g.exec(a)}}c=new Date(0,0,10,d,e,f,0);if(/^!/.test(a)){if(c.getDate()>10){c=new Date(0,0,10,23,59,59)}else if(c.getDate()<10){c=new Date(0,0,10,0,0,0)}}return c};return(i?(typeof i=='string'?l(i):(typeof i=='number'?k(i):i)):null)},_normaliseTime:function(a){if(!a){return null}a.setFullYear(1900);a.setMonth(0);a.setDate(0);return a},_handleKeyPress:function(a,b){if(b==a.options.separator){this._changeField(a,+1,false)}else if(b>='0'&&b<='9'){var c=parseInt(b,10);var d=parseInt(a._lastChr+b,10);var e=(a._field!=0?a._selectedHour:(a.options.show24Hours?(d<24?d:c):(d>=1&&d<=12?d:(c>0?c:a._selectedHour))%12+(a._selectedHour>=12?12:0)));var f=(a._field!=1?a._selectedMinute:(d<60?d:c));var g=(a._field!=a._secondField?a._selectedSecond:(d<60?d:c));var h=this._constrainTime(a,[e,f,g]);this._setTime(a,new Date(0,0,0,h[0],h[1],h[2]));if(a.options.noSeparatorEntry&&a._lastChr){this._changeField(a,+1,false)}else{a._lastChr=b}}else if(!a.options.show24Hours){b=b.toLowerCase();if((b==a.options.ampmNames[0].substring(0,1).toLowerCase()&&a._selectedHour>=12)||(b==a.options.ampmNames[1].substring(0,1).toLowerCase()&&a._selectedHour<12)){var i=a._field;a._field=a._ampmField;
214this._adjustField(a,+1);a._field=i;this._showField(a)}}}});var m=['getOffset','getTime','isDisabled'];function isNotChained(a,b){if(a=='option'&&(b.length==0||(b.length==1&&typeof b[0]=='string'))){return true}return $.inArray(a,m)>-1}$.fn.timeEntry=function(b){var c=Array.prototype.slice.call(arguments,1);if(isNotChained(b,c)){return n['_'+b+'Plugin'].apply(n,[this[0]].concat(c))}return this.each(function(){if(typeof b=='string'){if(!n['_'+b+'Plugin']){throw'Unknown command: '+b;}n['_'+b+'Plugin'].apply(n,[this].concat(c))}else{var a=($.fn.metadata?$(this).metadata():{});n._attachPlugin(this,$.extend({},a,b||{}))}})};var n=$.timeEntry=new TimeEntry()})(jQuery); 215/* jshint ignore:end */; 216/*! 217 * jQuery Form Plugin 218 * version: 2.69 (06-APR-2011) 219 * @requires jQuery v1.3.2 or later 220 * 221 * Examples and documentation at: http://malsup.com/jquery/form/ 222 * Dual licensed under the MIT and GPL licenses: 223 * http://www.opensource.org/licenses/mit-license.php 224 * http://www.gnu.org/licenses/gpl.html 225 */ 226(function(a){function b(){if(a.fn.ajaxSubmit.debug){var b="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(b):window.opera&&window.opera.postError&&window.opera.postError(b)}}a.fn.ajaxSubmit=function(c){function r(){function t(){if(!j.aborted){var c=i.contentWindow?i.contentWindow.document:i.contentDocument?i.contentDocument:i.document;if(!c||c.location.href==e.iframeSrc)if(!m)return;i.detachEvent?i.detachEvent("onload",t):i.removeEventListener("load",t,!1);var d=!0;try{if(m)throw"timeout";var f=e.dataType=="xml"||c.XMLDocument||a.isXMLDoc(c);b("isXml="+f);if(!f&&window.opera&&(c.body==null||c.body.innerHTML=="")&&--s){b("requeing onLoad callback, DOM not available"),setTimeout(t,250);return}j.responseText=c.body?c.body.innerHTML:c.documentElement?c.documentElement.innerHTML:null,j.responseXML=c.XMLDocument?c.XMLDocument:c,j.getResponseHeader=function(a){var b={"content-type":e.dataType};return b[a]};var g=/(json|script)/.test(e.dataType);if(g||e.textarea){var l=c.getElementsByTagName("textarea")[0];if(l)j.responseText=l.value;else if(g){var n=c.getElementsByTagName("pre")[0],o=c.getElementsByTagName("body")[0];n?j.responseText=n.textContent:o&&(j.responseText=o.innerHTML)}}else e.dataType=="xml"&&!j.responseXML&&j.responseText!=null&&(j.responseXML=u(j.responseText));q=w(j,e.dataType,e)}catch(p){b("error caught:",p),d=!1,j.error=p,e.error&&e.error.call(e.context,j,"error",p),k&&a.event.trigger("ajaxError",[j,e,p])}j.aborted&&(b("upload aborted"),d=!1),d&&(e.success&&e.success.call(e.context,q,"success",j),k&&a.event.trigger("ajaxSuccess",[j,e])),k&&a.event.trigger("ajaxComplete",[j,e]),k&&!--a.active&&a.event.trigger("ajaxStop"),e.complete&&e.complete.call(e.context,j,d?"success":"error"),setTimeout(function(){h.removeData("form-plugin-onload"),h.remove(),j.responseXML=null},100)}}function p(){var b=l.attr("target"),c=l.attr("action");d.setAttribute("target",f),d.getAttribute("method")!="POST"&&d.setAttribute("method","POST"),d.getAttribute("action")!=e.url&&d.setAttribute("action",e.url),e.skipEncodingOverride||l.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),e.timeout&&setTimeout(function(){m=!0,t()},e.timeout);var g=[];try{if(e.extraData)for(var j in e.extraData)g.push(a('<input type="hidden" name="'+j+'" value="'+e.extraData[j]+'" />').appendTo(d)[0]);h.appendTo("body"),i.attachEvent?i.attachEvent("onload",t):i.addEventListener("load",t,!1),d.submit()}finally{d.setAttribute("action",c),b?d.setAttribute("target",b):l.removeAttr("target"),a(g).remove()}}var d=l[0];if(a(":input[name=submit],:input[id=submit]",d).length)alert('Error: Form elements must not have name or id of "submit".');else{var e=a.extend(!0,{},a.ajaxSettings,c);e.context=e.context||e;var f="jqFormIO"+(new Date).getTime(),g="_"+f,h=a('<iframe id="'+f+'" name="'+f+'" src="'+e.iframeSrc+'" />'),i=h[0];h.css({position:"absolute",top:"-1000px",left:"-1000px"});var j={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){b("aborting upload...");var c="aborted";this.aborted=1,h.attr("src",e.iframeSrc),j.error=c,e.error&&e.error.call(e.context,j,"error",c),k&&a.event.trigger("ajaxError",[j,e,c]),e.complete&&e.complete.call(e.context,j,"error")}},k=e.global;k&&!(a.active++)&&a.event.trigger("ajaxStart"),k&&a.event.trigger("ajaxSend",[j,e]);
226if(e.beforeSend&&e.beforeSend.call(e.context,j,e)===!1){e.global&&a.active--;return}if(j.aborted)return;var m=0,n=d.clk;if(n){var o=n.name;o&&!n.disabled&&(e.extraData=e.extraData||{},e.extraData[o]=n.value,n.type=="image"&&(e.extraData[o+".x"]=d.clk_x,e.extraData[o+".y"]=d.clk_y))}e.forceSync?p():setTimeout(p,10);var q,r,s=50,u=a.parseXML||function(a,b){window.ActiveXObject?(b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a)):b=(new DOMParser).parseFromString(a,"text/xml");return b&&b.documentElement&&b.documentElement.nodeName!="parsererror"?b:null},v=a.parseJSON||function(a){return window.eval("("+a+")")},w=function(b,c,d){var e=b.getResponseHeader("content-type")||"",f=c==="xml"||!c&&e.indexOf("xml")>=0,g=f?b.responseXML:b.responseText;f&&g.documentElement.nodeName==="parsererror"&&a.error&&a.error("parsererror"),d&&d.dataFilter&&(g=d.dataFilter(g,c)),typeof g=="string"&&(c==="json"||!c&&e.indexOf("json")>=0?g=v(g):(c==="script"||!c&&e.indexOf("javascript")>=0)&&a.globalEval(g));return g}}}if(!this.length){b("ajaxSubmit: skipping submit process - no element selected");return this}typeof c=="function"&&(c={success:c});var d=this.attr("action"),e=typeof d=="string"?a.trim(d):"";e&&(e=(e.match(/^([^#]+)/)||[])[1]),e=e||window.location.href||"",c=a.extend(!0,{url:e,success:a.ajaxSettings.success,type:this[0].getAttribute("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},c);var f={};this.trigger("form-pre-serialize",[this,c,f]);if(f.veto){b("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(c.beforeSerialize&&c.beforeSerialize(this,c)===!1){b("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var g,h,i=this.formToArray(c.semantic);if(c.data){c.extraData=c.data;for(g in c.data)if(c.data[g]instanceof Array)for(var j in c.data[g])i.push({name:g,value:c.data[g][j]});else h=c.data[g],h=a.isFunction(h)?h():h,i.push({name:g,value:h})}if(c.beforeSubmit&&c.beforeSubmit(i,this,c)===!1){b("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[i,this,c,f]);if(f.veto){b("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var k=a.param(i);c.type.toUpperCase()=="GET"?(c.url+=(c.url.indexOf("?")>=0?"&":"?")+k,c.data=null):c.data=k;var l=this,m=[];c.resetForm&&m.push(function(){l.resetForm()}),c.clearForm&&m.push(function(){l.clearForm()});if(!c.dataType&&c.target){var n=c.success||function(){};m.push(function(b){var d=c.replaceTarget?"replaceWith":"html";a(c.target)[d](b).each(n,arguments)})}else c.success&&m.push(c.success);c.success=function(a,b,d){var e=c.context||c;for(var f=0,g=m.length;f<g;f++)m[f].apply(e,[a,b,d||l,l])};var o=a("input:file",this).length>0,p="multipart/form-data",q=l.attr("enctype")==p||l.attr("encoding")==p;c.iframe!==!1&&(o||c.iframe||q)?c.closeKeepAlive?a.get(c.closeKeepAlive,r):r():a.ajax(c),this.trigger("form-submit-notify",[this,c]);return this},a.fn.ajaxForm=function(c){if(this.length===0){var d={s:this.selector,c:this.context};if(!a.isReady&&d.s){b("DOM not ready, queuing ajaxForm"),a(function(){a(d.s,d.c).ajaxForm(c)});return this}b("terminating; zero elements found by selector"+(a.isReady?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(b){b.isDefaultPrevented()||(b.preventDefault(),a(this).ajaxSubmit(c))}).bind("click.form-plugin",function(b){var c=b.target,d=a(c);if(!d.is(":submit,input:image")){var e=d.closest(":submit");if(e.length==0)return;c=e[0]}var f=this;f.clk=c;if(c.type=="image")if(b.offsetX!=undefined)f.clk_x=b.offsetX,f.clk_y=b.offsetY;else if(typeof a.fn.offset=="function"){var g=d.offset();f.clk_x=b.pageX-g.left,f.clk_y=b.pageY-g.top}else f.clk_x=b.pageX-c.offsetLeft,f.clk_y=b.pageY-c.offsetTop;setTimeout(function(){f.clk=f.clk_x=f.clk_y=null},100)})},a.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},a.fn.formToArray=function(b){var c=[];if(this.length===0)return c;var d=this[0],e=b?d.getElementsByTagName("*"):d.elements;if(!e)return c;var f,g,h,i,j,k,l;
226for(f=0,k=e.length;f<k;f++){j=e[f],h=j.name;if(!h)continue;if(b&&d.clk&&j.type=="image"){!j.disabled&&d.clk==j&&(c.push({name:h,value:a(j).val()}),c.push({name:h+".x",value:d.clk_x},{name:h+".y",value:d.clk_y}));continue}i=a.fieldValue(j,!0);if(i&&i.constructor==Array)for(g=0,l=i.length;g<l;g++)c.push({name:h,value:i[g]});else i!==null&&typeof i!="undefined"&&c.push({name:h,value:i})}if(!b&&d.clk){var m=a(d.clk),n=m[0];h=n.name,h&&!n.disabled&&n.type=="image"&&(c.push({name:h,value:m.val()}),c.push({name:h+".x",value:d.clk_x},{name:h+".y",value:d.clk_y}))}return c},a.fn.formSerialize=function(b){return a.param(this.formToArray(b))},a.fn.fieldSerialize=function(b){var c=[];this.each(function(){var d=this.name;if(!!d){var e=a.fieldValue(this,b);if(e&&e.constructor==Array)for(var f=0,g=e.length;f<g;f++)c.push({name:d,value:e[f]});else e!==null&&typeof e!="undefined"&&c.push({name:this.name,value:e})}});return a.param(c)},a.fn.fieldValue=function(b){for(var c=[],d=0,e=this.length;d<e;d++){var f=this[d],g=a.fieldValue(f,b);if(g===null||typeof g=="undefined"||g.constructor==Array&&!g.length)continue;
226g.constructor==Array?a.merge(c,g):c.push(g)}return c},a.fieldValue=function(b,c){var d=b.name,e=b.type,f=b.tagName.toLowerCase();c===undefined&&(c=!0);if(c&&(!d||b.disabled||e=="reset"||e=="button"||(e=="checkbox"||e=="radio")&&!b.checked||(e=="submit"||e=="image")&&b.form&&b.form.clk!=b||f=="select"&&b.selectedIndex==-1))return null;if(f=="select"){var g=b.selectedIndex;if(g<0)return null;var h=[],i=b.options,j=e=="select-one",k=j?g+1:i.length;for(var l=j?g:0;l<k;l++){var m=i[l];if(m.selected){var n=m.value;n||(n=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value);if(j)return n;h.push(n)}}return h}return a(b).val()},a.fn.clearForm=function(){return this.each(function(){a("input,select,textarea",this).clearFields()})},a.fn.clearFields=a.fn.clearInputs=function(){return this.each(function(){var a=this.type,b=this.tagName.toLowerCase();a=="text"||a=="password"||b=="textarea"?this.value="":a=="checkbox"||a=="radio"?this.checked=!1:b=="select"&&(this.selectedIndex=-1)})},a.fn.resetForm=function(){return this.each(function(){(typeof this.reset=="function"||typeof this.reset=="object"&&!this.reset.nodeType)&&this.reset()})},a.fn.enable=function(a){a===undefined&&(a=!0);return this.each(function(){this.disabled=!a})},a.fn.selected=function(b){b===undefined&&(b=!0);return this.each(function(){var c=this.type;if(c=="checkbox"||c=="radio")this.checked=b;else if(this.tagName.toLowerCase()=="option"){var d=a(this).parent("select");b&&d[0]&&d[0].type=="select-one"&&d.find("option").selected(!1),this.selected=b}})}})(jQuery); 227(function ($) { 228 229/** 230 * Provides Ajax page updating via jQuery $.ajax (Asynchronous JavaScript and XML). 231 * 232 * Ajax is a method of making a request via JavaScript while viewing an HTML 233 * page. The request returns an array of commands encoded in JSON, which is 234 * then executed to make any changes that are necessary to the page. 235 * 236 * Drupal uses this file to enhance form elements with #ajax['path'] and 237 * #ajax['wrapper'] properties. If set, this file will automatically be included 238 * to provide Ajax capabilities. 239 */ 240 241Drupal.ajax = Drupal.ajax || {}; 242 243Drupal.settings.urlIsAjaxTrusted = Drupal.settings.urlIsAjaxTrusted || {}; 244 245/** 246 * Attaches the Ajax behavior to each Ajax form element. 247 */ 248Drupal.behaviors.AJAX = { 249 attach: function (context, settings) { 250 // Load all Ajax behaviors specified in the settings. 251 for (var base in settings.ajax) { 252 if (!$('#' + base + '.ajax-processed').length) { 253 var element_settings = settings.ajax[base]; 254 255 if (typeof element_settings.selector == 'undefined') { 256 element_settings.selector = '#' + base; 257 } 258 $(element_settings.selector).each(function () { 259 element_settings.element = this; 260 Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); 261 }); 262 263 $('#' + base).addClass('ajax-processed'); 264 } 265 } 266 267 // Bind Ajax behaviors to all items showing the class. 268 $('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { 269 var element_settings = {}; 270 // Clicked links look better with the throbber than the progress bar. 271 element_settings.progress = { 'type': 'throbber' }; 272 273 // For anchor tags, these will go to the target of the anchor rather 274 // than the usual location. 275 if ($(this).attr('href')) { 276 element_settings.url = $(this).attr('href'); 277 element_settings.event = 'click'; 278 } 279 var base = $(this).attr('id'); 280 Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); 281 }); 282 283 // This class means to submit the form to the action using Ajax. 284 $('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { 285 var element_settings = {}; 286 287 // Ajax submits specified in this manner automatically submit to the 288 // normal form action. 289 element_settings.url = $(this.form).attr('action'); 290 // Form submit button clicks need to tell the form what was clicked so 291 // it gets passed in the POST request. 292 element_settings.setClick = true; 293 // Form buttons use the 'click' event rather than mousedown. 294 element_settings.event = 'click'; 295 // Clicked form buttons look better with the throbber than the progress bar. 296 element_settings.progress = { 'type': 'throbber' }; 297 298 var base = $(this).attr('id'); 299 Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); 300 }); 301 } 302}; 303 304/** 305 * Ajax object. 306 * 307 * All Ajax objects on a page are accessible through the global Drupal.ajax 308 * object and are keyed by the submit button's ID. You can access them from 309 * your module's JavaScript file to override properties or functions. 310 * 311 * For example, if your Ajax enabled button has the ID 'edit-submit', you can 312 * redefine the function that is called to insert the new content like this 313 * (inside a Drupal.behaviors attach block): 314 * @code 315 * Drupal.behaviors.myCustomAJAXStuff = { 316 * attach: function (context, settings) { 317 * Drupal.ajax['edit-submit'].commands.insert = function (ajax, response, status) { 318 * new_content = $(response.data); 319 * $('#my-wrapper').append(new_content); 320 * alert('New content was appended to #my-wrapper'); 321 * } 322 * } 323 * }; 324 * @endcode 325 */ 326Drupal.ajax = function (base, element, element_settings) { 327 var defaults = { 328 url: 'system/ajax', 329 event: 'mousedown', 330 keypress: true, 331 selector: '#' + base, 332 effect: 'none', 333 speed: 'none', 334 method: 'replaceWith', 335 progress: { 336 type: 'throbber', 337 message: Drupal.t('Please wait...') 338 }, 339 submit: { 340 'js': true 341 } 342 }; 343 344 $.extend(this, defaults, element_settings); 345 346 this.element = element; 347 this.element_settings = element_settings; 348 349 // Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let 350 // the server detect when it needs to degrade gracefully. 351 // There are five scenarios to check for: 352 // 1. /nojs/ 353 // 2. /nojs$ - The end of a URL string. 354 // 3. /nojs? - Followed by a query (with clean URLs enabled). 355 // E.g.: path/nojs?destination=foobar 356 // 4. /nojs& - Followed by a query (without clean URLs enabled). 357 // E.g.: ?q=path/nojs&destination=foobar 358 // 5. /nojs# - Followed by a fragment. 359 // E.g.: path/nojs#myfragment 360 this.url = element_settings.url.replace(/\/nojs(\/|$|\?|&|#)/g, '/ajax$1'); 361 // If the 'nojs' version of the URL is trusted, also trust the 'ajax' version. 362 if (Drupal.settings.urlIsAjaxTrusted[element_settings.url]) { 363 Drupal.settings.urlIsAjaxTrusted[this.url] = true; 364 } 365 366 this.wrapper = '#' + element_settings.wrapper; 367 368 // If there isn't a form, jQuery.ajax() will be used instead, allowing us to 369 // bind Ajax to links as well. 370 if (this.element.form) { 371 this.form = $(this.element.form); 372 } 373 374 // Set the options for the ajaxSubmit function. 375 // The 'this' variable will not persist inside of the options object. 376 var ajax = this; 377 ajax.options = { 378 url: Drupal.sanitizeAjaxUrl(ajax.url), 379 data: ajax.submit, 380 beforeSerialize: function (element_settings, options) { 381 return ajax.beforeSerialize(element_settings, options); 382 }, 383 beforeSubmit: function (form_values, element_settings, options) { 384 ajax.ajaxing = true; 385 return ajax.beforeSubmit(form_values, element_settings, options); 386 }, 387 beforeSend: function (xmlhttprequest, options) { 388 ajax.ajaxing = true; 389 return ajax.beforeSend(xmlhttprequest, options); 390 }, 391 success: function (response, status, xmlhttprequest) { 392 // Sanity check for browser support (object expected). 393 // When using iFrame uploads, responses must be returned as a string. 394 if (typeof response == 'string') { 395 response = $.parseJSON(response); 396 } 397 398 // Prior to invoking the response's commands, verify that they can be 399 // trusted by checking for a response header. See 400 // ajax_set_verification_header() for details. 401 // - Empty responses are harmless so can bypass verification. This avoids 402 // an alert message for server-generated no-op responses that skip Ajax 403 // rendering. 404 // - Ajax objects with trusted URLs (e.g., ones defined server-side via 405 // #ajax) can bypass header verification. This is especially useful for 406 // Ajax with multipart forms. Because IFRAME transport is used, the 407 // response headers cannot be accessed for verification. 408 if (response !== null && !Drupal.settings.urlIsAjaxTrusted[ajax.url]) { 409 if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') { 410 var customMessage = Drupal.t("The response failed verification so will not be processed."); 411 return ajax.error(xmlhttprequest, ajax.url, customMessage); 412 } 413 } 414 415 return ajax.success(response, status); 416 }, 417 complete: function (xmlhttprequest, status) { 418 ajax.ajaxing = false;
419 if (status == 'error' || status == 'parsererror') { 420 return ajax.error(xmlhttprequest, ajax.url); 421 } 422 }, 423 dataType: 'json', 424 jsonp: false, 425 type: 'POST' 426 }; 427 428 // For multipart forms (e.g., file uploads), jQuery Form targets the form 429 // submission to an iframe instead of using an XHR object. The initial "src" 430 // of the iframe, prior to the form submission, is set to options.iframeSrc. 431 // "about:blank" is the semantically correct, standards-compliant, way to 432 // initialize a blank iframe; however, some old IE versions (possibly only 6) 433 // incorrectly report a mixed content warning when iframes with an 434 // "about:blank" src are added to a parent document with an https:// origin. 435 // jQuery Form works around this by defaulting to "javascript:false" instead, 436 // but that breaks on Chrome 83, so here we force the semantically correct 437 // behavior for all browsers except old IE. 438 // @see https://www.drupal.org/project/drupal/issues/3143016 439 // @see https://github.com/jquery-form/form/blob/df9cb101b9c9c085c8d75ad980c7ff1cf62063a1/jquery.form.js#L68 440 // @see https://bugs.chromium.org/p/chromium/issues/detail?id=1084874 441 // @see https://html.spec.whatwg.org/multipage/browsers.html#creating-browsing-contexts 442 // @see https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy 443 if (navigator.userAgent.indexOf("MSIE") === -1) { 444 ajax.options.iframeSrc = 'about:blank'; 445 } 446 447 // Bind the ajaxSubmit function to the element event. 448 $(ajax.element).bind(element_settings.event, function (event) { 449 if (!Drupal.settings.urlIsAjaxTrusted[ajax.url] && !Drupal.urlIsLocal(ajax.url)) { 450 throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', {'!url': ajax.url})); 451 } 452 return ajax.eventResponse(this, event); 453 }); 454 455 // If necessary, enable keyboard submission so that Ajax behaviors 456 // can be triggered through keyboard input as well as e.g. a mousedown 457 // action. 458 if (element_settings.keypress) { 459 $(ajax.element).keypress(function (event) { 460 return ajax.keypressResponse(this, event); 461 }); 462 } 463 464 // If necessary, prevent the browser default action of an additional event. 465 // For example, prevent the browser default action of a click, even if the 466 // AJAX behavior binds to mousedown. 467 if (element_settings.prevent) { 468 $(ajax.element).bind(element_settings.prevent, false); 469 } 470}; 471 472/** 473 * Handle a key press. 474 * 475 * The Ajax object will, if instructed, bind to a key press response. This 476 * will test to see if the key press is valid to trigger this event and 477 * if it is, trigger it for us and prevent other keypresses from triggering. 478 * In this case we're handling RETURN and SPACEBAR keypresses (event codes 13 479 * and 32. RETURN is often used to submit a form when in a textfield, and 480 * SPACE is often used to activate an element without submitting. 481 */ 482Drupal.ajax.prototype.keypressResponse = function (element, event) { 483 // Create a synonym for this to reduce code confusion. 484 var ajax = this; 485 486 // Detect enter key and space bar and allow the standard response for them, 487 // except for form elements of type 'text' and 'textarea', where the 488 // spacebar activation causes inappropriate activation if #ajax['keypress'] is 489 // TRUE. On a text-type widget a space should always be a space. 490 if (event.which == 13 || (event.which == 32 && element.type != 'text' && element.type != 'textarea')) { 491 $(ajax.element_settings.element).trigger(ajax.element_settings.event); 492 return false; 493 } 494}; 495 496/** 497 * Handle an event that triggers an Ajax response. 498 * 499 * When an event that triggers an Ajax response happens, this method will 500 * perform the actual Ajax call. It is bound to the event using 501 * bind() in the constructor, and it uses the options specified on the 502 * ajax object. 503 */ 504Drupal.ajax.prototype.eventResponse = function (element, event) { 505 // Create a synonym for this to reduce code confusion. 506 var ajax = this; 507 508 // Do not perform another ajax command if one is already in progress. 509 if (ajax.ajaxing) { 510 return false; 511 } 512 513 try { 514 if (ajax.form) { 515 // If setClick is set, we must set this to ensure that the button's 516 // value is passed. 517 if (ajax.setClick) { 518 // Mark the clicked button. 'form.clk' is a special variable for 519 // ajaxSubmit that tells the system which element got clicked to 520 // trigger the submit. Without it there would be no 'op' or
521 // equivalent. 522 element.form.clk = element; 523 } 524 525 ajax.form.ajaxSubmit(ajax.options); 526 } 527 else { 528 ajax.beforeSerialize(ajax.element, ajax.options); 529 $.ajax(ajax.options); 530 } 531 } 532 catch (e) { 533 // Unset the ajax.ajaxing flag here because it won't be unset during 534 // the complete response. 535 ajax.ajaxing = false; 536 alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); 537 } 538 539 // For radio/checkbox, allow the default event. On IE, this means letting 540 // it actually check the box. 541 if (typeof element.type != 'undefined' && (element.type == 'checkbox' || element.type == 'radio')) { 542 return true; 543 } 544 else { 545 return false; 546 } 547 548}; 549 550/** 551 * Handler for the form serialization. 552 * 553 * Runs before the beforeSend() handler (see below), and unlike that one, runs 554 * before field data is collected. 555 */ 556Drupal.ajax.prototype.beforeSerialize = function (element, options) { 557 // Allow detaching behaviors to update field values before collecting them. 558 // This is only needed when field values are added to the POST data, so only 559 // when there is a form such that this.form.ajaxSubmit() is used instead of 560 // $.ajax(). When there is no form and $.ajax() is used, beforeSerialize() 561 // isn't called, but don't rely on that: explicitly check this.form. 562 if (this.form) { 563 var settings = this.settings || Drupal.settings; 564 Drupal.detachBehaviors(this.form, settings, 'serialize'); 565 } 566 567 // Prevent duplicate HTML ids in the returned markup. 568 // @see drupal_html_id() 569 options.data['ajax_html_ids[]'] = []; 570 $('[id]').each(function () { 571 options.data['ajax_html_ids[]'].push(this.id); 572 }); 573 574 // Allow Drupal to return new JavaScript and CSS files to load without 575 // returning the ones already loaded. 576 // @see ajax_base_page_theme() 577 // @see drupal_get_css() 578 // @see drupal_get_js() 579 options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme; 580 options.data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token; 581 for (var key in Drupal.settings.ajaxPageState.css) { 582 options.data['ajax_page_state[css][' + key + ']'] = 1; 583 } 584 for (var key in Drupal.settings.ajaxPageState.js) { 585 options.data['ajax_page_state[js][' + key + ']'] = 1; 586 } 587}; 588 589/** 590 * Modify form values prior to form submission. 591 */ 592Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { 593 // This function is left empty to make it simple to override for modules 594 // that wish to add functionality here. 595}; 596 597/** 598 * Prepare the Ajax request before it is sent. 599 */ 600Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { 601 // For forms without file inputs, the jQuery Form plugin serializes the form 602 // values, and then calls jQuery's $.ajax() function, which invokes this 603 // handler. In this circumstance, options.extraData is never used. For forms 604 // with file inputs, the jQuery Form plugin uses the browser's normal form 605 // submission mechanism, but captures the response in a hidden IFRAME. In this 606 // circumstance, it calls this handler first, and then appends hidden fields 607 // to the form to submit the values in options.extraData. There is no simple 608 // way to know which submission mechanism will be used, so we add to extraData 609 // regardless, and allow it to be ignored in the former case. 610 if (this.form) { 611 options.extraData = options.extraData || {}; 612 613 // Let the server know when the IFRAME submission mechanism is used. The 614 // server can use this information to wrap the JSON response in a TEXTAREA, 615 // as per http://jquery.malsup.com/form/#file-upload. 616 options.extraData.ajax_iframe_upload = '1'; 617 618 // The triggering element is about to be disabled (see below), but if it 619 // contains a value (e.g., a checkbox, textfield, select, etc.), ensure that 620 // value is included in the submission. As per above, submissions that use 621 // $.ajax() are already serialized prior to the element being disabled, so 622 // this is only needed for IFRAME submissions. 623 var v = $.fieldValue(this.element); 624 if (v !== null) { 625 options.extraData[this.element.name] = Drupal.checkPlain(v); 626 } 627 } 628 629 // Disable the element that received the change to prevent user interface 630 // interaction while the Ajax request is in progress. ajax.ajaxing prevents 631 // the element from triggering a new request, but does not prevent the user 632 // from changing its value. 633 $(this.element).addClass('progress-disabled').attr('disabled', true); 634 635 // Insert progressbar or throbber. 636 if (this.progress.type == 'bar') { 637 var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.i
637d, $.noop, this.progress.method, $.noop); 638 if (this.progress.message) { 639 progressBar.setProgress(-1, this.progress.message); 640 } 641 if (this.progress.url) { 642 progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500); 643 } 644 this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar'); 645 this.progress.object = progressBar; 646 $(this.element).after(this.progress.element); 647 } 648 else if (this.progress.type == 'throbber') { 649 this.progress.element = $('<div class="ajax-progress ajax-progress-throbber"><div class="throbber"> </div></div>'); 650 if (this.progress.message) { 651 $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>'); 652 } 653 $(this.element).after(this.progress.element); 654 } 655}; 656 657/** 658 * Handler for the form redirection completion. 659 */ 660Drupal.ajax.prototype.success = function (response, status) { 661 // Remove the progress element. 662 if (this.progress.element) { 663 $(this.progress.element).remove(); 664 } 665 if (this.progress.object) { 666 this.progress.object.stopMonitoring(); 667 } 668 $(this.element).removeClass('progress-disabled').removeAttr('disabled'); 669 670 Drupal.freezeHeight(); 671 672 for (var i in response) { 673 if (response.hasOwnProperty(i) && response[i]['command'] && this.commands[response[i]['command']]) { 674 this.commands[response[i]['command']](this, response[i], status); 675 } 676 } 677 678 // Reattach behaviors, if they were detached in beforeSerialize(). The 679 // attachBehaviors() called on the new content from processing the response 680 // commands is not sufficient, because behaviors from the entire form need 681 // to be reattached. 682 if (this.form) { 683 var settings = this.settings || Drupal.settings; 684 Drupal.attachBehaviors(this.form, settings); 685 } 686 687 Drupal.unfreezeHeight(); 688 689 // Remove any response-specific settings so they don't get used on the next 690 // call by mistake. 691 this.settings = null; 692}; 693 694/** 695 * Build an effect object which tells us how to apply the effect when adding new HTML. 696 */ 697Drupal.ajax.prototype.getEffect = function (response) { 698 var type = response.effect || this.effect; 699 var speed = response.speed || this.speed; 700 701 var effect = {}; 702 if (type == 'none') { 703 effect.showEffect = 'show'; 704 effect.hideEffect = 'hide'; 705 effect.showSpeed = ''; 706 } 707 else if (type == 'fade') { 708 effect.showEffect = 'fadeIn'; 709 effect.hideEffect = 'fadeOut'; 710 effect.showSpeed = speed; 711 } 712 else { 713 effect.showEffect = type + 'Toggle'; 714 effect.hideEffect = type + 'Toggle'; 715 effect.showSpeed = speed; 716 } 717 718 return effect; 719}; 720 721/** 722 * Handler for the form redirection error. 723 */ 724Drupal.ajax.prototype.error = function (xmlhttprequest, uri, customMessage) { 725 Drupal.displayAjaxError(Drupal.ajaxError(xmlhttprequest, uri, customMessage)); 726 // Remove the progress element. 727 if (this.progress.element) { 728 $(this.progress.element).remove(); 729 } 730 if (this.progress.object) { 731 this.progress.object.stopMonitoring(); 732 } 733 // Undo hide. 734 $(this.wrapper).show(); 735 // Re-enable the element. 736 $(this.element).removeClass('progress-disabled').removeAttr('disabled'); 737 // Reattach behaviors, if they were detached in beforeSerialize(). 738 if (this.form) { 739 var settings = this.settings || Drupal.settings; 740 Drupal.attachBehaviors(this.form, settings); 741 } 742}; 743 744/** 745 * Provide a series of commands that the server can request the client perform. 746 */ 747Drupal.ajax.prototype.commands = { 748 /** 749 * Command to insert new content into the DOM. 750 */ 751 insert: function (ajax, response, status) { 752 // Get information from the response. If it is not there, default to 753 // our presets. 754 var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); 755 var method = response.method || ajax.method; 756 var effect = ajax.getEffect(response); 757 758 // We don't know what response.data contains: it might be a string of text 759 // without HTML, so don't rely on jQuery correctly iterpreting 760 // $(response.data) as new HTML rather than a CSS selector. Also, if 761 // response.data contains top-level text nodes, they get lost with either 762 // $(response.data) or $('<div></div>').replaceWith(response.data). 763 var new_content_wrapped = $('<div></div>').html(response.data); 764 var new_content = new_content_wrapped.contents(); 765 766 // For legacy reasons, the effects processing code assumes that new_content 767 // consists of a single top-level element. Also, it has not been 768 // sufficiently tested whether attachBehaviors() can be successfully called 769 // with a context object that includes top-level text nodes. However, to 770 // give developers full control of the HTML appearing in the page, and to 771 // enable Ajax content to be inserted in places where DIV elements are not 772 // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new 773 // content satisfies the requirement of a single top-level element, and 774 // only use the container DIV created above when it doesn't. For more 775 // information, please see http://drupal.org/node/736066. 776 if (new_content.length != 1 || new_content.get(0).nodeType != 1) { 777 new_content = new_content_wrapped; 778 } 779 780 // If removing content from the wrapper, detach behaviors first. 781 switch (method) { 782 case 'html': 783 case 'replaceWith': 784 case 'replaceAll': 785 case 'empty': 786 case 'remove': 787 var settings = response.settings || ajax.settings || Drupal.settings; 788 Drupal.detachBehaviors(wrapper, settings); 789 } 790 791 // Add the new content to the page. 792 wrapper[method](new_content); 793 794 // Immediately hide the new content if we're using any effects. 795 if (effect.showEffect != 'show') { 796 new_content.hide(); 797 } 798 799 // Determine which effect to use and what content will receive the 800 // effect, then show the new content. 801 if ($('.ajax-new-content', new_content).length > 0) { 802 $('.ajax-new-content', new_content).hide(); 803 new_content.show(); 804 $('.ajax-new-content', new_content)[effect.showEffect](effect.showSpeed); 805 } 806 else if (effect.showEffect != 'show') { 807 new_content[effect.showEffect](effect.showSpeed); 808 } 809 810 // Attach all JavaScript behaviors to the new content, if it was successfully 811 // added to the page, this if statement allows #ajax['wrapper'] to be 812 // optional. 813 if (new_content.parents('html').length > 0) { 814 // Apply any settings from the returned JSON if available. 815 var settings = response.settings || ajax.settings || Drupal.settings; 816 Drupal.attachBehaviors(new_content, settings); 817 } 818 }, 819 820 /** 821 * Command to remove a chunk from the page. 822 */ 823 remove: function (ajax, response, status) { 824 var settings = response.settings || ajax.settings || Drupal.settings; 825 Drupal.detachBehaviors($(response.selector), settings); 826 $(response.selector).remove(); 827 }, 828 829 /** 830 * Command to mark a chunk changed. 831 */ 832 changed: function (ajax, response, status) { 833 if (!$(response.selector).hasClass('ajax-changed')) { 834 $(response.selector).addClass('ajax-changed'); 835 if (response.asterisk) { 836 $(response.selector).find(response.asterisk).append(' <span class="ajax-changed">*</span> '); 837 } 838 } 839 }, 840 841 /** 842 * Command to provide an alert. 843 */ 844 alert: function (ajax, response, status) { 845 alert(response.text, response.title); 846 }, 847 848 /** 849 * Command to provide the jQuery css() function. 850 */ 851 css: function (ajax, response, status) { 852 $(response.selector).css(response.argument); 853 }, 854 855 /** 856 * Command to set the settings that will be used for other commands in this response. 857 */ 858 settings: function (ajax, response, status) { 859 if (response.merge) { 860 $.extend(true, Drupal.settings, response.settings); 861 } 862 else { 863 ajax.settings = response.settings; 864 } 865 }, 866 867 /** 868 * Command to attach data using jQuery's data API. 869 */ 870 data: function (ajax, response, status) { 871 $(response.selector).data(response.name, response.value); 872 }, 873 874 /** 875 * Command to apply a jQuery method. 876 */ 877 invoke: function (ajax, response, status) { 878 var $element = $(response.selector); 879 $element[response.method].apply($element, response.arguments); 880 }, 881 882 /** 883 * Command to restripe a table. 884 */ 885 restripe: function (ajax, response, status) { 886 // :even and :odd are reversed because jQuery counts from 0 and 887 // we count from 1, so we're out of sync. 888 // Match immediate children of the parent element to allow nesting. 889 $('> tbody > tr:visible, > tr:visible', $(response.selector)) 890 .removeClass('odd even') 891 .filter(':even').addClass('odd').end() 892 .filter(':odd').addClass('even'); 893 }, 894 895 /** 896 * Command to add css. 897 * 898 * Uses the proprietary addImport method if available as browsers which 899 * support that method ignore @import statements in dynamically added 900 * stylesheets. 901 */ 902 add_css: function (ajax, response, status) { 903 // Add the styles in the normal way. 904 $('head').prepend(response.data); 905 // Add imports in the styles using the addImport method if available. 906 var match, importMatch = /^@import url\("(.*)"\);$/igm; 907 if (document.styleSheets[0].addImport && importMatch.test(response.data)) { 908 importMatch.lastIndex = 0; 909 while (match = importMatch.exec(response.data)) { 910 document.styleSheets[0].addImport(match[1]); 911 } 912 } 913 }, 914 915 /** 916 * Command to update a form's build ID. 917 */ 918 updateBuildId: function(ajax, response, status) { 919 $('input[name="form_build_id"][value="' + response['old'] + '"]').val(response['new']); 920 } 921}; 922 923})(jQuery); 924; 925(function (D) { 926 var beforeSerialize = D.ajax.prototype.beforeSerialize;
927 D.ajax.prototype.beforeSerialize = function (element, options) { 928 beforeSerialize.call(this, element, options); 929 options.data['ajax_page_state[jquery_version]'] = D.settings.ajaxPageState.jquery_version; 930 } 931})(Drupal); 932;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.