')
.addClass("column-header-recon-stats-bar")
.attr("title", title)
.appendTo(elmts.reconStatsContainer.show());
$('
')
.addClass("column-header-recon-stats-blanks")
.width(Math.round((stats.newTopics + stats.matchedTopics) * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
$('
')
.addClass("column-header-recon-stats-matched")
.width(Math.round(stats.matchedTopics * 100 / stats.nonBlanks) + "%")
.appendTo(whole);
}
}
};
DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
var self = this;
var menu = [
{
id: "core/facet",
label: $.i18n._('core-views/facet'),
width: "170px",
submenu: []
},
{},
{
id: "core/edit-cells",
label: $.i18n._('core-views/edit-cells'),
width: "170px",
submenu: []
},
{
id: "core/edit-column",
label: $.i18n._('core-views/edit-column'),
submenu: []
},
{
id: "core/transpose",
label: $.i18n._('core-views/transpose'),
submenu: []
},
{},
(
this._dataTableView._getSortingCriterionForColumn(this._column.name) === null ?
{
id: "core/sort",
"label": $.i18n._('core-views/sort')+"...",
"click": function() {
self._showSortingCriterion(null, self._dataTableView._getSortingCriteriaCount() > 0);
}
} :
{
id: "core/sort",
label: $.i18n._('core-views/sort'),
submenu: this.createSortingMenu()
}
),
{
id: "core/view",
label: $.i18n._('core-views/view'),
tooltip: $.i18n._('core-views/collapse-expand'),
submenu: [
{
label: $.i18n._('core-views/collapse-this'),
click: function() {
self._dataTableView._collapsedColumnNames[self._column.name] = true;
self._dataTableView.render();
}
},
{
label: $.i18n._('core-views/collapse-other'),
click: function() {
var collapsedColumnNames = {};
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
if (i != self._columnIndex) {
collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
}
self._dataTableView._collapsedColumnNames = collapsedColumnNames;
self._dataTableView.render();
}
},
{
label: $.i18n._('core-views/collapse-left'),
click: function() {
for (var i = 0; i < self._columnIndex; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
},
{
label: $.i18n._('core-views/collapse-right'),
click: function() {
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
}
]
},
{},
{
id: "core/reconcile",
label: $.i18n._('core-views/reconcile'),
tooltip: $.i18n._('core-views/reconcile-tooltip'),
width: "170px",
submenu: []
}
];
for (var i = 0; i < DataTableColumnHeaderUI._extenders.length; i++) {
DataTableColumnHeaderUI._extenders[i].call(null, this._column, this, menu);
}
MenuSystem.createAndShowStandardMenu(menu, elmt, { width: "120px", horizontal: false });
};
DataTableColumnHeaderUI.prototype.createSortingMenu = function() {
var self = this;
var criterion = this._dataTableView._getSortingCriterionForColumn(this._column.name);
var criteriaCount = this._dataTableView._getSortingCriteriaCount();
var hasOtherCriteria = (criterion === null) ? (criteriaCount > 0) : criteriaCount > 1;
var items = [
{
"label": $.i18n._('core-views/sort')+"...",
"click": function() {
self._showSortingCriterion(criterion, hasOtherCriteria);
}
}
];
if (criterion !== null) {
items.push({
"label": $.i18n._('core-views/reverse'),
"click": function() {
criterion.reverse = !criterion.reverse;
self._dataTableView._addSortingCriterion(criterion);
}
});
items.push({
"label": $.i18n._('core-views/remove-sort'),
"click": function() {
self._dataTableView._removeSortingCriterionOfColumn(criterion.column);
}
});
}
return items;
};
DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, hasOtherCriteria) {
criterion = criterion || {
column: this._column.name,
valueType: "string",
caseSensitive: false,
errorPosition: 1,
blankPosition: 2
};
var self = this;
var frame = $(DOM.loadHTML("core", "scripts/views/data-table/sorting-criterion-dialog.html"));
var elmts = DOM.bind(frame);
elmts.dialogHeader.text($.i18n._('core-views/sort-by')+' ' + this._column.name);
elmts.or_views_sortAs.text($.i18n._('core-views/sort-cell'));
elmts.or_views_positionBlank.text($.i18n._('core-views/pos-blank'));
elmts.or_views_text.text($.i18n._('core-views/text'));
elmts.or_views_caseSens.text($.i18n._('core-views/case-sensitive'));
elmts.or_views_numbers.text($.i18n._('core-views/numbers'));
elmts.or_views_dates.text($.i18n._('core-views/dates'));
elmts.or_views_booleans.text($.i18n._('core-views/booleans'));
elmts.or_views_dragDrop.text($.i18n._('core-views/drag-drop'));
elmts.directionForwardLabel.text($.i18n._('core-views/forward'));
elmts.directionReverseLabel.text($.i18n._('core-views/reverse'));
elmts.or_views_sortByCol.text($.i18n._('core-views/sort-by-col'));
elmts.okButton.html($.i18n._('core-buttons/ok'));
elmts.cancelButton.text($.i18n._('core-buttons/cancel'));
elmts.valueTypeOptions
.find("input[type='radio'][value='" + criterion.valueType + "']")
.attr("checked", "checked");
var setValueType = function(valueType) {
var forward = elmts.directionForwardLabel;
var reverse = elmts.directionReverseLabel;
if (valueType == "string") {
forward.html("a - z");
reverse.html("z - a");
} else if (valueType == "number") {
forward.html($.i18n._('core-views/smallest-first'));
reverse.html($.i18n._('core-views/largest-first'));
} else if (valueType == "date") {
forward.html($.i18n._('core-views/earliest-first'));
reverse.html($.i18n._('core-views/latest-first'));
} else if (valueType == "boolean") {
forward.html($.i18n._('core-views/false-true'));
reverse.html($.i18n._('core-views/true-false'));
}
};
elmts.valueTypeOptions
.find("input[type='radio']")
.change(function() {
setValueType(this.value);
});
if (criterion.valueType == "string" && criterion.caseSensitive) {
elmts.caseSensitiveCheckbox.attr("checked", "checked");
}
elmts.directionOptions
.find("input[type='radio'][value='" + (criterion.reverse ? "reverse" : "forward") + "']")
.attr("checked", "checked");
if (hasOtherCriteria) {
elmts.sortAloneContainer.show();
}
var validValuesHtml = '
'+$.i18n._('core-views/valid-values')+'';
var blankValuesHtml = ''+$.i18n._('core-views/blanks')+'';
var errorValuesHtml = ''+$.i18n._('core-views/errors')+'';
var positionsHtml;
if (criterion.blankPosition < 0) {
if (criterion.errorPosition > 0) {
positionsHtml = [ blankValuesHtml, validValuesHtml, errorValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ errorValuesHtml, blankValuesHtml, validValuesHtml ];
} else {
positionsHtml = [ blankValuesHtml, errorValuesHtml, validValuesHtml ];
}
} else {
if (criterion.errorPosition < 0) {
positionsHtml = [ errorValuesHtml, validValuesHtml, blankValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ validValuesHtml, errorValuesHtml, blankValuesHtml ];
} else {
positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ];
}
}
elmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection();
var level = DialogSystem.showDialog(frame);
var dismiss = function() { DialogSystem.dismissLevel(level - 1); };
setValueType(criterion.valueType);
elmts.cancelButton.click(dismiss);
elmts.okButton.click(function() {
var criterion2 = {
column: self._column.name,
valueType: elmts.valueTypeOptions.find("input[type='radio']:checked")[0].value,
reverse: elmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse"
};
var valuePosition, blankPosition, errorPosition;
elmts.blankErrorPositions.find("li").each(function(index, elmt) {
var kind = this.getAttribute("kind");
if (kind == "value") {
valuePosition = index;
} else if (kind == "blank") {
blankPosition = index;
} else if (kind == "error") {
errorPosition = index;
}
});
criterion2.blankPosition = blankPosition - valuePosition;
criterion2.errorPosition = errorPosition - valuePosition;
if (criterion2.valueType == "string") {
criterion2.caseSensitive = elmts.caseSensitiveCheckbox[0].checked;
}
self._dataTableView._addSortingCriterion(
criterion2, elmts.sortAloneContainer.find("input")[0].checked);
dismiss();
});
};