{"appearance":{"background":"white","padding":14,"font":{"family":"Courier New","size":10.0,"bold":false,"italic":false,"underline":false,"strikeout":false,"color":"rgb(0,72,168)"},"border":{"on":true,"size":0.0,"style":"solid","color":"#666"},"text":{"wrap":false,"hAlign":"left","vAlign":"top"}},"outputType":"WIDGET","widgetState":null,"outputs":{"console":"<pre class='debug-source'>>library(flipRegression)\n</pre>\n<pre class='debug-source'>>ConfusionMatrix(svm, QFilter, QPopulationWeight)\n</pre>\r\n<div class=\"debug-summarystatistics\">\r\n<table>\r\n<tr><th>Total time:</th><td>0.91s</td></tr>\r\n<tr><th>Time on R server:</th><td title=\"rApacheServe 0.89s (pre 0.00s, post 0.00s) httpget_code() setup for eval 0.03s session$eval 0.85s (pre 0.00s, post 0.04s) unexplained 0.01s apparmor forking (pre 0.02s, post 0.00s)\">0.89s</td></tr>\r\n<tr><th>Time evaluating code:</th><td>0.79s</td></tr>\r\n<tr><th>Bytes sent:</th><td>39,632</td></tr>\r\n<tr><th>Bytes received:</th><td>7,301</td></tr>\r\n</table>\r\n</div>","htmlwidgets":"<div id=\"htmlwidget_container\">\n <div id=\"htmlwidget-8eb66299db3dfc349245\" style=\"width:960px;height:500px;\" class=\"rhtmlHeatmap html-widget\"></div>\n</div>\n<script type=\"application/json\" data-for=\"htmlwidget-8eb66299db3dfc349245\">{\"x\":{\"rows\":null,\"cols\":null,\"matrix\":{\"data\":[\"11\",\"5\",\"0\",\"0\",\"0\",\"0\",\"7\",\"8\",\"0\",\"0\",\"0\",\"0\",\"3\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"3\",\"0\",\"1\",\"0\",\"1\",\"1\",\"3\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"8\"],\"dim\":[6,6],\"rows\":[\"1\",\"2\",\"3\",\"5\",\"6\",\"7\"],\"cols\":[\"1\",\"2\",\"3\",\"5\",\"6\",\"7\"],\"cells_to_hide\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"cellnote_in_cell\":[\"11\",\"5\",\"0\",\"0\",\"0\",\"0\",\"7\",\"8\",\"0\",\"0\",\"0\",\"0\",\"3\",\"1\",\"0\",\"0\",\"0\",\"0\",\"0\",\"3\",\"0\",\"1\",\"0\",\"1\",\"1\",\"3\",\"0\",\"0\",\"0\",\"0\",\"1\",\"0\",\"0\",\"0\",\"0\",\"8\"]},\"image\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAXklEQVQImWNIZ+D9/6cy4v//rx9QMOMbC+3/T198ZdC7eoEBGTD+2TLjP5OREwMjvxiKBBOzYwTDv3P7GBgYGBj+f3wFp5lgHAYGBrguRn4xBsZ/z279RzfmkrYBAwA+/C+p+CB9MgAAAABJRU5ErkJggg==\",\"theme\":null,\"options\":{\"xaxis_height\":80,\"yaxis_width\":120,\"xaxis_font_size\":11.06,\"yaxis_font_size\":11,\"xaxis_location\":\"top\",\"yaxis_location\":\"left\",\"xaxis_title\":\"Predicted\",\"yaxis_title\":\"Observed\",\"xaxis_title_font_size\":14,\"yaxis_title_font_size\":14,\"xaxis_hidden\":false,\"yaxis_hidden\":false,\"xaxis_font_family\":\"sans-serif\",\"yaxis_font_family\":\"sans-serif\",\"title\":\"Prediction-Accuracy Table: Type\",\"title_font_size\":24,\"title_font_family\":\"sans-serif\",\"title_font_color\":\"#000000\",\"footer\":\"Fitted model : n = 116 cases used in estimation of a total sample size of 149 (Training split_0.70_TmKiE); cases containing missing values have been excluded; 53 observed/predicted pairs with 52.83% accuracy;\",\"footer_font_size\":11,\"footer_font_family\":\"sans-serif\",\"footer_font_color\":\"#000000\",\"tip_font_size\":11,\"brush_color\":\"#0000FF\",\"show_grid\":true,\"legend_font_size\":11,\"x_is_factor\":false,\"legend_colors\":[\"#67000D\",\"#71010F\",\"#7B0310\",\"#850612\",\"#8F0813\",\"#990B14\",\"#A40F15\",\"#AA1016\",\"#B01217\",\"#B71319\",\"#BD151A\",\"#C3161B\",\"#C9181D\",\"#CF1D1F\",\"#D52421\",\"#DB2924\",\"#E12F26\",\"#E73429\",\"#ED392B\",\"#F0412F\",\"#F24934\",\"#F45139\",\"#F6593E\",\"#F86043\",\"#FA6748\",\"#FB6E4D\",\"#FC7454\",\"#FC7B5A\",\"#FC8261\",\"#FC8867\",\"#FC8E6E\",\"#FC9575\",\"#FD9B7C\",\"#FDA284\",\"#FDA98C\",\"#FDAF93\",\"#FCB69B\",\"#FCBDA3\",\"#FDC3AB\",\"#FDC9B3\",\"#FECFBB\",\"#FED5C3\",\"#FEDBCB\",\"#FEE0D3\",\"#FEE4D7\",\"#FFE7DC\",\"#FFEBE1\",\"#FFEEE6\",\"#FFF2EB\",\"#FFF5F0\"],\"legend_range\":[0,11],\"legend_width\":60,\"legend_digits\":1,\"shownote_in_cell\":true,\"cell_font_size\":11,\"left_columns\":null,\"left_columns_font_size\":11,\"right_columns\":null,\"right_columns_font_size\":11,\"extra_tooltip_info\":{\"% cases\":[\"20.75% of all cases\",\" 9.43% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\"13.21% of all cases\",\"15.09% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 5.66% of all cases\",\" 1.89% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 5.66% of all cases\",\" 0.00% of all cases\",\" 1.89% of all cases\",\" 0.00% of all cases\",\" 1.89% of all cases\",\" 1.89% of all cases\",\" 5.66% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 1.89% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\" 0.00% of all cases\",\"15.09% of all cases\"],\"% Predicted\":[\" 47.83% of Predicted class\",\" 25.00% of Predicted class\",\"-\",\"-\",\"-\",\"-\",\" 30.43% of Predicted class\",\" 40.00% of Predicted class\",\"-\",\"-\",\"-\",\"-\",\" 13.04% of Predicted class\",\" 5.00% of Predicted class\",\"-\",\"-\",\"-\",\"-\",\"-\",\" 15.00% of Predicted class\",\"-\",\"100.00% of Predicted class\",\"-\",\" 11.11% of Predicted class\",\" 4.35% of Predicted class\",\" 15.00% of Predicted class\",\"-\",\"-\",\"-\",\"-\",\" 4.35% of Predicted class\",\"-\",\"-\",\"-\",\"-\",\" 88.89% of Predicted class\"],\"% Observed\":[\"68.75% of Observed class\",\"31.25% of Observed class\",\"-\",\"-\",\"-\",\"-\",\"46.67% of Observed class\",\"53.33% of Observed class\",\"-\",\"-\",\"-\",\"-\",\"75.00% of Observed class\",\"25.00% of Observed class\",\"-\",\"-\",\"-\",\"-\",\"-\",\"60.00% of Observed class\",\"-\",\"20.00% of Observed class\",\"-\",\"20.00% of Observed class\",\"25.00% of Observed class\",\"75.00% of Observed class\",\"-\",\"-\",\"-\",\"-\",\"11.11% of Observed class\",\"-\",\"-\",\"-\",\"-\",\"88.89% of Observed class\"]},\"anim_duration\":500,\"yclust_width\":0,\"xclust_height\":0}},\"evals\":[],\"jsHooks\":[]}</script>\n<script type=\"application/htmlwidget-sizing\" data-for=\"htmlwidget-8eb66299db3dfc349245\">{\"viewer\":{\"width\":450,\"height\":350,\"padding\":5,\"fill\":true},\"browser\":{\"width\":960,\"height\":500,\"padding\":5,\"fill\":true}}</script>","htmlwidget-head":"{\"stylesheets\":[\"https://rserverhtmlwidgetasset.azureedge.net/heatmapcore-0b0c3c977a3de18d1ff639e311c1249c.css\"],\"javascript\":[\"https://rserverhtmlwidgetasset.azureedge.net/htmlwidgets-d2ab507a7e7d3e3d7c2178bda9d4c762.js\",\"https://rserverhtmlwidgetasset.azureedge.net/d3.min-fe2151217025e25f119e69ca126390f4.js\",\"https://rserverhtmlwidgetasset.azureedge.net/heatmapcore-52fec512e96634cbdcb7f463d60b06e5.js\",\"https://rserverhtmlwidgetasset.azureedge.net/index-1868b419773570135e12157d84680fcc.js\",\"https://rserverhtmlwidgetasset.azureedge.net/rhtmlHeatmap-fce4de827a4fdb1bd7d1317d03394668.js\"],\"attachments\":[]}","message":"","warning":"","table":"{\"Dimensions\":[{\"IsStatistic\":true,\"Elements\":[{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement0\",\"Name\":\"1\",\"WrappedName\":[\"1\"],\"IsText\":false},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement1\",\"Name\":\"2\",\"WrappedName\":[\"2\"],\"IsText\":false},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement2\",\"Name\":\"3\",\"WrappedName\":[\"3\"],\"IsText\":false},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement3\",\"Name\":\"5\",\"WrappedName\":[\"5\"],\"IsText\":false},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement4\",\"Name\":\"6\",\"WrappedName\":[\"6\"],\"IsText\":false},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement5\",\"Name\":\"7\",\"WrappedName\":[\"7\"],\"IsText\":false}],\"Id\":\"StatisticsDimensionID\",\"Name\":\"Predicted\",\"WrappedName\":null,\"Tiers\":[],\"Count\":6},{\"IsStatistic\":false,\"Elements\":[{\"Id\":\"RowDimensionElement0\",\"Name\":\"1\",\"WrappedName\":[\"1\"]},{\"Id\":\"RowDimensionElement1\",\"Name\":\"2\",\"WrappedName\":[\"2\"]},{\"Id\":\"RowDimensionElement2\",\"Name\":\"3\",\"WrappedName\":[\"3\"]},{\"Id\":\"RowDimensionElement3\",\"Name\":\"5\",\"WrappedName\":[\"5\"]},{\"Id\":\"RowDimensionElement4\",\"Name\":\"6\",\"WrappedName\":[\"6\"]},{\"Id\":\"RowDimensionElement5\",\"Name\":\"7\",\"WrappedName\":[\"7\"]}],\"Id\":\"RowCategoricalDimension\",\"Name\":\"Observed\",\"WrappedName\":null,\"Tiers\":[],\"Count\":6}],\"DataPoints\":[[{\"Value\":11.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":7.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":3.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":1.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":1.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":5.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":8.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":1.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":3.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":3.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":1.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":1.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":0.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":8.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}]],\"Settings\":{\"CellDimensionId\":null,\"RowDimensionsIds\":[\"RowCategoricalDimension\"],\"ColumnDimensionsIds\":[\"StatisticsDimensionID\"],\"ColumnHeadersHidden\":false,\"Title\":null,\"Footnote\":null,\"IsRowHeadersSortable\":false,\"IsColumnHeadersSortable\":true,\"HeaderSorts\":[],\"IsRowHeadersFilterable\":false,\"IsColumnHeadersFilterable\":true,\"HeaderFilters\":[],\"PaginationParameters\":null,\"TableStyleCssClass\":\"style-97ba0187-37c0-47a1-a4ad-31b0f5281e77-1-_-_\",\"LiveTableFormat\":{},\"AvailableWidth\":576,\"AvailableHeight\":512,\"TableWidth\":null}}","visible":"yes"},"secondsTaken":0.9078869,"updated":"2017-03-24T00:25:23.6901809Z","lastUpdatedMessage":null,"executedCode":"library(flipRegression)\nConfusionMatrix(svm, QFilter, QPopulationWeight)","lastSavedCode":"library(flipRegression)\nConfusionMatrix(svm, QFilter, QPopulationWeight)","highlightedCodeSpans":[{"start":40,"length":3,"index":2},{"start":45,"length":7,"index":6},{"start":54,"length":17,"index":6}],"tableTransformations":"<TabularTransformer>\r\n <TabularTransform type=\"Truncation\" truncationHeaderType=\"Column\" />\r\n <TabularTransform />\r\n</TabularTransformer>","tabularFilteringOptions":null,"hasGuiControls":false,"guiControls":{"Code":"","JSError":null,"JSErrorDetails":null,"ControlDefinitionErrors":null,"InputValidationErrors":null,"Controls":[{"ItemGuid":"00000000-0000-0000-0000-000000000000","ControlName":null,"Type":null,"Label":null,"Value":null,"Allowed":null,"EmptyListMessage":null,"Multi":false,"Prompt":null,"ErrorMessage":null,"Invalid":null,"Required":false,"AllowedTypes":null,"MinInputs":0,"MaxInputs":0,"Height":0,"Duplicates":false,"Values":null,"CheckAlign":null,"Text":null,"Increment":0.0,"Min":0.0,"Max":0.0,"Vertical":true}]},"calculating":"Idle","showDebug":false,"layout":"OutputOnly","size":{"Width":576,"Height":512},"vSplit":0.25,"hSplit":0.45,"updateWarnings":true,"updateMode":"Automatic","warnSlow":true,"outputSize":{"Width":576,"Height":512},"Options":{"debugconsole":false,"codeposition":"OutputOnly","size":{"width":576,"height":512},"splitH":0.45,"splitV":0.25,"update warnings":true,"updating":"Automatic","warn slow":true}}
\n' // avoid explicitly writing the end-script tag so this code can safely be written into the body of an embedding
+ '\n'
+ (Util.isForScreenshot() ? '\n' : '\n')
+ body
+ '\n' // avoid explicitly writing the end-script tag so this code can safely be written into the body of an embedding
+ '\n'
+ '';
this._iframe = document.createElement('iframe');
this._iframe.className = 'r-htmlwidget-iframe'; // so we can style the iframe
this._rItemGui.addElement($(this._iframe), false);
setTimeout(function () {
if (!$(_this._iframe).existsInDom())
return;
var iframe = _this._iframe;
var iframe_window = _this._iframe.contentWindow;
var iframe_document = _this._iframeDocument();
if (!iframe_document || !iframe_window)
return;
iframe_document.open();
iframe_document.write(html);
iframe_document.close();
if (Util.isDesktop() || Environment.isEditor) {
var set_state_changed_hook = function () {
if (document.body.contains(iframe) && !iframe_window.failedToLoadScripts) {
if (iframe_window.HTMLWidgets) {
iframe_window.HTMLWidgets.stateChangedHook = function (new_state) { return _this._widgetStateChanged(new_state); };
}
else {
bugLog("HTMLWidgets is not yet available");
setTimeout(set_state_changed_hook, 100);
}
}
};
setTimeout(set_state_changed_hook, 0, "set_state_changed_hook");
}
else {
}
if (!iframe_window.qInterceptAjax && iframe_window.XMLHttpRequest) {
var proxy_send = iframe_window.XMLHttpRequest.prototype.send;
iframe_window.XMLHttpRequest.prototype.send = function () {
iframe_window.qInterceptAjaxOutstanding++;
var xhr = this;
if (xhr.addEventListener) {
xhr.addEventListener("readystatechange", function () {
if (xhr.readyState === 4)
iframe_window.qInterceptAjaxOutstanding--;
}, false);
}
else {
var proxy_onreadystatechange = xhr.onreadystatechange;
xhr.onreadystatechange = function () {
if (xhr.readyState === 4)
iframe_window.qInterceptAjaxOutstanding--;
proxy_onreadystatechange();
};
}
return proxy_send.apply(xhr, [].slice.call(arguments));
};
var proxy_abort = iframe_window.XMLHttpRequest.prototype.abort;
iframe_window.XMLHttpRequest.prototype.abort = function () {
iframe_window.qInterceptAjaxOutstanding--;
var xhr = this;
return proxy_abort.apply(xhr, [].slice.call(arguments));
};
iframe_window.qInterceptAjaxOutstanding = 0;
iframe_window.qInterceptAjax = true;
}
_this._rItemGui.reZoomOutput();
setTimeout(function () {
var DOMContentLoaded_event = iframe_document.createEvent("Event");
DOMContentLoaded_event.initEvent("DOMContentLoaded", true, true);
window.document.dispatchEvent(DOMContentLoaded_event);
}, 100);
setTimeout(function () {
_this._rItemGui.outputReadyForTraining = true;
if (App.ui.inspector)
App.ui.inspector.update("output Ready for training after reload");
}, 1000);
}, 0, "rendering R widget");
}
this._currentWidgetBody = body;
this._currentWidgetHead = head;
this._currentWidgetState = widget_state_json;
};
HtmlwidgetContainer.prototype._iframeDocument = function () {
var iframe_window = this._iframe.contentWindow;
return iframe_window ? iframe_window.document : (this._iframe.contentDocument && this._iframe.contentDocument.document) ? this._iframe.contentDocument.document : this._iframe.contentDocument;
};
HtmlwidgetContainer.prototype._widgetStateChanged = function (new_state) {
QServerRequestsCommon.SaveRItemWidgetState({
GUID: this._rItemGui.guids[0],
WidgetState: JSON.stringify(new_state),
SkipFeedbackFrom: {
Requests: [this._rItemGui.subscriptionRequest('GetRControls'),
this._rItemGui.subscriptionRequest('GetREditPreCalcStuff'),
this._rItemGui.subscriptionRequest('GetREditPostCalcStuff')]
}
});
};
HtmlwidgetContainer.prototype.getPendingOperations = function () {
var pending = new PendingOperations();
var widget_iframe = $('.r-htmlwidget-iframe');
if (widget_iframe.length) {
var widget_iframe_element = widget_iframe[0];
var widget_window = widget_iframe_element.contentWindow;
if (widget_window['failedToLoadScripts']) {
return pending;
}
if (!widget_window['HTMLWidgets']) {
pending.add('RItemGui', '', 'HTMLWidget not available');
return pending;
}
var widget_document = widget_iframe_element.contentDocument;
if (!widget_window['HTMLWidgets'].isRendered) {
pending.add('RItemGui', '', 'HTMLWidget not rendered. originalStaticRender set: ' + !!widget_window['originalStaticRender'] + '; HEAD=' + widget_document.head.outerHTML);
return pending;
}
var widget_readystate = widget_document.readyState;
if (widget_readystate !== 'complete') {
pending.add('RItemGui', '', 'HTMLWidget document readyState not complete', widget_readystate);
return pending;
}
var outstanding_ajax = widget_window['qInterceptAjaxOutstanding'] === undefined ? 0 : widget_window['qInterceptAjaxOutstanding'];
if (outstanding_ajax !== 0) {
pending.add('RItemGui', '', 'HTMLWidget outstanding ajax requests', outstanding_ajax);
return pending;
}
for (var i = 0; i < widget_document.images.length; i++) {
var img = widget_document.images[i];
if (!img.complete || img.naturalWidth === 0 || img.naturalHeight === 0) {
pending.add('RItemGui', '', 'HTMLWidget images not loaded');
return pending;
}
}
if ($('*', widget_iframe.contents()).is(function (index, element) { return element['__transition__']; })) {
pending.add('RItemGui', '', 'HTMLWidget d3 animations in progress');
return pending;
}
if (this._transitionsInProgress($('.leaflet-fade-anim .leaflet-tile-loaded', widget_iframe.contents()), 250)) {
pending.add('RItemGui', '', 'HTMLWidget CSS animations in progress');
return pending;
}
}
return pending;
};
/** Tracks when the given elements have finished their transitions.
* Because we are called in a polling manner, and there is only a
* transitionend event and no transitionstart event, we have no way of
* knowing when the native transitions end and must rely on setTimeouts. */
HtmlwidgetContainer.prototype._transitionsInProgress = function (elements, transition_length) {
var in_transition = false;
elements.each(function (index, elem) {
if (elem.attributes.getNamedItem('data-regrtest-transitioning')) {
in_transition = true;
}
else if (!elem.attributes.getNamedItem('data-regrtest-transitioned')) {
in_transition = true;
elem.setAttribute('data-regrtest-transitioning', '');
setTimeout(function () {
elem.removeAttribute('data-regrtest-transitioning');
elem.setAttribute('data-regrtest-transitioned', '');
}, transition_length);
}
});
return in_transition;
};
HtmlwidgetContainer.prototype.clear = function () {
this._currentWidgetHead = null;
this._currentWidgetBody = null;
this._currentWidgetState = null;
};
return HtmlwidgetContainer;
}());
;
// /Scripts/Dashboard/RItem/PreviewTooltipManager.ts
function getPreviewId(options) {
return (options.itemGuid
? "preview-tooltip-" + options.itemGuid
: "preview-tooltip-" + options.keywordLanguage + "-" + Util.clean(options.keyword) + "-" + options.triggerRectangle.left + "-" + options.triggerRectangle.top + "-" + options.triggerRectangle.right + "-" + options.triggerRectangle.bottom);
}
function previewOptionsToString(options) {
if (!options)
return "(null)";
return (options.itemGuid
? "preview for item: " + options.itemGuid + " hovered over: " + JSON.stringify(options.triggerRectangle)
: "preview for '" + options.keyword + "' in language: " + options.keywordLanguage + " hovered over: " + JSON.stringify(options.triggerRectangle));
}
var PreviewTooltipManager = (function () {
function PreviewTooltipManager() {
this.esc = null;
this._showing = null;
this.hide = function () { return undefined; };
}
PreviewTooltipManager.prototype.getShowing = function () {
if (this._showing && !this._showing.visible)
this._showing = null;
return this._showing;
};
PreviewTooltipManager.getTooltipClientArea = function () {
return $("#workarea-container,body.desktop .splitPanel-root > .splitPanel-left");
};
PreviewTooltipManager.prototype.showPreview = function (options) {
if (App.isDesktopDialog)
return;
if (Util.isSeleniumTesting())
return;
var showing = this.getShowing();
if (showing) {
if (showing.isSameAs(options))
return;
showing.hide();
this._showing = null;
}
var instance = new PreviewTooltipInstance(options);
instance.show();
this._showing = instance;
};
PreviewTooltipManager.prototype.clear = function () {
var showing = this.getShowing();
if (showing)
showing.hide();
this._showing = null;
$(".preview-tooltip").remove();
};
return PreviewTooltipManager;
}());
;
// /Scripts/Dashboard/RItem/PreviewTooltipInstance.ts
var PreviewTooltipInstance = (function () {
function PreviewTooltipInstance(options) {
this.options = options;
this.visible = false;
this._on_user_while_shown = null;
options.triggerRectangle = Util.rectify(options.triggerRectangle);
}
PreviewTooltipInstance.prototype.show = function () {
var _this = this;
if (this.visible)
return;
this.visible = true;
var id = getPreviewId(this.options);
this.tooltip = $("#" + id);
if (!this.tooltip.length) {
this.tooltip = $("");
PreviewTooltipManager.getTooltipClientArea().append(this.tooltip);
}
this.tooltip.css("display", "");
this.tooltip.css({ "opacity": 1, pointerEvents: 'all' });
this.tooltip.addClass("showing");
var finished_request = function () {
PreviewTooltipInstance.is_requesting = false;
var next = PreviewTooltipInstance._next_request;
PreviewTooltipInstance._next_request = null;
if (next)
next();
};
var make_request = function () {
PreviewTooltipInstance.is_requesting = true;
new PreviewContentLoader(_this).load().then(function () {
finished_request();
_this._updatePosition();
})["catch"](function (e) {
finished_request();
reportJavaScriptError(e);
});
};
if (!PreviewTooltipInstance.is_requesting)
setTimeout(make_request);
else
PreviewTooltipInstance._next_request = make_request;
this._monitorMouse();
this._updatePosition();
};
PreviewTooltipInstance.prototype._monitorMouse = function () {
var _this = this;
var hiding_timeout;
var last_distance_to_tooltip = Number.MAX_VALUE;
var shown_time = Date.now();
this._on_user_while_shown = function (event) {
if (!_this.visible)
throw new Error("should not receive mouse messages unless visible");
var tooltip_rect = _this.tooltip[0].getBoundingClientRect();
var is_over_tooltip = Util.inRect(Util.inflateRect(tooltip_rect, 8), event.pageX, event.pageY);
var trigger_rectangle = _this.options.triggerRectangle;
var is_over_hovered_element = Util.inRect(trigger_rectangle, event.pageX, event.pageY);
if (event.type === "mouseup") {
return;
}
if (event.type === "mousedown") {
if (!is_over_tooltip)
_this.hide();
return;
}
if ((Date.now() - shown_time) < 200)
return;
if (is_over_tooltip || is_over_hovered_element) {
clearTimeout(hiding_timeout);
hiding_timeout = 0;
_this.tooltip[0].style.pointerEvents = "initial";
return;
}
if (!hiding_timeout) {
last_distance_to_tooltip = Number.MAX_VALUE;
hiding_timeout = setTimeout(function () {
return _this.hide();
}, 300);
return;
}
var distance_to_tooltip = Util.distanceToRect(tooltip_rect, event.pageX, event.pageY);
if (distance_to_tooltip < last_distance_to_tooltip) {
clearTimeout(hiding_timeout);
hiding_timeout = setTimeout(function () {
return _this.hide();
}, 300);
}
last_distance_to_tooltip = distance_to_tooltip;
};
if (PreviewTooltipInstance.is_monitoring_mouse)
throw new Error("already monitoring mouse");
PreviewTooltipInstance.is_monitoring_mouse = true;
document.addEventListener("mousemove", this._on_user_while_shown, true);
document.addEventListener("mousedown", this._on_user_while_shown, true);
};
PreviewTooltipInstance.prototype.hide = function () {
var _this = this;
if (!this.visible)
return;
this.visible = false;
this.tooltip.removeClass("showing");
this.tooltip.css({ "opacity": 0, pointerEvents: 'none' });
if (!PreviewTooltipInstance.is_monitoring_mouse)
throw new Error("not monitoring mouse");
PreviewTooltipInstance.is_monitoring_mouse = false;
document.removeEventListener("mousemove", this._on_user_while_shown, true);
document.removeEventListener("mousedown", this._on_user_while_shown, true);
setTimeout(function () {
if (!_this.visible)
_this.tooltip.css("display", "none");
}, 0); // 0 because there is no CSS transition on opacity change; increase if animation used in future
};
PreviewTooltipInstance.prototype.isSameAs = function (options) {
if (Util.rectsAreEqual(this.options.triggerRectangle, options.triggerRectangle))
if (this.options.keyword === options.keyword)
if (this.options.itemGuid === options.itemGuid)
if (this.options.keywordLanguage === options.keywordLanguage)
return true;
return false;
};
PreviewTooltipInstance.prototype._updatePosition = function () {
var trigger_rectangle = this.options.triggerRectangle;
var tooltip = this.tooltip;
var workarea_container = PreviewTooltipManager.getTooltipClientArea();
var workarea_container_rect = workarea_container[0].getBoundingClientRect();
var tooltip_rect = tooltip[0].getBoundingClientRect();
var content = tooltip.find(".preview-content");
var internal_padding = 12;
var border = 1;
var tooltip_height = content.length ? (content.height() + 2 * (internal_padding + border)) : tooltip_rect.height;
bugLog("PreviewTooltipInstance::_updatePosition: top: " + trigger_rectangle.top);
var top = trigger_rectangle.top - workarea_container_rect.top;
var overflow = top + tooltip_height - workarea_container_rect.height;
if (overflow > 0)
top -= overflow;
var padding = 4;
top = Math.max(padding, top);
var scrolled_top = workarea_container.scrollTop();
var css = {
top: top + scrolled_top
};
var is_align_left = trigger_rectangle.left < (workarea_container_rect.left + workarea_container_rect.right) / 2;
var scrolled_left = workarea_container.scrollLeft();
if (is_align_left)
css.left = scrolled_left;
else
css.right = -scrolled_left;
var max_height = workarea_container_rect.height - padding * 2;
if (tooltip_rect.height > max_height)
css.bottom = (padding - scrolled_top);
css.maxWidth = workarea_container.width() - (padding * 2 + internal_padding + border) * 2;
tooltip.css(css);
};
return PreviewTooltipInstance;
}());
PreviewTooltipInstance.is_requesting = false;
PreviewTooltipInstance.is_monitoring_mouse = false;
;
// /Scripts/Dashboard/RItem/PreviewContentLoader.ts
var PreviewContentLoader = (function () {
function PreviewContentLoader(instance) {
this.instance = instance;
}
PreviewContentLoader.prototype.load = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this.instance.tooltip.hasClass("preview-has-content")) {
setTimeout(function () {
return resolve($(_this.instance.tooltip.children()[0]));
});
return;
}
var options_reject = {
error: function () { return reject(new AbortException()); } // network errors handled by $.rAjax wrapper; we now just abort the stack
};
var option_resolve = function (result) {
var tooltip = _this.instance.tooltip;
var options = _this.instance.options;
if (!options || !tooltip || !result) {
resolve($(""));
return;
}
var jq = _this._formatResult(result);
tooltip.empty();
tooltip.removeClass(options.keyword ? "preview-from-item" : "preview-from-keyword");
tooltip.addClass(options.keyword ? "preview-from-keyword" : "preview-from-item");
tooltip.addClass("preview-has-content");
var content = $("");
content.append(jq);
tooltip.append(content);
resolve(jq);
};
var selection = App.getSelection()[0];
var selected_guid = selection ? selection.guid : null;
QServerRequestsCommon.GetPreview({
Guid: _this.instance.options.itemGuid, KeywordFromGuid: selected_guid, Keyword: _this.instance.options.keyword
}, function (response) {
return option_resolve(response.Result);
}, options_reject);
});
};
PreviewContentLoader.prototype._formatResult = function (result) {
if (!result || !result.Info)
return $("");
var info_data = result.Info;
if (info_data.type === "documentation")
return $("").append(Util.htmlDocument(result.Documentation));
var result_jq = $("");
var item = App.resolve(info_data.guid);
var header_jq = $("");
if (info_data.title) {
header_jq.append("
";
header_jq.append($(error_html));
}
if (info_data.subtype)
this._addInfo(header_jq, "Type:", String(info_data.subtype));
if (info_data.name && info_data.name !== info_data.title)
this._addInfo(header_jq, "Name:", info_data.name);
if (info_data.dataset)
this._addInfo(header_jq, "Data Set:", info_data.dataset);
if (info_data.modified)
this._addInfo(header_jq, "Last Modified:", String(info_data.modified));
if (info_data.length)
this._addInfo(header_jq, "Length:", String(info_data.length));
if (info_data.code)
this._addInfo(header_jq, "Code:", info_data.code);
if (info_data.output_types && info_data.output_types.length)
this._addInfo(header_jq, "Output Types:", info_data.output_types.join());
if (info_data.value)
this._addInfo(header_jq, "Value:", info_data.value);
header_jq.appendTo(result_jq);
if (result.TabularData) {
var data = result.TabularData;
if (data.Settings)
data.Settings.TableStyleCssClass = "";
var table = new Table(data);
var table_div = $('
').addClass('datagrid').append(table.tableJQ);
var tabular_div = $("");
tabular_div.append(table_div);
$(result_jq).append(tabular_div);
}
return result_jq;
};
PreviewContentLoader.prototype.jqForTags = function (tags) {
var jq = $("");
jq.append(this.jqForTag(tags.contains("Filter"), Translate("Filter")));
jq.append(this.jqForTag(tags.contains("Weight"), Translate("Weight")));
jq.append(this.jqForTag(tags.contains("Hidden"), Translate("Hidden")));
return jq;
};
PreviewContentLoader.prototype.jqForTag = function (on, text) {
var jq = $("
").addClass("tag").text(text);
if (on)
jq.addClass("is-set");
return jq;
};
PreviewContentLoader.prototype.getIconType = function (type, subtype) {
if (type === "Question")
return Item.getIconTypeForQuestion(subtype);
if (type === "Variable")
return Item.getIconTypeForVariable(subtype);
return subtype;
};
PreviewContentLoader.prototype._addInfo = function (header_jq, info_prompt, info_name) {
header_jq.append("
" + info_prompt + "
" + info_name + "
");
};
return PreviewContentLoader;
}());
;
// /Scripts/Dashboard/RItem/RItemPreviewer.ts
;
// /Scripts/Dashboard/RItem/RItemForwarding.ts
;
// /Scripts/Dashboard/RItem/RItemForwarder.ts
/**
* Sets up the standalone editing GUI for R items in desktop Q.
*
* The main entry points from C# are:
* enterRItem()
* leaveRItem()
*/
var RItemForwarder = (function () {
function RItemForwarder() {
var _this = this;
this._guis = [];
CommonStandalone.initEnvironmentFromUrlFragmentIdentifier();
var state = new RItemState(); // dummy - will be substituted later
this._notificationBar = new RItemNotificationBar(null, state);
App = new Application(Application.isForDataset() ? ApplicationContext.DesktopDialog : ApplicationContext.DesktopSelection);
App.ui.inspector = new ItemObjectInspector();
App.ui.notificationBar = this._notificationBar;
App.ui.previewer = new PreviewTooltipManager();
this.setupDecorations();
CommonStandalone.onChromePanelZoomProportionChanged(function (zoom) {
return _this.setZoom(zoom);
});
QServerRequestsCommon.NumberOfObjectsWhichAreOutOfDate(function (response) {
return _this.multipleOutputsAreOutOfDate(response.N > 1);
});
if (Util.isTesting())
Notify.onNotificationsChanged.add(function () {
return _this._onNotificationsChanged();
});
}
RItemForwarder.prototype.enterRItem = function (guids, zoom) {
var _this = this;
console.log("%centerRItem: " + guids.join("+"), Util.HighlightStyles.PageLifecycle);
clearTimeout(RItemForwarder.delayedEnterRItem);
if (!App.isDesktopDialog) {
var selection_exists_in_report_tree = guids.all(function (guid) { return !!App.resolve(guid); });
if (!selection_exists_in_report_tree) {
RItemForwarder.delayedEnterRItem = setTimeout(function () {
_this.enterRItem(guids, zoom);
});
return;
}
}
if (guids.length === 1) {
var guid = guids[0];
this.add(guid);
var _selected = this._selected;
this._guis = [_selected];
this.setZoom(zoom);
this.using(guid);
_selected.enterRItemForEditMode(guid);
return;
}
if (!this._multi) {
var state = new RItemState(); // should be multistate
this.setState(guids[0], state);
this._multi = new RItemMultiGui(this.getSelectedGuids(), this._jqCentre, state, this._notificationBar);
App.ui.inspector.setGui(this._multi);
this._multi.applyInitialState();
}
else {
this.setState(guids[0], this._multi.getState());
App.ui.inspector.setGui(this._multi);
}
App.ui.inspector.update("RItemForwarder:enterRItem");
this._multiItemSubscription = { Request: 'GetREditMultiItemStuff', GUIDs: guids };
Subscription.subscribe(this._multiItemSubscription, function (response) {
return _this._multi.refreshMultipleRItems(guids, response.StatusSummary, response.Options, zoom);
});
};
RItemForwarder.prototype.leaveRItem = function (guids, refresh_r_item) {
console.log("%cleaveRItem: " + guids.join("+"), Util.HighlightStyles.PageLifecycle);
clearTimeout(RItemForwarder.delayedEnterRItem);
if (!guids.length)
return;
if (guids.length === 1) {
var guid = guids[0];
var index = this.getSelectedGuids().indexOf(guid);
if (index !== -1) {
var gui = this.using(guid);
gui.leaveRItem(refresh_r_item, "RItemForwarder.leaveRItem called from c#");
gui.tearDownBody();
this._guis.splice(index, 1);
gui.detach();
}
return;
}
Subscription.unsubscribe(this._multiItemSubscription);
if (this._multi)
this._multi.leaveMulti();
};
RItemForwarder.prototype.regressionTestCancelledInProgressDisplay = function () {
this._guis.forEach(function (g) { return g.doneDisplaying(); });
};
RItemForwarder.prototype.setZoom = function (zoom) {
this._guis.forEach(function (g) { return g.setZoom(zoom); });
};
RItemForwarder.prototype.getSelectedGuids = function () {
return this._guis.map(function (g) { return g.guids[0]; });
};
RItemForwarder.prototype.add = function (guid) {
var index = this.getSelectedGuids().indexOf(guid);
if (index !== -1) {
this.selectRItem(this._guis[index]);
return this._selected;
}
var state = new RItemState();
this.setState(guid, state);
this._jqCentre.empty();
var gui = new RItemStandaloneGui(guid, this._jqCentre, state, this._notificationBar);
App.ui.inspector.setGui(gui);
gui.applyInitialState();
this._guis.push(gui);
this.selectRItem(gui);
return this._selected;
};
RItemForwarder.prototype.setState = function (guid, state) {
this._notificationBar.setState(guid, state);
};
RItemForwarder.prototype.setupDecorations = function () {
var _this = this;
var main_container = $('
');
if (Environment.isEditor) {
var instance_1 = App.ui.inspector.propertiesPage;
this._inputs_update_control = new RibbonItemUpdateControl("propertyUpdateMode_inputs", "", "", function () {
return instance_1.setPropertyValue("propertyUpdateMode", _this._inputs_update_control.value());
}, function () {
return instance_1.userRequestedUpdate();
});
var row = $("");
this._inputs_update_control.addToDialog(row);
row.appendTo(this._rControlsContainer);
this._rControls.appendTo(this._rControlsContainer);
this._rControlsContainer.append('
');
}
};
RItemGui.prototype.setZoom = function (new_zoom) {
this._zoom = new_zoom;
this.reZoomOutput();
};
RItemGui.prototype.reZoomOutput = function () {
if (this._zoom !== 1)
if (this._jqObj)
this._jqObj.children().css({
'transform': "scale(" + this._zoom + ")",
'transform-origin': '0 0'
});
};
RItemGui.prototype.workareaZoom = function (workarea_zoom) {
if (this.rItemCodeEditor)
this.rItemCodeEditor.workareaZoom(workarea_zoom);
};
RItemGui.prototype.displayInputValues = function (options, code, spans) {
this.setLastUpdatedText(Translate("calculating..."));
if (this._editMode)
this._notificationBar.clearWarnings();
this.setOptions(options);
this.highlightSpans(spans);
if (this._firstPreCalcStuff)
App.ui.inspector.selectionChanged();
};
/** Called by the CodeEditorCoordinator when the user changes the code
* in any code editor instance (may be multiple). Or the Q OLT tests
* have set code programmatically. */
RItemGui.prototype.editCode = function (guid, value) {
var _this = this;
this._lastEditedCode = RibbonCodeEditor.getRCode(guid);
var text = value === undefined ? this._lastEditedCode : value;
if (text === this._state.lastSavedCode) {
bugLog("skipping save because text === this._state.lastSavedCode");
return;
}
this._state.lastSavedCode = text;
QServerRequestsCommon.RItemAutoSave({
GUID: this.guids[0],
Code: text
});
QServerRequestsCommon.RItemRehighlightCode({
GUID: guid
}, function (response) {
_this._state.highlightedCodeSpans = response.Highlights;
if (_this._state.highlightedCodeSpans)
_this.highlightSpans(_this._state.highlightedCodeSpans);
});
};
RItemGui.prototype.highlightCode = function (guid) {
clearTimeout(this._state.highlightingTimer);
this._state.highlightingTimer = setTimeout(function () {
}, 500);
};
RItemGui.prototype.onUpdateClicked = function () {
var _this = this;
App.ui.inspector.commit();
this._updateClickedTimer = setTimeout(function () {
bugLogGroup("RItemGui::onUpdateClicked() timeout");
try {
if (!Application.isForDataset() &&
!Subscription.getSubscriptions()
.any(function (sub) { return (sub.request.Request === 'GetREditPreCalcStuff' &&
sub.request.GUID === _this.guids[0]) ||
(sub.request
.Request ===
'RenderItem' &&
sub.request.GUID === _this.guids[0]); })) {
bugLog('Subscriptions summary: ' + Subscription.summariseSubscriptions());
bugLog('R item guid: ' + _this.guids[0]);
reportJavaScriptError(new Error('RItemUpdateClicked requested when there is no subscription waiting on results! RS-1411'));
}
QServer.setNextRequestPleaseWaitShowDelay(1);
QServerRequestsCommon.ItemUpdateClicked({
GUID: _this.guids[0],
Code: null
}, function () {
_this.onAfterUpdateClicked();
_this.lastStatistics = QServer.lastStatistics;
});
}
finally {
bugLogGroupEnd();
}
});
};
RItemGui.prototype.onAfterUpdateClicked = function () {
if (Application.isForDataset())
this.requestAndDisplayOutput();
};
RItemGui.prototype.setOptions = function (options) {
this._state.setFromOptions(options);
this.setDebugVisibility(this._state.showDebug, false);
if (this._state.layoutRefreshRequired)
this.changeLayout(this._state.layout);
if (!Application.isForDataset())
this.resize(this._state.getISize());
if (!this._editMode)
return;
if (App.ui.inspector)
App.ui.inspector.update("RItemGui:setOptions");
if (Application.isForDataset())
return;
this._notificationBar.setState(this.guids[0], this._state);
this._notificationBar.warnSlow(this._state.warnSlow);
};
RItemGui.prototype.changeOptions = function (options, user_done_it) {
QServerRequestsCommon.SetItemsUi({
ActiveTab: App.isDesktop ? null : Dashboard.instance.getSelectedTab().guid,
GUIDs: this.getItemGuids(),
Value: options,
UserDoneIt: user_done_it
});
};
RItemGui.prototype.changeOption = function (key, value, user_done_it) {
var options = {};
options[key] = value;
return this.changeOptions(options, user_done_it);
};
RItemGui.prototype.resize = function (size) {
var box = $('div#{0} #resizable-box'.format(this.id()));
box.css({
width: size.width,
height: size.height
});
if (this.rItemCodeEditor && this._state.layout && this._state.layout !== Layout.OutputOnly)
this.rItemCodeEditor.refresh("resized");
};
RItemGui.prototype.onUserResizeStop = function (size) {
this.resizeOutput();
this.changeOption("size", size, true);
this._state.size = { Width: size.width, Height: size.height };
};
RItemGui.prototype.updateSplits = function (user_done_it) {
if (this._state.oldLayout === Layout.Left)
this._state.hSplit = this._hsplitter.leftPercent / 100;
else if (this._state.oldLayout === Layout.Top)
this._state.vSplit = this._vsplitter.topPercent / 100;
else if (this._state.oldLayout === Layout.Right)
this._state.hSplit = 1 - this._hsplitter.leftPercent / 100;
else if (this._state.oldLayout === Layout.Bottom)
this._state.vSplit = 1 - this._vsplitter.topPercent / 100;
this.changeOptions({
splitH: this._state.hSplit,
splitV: this._state.vSplit
}, user_done_it);
};
RItemGui.prototype.updateLayout = function (user_done_it) {
this.changeOption("codeposition", this._state.oldLayout, user_done_it);
if (this.rItemCodeEditor)
this.rItemCodeEditor.refresh("updatelayout");
};
RItemGui.getOutputTypeForChoice = function (choice) {
switch (choice.toLowerCase()) {
case "widget":
return OutputType.WIDGET;
case "help":
return OutputType.HELP;
case "plot":
return OutputType.PLOT;
case "table":
return OutputType.TABLE;
case "text":
return OutputType.TEXT;
case "error":
return OutputType.ERROR;
}
return undefined;
};
RItemGui.prototype.chooseOutputType = function (choice, user_done_it) {
this._state.outputType = RItemGui.getOutputTypeForChoice(choice) || this._state.outputType;
this.onOutputTypeChosen();
this.changeOption("output type", this._state.outputType, user_done_it);
};
RItemGui.prototype.onOutputTypeChosen = function () {
this._displayAppropriateOutput();
if (this._editMode) {
this._notificationBar.clearMustChooseOutputType();
this._notificationBar.clearMultipleOutputTypesNotification();
}
};
RItemGui.prototype.resizeOutput = function () {
var box = $('div#{0} #output'.format(this.id()));
QServerRequestsCommon.RItemOutputResize({
GUID: this.guids[0],
Width: box.width() ? box.width() : 1,
Height: box.height() ? box.height() : 1
});
};
RItemGui.prototype.modifyOutputSplitter = function (splitter) {
var _this = this;
splitter.onResize = function () {
return _this.rItemCodeEditor.refresh("modifyOutputSplitter");
};
splitter.onStopResize = function () {
_this.resizeOutput();
_this.updateSplits(true);
};
};
RItemGui.prototype.setMultipleOutputTypesNotification = function () {
if (this._editMode)
this._notificationBar.setMultipleOutputTypesNotification();
};
RItemGui.prototype.setAvailableOutputTypes = function (list, choice, enabled) {
if (!Environment.isEditor)
return;
var instance = App.ui.inspector.propertiesPage;
if (instance)
instance.setAvailableOutputTypes(list, choice, enabled);
if (this._editMode)
App.ui.inspector.setAvailableOutputTypes(list, choice, enabled);
};
RItemGui.availableOutputTypes = function (dict) {
var valid = {};
valid[OutputType.TABLE] = dict["table"] != null;
valid[OutputType.TEXT] = dict["text"] != null;
valid[OutputType.PLOT] = dict["plots"] != null;
valid[OutputType.ERROR] = dict["html-error"] != null;
valid[OutputType.WIDGET] = dict["htmlwidgets"] != null && dict["htmlwidget-head"] != null;
valid[OutputType.HELP] = dict["help"] != null;
return valid;
};
RItemGui.prototype.displayAvailableOutputTypes = function (valid) {
var _this = this;
var list = [];
if (valid[OutputType.WIDGET])
list.push("Widget");
if (valid[OutputType.HELP])
list.push("Help");
if (valid[OutputType.PLOT])
list.push("Plot");
if (valid[OutputType.TABLE])
list.push("Table");
if (valid[OutputType.TEXT])
list.push("Text");
if (this._state.listOfAvailableOutputTypes && this._state.listOfAvailableOutputTypes.length > 0
&& list.any(function (x) { return !_this._state.listOfAvailableOutputTypes.contains(x); }) && list.length > 1)
this.setMultipleOutputTypesNotification();
this._state.listOfAvailableOutputTypes = list;
var enabled = true;
var choice = '';
switch (this._state.outputType) {
case OutputType.WIDGET:
choice = "Widget";
break;
case OutputType.HELP:
choice = "Help";
break;
case OutputType.PLOT:
choice = "Plot";
break;
case OutputType.TABLE:
choice = "Table";
break;
case OutputType.TEXT:
choice = "Text";
break;
case OutputType.ERROR:
enabled = false;
break;
}
this.setAvailableOutputTypes(list, choice, enabled);
};
RItemGui.prototype.setOutputs = function (dict) {
var _this = this;
this.resetNotificationBar();
console.log("set outputs");
this._state.setOutputs(dict);
var valid = RItemGui.availableOutputTypes(dict);
if (!Application.isForDataset())
this.displayAvailableOutputTypes(valid);
else if (valid[OutputType.ERROR])
this._state.outputType = OutputType.ERROR;
else if (valid[OutputType.TABLE])
this._state.outputType = OutputType.TABLE;
else if (valid[OutputType.HELP])
this._state.outputType = OutputType.HELP;
else if (valid[OutputType.WIDGET])
this._state.outputType = OutputType.WIDGET;
else if (valid[OutputType.PLOT])
this._state.outputType = OutputType.PLOT;
else if (valid[OutputType.TEXT])
this._state.outputType = OutputType.TEXT;
else
this._state.outputType = OutputType.UNKNOWN;
this._showWarningsOnNotification(dict['warning'], 'WARNING'); // warnings are marked up with a "WARNING: " prefix: this is also referenced in ROutput.FilteredOutputs().
this._displayAppropriateOutput();
console.log("routput = " + this._state.outputType);
var render_timeout = dict["plots"] ? Math.max(100, dict["plots"].length / 2000) : 100;
switch (this._state.outputType) {
case OutputType.TABLE_PLOT:
case OutputType.TABLE:
setTimeout(function () {
_this.outputReadyForTraining = true;
if (App.ui.inspector)
App.ui.inspector.update("outputReadyForTraining");
}, render_timeout);
break;
case OutputType.WIDGET:
break;
case OutputType.TEXT_PLOT:
case OutputType.PLOT:
case OutputType.HELP:
case OutputType.TEXT:
case OutputType.ERROR:
case OutputType.UNKNOWN:
setTimeout(function () {
_this.outputReadyForTraining = true;
if (App.ui.inspector)
App.ui.inspector.update("outputReadyForTraining");
}, render_timeout);
break;
}
};
RItemGui.prototype._showWarningsOnNotification = function (warning, type) {
if (warning && App.isDesktopDialog)
this._notificationBar.addWarnings(warning, type);
};
RItemGui.prototype.setMustChooseOutputType = function (type1, type2) {
var _this = this;
if (this._editMode)
this._notificationBar.setMustChooseOutputType(type1, type2, function (choice) { return _this.chooseOutputType(choice, true); });
};
RItemGui.prototype._effectiveOutputType = function () {
var effective_output = this._state.outputType;
var outputs = this._state.getOutputs();
if (outputs && outputs["html-error"]
&& (this._state.updateMode === "Automatic"
|| this._state.outputType === OutputType.ERROR
|| this._state.outputType === OutputType.UNKNOWN))
effective_output = OutputType.ERROR;
return effective_output;
};
RItemGui.prototype._displayAppropriateOutput = function () {
console.log("debug console = " + this._state.outputType);
this._jqObj.removeClassesByRegExp(/routput-type-/);
var outputs = this._state.getOutputs();
if (outputs == null)
return;
this._jqConsole.empty();
var div = $('
').html(outputs["console"]).css("margin", "8px");
this._addPreloadHeader(div.children('div.debug-preloaded'));
this._jqConsole.append(div);
this._jqObj.addClass("routput-type-" + this._state.outputType);
if (this.wasEmptyRCode()) {
this.clear();
if (App.isDesktop)
this.addElement($('
').addClass('r-empty-output-text').html(Translate('Enter R code') + ' →'));
}
else {
this._jqObj.closest(".content.r-ritem").removeClass("empty-r-code");
switch (this._effectiveOutputType()) {
case OutputType.TABLE: {
if (outputs["table"] != null)
this.displayTable(outputs["table"]);
else
this._displayListOfTables(outputs["listoftables"]);
break;
}
case OutputType.TEXT:
this.displayText(outputs["text"], outputs["scalar"]);
break;
case OutputType.TEXT_PLOT:
case OutputType.PLOT:
this.displayPlot(outputs["plots"]);
break;
case OutputType.ERROR:
this._displayHtmlError(outputs["html-error"]);
break;
case OutputType.WIDGET:
this._htmlWidgetContainer.display(outputs["htmlwidget-head"], outputs["htmlwidgets"], this._state.widgetState);
break;
case OutputType.HELP:
this._displayEltHtml(outputs["help"]);
break;
case OutputType.TABLE_PLOT:
this.displayTableAndPlot(outputs["table"], outputs["plots"]);
this.setMustChooseOutputType("Table", "Plot");
break;
default:
this.clear();
break;
}
}
if (!Application.isForDataset())
this.applyAppearanceParameters(this._state.appearance, "RItemGui:_displayAppropriateOutput, with this._state.appearance");
};
RItemGui.prototype.isEmptyRCode = function () {
if (!this._state.lastSavedCode || !this._state.lastSavedCode.trim().length)
return true;
return false;
};
RItemGui.prototype.wasEmptyRCode = function () {
if (this.guids.length > 1)
return false;
var guid = this.guids[0];
var outputs = this._state.getOutputs();
if (outputs && this._state.outputType === OutputType.UNKNOWN) {
var item = App.resolve(guid);
if (!item)
return false; // this can happen in embedded modes - we return that there is no warning
var report_tree_item = new ReportTreeItem(item);
return report_tree_item.hasEmptyRCodeWarning();
}
return false;
};
RItemGui.prototype._addPreloadHeader = function (div) {
var arrow1 = "";
var arrow2 = "";
div.prepend($('
{0}
'.format(Translate("Preloaded Packages")))
.prepend(arrow1)
.prepend(arrow2));
div.children(".debug-preloaded-header,.arrow-expanded,.arrow-collapsed")
.hover(function (e) {
$(e.target)
.addClass("hover")
.siblings().addClass("hover");
}, function (e) {
$(e.target)
.removeClass("hover")
.siblings().removeClass("hover");
})
.click(function () {
var parent = $("div.debug-preloaded");
if (parent.hasClass("collapse"))
parent.removeClass("collapse");
else
parent.addClass("collapse");
});
};
RItemGui.prototype.addElement = function (elt, rezoom_now) {
if (rezoom_now === void 0) { rezoom_now = true; }
if (!this._jqObj)
this.clear();
this._jqObj.empty();
this._jqObj.append(elt);
if (rezoom_now)
this.reZoomOutput();
if (Util.isInternetExplorerVersionOrPrevious(11)) {
var plot_svg = elt.find('svg.ritem-image');
if (plot_svg.length) {
setTimeout(function () {
plot_svg = elt.find('svg.ritem-image');
if (plot_svg.length)
plot_svg.parent()[0].innerHTML = " " + plot_svg.parent()[0].innerHTML;
}, 0);
}
}
};
/** Display a table, by reading in an ITabularAdapter JSON string.
* This is used by the R item's main table output, and any preview tables
* shown in the bottom-right preview window. */
RItemGui.prototype.displayTable = function (json_table_data, parent) {
var outputs = this._state.getOutputs();
var additional_class = outputs ? outputs["table class"] : null;
this.createAndDisplayTableFromJsonData(json_table_data, additional_class, parent);
var data = JSON.parse(json_table_data);
var pagination = data.Settings.PaginationParameters;
if (pagination && pagination.EndElement - pagination.StartElement > 1)
this._jqObj.addClass('noVerticalScroll');
};
RItemGui.prototype.createAndDisplayTableFromJsonData = function (json_table_data, additional_class, parent) {
var table = new Table(JSON.parse(json_table_data));
var table_div = $('
');
table_div.addClass('datagrid');
if (!!additional_class)
table_div.addClass(additional_class);
table_div.append(table.tableJQ);
this.handleTableEvents(table);
if (!parent)
parent = this._jqObj;
if (!parent)
throw new Error("Expected parent to have a value");
parent.empty();
parent.append(table_div);
this.reZoomOutput();
if (this._state.tabularFilteringOptions)
table.populateFilterDialog(this._state.tabularFilteringOptions);
};
RItemGui.prototype.handleTableEvents = function (table) {
var _this = this;
table.tableJQ.on('tableaction', function (event, action) {
return QServerRequestsCommon.RItemTableAction({ Action: action, GUID: _this.guids[0] }, function () {
_this.onAfterTableAction();
});
});
table.tableJQ.on('tablefilteropen', function (event, header) {
return QServerRequestsCommon.RItemTableFilterOpen({ Header: header, GUID: _this.guids[0] }, function (response) {
table.populateFilterDialog(response.Options);
_this.outputReadyForTraining = true;
App.ui.inspector.update("output Ready for training");
});
});
};
RItemGui.prototype.onAfterTableAction = function () {
if (Application.isForDataset())
this.requestAndDisplayOutput();
};
RItemGui.prototype._displayListOfTables = function (html) {
this.clear();
var arrow1 = "";
var arrow2 = "";
var div = $('
')
.addClass("datagrid")
.html(html)
.css("border", "none");
div.children().prepend(arrow1).prepend(arrow2);
div.children().children(".datagridlabel,.datagridlabel-arrow,.arrow-expanded,.arrow-collapsed")
.hover(function (e) {
$(e.target)
.addClass("hover")
.siblings().addClass("hover");
}, function (e) {
$(e.target)
.removeClass("hover")
.siblings().removeClass("hover");
})
.click(function (e) {
var tgt = $(e.target);
var parent = tgt.parent();
if (tgt.is("path"))
parent = parent.parent().parent();
if (tgt.is("svg"))
parent = parent.parent();
if (parent.hasClass("collapse"))
parent.removeClass("collapse");
else
parent.addClass("collapse");
});
this.addElement(div);
};
RItemGui.prototype.subscribeToTableStyles = function () {
if (!Subscription.isSubscribed(this._tableStylesSubscriptionRequest)) {
Subscription.subscribe(this._tableStylesSubscriptionRequest, function (response) {
$('style[data-tableformatstyle]').remove();
$("").appendTo('head');
});
}
};
RItemGui.prototype.displayPlot = function (plot_html) {
this.clear();
if (plot_html === undefined && this._state.hasGuiControls && Util.isDesktop())
this.addElement($('
').addClass("ritem-pair-container");
this.displayTable(json_table_data, parent);
var plot = $('
').addClass("ritem-plots").append(this.plotElement(plot_html));
this.addElement(parent.append(plot));
};
RItemGui.prototype.plotElement = function (plot_html) {
if (plot_html !== undefined && plot_html !== null) {
var plot_id_1 = (RItemGui._nextPlotId++).toString() + "-";
plot_html = plot_html
.replace(/(id="glyph)(\d+-\d+")/g, function (m, p1, p2) { return p1 + plot_id_1 + p2; })
.replace(/(href="#glyph)(\d+-\d+")/g, function (m, p1, p2) { return p1 + plot_id_1 + p2; });
}
var div = $('
').html(plot_html);
div.find('svg').attr('class', 'ritem-image');
return div;
};
RItemGui.prototype.displayText = function (text, scalar_output_json) {
if (scalar_output_json) {
var output = JSON.parse(scalar_output_json);
text = JavaScriptItemHelper.decimalsToShow(output.value, output.decimalPlaces);
if (output.showPercentage)
text += '%';
else if (output.moneySymbol)
text = output.moneySymbol + text;
}
this.clear();
var div = $('
')
.addClass("ritem-text-output")
.text(text);
var parent = $('
')
.addClass("ritem-text-container")
.append(div);
this.addElement(parent);
};
RItemGui.prototype._displayHtmlError = function (text, additional_class) {
var _this = this;
if (additional_class === void 0) { additional_class = null; }
this.clear();
var div = $('
')
.addClass("ritem-text-error")
.html(text);
if (additional_class !== null)
div.addClass(additional_class);
this.addElement(div);
setTimeout(function () {
_this.outputReadyForTraining = true; // because when an error occurs, we won't receive the actual output
if (App.ui.inspector)
App.ui.inspector.update("error ready");
}, 100, "ready and output ready for training");
};
RItemGui.prototype._displayImage = function (image) {
this.addElement($('')
.addClass("ritem-image")
.attr("src", "data:image/png;base64," + image));
};
RItemGui.prototype._displayEltHtml = function (html) {
this.clear();
var div = $("
");
div.append(Util.htmlDocument(html));
div.css("margin", "8px");
this.addElement(div);
};
RItemGui.prototype.applyAppearanceParameters = function (appearance, reason) {
if (!this._jqObj)
return; // we have not been added to the page.
var output_div_with_background = this._jqObj;
var output_div_with_scrollbars = this._getOutputDivWithScrollbars();
if (this._effectiveOutputType() !== OutputType.TEXT) {
output_div_with_background.css({
"background": ""
});
output_div_with_scrollbars.css({
"border-width": "",
"border-color": "",
"border-style": ""
});
return;
}
bugLog("Applying appearance parameters for %s because '%s': %o", this.id(), reason, appearance);
var output = output_div_with_scrollbars.find(".ritem-text-output");
var border = appearance.border;
if (border) {
if (output_div_with_background)
output_div_with_background.css({
"background": appearance.background
});
if (output_div_with_scrollbars)
output_div_with_scrollbars.css({
"border-width": border.size + "px",
"border-color": border.color,
"border-style": border.on ? border.style : "none"
});
output.css({
"padding": appearance.padding
});
}
var font = appearance.font;
var text = appearance.text;
if (font && text) {
if (output)
output.css({
"font-family": font.family,
"font-size": font.size + "pt",
"color": font.color,
"font-weight": font.bold ? "bold" : "normal",
"font-style": font.italic ? "italic" : "normal",
"text-decoration": font.underline ? (font.strikeout ? "underline line-through" : "underline") : (font.strikeout ? "line-through" : "none"),
"text-align": text.hAlign,
"vertical-align": text.vAlign,
"white-space": text.wrap ? "pre-wrap" : "pre"
});
if (output_div_with_scrollbars)
output_div_with_scrollbars.css({
"min-height": Math.ceil(font.size * 1.2) + "pt"
});
}
this._setDomScrollbars();
};
RItemGui.prototype._getOutputDivWithScrollbars = function () { return this._jqObj; };
RItemGui.prototype._setDomScrollbars = function () {
if (Util.isForScreenshot())
return;
var output_div_with_scrollbars = this._getOutputDivWithScrollbars();
var has_scroll = Util.getElementScrollbars(output_div_with_scrollbars[0]);
var css = Util.getTableCssForScrolling(has_scroll.x, has_scroll.y);
if (this._effectiveOutputType() !== OutputType.TEXT) {
output_div_with_scrollbars.css({ overflow: "" });
return;
}
output_div_with_scrollbars.css(css);
};
RItemGui.prototype.clear = function () {
if (this._jqObj) {
this._jqObj.empty();
this._jqObj.removeClass('noVerticalScroll');
this._htmlWidgetContainer.clear();
}
};
RItemGui.prototype.changeLayout = function (layout) {
this.applyLayout(layout);
if (this._editMode || App.isWeb) {
this._state.oldLayout = layout;
this.itemDidReattachToWorkarea();
}
};
RItemGui.prototype.itemDidReattachToWorkarea = function () {
if (this._state.outputType === OutputType.WIDGET) {
this.clear();
this._displayAppropriateOutput();
}
};
RItemGui.prototype.applyLayout = function (layout) {
var vsplitter_wanted = layout === Layout.Top || layout === Layout.Bottom;
var hsplitter_wanted = layout === Layout.Left || layout === Layout.Right;
if (this._lastLayoutApplied && this._lastLayoutApplied === layout &&
vsplitter_wanted === !!this._vsplitter && hsplitter_wanted === !!this._hsplitter) {
return; // avoid resetting any widget iframe when nothing has changed. cf. HtmlWidgetContainer.display()
}
else {
this._lastLayoutApplied = layout;
this._codeContainer.detach();
this._outputContainer.detach();
if (this._hsplitter) {
this._hsplitter.destroy();
this._hsplitter = null;
}
if (this._vsplitter) {
this._vsplitter.destroy();
this._vsplitter = null;
}
if (this._state.oldLayout === Layout.CodeOnly || this._state.oldLayout === Layout.OutputOnly)
this._contentFrame.removeClass("flip-container");
this._contentFrame.children(".splitPanel").remove();
switch (layout) {
case Layout.CodeOnly:
this._contentFrame.append(this._codeContainer);
break;
case Layout.OutputOnly:
this._outputContainer.children().removeClass("notransition");
this._contentFrame.addClass("flip-container flip-notanimating").append(this._outputContainer);
break;
case Layout.Left:
this._hsplitter = new WebWidgets.HorizontalSplitter({ appendTo: this._contentFrame, isRoot: false, initialSizePercent: 100 * this._state.hSplit });
this.modifyOutputSplitter(this._hsplitter);
this._hsplitter.leftPanel.append(this._codeContainer);
this._hsplitter.rightPanel.addClass("flip-container flip-notanimating").append(this._outputContainer);
break;
case Layout.Top:
this._vsplitter = new WebWidgets.VerticalSplitter({ appendTo: this._contentFrame, isRoot: false, initialSizePercent: 100 * this._state.vSplit });
this.modifyOutputSplitter(this._vsplitter);
this._vsplitter.topPanel.append(this._codeContainer);
this._vsplitter.bottomPanel.addClass("flip-container flip-notanimating").append(this._outputContainer);
break;
case Layout.Right:
this._hsplitter = new WebWidgets.HorizontalSplitter({ appendTo: this._contentFrame, isRoot: false, initialSizePercent: 100 - 100 * this._state.hSplit });
this.modifyOutputSplitter(this._hsplitter);
this._hsplitter.leftPanel.addClass("flip-container flip-notanimating").append(this._outputContainer);
this._hsplitter.rightPanel.append(this._codeContainer);
break;
case Layout.Bottom:
this._vsplitter = new WebWidgets.VerticalSplitter({ appendTo: this._contentFrame, isRoot: false, initialSizePercent: 100 - 100 * this._state.vSplit });
this.modifyOutputSplitter(this._vsplitter);
this._vsplitter.topPanel.addClass("flip-container flip-notanimating").append(this._outputContainer);
this._vsplitter.bottomPanel.append(this._codeContainer);
break;
}
if (Util.isForScreenshot())
(this._state.showDebug ? this._jqObj : this._jqConsole).css('display', 'none');
else
this.set_flip("div#{0} .flip-1".format(this.id()), this._state.showDebug);
}
};
RItemGui.prototype.set_flip = function (clss, flipToBack) {
console.log("set flip: " + this._state.oldLayout);
$(clss).addClass("notransition");
if (flipToBack)
$(clss).addClass("flipped");
else
$(clss).removeClass("flipped");
setTimeout(function () {
$(clss).removeClass("notransition");
}, 600, "removing R Gui transition");
};
RItemGui.prototype.resetPreviewer = function () {
if (App.ui.previewer)
App.ui.previewer.hide();
};
RItemGui.prototype.resetNotificationBar = function () {
if (this._editMode) {
this._notificationBar.clearMustChooseOutputType();
this._notificationBar.clearError();
this._notificationBar.clearWarnings();
}
};
RItemGui.prototype.enterRItemForEditMode = function (guid) {
this.enterRItem(guid);
this._editMode = true;
this.guiControlsReadyForTraining = false;
this._firstPreCalcStuff = true;
this.getPreCalcStuff();
};
RItemGui.prototype.enterRItem = function (guid) {
var _this = this;
bugLog('enterRItem({0})'.format(guid));
this.resetPreviewer();
this.guids[0] = guid;
if (!Application.isForDataset()) {
if (this.subscribe('GetRControls', function (response) { return _this.gotRControls(response); }))
this.guiControlsReadyForTraining = true;
}
};
RItemGui.prototype.leaveRItem = function (refresh_r_item, reason) {
bugLogGroup('leaveRItem because ' + reason);
try {
this.unsubscribe('GetRControls');
this.unsubscribe('GetREditPreCalcStuff');
this.unsubscribe('GetREditPostCalcStuff');
if (this._state)
this._state.guiControls = null; // reset so that next time we are entered, we know we do not have controls
this.resetNotificationBar();
this._notificationBar.warnSlow(false);
this._editMode = false; // defensive coding; just in case someone has reference to the RItemGui or change events fire, we want to ignore state changes
this.guiControlsReadyForTraining = true; // if the item is unselected before it completes entering edit mode, this needs to be reset
clearTimeout(this._state.autosaveTimer);
clearTimeout(this._state.highlightingTimer);
clearTimeout(this._updateClickedTimer);
if (refresh_r_item && this.getItemGuids().length === 1) {
QServerRequestsCommon.RItemLeaveEditMode({ GUID: this.getItemGuids()[0], Code: null });
}
for (var _i = 0, _a = RibbonCodeEditor.getEditorsFor(this.guids[0], "r", "javascript"); _i < _a.length; _i++) {
var editor = _a[_i];
editor.enabled(false);
}
}
finally {
bugLogGroupEnd();
}
};
/** Called before the reference to this RItemGui is thrown away and never used again.
* This is different from leaveRItem(), because in that case the RItemGui is re-used
* and enterRItem() may be called again.
* Here we throw away event handlers to avoid duplicate events (like the code editor change event)
* triggering server actions (like RItemRehighlightCode). */
RItemGui.prototype.detach = function () {
if (this._editMode) {
this.unsubscribe('GetRControls');
this.unsubscribe('GetREditPreCalcStuff');
this.unsubscribe('GetREditPostCalcStuff');
}
clearTimeout(this._state.autosaveTimer);
clearTimeout(this._state.highlightingTimer);
this._rControlsContainer.remove();
};
RItemGui.prototype.getItemGuids = function () {
return this.guids;
};
RItemGui.prototype.subscribe = function (name, callback) {
var request = this.subscriptionRequest(name);
if (!Subscription.isSubscribed(request)) {
Subscription.subscribe(request, callback);
return true;
}
return false;
};
RItemGui.prototype.unsubscribe = function (name) {
var request = this.subscriptionRequest(name);
if (Subscription.isSubscribed(request))
Subscription.unsubscribe(request);
};
RItemGui.prototype.subscriptionRequest = function (name) {
var guid = this.guids[0] ? this.guids[0] : "no-guid";
return { Request: name, GUID: guid };
};
RItemGui.prototype.hasPreCalcStuff = function () {
return !!this._firstPreCalcStuff;
};
RItemGui.prototype._applyCalculating = function (calculating) {
if (this._jqQueued) {
this._jqQueued.toggle(calculating === 'Queued');
this._jqCalculating.toggle(calculating === 'Calculating');
}
};
RItemGui.prototype.getPreCalcStuff = function () {
var _this = this;
this._waitingForPreCalcStuff = true;
$("#no-warnings").html("please wait");
var handle_precalcstuff = function (response) {
if (!_this._editMode)
return;
_this._applyCalculating(response.Calculating);
var code = _this._firstPreCalcStuff ? response.Code : null;
if (response.Code)
_this._state.lastSavedCode = response.Code;
_this.displayInputValues(response.Options, code,
response.Highlights.Highlights);
for (var _i = 0, _a = RibbonCodeEditor.getEditorsFor(_this.guids[0], "r", "javascript"); _i < _a.length; _i++) {
var editor = _a[_i];
editor.enabled(true);
}
_this._waitingForPreCalcStuff = false;
$("#no-warnings").html("No suggestions");
if (!_this._firstPreCalcStuff)
return;
App.ui.inspector.update("RItemGui:handle_precalcstuff");
_this._firstPreCalcStuff = false;
if (Util.isDesktop())
QServerRequestsCommon.RItemAutoUpdate({ GUIDs: [_this.guids[0]] }, function () {
return _this.requestAndDisplayOutput();
});
else
_this.requestAndDisplayOutput();
};
if (Application.isForDataset())
QServerRequestsCommon.GetREditPreCalcStuff({ GUID: this.guids[0] }, handle_precalcstuff);
else
this.subscribe('GetREditPreCalcStuff', handle_precalcstuff);
};
RItemGui.prototype.requestAndDisplayOutput = function () {
var _this = this;
var got_postcalcstuff = function (response) {
if (!_this._editMode)
return;
_this.setOutputs(response.Outputs);
if (App.isDesktopDialog)
for (var _i = 0, _a = response.StaticErrorsAndWarnings.filter(function (e) { return e.IsStatic && !e.WarningOnly; }); _i < _a.length; _i++) {
var error = _a[_i];
_this._notificationBar.setError("ERROR: " + error.Message).hideCloseButton();
}
if (response.ExecutedCode !== null)
_this.showExecutedCodeInOutput(response.ExecutedCode);
setTimeout(function () {
_this.guiControlsReadyForTraining = true;
App.ui.inspector.update("RItemGui:got_postcalcstuff");
}, 100, "gui controls ready for training");
};
if (Application.isForDataset())
QServerRequestsCommon.GetREditPostCalcStuff({ GUID: this.guids[0] }, got_postcalcstuff);
else {
this.unsubscribe('GetREditPostCalcStuff');
this.subscribe('GetREditPostCalcStuff', got_postcalcstuff);
}
};
RItemGui.prototype.replaceOutputWithItemRender = function (state) {
this._state = state;
};
RItemGui.prototype.showExecutedCodeInOutput = function (code, force_change) {
if (force_change === void 0) { force_change = false; }
for (var _i = 0, _a = RibbonCodeEditor.getEditorsFor(this.guids[0]).filter(function (e) { return e.name === "inplace"; }); _i < _a.length; _i++) {
var an_editor = _a[_i];
an_editor.text(code);
}
};
RItemGui.prototype.highlightSpans = function (spans) {
bugLog("highlightSpans: " + JSON.stringify(spans));
for (var _i = 0, _a = RibbonCodeEditor.getEditorsFor(this.guids[0]).filter(function (editor) { return editor.name === "inplace" || editor.name === "propertyRCode"; }); _i < _a.length; _i++) {
var editor = _a[_i];
editor.highlightSpans(spans);
}
};
RItemGui.prototype.gotRControls = function (response) {
var _this = this;
this._state.guiControls = response;
setTimeout(function () {
_this.guiControlsReadyForTraining = true;
App.ui.inspector.update("gotRControls");
}, 100, "gui controls ready for training");
var is_commit_pending = this._committables.any(function (c) { return c.isCommitPending(); });
bugLog("is_commit_pending = " + is_commit_pending + " (asked " + this._committables.length + " committables)");
if (is_commit_pending ||
QServer.getLastSeqAckReceived() < this._lastSequenceSent) {
bugLog("not updating control, last ack received: " +
QServer.getLastSeqAckReceived() +
", waiting on ack for " +
this._lastSequenceSent);
return;
}
bugLog("updating control, last ack received: " +
QServer.getLastSeqAckReceived() +
", not waiting on ack for " +
this._lastSequenceSent);
var old_scroll = this._rControlsContainer.scrollTop();
var ribbon_scroll_offsets = [];
this._rControls.find(".ribbon-dropbox-input")
.each(function (index, item) {
ribbon_scroll_offsets.push({ id: item.id, top: item.scrollTop });
});
this._rControls.empty();
this.inputsControls = {};
var div = this._rControls;
this._dropBoxes = [];
if (this._editMode)
App.ui.inspector.update("RItemGui:GotRControls");
if (response.JSError) {
div.append('
Inputs cannot be displayed as there is an error in the input code (please refer to the "Inputs JavaScript" section of the Properties).
');
contentFrame.append(this._jqObj);
};
RItemMultiGui.prototype.updateInspectorSize = function () {
};
RItemMultiGui.prototype.resizeOutput = function () {
};
RItemMultiGui.prototype.setAvailableOutputTypes = function (list, choice, enabled) {
};
RItemMultiGui.prototype.changeLayout = function (layout) {
this._state.oldLayout = layout;
};
RItemMultiGui.prototype.refreshMultipleRItems = function (guids, summary, options, zoom) {
this._editMode = true;
this.setupLeftSide(this._jqCenter);
this.clear();
this._guids = guids;
this.setZoom(zoom);
this.displayMultipleItems(summary);
this.setLastUpdatedText("");
};
RItemMultiGui.prototype.displayMultipleItems = function (items) {
var _this = this;
this.multiple = true;
this.clear();
this.showNoCode();
this._jqObj.removeClass("red");
var div = $('
')
.addClass('multi-item')
.text(Translate("Multiple R items have been selected."))
.append($(' '))
.append($(' '));
var table = $('
')
.addClass('multi-item')
.append($('
').html('
{0}
{1}
{2}
{3}
{4}
{5}
'.format('Item', 'Last Updated', 'Duration', 'Updating', 'Status', 'Errors')));
var grey = [];
for (var i = 0; i < items.length; i++) {
var row = $('
').html('
{0}
{1}
{2}
{3}
{4}
{5}
'.format(items[i][1], items[i][2], items[i][3], items[i][4], items[i][5], items[i][6]));
if (items[i][0] === "grey") {
row.addClass("ritem-not-calculated");
grey.push(this._guids[i]);
}
row.click(function (e) {
});
table.append(row);
}
var update_these = new RibbonButton('btnUpdateThese', Translate('Update all these items'), null, 'medium', null, function () {
_this.commitTextBoxes();
QServerRequestsCommon.RItemUpdateMultiClicked({
AllItems: false,
GUIDs: _this._guids
});
});
update_these.addToDialog(div, null);
update_these.enabled(true);
if (grey.length > 0) {
div.append(" ");
div.append(" ");
var update_grey = new RibbonButton('btnUpdateGrey', Translate('Update grey items'), null, 'medium', null, function () {
_this.commitTextBoxes();
console.log(grey);
QServerRequestsCommon.RItemUpdateMultiClicked({
AllItems: false,
GUIDs: grey
});
});
update_grey.addToDialog(div, null);
update_grey.enabled(true);
}
div.append(table);
this.addElement(div);
this.doneDisplaying();
};
RItemMultiGui.prototype.leaveMulti = function () {
this.clear();
};
RItemMultiGui.prototype.resize = function (size) {
};
RItemMultiGui.prototype.showNoCode = function () {
if (this.rItemCodeEditor)
this.rItemCodeEditor.visible(false);
};
RItemMultiGui.prototype.editCode = function () {
};
RItemMultiGui.prototype.highlightSpans = function (spans) {
};
RItemMultiGui.prototype.resetNotificationBar = function () {
};
RItemMultiGui.prototype.setAppearanceOptions = function () {
};
RItemMultiGui.prototype.showControlCode = function (code) {
};
RItemMultiGui.prototype.handleTableEvents = function (table) {
};
RItemMultiGui.prototype.onOutputTypeChosen = function () {
};
RItemMultiGui.prototype.getPendingOperations = function () {
var pending = _super.prototype.getPendingOperations.call(this);
this._jqObj.find('.col-lastupdated, .col-duration').not(':empty').text('masked');
return pending;
};
return RItemMultiGui;
}(RItemGui));
;
// /Scripts/Dashboard/RItem/RItemForDashboard.ts
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var RItemForDashboard = (function (_super) {
__extends(RItemForDashboard, _super);
function RItemForDashboard(guid, element, state) {
return _super.call(this, [guid], $(element), state, null, true) || this;
}
/** Called when an R Item is exported as an image.
* We load a new HTML page and call this function to do a complete render. */
RItemForDashboard.initialiseEmbeddedItem = function (guid) {
App = new Application(ApplicationContext.WebEmbedded);
var state = new RItemState(JSON.parse(Util.htmlDecode(document.getElementById('rItemStateJson').innerHTML)));
var gui = new RItemForDashboard(guid, $('#ritemforexporting')[0], state);
gui.applyInitialState();
getPendingOperationsBeforeScreenshot = function () {
var pending = Util.getPendingOperations();
pending.addRange(gui.getPendingOperations());
return pending.isEmpty() ? null : pending.toString();
};
};
RItemForDashboard.prototype.setupBody = function () {
var _this = this;
this.setupLeftSide(this._jqCenter);
this.rItemCodeEditor.attachOnDoubleClickHandler(function () {
if (!_this.rItemCodeEditor.isMaximised())
$('a#maximiseEditor').click();
App.ui.inspector.setCurrentPage(ObjectInspectorPageType.Properties);
});
};
RItemForDashboard.prototype.resize = function (size) {
var box = $('div#{0} #resizable-box'.format(this.id()));
box.css({ left: 0, top: 0, width: size.width, height: size.height });
if (this.rItemCodeEditor)
this.rItemCodeEditor.refresh("resized");
this._setDomScrollbars();
};
RItemForDashboard.prototype.handleTableEvents = function (table) {
var _this = this;
if (this._editMode) {
_super.prototype.handleTableEvents.call(this, table);
return;
}
if (!Environment.isViewer)
return;
table.tableJQ.on('tableaction', function (event, action) {
if (Environment.isEmbedded)
alert('Coming soon :-)');
else
_this.onTableAction(action);
});
table.tableJQ.on('tablefilteropen', function (event, header) {
if (Environment.isEmbedded)
alert('Coming soon :-)');
else
_this.onTableFilterOpen(header);
});
};
return RItemForDashboard;
}(RItemGui));
;
// /Scripts/Dashboard/RItem/RItemDragNDrop.ts
/** Connects the TreeView (showing Q's report tree and data files->questions->variables)
* to any drop boxes on the R Controls panel.
* The user drags from the TreeView and drops onto the drop boxes. */
var RItemDragNDrop = (function () {
function RItemDragNDrop(tree_view, element) {
var _this = this;
this._dragInProgress = false;
this._removed = false;
this.onDragStartOrStop = new EventSource();
this._treeView = tree_view;
this._dropIndicator = $('
');
console.log("RItemDragNDrop:()");
this._element = element;
$(element).draggable({
appendTo: "body",
cursorAt: { left: RItemDragHelper.widthOfSelectionFromTree(this._treeView) / 2 + 2, top: 0 },
opacity: 0.75,
helper: function (event) { return _this._makeHelper(event); },
scroll: false,
start: function () { return _this._start(); },
drag: function (event, ui) { return _this._drag(event, ui); },
stop: function (event, ui) { return _this._stop(event, ui); },
delay: 0
});
}
RItemDragNDrop.prototype.esc = function () {
$(document).mouseup();
this._remove();
};
RItemDragNDrop.prototype.dispose = function () {
$(document).mouseup();
this._remove();
};
RItemDragNDrop.prototype._remove = function () {
if (this._removed)
return false;
console.log("RItemDragNDrop:_remove");
if (this._dragHelper) {
this._dragHelper.getJq().detach();
this._dragHelper = null;
}
var el = $(this._element);
if (el.data('ui-draggable'))
el.draggable("destroy");
return this._removed = true;
};
RItemDragNDrop.prototype._start = function () {
this.onDragStartOrStop.trigger(true);
};
RItemDragNDrop.prototype._drag = function (event, ui) {
var drop_box = this._dragHelper.getDropBox();
if (drop_box)
drop_box.updateHighlight(ui);
console.log("dragging: {0}".format(drop_box));
};
RItemDragNDrop.prototype._stop = function (event, ui) {
this.onDragStartOrStop.trigger(false);
ui.helper.detach();
if (!this._dragInProgress)
return;
this._remove();
};
RItemDragNDrop.prototype._makeHelper = function (event) {
this._dragHelper = new RItemDragHelper(this._treeView, this._element, event);
return this._dragHelper.getJq();
};
RItemDragNDrop.prototype.dragSourceChanged = function () {
bugLog("RItemDragNDrop::dragSourceChanged");
};
RItemDragNDrop.prototype.getDraggingElement = function () { return this._element; };
return RItemDragNDrop;
}());
/** Creates the 'helper' jQuery element for the jQuery UI draggable plugin.
* This represents the data the user has dragged from the TreeView. */
var RItemDragHelper = (function () {
function RItemDragHelper(treeView, element, event) {
this._treeView = treeView;
var guid = element.id;
var selected = this._treeView.getModel().getSortedSelectedItems();
var which = selected.map(function (item) { return item.guid; }).indexOf(guid);
var elt = $(element);
var offset = elt.offset();
var offset_x = Util.getAndConvertToPx(element, "padding-left") + (offset.left - event.pageX) + RItemDragHelper.widthOfSelectionFromTree(this._treeView) / 2 + 14;
var offset_y = -22 * which + (offset.top - event.pageY) - 1;
var div = $("")
.css({ left: offset_x, top: offset_y, height: 22 * selected.length });
console.log("which = {0}".format(which));
selected.forEach(function (item) { return div.append(RItemDragHelper.jqForIItem(item)); });
this._jq = $("
').addClass("item-title").text(item.title));
};
RItemDragHelper.widthOfSelectionFromTree = function (treeView) {
var _this = this;
var selected = treeView.getSelection();
var div = $("
").css({ visibility: "hidden", display: "inline-block" });
treeView.getContainer().append(div);
selected.forEach(function (item) { return div.append(_this.jqForIItem(item)); });
var w = div.width();
div.remove();
return w;
};
RItemDragHelper.prototype.getJq = function () {
return this._jq;
};
RItemDragHelper.prototype.getDropBox = function () {
return this._dropBox;
};
RItemDragHelper.prototype.setDropBox = function (drop_box) {
this._dropBox = drop_box;
};
RItemDragHelper.prototype.getSelection = function () {
return this._treeView.getSelection();
};
RItemDragHelper.prototype.getSortedSelection = function () {
return this._treeView.getModel().getSortedSelectedItems();
};
return RItemDragHelper;
}());
;
// /Scripts/Ribbon/ScriptControls/DataEntryButton.ts
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* A button that pops up an Excel-style form for manual entry of data.
*/
var DataEntryButton = (function (_super) {
__extends(DataEntryButton, _super);
function DataEntryButton(name, label, tooltip, size, icon, on_changed, keyboard_shortcut, shortcut_active) {
var _this = _super.call(this, name, label, tooltip, size, icon, function () { return _this.onClick(); }, keyboard_shortcut, shortcut_active) || this;
_this._onChanged = on_changed;
return _this;
}
DataEntryButton.prototype.onClick = function () {
var _this = this;
var dialog = new DataEntryDialog(this._spreadsheetData, function (revised_data) {
_this._spreadsheetData = revised_data;
_this._onChanged();
});
dialog.show();
};
DataEntryButton.prototype.value = function (value) {
if (arguments.length)
this._spreadsheetData = value;
return this._spreadsheetData;
};
return DataEntryButton;
}(RibbonButton));
DataEntryButton.MAX_COLS = 200;
DataEntryButton.MAX_ROWS = 200;
var DataEntryDialog = (function () {
function DataEntryDialog(data, on_ok) {
this._data = data;
this._okCallback = on_ok;
}
DataEntryDialog.prototype.show = function () {
var _this = this;
this._loadHandsOnTable(function () {
var table_div;
var dialog = $('')
.append($('')
.text(Translate("Enter or Paste Data")))
.append($('')
.text(Translate("Enter data manually or use Ctrl-V to paste data from a spreadsheet.")))
.append(table_div = $('') // necessary to trick Handsontable to not takes it reference size from one of our parents. It will show its own scrollbars
)
.append($('')
.append($('')
.text(Translate("OK"))
.click(function () { return _this._onOkClicked(); }))
.append($('')
.text(Translate("Cancel"))
.click(function () { return _this._onCancelClicked(); })));
_this._blockDialog = new BlockDialog(dialog, {
position: 'fixed',
width: window.innerWidth * 0.8
}, { removeContentOnClose: true });
_this._blockDialog.show();
var entire_dialog = _this._blockDialog.surroundingDiv();
var height = Math.floor(window.innerHeight * 0.8 - entire_dialog.outerHeight()) - 4; // -4 to remove scrollbar on FF
table_div.css('height', height);
var data = _this._data;
if (data !== null && (!data.length || !data[0].length))
data = null; // Handsontable does not handle this well - does not apply extra rows/columns
var column_width = 72; // to match Excel
_this._table = new Handsontable(table_div[0], {
data: data,
colWidths: column_width,
rowHeaders: true,
colHeaders: true,
manualColumnResize: true,
manualRowResize: true,
manualColumnMove: true,
manualRowMove: true,
maxCols: DataEntryButton.MAX_COLS + 1,
maxRows: DataEntryButton.MAX_ROWS + 1,
contextMenu: true,
copyPaste: true,
minSpareRows: (height / 20) * 2,
minSpareCols: (dialog.innerWidth() / column_width) * 2
});
});
};
DataEntryDialog.prototype._onOkClicked = function () {
var data = this._table.getData();
data = this._normaliseData(data);
var nrows = data.length, ncols = data.length > 0 ? data[0].length : 0;
if (nrows > DataEntryButton.MAX_ROWS || ncols > DataEntryButton.MAX_COLS) {
Msg.ok(Translate("You may enter a table that is at most {0} x {1}. If you need to enter more data then upload it as a CSV file.").format(DataEntryButton.MAX_COLS, DataEntryButton.MAX_ROWS));
}
else {
this._okCallback(data);
this._blockDialog.close();
}
};
DataEntryDialog.prototype._onCancelClicked = function () {
this._blockDialog.close();
};
/**
* Remove trailing blanks rows and columns. Ensure all data is strings.
*
* The data from Handsontable always comes out rectangular, but it
* will always have trailing blank (null) rows and columns.
*/
DataEntryDialog.prototype._normaliseData = function (data) {
var last_row_i;
for (last_row_i = data.length - 1; last_row_i >= 0; last_row_i--)
if (!data[last_row_i].all(function (s) { return s === null || s === ""; }))
break;
var ncols = data[0].length; // just in case we are about to delete the only blank row
data.splice(last_row_i + 1, data.length - last_row_i + 1);
var last_col_i;
var found_non_empty = false;
for (last_col_i = ncols - 1; last_col_i >= 0; last_col_i--) {
for (var row_i = 0; row_i < data.length; row_i++) {
var cell = data[row_i][last_col_i];
if (cell !== null && cell !== "") {
found_non_empty = true;
break;
}
}
if (found_non_empty)
break;
}
for (var row = 0; row < data.length; row++)
data[row].splice(last_col_i + 1, data[row].length - last_col_i + 1);
for (var row_i = 0; row_i < data.length; row_i++) {
var row = data[row_i];
for (var col_i = 0; col_i < row.length; col_i++)
if (row[col_i] === null)
row[col_i] = "";
}
return data;
};
DataEntryDialog.prototype._loadHandsOnTable = function (on_loaded) {
if (DataEntryDialog._handsOnTableLoading)
return;
if (!DataEntryDialog._handsOnTableLoaded) {
var css = document.createElement('link');
css.setAttribute('rel', 'stylesheet');
css.setAttribute('type', 'text/css');
css.setAttribute('href', '/SharedWebUi/Css/handsontable.full.css');
document.body.appendChild(css);
var js = document.createElement('script');
js.setAttribute('src', '/SharedWebUi/Scripts/handsontable.full.js');
DataEntryDialog._handsOnTableLoading = true;
js.onload = function () {
DataEntryDialog._handsOnTableLoaded = true;
DataEntryDialog._handsOnTableLoading = false;
on_loaded();
};
document.body.appendChild(js);
}
else {
on_loaded();
}
};
return DataEntryDialog;
}());
DataEntryDialog._handsOnTableLoading = false;
DataEntryDialog._handsOnTableLoaded = false;
;
// /Scripts/Ribbon/ScriptControls/SCCheckBox.ts
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SCCheckBox = (function (_super) {
__extends(SCCheckBox, _super);
function SCCheckBox() {
return _super.apply(this, arguments) || this;
}
SCCheckBox.prototype.addToDom = function (row_jq, ribbon, ribbon_section_row, nested_within_popup) {
var _this = this;
this.commonAddToDom(ribbon, ribbon_section_row, nested_within_popup);
var btn_jq = $('');
btn_jq.prop('id', this.name);
btn_jq.preventSelection();
btn_jq.addClass('ribbon-checkbox');
if (this._withinPopup) {
var icon_jq = $('');
btn_jq.append(icon_jq);
}
var span_jq = $('');
span_jq.addClass('ribbon-mediumlabel');
var chk_id = this.name + 'chk';
var label_jq = $('');
label_jq.prop('for', chk_id);
var chk_jq = $('');
chk_jq.prop('id', chk_id);
this.chkjq = chk_jq;
if (this.checkAlign === 'left') {
span_jq.append(chk_jq);
span_jq.append(label_jq);
}
else {
span_jq.append(label_jq);
span_jq.append(chk_jq);
}
btn_jq.append(span_jq);
row_jq.append(btn_jq);
chk_jq.change(function () {
_this.onCheckChanged();
});
this.btnjq = btn_jq;
return btn_jq;
};
SCCheckBox.prototype.updateDom = function () {
var _this = this;
if (!this.btnjq)
return;
this.updateDomVisibility(this.btnjq);
this.updateDomEnabled(this.btnjq, function () { return _this.chkjq.removeAttr('disabled'); }, function () { return _this.chkjq.prop('disabled', true); });
var chk = this.chkjq[0]; // cannot use jQuery ':indeterminate' because it crashes IE8
if (this.indeterminate() && !chk.indeterminate)
this.chkjq.prop('indeterminate', true);
if (!this.indeterminate() && chk.indeterminate)
this.chkjq.prop('indeterminate', false);
if (this.checked() && !this.chkjq.is(':checked'))
this.chkjq.prop('checked', true);
if (!this.checked() && this.chkjq.is(':checked'))
this.chkjq.removeAttr('checked');
if (this.label())
this.btnjq.find('label').text(this.label());
this.updateTooltipDom(this.btnjq);
};
return SCCheckBox;
}(RibbonCheckBox));
;
// /Scripts/Ribbon/ScriptControls/SCComboBox.ts
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SCComboBox = (function (_super) {
__extends(SCComboBox, _super);
function SCComboBox() {
return _super.apply(this, arguments) || this;
}
SCComboBox.prototype.addToDom = function (row_jq, ribbon, ribbon_section_row, nested_within_popup) {
var _this = this;
this.commonAddToDom(ribbon, ribbon_section_row, nested_within_popup);
var span_jq = RibbonComboBox.createJqComboBox(this.name);
this.btnjq = span_jq;
this.inputjq = span_jq.find("input");
this.inputjq.attr('placeholder', Util.htmlToText(this._prompt || ''));
var dropdown_btn_jq = span_jq.find('a');
if (this.allowEdit) {
this.inputjq.keyup(function (event) {
if (event.which === Keys.enter) {
event.preventDefault();
_this.onEditCommit();
}
else if (event.which === Keys.escape) {
event.preventDefault();
_this.updateDom();
}
});
this.inputjq.focusout(function () {
_this.onEditCommit();
});
dropdown_btn_jq.mousedown(function (event) {
event.preventDefault();
_this.onClick();
});
}
else {
this.inputjq.prop('disabled', true);
span_jq.mousedown(function (event) {
event.preventDefault();
if (event.target === _this.btnjq.find('label')[0])
return; // label clicked; ignore
_this.onClick();
});
}
var div = $("
").addClass("sc-combobox").append(span_jq);
row_jq.append(div);
this.createPopupJQuery();
this.popupjq.addClass('ribbon-combobox-popup');
row_jq.append(this.popupjq);
return span_jq;
};
SCComboBox.prototype.setOptions = function (options) {
this._prompt = options.Prompt;
this._errorMsg = options.ErrorMessage;
this._invalidMsg = options.Invalid;
};
return SCComboBox;
}(RibbonComboBox));
;
// /Scripts/Ribbon/ScriptControls/SCPopupColor.ts
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/** A basic button that, when clicked, opens a gallery of colors.
* The button shown on the ribbon is overlayed with the current color.
*
* Colors should always be in rgb() format.
*
* This can have:
* a size for the button (mandatory)
* which can either be 'medium' (16x16 icon) or 'large' (32x32 icon),
*
* an icon for the button (optional)
* which can be either 16x16 or 32x32 - should match the 'size',
*
* a label for the button (optional, '' for none, if you just want to show the icon).
*
* If there is an icon, the color is overlayed upon it. If no icon, it is
* overlayed on the label.
*/
var SCPopupColor = (function (_super) {
__extends(SCPopupColor, _super);
function SCPopupColor(name, label, tooltip, size, icon_url, on_color_changed, no_color_label, more_colors_label, popup_controls) {
var _this = _super.call(this, name, null, tooltip, size, icon_url, on_color_changed, no_color_label, more_colors_label, popup_controls) || this;
_this._leftLabel = label;
return _this;
}
SCPopupColor.prototype.addToDom = function (row_jq, ribbon, ribbon_section_row, nested_within_popup) {
var btn_jq = _super.prototype.addToDom.call(this, row_jq, ribbon, ribbon_section_row, nested_within_popup);
btn_jq.addClass('ribbon-color-parent');
if (this._leftLabel)
btn_jq.parent().prepend($("