code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function consume(e)
{
e.consume(true);
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | consume | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
function move(e)
{
if (dragging) {
var dragX = Math.max(0, Math.min(e.pageX - offset.left + scrollOffset.left, maxWidth));
var dragY = Math.max(0, Math.min(e.pageY - offset.top + scrollOffset.top, maxHeight));
if (onmove)
onmove(element, dragX, dragY);
}
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | move | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
function start(e)
{
var rightClick = e.which ? (e.which === 3) : (e.button === 2);
if (!rightClick && !dragging) {
if (onstart)
onstart(element, e)
dragging = true;
maxHeight = element.clientHeight;
maxWidth = element.clientWidth;
scrollOffset = element.scrollOffset();
offset = element.totalOffset();
doc.addEventListener("selectstart", consume, false);
doc.addEventListener("dragstart", consume, false);
doc.addEventListener("mousemove", move, false);
doc.addEventListener("mouseup", stop, false);
move(e);
consume(e);
}
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | start | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
function stop(e)
{
if (dragging) {
doc.removeEventListener("selectstart", consume, false);
doc.removeEventListener("dragstart", consume, false);
doc.removeEventListener("mousemove", move, false);
doc.removeEventListener("mouseup", stop, false);
if (onstop)
onstop(element, e);
}
dragging = false;
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | stop | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
set color(color)
{
var rgba = (color.rgba || color.rgb).slice(0);
if (rgba.length === 3)
rgba[3] = 1;
this.hsv = WebInspector.Spectrum.rgbaToHSVA(rgba[0], rgba[1], rgba[2], rgba[3]);
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | color | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
get color()
{
var rgba = WebInspector.Spectrum.hsvaToRGBA(this.hsv[0], this.hsv[1], this.hsv[2], this.hsv[3]);
var color;
if (rgba[3] === 1)
color = WebInspector.Color.fromRGB(rgba[0], rgba[1], rgba[2]);
else
color = WebInspector.Color.fromRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
var colorValue = color.toString(this.outputColorFormat);
if (!colorValue)
colorValue = color.toString(); // this.outputColorFormat can be invalid for current color (e.g. "nickname").
return new WebInspector.Color(colorValue);
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | color | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
get outputColorFormat()
{
var cf = WebInspector.StylesSidebarPane.ColorFormat;
var format = this._originalFormat;
if (this.hsv[3] === 1) {
// Simplify transparent formats.
if (format === cf.RGBA)
format = cf.RGB;
else if (format === cf.HSLA)
format = cf.HSL;
} else {
// Everything except HSL(A) should be returned as RGBA if transparency is involved.
if (format === cf.HSL || format === cf.HSLA)
format = cf.HSLA;
else
format = cf.RGBA;
}
return format;
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | outputColorFormat | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
get colorHueOnly()
{
var rgba = WebInspector.Spectrum.hsvaToRGBA(this.hsv[0], 1, 1, 1);
return WebInspector.Color.fromRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | colorHueOnly | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
set displayText(text)
{
this._displayElement.textContent = text;
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | displayText | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
get visible()
{
return this._popover.visible;
} | @param {Function=} onmove
@param {Function=} onstart
@param {Function=} onstop | visible | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/Spectrum.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/Spectrum.js | MIT |
get disabled()
{
return this._disabled;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | disabled | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
set disabled(x)
{
if (this._disabled === x)
return;
this._disabled = x;
this.element.disabled = x;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | disabled | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
get title()
{
return this._title;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | title | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
set title(x)
{
if (this._title === x)
return;
this._title = x;
this.element.title = x;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | title | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
get state()
{
return this._state;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | state | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
set state(x)
{
if (this._state === x)
return;
if (this.states === 2) {
if (x)
this.element.addStyleClass("toggled-on");
else
this.element.removeStyleClass("toggled-on");
} else {
if (x !== 0) {
this.element.removeStyleClass("toggled-" + this._state);
this.element.addStyleClass("toggled-" + x);
} else
this.element.removeStyleClass("toggled-" + this._state);
}
this._state = x;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | state | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
get toggled()
{
if (this.states !== 2)
throw("Only used toggled when there are 2 states, otherwise, use state");
return this.state;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | toggled | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
set toggled(x)
{
if (this.states !== 2)
throw("Only used toggled when there are 2 states, otherwise, use state");
this.state = x;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | toggled | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
get visible()
{
return this._visible;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | visible | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
set visible(x)
{
if (this._visible === x)
return;
if (x)
this.element.removeStyleClass("hidden");
else
this.element.addStyleClass("hidden");
this._visible = x;
} | @extends {WebInspector.Object}
@constructor
@param {number=} states | visible | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StatusBarButton.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StatusBarButton.js | MIT |
function computedStyleCallback(computedStyle)
{
delete this._refreshUpdateInProgress;
if (this._lastNodeForInnerRefresh) {
delete this._lastNodeForInnerRefresh;
this._refreshUpdate(editedSection, forceFetchComputedStyle, userCallback);
return;
}
if (this.node === node && computedStyle)
this._innerRefreshUpdate(node, computedStyle, editedSection);
if (userCallback)
userCallback();
} | @param {WebInspector.StylePropertiesSection=} editedSection
@param {boolean=} forceFetchComputedStyle
@param {function()=} userCallback | computedStyleCallback | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get inherited()
{
return this._inherited;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | inherited | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
set inherited(x)
{
if (x === this._inherited)
return;
this._inherited = x;
this.updateState();
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | inherited | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get overloaded()
{
return this._overloaded;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | overloaded | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
set overloaded(x)
{
if (x === this._overloaded)
return;
this._overloaded = x;
this.updateState();
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | overloaded | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get disabled()
{
return this.property.disabled;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | disabled | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get name()
{
if (!this.disabled || !this.property.text)
return this.property.name;
var text = this.property.text;
var index = text.indexOf(":");
if (index < 1)
return this.property.name;
return text.substring(0, index).trim();
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | name | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get priority()
{
if (this.disabled)
return ""; // rely upon raw text to render it in the value field
return this.property.priority;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | priority | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get value()
{
if (!this.disabled || !this.property.text)
return this.property.value;
var match = this.property.text.match(/(.*);\s*/);
if (!match || !match[1])
return this.property.value;
var text = match[1];
var index = text.indexOf(":");
if (index < 1)
return this.property.value;
return text.substring(index + 1).trim();
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | value | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
get parsedOk()
{
return this.property.parsedOk;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | parsedOk | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function processValue(regex, processor, nextProcessor, valueText)
{
var container = document.createDocumentFragment();
var items = valueText.replace(regex, "\0$1\0").split("\0");
for (var i = 0; i < items.length; ++i) {
if ((i % 2) === 0) {
if (nextProcessor)
container.appendChild(nextProcessor(items[i]));
else
container.appendChild(document.createTextNode(items[i]));
} else {
var processedNode = processor(items[i]);
if (processedNode)
container.appendChild(processedNode);
}
}
return container;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | processValue | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function linkifyURL(url)
{
var hrefUrl = url;
var match = hrefUrl.match(/['"]?([^'"]+)/);
if (match)
hrefUrl = match[1];
var container = document.createDocumentFragment();
container.appendChild(document.createTextNode("url("));
if (self._styleRule.sourceURL)
hrefUrl = WebInspector.completeURL(self._styleRule.sourceURL, hrefUrl);
else if (WebInspector.panels.elements.selectedDOMNode())
hrefUrl = WebInspector.resourceURLForRelatedNode(WebInspector.panels.elements.selectedDOMNode(), hrefUrl);
var hasResource = !!WebInspector.resourceForURL(hrefUrl);
// FIXME: WebInspector.linkifyURLAsNode() should really use baseURI.
container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl, url, undefined, !hasResource));
container.appendChild(document.createTextNode(")"));
return container;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | linkifyURL | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function processColor(text)
{
try {
var color = new WebInspector.Color(text);
} catch (e) {
return document.createTextNode(text);
}
var format = getFormat();
var hasSpectrum = self._parentPane;
var spectrum = hasSpectrum ? self._parentPane._spectrum : null;
var swatchElement = document.createElement("span");
var swatchInnerElement = swatchElement.createChild("span", "swatch-inner");
swatchElement.title = WebInspector.UIString("Click to open a colorpicker. Shift-click to change color format");
swatchElement.className = "swatch";
swatchElement.addEventListener("mousedown", consumeEvent, false);
swatchElement.addEventListener("click", swatchClick, false);
swatchElement.addEventListener("dblclick", consumeEvent, false);
swatchInnerElement.style.backgroundColor = text;
var scrollerElement = hasSpectrum ? self._parentPane._computedStylePane.element.parentElement : null;
function spectrumChanged(e)
{
color = e.data;
var colorString = color.toString();
colorValueElement.textContent = colorString;
spectrum.displayText = colorString;
swatchInnerElement.style.backgroundColor = colorString;
self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, false, false, false);
}
function spectrumHidden()
{
scrollerElement.removeEventListener("scroll", repositionSpectrum, false);
self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, true, true, false);
spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
spectrum.removeEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
delete self._parentPane._isEditingStyle;
}
function repositionSpectrum()
{
spectrum.reposition(swatchElement);
}
function swatchClick(e)
{
// Shift + click toggles color formats.
// Click opens colorpicker, only if the element is not in computed styles section.
if (!spectrum || e.shiftKey)
changeColorDisplay(e);
else {
var visible = spectrum.toggle(swatchElement, color, format);
if (visible) {
spectrum.displayText = color.toString(format);
self._parentPane._isEditingStyle = true;
spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
spectrum.addEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
scrollerElement.addEventListener("scroll", repositionSpectrum, false);
}
}
e.consume(true);
}
function getFormat()
{
var format;
var formatSetting = WebInspector.settings.colorFormat.get();
if (formatSetting === cf.Original)
format = cf.Original;
else if (color.nickname)
format = cf.Nickname;
else if (formatSetting === cf.RGB)
format = (color.simple ? cf.RGB : cf.RGBA);
else if (formatSetting === cf.HSL)
format = (color.simple ? cf.HSL : cf.HSLA);
else if (color.simple)
format = (color.hasShortHex() ? cf.ShortHEX : cf.HEX);
else
format = cf.RGBA;
return format;
}
var colorValueElement = document.createElement("span");
colorValueElement.textContent = color.toString(format);
function nextFormat(curFormat)
{
// The format loop is as follows:
// * original
// * rgb(a)
// * hsl(a)
// * nickname (if the color has a nickname)
// * if the color is simple:
// - shorthex (if has short hex)
// - hex
switch (curFormat) {
case cf.Original:
return color.simple ? cf.RGB : cf.RGBA;
case cf.RGB:
case cf.RGBA:
return color.simple ? cf.HSL : cf.HSLA;
case cf.HSL:
case cf.HSLA:
if (color.nickname)
return cf.Nickname;
if (color.simple)
return color.hasShortHex() ? cf.ShortHEX : cf.HEX;
else
return cf.Original;
case cf.ShortHEX:
return cf.HEX;
case cf.HEX:
return cf.Original;
case cf.Nickname:
if (color.simple)
return color.hasShortHex() ? cf.ShortHEX : cf.HEX;
else
return cf.Original;
default:
return null;
}
}
function changeColorDisplay(event)
{
do {
format = nextFormat(format);
var currentValue = color.toString(format || "");
} while (format && currentValue === color.value && format !== cf.Original);
if (format)
colorValueElement.textContent = currentValue;
}
var container = document.createDocumentFragment();
container.appendChild(swatchElement);
container.appendChild(colorValueElement);
return container;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | processColor | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function spectrumChanged(e)
{
color = e.data;
var colorString = color.toString();
colorValueElement.textContent = colorString;
spectrum.displayText = colorString;
swatchInnerElement.style.backgroundColor = colorString;
self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, false, false, false);
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | spectrumChanged | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function spectrumHidden()
{
scrollerElement.removeEventListener("scroll", repositionSpectrum, false);
self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, true, true, false);
spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
spectrum.removeEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
delete self._parentPane._isEditingStyle;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | spectrumHidden | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function repositionSpectrum()
{
spectrum.reposition(swatchElement);
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | repositionSpectrum | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function swatchClick(e)
{
// Shift + click toggles color formats.
// Click opens colorpicker, only if the element is not in computed styles section.
if (!spectrum || e.shiftKey)
changeColorDisplay(e);
else {
var visible = spectrum.toggle(swatchElement, color, format);
if (visible) {
spectrum.displayText = color.toString(format);
self._parentPane._isEditingStyle = true;
spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
spectrum.addEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
scrollerElement.addEventListener("scroll", repositionSpectrum, false);
}
}
e.consume(true);
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | swatchClick | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function getFormat()
{
var format;
var formatSetting = WebInspector.settings.colorFormat.get();
if (formatSetting === cf.Original)
format = cf.Original;
else if (color.nickname)
format = cf.Nickname;
else if (formatSetting === cf.RGB)
format = (color.simple ? cf.RGB : cf.RGBA);
else if (formatSetting === cf.HSL)
format = (color.simple ? cf.HSL : cf.HSLA);
else if (color.simple)
format = (color.hasShortHex() ? cf.ShortHEX : cf.HEX);
else
format = cf.RGBA;
return format;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | getFormat | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function nextFormat(curFormat)
{
// The format loop is as follows:
// * original
// * rgb(a)
// * hsl(a)
// * nickname (if the color has a nickname)
// * if the color is simple:
// - shorthex (if has short hex)
// - hex
switch (curFormat) {
case cf.Original:
return color.simple ? cf.RGB : cf.RGBA;
case cf.RGB:
case cf.RGBA:
return color.simple ? cf.HSL : cf.HSLA;
case cf.HSL:
case cf.HSLA:
if (color.nickname)
return cf.Nickname;
if (color.simple)
return color.hasShortHex() ? cf.ShortHEX : cf.HEX;
else
return cf.Original;
case cf.ShortHEX:
return cf.HEX;
case cf.HEX:
return cf.Original;
case cf.Nickname:
if (color.simple)
return color.hasShortHex() ? cf.ShortHEX : cf.HEX;
else
return cf.Original;
default:
return null;
}
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | nextFormat | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function changeColorDisplay(event)
{
do {
format = nextFormat(format);
var currentValue = color.toString(format || "");
} while (format && currentValue === color.value && format !== cf.Original);
if (format)
colorValueElement.textContent = currentValue;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | changeColorDisplay | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function callback(newStyle)
{
if (!newStyle)
return;
this.style = newStyle;
this._styleRule.style = newStyle;
if (this.treeOutline.section && this.treeOutline.section.pane)
this.treeOutline.section.pane.dispatchEventToListeners("style property toggled");
this._updatePane();
delete this._parentPane._userOperation;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | callback | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function pasteHandler(context, event)
{
var data = event.clipboardData.getData("Text");
if (!data)
return;
var colonIdx = data.indexOf(":");
if (colonIdx < 0)
return;
var name = data.substring(0, colonIdx).trim();
var value = data.substring(colonIdx + 1).trim();
event.preventDefault();
if (!("originalName" in context)) {
context.originalName = this.nameElement.textContent;
context.originalValue = this.valueElement.textContent;
}
this.nameElement.textContent = name;
this.valueElement.textContent = value;
this.nameElement.normalize();
this.valueElement.normalize();
this.editingCommitted(null, event.target.textContent, context.previousContent, context, "forward");
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | pasteHandler | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function blurListener(context, event)
{
var treeElement = this._parentPane._mouseDownTreeElement;
var moveDirection = "";
if (treeElement === this) {
if (isEditingName && this._parentPane._mouseDownTreeElementIsValue)
moveDirection = "forward";
if (!isEditingName && this._parentPane._mouseDownTreeElementIsName)
moveDirection = "backward";
}
this.editingCommitted(null, event.target.textContent, context.previousContent, context, moveDirection);
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | blurListener | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function shouldCommitValueSemicolon(text, cursorPosition)
{
// FIXME: should this account for semicolons inside comments?
var openQuote = "";
for (var i = 0; i < cursorPosition; ++i) {
var ch = text[i];
if (ch === "\\" && openQuote !== "")
++i; // skip next character inside string
else if (!openQuote && (ch === "\"" || ch === "'"))
openQuote = ch;
else if (openQuote === ch)
openQuote = "";
}
return !openQuote;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | shouldCommitValueSemicolon | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function apply()
{
var valueText = this.valueElement.textContent;
if (valueText.indexOf(";") === -1)
this.applyStyleText(this.nameElement.textContent + ": " + valueText, false, false, false);
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | apply | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function moveToNextCallback(alreadyNew, valueChanged, section)
{
if (!moveDirection)
return;
// User just tabbed through without changes.
if (moveTo && moveTo.parent) {
moveTo.startEditing(!isEditingName ? moveTo.nameElement : moveTo.valueElement);
return;
}
// User has made a change then tabbed, wiping all the original treeElements.
// Recalculate the new treeElement for the same property we were going to edit next.
if (moveTo && !moveTo.parent) {
var propertyElements = section.propertiesTreeOutline.children;
if (moveDirection === "forward" && blankInput && !isEditingName)
--moveToIndex;
if (moveToIndex >= propertyElements.length && !this._newProperty)
createNewProperty = true;
else {
var treeElement = moveToIndex >= 0 ? propertyElements[moveToIndex] : null;
if (treeElement) {
var elementToEdit = !isEditingName ? treeElement.nameElement : treeElement.valueElement;
if (alreadyNew && blankInput)
elementToEdit = moveDirection === "forward" ? treeElement.nameElement : treeElement.valueElement;
treeElement.startEditing(elementToEdit);
return;
} else if (!alreadyNew)
moveToSelector = true;
}
}
// Create a new attribute in this section (or move to next editable selector if possible).
if (createNewProperty) {
if (alreadyNew && !valueChanged && (isEditingName ^ (moveDirection === "backward")))
return;
section.addNewBlankProperty().startEditing();
return;
}
if (abandonNewProperty) {
moveTo = this._findSibling(moveDirection);
var sectionToEdit = (moveTo || moveDirection === "backward") ? section : section.nextEditableSibling();
if (sectionToEdit) {
if (sectionToEdit.rule)
sectionToEdit.startEditingSelector();
else
sectionToEdit._moveEditorFromSelector(moveDirection);
}
return;
}
if (moveToSelector) {
if (section.rule)
section.startEditingSelector();
else
section._moveEditorFromSelector(moveDirection);
}
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | moveToNextCallback | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function userOperationFinishedCallback(parentPane, updateInterface)
{
if (updateInterface)
delete parentPane._userOperation;
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | userOperationFinishedCallback | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function callback(userCallback, originalPropertyText, newStyle)
{
if (!newStyle) {
if (updateInterface) {
// It did not apply, cancel editing.
this._revertStyleUponEditingCanceled(originalPropertyText);
}
userCallback();
return;
}
if (this._newProperty)
this._newPropertyInStyle = true;
this.style = newStyle;
this.property = newStyle.propertyAt(this.property.index);
this._styleRule.style = this.style;
if (section && section.pane)
section.pane.dispatchEventToListeners("style edited");
if (updateInterface && currentNode === section.pane.node) {
this._updatePane(userCallback);
return;
}
userCallback();
} | @constructor
@extends {TreeElement}
@param {?WebInspector.StylesSidebarPane} parentPane | callback | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/StylesSidebarPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/StylesSidebarPane.js | MIT |
function tabToTabId(tab) {
return tab.id;
} | @param {number} tabsCount
@return {Array.<string>} | tabToTabId | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TabbedPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TabbedPane.js | MIT |
get text()
{
return this._element.textContent;
} | Clients should never attach any event listeners to the |element|. Instead,
they should use the result of this method to attach listeners for bubbling events
or the |blurListener| parameter to register a "blur" event listener on the |element|
(since the "blur" event does not bubble.)
@param {Element} element
@param {function(Event)} blurListener | text | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TextPrompt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TextPrompt.js | MIT |
set text(x)
{
this._removeSuggestionAids();
if (!x) {
// Append a break element instead of setting textContent to make sure the selection is inside the prompt.
this._element.removeChildren();
this._element.appendChild(document.createElement("br"));
} else
this._element.textContent = x;
this.moveCaretToEndOfPrompt();
this._element.scrollIntoView();
} | Clients should never attach any event listeners to the |element|. Instead,
they should use the result of this method to attach listeners for bubbling events
or the |blurListener| parameter to register a "blur" event listener on the |element|
(since the "blur" event does not bubble.)
@param {Element} element
@param {function(Event)} blurListener | text | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TextPrompt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TextPrompt.js | MIT |
function moveBackIfOutside()
{
delete this._selectionTimeout;
if (!this.isCaretInsidePrompt() && window.getSelection().isCollapsed) {
this.moveCaretToEndOfPrompt();
this.autoCompleteSoon();
}
} | Clients should never attach any event listeners to the |element|. Instead,
they should use the result of this method to attach listeners for bubbling events
or the |blurListener| parameter to register a "blur" event listener on the |element|
(since the "blur" event does not bubble.)
@param {Element} element
@param {function(Event)} blurListener | moveBackIfOutside | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TextPrompt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TextPrompt.js | MIT |
get historyData()
{
// FIXME: do we need to copy this?
return this._data;
} | Whether to coalesce duplicate items in the history, default is true.
@type {boolean} | historyData | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TextPrompt.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TextPrompt.js | MIT |
function updateBoundaries(record)
{
this._overviewCalculator.updateBoundaries(record);
return false;
} | @constructor
@extends {WebInspector.Object}
@implements {WebInspector.TimelinePresentationModel.Filter} | updateBoundaries | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TimelineOverviewPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TimelineOverviewPane.js | MIT |
function markPercentagesForRecord(record)
{
if (!(this._showShortEvents || record.isLong()))
return;
var percentages = this._overviewCalculator.computeBarGraphPercentages(record);
var end = Math.round(percentages.end);
var categoryName = record.category.name;
for (var j = Math.round(percentages.start); j <= end; ++j)
timelines[categoryName][j] = true;
} | @constructor
@extends {WebInspector.Object}
@implements {WebInspector.TimelinePresentationModel.Filter} | markPercentagesForRecord | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/TimelineOverviewPane.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/TimelineOverviewPane.js | MIT |
function TreeElement(title, representedObject, hasChildren)
{
this._title = title;
this.representedObject = (representedObject || {});
this._hidden = false;
this._selectable = true;
this.expanded = false;
this.selected = false;
this.hasChildren = hasChildren;
this.children = [];
this.treeOutline = null;
this.parent = null;
this.previousSibling = null;
this.nextSibling = null;
this._listItemNode = null;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | TreeElement | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get selectable() {
if (this._hidden)
return false;
return this._selectable;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | selectable | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set selectable(x) {
this._selectable = x;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | selectable | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get listItemElement() {
return this._listItemNode;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | listItemElement | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get childrenListElement() {
return this._childrenListNode;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | childrenListElement | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get title() {
return this._title;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | title | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set title(x) {
this._title = x;
this._setListItemNodeContent();
this.didChange();
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | title | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get tooltip() {
return this._tooltip;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | tooltip | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set tooltip(x) {
this._tooltip = x;
if (this._listItemNode)
this._listItemNode.title = x ? x : "";
this.didChange();
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | tooltip | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get hasChildren() {
return this._hasChildren;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | hasChildren | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set hasChildren(x) {
if (this._hasChildren === x)
return;
this._hasChildren = x;
if (!this._listItemNode)
return;
if (x)
this._listItemNode.classList.add("parent");
else {
this._listItemNode.classList.remove("parent");
this.collapse();
}
this.didChange();
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | hasChildren | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get hidden() {
return this._hidden;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | hidden | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set hidden(x) {
if (this._hidden === x)
return;
this._hidden = x;
if (x) {
if (this._listItemNode)
this._listItemNode.classList.add("hidden");
if (this._childrenListNode)
this._childrenListNode.classList.add("hidden");
} else {
if (this._listItemNode)
this._listItemNode.classList.remove("hidden");
if (this._childrenListNode)
this._childrenListNode.classList.remove("hidden");
}
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | hidden | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
get shouldRefreshChildren() {
return this._shouldRefreshChildren;
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | shouldRefreshChildren | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
set shouldRefreshChildren(x) {
this._shouldRefreshChildren = x;
if (x && this.expanded)
this.expand();
} | @constructor
@param {Object=} representedObject
@param {boolean=} hasChildren | shouldRefreshChildren | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/treeoutline.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/treeoutline.js | MIT |
function getContent(element) {
if (element.tagName === "INPUT" && element.type === "text")
return element.value;
else
return element.textContent;
} | @param {Element} element
@param {WebInspector.EditingConfig=} config | getContent | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/UIUtils.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/UIUtils.js | MIT |
function windowLoaded()
{
window.addEventListener("focus", WebInspector._windowFocused, false);
window.addEventListener("blur", WebInspector._windowBlurred, false);
document.addEventListener("focus", WebInspector._focusChanged.bind(this), true);
window.removeEventListener("DOMContentLoaded", windowLoaded, false);
} | @param {WebInspector.ContextMenu} contextMenu
@param {Node} contextNode
@param {Event} event | windowLoaded | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/UIUtils.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/UIUtils.js | MIT |
function AnchorBox(x, y, width, height)
{
this.x = x || 0;
this.y = y || 0;
this.width = width || 0;
this.height = height || 0;
} | @constructor
@param {number=} x
@param {number=} y
@param {number=} width
@param {number=} height | AnchorBox | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function highlightSearchResult(element, offset, length, domChanges)
{
var result = highlightSearchResults(element, [{offset: offset, length: length }], domChanges);
return result.length ? result[0] : null;
} | @param {Element} element
@param {number} offset
@param {number} length
@param {Array.<Object>=} domChanges | highlightSearchResult | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function highlightSearchResults(element, resultRanges, changes)
{
return highlightRangesWithStyleClass(element, resultRanges, "webkit-search-result", changes);
} | @param {Element} element
@param {Array.<Object>} resultRanges
@param {Array.<Object>=} changes | highlightSearchResults | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function highlightRangesWithStyleClass(element, resultRanges, styleClass, changes)
{
changes = changes || [];
var highlightNodes = [];
var lineText = element.textContent;
var ownerDocument = element.ownerDocument;
var textNodeSnapshot = ownerDocument.evaluate(".//text()", element, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var snapshotLength = textNodeSnapshot.snapshotLength;
if (snapshotLength === 0)
return highlightNodes;
var nodeRanges = [];
var rangeEndOffset = 0;
for (var i = 0; i < snapshotLength; ++i) {
var range = {};
range.offset = rangeEndOffset;
range.length = textNodeSnapshot.snapshotItem(i).textContent.length;
rangeEndOffset = range.offset + range.length;
nodeRanges.push(range);
}
var startIndex = 0;
for (var i = 0; i < resultRanges.length; ++i) {
var startOffset = resultRanges[i].offset;
var endOffset = startOffset + resultRanges[i].length;
while (startIndex < snapshotLength && nodeRanges[startIndex].offset + nodeRanges[startIndex].length <= startOffset)
startIndex++;
var endIndex = startIndex;
while (endIndex < snapshotLength && nodeRanges[endIndex].offset + nodeRanges[endIndex].length < endOffset)
endIndex++;
if (endIndex === snapshotLength)
break;
var highlightNode = ownerDocument.createElement("span");
highlightNode.className = styleClass;
highlightNode.textContent = lineText.substring(startOffset, endOffset);
var lastTextNode = textNodeSnapshot.snapshotItem(endIndex);
var lastText = lastTextNode.textContent;
lastTextNode.textContent = lastText.substring(endOffset - nodeRanges[endIndex].offset);
changes.push({ node: lastTextNode, type: "changed", oldText: lastText, newText: lastTextNode.textContent });
if (startIndex === endIndex) {
lastTextNode.parentElement.insertBefore(highlightNode, lastTextNode);
changes.push({ node: highlightNode, type: "added", nextSibling: lastTextNode, parent: lastTextNode.parentElement });
highlightNodes.push(highlightNode);
var prefixNode = ownerDocument.createTextNode(lastText.substring(0, startOffset - nodeRanges[startIndex].offset));
lastTextNode.parentElement.insertBefore(prefixNode, highlightNode);
changes.push({ node: prefixNode, type: "added", nextSibling: highlightNode, parent: lastTextNode.parentElement });
} else {
var firstTextNode = textNodeSnapshot.snapshotItem(startIndex);
var firstText = firstTextNode.textContent;
var anchorElement = firstTextNode.nextSibling;
firstTextNode.parentElement.insertBefore(highlightNode, anchorElement);
changes.push({ node: highlightNode, type: "added", nextSibling: anchorElement, parent: firstTextNode.parentElement });
highlightNodes.push(highlightNode);
firstTextNode.textContent = firstText.substring(0, startOffset - nodeRanges[startIndex].offset);
changes.push({ node: firstTextNode, type: "changed", oldText: firstText, newText: firstTextNode.textContent });
for (var j = startIndex + 1; j < endIndex; j++) {
var textNode = textNodeSnapshot.snapshotItem(j);
var text = textNode.textContent;
textNode.textContent = "";
changes.push({ node: textNode, type: "changed", oldText: text, newText: textNode.textContent });
}
}
startIndex = endIndex;
nodeRanges[startIndex].offset = endOffset;
nodeRanges[startIndex].length = lastTextNode.textContent.length;
}
return highlightNodes;
} | @param {Element} element
@param {Array.<Object>} resultRanges
@param {string} styleClass
@param {Array.<Object>=} changes | highlightRangesWithStyleClass | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function applyDomChanges(domChanges)
{
for (var i = 0, size = domChanges.length; i < size; ++i) {
var entry = domChanges[i];
switch (entry.type) {
case "added":
entry.parent.insertBefore(entry.node, entry.nextSibling);
break;
case "changed":
entry.node.textContent = entry.newText;
break;
}
}
} | @param {Element} element
@param {Array.<Object>} resultRanges
@param {string} styleClass
@param {Array.<Object>=} changes | applyDomChanges | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function revertDomChanges(domChanges)
{
for (var i = domChanges.length - 1; i >= 0; --i) {
var entry = domChanges[i];
switch (entry.type) {
case "added":
if (entry.node.parentElement)
entry.node.parentElement.removeChild(entry.node);
break;
case "changed":
entry.node.textContent = entry.oldText;
break;
}
}
} | @param {Element} element
@param {Array.<Object>} resultRanges
@param {string} styleClass
@param {Array.<Object>=} changes | revertDomChanges | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function createSearchRegex(query, caseSensitive, isRegex)
{
var regexFlags = caseSensitive ? "g" : "gi";
var regexObject;
if (isRegex) {
try {
regexObject = new RegExp(query, regexFlags);
} catch (e) {
// Silent catch.
}
}
if (!regexObject)
regexObject = createPlainTextSearchRegex(query, regexFlags);
return regexObject;
} | @param {string} query
@param {boolean} caseSensitive
@param {boolean} isRegex
@return {RegExp} | createSearchRegex | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function createPlainTextSearchRegex(query, flags)
{
// This should be kept the same as the one in ContentSearchUtils.cpp.
var regexSpecialCharacters = "[](){}+-*.,?\\^$|";
var regex = "";
for (var i = 0; i < query.length; ++i) {
var c = query.charAt(i);
if (regexSpecialCharacters.indexOf(c) != -1)
regex += "\\";
regex += c;
}
return new RegExp(regex, flags || "");
} | @param {string} query
@param {string=} flags
@return {RegExp} | createPlainTextSearchRegex | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function countRegexMatches(regex, content)
{
var text = content;
var result = 0;
var match;
while (text && (match = regex.exec(text))) {
if (match[0].length > 0)
++result;
text = text.substring(match.index + 1);
}
return result;
} | @param {RegExp} regex
@param {string} content
@return {number} | countRegexMatches | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function numberToStringWithSpacesPadding(value, symbolsCount)
{
var numberString = value.toString();
var paddingLength = Math.max(0, symbolsCount - numberString.length);
var paddingString = Array(paddingLength + 1).join("\u00a0");
return paddingString + numberString;
} | @param {number} value
@param {number} symbolsCount
@return {string} | numberToStringWithSpacesPadding | javascript | node-pinus/pinus | tools/pinus-admin-web/public/front/utilities.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/front/utilities.js | MIT |
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
} | Based on JSON2 (http://www.JSON.org/js.html). | f | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function date(d, key) {
return isFinite(d.valueOf()) ?
d.getUTCFullYear() + '-' +
f(d.getUTCMonth() + 1) + '-' +
f(d.getUTCDate()) + 'T' +
f(d.getUTCHours()) + ':' +
f(d.getUTCMinutes()) + ':' +
f(d.getUTCSeconds()) + 'Z' : null;
} | Based on JSON2 (http://www.JSON.org/js.html). | date | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
} | Based on JSON2 (http://www.JSON.org/js.html). | quote | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value instanceof Date) {
value = date(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' : gap ?
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' : gap ?
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
'{' + partial.join(',') + '}';
gap = mind;
return v;
}
} | Based on JSON2 (http://www.JSON.org/js.html). | str | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
} | Based on JSON2 (http://www.JSON.org/js.html). | walk | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function Transport (socket, sessid) {
this.socket = socket;
this.sessid = sessid;
} | This is the transport template for all supported transport methods.
@constructor
@api public | Transport | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function Socket (options) {
this.options = {
port: 80
, secure: false
, document: 'document' in global ? document : false
, resource: 'socket.io'
, transports: io.transports
, 'connect timeout': 10000
, 'try multiple transports': true
, 'reconnect': true
, 'reconnection delay': 500
, 'reconnection limit': Infinity
, 'reopen delay': 3000
, 'max reconnection attempts': 10
, 'sync disconnect on unload': true
, 'auto connect': true
, 'flash policy port': 10843
};
io.util.merge(this.options, options);
this.connected = false;
this.open = false;
this.connecting = false;
this.reconnecting = false;
this.namespaces = {};
this.buffer = [];
this.doBuffer = false;
if (this.options['sync disconnect on unload'] &&
(!this.isXDomain() || io.util.ua.hasCORS)) {
var self = this;
io.util.on(global, 'beforeunload', function () {
self.disconnectSync();
}, false);
}
if (this.options['auto connect']) {
this.connect();
}
} | Create a new `Socket.IO client` which can establish a persistent
connection with a Socket.IO enabled server.
@api public | Socket | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function connect (transports){
if (self.transport) self.transport.clearTimeouts();
self.transport = self.getTransport(transports);
if (!self.transport) return self.publish('connect_failed');
// once the transport is ready
self.transport.ready(self, function () {
self.connecting = true;
self.publish('connecting', self.transport.name);
self.transport.open();
if (self.options['connect timeout']) {
self.connectTimeoutTimer = setTimeout(function () {
if (!self.connected) {
self.connecting = false;
if (self.options['try multiple transports']) {
if (!self.remainingTransports) {
self.remainingTransports = self.transports.slice(0);
}
var remaining = self.remainingTransports;
while (remaining.length > 0 && remaining.splice(0,1)[0] !=
self.transport.name) {}
if (remaining.length){
connect(remaining);
} else {
self.publish('connect_failed');
}
}
}
}, self.options['connect timeout']);
}
});
} | Connects to the server.
@param {Function} [fn] Callback.
@returns {io.Socket}
@api public | connect | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function SocketNamespace (socket, name) {
this.socket = socket;
this.name = name || '';
this.flags = {};
this.json = new Flag(this, 'json');
this.ackPackets = 0;
this.acks = {};
} | Socket namespace constructor.
@constructor
@api public | SocketNamespace | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function WS (socket) {
io.Transport.apply(this, arguments);
} | The WebSocket transport uses the HTML5 WebSocket API to establish an
persistent connection with the Socket.IO server. This transport will also
be inherited by the FlashSocket fallback as it provides a API compatible
polyfill for the WebSockets.
@constructor
@extends {io.Transport}
@api public | WS | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function Flashsocket () {
io.Transport.websocket.apply(this, arguments);
} | The FlashSocket transport. This is a API wrapper for the HTML5 WebSocket
specification. It uses a .swf file to communicate with the server. If you want
to serve the .swf file from a other server than where the Socket.IO script is
coming from you need to use the insecure version of the .swf. More information
about this can be found on the github page.
@constructor
@extends {io.Transport.websocket}
@api public | Flashsocket | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function init () {
var options = socket.options
, port = options['flash policy port']
, path = [
'http' + (options.secure ? 's' : '') + ':/'
, options.host + ':' + options.port
, options.resource
, 'static/flashsocket'
, 'WebSocketMain' + (socket.isXDomain() ? 'Insecure' : '') + '.swf'
];
// Only start downloading the swf file when the checked that this browser
// actually supports it
if (!Flashsocket.loaded) {
if (typeof WEB_SOCKET_SWF_LOCATION === 'undefined') {
// Set the correct file based on the XDomain settings
WEB_SOCKET_SWF_LOCATION = path.join('/');
}
if (port !== 843) {
WebSocket.loadFlashPolicyFile('xmlsocket://' + options.host + ':' + port);
}
WebSocket.__initialize();
Flashsocket.loaded = true;
}
fn.call(self);
} | The WebSocket fall back needs to append the flash container to the body
element, so we need to make sure we have access to it. Or defer the call
until we are sure there is a body element.
@param {Socket} socket The socket instance that needs a transport
@param {Function} fn The callback
@api private | init | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function stateChange () {
if (this.readyState == 4) {
this.onreadystatechange = empty;
self.posting = false;
if (this.status == 200){
self.socket.setBuffer(false);
} else {
self.onClose();
}
}
} | Posts a encoded message to the Socket.IO server.
@param {String} data A encoded message.
@api private | stateChange | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function onload () {
this.onload = empty;
self.socket.setBuffer(false);
} | Posts a encoded message to the Socket.IO server.
@param {String} data A encoded message.
@api private | onload | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function HTMLFile (socket) {
io.Transport.XHR.apply(this, arguments);
} | The HTMLFile transport creates a `forever iframe` based transport
for Internet Explorer. Regular forever iframe implementations will
continuously trigger the browsers buzy indicators. If the forever iframe
is created inside a `htmlfile` these indicators will not be trigged.
@constructor
@extends {io.Transport.XHR}
@api public | HTMLFile | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function XHRPolling () {
io.Transport.XHR.apply(this, arguments);
} | The XHR-polling transport uses long polling XHR requests to create a
"persistent" connection with the server.
@constructor
@api public | XHRPolling | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function stateChange () {
if (this.readyState == 4) {
this.onreadystatechange = empty;
if (this.status == 200) {
self.onData(this.responseText);
self.get();
} else {
self.onClose();
}
}
} | Starts a XHR request to wait for incoming messages.
@api private | stateChange | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
function onload () {
this.onload = empty;
self.onData(this.responseText);
self.get();
} | Starts a XHR request to wait for incoming messages.
@api private | onload | javascript | node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | https://github.com/node-pinus/pinus/blob/master/tools/pinus-admin-web/public/js/socket.io.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.