_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q29900
train
function(oRequest, oCallback, oCaller) { var tId = DS._nTransactionId++; this.fireEvent("requestEvent", {tId:tId, request:oRequest,callback:oCallback,caller:oCaller}); /* accounts for the following cases: YAHOO.util.DataSourceBase.TYPE_UNKNOWN YAHOO.util.DataSourceBase.TYPE_JSARRAY YAHOO.util.DataSourceBase.TYPE_JSON YAHOO.util.DataSourceBase.TYPE_HTMLTABLE YAHOO.util.DataSourceBase.TYPE_XML YAHOO.util.DataSourceBase.TYPE_TEXT */ var oRawResponse = this.liveData; this.handleResponse(oRequest, oRawResponse, oCallback, oCaller, tId); return tId; }
javascript
{ "resource": "" }
q29901
train
function(oRequest, oFullResponse) { if(lang.isValue(oFullResponse)) { var oParsedResponse = {results:oFullResponse,meta:{}}; YAHOO.log("Parsed generic data is " + lang.dump(oParsedResponse), "info", this.toString()); return oParsedResponse; } YAHOO.log("Generic data could not be parsed: " + lang.dump(oFullResponse), "error", this.toString()); return null; }
javascript
{ "resource": "" }
q29902
train
function(result) { var oResult = {}, schema = this.responseSchema; try { // Loop through each data field in each result using the schema for(var m = schema.fields.length-1; m >= 0 ; m--) { var field = schema.fields[m]; var key = (lang.isValue(field.key)) ? field.key : field; var data = null; if(this.useXPath) { data = YAHOO.util.DataSource._getLocationValue(field, result); } else { // Values may be held in an attribute... var xmlAttr = result.attributes.getNamedItem(key); if(xmlAttr) { data = xmlAttr.value; } // ...or in a node else { var xmlNode = result.getElementsByTagName(key); if(xmlNode && xmlNode.item(0)) { var item = xmlNode.item(0); // For IE, then DOM... data = (item) ? ((item.text) ? item.text : (item.textContent) ? item.textContent : null) : null; // ...then fallback, but check for multiple child nodes if(!data) { var datapieces = []; for(var j=0, len=item.childNodes.length; j<len; j++) { if(item.childNodes[j].nodeValue) { datapieces[datapieces.length] = item.childNodes[j].nodeValue; } } if(datapieces.length > 0) { data = datapieces.join(""); } } } } } // Safety net if(data === null) { data = ""; } // Backward compatibility if(!field.parser && field.converter) { field.parser = field.converter; YAHOO.log("The field property converter has been deprecated" + " in favor of parser", "warn", this.toString()); } var parser = (typeof field.parser === 'function') ? field.parser : DS.Parser[field.parser+'']; if(parser) { data = parser.call(this, data); } // Safety measure if(data === undefined) { data = null; } oResult[key] = data; } } catch(e) { YAHOO.log("Error while parsing XML result: " + e.message); } return oResult; }
javascript
{ "resource": "" }
q29903
train
function(oRequest, oFullResponse) { var bError = false, schema = this.responseSchema, oParsedResponse = {meta:{}}, xmlList = null, metaNode = schema.metaNode, metaLocators = schema.metaFields || {}, i,k,loc,v; // In case oFullResponse is something funky try { // Pull any meta identified if(this.useXPath) { for (k in metaLocators) { oParsedResponse.meta[k] = YAHOO.util.DataSource._getLocationValue(metaLocators[k], oFullResponse); } } else { metaNode = metaNode ? oFullResponse.getElementsByTagName(metaNode)[0] : oFullResponse; if (metaNode) { for (k in metaLocators) { if (lang.hasOwnProperty(metaLocators, k)) { loc = metaLocators[k]; // Look for a node v = metaNode.getElementsByTagName(loc)[0]; if (v) { v = v.firstChild.nodeValue; } else { // Look for an attribute v = metaNode.attributes.getNamedItem(loc); if (v) { v = v.value; } } if (lang.isValue(v)) { oParsedResponse.meta[k] = v; } } } } } // For result data xmlList = (schema.resultNode) ? oFullResponse.getElementsByTagName(schema.resultNode) : null; } catch(e) { YAHOO.log("Error while parsing XML data: " + e.message); } if(!xmlList || !lang.isArray(schema.fields)) { bError = true; } // Loop through each result else { oParsedResponse.results = []; for(i = xmlList.length-1; i >= 0 ; --i) { var oResult = this.parseXMLResult(xmlList.item(i)); // Capture each array of values into an array of results oParsedResponse.results[i] = oResult; } } if(bError) { YAHOO.log("XML data could not be parsed: " + lang.dump(oFullResponse), "error", this.toString()); oParsedResponse.error = true; } else { YAHOO.log("Parsed XML data is " + lang.dump(oParsedResponse), "info", this.toString()); } return oParsedResponse; }
javascript
{ "resource": "" }
q29904
train
function(oResponse) { // If response ID does not match last made request ID, // silently fail and wait for the next response if(oResponse && (this.connXhrMode == "ignoreStaleResponses") && (oResponse.tId != oQueue.conn.tId)) { YAHOO.log("Ignored stale response", "warn", this.toString()); return null; } // Error if no response else if(!oResponse) { this.fireEvent("dataErrorEvent", {request:oRequest, response:null, callback:oCallback, caller:oCaller, message:DS.ERROR_DATANULL}); YAHOO.log(DS.ERROR_DATANULL, "error", this.toString()); // Send error response back to the caller with the error flag on DS.issueCallback(oCallback,[oRequest, {error:true}], true, oCaller); return null; } // Forward to handler else { // Try to sniff data type if it has not been defined if(this.responseType === DS.TYPE_UNKNOWN) { var ctype = (oResponse.getResponseHeader) ? oResponse.getResponseHeader["Content-Type"] : null; if(ctype) { // xml if(ctype.indexOf("text/xml") > -1) { this.responseType = DS.TYPE_XML; } else if(ctype.indexOf("application/json") > -1) { // json this.responseType = DS.TYPE_JSON; } else if(ctype.indexOf("text/plain") > -1) { // text this.responseType = DS.TYPE_TEXT; } } } this.handleResponse(oRequest, oResponse, oCallback, oCaller, tId); } }
javascript
{ "resource": "" }
q29905
train
function(oResponse) { this.fireEvent("dataErrorEvent", {request:oRequest, response: oResponse, callback:oCallback, caller:oCaller, message:DS.ERROR_DATAINVALID}); YAHOO.log(DS.ERROR_DATAINVALID + ": " + oResponse.statusText, "error", this.toString()); // Backward compatibility if(lang.isString(this.liveData) && lang.isString(oRequest) && (this.liveData.lastIndexOf("?") !== this.liveData.length-1) && (oRequest.indexOf("?") !== 0)){ YAHOO.log("DataSources using XHR no longer automatically supply " + "a \"?\" between the host and query parameters" + " -- please check that the request URL is correct", "warn", this.toString()); } // Send failure response back to the caller with the error flag on oResponse = oResponse || {}; oResponse.error = true; DS.issueCallback(oCallback,[oRequest,oResponse],true, oCaller); return null; }
javascript
{ "resource": "" }
q29906
train
function (oDate, oConfig, sLocale) { oConfig = oConfig || {}; if(!(oDate instanceof Date)) { return YAHOO.lang.isValue(oDate) ? oDate : ""; } var format = oConfig.format || "%m/%d/%Y"; // Be backwards compatible, support strings that are // exactly equal to YYYY/MM/DD, DD/MM/YYYY and MM/DD/YYYY if(format === 'YYYY/MM/DD') { format = '%Y/%m/%d'; } else if(format === 'DD/MM/YYYY') { format = '%d/%m/%Y'; } else if(format === 'MM/DD/YYYY') { format = '%m/%d/%Y'; } // end backwards compatibility block sLocale = sLocale || "en"; // Make sure we have a definition for the requested locale, or default to en. if(!(sLocale in YAHOO.util.DateLocale)) { if(sLocale.replace(/-[a-zA-Z]+$/, '') in YAHOO.util.DateLocale) { sLocale = sLocale.replace(/-[a-zA-Z]+$/, ''); } else { sLocale = "en"; } } var aLocale = YAHOO.util.DateLocale[sLocale]; var replace_aggs = function (m0, m1) { var f = Dt.aggregates[m1]; return (f === 'locale' ? aLocale[m1] : f); }; var replace_formats = function (m0, m1) { var f = Dt.formats[m1]; if(typeof f === 'string') { // string => built in date function return oDate[f](); } else if(typeof f === 'function') { // function => our own function return f.call(oDate, oDate, aLocale); } else if(typeof f === 'object' && typeof f[0] === 'string') { // built in function with padding return xPad(oDate[f[0]](), f[1]); } else { return m1; } }; // First replace aggregates (run in a loop because an agg may be made up of other aggs) while(format.match(/%[cDFhnrRtTxX]/)) { format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs); } // Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a) var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats); replace_aggs = replace_formats = undefined; return str; }
javascript
{ "resource": "" }
q29907
train
function(typeName, id, snapshot) { // FIXME If there is a record, try and look up the self link // - Need to use the function from the serializer to build the self key // TODO: this basically only works in the simplest of scenarios var route = this.getRoute(typeName, id, snapshot); if(!route) { return this._super(typeName, id, snapshot); } var url = []; var host = get(this, 'host'); var prefix = this.urlPrefix(); var param = /\{(.*?)\}/g; if (id) { if (param.test(route)) { url.push(route.replace(param, id)); } else { url.push(route); } } else { url.push(route.replace(param, '')); } if (prefix) { url.unshift(prefix); } url = url.join('/'); if (!host && url) { url = '/' + url; } return url; }
javascript
{ "resource": "" }
q29908
train
function(store, type, ids, snapshots) { return this.ajax(this.buildURL(type.modelName, ids.join(','), snapshots, 'findMany'), 'GET'); }
javascript
{ "resource": "" }
q29909
train
function(payload) { if(!payload) { return {}; } var data = payload[this.primaryRecordKey]; if (data) { if (Ember.isArray(data)) { this.extractArrayData(data, payload); } else { this.extractSingleData(data, payload); } delete payload[this.primaryRecordKey]; } if (payload.meta) { this.extractMeta(payload.meta); delete payload.meta; } if (payload.links) { // FIXME Need to handle top level links, like pagination delete payload.links; } if (payload[this.sideloadedRecordsKey]) { this.extractSideloaded(payload[this.sideloadedRecordsKey]); delete payload[this.sideloadedRecordsKey]; } return payload; }
javascript
{ "resource": "" }
q29910
train
function(sideloaded) { var store = get(this, 'store'); var models = {}; var serializer = this; sideloaded.forEach(function(link) { var type = link.type; if (link.relationships) { serializer.extractRelationships(link.relationships, link); } delete link.type; if (!models[type]) { models[type] = []; } models[type].push(link); }); this.pushPayload(store, models); }
javascript
{ "resource": "" }
q29911
train
function(links, resource) { var link, association, id, route, relationshipLink, cleanedRoute; // Clear the old format resource.links = {}; for (link in links) { association = links[link]; link = Ember.String.camelize(link.split('.').pop()); if(!association) { continue; } if (typeof association === 'string') { if (association.indexOf('/') > -1) { route = association; id = null; } else { // This is no longer valid in JSON API. Potentially remove. route = null; id = association; } relationshipLink = null; } else { if (association.links) { relationshipLink = association.links[this.relationshipKey]; route = association.links[this.relatedResourceKey]; } id = getLinkageId(association.data); } if (route) { cleanedRoute = this.removeHost(route); resource.links[link] = cleanedRoute; // Need clarification on how this is used if (cleanedRoute.indexOf('{') > -1) { DS._routes[link] = cleanedRoute.replace(/^\//, ''); } } if (id) { resource[link] = id; } } return resource.links; }
javascript
{ "resource": "" }
q29912
train
function(record, json, relationship) { var attr = relationship.key; var belongsTo = record.belongsTo(attr); var type, key; if (isNone(belongsTo)) { return; } type = this.keyForSnapshot(belongsTo); key = this.keyForRelationship(attr); if (!json.links) { json.links = json.relationships || {}; } json.links[key] = belongsToLink(key, type, get(belongsTo, 'id')); }
javascript
{ "resource": "" }
q29913
train
function(record, json, relationship) { var attr = relationship.key; var type = this.keyForRelationship(relationship.type); var key = this.keyForRelationship(attr); if (relationship.kind === 'hasMany') { json.relationships = json.relationships || {}; json.relationships[key] = hasManyLink(key, type, record, attr); } }
javascript
{ "resource": "" }
q29914
onSkeletonUpdate
train
function onSkeletonUpdate(skeleton) { for (var c in connections) { connections[c].sendUTF(JSON.stringify(skeleton)); } }
javascript
{ "resource": "" }
q29915
onMessage
train
function onMessage(data) { if (data.type == "utf8") { message = JSON.parse(data.utf8Data); switch (message.command) { case "setJoints": console.log("Client has request to add joints: " + message.data); nuimotion.jointsTracking = message.data; break; case "addListener": console.log("Client has request to add events: " + message.data); if (!nuimotion._eventCallbackDict[message.data]) { nuimotion.addListener(message.data, onEvent); } break; case "addGesture": console.log("Client has request to add gestures: " + message.data); if (!nuimotion._gestureCallbackDict[message.data]) { nuimotion.addGesture(message.data, onEvent); } break; } } }
javascript
{ "resource": "" }
q29916
xsltChildNodes
train
function xsltChildNodes(input, template, output) { // Clone input context to keep variables declared here local to the // siblings of the children. var context = input.clone(); for (var i = 0; i < template.childNodes.length; ++i) { xsltProcessContext(context, template.childNodes[i], output); } }
javascript
{ "resource": "" }
q29917
train
function() { // Make sure pending changes have been committed. this.commit(); if (this.history.length) { // Take the top diff from the history, apply it, and store its // shadow in the redo history. var item = this.history.pop(); this.redoHistory.push(this.updateTo(item, "applyChain")); this.notifyEnvironment(); return this.chainNode(item); } }
javascript
{ "resource": "" }
q29918
train
function() { this.commit(); if (this.redoHistory.length) { // The inverse of undo, basically. var item = this.redoHistory.pop(); this.addUndoLevel(this.updateTo(item, "applyChain")); this.notifyEnvironment(); return this.chainNode(item); } }
javascript
{ "resource": "" }
q29919
train
function(from, to, lines) { var chain = []; for (var i = 0; i < lines.length; i++) { var end = (i == lines.length - 1) ? to : this.container.ownerDocument.createElement("BR"); chain.push({from: from, to: end, text: cleanText(lines[i])}); from = end; } this.pushChains([chain], from == null && to == null); this.notifyEnvironment(); }
javascript
{ "resource": "" }
q29920
train
function(doNotHighlight) { this.parent.clearTimeout(this.commitTimeout); // Make sure there are no pending dirty nodes. if (!doNotHighlight) this.editor.highlightDirty(true); // Build set of chains. var chains = this.touchedChains(), self = this; if (chains.length) { this.addUndoLevel(this.updateTo(chains, "linkChain")); this.redoHistory = []; this.notifyEnvironment(); } }
javascript
{ "resource": "" }
q29921
train
function(chains, updateFunc) { var shadows = [], dirty = []; for (var i = 0; i < chains.length; i++) { shadows.push(this.shadowChain(chains[i])); dirty.push(this[updateFunc](chains[i])); } if (updateFunc == "applyChain") this.notifyDirty(dirty); return shadows; }
javascript
{ "resource": "" }
q29922
train
function(node) { if (node) { if (!node.historyTouched) { this.touched.push(node); node.historyTouched = true; } } else { this.firstTouched = true; } }
javascript
{ "resource": "" }
q29923
train
function(chain) { var shadows = [], next = this.after(chain[0].from), end = chain[chain.length - 1].to; while (true) { shadows.push(next); var nextNode = next.to; if (!nextNode || nextNode == end) break; else next = nextNode.historyAfter || this.before(end); // (The this.before(end) is a hack -- FF sometimes removes // properties from BR nodes, in which case the best we can hope // for is to not break.) } return shadows; }
javascript
{ "resource": "" }
q29924
train
function(chain) { // Some attempt is made to prevent the cursor from jumping // randomly when an undo or redo happens. It still behaves a bit // strange sometimes. var cursor = select.cursorPos(this.container, false), self = this; // Remove all nodes in the DOM tree between from and to (null for // start/end of container). function removeRange(from, to) { var pos = from ? from.nextSibling : self.container.firstChild; while (pos != to) { var temp = pos.nextSibling; removeElement(pos); pos = temp; } } var start = chain[0].from, end = chain[chain.length - 1].to; // Clear the space where this change has to be made. removeRange(start, end); // Insert the content specified by the chain into the DOM tree. for (var i = 0; i < chain.length; i++) { var line = chain[i]; // The start and end of the space are already correct, but BR // tags inside it have to be put back. if (i > 0) self.container.insertBefore(line.from, end); // Add the text. var node = makePartSpan(fixSpaces(line.text), this.container.ownerDocument); self.container.insertBefore(node, end); // See if the cursor was on this line. Put it back, adjusting // for changed line length, if it was. if (cursor && cursor.node == line.from) { var cursordiff = 0; var prev = this.after(line.from); if (prev && i == chain.length - 1) { // Only adjust if the cursor is after the unchanged part of // the line. for (var match = 0; match < cursor.offset && line.text.charAt(match) == prev.text.charAt(match); match++); if (cursor.offset > match) cursordiff = line.text.length - prev.text.length; } select.setCursorPos(this.container, {node: line.from, offset: Math.max(0, cursor.offset + cursordiff)}); } // Cursor was in removed line, this is last new line. else if (cursor && (i == chain.length - 1) && cursor.node && cursor.node.parentNode != this.container) { select.setCursorPos(this.container, {node: line.from, offset: line.text.length}); } } // Anchor the chain in the DOM tree. this.linkChain(chain); return start; }
javascript
{ "resource": "" }
q29925
train
function (hash /*:Object*/) /*:String*/ { //shortcuts var lang = YAHOO.lang; if (!lang.isObject(hash)){ throw new TypeError("Cookie._createCookieHashString(): Argument must be an object."); } var text /*:Array*/ = []; for (var key in hash){ if (lang.hasOwnProperty(hash, key) && !lang.isFunction(hash[key]) && !lang.isUndefined(hash[key])){ text.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(hash[key]))); } } return text.join("&"); }
javascript
{ "resource": "" }
q29926
train
function (text /*:String*/) /*:Object*/ { var hashParts /*:Array*/ = text.split("&"), hashPart /*:Array*/ = null, hash /*:Object*/ = {}; if (text.length > 0){ for (var i=0, len=hashParts.length; i < len; i++){ hashPart = hashParts[i].split("="); hash[decodeURIComponent(hashPart[0])] = decodeURIComponent(hashPart[1]); } } return hash; }
javascript
{ "resource": "" }
q29927
train
function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ { var cookies /*:Object*/ = {}; if (YAHOO.lang.isString(text) && text.length > 0) { var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent); //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){ var cookieParts /*:Array*/ = text.split(/;\s/g), cookieName /*:String*/ = null, cookieValue /*:String*/ = null, cookieNameValue /*:Array*/ = null; for (var i=0, len=cookieParts.length; i < len; i++){ //check for normally-formatted cookie (name-value) cookieNameValue = cookieParts[i].match(/([^=]+)=/i); if (cookieNameValue instanceof Array){ try { cookieName = decodeURIComponent(cookieNameValue[1]); cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1)); } catch (ex){ //ignore the entire cookie - encoding is likely invalid } } else { //means the cookie does not have an "=", so treat it as a boolean flag cookieName = decodeURIComponent(cookieParts[i]); cookieValue = ""; } cookies[cookieName] = cookieValue; } //} } return cookies; }
javascript
{ "resource": "" }
q29928
train
function (name /*:String*/, options /*:Variant*/) /*:Variant*/{ var lang = YAHOO.lang, converter; if (lang.isFunction(options)) { converter = options; options = {}; } else if (lang.isObject(options)) { converter = options.converter; } else { options = {}; } var cookies /*:Object*/ = this._parseCookieString(document.cookie, !options.raw); if (!lang.isString(name) || name === ""){ throw new TypeError("Cookie.get(): Cookie name must be a non-empty string."); } if (lang.isUndefined(cookies[name])) { return null; } if (!lang.isFunction(converter)){ return cookies[name]; } else { return converter(cookies[name]); } }
javascript
{ "resource": "" }
q29929
train
function (name, subName, converter) { var lang = YAHOO.lang, hash = this.getSubs(name); if (hash !== null) { if (!lang.isString(subName) || subName === ""){ throw new TypeError("Cookie.getSub(): Subcookie name must be a non-empty string."); } if (lang.isUndefined(hash[subName])){ return null; } if (!lang.isFunction(converter)){ return hash[subName]; } else { return converter(hash[subName]); } } else { return null; } }
javascript
{ "resource": "" }
q29930
train
function (name /*:String*/) /*:Object*/ { var isString = YAHOO.lang.isString; //check cookie name if (!isString(name) || name === ""){ throw new TypeError("Cookie.getSubs(): Cookie name must be a non-empty string."); } var cookies = this._parseCookieString(document.cookie, false); if (isString(cookies[name])){ return this._parseCookieHash(cookies[name]); } return null; }
javascript
{ "resource": "" }
q29931
train
function (name /*:String*/, options /*:Object*/) /*:String*/ { //check cookie name if (!YAHOO.lang.isString(name) || name === ""){ throw new TypeError("Cookie.remove(): Cookie name must be a non-empty string."); } //set options - clone options so the original isn't affected options = YAHOO.lang.merge(options || {}, { expires: new Date(0) }); //set cookie return this.set(name, "", options); }
javascript
{ "resource": "" }
q29932
train
function(name /*:String*/, subName /*:String*/, options /*:Object*/) /*:String*/ { var lang = YAHOO.lang; options = options || {}; //check cookie name if (!lang.isString(name) || name === ""){ throw new TypeError("Cookie.removeSub(): Cookie name must be a non-empty string."); } //check subcookie name if (!lang.isString(subName) || subName === ""){ throw new TypeError("Cookie.removeSub(): Subcookie name must be a non-empty string."); } //get all subcookies for this cookie var subs = this.getSubs(name); //delete the indicated subcookie if (lang.isObject(subs) && lang.hasOwnProperty(subs, subName)){ delete subs[subName]; if (!options.removeIfEmpty) { //reset the cookie return this.setSubs(name, subs, options); } else { //reset the cookie if there are subcookies left, else remove for (var key in subs){ if (lang.hasOwnProperty(subs, key) && !lang.isFunction(subs[key]) && !lang.isUndefined(subs[key])){ return this.setSubs(name, subs, options); } } return this.remove(name, options); } } else { return ""; } }
javascript
{ "resource": "" }
q29933
train
function (name /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ { var lang = YAHOO.lang; options = options || {}; if (!lang.isString(name)){ throw new TypeError("Cookie.set(): Cookie name must be a string."); } if (lang.isUndefined(value)){ throw new TypeError("Cookie.set(): Value cannot be undefined."); } var text /*:String*/ = this._createCookieString(name, value, !options.raw, options); document.cookie = text; return text; }
javascript
{ "resource": "" }
q29934
train
function (name /*:String*/, subName /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ { var lang = YAHOO.lang; if (!lang.isString(name) || name === ""){ throw new TypeError("Cookie.setSub(): Cookie name must be a non-empty string."); } if (!lang.isString(subName) || subName === ""){ throw new TypeError("Cookie.setSub(): Subcookie name must be a non-empty string."); } if (lang.isUndefined(value)){ throw new TypeError("Cookie.setSub(): Subcookie value cannot be undefined."); } var hash /*:Object*/ = this.getSubs(name); if (!lang.isObject(hash)){ hash = {}; } hash[subName] = value; return this.setSubs(name, hash, options); }
javascript
{ "resource": "" }
q29935
train
function (name /*:String*/, value /*:Object*/, options /*:Object*/) /*:String*/ { var lang = YAHOO.lang; if (!lang.isString(name)){ throw new TypeError("Cookie.setSubs(): Cookie name must be a string."); } if (!lang.isObject(value)){ throw new TypeError("Cookie.setSubs(): Cookie value must be an object."); } var text /*:String*/ = this._createCookieString(name, this._createCookieHashString(value), false, options); document.cookie = text; return text; }
javascript
{ "resource": "" }
q29936
train
function(el,style) { var sStyle = YAHOO.util.Dom.getStyle(el, style); return parseInt(sStyle.substr(0, sStyle.length-2), 10); }
javascript
{ "resource": "" }
q29937
train
function() { // Remove the canvas from the dom this.parentEl.removeChild(this.element); // Remove the wire reference from the connected terminals if(this.terminal1 && this.terminal1.removeWire) { this.terminal1.removeWire(this); } if(this.terminal2 && this.terminal2.removeWire) { this.terminal2.removeWire(this); } // Remove references to old terminals this.terminal1 = null; this.terminal2 = null; // Remove Label if(this.labelEl) { if(this.labelField) { this.labelField.destroy(); } this.labelEl.innerHTML = ""; } }
javascript
{ "resource": "" }
q29938
train
function() { var self=this, body=document.body; if (!body || !body.firstChild) { window.setTimeout( function() { self.createFrame(); }, 50 ); return; } var div=this.getDragEl(), Dom=YAHOO.util.Dom; if (!div) { div = document.createElement("div"); div.id = this.dragElId; var s = div.style; s.position = "absolute"; s.visibility = "hidden"; s.cursor = "move"; s.border = "2px solid #aaa"; s.zIndex = 999; var size = this.terminalProxySize+"px"; s.height = size; s.width = size; var _data = document.createElement('div'); Dom.setStyle(_data, 'height', '100%'); Dom.setStyle(_data, 'width', '100%'); Dom.setStyle(_data, 'background-color', '#ccc'); Dom.setStyle(_data, 'opacity', '0'); div.appendChild(_data); body.insertBefore(div, body.firstChild); } }
javascript
{ "resource": "" }
q29939
train
function() { // Display the cut button this.hideNow(); this.addClass(CSS_PREFIX+"Wire-scissors"); // The scissors are within the terminal element this.appendTo(this._terminal.container ? this._terminal.container.layer.el : this._terminal.el.parentNode.parentNode); // Ajoute un listener sur le scissor: this.on("mouseover", this.show, this, true); this.on("mouseout", this.hide, this, true); this.on("click", this.scissorClick, this, true); // On mouseover/mouseout to display/hide the scissors Event.addListener(this._terminal.el, "mouseover", this.mouseOver, this, true); Event.addListener(this._terminal.el, "mouseout", this.hide, this, true); }
javascript
{ "resource": "" }
q29940
train
function() { // Create the DIV element this.el = WireIt.cn('div', {className: this.className} ); if(this.name) { this.el.title = this.name; } // Set the offset position this.setPosition(this.offsetPosition); // Append the element to the parent this.parentEl.appendChild(this.el); }
javascript
{ "resource": "" }
q29941
train
function(wire) { // Adds this wire to the list of connected wires : this.wires.push(wire); // Set class indicating that the wire is connected Dom.addClass(this.el, this.connectedClassName); // Fire the event this.eventAddWire.fire(wire); }
javascript
{ "resource": "" }
q29942
train
function(wire) { var index = WireIt.indexOf(wire, this.wires); if( index != -1 ) { this.wires[index].destroy(); this.wires[index] = null; this.wires = WireIt.compact(this.wires); // Remove the connected class if it has no more wires: if(this.wires.length === 0) { Dom.removeClass(this.el, this.connectedClassName); } // Fire the event this.eventRemoveWire.fire(wire); } }
javascript
{ "resource": "" }
q29943
train
function() { var layerEl = this.container && this.container.layer ? this.container.layer.el : document.body; var obj = this.el; var curleft = 0, curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; obj = obj.offsetParent; } while ( !!obj && obj != layerEl); } return [curleft+15,curtop+15]; }
javascript
{ "resource": "" }
q29944
train
function() { var terminalList = []; if(this.wires) { for(var i = 0 ; i < this.wires.length ; i++) { terminalList.push(this.wires[i].getOtherTerminal(this)); } } return terminalList; }
javascript
{ "resource": "" }
q29945
train
function(e) { // Make sure terminalList is an array var terminalList = YAHOO.lang.isArray(this._WireItTerminals) ? this._WireItTerminals : (this._WireItTerminals.isWireItTerminal ? [this._WireItTerminals] : []); // Redraw all the wires for(var i = 0 ; i < terminalList.length ; i++) { if(terminalList[i].wires) { for(var k = 0 ; k < terminalList[i].wires.length ; k++) { terminalList[i].wires[k].redraw(); } } } }
javascript
{ "resource": "" }
q29946
train
function(event, args) { var size = args[0]; // TODO: do not hardcode those sizes !! WireIt.sn(this.bodyEl, null, {width: (size[0]-14)+"px", height: (size[1]-( this.ddHandle ? 44 : 14) )+"px"}); }
javascript
{ "resource": "" }
q29947
train
function(content) { if(typeof content == "string") { this.bodyEl.innerHTML = content; } else { this.bodyEl.innerHTML = ""; this.bodyEl.appendChild(content); } }
javascript
{ "resource": "" }
q29948
train
function(event, args) { var wire = args[0]; // add the wire to the list if it isn't in if( WireIt.indexOf(wire, this.wires) == -1 ) { this.wires.push(wire); this.eventAddWire.fire(wire); } }
javascript
{ "resource": "" }
q29949
train
function(container) { var index = WireIt.indexOf(container, this.containers); if( index != -1 ) { container.remove(); this.containers[index] = null; this.containers = WireIt.compact(this.containers); this.eventRemoveContainer.fire(container); this.eventChanged.fire(this); } }
javascript
{ "resource": "" }
q29950
train
function(event, args) { var wire = args[0]; // add the wire to the list if it isn't in if( WireIt.indexOf(wire, this.wires) == -1 ) { this.wires.push(wire); if(this.enableMouseEvents) { YAHOO.util.Event.addListener(wire.element, "mousemove", this.onWireMouseMove, this, true); YAHOO.util.Event.addListener(wire.element, "click", this.onWireClick, this, true); } // Re-Fire an event at the layer level this.eventAddWire.fire(wire); // Fire the layer changed event this.eventChanged.fire(this); } }
javascript
{ "resource": "" }
q29951
train
function(event, args) { var wire = args[0]; var index = WireIt.indexOf(wire, this.wires); if( index != -1 ) { this.wires[index] = null; this.wires = WireIt.compact(this.wires); this.eventRemoveWire.fire(wire); this.eventChanged.fire(this); } }
javascript
{ "resource": "" }
q29952
train
function() { var i; var obj = {containers: [], wires: []}; for( i = 0 ; i < this.containers.length ; i++) { obj.containers.push( this.containers[i].getConfig() ); } for( i = 0 ; i < this.wires.length ; i++) { var wire = this.wires[i]; var wireObj = wire.getConfig(); wireObj.src = {moduleId: WireIt.indexOf(wire.terminal1.container, this.containers), terminal: wire.terminal1.name }; wireObj.tgt = {moduleId: WireIt.indexOf(wire.terminal2.container, this.containers), terminal: wire.terminal2.name }; obj.wires.push(wireObj); } return obj; }
javascript
{ "resource": "" }
q29953
train
function(wiring) { this.clear(); var i; if(YAHOO.lang.isArray(wiring.containers)) { for(i = 0 ; i < wiring.containers.length ; i++) { this.addContainer(wiring.containers[i]); } } if(YAHOO.lang.isArray(wiring.wires)) { for(i = 0 ; i < wiring.wires.length ; i++) { this.addWire(wiring.wires[i]); } } }
javascript
{ "resource": "" }
q29954
train
function(e) { var tgt = YAHOO.util.Event.getTarget(e); var tgtPos = [tgt.offsetLeft, tgt.offsetTop]; return [tgtPos[0]+e.layerX, tgtPos[1]+e.layerY]; }
javascript
{ "resource": "" }
q29955
train
function() { var layer = this.layer; Event.addListener(this.element, 'mousedown', this.onMouseDown, this, true); Event.addListener(this.element, 'mouseup', this.onMouseUp, this, true); Event.addListener(this.element, 'mousemove', this.onMouseMove, this, true); Event.addListener(this.element, 'mouseout', this.onMouseUp, this, true); layer.eventAddWire.subscribe(this.draw, this, true); layer.eventRemoveWire.subscribe(this.draw, this, true); layer.eventAddContainer.subscribe(this.draw, this, true); layer.eventRemoveContainer.subscribe(this.draw, this, true); layer.eventContainerDragged.subscribe(this.draw, this, true); layer.eventContainerResized.subscribe(this.draw, this, true); Event.addListener(this.layer.el, "scroll", this.onLayerScroll, this, true); }
javascript
{ "resource": "" }
q29956
train
function(e, args) { Event.stopEvent(e); if(this.isMouseDown) { this.scrollLayer(e.clientX,e.clientY); } }
javascript
{ "resource": "" }
q29957
train
function() { if(this.scrollTimer) { window.clearTimeout(this.scrollTimer); } var that = this; this.scrollTimer = window.setTimeout(function() { that.draw(); },50); }
javascript
{ "resource": "" }
q29958
train
function() { var ctxt=this.getContext(); // Canvas Region var canvasRegion = Dom.getRegion(this.element); var canvasWidth = canvasRegion.right-canvasRegion.left-4; var canvasHeight = canvasRegion.bottom-canvasRegion.top-4; // Clear Rect ctxt.clearRect(0,0, canvasWidth, canvasHeight); // Calculate ratio var layerWidth = this.layer.el.scrollWidth; var layerHeight = this.layer.el.scrollHeight; var hRatio = Math.floor(100*canvasWidth/layerWidth)/100; var vRatio = Math.floor(100*canvasHeight/layerHeight)/100; // Draw the viewport var region = Dom.getRegion(this.layer.el); var viewportWidth = region.right-region.left; var viewportHeight = region.bottom-region.top; var viewportX = this.layer.el.scrollLeft; var viewportY = this.layer.el.scrollTop; ctxt.strokeStyle= "rgb(200, 50, 50)"; ctxt.lineWidth=1; ctxt.strokeRect(viewportX*hRatio, viewportY*vRatio, viewportWidth*hRatio, viewportHeight*vRatio); // Draw containers and wires ctxt.fillStyle = this.style; ctxt.strokeStyle= this.style; ctxt.lineWidth=this.lineWidth; this.drawContainers(ctxt, hRatio, vRatio); this.drawWires(ctxt, hRatio, vRatio); }
javascript
{ "resource": "" }
q29959
train
function(ctxt, hRatio, vRatio) { var containers = this.layer.containers; var n = containers.length,i,gIS = WireIt.getIntStyle,containerEl; for(i = 0 ; i < n ; i++) { containerEl = containers[i].el; ctxt.fillRect(gIS(containerEl, "left")*hRatio, gIS(containerEl, "top")*vRatio, gIS(containerEl, "width")*hRatio, gIS(containerEl, "height")*vRatio); } }
javascript
{ "resource": "" }
q29960
train
function(ctxt, hRatio, vRatio) { var wires = this.layer.wires; var n = wires.length,i,wire; for(i = 0 ; i < n ; i++) { wire = wires[i]; var pos1 = wire.terminal1.getXY(), pos2 = wire.terminal2.getXY(); // Stroked line // TODO: ctxt.beginPath(); ctxt.moveTo(pos1[0]*hRatio,pos1[1]*vRatio); ctxt.lineTo(pos2[0]*hRatio,pos2[1]*vRatio); ctxt.closePath(); ctxt.stroke(); } }
javascript
{ "resource": "" }
q29961
train
function(arr) { var n = [], l=arr.length,i; for(i = 0 ; i < l ; i++) { if( !lang.isNull(arr[i]) && !lang.isUndefined(arr[i]) ) { n.push(arr[i]); } } return n; }
javascript
{ "resource": "" }
q29962
train
function(state) { if(state == inputEx.stateRequired) { return this.options.messages.required; } else if(state == inputEx.stateInvalid) { return this.options.messages.invalid; } else { return ''; } }
javascript
{ "resource": "" }
q29963
train
function(msg) { if(!this.fieldContainer) { return; } if(!this.msgEl) { this.msgEl = inputEx.cn('div', {className: 'inputEx-message'}); try{ var divElements = this.divEl.getElementsByTagName('div'); this.divEl.insertBefore(this.msgEl, divElements[(divElements.length-1>=0)?divElements.length-1:0]); //insertBefore the clear:both div }catch(e){alert(e);} } this.msgEl.innerHTML = msg; }
javascript
{ "resource": "" }
q29964
train
function(options) { inputEx.Field.superclass.setOptions.call(this, options); this.options.wirable = lang.isUndefined(options.wirable) ? false : options.wirable; this.options.container = options.container; options.container = null; }
javascript
{ "resource": "" }
q29965
train
function() { var wrapper = inputEx.cn('div', {className: 'WireIt-InputExTerminal'}); this.divEl.insertBefore(wrapper, this.fieldContainer); this.terminal = new WireIt.Terminal(wrapper, { name: this.options.name, direction: [-1,0], fakeDirection: [0, 1], ddConfig: { type: "input", allowedTypes: ["output"] }, nMaxWires: 1 }, this.options.container); // Reference to the container if(this.options.container) { this.options.container.terminals.push(this.terminal); } // Register the events this.terminal.eventAddWire.subscribe(this.onAddWire, this, true); this.terminal.eventRemoveWire.subscribe(this.onRemoveWire, this, true); }
javascript
{ "resource": "" }
q29966
train
function(fieldOptions) { // Instanciate the field var fieldInstance = inputEx(fieldOptions,this); this.inputs.push(fieldInstance); // Create an index to access fields by their name if(fieldInstance.options.name) { this.inputsNames[fieldInstance.options.name] = fieldInstance; } // Create the this.hasInteractions to run interactions at startup if(!this.hasInteractions && fieldOptions.interactions) { this.hasInteractions = true; } // Subscribe to the field "updated" event to send the group "updated" event fieldInstance.updatedEvt.subscribe(this.onChange, this, true); return fieldInstance; }
javascript
{ "resource": "" }
q29967
train
function() { var input, inputName, state, message, returnedObj = { fields:{}, validate:true }; // Loop on all the sub fields for (var i = 0 ; i < this.inputs.length ; i++) { input = this.inputs[i]; inputName = input.options.name; state = input.getState(); message = input.getStateString(state); returnedObj.fields[inputName] = {}; returnedObj.fields[inputName].valid = true; returnedObj.fields[inputName].message = message; // check if subfield validates if( state == inputEx.stateRequired || state == inputEx.stateInvalid ) { returnedObj.fields[inputName].valid = false; returnedObj.validate = false; } } return returnedObj; }
javascript
{ "resource": "" }
q29968
train
function() { var o = {}; for (var i = 0 ; i < this.inputs.length ; i++) { var v = this.inputs[i].getValue(); if(this.inputs[i].options.name) { if(this.inputs[i].options.flatten && lang.isObject(v) ) { lang.augmentObject( o, v); } else { o[this.inputs[i].options.name] = v; } } } return o; }
javascript
{ "resource": "" }
q29969
train
function(eventName, args) { // Run interactions var fieldValue = args[0]; var fieldInstance = args[1]; this.runInteractions(fieldInstance,fieldValue); //this.setClassFromState(); this.fireUpdatedEvt(); }
javascript
{ "resource": "" }
q29970
train
function(fieldInstance,fieldValue) { var index = inputEx.indexOf(fieldInstance, this.inputs); var fieldConfig = this.options.fields[index]; if( YAHOO.lang.isUndefined(fieldConfig.interactions) ) return; // Let's run the interactions ! var interactions = fieldConfig.interactions; for(var i = 0 ; i < interactions.length ; i++) { var interaction = interactions[i]; if(interaction.valueTrigger === fieldValue) { for(var j = 0 ; j < interaction.actions.length ; j++) { this.runAction(interaction.actions[j], fieldValue); } } } }
javascript
{ "resource": "" }
q29971
train
function() { if(this.hasInteractions) { for(var i = 0 ; i < this.inputs.length ; i++) { this.runInteractions(this.inputs[i],this.inputs[i].getValue()); } } }
javascript
{ "resource": "" }
q29972
train
function(sendUpdatedEvt) { for(var i = 0 ; i < this.inputs.length ; i++) { this.inputs[i].clear(false); } if(sendUpdatedEvt !== false) { // fire update event this.fireUpdatedEvt(); } }
javascript
{ "resource": "" }
q29973
train
function(errors) { var i,k; if(YAHOO.lang.isArray(errors)) { for(i = 0 ; i < errors.length ; i++) { k = errors[i][0]; value = errors[i][1]; if(this.inputsNames[k]) { if(this.inputsNames[k].options.showMsg) { this.inputsNames[k].displayMessage(value); Dom.replaceClass(this.inputsNames[k].divEl, "inputEx-valid", "inputEx-invalid" ); } } } } else if(YAHOO.lang.isObject(errors)) { for(k in errors) { if(errors.hasOwnProperty(k)) { if(this.inputsNames[k]) { if(this.inputsNames[k].options.showMsg) { this.inputsNames[k].displayMessage(errors[k]); Dom.replaceClass(this.inputsNames[k].divEl, "inputEx-valid", "inputEx-invalid" ); } } } } } }
javascript
{ "resource": "" }
q29974
train
function(options) { this.options = {}; this.options.id = lang.isString(options.id) ? options.id : Dom.generateId(); this.options.className = options.className || "inputEx-Button"; this.options.parentEl = lang.isString(options.parentEl) ? Dom.get(options.parentEl) : options.parentEl; // default type === "submit" this.options.type = (options.type === "link" || options.type === "submit-link") ? options.type : "submit"; // value is the text displayed inside the button (<input type="submit" value="Submit" /> convention...) this.options.value = options.value; this.options.disabled = !!options.disabled; if (lang.isFunction(options.onClick)) { this.options.onClick = {fn: options.onClick, scope:this}; } else if (lang.isObject(options.onClick)) { this.options.onClick = {fn: options.onClick.fn, scope: options.onClick.scope || this}; } }
javascript
{ "resource": "" }
q29975
train
function(parentEl) { var innerSpan; if (this.options.type === "link" || this.options.type === "submit-link") { this.el = inputEx.cn('a', {className: this.options.className, id:this.options.id, href:"#"}); Dom.addClass(this.el,this.options.type === "link" ? "inputEx-Button-Link" : "inputEx-Button-Submit-Link"); innerSpan = inputEx.cn('span', null, null, this.options.value); this.el.appendChild(innerSpan); // default type is "submit" input } else { this.el = inputEx.cn('input', {type: "submit", value: this.options.value, className: this.options.className, id:this.options.id}); Dom.addClass(this.el,"inputEx-Button-Submit"); } parentEl.appendChild(this.el); if (this.options.disabled) { this.disable(); } this.initEvents(); return this.el; }
javascript
{ "resource": "" }
q29976
train
function() { /** * Click Event facade (YUI custom event) * @event clickEvent */ this.clickEvent = new util.CustomEvent("click"); /** * Submit Event facade (YUI custom event) * @event submitEvent */ this.submitEvent = new util.CustomEvent("submit"); Event.addListener(this.el,"click",function(e) { var fireSubmitEvent; // stop click event, so : // // 1. buttons of 'link' or 'submit-link' type don't link to any url // 2. buttons of 'submit' type (<input type="submit" />) don't fire a 'submit' event Event.stopEvent(e); // button disabled : don't fire clickEvent, and stop here if (this.disabled) { fireSubmitEvent = false; // button enabled : fire clickEvent } else { // submit event will be fired if not prevented by clickEvent fireSubmitEvent = this.clickEvent.fire(); } // link buttons should NOT fire a submit event if (this.options.type === "link") { fireSubmitEvent = false; } if (fireSubmitEvent) { this.submitEvent.fire(); } },this,true); // Subscribe onClick handler if (this.options.onClick) { this.clickEvent.subscribe(this.options.onClick.fn,this.options.onClick.scope,true); } }
javascript
{ "resource": "" }
q29977
train
function() { this.disabled = true; Dom.addClass(this.el,"inputEx-Button-disabled"); if (this.options.type === "submit") { this.el.disabled = true; } }
javascript
{ "resource": "" }
q29978
train
function() { this.disabled = false; Dom.removeClass(this.el,"inputEx-Button-disabled"); if (this.options.type === "submit") { this.el.disabled = false; } }
javascript
{ "resource": "" }
q29979
train
function() { Event.addListener(this.el, "change", this.onChange, this, true); if (YAHOO.env.ua.ie){ // refer to inputEx-95 var field = this.el; new YAHOO.util.KeyListener(this.el, {keys:[13]}, {fn:function(){ field.blur(); field.focus(); }}).enable(); } Event.addFocusListener(this.el, this.onFocus, this, true); Event.addBlurListener(this.el, this.onBlur, this, true); Event.addListener(this.el, "keypress", this.onKeyPress, this, true); Event.addListener(this.el, "keyup", this.onKeyUp, this, true); }
javascript
{ "resource": "" }
q29980
train
function() { var value; value = (this.options.typeInvite && this.el.value == this.options.typeInvite) ? '' : this.el.value; if (this.options.trim) { value = YAHOO.lang.trim(value); } return value; }
javascript
{ "resource": "" }
q29981
train
function(e) { inputEx.StringField.superclass.onFocus.call(this,e); if(this.options.typeInvite) { this.updateTypeInvite(); } }
javascript
{ "resource": "" }
q29982
train
function (config) { var choice, position, that; // allow config not to be an object, just a value -> convert it in a standard config object if (!lang.isObject(config)) { config = { value: config }; } choice = { value: config.value, label: lang.isString(config.label) ? config.label : "" + config.value, visible: true }; // Create DOM <option> node choice.node = this.createChoiceNode(choice); // Get choice's position // -> don't pass config.value to getChoicePosition !!! // (we search position of existing choice, whereas config.value is a property of new choice to be created...) position = this.getChoicePosition({ position: config.position, label: config.before || config.after }); if (position === -1) { // (default is at the end) position = this.choicesList.length; } else if (lang.isString(config.after)) { // +1 to insert "after" position (not "at" position) position += 1; } // Insert choice in list at position this.choicesList.splice(position, 0, choice); // Append <option> node in DOM this.appendChoiceNode(choice.node, position); // Select new choice if (!!config.selected) { // setTimeout for IE6 (let time to create dom option) that = this; setTimeout(function () { that.setValue(choice.value); }, 0); } // Return generated choice return choice; }
javascript
{ "resource": "" }
q29983
train
function (config) { var position, choice; // Get choice's position position = this.getChoicePosition(config); if (position === -1) { throw new Error("SelectField : invalid or missing position, label or value in removeChoice"); } // Choice to remove choice = this.choicesList[position]; // Clear if removing selected choice if (this.getValue() === choice.value) { this.clear(); } // Remove choice in list at position this.choicesList.splice(position, 1); // remove 1 element at position // Remove node from DOM this.removeChoiceNode(choice.node); }
javascript
{ "resource": "" }
q29984
train
function (config) { var position, choice; position = this.getChoicePosition(config); if (position !== -1) { choice = this.choicesList[position]; if (!choice.visible) { choice.visible = true; this.appendChoiceNode(choice.node, position); } } }
javascript
{ "resource": "" }
q29985
train
function (config, unselect) { var position, choice; // Should we unselect choice if disabling selected choice if (lang.isUndefined(unselect) || !lang.isBoolean(unselect)) { unselect = true; } position = this.getChoicePosition(config); if (position !== -1) { choice = this.choicesList[position]; this.disableChoiceNode(choice.node); // Clear if disabling selected choice if (unselect && this.getValue() === choice.value) { this.clear(); } } }
javascript
{ "resource": "" }
q29986
train
function (config) { var position, choice; position = this.getChoicePosition(config); if (position !== -1) { choice = this.choicesList[position]; this.enableChoiceNode(choice.node); } }
javascript
{ "resource": "" }
q29987
train
function () { var i, length; // create DOM <select> node this.el = inputEx.cn('select', { id: this.divEl.id ? this.divEl.id + '-field' : YAHOO.util.Dom.generateId(), name: this.options.name || '' }); // list of choices (e.g. [{ label: "France", value:"fr", node:<DOM-node>, visible:true }, {...}, ...]) this.choicesList = []; // add choices for (i = 0, length = this.options.choices.length; i < length; i += 1) { this.addChoice(this.options.choices[i]); } // append <select> to DOM tree this.fieldContainer.appendChild(this.el); }
javascript
{ "resource": "" }
q29988
train
function () { var choiceIndex; if (this.el.selectedIndex >= 0) { choiceIndex = inputEx.indexOf(this.el.childNodes[this.el.selectedIndex], this.choicesList, function (node, choice) { return node === choice.node; }); return this.choicesList[choiceIndex].value; } else { return ""; } }
javascript
{ "resource": "" }
q29989
train
function(options) { inputEx.EmailField.superclass.setOptions.call(this, options); // Overwrite options this.options.messages.invalid = inputEx.messages.invalidEmail; this.options.regexp = inputEx.regexps.email; // Validate the domain name ( false by default ) this.options.fixdomain = (YAHOO.lang.isUndefined(options.fixdomain) ? false : !!options.fixdomain); }
javascript
{ "resource": "" }
q29990
train
function() { var value; value = inputEx.EmailField.superclass.getValue.call(this); return inputEx.removeAccents(value.toLowerCase()); }
javascript
{ "resource": "" }
q29991
train
function(options) { inputEx.UrlField.superclass.setOptions.call(this, options); this.options.className = options.className ? options.className : "inputEx-Field inputEx-UrlField"; this.options.messages.invalid = inputEx.messages.invalidUrl; this.options.favicon = lang.isUndefined(options.favicon) ? (("https:" == document.location.protocol) ? false : true) : options.favicon; this.options.size = options.size || 50; // validate with url regexp this.options.regexp = inputEx.regexps.url; }
javascript
{ "resource": "" }
q29992
train
function() { inputEx.UrlField.superclass.render.call(this); this.el.size = this.options.size; if(!this.options.favicon) { YAHOO.util.Dom.addClass(this.el, 'nofavicon'); } // Create the favicon image tag if(this.options.favicon) { this.favicon = inputEx.cn('img', {src: inputEx.spacerUrl}); this.fieldContainer.insertBefore(this.favicon,this.fieldContainer.childNodes[0]); // focus field when clicking on favicon YAHOO.util.Event.addListener(this.favicon,"click",function(){this.focus();},this,true); } }
javascript
{ "resource": "" }
q29993
train
function(options) { inputEx.ListField.superclass.setOptions.call(this, options); this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ListField'; this.options.sortable = lang.isUndefined(options.sortable) ? false : options.sortable; this.options.elementType = options.elementType || {type: 'string'}; this.options.useButtons = lang.isUndefined(options.useButtons) ? false : options.useButtons; this.options.unique = lang.isUndefined(options.unique) ? false : options.unique; this.options.listAddLabel = options.listAddLabel || inputEx.messages.listAddLink; this.options.listRemoveLabel = options.listRemoveLabel || inputEx.messages.listRemoveLink; this.options.maxItems = options.maxItems; this.options.minItems = options.minItems; }
javascript
{ "resource": "" }
q29994
train
function() { // Add element button if(this.options.useButtons) { this.addButton = inputEx.cn('img', {src: inputEx.spacerUrl, className: 'inputEx-ListField-addButton'}); this.fieldContainer.appendChild(this.addButton); } // List label this.fieldContainer.appendChild( inputEx.cn('span', null, {marginLeft: "4px"}, this.options.listLabel) ); // Div element to contain the children this.childContainer = inputEx.cn('div', {className: 'inputEx-ListField-childContainer'}); this.fieldContainer.appendChild(this.childContainer); // Add link if(!this.options.useButtons) { this.addButton = inputEx.cn('a', {className: 'inputEx-List-link'}, null, this.options.listAddLabel); this.fieldContainer.appendChild(this.addButton); } }
javascript
{ "resource": "" }
q29995
train
function(value, sendUpdatedEvt) { if(!lang.isArray(value) ) { throw new Error("inputEx.ListField.setValue expected an array, got "+(typeof value)); } // Set the values (and add the lines if necessary) for(var i = 0 ; i < value.length ; i++) { if(i == this.subFields.length) { this.addElement(value[i]); } else { this.subFields[i].setValue(value[i], false); } } // Remove additional subFields var additionalElements = this.subFields.length-value.length; if(additionalElements > 0) { for(i = 0 ; i < additionalElements ; i++) { this.removeElement(value.length); } } inputEx.ListField.superclass.setValue.call(this, value, sendUpdatedEvt); }
javascript
{ "resource": "" }
q29996
train
function() { var values = []; for(var i = 0 ; i < this.subFields.length ; i++) { values[i] = this.subFields[i].getValue(); } return values; }
javascript
{ "resource": "" }
q29997
train
function(e) { Event.stopEvent(e); // Prevent adding a new field if already at maxItems if( lang.isNumber(this.options.maxItems) && this.subFields.length >= this.options.maxItems ) { return; } // Add a field with no value: var subFieldEl = this.addElement(); // Focus on this field subFieldEl.focus(); // Fire updated ! this.fireUpdatedEvt(); }
javascript
{ "resource": "" }
q29998
train
function(index) { var elementDiv = this.subFields[index].getEl().parentNode; this.subFields[index] = undefined; this.subFields = inputEx.compactArray(this.subFields); // Remove the element elementDiv.parentNode.removeChild(elementDiv); }
javascript
{ "resource": "" }
q29999
train
function(options) { inputEx.CheckBox.superclass.setOptions.call(this, options); // Overwrite options: this.options.className = options.className ? options.className : 'inputEx-Field inputEx-CheckBox'; this.options.rightLabel = options.rightLabel || ''; // Added options this.sentValues = options.sentValues || [true, false]; this.options.sentValues = this.sentValues; // for compatibility this.checkedValue = this.sentValues[0]; this.uncheckedValue = this.sentValues[1]; }
javascript
{ "resource": "" }