_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3 values | text stringlengths 52 373k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q30500 | train | function (obj) {
var attr, carousel = this,
styles = getCarouselItemPosition.call(carousel, obj.pos);
return createElement(carousel.get("carouselItemEl"), {
className : obj.className,
styles : obj.styles,
content : obj.content,
id : obj.id
});
} | javascript | {
"resource": ""
} | |
q30501 | train | function (index) {
var carousel = this,
isCircular = carousel.get("isCircular"),
numItems = carousel.get("numItems"),
numVisible = carousel.get("numVisible"),
sentinel = numItems - 1;
if (index < 0) {
index = isCircular ?
Math.ceil(numItems/numVisible)*numVisible + index : 0;
} else if (index > sentinel) {
index = isCircular ? 0 : sentinel;
}
return index;
} | javascript | {
"resource": ""
} | |
q30502 | train | function (val) {
var carousel = this,
isCircular = carousel.get("isCircular"),
numItems = carousel.get("numItems"),
sentinel = numItems - 1;
if (val < 0) {
if (isCircular) {
val = numItems + val;
} else {
val = carousel.get("selectedItem");
}
} else if (val > sentinel) {
if (isCircular) {
val = val - numItems;
} else {
val = carousel.get("selectedItem");
}
}
return val;
} | javascript | {
"resource": ""
} | |
q30503 | train | function (ev) {
var carousel = this,
carouselItem = carousel.get("carouselItemEl"),
container = carousel.get("element"),
el,
item,
target = Event.getTarget(ev),
tag = target.tagName.toUpperCase();
if(tag === "INPUT" ||
tag === "SELECT" ||
tag === "TEXTAREA") {
return;
}
while (target && target != container &&
target.id != carousel._carouselEl) {
el = target.nodeName;
if (el.toUpperCase() == carouselItem) {
break;
}
target = target.parentNode;
}
if ((item = carousel.getItemPositionById(target.id)) >= 0) {
YAHOO.log("Setting selection to " + item, WidgetName);
carousel.set("selectedItem", carousel._getSelectedItem(item));
carousel.focus();
}
} | javascript | {
"resource": ""
} | |
q30504 | train | function (ev) {
var carousel = this,
key = Event.getCharCode(ev),
target = Event.getTarget(ev),
prevent = false;
// do not mess while animation is in progress or naving via select
if (carousel.isAnimating() || target.tagName.toUpperCase() === "SELECT") {
return;
}
switch (key) {
case 0x25: // left arrow
case 0x26: // up arrow
carousel.selectPreviousItem();
prevent = true;
break;
case 0x27: // right arrow
case 0x28: // down arrow
carousel.selectNextItem();
prevent = true;
break;
case 0x21: // page-up
carousel.scrollPageBackward();
prevent = true;
break;
case 0x22: // page-down
carousel.scrollPageForward();
prevent = true;
break;
}
if (prevent) {
if (carousel.isAutoPlayOn()) {
carousel.stopAutoPlay();
}
Event.preventDefault(ev);
}
} | javascript | {
"resource": ""
} | |
q30505 | train | function(last) {
var carousel = this,
numItems = carousel.get("numItems"),
numVisible = carousel.get("numVisible"),
reveal = carousel.get("revealAmount"),
first = carousel._itemsTable.items.length,
lastVisible = carousel.get("lastVisible");
// adjust if going backwards
if(first > last && last+1 >= numVisible){
// need to get first a bit differently for the last page
first = last % numVisible || last == lastVisible ? last - last % numVisible : last - numVisible + 1;
}
if(reveal && last < numItems - 1){ last++; }
if (last >= first && (!carousel.getItem(first) || !carousel.getItem(last))) {
carousel.fireEvent(loadItemsEvent, {
ev: loadItemsEvent, first: first, last: last,
num: last - first + 1
});
}
} | javascript | {
"resource": ""
} | |
q30506 | train | function (ev) {
var carousel = this,
target = Event.getTarget(ev),
page = target.value,
item;
if (page) {
item = carousel.getFirstVisibleOnPage(page);
carousel._selectedItem = item;
carousel.scrollTo(item);
carousel.focus();
}
} | javascript | {
"resource": ""
} | |
q30507 | train | function (ev) {
var carousel = this,
css = carousel.CLASSES,
target = Event.getTarget(ev),
elNode = target.nodeName.toUpperCase(),
val,
stringIndex,
page,
item;
if (Dom.hasClass(target, css.PAGER_ITEM) || Dom.hasClass(target.parentNode, css.PAGER_ITEM)) {
if (elNode == "EM") {
target = target.parentNode;// item is an em and not an anchor (when text is visible)
}
val = target.href;
stringIndex = val.lastIndexOf("#");
page = parseInt(val.substring(stringIndex+1), 10);
if (page != -1) {
item = carousel.getFirstVisibleOnPage(page);
carousel._selectedItem = item;
carousel.scrollTo(item);
carousel.focus();
}
Event.preventDefault(ev);
}
} | javascript | {
"resource": ""
} | |
q30508 | train | function (parent) {
var carousel = this, child, cssClass, domEl, found, node;
cssClass = carousel.CLASSES;
domEl = carousel.get("carouselEl");
found = false;
for (child = parent.firstChild; child; child = child.nextSibling) {
if (child.nodeType == 1) {
node = child.nodeName;
if (node.toUpperCase() == domEl) {
carousel._carouselEl = child;
Dom.addClass(carousel._carouselEl,
carousel.CLASSES.CAROUSEL_EL);
YAHOO.log("Found Carousel - " + node +
(child.id ? " (#" + child.id + ")" : ""),
WidgetName);
found = true;
}
}
}
return found;
} | javascript | {
"resource": ""
} | |
q30509 | train | function () {
var carousel = this,
cssClass = carousel.CLASSES,
i=0,
rows,
child,
domItemEl,
elId,
node,
index = carousel.get("firstVisible"),
parent = carousel._carouselEl;
rows = carousel._rows;
domItemEl = carousel.get("carouselItemEl");
for (child = parent.firstChild; child; child = child.nextSibling) {
if (child.nodeType == 1) {
node = child.nodeName;
if (node.toUpperCase() == domItemEl) {
if (child.id) {
elId = child.id;
} else {
elId = Dom.generateId();
child.setAttribute("id", elId);
}
carousel.addItem(child,index);
index++;
}
}
}
} | javascript | {
"resource": ""
} | |
q30510 | train | function (parent) {
var carousel = this,
cfg,
cssClass = carousel.CLASSES,
el,
i,
j,
nav,
rv = false;
nav = Dom.getElementsByClassName(cssClass.PREV_PAGE, "*", parent);
if (nav.length > 0) {
for (i in nav) {
if (nav.hasOwnProperty(i)) {
el = nav[i];
YAHOO.log("Found Carousel previous page navigation - " +
el + (el.id ? " (#" + el.id + ")" : ""),
WidgetName);
if (el.nodeName == "INPUT" ||
el.nodeName == "BUTTON" ||
el.nodeName == "A") {// Anchor support in Nav (for SEO)
carousel._navBtns.prev.push(el);
} else {
j = el.getElementsByTagName("INPUT");
if (JS.isArray(j) && j.length > 0) {
carousel._navBtns.prev.push(j[0]);
} else {
j = el.getElementsByTagName("BUTTON");
if (JS.isArray(j) && j.length > 0) {
carousel._navBtns.prev.push(j[0]);
}
}
}
}
}
cfg = { prev: nav };
}
nav = Dom.getElementsByClassName(cssClass.NEXT_PAGE, "*", parent);
if (nav.length > 0) {
for (i in nav) {
if (nav.hasOwnProperty(i)) {
el = nav[i];
YAHOO.log("Found Carousel next page navigation - " +
el + (el.id ? " (#" + el.id + ")" : ""),
WidgetName);
if (el.nodeName == "INPUT" ||
el.nodeName == "BUTTON" ||
el.nodeName == "A") {// Anchor support in Nav (for SEO)
carousel._navBtns.next.push(el);
} else {
j = el.getElementsByTagName("INPUT");
if (JS.isArray(j) && j.length > 0) {
carousel._navBtns.next.push(j[0]);
} else {
j = el.getElementsByTagName("BUTTON");
if (JS.isArray(j) && j.length > 0) {
carousel._navBtns.next.push(j[0]);
}
}
}
}
}
if (cfg) {
cfg.next = nav;
} else {
cfg = { next: nav };
}
}
if (cfg) {
carousel.set("navigation", cfg);
rv = true;
}
return rv;
} | javascript | {
"resource": ""
} | |
q30511 | train | function () {
var carousel = this, i, isVertical = carousel.get("isVertical"), firstVisible = carousel.get("firstVisible"), item, n, rsz, sz;
if (carousel._itemsTable.numItems < 1) {
return;
}
sz = getCarouselItemSize.call(carousel,
isVertical ? "height" : "width");
// This fixes the widget to auto-adjust height/width for absolute
// positioned children.
item = carousel._itemsTable.items[firstVisible].id;
sz = isVertical ? getStyle(item, "width") :
getStyle(item, "height");
Dom.setStyle(carousel._carouselEl,
isVertical ? "width" : "height", sz + "px");
// Set the rendered state appropriately.
carousel._hasRendered = true;
carousel.fireEvent(renderEvent);
} | javascript | {
"resource": ""
} | |
q30512 | train | function (offset) {
var carousel = this, which;
which = carousel.get("isVertical") ? "top" : "left";
Dom.setStyle(carousel._carouselEl, which, offset + "px");
} | javascript | {
"resource": ""
} | |
q30513 | train | function (clip, attr) {
var carousel = this,
config = carousel.CONFIG,
cssClass = carousel.CLASSES,
isVertical,
rows,
cols,
size;
isVertical = carousel.get("isVertical");
rows = carousel._rows;
cols = carousel._cols;
clip = clip || carousel._clipEl;
attr = attr || (isVertical ? "height" : "width");
size = parseFloat(Dom.getStyle(clip, attr), 10);
size = JS.isNumber(size) ? size : 0;
if (isVertical) {
size += getDimensions(carousel._carouselEl, "height") +
getStyle(carousel._navEl, "height");
} else {
size += getDimensions(carousel._carouselEl, "width");
}
if (!isVertical) {
if (size < config.HORZ_MIN_WIDTH) {
size = config.HORZ_MIN_WIDTH;
carousel.addClass(cssClass.MIN_WIDTH);
}
}
carousel.setStyle(attr, size + "px");
// Additionally the width of the container should be set for
// the vertical Carousel
if (isVertical) {
size = getCarouselItemSize.call(carousel, "width");
if(cols) {
size = size * cols;
}
Dom.setStyle(carousel._carouselEl, "width", size + "px");// Bug fix for vertical carousel (goes in conjunction with .yui-carousel-element {... 3200px removed from styles), and allows for multirows in IEs).
if (size < config.VERT_MIN_WIDTH) {
size = config.VERT_MIN_WIDTH;
carousel.addClass(cssClass.MIN_WIDTH);// set a min width on vertical carousel, don't see why this shouldn't always be set...
}
carousel.setStyle("width", size + "px");
} else {
if(rows) {
size = getCarouselItemSize.call(carousel, "height");
size = size * rows;
Dom.setStyle(carousel._carouselEl, "height", size + "px");
}
}
} | javascript | {
"resource": ""
} | |
q30514 | train | function (val) {
var carousel = this;
if (val >= 0 && val < carousel.get("numItems")) {
carousel.scrollTo(val);
} else {
val = carousel.get("firstVisible");
}
return val;
} | javascript | {
"resource": ""
} | |
q30515 | train | function (cfg) {
var carousel = this;
if (cfg.prev) {
Event.on(cfg.prev, "click", scrollPageBackward, carousel);
}
if (cfg.next) {
Event.on(cfg.next, "click", scrollPageForward, carousel);
}
} | javascript | {
"resource": ""
} | |
q30516 | train | function (val) {
var carousel = this,
numVisible = val;
if(JS.isArray(val)) {
carousel._cols = val[0];
carousel._rows = val[1];
numVisible = val[0] * val[1];
}
return numVisible;
} | javascript | {
"resource": ""
} | |
q30517 | train | function (val) {
var carousel = this,
cssClass = carousel.CLASSES;
if (val) {
carousel.replaceClass(cssClass.HORIZONTAL, cssClass.VERTICAL);
} else {
carousel.replaceClass(cssClass.VERTICAL, cssClass.HORIZONTAL);
}
this._itemAttrCache = {}; // force recomputed next time
return val;
} | javascript | {
"resource": ""
} | |
q30518 | train | function (val) {
var carousel = this;
if (val >= 0 && val <= 100) {
val = parseInt(val, 10);
val = JS.isNumber(val) ? val : 0;
carousel._setClipContainerSize();
} else {
val = carousel.get("revealAmount");
}
return val;
} | javascript | {
"resource": ""
} | |
q30519 | train | function () {
var carousel = this;
return carousel.get("currentPage") + 1 == carousel.get("numPages") ?
carousel.get("numItems") - 1:
carousel.get("firstVisible") + carousel.get("numVisible") - 1;
} | javascript | {
"resource": ""
} | |
q30520 | train | function (obj) {
var attr,
carousel = this,
carouselEl = carousel._carouselEl,
el,
item,
itemsTable = carousel._itemsTable,
oel,
pos,
sibling,
styles;
pos = JS.isUndefined(obj.pos) ?
obj.newPos || itemsTable.numItems - 1 : obj.pos;
if (!oel) {
item = itemsTable.items[pos] || {};
el = carousel._createCarouselItem({
className : item.className,
styles : item.styles,
content : item.item,
id : item.id,
pos : pos
});
if (JS.isUndefined(obj.pos)) {
if (!JS.isUndefined(itemsTable.loading[pos])) {
oel = itemsTable.loading[pos];
// if oel is null, it is a problem ...
}
if (oel) {
// replace the node
carouselEl.replaceChild(el, oel);
// ... and remove the item from the data structure
delete itemsTable.loading[pos];
} else {
carouselEl.appendChild(el);
}
} else {
if (!JS.isUndefined(itemsTable.items[obj.pos + 1])) {
sibling = Dom.get(itemsTable.items[obj.pos + 1].id);
}
if (sibling) {
carouselEl.insertBefore(el, sibling);
} else {
YAHOO.log("Unable to find sibling","error",WidgetName);
}
}
} else {
if (JS.isUndefined(obj.pos)) {
if (!Dom.isAncestor(carousel._carouselEl, oel)) {
carouselEl.appendChild(oel);
}
} else {
if (!Dom.isAncestor(carouselEl, oel)) {
if (!JS.isUndefined(itemsTable.items[obj.pos + 1])) {
carouselEl.insertBefore(oel,
Dom.get(itemsTable.items[obj.pos + 1].id));
}
}
}
}
if (!carousel._hasRendered) {
carousel._refreshUi();
}
if (carousel.get("selectedItem") < 0) {
carousel.set("selectedItem", carousel.get("firstVisible"));
}
carousel._syncUiItems();
} | javascript | {
"resource": ""
} | |
q30521 | train | function (o) {
var carousel = this,
carouselEl = carousel._carouselEl,
itemsTable = carousel._itemsTable,
pos = o.pos,
item = o.newItem,
oel = o.oldItem,
el;
el = carousel._createCarouselItem({
className : item.className,
styles : item.styles,
content : item.item,
id : item.id,
pos : pos
});
if(el && oel) {
Event.purgeElement(oel, true);
carouselEl.replaceChild(el, Dom.get(oel.id));
if (!JS.isUndefined(itemsTable.loading[pos])) {
itemsTable.numItems++;
delete itemsTable.loading[pos];
}
}
// TODO: should we add the item if oel is undefined?
if (!carousel._hasRendered) {
carousel._refreshUi();
}
carousel._syncUiItems();
} | javascript | {
"resource": ""
} | |
q30522 | train | function (obj) {
var carousel = this,
carouselEl = carousel._carouselEl,
el, item, num, pos;
num = carousel.get("numItems");
item = obj.item;
pos = obj.pos;
if (item && (el = Dom.get(item.id))) {
if (el && Dom.isAncestor(carouselEl, el)) {
Event.purgeElement(el, true);
carouselEl.removeChild(el);
}
if (carousel.get("selectedItem") == pos) {
pos = pos >= num ? num - 1 : pos;
}
} else {
YAHOO.log("Unable to find item", "warn", WidgetName);
}
carousel._syncUiItems();
} | javascript | {
"resource": ""
} | |
q30523 | train | function (obj) {
var carousel = this,
carouselEl = carousel._carouselEl,
itemsTable = carousel._itemsTable,
len = itemsTable.items.length,
sibling = itemsTable.items[obj.last + 1],
el,
j;
// attempt to find the next closest sibling
if(!sibling && obj.last < len){
j = obj.first;
do {
sibling = itemsTable.items[j];
j++;
} while (j<len && !sibling);
}
for (var i = obj.first; i <= obj.last; i++) {
if(JS.isUndefined(itemsTable.loading[i]) && JS.isUndefined(itemsTable.items[i])){
el = carousel._createCarouselItem({
className : carousel.CLASSES.ITEM_LOADING,
content : carousel.STRINGS.ITEM_LOADING_CONTENT,
id : Dom.generateId(),
pos : i
});
if (el) {
if (sibling) {
sibling = Dom.get(sibling.id);
if (sibling) {
carouselEl.insertBefore(el, sibling);
} else {
YAHOO.log("Unable to find sibling", "error",
WidgetName);
}
} else {
carouselEl.appendChild(el);
}
}
itemsTable.loading[i] = el;
}
}
carousel._syncUiItems();
} | javascript | {
"resource": ""
} | |
q30524 | train | function () {
var attr,
carousel = this,
numItems = carousel.get("numItems"),
i,
itemsTable = carousel._itemsTable,
items = itemsTable.items,
loading = itemsTable.loading,
item,
styles;
for (i = 0; i < numItems; i++) {
item = items[i] || loading[i];
if (item && item.id) {
styles = getCarouselItemPosition.call(carousel, i);
item.styles = item.styles || {};
for (attr in styles) {
if (styles.hasOwnProperty(attr)) {
item.styles[attr] = styles[attr];
}
}
setStyles(Dom.get(item.id), styles);
}
}
} | javascript | {
"resource": ""
} | |
q30525 | train | function (el, setFocus) {
var children,
cssClass = this.CLASSES,
grandParent,
parent = el.parentNode;
if (!parent) {
return;
}
grandParent = parent.parentNode;
if (el.nodeName.toUpperCase() == "BUTTON" &&
Dom.hasClass(parent, cssClass.BUTTON)) {
if (setFocus) {
if (grandParent) {
children = Dom.getChildren(grandParent);
if (children) {
Dom.removeClass(children, cssClass.FOCUSSED_BUTTON);
}
}
Dom.addClass(parent, cssClass.FOCUSSED_BUTTON);
} else {
Dom.removeClass(parent, cssClass.FOCUSSED_BUTTON);
}
}
} | javascript | {
"resource": ""
} | |
q30526 | train | function () {
var carousel = this,
css = carousel.CLASSES,
cur = carousel._pages.cur, // current page
el,
html,
i,
item,
n = carousel.get("numVisible"),
num = carousel._pages.num, // total pages
pager = carousel._pages.el; // the pager container element
if (num === 0 || !pager) {
return; // don't do anything if number of pages is 0
}
// Hide the pager before redrawing it
Dom.setStyle(pager, "visibility", "hidden");
// Remove all nodes from the pager
while (pager.firstChild) {
pager.removeChild(pager.firstChild);
}
for (i = 0; i < num; i++) {
el = document.createElement("LI");
if (i === 0) {
Dom.addClass(el, css.FIRST_PAGE);
}
if (i == cur) {
Dom.addClass(el, css.SELECTED_NAV);
}
html = "<a class=" + css.PAGER_ITEM + " href=\"#" + (i+1) + "\" tabindex=\"0\"><em>" +
carousel.STRINGS.PAGER_PREFIX_TEXT + " " + (i+1) +
"</em></a>";
el.innerHTML = html;
pager.appendChild(el);
}
// Show the pager now
Dom.setStyle(pager, "visibility", "visible");
} | javascript | {
"resource": ""
} | |
q30527 | train | function () {
var carousel = this,
css = carousel.CLASSES,
cur = carousel._pages.cur, // current page
el,
i,
item,
n = carousel.get("numVisible"),
num = carousel._pages.num, // total pages
pager = carousel._pages.el, // the pager container element
sel;
if (num === 0) {
return;// don't do anything if number of pages is 0
}
sel = document.createElement("SELECT");
if (!sel) {
YAHOO.log("Unable to create the pager menu", "error",
WidgetName);
return;
}
// Hide the pager before redrawing it
Dom.setStyle(pager, "visibility", "hidden");
// Remove all nodes from the pager
while (pager.firstChild) {
pager.removeChild(pager.firstChild);
}
for (i = 0; i < num; i++) {
el = document.createElement("OPTION");
el.value = i+1;
el.innerHTML = carousel.STRINGS.PAGER_PREFIX_TEXT+" "+(i+1);
if (i == cur) {
el.setAttribute("selected", "selected");
}
sel.appendChild(el);
}
el = document.createElement("FORM");
if (!el) {
YAHOO.log("Unable to create the pager menu", "error",
WidgetName);
} else {
el.appendChild(sel);
pager.appendChild(el);
}
// Show the pager now
Event.addListener(sel, "change", carousel._pagerChangeHandler, this, true);
Dom.setStyle(pager, "visibility", "visible");
} | javascript | {
"resource": ""
} | |
q30528 | train | function (el) {
var carousel = this;
if (el) {
if (carousel._focusableItemEl) {
carousel._focusableItemEl.tabIndex = -1;
}
carousel._focusableItemEl = el;
el.tabIndex = 0;
}
} | javascript | {
"resource": ""
} | |
q30529 | train | function (cfg) {
var rv = true;
if (JS.isObject(cfg)) {
if (cfg.speed) {
rv = rv && JS.isNumber(cfg.speed);
}
if (cfg.effect) {
rv = rv && JS.isFunction(cfg.effect);
} else if (!JS.isUndefined(YAHOO.util.Easing)) {
cfg.effect = YAHOO.util.Easing.easeOut;
}
} else {
rv = false;
}
return rv;
} | javascript | {
"resource": ""
} | |
q30530 | train | function (val) {
var carousel = this, numItems = carousel.get("numItems");
if (JS.isNumber(val)) {
if (numItems === 0 && val == numItems) {
return true;
} else {
return (val >= 0 && val < numItems);
}
}
return false;
} | javascript | {
"resource": ""
} | |
q30531 | train | function (cfg) {
var i;
if (!JS.isObject(cfg)) {
return false;
}
if (cfg.prev) {
if (!JS.isArray(cfg.prev)) {
return false;
}
for (i in cfg.prev) {
if (cfg.prev.hasOwnProperty(i)) {
if (!JS.isString(cfg.prev[i].nodeName)) {
return false;
}
}
}
}
if (cfg.next) {
if (!JS.isArray(cfg.next)) {
return false;
}
for (i in cfg.next) {
if (cfg.next.hasOwnProperty(i)) {
if (!JS.isString(cfg.next[i].nodeName)) {
return false;
}
}
}
}
return true;
} | javascript | {
"resource": ""
} | |
q30532 | train | function (val) {
var rv = false;
if (JS.isNumber(val)) {
rv = val > 0 && val <= this.get("numItems");
} else if (JS.isArray(val)) {
if (JS.isNumber(val[0]) && JS.isNumber(val[1])) {
rv = val[0] * val[1] > 0 && val.length == 2;
}
}
return rv;
} | javascript | {
"resource": ""
} | |
q30533 | train | function (val) {
var rv = false;
if (JS.isNumber(val)) {
rv = val >= 0 && val < 100;
}
return rv;
} | javascript | {
"resource": ""
} | |
q30534 | train | function() {
var size = this.get(this.OPT.PICKER_SIZE),
h = this.get(this.OPT.HUE);
h = size - Math.round(h / 360 * size);
// 0 is at the top and bottom of the hue slider. Always go to
// the top so we don't end up sending the thumb to the bottom
// when the value didn't actually change (e.g., a conversion
// produced 360 instead of 0 and the value was already 0).
if (h === size) {
h = 0;
}
this.logger.log("Hue slider is being set to " + h);
this.hueSlider.setValue(h, this.skipAnim);
} | javascript | {
"resource": ""
} | |
q30535 | train | function() {
var size = this.get(this.OPT.PICKER_SIZE),
s = this.get(this.OPT.SATURATION),
v = this.get(this.OPT.VALUE);
s = Math.round(s * size / 100);
v = Math.round(size - (v * size / 100));
this.logger.log("Setting picker slider to " + [s, v]);
this.pickerSlider.setRegionValue(s, v, this.skipAnim);
} | javascript | {
"resource": ""
} | |
q30536 | train | function() {
this.logger.log("hsv " + [this._getH(),this._getS(),this._getV()]);
this.set(this.OPT.RGB, Color.hsv2rgb(this._getH(), this._getS(), this._getV()));
} | javascript | {
"resource": ""
} | |
q30537 | train | function(newOffset) {
this.logger.log("hue update: " + newOffset , "warn");
var h = this._getH(),
rgb = Color.hsv2rgb(h, 1, 1),
styleDef = "rgb(" + rgb.join(",") + ")";
this.set(this.OPT.HUE, h, true);
// set picker background to the hue
Dom.setStyle(this.getElement(this.ID.PICKER_BG), "background-color", styleDef);
if (this.hueSlider.valueChangeSource !== Slider.SOURCE_SET_VALUE) {
this._getValuesFromSliders();
}
this._updateFormFields();
this._updateSwatch();
} | javascript | {
"resource": ""
} | |
q30538 | train | function () {
// bind all of our elements
var o=this.OPT,
ids = this.get(o.IDS),
els = this.get(o.ELEMENTS),
i, el, id;
// Add the default value as a key for each element for easier lookup
for (i in this.ID) {
if (lang.hasOwnProperty(this.ID, i)) {
ids[this.ID[i]] = ids[i];
}
}
// Check for picker element, if not there, create all of them
el = Dom.get(ids[this.ID.PICKER_BG]);
if (!el) {
this._createElements();
} else {
this.logger.log("Using pre-existing markup");
}
for (i in ids) {
if (lang.hasOwnProperty(ids, i)) {
// look for element
el = Dom.get(ids[i]);
// generate an id if the implementer passed in an element reference,
// and the element did not have an id already
id = Dom.generateId(el);
// update the id in case we generated the id
ids[i] = id; // key is WEBSAFE_SWATCH
ids[ids[i]] = id; // key is websafe_swatch
// store the dom ref
els[id] = el;
}
}
} | javascript | {
"resource": ""
} | |
q30539 | train | function() {
var hsv = [this.get(this.OPT.HUE),
this.get(this.OPT.SATURATION)/100,
this.get(this.OPT.VALUE)/100],
rgb = Color.hsv2rgb(hsv);
this.logger.log("HSV converted to RGB " + hsv + " : " + rgb);
this.set(this.OPT.RGB, rgb);
this._updateSliders();
} | javascript | {
"resource": ""
} | |
q30540 | train | function(date, field, amount) {
var d = new Date(date.getTime());
switch (field) {
case this.MONTH:
var newMonth = date.getMonth() + amount;
var years = 0;
if (newMonth < 0) {
while (newMonth < 0) {
newMonth += 12;
years -= 1;
}
} else if (newMonth > 11) {
while (newMonth > 11) {
newMonth -= 12;
years += 1;
}
}
d.setMonth(newMonth);
d.setFullYear(date.getFullYear() + years);
break;
case this.DAY:
this._addDays(d, amount);
// d.setDate(date.getDate() + amount);
break;
case this.YEAR:
d.setFullYear(date.getFullYear() + amount);
break;
case this.WEEK:
this._addDays(d, (amount * 7));
// d.setDate(date.getDate() + (amount * 7));
break;
}
return d;
} | javascript | {
"resource": ""
} | |
q30541 | train | function(date, compareTo) {
var ms = compareTo.getTime();
if (date.getTime() < ms) {
return true;
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q30542 | train | function(date, dateBegin, dateEnd) {
if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
return true;
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q30543 | train | function(date, calendarYear) {
var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
// Find the number of days the passed in date is away from the calendar year start
var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
return dayOffset;
} | javascript | {
"resource": ""
} | |
q30544 | train | function(date, firstDayOfWeek, janDate) {
// Setup Defaults
firstDayOfWeek = firstDayOfWeek || 0;
janDate = janDate || this.WEEK_ONE_JAN_DATE;
var targetDate = this.clearTime(date),
startOfWeek,
endOfWeek;
if (targetDate.getDay() === firstDayOfWeek) {
startOfWeek = targetDate;
} else {
startOfWeek = this.getFirstDayOfWeek(targetDate, firstDayOfWeek);
}
var startYear = startOfWeek.getFullYear();
// DST shouldn't be a problem here, math is quicker than setDate();
endOfWeek = new Date(startOfWeek.getTime() + 6*this.ONE_DAY_MS);
var weekNum;
if (startYear !== endOfWeek.getFullYear() && endOfWeek.getDate() >= janDate) {
// If years don't match, endOfWeek is in Jan. and if the
// week has WEEK_ONE_JAN_DATE in it, it's week one by definition.
weekNum = 1;
} else {
// Get the 1st day of the 1st week, and
// find how many days away we are from it.
var weekOne = this.clearTime(this.getDate(startYear, 0, janDate)),
weekOneDayOne = this.getFirstDayOfWeek(weekOne, firstDayOfWeek);
// Round days to smoothen out 1 hr DST diff
var daysDiff = Math.round((targetDate.getTime() - weekOneDayOne.getTime())/this.ONE_DAY_MS);
// Calc. Full Weeks
var rem = daysDiff % 7;
var weeksDiff = (daysDiff - rem)/7;
weekNum = weeksDiff + 1;
}
return weekNum;
} | javascript | {
"resource": ""
} | |
q30545 | train | function (dt, startOfWeek) {
startOfWeek = startOfWeek || 0;
var dayOfWeekIndex = dt.getDay(),
dayOfWeek = (dayOfWeekIndex - startOfWeek + 7) % 7;
return this.subtract(dt, this.DAY, dayOfWeek);
} | javascript | {
"resource": ""
} | |
q30546 | train | function(weekBeginDate) {
var overlaps = false;
var nextWeek = this.add(weekBeginDate, this.DAY, 6);
if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
overlaps = true;
}
return overlaps;
} | javascript | {
"resource": ""
} | |
q30547 | train | function(weekBeginDate) {
var overlaps = false;
var nextWeek = this.add(weekBeginDate, this.DAY, 6);
if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
overlaps = true;
}
return overlaps;
} | javascript | {
"resource": ""
} | |
q30548 | train | function(date) {
var start = this.findMonthStart(date);
var nextMonth = this.add(start, this.MONTH, 1);
var end = this.subtract(nextMonth, this.DAY, 1);
return end;
} | javascript | {
"resource": ""
} | |
q30549 | train | function(type, args, obj) {
var useIframe = args[0];
if (!this.parent) {
if (Dom.inDocument(this.oDomContainer)) {
if (useIframe) {
var pos = Dom.getStyle(this.oDomContainer, "position");
if (pos == "absolute" || pos == "relative") {
if (!Dom.inDocument(this.iframe)) {
this.iframe = document.createElement("iframe");
this.iframe.src = "javascript:false;";
Dom.setStyle(this.iframe, "opacity", "0");
if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) {
Dom.addClass(this.iframe, this.Style.CSS_FIXED_SIZE);
}
this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild);
}
}
} else {
if (this.iframe) {
if (this.iframe.parentNode) {
this.iframe.parentNode.removeChild(this.iframe);
}
this.iframe = null;
}
}
}
}
} | javascript | {
"resource": ""
} | |
q30550 | train | function(type, args, obj) {
var title = args[0];
// "" disables title bar
if (title) {
this.createTitleBar(title);
} else {
var close = this.cfg.getProperty(DEF_CFG.CLOSE.key);
if (!close) {
this.removeTitleBar();
} else {
this.createTitleBar(" ");
}
}
} | javascript | {
"resource": ""
} | |
q30551 | train | function(type, args, obj) {
var close = args[0],
title = this.cfg.getProperty(DEF_CFG.TITLE.key);
if (close) {
if (!title) {
this.createTitleBar(" ");
}
this.createCloseButton();
} else {
this.removeCloseButton();
if (!title) {
this.removeTitleBar();
}
}
} | javascript | {
"resource": ""
} | |
q30552 | train | function() {
var defEvents = Calendar._EVENT_TYPES,
CE = YAHOO.util.CustomEvent,
cal = this; // To help with minification
/**
* Fired before a date selection is made
* @event beforeSelectEvent
*/
cal.beforeSelectEvent = new CE(defEvents.BEFORE_SELECT);
/**
* Fired when a date selection is made
* @event selectEvent
* @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
*/
cal.selectEvent = new CE(defEvents.SELECT);
/**
* Fired before a date or set of dates is deselected
* @event beforeDeselectEvent
*/
cal.beforeDeselectEvent = new CE(defEvents.BEFORE_DESELECT);
/**
* Fired when a date or set of dates is deselected
* @event deselectEvent
* @param {Array} Array of Date field arrays in the format [YYYY, MM, DD].
*/
cal.deselectEvent = new CE(defEvents.DESELECT);
/**
* Fired when the Calendar page is changed
* @event changePageEvent
* @param {Date} prevDate The date before the page was changed
* @param {Date} newDate The date after the page was changed
*/
cal.changePageEvent = new CE(defEvents.CHANGE_PAGE);
/**
* Fired before the Calendar is rendered
* @event beforeRenderEvent
*/
cal.beforeRenderEvent = new CE(defEvents.BEFORE_RENDER);
/**
* Fired when the Calendar is rendered
* @event renderEvent
*/
cal.renderEvent = new CE(defEvents.RENDER);
/**
* Fired just before the Calendar is to be destroyed
* @event beforeDestroyEvent
*/
cal.beforeDestroyEvent = new CE(defEvents.BEFORE_DESTROY);
/**
* Fired after the Calendar is destroyed. This event should be used
* for notification only. When this event is fired, important Calendar instance
* properties, dom references and event listeners have already been
* removed/dereferenced, and hence the Calendar instance is not in a usable
* state.
*
* @event destroyEvent
*/
cal.destroyEvent = new CE(defEvents.DESTROY);
/**
* Fired when the Calendar is reset
* @event resetEvent
*/
cal.resetEvent = new CE(defEvents.RESET);
/**
* Fired when the Calendar is cleared
* @event clearEvent
*/
cal.clearEvent = new CE(defEvents.CLEAR);
/**
* Fired just before the Calendar is to be shown
* @event beforeShowEvent
*/
cal.beforeShowEvent = new CE(defEvents.BEFORE_SHOW);
/**
* Fired after the Calendar is shown
* @event showEvent
*/
cal.showEvent = new CE(defEvents.SHOW);
/**
* Fired just before the Calendar is to be hidden
* @event beforeHideEvent
*/
cal.beforeHideEvent = new CE(defEvents.BEFORE_HIDE);
/**
* Fired after the Calendar is hidden
* @event hideEvent
*/
cal.hideEvent = new CE(defEvents.HIDE);
/**
* Fired just before the CalendarNavigator is to be shown
* @event beforeShowNavEvent
*/
cal.beforeShowNavEvent = new CE(defEvents.BEFORE_SHOW_NAV);
/**
* Fired after the CalendarNavigator is shown
* @event showNavEvent
*/
cal.showNavEvent = new CE(defEvents.SHOW_NAV);
/**
* Fired just before the CalendarNavigator is to be hidden
* @event beforeHideNavEvent
*/
cal.beforeHideNavEvent = new CE(defEvents.BEFORE_HIDE_NAV);
/**
* Fired after the CalendarNavigator is hidden
* @event hideNavEvent
*/
cal.hideNavEvent = new CE(defEvents.HIDE_NAV);
/**
* Fired just before the CalendarNavigator is to be rendered
* @event beforeRenderNavEvent
*/
cal.beforeRenderNavEvent = new CE(defEvents.BEFORE_RENDER_NAV);
/**
* Fired after the CalendarNavigator is rendered
* @event renderNavEvent
*/
cal.renderNavEvent = new CE(defEvents.RENDER_NAV);
cal.beforeSelectEvent.subscribe(cal.onBeforeSelect, this, true);
cal.selectEvent.subscribe(cal.onSelect, this, true);
cal.beforeDeselectEvent.subscribe(cal.onBeforeDeselect, this, true);
cal.deselectEvent.subscribe(cal.onDeselect, this, true);
cal.changePageEvent.subscribe(cal.onChangePage, this, true);
cal.renderEvent.subscribe(cal.onRender, this, true);
cal.resetEvent.subscribe(cal.onReset, this, true);
cal.clearEvent.subscribe(cal.onClear, this, true);
} | javascript | {
"resource": ""
} | |
q30553 | train | function(e, cal) {
Event.preventDefault(e);
// previousMonth invoked in a timeout, to allow
// event to bubble up, with correct target. Calling
// previousMonth, will call render which will remove
// HTML which generated the event, resulting in an
// invalid event target in certain browsers.
setTimeout(function() {
cal.previousMonth();
var navs = Dom.getElementsByClassName(cal.Style.CSS_NAV_LEFT, "a", cal.oDomContainer);
if (navs && navs[0]) {
try {
navs[0].focus();
} catch (ex) {
// ignore
}
}
}, 0);
} | javascript | {
"resource": ""
} | |
q30554 | train | function(e, cal) {
Event.preventDefault(e);
setTimeout(function() {
cal.nextMonth();
var navs = Dom.getElementsByClassName(cal.Style.CSS_NAV_RIGHT, "a", cal.oDomContainer);
if (navs && navs[0]) {
try {
navs[0].focus();
} catch (ex) {
// ignore
}
}
}, 0);
} | javascript | {
"resource": ""
} | |
q30555 | train | function(e, cal) {
var target;
if (e) {
target = Event.getTarget(e);
} else {
target = this;
}
while (target.tagName && target.tagName.toLowerCase() != "td") {
target = target.parentNode;
if (!target.tagName || target.tagName.toLowerCase() == "html") {
return;
}
}
if (Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) {
Dom.addClass(target, cal.Style.CSS_CELL_HOVER);
}
} | javascript | {
"resource": ""
} | |
q30556 | train | function() {
cfg.refireEvent(DEF_CFG.LOCALE_MONTHS.key);
cfg.refireEvent(DEF_CFG.LOCALE_WEEKDAYS.key);
} | javascript | {
"resource": ""
} | |
q30557 | train | function(type, args, obj) {
this.cfg.setProperty(DEF_CFG.PAGEDATE.key, this._parsePageDate(args[0]), true);
} | javascript | {
"resource": ""
} | |
q30558 | train | function(type, args, obj) {
var val = args[0];
if (Lang.isString(val)) {
val = this._parseDate(val);
this.cfg.setProperty(DEF_CFG.MINDATE.key, DateMath.getDate(val[0],(val[1]-1),val[2]));
}
} | javascript | {
"resource": ""
} | |
q30559 | train | function(type, args, obj) {
// Only do this for initial set. Changing the today property after the initial
// set, doesn't affect pagedate
var val = args[0];
if (Lang.isString(val)) {
val = this._parseDate(val);
}
var today = DateMath.clearTime(val);
if (!this.cfg.initialConfig[DEF_CFG.PAGEDATE.key]) {
this.cfg.setProperty(DEF_CFG.PAGEDATE.key, today);
}
this.today = today;
this.cfg.setProperty(DEF_CFG.TODAY.key, today, true);
} | javascript | {
"resource": ""
} | |
q30560 | train | function(type, args, obj) {
var selected = args[0],
cfgSelected = DEF_CFG.SELECTED.key;
if (selected) {
if (Lang.isString(selected)) {
this.cfg.setProperty(cfgSelected, this._parseDates(selected), true);
}
}
if (! this._selectedDates) {
this._selectedDates = this.cfg.getProperty(cfgSelected);
}
} | javascript | {
"resource": ""
} | |
q30561 | train | function(type, args, obj) {
this.Locale[type.toUpperCase()] = args[0];
this.cfg.refireEvent(DEF_CFG.LOCALE_MONTHS.key);
this.cfg.refireEvent(DEF_CFG.LOCALE_WEEKDAYS.key);
} | javascript | {
"resource": ""
} | |
q30562 | train | function(type, args, obj) {
type = type.toLowerCase();
var val = args[0],
cfg = this.cfg,
Locale = this.Locale;
switch (type) {
case DEF_CFG.LOCALE_MONTHS.key:
switch (val) {
case Calendar.SHORT:
Locale.LOCALE_MONTHS = cfg.getProperty(DEF_CFG.MONTHS_SHORT.key).concat();
break;
case Calendar.LONG:
Locale.LOCALE_MONTHS = cfg.getProperty(DEF_CFG.MONTHS_LONG.key).concat();
break;
}
break;
case DEF_CFG.LOCALE_WEEKDAYS.key:
switch (val) {
case Calendar.ONE_CHAR:
Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_1CHAR.key).concat();
break;
case Calendar.SHORT:
Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_SHORT.key).concat();
break;
case Calendar.MEDIUM:
Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_MEDIUM.key).concat();
break;
case Calendar.LONG:
Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_LONG.key).concat();
break;
}
var START_WEEKDAY = cfg.getProperty(DEF_CFG.START_WEEKDAY.key);
if (START_WEEKDAY > 0) {
for (var w=0; w < START_WEEKDAY; ++w) {
Locale.LOCALE_WEEKDAYS.push(Locale.LOCALE_WEEKDAYS.shift());
}
}
break;
}
} | javascript | {
"resource": ""
} | |
q30563 | train | function(type, args, obj) {
var val = args[0];
if (YAHOO.widget.CalendarNavigator && (val === true || Lang.isObject(val))) {
if (!this.oNavigator) {
this.oNavigator = new YAHOO.widget.CalendarNavigator(this);
// Cleanup DOM Refs/Events before innerHTML is removed.
this.beforeRenderEvent.subscribe(function () {
if (!this.pages) {
this.oNavigator.erase();
}
}, this, true);
}
} else {
if (this.oNavigator) {
this.oNavigator.destroy();
this.oNavigator = null;
}
}
} | javascript | {
"resource": ""
} | |
q30564 | train | function() {
var defStyle = Calendar.STYLES;
this.Style = {
/**
* @property Style.CSS_ROW_HEADER
*/
CSS_ROW_HEADER: defStyle.CSS_ROW_HEADER,
/**
* @property Style.CSS_ROW_FOOTER
*/
CSS_ROW_FOOTER: defStyle.CSS_ROW_FOOTER,
/**
* @property Style.CSS_CELL
*/
CSS_CELL : defStyle.CSS_CELL,
/**
* @property Style.CSS_CELL_SELECTOR
*/
CSS_CELL_SELECTOR : defStyle.CSS_CELL_SELECTOR,
/**
* @property Style.CSS_CELL_SELECTED
*/
CSS_CELL_SELECTED : defStyle.CSS_CELL_SELECTED,
/**
* @property Style.CSS_CELL_SELECTABLE
*/
CSS_CELL_SELECTABLE : defStyle.CSS_CELL_SELECTABLE,
/**
* @property Style.CSS_CELL_RESTRICTED
*/
CSS_CELL_RESTRICTED : defStyle.CSS_CELL_RESTRICTED,
/**
* @property Style.CSS_CELL_TODAY
*/
CSS_CELL_TODAY : defStyle.CSS_CELL_TODAY,
/**
* @property Style.CSS_CELL_OOM
*/
CSS_CELL_OOM : defStyle.CSS_CELL_OOM,
/**
* @property Style.CSS_CELL_OOB
*/
CSS_CELL_OOB : defStyle.CSS_CELL_OOB,
/**
* @property Style.CSS_HEADER
*/
CSS_HEADER : defStyle.CSS_HEADER,
/**
* @property Style.CSS_HEADER_TEXT
*/
CSS_HEADER_TEXT : defStyle.CSS_HEADER_TEXT,
/**
* @property Style.CSS_BODY
*/
CSS_BODY : defStyle.CSS_BODY,
/**
* @property Style.CSS_WEEKDAY_CELL
*/
CSS_WEEKDAY_CELL : defStyle.CSS_WEEKDAY_CELL,
/**
* @property Style.CSS_WEEKDAY_ROW
*/
CSS_WEEKDAY_ROW : defStyle.CSS_WEEKDAY_ROW,
/**
* @property Style.CSS_FOOTER
*/
CSS_FOOTER : defStyle.CSS_FOOTER,
/**
* @property Style.CSS_CALENDAR
*/
CSS_CALENDAR : defStyle.CSS_CALENDAR,
/**
* @property Style.CSS_SINGLE
*/
CSS_SINGLE : defStyle.CSS_SINGLE,
/**
* @property Style.CSS_CONTAINER
*/
CSS_CONTAINER : defStyle.CSS_CONTAINER,
/**
* @property Style.CSS_NAV_LEFT
*/
CSS_NAV_LEFT : defStyle.CSS_NAV_LEFT,
/**
* @property Style.CSS_NAV_RIGHT
*/
CSS_NAV_RIGHT : defStyle.CSS_NAV_RIGHT,
/**
* @property Style.CSS_NAV
*/
CSS_NAV : defStyle.CSS_NAV,
/**
* @property Style.CSS_CLOSE
*/
CSS_CLOSE : defStyle.CSS_CLOSE,
/**
* @property Style.CSS_CELL_TOP
*/
CSS_CELL_TOP : defStyle.CSS_CELL_TOP,
/**
* @property Style.CSS_CELL_LEFT
*/
CSS_CELL_LEFT : defStyle.CSS_CELL_LEFT,
/**
* @property Style.CSS_CELL_RIGHT
*/
CSS_CELL_RIGHT : defStyle.CSS_CELL_RIGHT,
/**
* @property Style.CSS_CELL_BOTTOM
*/
CSS_CELL_BOTTOM : defStyle.CSS_CELL_BOTTOM,
/**
* @property Style.CSS_CELL_HOVER
*/
CSS_CELL_HOVER : defStyle.CSS_CELL_HOVER,
/**
* @property Style.CSS_CELL_HIGHLIGHT1
*/
CSS_CELL_HIGHLIGHT1 : defStyle.CSS_CELL_HIGHLIGHT1,
/**
* @property Style.CSS_CELL_HIGHLIGHT2
*/
CSS_CELL_HIGHLIGHT2 : defStyle.CSS_CELL_HIGHLIGHT2,
/**
* @property Style.CSS_CELL_HIGHLIGHT3
*/
CSS_CELL_HIGHLIGHT3 : defStyle.CSS_CELL_HIGHLIGHT3,
/**
* @property Style.CSS_CELL_HIGHLIGHT4
*/
CSS_CELL_HIGHLIGHT4 : defStyle.CSS_CELL_HIGHLIGHT4,
/**
* @property Style.CSS_WITH_TITLE
*/
CSS_WITH_TITLE : defStyle.CSS_WITH_TITLE,
/**
* @property Style.CSS_FIXED_SIZE
*/
CSS_FIXED_SIZE : defStyle.CSS_FIXED_SIZE,
/**
* @property Style.CSS_LINK_CLOSE
*/
CSS_LINK_CLOSE : defStyle.CSS_LINK_CLOSE
};
} | javascript | {
"resource": ""
} | |
q30565 | train | function(date) {
var monthLabel = this.Locale.LOCALE_MONTHS[date.getMonth()] + this.Locale.MY_LABEL_MONTH_SUFFIX,
yearLabel = (date.getFullYear() + this.Locale.YEAR_OFFSET) + this.Locale.MY_LABEL_YEAR_SUFFIX;
if (this.Locale.MY_LABEL_MONTH_POSITION == 2 || this.Locale.MY_LABEL_YEAR_POSITION == 1) {
return yearLabel + monthLabel;
} else {
return monthLabel + yearLabel;
}
} | javascript | {
"resource": ""
} | |
q30566 | train | function(strTitle) {
var tDiv = Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div");
tDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE;
tDiv.innerHTML = strTitle;
this.oDomContainer.insertBefore(tDiv, this.oDomContainer.firstChild);
Dom.addClass(this.oDomContainer, this.Style.CSS_WITH_TITLE);
return tDiv;
} | javascript | {
"resource": ""
} | |
q30567 | train | function() {
var tDiv = Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null;
if (tDiv) {
Event.purgeElement(tDiv);
this.oDomContainer.removeChild(tDiv);
}
Dom.removeClass(this.oDomContainer, this.Style.CSS_WITH_TITLE);
} | javascript | {
"resource": ""
} | |
q30568 | train | function() {
var cssClose = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE,
cssLinkClose = this.Style.CSS_LINK_CLOSE,
DEPR_CLOSE_PATH = "us/my/bn/x_d.gif",
lnk = Dom.getElementsByClassName(cssLinkClose, "a", this.oDomContainer)[0],
strings = this.cfg.getProperty(DEF_CFG.STRINGS.key),
closeStr = (strings && strings.close) ? strings.close : "";
if (!lnk) {
lnk = document.createElement("a");
Event.addListener(lnk, "click", function(e, cal) {
cal.hide();
Event.preventDefault(e);
}, this);
}
lnk.href = "#";
lnk.className = cssLinkClose;
if (Calendar.IMG_ROOT !== null) {
var img = Dom.getElementsByClassName(cssClose, "img", lnk)[0] || document.createElement("img");
img.src = Calendar.IMG_ROOT + DEPR_CLOSE_PATH;
img.className = cssClose;
lnk.appendChild(img);
} else {
lnk.innerHTML = '<span class="' + cssClose + ' ' + this.Style.CSS_CLOSE + '">' + closeStr + '</span>';
}
this.oDomContainer.appendChild(lnk);
return lnk;
} | javascript | {
"resource": ""
} | |
q30569 | train | function() {
var btn = Dom.getElementsByClassName(this.Style.CSS_LINK_CLOSE, "a", this.oDomContainer)[0] || null;
if (btn) {
Event.purgeElement(btn);
this.oDomContainer.removeChild(btn);
}
} | javascript | {
"resource": ""
} | |
q30570 | train | function(html) {
html[html.length] = '<tr class="' + this.Style.CSS_WEEKDAY_ROW + '">';
if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key)) {
html[html.length] = '<th> </th>';
}
for(var i=0;i < this.Locale.LOCALE_WEEKDAYS.length; ++i) {
html[html.length] = '<th class="' + this.Style.CSS_WEEKDAY_CELL + '">' + this.Locale.LOCALE_WEEKDAYS[i] + '</th>';
}
if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key)) {
html[html.length] = '<th> </th>';
}
html[html.length] = '</tr>';
return html;
} | javascript | {
"resource": ""
} | |
q30571 | train | function() {
var root = this.oDomContainer,
cal = this.parent || this,
anchor = "a",
click = "click";
var linkLeft = Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, anchor, root),
linkRight = Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, anchor, root);
if (linkLeft && linkLeft.length > 0) {
this.linkLeft = linkLeft[0];
Event.addListener(this.linkLeft, click, this.doPreviousMonthNav, cal, true);
}
if (linkRight && linkRight.length > 0) {
this.linkRight = linkRight[0];
Event.addListener(this.linkRight, click, this.doNextMonthNav, cal, true);
}
if (cal.cfg.getProperty("navigator") !== null) {
this.applyNavListeners();
}
if (this.domEventMap) {
var el,elements;
for (var cls in this.domEventMap) {
if (Lang.hasOwnProperty(this.domEventMap, cls)) {
var items = this.domEventMap[cls];
if (! (items instanceof Array)) {
items = [items];
}
for (var i=0;i<items.length;i++) {
var item = items[i];
elements = Dom.getElementsByClassName(cls, item.tag, this.oDomContainer);
for (var c=0;c<elements.length;c++) {
el = elements[c];
Event.addListener(el, item.event, item.handler, item.scope, item.correct );
}
}
}
}
}
Event.addListener(this.oDomContainer, "click", this.doSelectCell, this);
Event.addListener(this.oDomContainer, "mouseover", this.doCellMouseOver, this);
Event.addListener(this.oDomContainer, "mouseout", this.doCellMouseOut, this);
} | javascript | {
"resource": ""
} | |
q30572 | train | function(id) {
var date = this.getDateFieldsByCellId(id);
return (date) ? DateMath.getDate(date[0],date[1]-1,date[2]) : null;
} | javascript | {
"resource": ""
} | |
q30573 | train | function(strId) {
var idx = -1,
li = strId.lastIndexOf("_cell");
if (li > -1) {
idx = parseInt(strId.substring(li + 5), 10);
}
return idx;
} | javascript | {
"resource": ""
} | |
q30574 | train | function(workingDate, cell) {
Dom.addClass(cell, this.Style.CSS_CELL_OOB);
cell.innerHTML = workingDate.getDate();
return Calendar.STOP_RENDER;
} | javascript | {
"resource": ""
} | |
q30575 | train | function(workingDate, cell) {
Dom.addClass(cell, this.Style.CSS_CELL);
Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED);
cell.innerHTML=workingDate.getDate();
return Calendar.STOP_RENDER;
} | javascript | {
"resource": ""
} | |
q30576 | train | function(count) {
var cfgPageDate = DEF_CFG.PAGEDATE.key,
prevDate = this.cfg.getProperty(cfgPageDate),
newDate = DateMath.add(prevDate, DateMath.YEAR, count);
this.cfg.setProperty(cfgPageDate, newDate);
this.resetRenderers();
this.changePageEvent.fire(prevDate, newDate);
} | javascript | {
"resource": ""
} | |
q30577 | train | function(array1, array2) {
var match = false;
if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) {
match=true;
}
return match;
} | javascript | {
"resource": ""
} | |
q30578 | train | function(sDate) {
var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER),
rArray;
if (aDate.length == 2) {
rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];
rArray.type = Calendar.MONTH_DAY;
} else {
rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1] - this.Locale.YEAR_OFFSET, aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];
rArray.type = Calendar.DATE;
}
for (var i=0;i<rArray.length;i++) {
rArray[i] = parseInt(rArray[i], 10);
}
return rArray;
} | javascript | {
"resource": ""
} | |
q30579 | train | function(sDates) {
var aReturn = [],
aDates = sDates.split(this.Locale.DATE_DELIMITER);
for (var d=0;d<aDates.length;++d) {
var sDate = aDates[d];
if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) {
// This is a range
var aRange = sDate.split(this.Locale.DATE_RANGE_DELIMITER),
dateStart = this._parseDate(aRange[0]),
dateEnd = this._parseDate(aRange[1]),
fullRange = this._parseRange(dateStart, dateEnd);
aReturn = aReturn.concat(fullRange);
} else {
// This is not a range
var aDate = this._parseDate(sDate);
aReturn.push(aDate);
}
}
return aReturn;
} | javascript | {
"resource": ""
} | |
q30580 | train | function(startDate, endDate) {
var dCurrent = DateMath.add(DateMath.getDate(startDate[0],startDate[1]-1,startDate[2]),DateMath.DAY,1),
dEnd = DateMath.getDate(endDate[0], endDate[1]-1, endDate[2]),
results = [];
results.push(startDate);
while (dCurrent.getTime() <= dEnd.getTime()) {
results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);
dCurrent = DateMath.add(dCurrent,DateMath.DAY,1);
}
return results;
} | javascript | {
"resource": ""
} | |
q30581 | train | function(type, aDates, fnRender) {
var add = [type,aDates,fnRender];
this.renderStack.unshift(add);
this._renderStack = this.renderStack.concat();
} | javascript | {
"resource": ""
} | |
q30582 | train | function(style) {
for (var c=0;c<this.cells.length;++c) {
Dom.removeClass(this.cells[c],style);
}
} | javascript | {
"resource": ""
} | |
q30583 | train | function(year) {
var cfgPageDate = DEF_CFG.PAGEDATE.key,
current = this.cfg.getProperty(cfgPageDate);
current.setFullYear(parseInt(year, 10) - this.Locale.YEAR_OFFSET);
this.cfg.setProperty(cfgPageDate, current);
} | javascript | {
"resource": ""
} | |
q30584 | train | function() {
var returnDates = [],
selected = this.cfg.getProperty(DEF_CFG.SELECTED.key);
for (var d=0;d<selected.length;++d) {
var dateArray = selected[d];
var date = DateMath.getDate(dateArray[0],dateArray[1]-1,dateArray[2]);
returnDates.push(date);
}
returnDates.sort( function(a,b) { return a-b; } );
return returnDates;
} | javascript | {
"resource": ""
} | |
q30585 | train | function() {
if (this.beforeDestroyEvent.fire()) {
var cal = this;
// Child objects
if (cal.navigator) {
cal.navigator.destroy();
}
if (cal.cfg) {
cal.cfg.destroy();
}
// DOM event listeners
Event.purgeElement(cal.oDomContainer, true);
// Generated markup/DOM - Not removing the container DIV since we didn't create it.
Dom.removeClass(cal.oDomContainer, cal.Style.CSS_WITH_TITLE);
Dom.removeClass(cal.oDomContainer, cal.Style.CSS_CONTAINER);
Dom.removeClass(cal.oDomContainer, cal.Style.CSS_SINGLE);
cal.oDomContainer.innerHTML = "";
// JS-to-DOM references
cal.oDomContainer = null;
cal.cells = null;
this.destroyEvent.fire();
}
} | javascript | {
"resource": ""
} | |
q30586 | train | function(fn, obj, bOverride) {
for (var p=0;p<me.pages.length;++p) {
var cal = me.pages[p];
cal[this.type + strEvent].subscribe(fn, obj, bOverride);
}
} | javascript | {
"resource": ""
} | |
q30587 | train | function(fn, obj) {
for (var p=0;p<me.pages.length;++p) {
var cal = me.pages[p];
cal[this.type + strEvent].unsubscribe(fn, obj);
}
} | javascript | {
"resource": ""
} | |
q30588 | train | function(type, args, obj) {
var pageCount = args[0],
cfgPageDate = DEF_CFG.PAGEDATE.key,
sep = "_",
caldate,
firstPageDate = null,
groupCalClass = "groupcal",
firstClass = "first-of-type",
lastClass = "last-of-type";
for (var p=0;p<pageCount;++p) {
var calId = this.id + sep + p,
calContainerId = this.containerId + sep + p,
childConfig = this.cfg.getConfig();
childConfig.close = false;
childConfig.title = false;
childConfig.navigator = null;
if (p > 0) {
caldate = new Date(firstPageDate);
this._setMonthOnDate(caldate, caldate.getMonth() + p);
childConfig.pageDate = caldate;
}
var cal = this.constructChild(calId, calContainerId, childConfig);
Dom.removeClass(cal.oDomContainer, this.Style.CSS_SINGLE);
Dom.addClass(cal.oDomContainer, groupCalClass);
if (p===0) {
firstPageDate = cal.cfg.getProperty(cfgPageDate);
Dom.addClass(cal.oDomContainer, firstClass);
}
if (p==(pageCount-1)) {
Dom.addClass(cal.oDomContainer, lastClass);
}
cal.parent = this;
cal.index = p;
this.pages[this.pages.length] = cal;
}
} | javascript | {
"resource": ""
} | |
q30589 | train | function(type, args, obj) {
var val = args[0],
firstPageDate;
var cfgPageDate = DEF_CFG.PAGEDATE.key;
for (var p=0;p<this.pages.length;++p) {
var cal = this.pages[p];
if (p === 0) {
firstPageDate = cal._parsePageDate(val);
cal.cfg.setProperty(cfgPageDate, firstPageDate);
} else {
var pageDate = new Date(firstPageDate);
this._setMonthOnDate(pageDate, pageDate.getMonth() + p);
cal.cfg.setProperty(cfgPageDate, pageDate);
}
}
} | javascript | {
"resource": ""
} | |
q30590 | train | function(type, args, obj) {
var cfgSelected = DEF_CFG.SELECTED.key;
this.delegateConfig(type, args, obj);
var selected = (this.pages.length > 0) ? this.pages[0].cfg.getProperty(cfgSelected) : [];
this.cfg.setProperty(cfgSelected, selected, true);
} | javascript | {
"resource": ""
} | |
q30591 | train | function(type, args, obj) {
var val = args[0];
var cal;
for (var p=0;p<this.pages.length;p++) {
cal = this.pages[p];
cal.cfg.setProperty(type, val);
}
} | javascript | {
"resource": ""
} | |
q30592 | train | function(fnName, fn) {
var pageCount = this.cfg.getProperty(DEF_CFG.PAGES.key);
for (var p=0;p<pageCount;++p) {
this.pages[p][fnName] = fn;
}
} | javascript | {
"resource": ""
} | |
q30593 | train | function(fnName, args) {
var pageCount = this.cfg.getProperty(DEF_CFG.PAGES.key);
for (var p=0;p<pageCount;++p) {
var page = this.pages[p];
if (page[fnName]) {
var fn = page[fnName];
fn.call(page, args);
}
}
} | javascript | {
"resource": ""
} | |
q30594 | train | function(id,containerId,config) {
var container = document.getElementById(containerId);
if (! container) {
container = document.createElement("div");
container.id = containerId;
this.oDomContainer.appendChild(container);
}
return new Calendar(id,containerId,config);
} | javascript | {
"resource": ""
} | |
q30595 | train | function(month) {
month = parseInt(month, 10);
var currYear;
var cfgPageDate = DEF_CFG.PAGEDATE.key;
for (var p=0; p<this.pages.length; ++p) {
var cal = this.pages[p];
var pageDate = cal.cfg.getProperty(cfgPageDate);
if (p === 0) {
currYear = pageDate.getFullYear();
} else {
pageDate.setFullYear(currYear);
}
this._setMonthOnDate(pageDate, month+p);
cal.cfg.setProperty(cfgPageDate, pageDate);
}
} | javascript | {
"resource": ""
} | |
q30596 | train | function(year) {
var cfgPageDate = DEF_CFG.PAGEDATE.key;
year = parseInt(year, 10);
for (var p=0;p<this.pages.length;++p) {
var cal = this.pages[p];
var pageDate = cal.cfg.getProperty(cfgPageDate);
if ((pageDate.getMonth()+1) == 1 && p>0) {
year+=1;
}
cal.setYear(year);
}
} | javascript | {
"resource": ""
} | |
q30597 | train | function() {
this.renderHeader();
for (var p=0;p<this.pages.length;++p) {
var cal = this.pages[p];
cal.render();
}
this.renderFooter();
} | javascript | {
"resource": ""
} | |
q30598 | train | function(cellIndex) {
for (var p=0;p<this.pages.length;++p) {
var cal = this.pages[p];
cal.deselectCell(cellIndex);
}
return this.getSelectedDates();
} | javascript | {
"resource": ""
} | |
q30599 | train | function() {
for (var p=0;p<this.pages.length;++p) {
var cal = this.pages[p];
cal.clear();
}
this.cfg.setProperty(DEF_CFG.SELECTED.key, []);
this.cfg.setProperty(DEF_CFG.PAGEDATE.key, new Date(this.pages[0].today.getTime()));
this.render();
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.