_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q30300
train
function() { inputEx.Form.superclass.disable.call(this); for (var i = 0 ; i < this.buttons.length ; i++) { this.buttons[i].disable(); } }
javascript
{ "resource": "" }
q30301
train
function(parentEl) { this.appendSeparator(0); if(!this.options.fields) {return;} var i, n=this.options.fields.length, f, field, fieldEl,t; for(i = 0 ; i < n ; i++) { f = this.options.fields[i]; if (this.options.required) {f.required = true;} field = this.renderField(f); fieldEl = field.getEl(); t = f.type; if(t != "group" && t != "form") { // remove the line breaker (<div style='clear: both;'>) field.divEl.removeChild(fieldEl.childNodes[fieldEl.childNodes.length-1]); } // make the field float left Dom.setStyle(fieldEl, 'float', 'left'); this.divEl.appendChild(fieldEl); this.appendSeparator(i+1); } this.setFieldName(this.options.name); }
javascript
{ "resource": "" }
q30302
train
function(fieldOptions) { // Subfields should inherit required property if (this.options.required) { fieldOptions.required = true; } return inputEx.CombineField.superclass.renderField.call(this, fieldOptions); }
javascript
{ "resource": "" }
q30303
train
function(i) { if(this.options.separators && this.options.separators[i]) { var sep = inputEx.cn('div', {className: 'inputEx-CombineField-separator'}, null, this.options.separators[i]); this.divEl.appendChild(sep); } }
javascript
{ "resource": "" }
q30304
train
function(options) { inputEx.AutoComplete.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-AutoComplete'; // Added options this.options.datasource = options.datasource; this.options.autoComp = options.autoComp; this.options.returnValue = options.returnValue; this.options.generateRequest = options.generateRequest; this.options.datasourceParameters = options.datasourceParameters; }
javascript
{ "resource": "" }
q30305
train
function() { // This element wraps the input node in a float: none div this.wrapEl = inputEx.cn('div', {className: 'inputEx-StringField-wrapper'}); // Attributes of the input field var attributes = { type: 'text', id: YAHOO.util.Dom.generateId() }; if(this.options.size) attributes.size = this.options.size; if(this.options.readonly) attributes.readonly = 'readonly'; if(this.options.maxLength) attributes.maxLength = this.options.maxLength; // Create the node this.el = inputEx.cn('input', attributes); // Create the hidden input var hiddenAttrs = { type: 'hidden', value: '' }; if(this.options.name) hiddenAttrs.name = this.options.name; this.hiddenEl = inputEx.cn('input', hiddenAttrs); // Append it to the main element this.wrapEl.appendChild(this.el); this.wrapEl.appendChild(this.hiddenEl); this.fieldContainer.appendChild(this.wrapEl); // Render the list : this.listEl = inputEx.cn('div', {id: Dom.generateId() }); this.fieldContainer.appendChild(this.listEl); Event.onAvailable([this.el, this.listEl], this.buildAutocomplete, this, true); }
javascript
{ "resource": "" }
q30306
train
function() { // Call this function only when this.el AND this.listEl are available if(!this._nElementsReady) { this._nElementsReady = 0; } this._nElementsReady++; if(this._nElementsReady != 2) return; if(!lang.isUndefined(this.options.datasourceParameters)) { for (param in this.options.datasourceParameters) { this.options.datasource[param] = this.options.datasourceParameters[param]; } } // Instantiate AutoComplete this.oAutoComp = new YAHOO.widget.AutoComplete(this.el.id, this.listEl.id, this.options.datasource, this.options.autoComp); if(!lang.isUndefined(this.options.generateRequest)) { this.oAutoComp.generateRequest = this.options.generateRequest; } // subscribe to the itemSelect event this.oAutoComp.itemSelectEvent.subscribe(this.itemSelectHandler, this, true); // subscribe to the textboxBlur event (instead of "blur" event on this.el) // |-------------- autocompleter ----------| // -> order : "blur" on this.el -> internal callback -> textboxBlur event -> this.onBlur callback // -> so fired after autocomp internal "blur" callback (which would erase typeInvite...) this.oAutoComp.textboxBlurEvent.subscribe(this.onBlur, this, true); }
javascript
{ "resource": "" }
q30307
train
function(e) { this.setClassFromState(); // Clear the field when no value if (this.hiddenEl.value != this.el.value) this.hiddenEl.value = this.el.value; lang.later(50, this, function() { if(this.el.value == "") { this.setValue(""); } }); }
javascript
{ "resource": "" }
q30308
train
function(options) { inputEx.ColorField.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ColorField inputEx-PickerField'; // Added options this.options.palette = options.palette; this.options.colors = options.colors; if (options.ratio) { this.options.ratio = options.ratio;} if (options.cellPerLine) { this.options.cellPerLine = options.cellPerLine;} }
javascript
{ "resource": "" }
q30309
train
function() { var grid, eventDelegation, square, i; // remember squares this.squares = []; // container grid = inputEx.cn('div', {className: 'inputEx-ColorField-Grid'}); // Is event delegation available ? // (YAHOO.util.Event.delegate method is in "event-delegate" YUI-module) eventDelegation = !lang.isUndefined(Event.delegate); for(i = 0 ; i < this.length ; i++) { //var square = inputEx.cn('div', {className: 'inputEx-ColorField-square'},{backgroundColor: this.colors[i], width:this.cellWidth+"px", height:this.cellHeight+"px", margin:this.cellMargin+"px" }); square = inputEx.cn('div', {className: 'inputEx-ColorField-square'},{backgroundColor: this.colors[i] }); grid.appendChild(square); this.squares.push(square); // No event delegation available : add a listener on each square if (!eventDelegation) { Event.addListener(square, "mousedown", function(e) { var el = Event.getTarget(e); this.onColorClick(e,el,grid); }, this, true ); } // <br clear='both'/> insertion to end a line // ( + always after the last colored square) if (i%this.cellPerLine === this.cellPerLine-1 || i === this.length-1) { grid.appendChild(inputEx.cn('br',{clear:'both'})); } } // Mousedown event delegation if (eventDelegation) { if (!lang.isUndefined(YAHOO.util.Selector)) { Event.delegate(grid,"mousedown",this.onColorClick,"div.inputEx-ColorField-square",this,true); } else { Event.delegate(grid,"mousedown",this.onColorClick,function(el) { if (el.nodeName === "DIV" && YAHOO.util.Dom.hasClass(el,'inputEx-ColorField-square')) { return el; } },this,true); } } return grid; }
javascript
{ "resource": "" }
q30310
train
function(e,square,container) { // Stop the event to prevent a selection Event.stopEvent(e); // Overlay closure this.oOverlay.hide(); // SetValue var color = Dom.getStyle(square,'background-color'); var hexaColor = inputEx.ColorField.ensureHexa(color); this.setValue(hexaColor); }
javascript
{ "resource": "" }
q30311
train
function(options) { inputEx.DateField.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-DateField'; this.options.messages.invalid = inputEx.messages.invalidDate ? inputEx.messages.invalidDate : "Invalid date, ex: 03/27/2008"; // Added options this.options.dateFormat = options.dateFormat || inputEx.messages.defaultDateFormat; this.options.valueFormat = options.valueFormat; }
javascript
{ "resource": "" }
q30312
train
function() { var value = this.el.value; var separator = this.options.dateFormat.match(/[^Ymd ]/g)[0]; var ladate = value.split(separator); if( ladate.length != 3) { return false; } if ( isNaN(parseInt(ladate[0],10)) || isNaN(parseInt(ladate[1],10)) || isNaN(parseInt(ladate[2],10))) { return false; } var formatSplit = this.options.dateFormat.split(separator); var yearIndex = inputEx.indexOf('Y',formatSplit); if (ladate[yearIndex].length!=4) { return false; } // Avoid 3-digits years... var d = parseInt(ladate[ inputEx.indexOf('d',formatSplit) ],10); var Y = parseInt(ladate[yearIndex],10); var m = parseInt(ladate[ inputEx.indexOf('m',formatSplit) ],10)-1; var unedate = new Date(Y,m,d); var annee = unedate.getFullYear(); return ((unedate.getDate() == d) && (unedate.getMonth() == m) && (annee == Y)); }
javascript
{ "resource": "" }
q30313
train
function(val, sendUpdatedEvt) { // Don't try to parse a date if there is no date if( val === '' ) { inputEx.DateField.superclass.setValue.call(this, '', sendUpdatedEvt); return; } var str = ""; if (val instanceof Date) { str = inputEx.DateField.formatDate(val, this.options.dateFormat); } else if(this.options.valueFormat){ var dateVal = inputEx.DateField.parseWithFormat(val, this.options.valueFormat); str = inputEx.DateField.formatDate(dateVal, this.options.dateFormat); } // else date must match this.options.dateFormat else { str = val; } inputEx.DateField.superclass.setValue.call(this, str, sendUpdatedEvt); }
javascript
{ "resource": "" }
q30314
train
function(forceDate) { // let parent class function check if typeInvite, etc... var value = inputEx.DateField.superclass.getValue.call(this); // Hack to validate if field not required and empty if (value === '') { return '';} var finalDate = inputEx.DateField.parseWithFormat(value,this.options.dateFormat); // if valueFormat is specified, we format the string if(!forceDate && this.options.valueFormat){ return inputEx.DateField.formatDate(finalDate, this.options.valueFormat); } return finalDate; }
javascript
{ "resource": "" }
q30315
train
function(value, sendUpdatedEvt) { var values = []; // !value catches "" (empty field), and invalid dates if(!value || !lang.isFunction(value.getTime) || !lang.isNumber(value.getTime()) ) { values[this.monthIndex] = ""; values[this.yearIndex] = ""; values[this.dayIndex] = ""; } else { for(var i = 0 ; i < 3 ; i++) { values.push( i == this.dayIndex ? value.getDate() : (i==this.yearIndex ? value.getFullYear() : value.getMonth()+1 ) ); } } inputEx.DateSplitField.superclass.setValue.call(this, values, sendUpdatedEvt); }
javascript
{ "resource": "" }
q30316
train
function(options) { inputEx.DatePickerField.superclass.setOptions.call(this, options); // Overwrite default options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-DateField inputEx-PickerField inputEx-DatePickerField'; this.options.readonly = YAHOO.lang.isUndefined(options.readonly) ? true : options.readonly; // Added options this.options.calendar = options.calendar || inputEx.messages.defautCalendarOpts; }
javascript
{ "resource": "" }
q30317
train
function() { inputEx.DatePickerField.superclass.renderComponent.call(this); // Create overlay this.oOverlay = new YAHOO.widget.Overlay(Dom.generateId(), { visible: false }); this.oOverlay.setBody(" "); this.oOverlay.body.id = Dom.generateId(); // Create button this.button = new YAHOO.widget.Button({ type: "menu", menu: this.oOverlay, label: "&nbsp;&nbsp;&nbsp;&nbsp;" }); this.button.appendTo(this.wrapEl); // Render the overlay this.oOverlay.render(this.wrapEl); // HACK: Set position absolute to the overlay Dom.setStyle(this.oOverlay.body.parentNode, "position", "absolute"); // Subscribe the click handler on the field only if readonly if(this.options.readonly) { Event.addListener(this.el,'click',function(){ // calendar may not have been rendered yet this.renderCalendar(); if (!this.oOverlay.justHidden) { this.button._showMenu(); } },this,true); } this.oOverlay.hideEvent.subscribe(function() { this.oOverlay.justHidden = true; YAHOO.lang.later(250,this,function(){this.oOverlay.justHidden=false;}); },this,true); // Subscribe to the first click this.button.on('click', this.renderCalendar, this, true); }
javascript
{ "resource": "" }
q30318
train
function() { // if already rendered, ignore call if (!!this.calendarRendered) return; // Render the calendar var calendarId = Dom.generateId(); this.calendar = new YAHOO.widget.Calendar(calendarId,this.oOverlay.body.id, this.options.calendar ); /* this.calendar.cfg.setProperty("DATE_FIELD_DELIMITER", "/"); this.calendar.cfg.setProperty("MDY_DAY_POSITION", 1); this.calendar.cfg.setProperty("MDY_MONTH_POSITION", 2); this.calendar.cfg.setProperty("MDY_YEAR_POSITION", 3); this.calendar.cfg.setProperty("MD_DAY_POSITION", 1); this.calendar.cfg.setProperty("MD_MONTH_POSITION", 2);*/ // localization if(inputEx.messages.shortMonths) this.calendar.cfg.setProperty("MONTHS_SHORT", inputEx.messages.shortMonths); if(inputEx.messages.months) this.calendar.cfg.setProperty("MONTHS_LONG", inputEx.messages.months); if(inputEx.messages.weekdays1char) this.calendar.cfg.setProperty("WEEKDAYS_1CHAR", inputEx.messages.weekdays1char); if(inputEx.messages.shortWeekdays) this.calendar.cfg.setProperty("WEEKDAYS_SHORT", inputEx.messages.shortWeekdays); // HACK to keep focus on calendar/overlay // so overlay is not hidden when changing page in calendar // (inspired by YUI examples) var focusDay = function () { var oCalendarTBody = Dom.get(calendarId).tBodies[0], aElements = oCalendarTBody.getElementsByTagName("a"), oAnchor; if (aElements.length > 0) { Dom.batch(aElements, function (element) { if (Dom.hasClass(element.parentNode, "today")) { oAnchor = element; } }); if (!oAnchor) { oAnchor = aElements[0]; } // Focus the anchor element using a timer since Calendar will try // to set focus to its next button by default lang.later(0, oAnchor, function () { try { oAnchor.focus(); } catch(e) {} }); } }; // Set focus to either the current day, or first day of the month in // the Calendar when the month changes (renderEvent is fired) this.calendar.renderEvent.subscribe(focusDay, this.calendar, true); // Open minical on correct date / month if field contains a value this.oOverlay.beforeShowEvent.subscribe(this.beforeShowOverlay, this, true); // Render the calendar on the right page ! // -> this.calendar.render(); is not enough... this.beforeShowOverlay(); this.calendar.selectEvent.subscribe(function (type,args,obj) { // HACK: stop here if called from beforeShowOverlay if (!!this.ignoreBeforeShowOverlayCall) { return; } this.oOverlay.hide(); var date = args[0][0]; var year = date[0], month = date[1], day = date[2]; // set value (updatedEvt fired by setValue) this.setValue(new Date(year,month-1, day) ); }, this, true); // Unsubscribe the event so this function is called only once this.button.unsubscribe("click", this.renderCalendar); this.calendarRendered = true; // Since we render the calendar AFTER the opening of the overlay, // the overlay can be mis-positionned (outside of the viewport). // We force the repositionning of the overlay by hiding it, and show it again. this.oOverlay.hide(); this.button._showMenu(); }
javascript
{ "resource": "" }
q30319
train
function(e) { var date = this.getValue(true); if (!!this.calendar) { if(!!date) { // HACK: don't fire Field updatedEvt when selecting date this.ignoreBeforeShowOverlayCall = true; // select the previous date in calendar this.calendar.select(date); this.ignoreBeforeShowOverlayCall = false; this.calendar.cfg.setProperty("pagedate",(date.getMonth()+1)+"/"+date.getFullYear()); } this.calendar.render(); // refresh calendar } }
javascript
{ "resource": "" }
q30320
train
function() { this.type = inputEx.HiddenField; this.divEl = inputEx.cn('div', null, {display: 'none'}); this.el = inputEx.cn('input', {type: 'hidden'}); this.rawValue = ''; // initialize the rawValue with '' (default value of a hidden field) if(this.options.name) this.el.name = this.options.name; this.divEl.appendChild(this.el); }
javascript
{ "resource": "" }
q30321
train
function(options) { inputEx.IntegerField.superclass.setOptions.call(this, options); this.options.negative = lang.isUndefined(options.negative) ? false : options.negative; this.options.min = lang.isUndefined(options.min) ? (this.options.negative ? -Infinity : 0) : parseInt(options.min,10); this.options.max = lang.isUndefined(options.max) ? Infinity : parseInt(options.max,10); }
javascript
{ "resource": "" }
q30322
train
function() { var v = this.getValue(), str_value = inputEx.IntegerField.superclass.getValue.call(this); // empty field if (v === '') { // validate only if not required return !this.options.required; } if (isNaN(v)) { return false; } return !!str_value.match(/^[\+\-]?[0-9]+$/) && (this.options.negative ? true : v >= 0) && v >= this.options.min && v <= this.options.max; }
javascript
{ "resource": "" }
q30323
train
function(value) { // Render the subField var subFieldEl = this.renderSubField(value); if(this.options.name) { subFieldEl.setFieldName(this.options.name+"["+this.subFields.length+"]"); } // Adds it to the local list this.subFields.push(subFieldEl); return subFieldEl; }
javascript
{ "resource": "" }
q30324
train
function(e) { var childElement = Event.getTarget(e).parentNode; var previousChildNode = null; var nodeIndex = -1; for(var i = 1 ; i < childElement.parentNode.childNodes.length ; i++) { var el=childElement.parentNode.childNodes[i]; if(el == childElement) { previousChildNode = childElement.parentNode.childNodes[i-1]; nodeIndex = i; break; } } if(previousChildNode) { // Remove the line var removedEl = this.childContainer.removeChild(childElement); // Adds it before the previousChildNode var insertedEl = this.childContainer.insertBefore(removedEl, previousChildNode); // Swap this.subFields elements (i,i-1) var temp = this.subFields[nodeIndex]; this.subFields[nodeIndex] = this.subFields[nodeIndex-1]; this.subFields[nodeIndex-1] = temp; // Note: not very efficient, we could just swap the names this.resetAllNames(); // Color Animation if(this.arrowAnim) { this.arrowAnim.stop(true); } this.arrowAnim = new YAHOO.util.ColorAnim(insertedEl, {backgroundColor: this.arrowAnimColors}, 0.4); this.arrowAnim.onComplete.subscribe(function() { Dom.setStyle(insertedEl, 'background-color', ''); }); this.arrowAnim.animate(); // Fire updated ! this.fireUpdatedEvt(); } }
javascript
{ "resource": "" }
q30325
train
function(e) { Event.stopEvent(e); // Prevent removing a field if already at minItems if( lang.isNumber(this.options.minItems) && this.subFields.length <= this.options.minItems ) { return; } // Get the wrapping div element var elementDiv = Event.getTarget(e).parentNode; // Get the index of the subField var index = -1; var subFieldEl = elementDiv.childNodes[this.options.useButtons ? 1 : 0]; for(var i = 0 ; i < this.subFields.length ; i++) { if(this.subFields[i].getEl() == subFieldEl) { index = i; break; } } // Remove it if(index != -1) { this.removeElement(index); } // Note: not very efficient this.resetAllNames(); // Fire the updated event this.fireUpdatedEvt(); }
javascript
{ "resource": "" }
q30326
train
function(options) { inputEx.NumberField.superclass.setOptions.call(this, options); this.options.min = lang.isUndefined(options.min) ? -Infinity : parseFloat(options.min); this.options.max = lang.isUndefined(options.max) ? Infinity : parseFloat(options.max); }
javascript
{ "resource": "" }
q30327
train
function() { var v = this.getValue(), str_value = inputEx.NumberField.superclass.getValue.call(this); // empty field if (v === '') { // validate only if not required return !this.options.required; } if (isNaN(v)) { return false; } // We have to check the number with a regexp, otherwise "0.03a" is parsed to a valid number 0.03 return !!str_value.match(/^([\+\-]?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/) && v >= this.options.min && v <= this.options.max; }
javascript
{ "resource": "" }
q30328
train
function(options) { inputEx.PasswordField.superclass.setOptions.call(this, options); this.options.className = options.className ? options.className : "inputEx-Field inputEx-PasswordField"; // Add the password regexp (overridable) this.options.regexp = options.regexp || inputEx.regexps.password; // display a strength indicator this.options.strengthIndicator = YAHOO.lang.isUndefined(options.strengthIndicator) ? false : options.strengthIndicator; // capsLockWarning this.options.capsLockWarning = YAHOO.lang.isUndefined(options.capsLockWarning) ? false : options.capsLockWarning; // confirm option, pass the id of the password field to confirm inputEx.PasswordField.byId[options.id] = this; var passwordField; if(options.confirm && (passwordField = inputEx.PasswordField.byId[options.confirm]) ) { this.setConfirmationField(passwordField); } }
javascript
{ "resource": "" }
q30329
train
function() { // IE doesn't want to set the "type" property to 'password' if the node has a parent // even if the parent is not in the DOM yet !! // This element wraps the input node in a float: none div this.wrapEl = inputEx.cn('div', {className: 'inputEx-StringField-wrapper'}); // Attributes of the input field var attributes = {}; attributes.type = 'password'; attributes.size = this.options.size; if(this.options.name) attributes.name = this.options.name; // Create the node this.el = inputEx.cn('input', attributes); //inputEx.PasswordField.byId // Append it to the main element this.wrapEl.appendChild(this.el); this.fieldContainer.appendChild(this.wrapEl); // Caps lock warning if(this.options.capsLockWarning) { this.capsLockWarning = inputEx.cn('div',{className: 'capsLockWarning'},{display: 'none'},inputEx.messages.capslockWarning); this.wrapEl.appendChild(this.capsLockWarning); } // Password strength indicator if(this.options.strengthIndicator) { this.strengthEl = inputEx.cn('div', {className: 'inputEx-Password-StrengthIndicator'}, null, inputEx.messages.passwordStrength); this.strengthBlocks = []; for(var i = 0 ; i < 4 ; i++) { this.strengthBlocks[i] = inputEx.cn('div', {className: 'inputEx-Password-StrengthIndicatorBlock'}); this.strengthEl.appendChild( this.strengthBlocks[i] ); } this.wrapEl.appendChild(this.strengthEl); } }
javascript
{ "resource": "" }
q30330
train
function() { if(this.options.confirmPasswordField) { if(this.options.confirmPasswordField.getValue() != this.getValue() ) { return false; } } return inputEx.PasswordField.superclass.validate.call(this); }
javascript
{ "resource": "" }
q30331
train
function(e) { inputEx.PasswordField.superclass.onInput.call(this,e); if(this.options.confirmationPasswordField) { this.options.confirmationPasswordField.setClassFromState(); } }
javascript
{ "resource": "" }
q30332
train
function(e) { inputEx.PasswordField.superclass.onKeyPress.call(this,e); if(this.options.capsLockWarning) { var ev = e ? e : window.event; if (!ev) { return; } var targ = ev.target ? ev.target : ev.srcElement; // get key pressed var which = -1; if (ev.which) { which = ev.which; } else if (ev.keyCode) { which = ev.keyCode; } // get shift status var shift_status = false; if (ev.shiftKey) { shift_status = ev.shiftKey; } else if (ev.modifiers) { shift_status = !!(ev.modifiers & 4); } var displayWarning = ((which >= 65 && which <= 90) && !shift_status) || ((which >= 97 && which <= 122) && shift_status); this.setCapsLockWarning(displayWarning); } }
javascript
{ "resource": "" }
q30333
train
function(e) { inputEx.PasswordField.superclass.onKeyUp.call(this,e); if(this.options.strengthIndicator) { lang.later( 0, this, this.updateStrengthIndicator); } }
javascript
{ "resource": "" }
q30334
train
function (options) { var i, length; inputEx.RadioField.superclass.setOptions.call(this, options); // Display mode this.options.display = options.display === "vertically" ? "vertically" : "inline"; // default "inline" // Classname this.options.className = options.className ? options.className : 'inputEx-Field inputEx-RadioField'; if (this.options.display === "vertically") { this.options.className += ' inputEx-RadioField-Vertically'; } // Choices creation // Retro-compatibility with old pattern (DEPRECATED since 2010-06-30) if (lang.isArray(options.values)) { this.options.choices = []; for (i = 0, length = options.values.length; i < length; i += 1) { this.options.choices.push({ value: options.values[i], label: options.choices[i] }); } // New pattern to define choices } else { this.options.choices = options.choices; // ['val1','val2'] or [{ value: 'val1', label: '1st Choice' }, etc.] } if (lang.isUndefined(options.allowAny) || options.allowAny === false ) { this.options.allowAny = false; } else { this.options.allowAny = {}; if (lang.isArray(options.allowAny.separators)) { this.options.allowAny.separators = options.allowAny.separators;} this.options.allowAny.validator = lang.isFunction(options.allowAny.validator) ? options.allowAny.validator : function (val) {return true;}; this.options.allowAny.value = !lang.isUndefined(options.allowAny.value) ? options.allowAny.value : ""; this.options.allowAny.field = lang.isUndefined(options.allowAny.field) ? { type: "string", value: this.options.allowAny.value } : options.allowAny.field; } }
javascript
{ "resource": "" }
q30335
train
function () { // Delegate event listening because list of choices is dynamic // so we can't listen on each <input type="radio" class='inputEx-RadioField-radio' /> // Change event (IE does not fire "change" event, so listen to click instead) Event.delegate(this.fieldContainer, YAHOO.env.ua.ie ? "click" : "change", function(e, matchedEl, container) { this.onChange(e); }, "input.inputEx-RadioField-radio", this, true); // Focus / Blur events Event.delegate(this.fieldContainer, "focusin", function(e, matchedEl, container) { this.onFocus(e); }, "input.inputEx-RadioField-radio", this, true); Event.delegate(this.fieldContainer, "focusout", function(e, matchedEl, container) { this.onBlur(e); }, "input.inputEx-RadioField-radio", this, true); // AnyField events if (this.allowAnyChoice) { this.anyField.updatedEvt.subscribe(function (e, params) { var value = params[0]; this.radioAny.value = value; this.setClassFromState(); inputEx.RadioField.superclass.onChange.call(this,e); }, this, true); // Update radio field style after editing anyField content ! Event.addBlurListener(this.anyField.el, this.onBlur, this, true); } }
javascript
{ "resource": "" }
q30336
train
function () { var i, length; for (i = 0, length = this.choicesList.length ; i < length ; i += 1) { if (this.choicesList[i].node.firstChild.checked) { Dom.addClass(this.choicesList[i].node,"inputEx-selected"); } else { Dom.removeClass(this.choicesList[i].node,"inputEx-selected"); } } }
javascript
{ "resource": "" }
q30337
train
function () { var i, length; for (i = 0, length = this.choicesList.length ; i < length ; i += 1) { if (this.choicesList[i].node.firstChild.checked) { if (this.radioAny && this.radioAny == this.choicesList[i].node.firstChild) { return this.anyField.getValue(); } return this.choicesList[i].value; } } return ""; }
javascript
{ "resource": "" }
q30338
train
function (value, sendUpdatedEvt) { var checkAny = true, valueFound = false, i, length; for (i = 0, length = this.choicesList.length ; i < length ; i += 1) { // valueFound is a useful when "real" choice has a value equal to allowAny choice default value // so we check only the first value-matching radio button if (value === this.choicesList[i].value && !valueFound) { this.choicesList[i].node.firstChild.checked = true; valueFound = true; checkAny = false; } else { this.choicesList[i].node.firstChild.checked = false; } } // Option allowAny if (this.radioAny) { if (checkAny) { this.radioAny.checked = true; this.radioAny.value = value; this.anyField.enable(); this.anyField.setValue(value, false); } else { this.anyField.disable(); } } // call parent class method to set style and fire updatedEvt inputEx.RadioField.superclass.setValue.call(this, value, sendUpdatedEvt); }
javascript
{ "resource": "" }
q30339
train
function (sendUpdatedEvt) { if (this.radioAny){ this.anyField.setValue(this.options.allowAny.value, false); } inputEx.RadioField.superclass.clear.call(this, sendUpdatedEvt); }
javascript
{ "resource": "" }
q30340
train
function () { var i, length, radioInput; for (i = 0, length = this.choicesList.length ; i < length ; i += 1) { radioInput = this.choicesList[i].node.firstChild; if (radioInput.checked) { // if "any" option checked if (this.radioAny && this.radioAny == radioInput) { return this.anyField.getValue() === ''; } else { return false; } } } return true; }
javascript
{ "resource": "" }
q30341
train
function () { var i, length; for (i = 0, length = this.choicesList.length; i < length; i += 1) { this.disableChoice(this.choicesList[i], false); } }
javascript
{ "resource": "" }
q30342
train
function () { var i, length; for (i = 0, length = this.choicesList.length; i < length; i += 1) { this.enableChoice(this.choicesList[i]); } }
javascript
{ "resource": "" }
q30343
train
function(val, sendUpdatedEvt) { this.value = val; inputEx.renderVisu(this.options.visu, val, this.fieldContainer); inputEx.UneditableField.superclass.setValue.call(this, val, sendUpdatedEvt); }
javascript
{ "resource": "" }
q30344
train
function(x, y) { // make the proxy look like the source element var dragEl = this.getDragEl(); var clickEl = this.getEl(); Dom.setStyle(clickEl, "visibility", "hidden"); this._originalIndex = inputEx.indexOf(clickEl ,clickEl.parentNode.childNodes); dragEl.className = clickEl.className; dragEl.innerHTML = clickEl.innerHTML; }
javascript
{ "resource": "" }
q30345
train
function(e) { Dom.setStyle(this.id, "visibility", ""); // Fire the reordered event if position in list has changed var clickEl = this.getEl(); var newIndex = inputEx.indexOf(clickEl ,clickEl.parentNode.childNodes); if(this._originalIndex != newIndex) { this._list.onReordered(this._originalIndex, newIndex); } }
javascript
{ "resource": "" }
q30346
train
function(e) { var y = Event.getPageY(e); if (y < this.lastY) { this.goingUp = true; } else if (y > this.lastY) { this.goingUp = false; } this.lastY = y; }
javascript
{ "resource": "" }
q30347
train
function(i) { var itemValue = this.items[i]; this.ul.removeChild(this.ul.childNodes[i]); this.items[i] = null; this.items = inputEx.compactArray(this.items); return itemValue; }
javascript
{ "resource": "" }
q30348
train
function(originalIndex, newIndex) { if(originalIndex < newIndex) { this.items.splice(newIndex+1,0, this.items[originalIndex]); this.items[originalIndex] = null; } else { this.items.splice(newIndex,0, this.items[originalIndex]); this.items[originalIndex+1] = null; } this.items = inputEx.compactArray(this.items); this.listReorderedEvt.fire(); }
javascript
{ "resource": "" }
q30349
train
function(index, item) { this.items[index] = (typeof item == "object") ? item.value : item; this.ul.childNodes[index].childNodes[0].innerHTML = (typeof item == "object") ? item.label : item; }
javascript
{ "resource": "" }
q30350
train
function() { var value, position, choice; if (this.el.selectedIndex !== 0) { // Get the selector value value = inputEx.MultiSelectField.superclass.getValue.call(this); position = this.getChoicePosition({ value : value }); choice = this.choicesList[position]; this.ddlist.addItem({ value: value, label: choice.label }); // hide choice that has just been selected (+ select first choice) this.hideChoice({ position : position }); this.el.selectedIndex = 0; this.fireUpdatedEvt(); } }
javascript
{ "resource": "" }
q30351
train
function(sType, aArgs) { var aData = aArgs[2]; var value = lang.isFunction(this.options.returnValue) ? this.options.returnValue(aData) : aData[0]; var label = lang.isFunction(this.options.returnLabel) ? this.options.returnLabel(aData) : value; this.ddlist.addItem({label: label, value: value}); this.el.value = ""; this.fireUpdatedEvt(); }
javascript
{ "resource": "" }
q30352
train
function(options) { inputEx.SliderField.superclass.setOptions.call(this, options); this.options.className = options.className ? options.className : 'inputEx-SliderField'; this.options.minValue = lang.isUndefined(options.minValue) ? 0 : options.minValue; this.options.maxValue = lang.isUndefined(options.maxValue) ? 100 : options.maxValue; this.options.displayValue = lang.isUndefined(options.displayValue) ? true : options.displayValue; }
javascript
{ "resource": "" }
q30353
train
function() { this.sliderbg = inputEx.cn('div', {id: YAHOO.util.Dom.generateId(), className: 'inputEx-SliderField-bg'}); this.sliderthumb = inputEx.cn('div', {className: 'inputEx-SliderField-thumb'} ); this.sliderbg.appendChild(this.sliderthumb); this.fieldContainer.appendChild(this.sliderbg); if(this.options.displayValue) { this.valueDisplay = inputEx.cn('div', {className: 'inputEx-SliderField-value'}, null, String(this.options.minValue) ); this.fieldContainer.appendChild(this.valueDisplay); } this.fieldContainer.appendChild( inputEx.cn('div',null,{clear: 'both'}) ); this.slider = YAHOO.widget.Slider.getHorizSlider(this.sliderbg, this.sliderthumb, 0,100); }
javascript
{ "resource": "" }
q30354
train
function() { var val = Math.floor(this.options.minValue+(this.options.maxValue-this.options.minValue)*this.slider.getValue()/100); return val; }
javascript
{ "resource": "" }
q30355
train
function(attr) { TabView.superclass.initAttributes.call(this, attr); if (!attr.orientation) { attr.orientation = 'top'; } var el = this.get(ELEMENT); if (!Dom.hasClass(el, this.CLASSNAME)) { Dom.addClass(el, this.CLASSNAME); } /** * The Tabs belonging to the TabView instance. * @attribute tabs * @type Array */ this.setAttributeConfig('tabs', { value: [], readOnly: true }); /** * The container of the tabView's label elements. * @property _tabParent * @private * @type HTMLElement */ this._tabParent = this.getElementsByClassName(this.TAB_PARENT_CLASSNAME, 'ul' )[0] || this._createTabParent(); /** * The container of the tabView's content elements. * @property _contentParent * @type HTMLElement * @private */ this._contentParent = this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME, 'div')[0] || this._createContentParent(); /** * How the Tabs should be oriented relative to the TabView. * @attribute orientation * @type String * @default "top" */ this.setAttributeConfig('orientation', { value: attr.orientation, method: function(value) { var current = this.get('orientation'); this.addClass('yui-navset-' + value); if (current != value) { this.removeClass('yui-navset-' + current); } if (value === 'bottom') { this.appendChild(this._tabParent); } } }); /** * The index of the tab currently active. * @attribute activeIndex * @type Int */ this.setAttributeConfig(ACTIVE_INDEX, { value: attr.activeIndex, validator: function(value) { var ret = true; if (value && this.getTab(value).get('disabled')) { // cannot activate if disabled ret = false; } return ret; } }); /** * The tab currently active. * @attribute activeTab * @type YAHOO.widget.Tab */ this.setAttributeConfig(ACTIVE_TAB, { value: attr.activeTab, method: function(tab) { var activeTab = this.get(ACTIVE_TAB); if (tab) { tab.set(ACTIVE, true); } if (activeTab && activeTab !== tab) { activeTab.set(ACTIVE, false); } if (activeTab && tab !== activeTab) { // no transition if only 1 this.contentTransition(tab, activeTab); } else if (tab) { tab.set('contentVisible', true); } }, validator: function(value) { var ret = true; if (value && value.get('disabled')) { // cannot activate if disabled ret = false; } return ret; } }); this.on('activeTabChange', this._onActiveTabChange); this.on('activeIndexChange', this._onActiveIndexChange); if ( this._tabParent ) { this._initTabs(); } // Due to delegation we add all DOM_EVENTS to the TabView container // but IE will leak when unsupported events are added, so remove these this.DOM_EVENTS.submit = false; this.DOM_EVENTS.focus = false; this.DOM_EVENTS.blur = false; for (var type in this.DOM_EVENTS) { if ( YAHOO.lang.hasOwnProperty(this.DOM_EVENTS, type) ) { this.addListener.call(this, type, this.DOMEventHandler); } } }
javascript
{ "resource": "" }
q30356
train
function() { var el = this.getEl() || {}; var id = el.id || el.tagName; return (this.constructor.NAME + ': ' + id); }
javascript
{ "resource": "" }
q30357
train
function(attr, val, unit) { var el = this.getEl(); if ( this.patterns.noNegatives.test(attr) ) { val = (val > 0) ? val : 0; } if (attr in el && !('style' in el && attr in el.style)) { el[attr] = val; } else { Y.Dom.setStyle(el, attr, val + unit); } }
javascript
{ "resource": "" }
q30358
train
function(attr) { var el = this.getEl(); var val = Y.Dom.getStyle(el, attr); if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) { return parseFloat(val); } var a = this.patterns.offsetAttribute.exec(attr) || []; var pos = !!( a[3] ); // top or left var box = !!( a[2] ); // width or height if ('style' in el) { // use offsets for width/height and abs pos top/left if ( box || (Y.Dom.getStyle(el, 'position') == 'absolute' && pos) ) { val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)]; } else { // default to zero for other 'auto' val = 0; } } else if (attr in el) { val = el[attr]; } return val; }
javascript
{ "resource": "" }
q30359
train
function(attr) { var start; var end; var attributes = this.attributes; this.runtimeAttributes[attr] = {}; var isset = function(prop) { return (typeof prop !== 'undefined'); }; if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) { return false; // note return; nothing to animate to } start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr); // To beats by, per SMIL 2.1 spec if ( isset(attributes[attr]['to']) ) { end = attributes[attr]['to']; } else if ( isset(attributes[attr]['by']) ) { if (start.constructor == Array) { end = []; for (var i = 0, len = start.length; i < len; ++i) { end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by" } } else { end = start + attributes[attr]['by'] * 1; } } this.runtimeAttributes[attr].start = start; this.runtimeAttributes[attr].end = end; // set units if needed this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); return true; }
javascript
{ "resource": "" }
q30360
train
function(tween) { var frames = tween.totalFrames; var frame = tween.currentFrame; var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames); var elapsed = (new Date() - tween.getStartTime()); var tweak = 0; if (elapsed < tween.duration * 1000) { // check if falling behind tweak = Math.round((elapsed / expected - 1) * tween.currentFrame); } else { // went over duration, so jump to end tweak = frames - (frame + 1); } if (tweak > 0 && isFinite(tweak)) { // adjust if needed if (tween.currentFrame + tweak >= frames) {// dont go past last frame tweak = frames - (frame + 1); } tween.currentFrame += tweak; } }
javascript
{ "resource": "" }
q30361
train
function (t, b, c, d) { return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b; }
javascript
{ "resource": "" }
q30362
train
function (t, b, c, d) { if (t < d/2) { return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b; } return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b; }
javascript
{ "resource": "" }
q30363
train
function(n) { var a = (n === Math.floor(n)) ? n : (Math.round(n*1000))/1000; return (a + " " + YAHOO.widget.ProfilerViewer.STRINGS.millisecondsAbbrev); }
javascript
{ "resource": "" }
q30364
train
function(n) { var a = (n === Math.floor(n)) ? n : (Math.round(n*100))/100; return (a + "%"); }
javascript
{ "resource": "" }
q30365
train
function(arr){ var ct = 0; for(var i = 0; i < arr.length; ct+=arr[i++]){} return ct; }
javascript
{ "resource": "" }
q30366
train
function(elCell, oRecord, oColumn, oData) { var a = (oData === Math.floor(oData)) ? oData : (Math.round(oData*1000))/1000; elCell.innerHTML = a + " " + PV.STRINGS.millisecondsAbbrev; }
javascript
{ "resource": "" }
q30367
train
function(yql, callback) { var ud = 'yqlexecuteconsole'+(inputEx.YQL.query_index)++, API = 'http://query.yahooapis.com/v1/public/yql?q=', url = API + window.encodeURIComponent(yql) + '&format=json&diagnostics=true&callback=' + ud; window[ud]= function(o){ callback && callback(o); }; document.body.appendChild((function(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.src = url; return s; })()); }
javascript
{ "resource": "" }
q30368
train
function(codeUrl, callback) { var url = ("http://javascript.neyric.com/yql/js.php?url="+window.encodeURIComponent(codeUrl)).replace(new RegExp("'","g"),"\\'"); var yql = "use '"+url+"' as yqlexconsole; select * from yqlexconsole;"; inputEx.YQL.query(yql,callback); }
javascript
{ "resource": "" }
q30369
train
function(r, s) { if (!s||!r) { throw new Error("Augment failed, verify dependencies."); } //var a=[].concat(arguments); var a=[r.prototype,s.prototype], i; for (i=2;i<arguments.length;i=i+1) { a.push(arguments[i]); } L.augmentObject.apply(this, a); }
javascript
{ "resource": "" }
q30370
train
function(o, d) { var i,len,s=[],OBJ="{...}",FUN="f(){...}", COMMA=', ', ARROW=' => '; // Cast non-objects to string // Skip dates because the std toString is what we want // Skip HTMLElement-like objects because trying to dump // an element will cause an unhandled exception in FF 2.x if (!L.isObject(o)) { return o + ""; } else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) { return o; } else if (L.isFunction(o)) { return FUN; } // dig into child objects the depth specifed. Default 3 d = (L.isNumber(d)) ? d : 3; // arrays [1, 2, 3] if (L.isArray(o)) { s.push("["); for (i=0,len=o.length;i<len;i=i+1) { if (L.isObject(o[i])) { s.push((d > 0) ? L.dump(o[i], d-1) : OBJ); } else { s.push(o[i]); } s.push(COMMA); } if (s.length > 1) { s.pop(); } s.push("]"); // objects {k1 => v1, k2 => v2} } else { s.push("{"); for (i in o) { if (L.hasOwnProperty(o, i)) { s.push(i + ARROW); if (L.isObject(o[i])) { s.push((d > 0) ? L.dump(o[i], d-1) : OBJ); } else { s.push(o[i]); } s.push(COMMA); } } if (s.length > 1) { s.pop(); } s.push("}"); } return s.join(""); }
javascript
{ "resource": "" }
q30371
train
function() { var o={}, a=arguments, l=a.length, i; for (i=0; i<l; i=i+1) { L.augmentObject(o, a[i], true); } return o; }
javascript
{ "resource": "" }
q30372
train
function(when, o, fn, data, periodic) { when = when || 0; o = o || {}; var m=fn, d=data, f, r; if (L.isString(fn)) { m = o[fn]; } if (!m) { throw new TypeError("method undefined"); } if (d && !L.isArray(d)) { d = [data]; } f = function() { m.apply(o, d || NOTHING); }; r = (periodic) ? setInterval(f, when) : setTimeout(f, when); return { interval: periodic, cancel: function() { if (this.interval) { clearInterval(r); } else { clearTimeout(r); } } }; }
javascript
{ "resource": "" }
q30373
train
function(type, attr, win) { var w = win || window, d=w.document, n=d.createElement(type); for (var i in attr) { if (attr[i] && YAHOO.lang.hasOwnProperty(attr, i)) { n.setAttribute(i, attr[i]); } } return n; }
javascript
{ "resource": "" }
q30374
train
function(url, win, attributes) { var o = { id: "yui__dyn_" + (nidx++), type: "text/css", rel: "stylesheet", href: url }; if (attributes) { lang.augmentObject(o, attributes); } return _node("link", o, win); }
javascript
{ "resource": "" }
q30375
train
function(url, win, attributes) { var o = { id: "yui__dyn_" + (nidx++), type: "text/javascript", src: url }; if (attributes) { lang.augmentObject(o, attributes); } return _node("script", o, win); }
javascript
{ "resource": "" }
q30376
train
function(q, msg) { return { tId: q.tId, win: q.win, data: q.data, nodes: q.nodes, msg: msg, purge: function() { _purge(this.tId); } }; }
javascript
{ "resource": "" }
q30377
train
function(id) { var q = queues[id]; q.finished = true; if (q.aborted) { var msg = "transaction " + id + " was aborted"; _fail(id, msg); return; } // execute success callback if (q.onSuccess) { var sc=q.scope || q.win; q.onSuccess.call(sc, _returnData(q)); } }
javascript
{ "resource": "" }
q30378
train
function(id, loaded) { var q = queues[id]; if (q.timer) { // Y.log('cancel timer'); q.timer.cancel(); } if (q.aborted) { var msg = "transaction " + id + " was aborted"; _fail(id, msg); return; } if (loaded) { q.url.shift(); if (q.varName) { q.varName.shift(); } } else { // This is the first pass: make sure the url is an array q.url = (lang.isString(q.url)) ? [q.url] : q.url; if (q.varName) { q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName; } } var w=q.win, d=w.document, h=d.getElementsByTagName("head")[0], n; if (q.url.length === 0) { // Safari 2.x workaround - There is no way to know when // a script is ready in versions of Safari prior to 3.x. // Adding an extra node reduces the problem, but doesn't // eliminate it completely because the browser executes // them asynchronously. if (q.type === "script" && ua.webkit && ua.webkit < 420 && !q.finalpass && !q.varName) { // Add another script node. This does not guarantee that the // scripts will execute in order, but it does appear to fix the // problem on fast connections more effectively than using an // arbitrary timeout. It is possible that the browser does // block subsequent script execution in this case for a limited // time. var extra = _scriptNode(null, q.win, q.attributes); extra.innerHTML='YAHOO.util.Get._finalize("' + id + '");'; q.nodes.push(extra); h.appendChild(extra); } else { _finish(id); } return; } var url = q.url[0]; // if the url is undefined, this is probably a trailing comma problem in IE if (!url) { q.url.shift(); return _next(id); } if (q.timeout) { // Y.log('create timer'); q.timer = lang.later(q.timeout, q, _timeout, id); } if (q.type === "script") { n = _scriptNode(url, w, q.attributes); } else { n = _linkNode(url, w, q.attributes); } // track this node's load progress _track(q.type, n, id, url, w, q.url.length); // add the node to the queue so we can return it to the user supplied callback q.nodes.push(n); // add it to the head or insert it before 'insertBefore' if (q.insertBefore) { var s = _get(q.insertBefore, id); if (s) { s.parentNode.insertBefore(n, s); } } else { h.appendChild(n); } // FireFox does not support the onload event for link nodes, so there is // no way to make the css requests synchronous. This means that the css // rules in multiple files could be applied out of order in this browser // if a later request returns before an earlier one. Safari too. if ((ua.webkit || ua.gecko) && q.type === "css") { _next(id, url); } }
javascript
{ "resource": "" }
q30379
train
function() { if (purging) { return; } purging = true; for (var i in queues) { var q = queues[i]; if (q.autopurge && q.finished) { _purge(q.tId); delete queues[i]; } } purging = false; }
javascript
{ "resource": "" }
q30380
train
function(tId) { if (queues[tId]) { var q = queues[tId], nodes = q.nodes, l = nodes.length, d = q.win.document, h = d.getElementsByTagName("head")[0], sib, i, node, attr; if (q.insertBefore) { sib = _get(q.insertBefore, tId); if (sib) { h = sib.parentNode; } } for (i=0; i<l; i=i+1) { node = nodes[i]; if (node.clearAttributes) { node.clearAttributes(); } else { for (attr in node) { delete node[attr]; } } h.removeChild(node); } q.nodes = []; } }
javascript
{ "resource": "" }
q30381
train
function(type, url, opts) { var id = "q" + (qidx++); opts = opts || {}; if (qidx % YAHOO.util.Get.PURGE_THRESH === 0) { _autoPurge(); } queues[id] = lang.merge(opts, { tId: id, type: type, url: url, finished: false, aborted: false, nodes: [] }); var q = queues[id]; q.win = q.win || window; q.scope = q.scope || q.win; q.autopurge = ("autopurge" in q) ? q.autopurge : (type === "script") ? true : false; if (opts.charset) { q.attributes = q.attributes || {}; q.attributes.charset = opts.charset; } lang.later(0, q, _next, id); return { tId: id }; }
javascript
{ "resource": "" }
q30382
train
function(type, n, id, url, win, qlength, trackfn) { var f = trackfn || _next; // IE supports the readystatechange event for script and css nodes if (ua.ie) { n.onreadystatechange = function() { var rs = this.readyState; if ("loaded" === rs || "complete" === rs) { n.onreadystatechange = null; f(id, url); } }; // webkit prior to 3.x is problemmatic } else if (ua.webkit) { if (type === "script") { // Safari 3.x supports the load event for script nodes (DOM2) if (ua.webkit >= 420) { n.addEventListener("load", function() { f(id, url); }); // Nothing can be done with Safari < 3.x except to pause and hope // for the best, particularly after last script is inserted. The // scripts will always execute in the order they arrive, not // necessarily the order in which they were inserted. To support // script nodes with complete reliability in these browsers, script // nodes either need to invoke a function in the window once they // are loaded or the implementer needs to provide a well-known // property that the utility can poll for. } else { // Poll for the existence of the named variable, if it // was supplied. var q = queues[id]; if (q.varName) { var freq=YAHOO.util.Get.POLL_FREQ; q.maxattempts = YAHOO.util.Get.TIMEOUT/freq; q.attempts = 0; q._cache = q.varName[0].split("."); q.timer = lang.later(freq, q, function(o) { var a=this._cache, l=a.length, w=this.win, i; for (i=0; i<l; i=i+1) { w = w[a[i]]; if (!w) { // if we have exausted our attempts, give up this.attempts++; if (this.attempts++ > this.maxattempts) { var msg = "Over retry limit, giving up"; q.timer.cancel(); _fail(id, msg); } else { } return; } } q.timer.cancel(); f(id, url); }, null, true); } else { lang.later(YAHOO.util.Get.POLL_FREQ, null, f, [id, url]); } } } // FireFox and Opera support onload (but not DOM2 in FF) handlers for // script nodes. Opera, but not FF, supports the onload event for link // nodes. } else { n.onload = function() { f(id, url); }; } }
javascript
{ "resource": "" }
q30383
train
function(mm) { if (!done[mm]) { // Y.log(name + ' provides worker trying: ' + mm); done[mm] = true; // we always want the return value normal behavior // (provides) for superseded modules. lang.augmentObject(o, me.getProvides(mm)); } // else { // Y.log(name + ' provides worker skipping done: ' + mm); // } }
javascript
{ "resource": "" }
q30384
train
function(o) { if (o || this.dirty) { this._config(o); this._setup(); this._explode(); // this._skin(); // deprecated if (this.allowRollup) { this._rollup(); } this._reduce(); this._sort(); // Y.log("after calculate: " + lang.dump(this.required)); this.dirty = false; } }
javascript
{ "resource": "" }
q30385
train
function(aa, bb) { var mm=info[aa]; if (loaded[bb] || !mm) { return false; } var ii, rr = mm.expanded, after = mm.after, other = info[bb], optional = mm.optional; // check if this module requires the other directly if (rr && YUI.ArrayUtil.indexOf(rr, bb) > -1) { return true; } // check if this module should be sorted after the other if (after && YUI.ArrayUtil.indexOf(after, bb) > -1) { return true; } // if loadOptional is not specified, optional dependencies still // must be sorted correctly when present. if (checkOptional && optional && YUI.ArrayUtil.indexOf(optional, bb) > -1) { return true; } // check if this module requires one the other supersedes var ss=info[bb] && info[bb].supersedes; if (ss) { for (ii=0; ii<ss.length; ii=ii+1) { if (requires(aa, ss[ii])) { return true; } } } // var ss=me.getProvides(bb, true); // if (ss) { // for (ii in ss) { // if (requires(aa, ii)) { // return true; // } // } // } // external css files should be sorted below yui css if (mm.ext && mm.type == 'css' && !other.ext && other.type == 'css') { return true; } return false; }
javascript
{ "resource": "" }
q30386
train
function(str) { var f = this.filter; return (f) ? str.replace(new RegExp(f.searchExp, 'g'), f.replaceStr) : str; }
javascript
{ "resource": "" }
q30387
train
function () { var i, j, ilength, jlength, currentSubChoices, currentSubChoice, currentValue, testValue, isDuplicateChoice, secondSelectChoices; // object used in updateSecondSelectChoices // // * key : string representing a value in 1st select // * value : array of values available in 2nd select when key is selected in first select // this.valuesMatching = {}; // helper to filter 2nd select choices to find duplicates isDuplicateChoice = function(elt, arrElt) { elt = lang.isObject(elt) ? elt.value : elt; arrElt = lang.isObject(arrElt) ? arrElt.value : arrElt; return elt === arrElt; }; // collect 2nd level choices + ensure uniqueness of values secondSelectChoices = []; for (i = 0, ilength = this.options.choices.length; i < ilength; i += 1) { currentValue = lang.isObject(this.options.choices[i]) ? this.options.choices[i].value : this.options.choices[i]; currentSubChoices = this.options.choices[i].choices; this.valuesMatching[currentValue] = []; // maybe no sub choices ??? if (currentSubChoices) { for (j = 0, jlength = currentSubChoices.length; j < jlength; j += 1) { currentSubChoice = currentSubChoices[j]; testValue = lang.isObject(currentSubChoice) ? currentSubChoice.value : currentSubChoice; this.valuesMatching[currentValue].push(testValue); if (inputEx.indexOf(testValue, secondSelectChoices, isDuplicateChoice) === -1) { secondSelectChoices.push(currentSubChoices[j]); } } } } // create and store selects this.selects = []; this.selects.push(new inputEx.SelectField({ choices: this.options.choices })); this.selects.push(new inputEx.SelectField({ choices: secondSelectChoices })); // append <select>s to DOM tree this.fieldContainer.appendChild(this.selects[0].getEl()); this.fieldContainer.appendChild(this.selects[1].getEl()); }
javascript
{ "resource": "" }
q30388
train
function() { var i, length, choicesList, secondSelectValues, testValue; // allowed values in second select secondSelectValues = this.valuesMatching[this.selects[0].getValue()]; // all choices in second select choicesList = this.selects[1].choicesList; for (i = 0, length = choicesList.length; i < length; i += 1) { testValue = choicesList[i].value; if (inputEx.indexOf(testValue, secondSelectValues) === -1) { this.selects[1].hideChoice({ position: i }, false); // no updatedEvt in case of clear (because multiple clear could happen...) } else { this.selects[1].showChoice({ position: i }); } } }
javascript
{ "resource": "" }
q30389
train
function() { // if the field is empty : if( this.getValue() === this.options.valueSeparator ) { return this.options.required ? inputEx.stateRequired : inputEx.stateEmpty; } return this.validate() ? inputEx.stateValid : inputEx.stateInvalid; }
javascript
{ "resource": "" }
q30390
parse
train
function parse(name, options, fn) { if ('function' === typeof options) { fn = options; options = null; } // // Fix circular require. // if (!Registry) Registry = require('npm-registry'); options = options || {}; options.githulk = options.githulk || null; options.order = options.order || ['registry', 'github', 'content']; options.registry = options.registry || Registry.mirrors.nodejitsu; options.npmjs = 'string' !== typeof options.registry ? options.registry : new Registry({ registry: options.registry || Registry.mirrors.nodejitsu, githulk: options.githulk }); async.waterfall([ // // Make sure that we have the correct contents to start searching for // license information. // function fetch(next) { if ('string' !== typeof name) return next(undefined, name); options.npmjs.packages.get(name, next); }, // // Search for the correct way of parsing out the license information. // function search(data, next) { if (!options.order.length) return next(); if (Array.isArray(data)) data = data[0]; debug('searching for licensing information for %s', data.name); var parser, result, name; async.doWhilst(function does(next) { name = options.order.shift(); parser = parse.parsers[name]; if (!parser.supported(data)) return next(); debug('attempting to extract the license information using: %s', name); parser.parse(data, options, function parsed(err, license) { if (err) return next(); result = license; if (result) debug('parsing with %s was successful', name); next(); }); }, function select() { return !result && options.order.length; }, function cleanup(err) { options = null; next(err, result, name); }); } ], fn); }
javascript
{ "resource": "" }
q30391
fetch
train
function fetch(next) { if ('string' !== typeof name) return next(undefined, name); options.npmjs.packages.get(name, next); }
javascript
{ "resource": "" }
q30392
search
train
function search(data, next) { if (!options.order.length) return next(); if (Array.isArray(data)) data = data[0]; debug('searching for licensing information for %s', data.name); var parser, result, name; async.doWhilst(function does(next) { name = options.order.shift(); parser = parse.parsers[name]; if (!parser.supported(data)) return next(); debug('attempting to extract the license information using: %s', name); parser.parse(data, options, function parsed(err, license) { if (err) return next(); result = license; if (result) debug('parsing with %s was successful', name); next(); }); }, function select() { return !result && options.order.length; }, function cleanup(err) { options = null; next(err, result, name); }); }
javascript
{ "resource": "" }
q30393
train
function() { var scrollHeight = (document[COMPAT_MODE] != CSS1_COMPAT || isSafari) ? document.body.scrollHeight : documentElement.scrollHeight, h = Math.max(scrollHeight, Y.Dom.getViewportHeight()); return h; }
javascript
{ "resource": "" }
q30394
train
function() { var scrollWidth = (document[COMPAT_MODE] != CSS1_COMPAT || isSafari) ? document.body.scrollWidth : documentElement.scrollWidth, w = Math.max(scrollWidth, Y.Dom.getViewportWidth()); return w; }
javascript
{ "resource": "" }
q30395
train
function() { var width = self.innerWidth, // Safari mode = document[COMPAT_MODE]; if (mode || isIE) { // IE, Gecko, Opera width = (mode == CSS1_COMPAT) ? documentElement.clientWidth : // Standards document.body.clientWidth; // Quirks } return width; }
javascript
{ "resource": "" }
q30396
train
function(node, className) { node = Y.Dom.get(node); if (!node) { return null; } var method = function(el) { return Y.Dom.hasClass(el, className); }; return Y.Dom.getAncestorBy(node, method); }
javascript
{ "resource": "" }
q30397
train
function(node, tagName) { node = Y.Dom.get(node); if (!node) { return null; } var method = function(el) { return el[TAG_NAME] && el[TAG_NAME].toUpperCase() == tagName.toUpperCase(); }; return Y.Dom.getAncestorBy(node, method); }
javascript
{ "resource": "" }
q30398
train
function(newNode, referenceNode) { newNode = Y.Dom.get(newNode); referenceNode = Y.Dom.get(referenceNode); if (!newNode || !referenceNode || !referenceNode[PARENT_NODE]) { return null; } return referenceNode[PARENT_NODE].insertBefore(newNode, referenceNode); }
javascript
{ "resource": "" }
q30399
train
function (sel) { var rule,css; if (lang.isString(sel)) { // IE's addRule doesn't support multiple comma delimited // selectors so rules are mapped internally by atomic selectors rule = cssRules[sel.split(/\s*,\s*/)[0]]; return rule ? rule.style.cssText : null; } else { css = []; for (sel in cssRules) { if (cssRules.hasOwnProperty(sel)) { rule = cssRules[sel]; css.push(rule.selectorText+" {"+rule.style.cssText+"}"); } } return css.join("\n"); } }
javascript
{ "resource": "" }