_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3 values | text stringlengths 52 373k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q34400 | train | function(callback) {
// everything is copied in case the collection is modified during the cycle
var values = this._data_values.slice(),
uids = this._data_uids.slice(),
names = this._data_names.slice(),
i = 0,
count = this._count;
for (; i < count; i++) {
if (callback(values[i], names[i], uids[i], i) === false) {
break;
}
}
} | javascript | {
"resource": ""
} | |
q34401 | train | function(new_indices) {
var i = 0,
result = this._createHelperStorage(),
index,
verification = {};
if (Lava.schema.DEBUG && new_indices.length != this._count) throw "reorder: new item count is less than current";
for (; i < this._count; i++) {
index = new_indices[i];
result.push(this._data_uids[index], this._data_values[index], this._data_names[index]);
if (Lava.schema.DEBUG) {
// duplicate UIDs may break a lot of functionality, in this class and outside
if (index in verification) Lava.t("Malformed index array");
verification[index] = null;
}
}
this._assignStorage(result);
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34402 | train | function(start_index, count) {
if (count <= 0) Lava.t("Invalid item count supplied for removeRange");
if (start_index + count >= this._count + 1) Lava.t("Index is out of range");
var removed_uids = this._data_uids.splice(start_index, count),
removed_values = this._data_values.splice(start_index, count),
removed_names = this._data_names.splice(start_index, count);
this._setLength(this._count - count);
this._fire('items_removed', {
uids: removed_uids,
values: removed_values,
names: removed_names
});
this._fire('collection_changed');
return removed_values;
} | javascript | {
"resource": ""
} | |
q34403 | train | function() {
return {
uids: [],
values: [],
names: [],
push: function(uid, value, name) {
this.uids.push(uid);
this.values.push(value);
this.names.push(name);
},
getObject: function() {
return {
uids: this.uids,
values: this.values,
names: this.names
}
}
}
} | javascript | {
"resource": ""
} | |
q34404 | train | function(data_source) {
this.guid = Lava.guid++;
if (data_source) {
var count = 0,
i = 0,
name;
if (Array.isArray(data_source)) {
for (count = data_source.length; i < count; i++) {
this._push(this._uid++, data_source[i], null);
}
} else if (data_source.isCollection) {
this._data_names = data_source.getNames();
this._data_values = data_source.getValues();
for (count = this._data_values.length; i < count; i++) {
this._data_uids.push(this._uid++);
}
} else {
if (data_source.isProperties) {
data_source = data_source.getProperties();
}
for (name in data_source) {
this._push(this._uid++, data_source[name], name);
}
}
this._count = this._data_uids.length;
}
} | javascript | {
"resource": ""
} | |
q34405 | train | function(data_source) {
if (Lava.schema.DEBUG && typeof(data_source) != 'object') Lava.t("Wrong argument passed to updateFromSourceObject");
if (Array.isArray(data_source)) {
this._updateFromArray(data_source, []);
} else if (data_source.isCollection) {
this._updateFromEnumerable(data_source);
} else {
this._updateFromObject(data_source.isProperties ? data_source.getProperties() : data_source);
}
} | javascript | {
"resource": ""
} | |
q34406 | train | function(source_array, names) {
var i = 0,
count = source_array.length,
items_removed_argument = {
uids: this._data_uids,
values: this._data_values,
names: this._data_names
};
this._data_uids = [];
this._data_values = [];
this._data_names = [];
for (; i < count; i++) {
this._push(this._uid++, source_array[i], names[i] || null);
}
this._setLength(count);
this._fire('items_removed', items_removed_argument);
this._fire('items_added', {
uids: this._data_uids.slice(),
values: this._data_values.slice(),
names: this._data_names.slice()
});
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34407 | train | function(source_object) {
var i = 0,
name,
uid,
result = this._createHelperStorage(),
removed = this._createHelperStorage(),
added = this._createHelperStorage();
for (; i < this._count; i++) {
name = this._data_names[i];
if (name != null && (name in source_object)) {
if (source_object[name] === this._data_values[i]) {
result.push(this._data_uids[i], this._data_values[i], this._data_names[i]);
} else {
// Attention: the name has NOT changed, but it will be present in both added and removed names!
removed.push(this._data_uids[i], this._data_values[i], name);
uid = this._uid++;
result.push(uid, source_object[name], name);
added.push(uid, source_object[name], name);
}
} else {
removed.push(this._data_uids[i], this._data_values[i], this._data_names[i]);
}
}
for (name in source_object) {
if (this._data_names.indexOf(name) == -1) {
uid = this._uid++;
result.push(uid, source_object[name], name);
added.push(uid, source_object[name], name);
}
}
this._assignStorage(result);
this._setLength(this._data_uids.length);
removed.uids.length && this._fire('items_removed', removed.getObject());
added.uids.length && this._fire('items_added', added.getObject());
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34408 | train | function(index, value, name) {
if (index > this._count) Lava.t("Index is out of range");
var old_uid = this._data_uids[index],
old_value = this._data_values[index],
old_name = this._data_names[index],
new_uid = this._uid++;
this._data_uids[index] = new_uid;
this._data_values[index] = value;
if (name) {
this._data_names[index] = name;
}
this._fire('items_removed', {
uids: [old_uid],
values: [old_value],
names: [old_name]
});
this._fire('items_added', {
uids: [new_uid],
values: [value],
names: [this._data_names[index]]
});
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34409 | train | function(value, name) {
var result = false,
index = this._data_values.indexOf(value);
if (index == -1) {
this.push(value, name);
result = true;
}
return result;
} | javascript | {
"resource": ""
} | |
q34410 | train | function(start_index, values, names) {
if (start_index >= this._count) Lava.t("Index is out of range");
var i = 0,
count = values.length,
added_uids = [],
added_names = [];
if (names) {
if (count != names.length) Lava.t("If names array is provided, it must be equal length with values array.");
added_names = names;
} else {
for (; i < count; i++) {
added_names.push(null);
}
}
for (; i < count; i++) {
added_uids.push(this._uid++);
}
if (start_index == 0) {
// prepend to beginning
this._data_uids = added_uids.concat(this._data_uids);
this._data_values = values.concat(this._data_values);
this._data_names = added_names.concat(this._data_names);
} else if (start_index == this._count - 1) {
// append to the end
this._data_uids = this._data_uids.concat(added_uids);
this._data_values = this._data_values.concat(values);
this._data_names = this._data_names.concat(added_names);
} else {
this._data_uids = this._data_uids.slice(0, start_index).concat(added_uids).concat(this._data_uids.slice(start_index));
this._data_values = this._data_values.slice(0, start_index).concat(values).concat(this._data_values.slice(start_index));
this._data_names = this._data_names.slice(0, start_index).concat(added_names).concat(this._data_names.slice(start_index));
}
this._setLength(this._count + count);
this._fire('items_added', {
uids: added_uids,
values: values,
names: added_names
});
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34411 | train | function() {
this._data_names = this._data_source.getNames();
this._data_values = this._data_source.getValues();
this._data_uids = this._data_source.getUIDs();
this._count = this._data_uids.length;
this._fire('collection_changed');
} | javascript | {
"resource": ""
} | |
q34412 | train | function(data_source) {
if (Lava.schema.DEBUG && !data_source.isCollection) Lava.t("Wrong argument supplied for DataView constructor");
this._data_source = data_source;
} | javascript | {
"resource": ""
} | |
q34413 | train | function(template_config, widget, parent_view, child_properties) {
this.guid = Lava.guid++;
this._parent_view = parent_view;
this._widget = widget;
this._config = template_config;
this._createChildren(this._content, template_config, [], child_properties);
this._count = this._content.length;
} | javascript | {
"resource": ""
} | |
q34414 | train | function(result, children_config, include_name_stack, properties) {
var i = 0,
count = children_config.length,
childConfig,
type;
for (; i < count; i++) {
childConfig = children_config[i];
type = typeof(childConfig);
if (type == 'object') type = childConfig.type;
if (Lava.schema.DEBUG && !(type in this._block_handlers_map)) Lava.t("Unsupported template item type: " + type);
this[this._block_handlers_map[type]](result, childConfig, include_name_stack, properties);
}
} | javascript | {
"resource": ""
} | |
q34415 | train | function(result, childConfig, include_name_stack, properties) {
var constructor = Lava.ClassManager.getConstructor(childConfig['class'], 'Lava.view'),
view = new constructor(
childConfig,
this._widget,
this._parent_view,
this, // template
properties
);
view.template_index = result.push(view) - 1;
} | javascript | {
"resource": ""
} | |
q34416 | train | function(result, child_config, include_name_stack, properties) {
if (include_name_stack.indexOf(child_config.name) != -1) Lava.t("Infinite include recursion");
var include = Lava.view_manager.getInclude(this._parent_view, child_config);
if (Lava.schema.DEBUG && include == null) Lava.t("Include not found: " + child_config.name);
include_name_stack.push(child_config.name);
this._createChildren(result, include, include_name_stack, properties);
include_name_stack.pop();
} | javascript | {
"resource": ""
} | |
q34417 | train | function(name, value) {
for (var i = 0; i < this._count; i++) {
if (this._content[i].isView) {
this._content[i].set(name, value);
}
}
} | javascript | {
"resource": ""
} | |
q34418 | train | function(properties_object) {
for (var i = 0; i < this._count; i++) {
if (this._content[i].isView) {
this._content[i].setProperties(properties_object);
}
}
} | javascript | {
"resource": ""
} | |
q34419 | train | function(i) {
var result = null;
while (i < this._count) {
if (this._content[i].isView) {
result = this._content[i];
break;
}
i++;
}
return result;
} | javascript | {
"resource": ""
} | |
q34420 | train | function(label) {
var result = [],
i = 0;
for (; i < this._count; i++) {
if (this._content[i].isView && this._content[i].label == label) {
result.push(this._content[i]);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34421 | train | function(name) {
var result = [],
i = 0;
for (; i < this._count; i++) {
if (this._content[i].isWidget && this._content[i].name == name) {
result.push(this._content[i]);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34422 | train | function() {
var default_events = Lava.schema.system.DEFAULT_EVENTS,
i = 0,
count = default_events.length;
for (; i < count; i++) {
this._event_usage_counters[default_events[i]] = 1;
this._initEvent(default_events[i]);
}
} | javascript | {
"resource": ""
} | |
q34423 | train | function(view) {
if (view.depth in this._dirty_views) {
this._dirty_views[view.depth].push(view);
} else {
this._dirty_views[view.depth] = [view];
}
} | javascript | {
"resource": ""
} | |
q34424 | train | function(dirty_views) {
var level = 0,
deepness,
views_list,
has_exceptions = false,
i,
count;
deepness = dirty_views.length; // this line must be after ScopeManager#refresh()
for (; level < deepness; level++) {
if (level in dirty_views) {
views_list = dirty_views[level];
for (i = 0, count = views_list.length; i < count; i++) {
if (views_list[i].refresh(this._refresh_id)) {
Lava.logError("ViewManager: view was refreshed several times in one refresh loop. Aborting.");
has_exceptions = true;
}
}
}
}
return has_exceptions;
} | javascript | {
"resource": ""
} | |
q34425 | train | function(starting_widget, id) {
if (Lava.schema.DEBUG && !id) Lava.t();
return this._views_by_id[id];
} | javascript | {
"resource": ""
} | |
q34426 | train | function(starting_widget, guid) {
if (Lava.schema.DEBUG && !guid) Lava.t();
return this._views_by_guid[guid];
} | javascript | {
"resource": ""
} | |
q34427 | train | function(view, targets, callback, callback_arguments, global_targets_object) {
var i = 0,
count = targets.length,
target,
target_name,
widget,
template_arguments,
bubble_index = 0,
bubble_targets_copy,
bubble_targets_count;
this._nested_dispatch_count++;
for (; i < count; i++) {
target = targets[i];
target_name = target.name;
template_arguments = ('arguments' in target) ? this._evalTargetArguments(view, target) : null;
widget = null;
if ('locator_type' in target) {
/*
Note: there is similar view location mechanism in view.Abstract, but the algorithms are different:
when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy.
Also, hardcoded labels differ.
*/
widget = this['_locateWidgetBy' + target.locator_type](view.getWidget(), target.locator);
if (!widget) {
Lava.logError('ViewManager: callback target (widget) not found. Type: ' + target.locator_type + ', locator: ' + target.locator);
} else if (!widget.isWidget) {
Lava.logError('ViewManager: callback target is not a widget');
} else if (!callback(widget, target_name, view, template_arguments, callback_arguments)) {
Lava.logError('ViewManager: targeted widget did not handle the role or event: ' + target_name);
}
// ignore possible call to cancelBubble()
this._cancel_bubble = false;
} else {
// bubble
widget = view.getWidget();
do {
callback(widget, target_name, view, template_arguments, callback_arguments);
widget = widget.getParentWidget();
} while (widget && !this._cancel_bubble);
if (this._cancel_bubble) {
this._cancel_bubble = false;
continue;
}
if (target_name in global_targets_object) {
// cause target can be removed inside event handler
bubble_targets_copy = global_targets_object[target_name].slice();
for (bubble_targets_count = bubble_targets_copy.length; bubble_index < bubble_targets_count; bubble_index++) {
callback(
bubble_targets_copy[bubble_index],
target_name,
view,
template_arguments,
callback_arguments
);
if (this._cancel_bubble) {
this._cancel_bubble = false;
break;
}
}
}
}
}
this._nested_dispatch_count--;
} | javascript | {
"resource": ""
} | |
q34428 | train | function(view, event_name, event_object) {
var targets = view.getContainer().getEventTargets(event_name);
if (targets) {
this.dispatchEvent(view, event_name, event_object, targets);
}
} | javascript | {
"resource": ""
} | |
q34429 | train | function(view, event_name, event_object, targets) {
this._dispatchCallback(
view,
targets,
this._callHandleEvent,
{
event_name: event_name,
event_object: event_object
},
this._global_event_targets
);
} | javascript | {
"resource": ""
} | |
q34430 | train | function(view, target) {
var result = [];
for (var i = 0, count = target.arguments.length; i < count; i++) {
if (target.arguments[i].type == Lava.TARGET_ARGUMENT_TYPES.VALUE) {
result.push(target.arguments[i].data);
} else {
if (target.arguments[i].type != Lava.TARGET_ARGUMENT_TYPES.BIND) Lava.t();
result.push(view.evalPathConfig(target.arguments[i].data));
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34431 | train | function(starting_view, config) {
var widget = starting_view.getWidget(),
template_arguments = ('arguments' in config) ? this._evalTargetArguments(starting_view, config) : null;
if ('locator_type' in config) {
widget = this['_locateWidgetBy' + config.locator_type](widget, config.locator);
if (!widget || !widget.isWidget) Lava.t();
}
return widget.getInclude(config.name, template_arguments);
} | javascript | {
"resource": ""
} | |
q34432 | train | function(element) {
var id = Firestorm.Element.getProperty(element, 'id'),
result = null;
if (id) {
if (id.indexOf(Lava.ELEMENT_ID_PREFIX) == 0) {
result = this.getViewByGuid(id.substr(Lava.ELEMENT_ID_PREFIX.length));
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34433 | train | function(label) {
var result = [];
for (var guid in this._views_by_guid) {
if (this._views_by_guid[guid].label == label) {
result.push(this._views_by_guid[guid]);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34434 | train | function(element) {
// note: target of some events can be the root html tag (for example, mousedown on a scroll bar)
var document_ref = window.document, // document > html > body > ...
result = [];
while (element && element != document_ref) {
result.push(element);
element = element.parentNode;
}
// you must not modify the returned array, but you can slice() it
if (Lava.schema.DEBUG && Object.freeze) {
Object.freeze(result);
}
return result;
} | javascript | {
"resource": ""
} | |
q34435 | train | function(event_name, event_object) {
var target = event_object.target,
view,
container,
stack_changed_event_name = event_name + '_stack_changed',
stack = target ? this._buildElementStack(target) : [],
i = 0,
count = stack.length;
// Warning! You must not modify the `stack` array!
this._fire(stack_changed_event_name, stack);
for (; i < count; i++) {
view = this.getViewByElement(stack[i]);
if (view) {
container = view.getContainer();
if (container.isElementContainer) {
if (container.getEventTargets(event_name)) {
this.dispatchEvent(view, event_name, event_object, container.getEventTargets(event_name));
}
}
}
}
} | javascript | {
"resource": ""
} | |
q34436 | train | function(event_name) {
if (Lava.schema.DEBUG && ['mouseenter', 'mouseleave', 'mouseover', 'mouseout'].indexOf(event_name) != -1)
Lava.t("The following events: mouseenter, mouseleave, mouseover and mouseout are served by common alias - mouse_events");
if (this._event_usage_counters[event_name]) {
this._event_usage_counters[event_name]++;
} else {
this._event_usage_counters[event_name] = 1;
this._initEvent(event_name);
}
} | javascript | {
"resource": ""
} | |
q34437 | train | function(event_name) {
if (event_name == 'mouse_events') {
this._events_listeners['mouseover'] =
Lava.Core.addGlobalHandler('mouseover', this.handleMouseMovement, this);
this._events_listeners['mouseout'] =
Lava.Core.addGlobalHandler('mouseout', this.handleMouseMovement, this);
} else {
this._events_listeners[event_name] =
Lava.Core.addGlobalHandler(event_name, this.onDOMEvent, this);
}
} | javascript | {
"resource": ""
} | |
q34438 | train | function(event_name) {
if (this._event_usage_counters[event_name] == 0) {
Lava.logError("ViewManager: trying to release an event with zero usage.");
return;
}
this._event_usage_counters[event_name]--;
if (this._event_usage_counters[event_name] == 0) {
this._shutdownEvent(event_name);
}
} | javascript | {
"resource": ""
} | |
q34439 | train | function(event_name) {
if (event_name == 'mouse_events') {
Lava.Core.removeGlobalHandler(this._events_listeners['mouseover']);
this._events_listeners['mouseover'] = null;
Lava.Core.removeGlobalHandler(this._events_listeners['mouseout']);
this._events_listeners['mouseout'] = null;
} else {
Lava.Core.removeGlobalHandler(this._events_listeners[event_name]);
this._events_listeners[event_name] = null;
}
} | javascript | {
"resource": ""
} | |
q34440 | train | function(name) {
if (!(name in this._modules)) {
var config = Lava.schema.modules[name],
className = config.type || Lava.schema.data.DEFAULT_MODULE_CLASS,
constructor = Lava.ClassManager.getConstructor(className, 'Lava.data');
// construction is split into two phases, cause initFields() may reference other modules
// - this will result in recursive call to getModule().
// In case of circular dependency, the first module must be already constructed.
this._modules[name] = new constructor(this, config, name);
this._modules[name].initFields();
}
return this._modules[name];
} | javascript | {
"resource": ""
} | |
q34441 | train | function(schema, raw_tag, parent_title) {
var widget_config = Lava.parsers.Common.createDefaultWidgetConfig(),
tags,
name,
x = raw_tag.x;
widget_config['extends'] = parent_title;
if (raw_tag.content) {
// Lava.isVoidTag is a workaround for <x:attach_directives>
// It's highly discouraged to make sugar from void tags
if (Lava.isVoidTag(raw_tag.name) || !schema.content_schema) {
tags = Lava.parsers.Common.asBlocks(raw_tag.content);
tags = this._applyTopDirectives(tags, widget_config);
if (Lava.schema.DEBUG && tags.length) Lava.t("Widget is not allowed to have any content: " + raw_tag.name);
} else {
if (Lava.schema.DEBUG && !(schema.content_schema.type in this._root_map)) Lava.t("Unknown type of content in sugar: " + schema.content_schema.type);
this[this._root_map[schema.content_schema.type]](schema.content_schema, raw_tag, widget_config, schema.content_schema.name);
}
}
if (raw_tag.attributes) {
this._parseRootAttributes(schema, raw_tag, widget_config);
}
if (x) {
if (Lava.schema.DEBUG && x) {
for (name in x) {
if (['label', 'roles', 'resource_id', 'controller'].indexOf(name) == -1) Lava.t("Control attribute is not allowed on sugar: " + name);
}
}
if ('label' in x) this.setViewConfigLabel(widget_config, x.label);
if ('roles' in x) widget_config.roles = Lava.parsers.Common.parseTargets(x.roles);
if ('resource_id' in x) widget_config.resource_id = Lava.parsers.Common.parseResourceId(x.resource_id);
if ('controller' in x) widget_config.real_class = x.controller;
}
return widget_config;
} | javascript | {
"resource": ""
} | |
q34442 | train | function(raw_blocks, widget_config) {
var i = 0,
count = raw_blocks.length,
result = [];
for (; i < count; i++) {
if (raw_blocks[i].type == 'directive') {
if (Lava.parsers.Directives.processDirective(raw_blocks[i], widget_config, true)) Lava.t("Directive inside sugar has returned a value: " + raw_blocks[i].name);
} else {
result = raw_blocks.slice(i);
break;
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34443 | train | function(content_schema, raw_tag, widget_config) {
var tags = Lava.parsers.Common.asBlocks(raw_tag.content),
i = 0,
count,
tag_roles_map = content_schema.tag_roles,
tag_schema,
storage_tags = [];
tags = this._applyTopDirectives(tags, widget_config);
count = tags.length;
for (; i < count; i++) {
if (tags[i].name in tag_roles_map) {
tag_schema = tag_roles_map[tags[i].name];
this[this._union_handlers[tag_schema.type]](tag_schema, tags[i], widget_config, tag_schema.name || tags[i].name);
} else {
storage_tags.push(tags[i]);
}
}
if (storage_tags.length) {
Lava.parsers.Storage.parse(widget_config, storage_tags);
}
} | javascript | {
"resource": ""
} | |
q34444 | train | function(widget_config, unknown_attributes, resource_name) {
var value = {
type: 'container_stack',
value: []
},
operations_stack = value.value;
if (!widget_config.resources) {
widget_config.resources = {};
}
if (!widget_config.resources['default']) {
widget_config.resources['default'] = {};
}
if ('class' in unknown_attributes) {
operations_stack.push({
name: 'add_classes',
value: unknown_attributes['class'].trim().split(/\s+/)
});
delete unknown_attributes['class'];
}
if ('style' in unknown_attributes) {
operations_stack.push({
name: 'add_styles',
value: Lava.parsers.Common.parseStyleAttribute(unknown_attributes.style)
});
delete unknown_attributes.style;
}
if (!Firestorm.Object.isEmpty(unknown_attributes)) {
operations_stack.push({
name: 'add_properties',
value: Firestorm.Object.copy(unknown_attributes) // copying to reduce possible slowdowns (object may contain deleted values)
});
}
Lava.resources.putResourceValue(widget_config.resources['default'], resource_name, value);
} | javascript | {
"resource": ""
} | |
q34445 | train | function(widget_config, attribute_value, descriptor, name) {
Lava.store(
widget_config,
'options',
name,
Lava.ExpressionParser.parse(attribute_value, Lava.ExpressionParser.SEPARATORS.SEMICOLON)
);
} | javascript | {
"resource": ""
} | |
q34446 | train | function() {
if (!this._mouseover_stack_changed_listener) {
Lava.view_manager.lendEvent('mouse_events');
this._mouseover_stack_changed_listener = Lava.view_manager.on('mouseover_stack_changed', this._onMouseoverStackChanged, this);
if (!this._tooltip) this._tooltip = Lava.createWidget(this.DEFAULT_TOOLTIP_WIDGET);
this._tooltip.inject(document.body, 'Bottom');
}
} | javascript | {
"resource": ""
} | |
q34447 | train | function() {
if (this._mouseover_stack_changed_listener) {
Lava.view_manager.releaseEvent('mouse_events');
Lava.view_manager.removeListener(this._mouseover_stack_changed_listener);
this._mouseover_stack_changed_listener = null;
if (this._mousemove_listener) {
Lava.Core.removeGlobalHandler(this._mousemove_listener);
this._mousemove_listener = null;
}
this._tooltip.set('is_visible', false);
this._tooltip.remove();
}
} | javascript | {
"resource": ""
} | |
q34448 | train | function(view_manager, stack) {
var new_tooltip_target = null,
html;
for (var i = 0, count = stack.length; i < count; i++) {
if (Firestorm.Element.hasAttribute(stack[i], this._attribute_name)) {
new_tooltip_target = stack[i];
break;
}
}
if (new_tooltip_target != this._tooltip_target) {
if (!this._tooltip_target) { // if there was no tooltip
if (Lava.schema.DEBUG && this._mousemove_listener) Lava.t();
this._mousemove_listener = Lava.Core.addGlobalHandler('mousemove', this._onMouseMove, this);
this._tooltip.set('is_visible', true);
} else if (!new_tooltip_target) { // if there was a tooltip, and now it should be hidden
Lava.Core.removeGlobalHandler(this._mousemove_listener);
this._mousemove_listener = null;
this._tooltip.set('is_visible', false);
}
if (new_tooltip_target) {
html = Firestorm.Element.getAttribute(new_tooltip_target, this._attribute_name).replace(/\r?\n/g, '<br/>');
this._tooltip.set('html', html);
this._tooltip.set('is_visible', !!(html || !Lava.schema.popover_manager.HIDE_EMPTY_TOOLTIPS));
}
this._tooltip_target = new_tooltip_target;
}
} | javascript | {
"resource": ""
} | |
q34449 | train | function(event_name, event_object) {
this._tooltip.set('x', event_object.page.x); // left
this._tooltip.set('y', event_object.page.y); // top
} | javascript | {
"resource": ""
} | |
q34450 | train | function () {
if (!this._focus_acquired_listener) {
this._focus_acquired_listener = Lava.app.on('focus_acquired', this._onFocusTargetAcquired, this);
this._focus_lost_listener = Lava.app.on('focus_lost', this.clearFocusedTarget, this);
this._focus_listener = Lava.Core.addGlobalHandler('blur', this._onElementBlurred, this);
this._blur_listener = Lava.Core.addGlobalHandler('focus', this._onElementFocused, this);
}
} | javascript | {
"resource": ""
} | |
q34451 | train | function() {
if (this._focus_acquired_listener) {
Lava.app.removeListener(this._focus_acquired_listener);
Lava.app.removeListener(this._focus_lost_listener);
Lava.Core.removeGlobalHandler(this._focus_listener);
Lava.Core.removeGlobalHandler(this._blur_listener);
this._focus_acquired_listener
= this._focused_element
= this._focus_target
= null;
}
} | javascript | {
"resource": ""
} | |
q34452 | train | function(event_name, event_object) {
if (this._focused_element != event_object.target) {
this._setTarget(null);
this._focused_element = event_object.target;
}
} | javascript | {
"resource": ""
} | |
q34453 | train | function(module, name, config, module_storage) {
this._module = module;
this._name = name;
this._config = config;
this._properties_by_guid = module_storage;
if ('is_nullable' in config) this._is_nullable = config.is_nullable;
} | javascript | {
"resource": ""
} | |
q34454 | train | function(properties, raw_properties) {
if (Lava.schema.data.VALIDATE_IMPORT_DATA && !this.isValidValue(raw_properties[this._name]))
Lava.t('Invalid value in import data (' + this._name + '): ' + raw_properties[this._name]);
return raw_properties[this._name];
} | javascript | {
"resource": ""
} | |
q34455 | train | function(record_a, record_b) {
return this._properties_by_guid[record_a.guid][this._name] < this._properties_by_guid[record_b.guid][this._name];
} | javascript | {
"resource": ""
} | |
q34456 | train | function(field, event_args) {
var local_record = event_args.collection_owner;
if (local_record.guid in this._collections_by_record_guid) {
Lava.suspendListener(this._collection_listeners_by_guid[local_record.guid].removed);
this._collections_by_record_guid[local_record.guid].removeValue(event_args.child);
Lava.resumeListener(this._collection_listeners_by_guid[local_record.guid].removed);
}
} | javascript | {
"resource": ""
} | |
q34457 | train | function(field, event_args) {
var local_record = event_args.collection_owner;
if (local_record.guid in this._collections_by_record_guid) {
Lava.suspendListener(this._collection_listeners_by_guid[local_record.guid].added);
this._collections_by_record_guid[local_record.guid].includeValue(event_args.child);
Lava.suspendListener(this._collection_listeners_by_guid[local_record.guid].added);
}
} | javascript | {
"resource": ""
} | |
q34458 | train | function(record, foreign_key) {
if (foreign_key in this._collections_by_foreign_id) {
this._collections_by_foreign_id[foreign_key].push(record);
} else {
this._collections_by_foreign_id[foreign_key] = [record];
}
} | javascript | {
"resource": ""
} | |
q34459 | train | function(foreign_module_id_field, event_args) {
var referenced_record = event_args.record, // record belongs to foreign module
new_referenced_id = referenced_record.get('id'),
collection,
i = 0,
count;
if (referenced_record.guid in this._collections_by_foreign_guid) {
collection = this._collections_by_foreign_guid[referenced_record.guid];
// Set the value of foreign ID field in all local records that reference this foreign record.
// Situation: there is a new record, which was created in the browser, and some records that reference it
// (either new or loaded from database). It's new, so there are no records on server that reference it.
if (this._foreign_key_field) {
Lava.suspendListener(this._foreign_key_changed_listener);
for (count = collection.length; i < count; i++) {
collection[i].set(this._foreign_key_field_name, new_referenced_id);
}
Lava.resumeListener(this._foreign_key_changed_listener);
}
}
} | javascript | {
"resource": ""
} | |
q34460 | train | function(record, properties, referenced_record_id) {
properties[this._name] = this._referenced_module.getRecordById(referenced_record_id) || null;
if (properties[this._name]) {
this._registerRecord(record, properties[this._name]);
}
} | javascript | {
"resource": ""
} | |
q34461 | train | function(local_record, referenced_record) {
if (!Firestorm.Array.exclude(this._collections_by_foreign_guid[referenced_record.guid], local_record)) Lava.t();
this._fire('removed_child', {
collection_owner: referenced_record,
child: local_record
});
} | javascript | {
"resource": ""
} | |
q34462 | train | function(local_record, referenced_record) {
var referenced_guid = referenced_record.guid;
if (referenced_guid in this._collections_by_foreign_guid) {
if (Lava.schema.DEBUG && this._collections_by_foreign_guid[referenced_guid].indexOf(local_record) != -1)
Lava.t("Duplicate record");
this._collections_by_foreign_guid[referenced_guid].push(local_record);
} else {
this._collections_by_foreign_guid[referenced_guid] = [local_record];
}
this._fire('added_child', {
collection_owner: referenced_record,
child: local_record
});
} | javascript | {
"resource": ""
} | |
q34463 | train | function(record) {
if (Lava.schema.DEBUG && !(record.guid in this._properties_by_guid)) Lava.t("isLess: record does not belong to this module");
var ref_record_a = this._properties_by_guid[record.guid][this._name];
// must return undefined, cause comparison against nulls behaves differently
return ref_record_a ? ref_record_a.get('id') : void 0;
} | javascript | {
"resource": ""
} | |
q34464 | train | function(config) {
var field_name,
type,
constructor;
for (field_name in config.fields) {
type = config.fields[field_name].type || Lava.schema.data.DEFAULT_FIELD_TYPE;
constructor = Lava.ClassManager.getConstructor(type, 'Lava.data.field');
this._fields[field_name] = new constructor(
this,
field_name,
config.fields[field_name],
this._properties_by_guid
);
}
} | javascript | {
"resource": ""
} | |
q34465 | train | function() {
var default_properties = {},
field_name;
for (field_name in this._fields) {
this._fields[field_name].onModuleFieldsCreated(default_properties);
}
this._createRecordProperties = new Function(
"return " + Lava.serializer.serialize(default_properties)
);
} | javascript | {
"resource": ""
} | |
q34466 | train | function(lava_app, config, name) {
this._app = lava_app;
this._config = config;
this._name = name;
this._createFields(config);
this._record_constructor = Lava.ClassManager.getConstructor(
config.record_class || Lava.schema.data.DEFAULT_RECORD_CLASS,
'Lava.data'
);
if ('id' in this._fields) {
this._has_id = true;
this._fields['id'].on('changed', this._onRecordIdChanged, this);
}
} | javascript | {
"resource": ""
} | |
q34467 | train | function(raw_properties) {
var result;
if (Lava.schema.DEBUG && !raw_properties.id) Lava.t('safeLoadRecord: import data must have an id');
if (raw_properties.id in this._records_by_id) {
result = this._records_by_id[raw_properties.id];
} else {
result = this.loadRecord(raw_properties);
}
return result;
} | javascript | {
"resource": ""
} | |
q34468 | train | function(raw_records_array) {
var i = 0,
count = raw_records_array.length,
records = [];
for (; i < count; i++) {
records.push(this._createRecordInstance(raw_records_array[i]));
}
this._fire('records_loaded', {records: records});
return records;
} | javascript | {
"resource": ""
} | |
q34469 | train | function(module, fields, properties_ref, raw_properties) {
this.guid = Lava.guid++;
this._module = module;
this._fields = fields;
this._properties = properties_ref;
var field;
if (typeof(raw_properties) != 'undefined') {
for (field in fields) {
fields[field]['import'](this, properties_ref, raw_properties);
}
} else {
for (field in fields) {
fields[field].initNewRecord(this, properties_ref);
}
}
} | javascript | {
"resource": ""
} | |
q34470 | train | function(config) {
if ('id' in config.fields) Lava.t("Id field in MetaStorage is not permitted");
this._config = config;
this._createFields(config);
this.initFields(); // MetaStorage is constructed directly, not via App class
var field;
if (Lava.schema.DEBUG) {
for (field in this._fields) {
if (this._fields[field].isCollectionField || this._fields[field].isRecordField)
Lava.t("Standard Collection and Record fields will not work inside the MetaStorage");
}
}
this._record_constructor = Lava.ClassManager.getConstructor('MetaRecord', 'Lava.data');
} | javascript | {
"resource": ""
} | |
q34471 | train | function(ext_guid, raw_properties, original_record) {
if (ext_guid in this._properties) Lava.t("MetaRecord already exists");
var properties = this._createRecordProperties(),
record = new this._record_constructor(this, this._fields, properties, raw_properties, original_record);
record.ext_guid = ext_guid;
this._records.push(record);
this._properties_by_guid[record.guid] = properties;
this._records_by_guid[record.guid] = record;
this._properties[ext_guid] = record;
this.firePropertyChangedEvents(ext_guid);
return record;
} | javascript | {
"resource": ""
} | |
q34472 | train | function(property_name) {
if (!(property_name in this._data_bindings_by_property)) {
this._data_bindings_by_property[property_name] = new Lava.scope.DataBinding(this, property_name);
}
return this._data_bindings_by_property[property_name];
} | javascript | {
"resource": ""
} | |
q34473 | train | function(path_config) {
var widget = this._widget.locateViewByPathConfig(path_config);
if (Lava.schema.DEBUG && !widget.isWidget) Lava.t("Tried to call a modifier from non-widget view");
return /** @type {Lava.widget.Standard} */ widget;
} | javascript | {
"resource": ""
} | |
q34474 | train | function() {
var result = null;
// in production - wrap evaluation into try/catch block
if (Lava.schema.DEBUG) {
result = this._evaluator();
} else {
try {
result = this._evaluator();
} catch (e) {
Lava.logException(e);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q34475 | train | function(index, arguments_array) {
return this._modifier_descriptors[index].widget.callModifier(this._modifier_descriptors[index].callback_name, arguments_array);
} | javascript | {
"resource": ""
} | |
q34476 | train | function(config, widget) {
this._widget = widget;
this._property_name = config.property_name;
this._scope = widget.getScopeByPathConfig(config.path_config);
if (config.from_widget) {
this._scope.setValue(this._widget.get(this._property_name));
} else {
this._widget.set(this._property_name, this._scope.getValue());
this._scope_changed_listener = this._scope.on('changed', this.onScopeChanged, this);
}
if (!this._scope.isSetValue) Lava.t("Binding: bound scope does not implement setValue");
this._widget_property_changed_listener = widget.onPropertyChanged(this._property_name, this.onWidgetPropertyChanged, this);
} | javascript | {
"resource": ""
} | |
q34477 | train | function() {
// avoid setting nulls to non-nullable fields.
if (this._scope.isConnected()) {
// turning off both of them to avoid infinite loop. From architect's point of view, better solution would be
// to hang up developer's browser, but if it happens in production - it may have disastrous consequences.
Lava.suspendListener(this._widget_property_changed_listener);
this._scope_changed_listener && Lava.suspendListener(this._scope_changed_listener);
this._widget.set(this._property_name, this._scope.getValue());
Lava.resumeListener(this._widget_property_changed_listener);
this._scope_changed_listener && Lava.resumeListener(this._scope_changed_listener);
}
} | javascript | {
"resource": ""
} | |
q34478 | train | function() {
Lava.suspendListener(this._widget_property_changed_listener);
this._scope_changed_listener && Lava.suspendListener(this._scope_changed_listener);
this._scope.setValue(this._widget.get(this._property_name));
Lava.resumeListener(this._widget_property_changed_listener);
this._scope_changed_listener && Lava.resumeListener(this._scope_changed_listener);
} | javascript | {
"resource": ""
} | |
q34479 | train | function(value_container, property_name) {
this.guid = Lava.guid++;
this._value_container = value_container;
this._property_name = property_name;
this.level = value_container.level + 1;
this._container_changed_listener = value_container.on('changed', this.onParentDataSourceChanged, this);
this._refreshValue();
Lava.schema.DEBUG && Lava.ScopeManager.debugTrackScope(this);
} | javascript | {
"resource": ""
} | |
q34480 | train | function() {
var property_container = this._value_container.getValue(),
value = null,
is_connected = false;
if (property_container != null) {
// Collection implements Properties, so if _property_name is not a number - then `get` will be called
if (property_container.isCollection && /^\d+$/.test(this._property_name)) {
if (this._enumerable_changed_listener == null) {
this._enumerable_changed_listener = property_container.on('collection_changed', this.onValueChanged, this);
this._property_container = property_container;
}
value = property_container.getValueAt(+this._property_name);
} else if (property_container.isProperties) {
if (this._property_changed_listener == null) {
this._property_changed_listener = property_container.onPropertyChanged(this._property_name, this.onValueChanged, this);
this._property_container = property_container;
}
value = property_container.get(this._property_name);
} else {
value = property_container[this._property_name];
}
is_connected = true;
}
if (value !== this._value || this._is_connected != is_connected) {
this._value = value;
this._is_connected = is_connected;
this._fire('changed');
}
} | javascript | {
"resource": ""
} | |
q34481 | train | function() {
if (this._property_changed_listener && (this._value_container.getValue() != this._property_container)) {
// currently listening to the parent's old data source
this._property_changed_listener && this._property_container.removePropertyListener(this._property_changed_listener);
this._enumerable_changed_listener && this._property_container.removeListener(this._enumerable_changed_listener);
this._property_changed_listener = null;
this._enumerable_changed_listener = null;
this._property_container = null;
}
this._queueForRefresh();
} | javascript | {
"resource": ""
} | |
q34482 | train | function(value) {
var property_container = this._value_container.getValue();
if (property_container) {
if (this._property_changed_listener) {
Lava.suspendListener(this._property_changed_listener);
property_container.set(this._property_name, value);
Lava.resumeListener(this._property_changed_listener);
} else if (this._enumerable_changed_listener) {
Lava.suspendListener(this._enumerable_changed_listener);
property_container.replaceAt(+this._property_name, value);
Lava.resumeListener(this._enumerable_changed_listener);
} else if (property_container.isProperties) {
property_container.set(this._property_name, value);
} else {
property_container[this._property_name] = value;
}
this._queueForRefresh();
}
} | javascript | {
"resource": ""
} | |
q34483 | train | function(argument, view, widget, config) {
var i = 0,
count,
depends,
bind;
this.guid = Lava.guid++;
this._argument = argument;
this._view = view;
this._widget = widget;
this.level = argument.level + 1;
if (config) {
if (Lava.schema.DEBUG && ['Enumerable', 'DataView'].indexOf(config['own_enumerable_mode']) == -1) Lava.t('Unknown value in own_enumerable_mode option: ' + config['own_enumerable_mode']);
if (config['own_enumerable_mode'] == "DataView") {
this._refreshDataSource = this._refreshDataSource_DataView;
this._value = new Lava.system.DataView();
} else {
this._refreshDataSource = this._refreshDataSource_Enumerable;
this._value = new Lava.system.Enumerable();
}
this._own_collection = true;
if (config['depends']) {
depends = config['depends'];
this._binds = [];
this._bind_changed_listeners = [];
for (count = depends.length; i < count; i++) {
if (depends[i].isDynamic) {
bind = view.locateViewByPathConfig(depends[i]).getDynamicScope(view, depends[i]);
} else {
bind = view.getScopeByPathConfig(depends[i]);
}
this._binds.push(bind);
this._bind_changed_listeners.push(bind.on('changed', this._onDependencyChanged, this));
}
}
}
this._argument_changed_listener = this._argument.on('changed', this.onDataSourceChanged, this);
this.refreshDataSource();
} | javascript | {
"resource": ""
} | |
q34484 | train | function() {
var argument_value = this._argument.getValue();
if (argument_value) {
this._refreshDataSource(argument_value);
if (this._observable_listener == null) {
if (argument_value.isCollection) {
this._observable_listener = argument_value.on('collection_changed', this._onObservableChanged, this);
this._observable = argument_value;
} else if (argument_value.isProperties) {
this._observable_listener = argument_value.on('property_changed', this._onObservableChanged, this);
this._observable = argument_value;
}
}
} else if (this._own_collection) {
this._value.removeAll();
} else {
// will be called only when "own_enumerable_mode" is off, cause otherwise this._own_collection is always true
this._createCollection(null);
}
this._fire('after_refresh');
this._fire('changed');
} | javascript | {
"resource": ""
} | |
q34485 | train | function(view, property_name, assign_config) {
this.guid = Lava.guid++;
this._view = view;
this._property_name = property_name;
if (assign_config) {
this._assign_argument = new Lava.scope.Argument(assign_config, view, view.getWidget());
this._assign_argument.on('changed', this.onAssignChanged, this);
this._value = this._assign_argument.getValue();
view.set(this._property_name, this._value);
this.level = this._assign_argument.level + 1;
} else {
// this is needed to order implicit inheritance
// (in custom widget property setters logic and in view.Foreach, while refreshing children).
// Zero was added to simplify examples from site documentation - it's not needed by framework
this.level = view.depth || 0;
this._value = view.get(this._property_name);
this._property_changed_listener = view.onPropertyChanged(property_name, this.onContainerPropertyChanged, this);
}
Lava.schema.DEBUG && Lava.ScopeManager.debugTrackScope(this);
} | javascript | {
"resource": ""
} | |
q34486 | train | function(value) {
Lava.suspendListener(this._property_changed_listener);
this._view.set(this._property_name, value);
Lava.resumeListener(this._property_changed_listener);
this._queueForRefresh();
} | javascript | {
"resource": ""
} | |
q34487 | train | function(container, name_source_container) {
if (Lava.schema.DEBUG && !name_source_container.isValueContainer) Lava.t();
if (Lava.schema.DEBUG && !name_source_container.guid) Lava.t("Name source for segments must be either PropertyBinding or DataBinding");
this._container = container;
this._property_name = name_source_container.getValue();
this._refreshDataBinding();
if (container.isRefreshable) {
this.level = container.level;
}
this.level = this.level > name_source_container.level ? this.level : name_source_container.level;
this.level++;
this._name_source_container = name_source_container;
this._name_source_changed_listener = name_source_container.on('changed', this.onPropertyNameChanged, this);
this._value = this._data_binding.getValue();
Lava.schema.DEBUG && Lava.ScopeManager.debugTrackScope(this);
} | javascript | {
"resource": ""
} | |
q34488 | train | function(view, config, widget) {
// About IOS bugfixes:
// http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
// http://www.quirksmode.org/blog/archives/2010/10/click_event_del_1.html
var needs_shim = Firestorm.Environment.platform == "ios";
Lava.ClassManager.patch(this, "Element", "addEventTarget", needs_shim ? "addEventTarget_IOS" : "addEventTarget_Normal");
Lava.ClassManager.patch(this, "Element", "informInDOM", needs_shim ? "informInDOM_IOS" : "informInDOM_Normal");
this.init_Normal(view, config, widget);
Lava.ClassManager.patch(this, "Element", "init", "init_Normal");
} | javascript | {
"resource": ""
} | |
q34489 | train | function(event_name, target) {
if (this._is_inDOM && event_name == 'click' && !(event_name in this._events)) {
this.getDOMElement().onclick = Lava.noop;
}
this.addEventTarget_Normal(event_name, target)
} | javascript | {
"resource": ""
} | |
q34490 | train | function(event_name, target) {
if (!(event_name in this._events)) {
this._events[event_name] = [target];
} else {
this._events[event_name].push(target);
}
} | javascript | {
"resource": ""
} | |
q34491 | train | function(name, value) {
if (Lava.schema.DEBUG && name == 'id') Lava.t();
if (Lava.schema.DEBUG && (name in this._property_bindings)) Lava.t("Property is bound to an argument and cannot be set directly: " + name);
this._static_properties[name] = value;
} | javascript | {
"resource": ""
} | |
q34492 | train | function(class_name, cancel_sync) {
if (Lava.schema.DEBUG && (!class_name || class_name.indexOf(' ') != -1)) Lava.t("addClass: expected one class name, got: " + class_name);
if (Firestorm.Array.include(this._static_classes, class_name)) {
if (this._is_inDOM && !cancel_sync) Firestorm.Element.addClass(this.getDOMElement(), class_name);
}
} | javascript | {
"resource": ""
} | |
q34493 | train | function(class_name, cancel_sync) {
if (Firestorm.Array.exclude(this._static_classes, class_name)) {
if (this._is_inDOM && !cancel_sync) Firestorm.Element.removeClass(this.getDOMElement(), class_name);
}
} | javascript | {
"resource": ""
} | |
q34494 | train | function(class_names, cancel_sync) {
if (Lava.schema.DEBUG && typeof(class_names) == 'string') Lava.t();
for (var i = 0, count = class_names.length; i < count; i++) {
this.addClass(class_names[i], cancel_sync);
}
} | javascript | {
"resource": ""
} | |
q34495 | train | function(name, value, cancel_sync) {
if (value == null) {
this.removeStyle(name, cancel_sync);
} else {
this._static_styles[name] = value;
if (this._is_inDOM && !cancel_sync) Firestorm.Element.setStyle(this.getDOMElement(), name, value);
}
} | javascript | {
"resource": ""
} | |
q34496 | train | function(name, cancel_sync) {
if (name in this._static_styles) {
delete this._static_styles[name];
if (this._is_inDOM && !cancel_sync) Firestorm.Element.setStyle(this.getDOMElement(), name, null);
}
} | javascript | {
"resource": ""
} | |
q34497 | train | function(configs, view, fn) {
var result = {},
argument;
for (var name in configs) {
argument = new Lava.scope.Argument(configs[name], view, this._widget);
result[name] = argument;
argument.on('changed', fn, this, {name: name})
}
return result;
} | javascript | {
"resource": ""
} | |
q34498 | train | function(argument, event_args, listener_args) {
if (this._is_inDOM) {
// note: escape will be handled by framework
var value = argument.getValue();
if (value != null && value !== false) {
if (value === true) {
value = listener_args.name;
}
Firestorm.Element.setProperty(this.getDOMElement(), listener_args.name, value);
} else {
Firestorm.Element.removeProperty(this.getDOMElement(), listener_args.name);
}
}
} | javascript | {
"resource": ""
} | |
q34499 | train | function(argument, event_args, listener_args) {
var value = this._style_bindings[listener_args.name].getValue() || '';
if (this._is_inDOM) Firestorm.Element.setStyle(this.getDOMElement(), listener_args.name, value.toString().trim());
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.