{"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":"TABLE","widgetState":null,"outputs":{"text":" id name period\n1 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n2 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n3 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n4 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n5 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n6 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n7 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n title\n1 Lifetime Total Likes\n2 Lifetime Total Likes\n3 Lifetime Total Likes\n4 Lifetime Total Likes\n5 Lifetime Total Likes\n6 Lifetime Total Likes\n7 Lifetime Total Likes\n description\n1 Lifetime: The total number of people who have liked your Page. (Unique Users)\n2 Lifetime: The total number of people who have liked your Page. (Unique Users)\n3 Lifetime: The total number of people who have liked your Page. (Unique Users)\n4 Lifetime: The total number of people who have liked your Page. (Unique Users)\n5 Lifetime: The total number of people who have liked your Page. (Unique Users)\n6 Lifetime: The total number of people who have liked your Page. (Unique Users)\n7 Lifetime: The total number of people who have liked your Page. (Unique Users)\n value end_time\n1 64 2016-08-01T07:00:00+0000\n2 64 2016-08-02T07:00:00+0000\n3 64 2016-08-03T07:00:00+0000\n4 64 2016-08-04T07:00:00+0000\n5 66 2016-08-05T07:00:00+0000\n6 66 2016-08-06T07:00:00+0000\n7 66 2016-08-07T07:00:00+0000\n","console":"<pre class='debug-source'>>require("Rfacebook")\n</pre>\n<pre class='debug-message'>Loading required package: Rfacebook\n</pre>\n<pre class='debug-message'>Loading required package: httr\n</pre>\n<pre class='debug-message'>Loading required package: rjson\n</pre>\n<pre class='debug-message'>Loading required package: httpuv\n</pre>\n<pre class='debug-message'>\nAttaching package: 'Rfacebook'\n\n</pre>\n<pre class='debug-message'>The following object is masked from 'package:methods':\n\n getGroup\n\n</pre>\n<pre class='debug-source'>>require("httr")\n</pre>\n<pre class='debug-source'>>library(devtools)\n</pre>\n<pre class='debug-source'>>\n</pre>\n<pre class='debug-source'>>#token <- 'EAAYAnC2rZAhABACeOIfZCs3JpCa82abFKppqy0cLscGjK5FGzXJV0w2LZB2RsvXIaAYK0WR75DhUsBZB1Lw3arRmPZCV1xAuMfHDS44YfnGrAAMiQRK1h8zo6f6HoxepqI9TGspPI9OuBmKnSBDtAl2SmY5xNXjAZD'\n</pre>\n<pre class='debug-source'>>#token <- GET(paste(baseurl,'?client_id=',clientid,'&client_secret=',clientsecret,'&grant_type=client_credentials',sep=""))\n</pre>\n<pre class='debug-source'>>#token = gsub("access_token=", "", content(token))\n</pre>\n<pre class='debug-source'>>\n</pre>\n<pre class='debug-source'>>#pageid <- ('516677088511758')\n</pre>\n<pre class='debug-source'>>\n</pre>\n<pre class='debug-source'>>untilDate <- '2016-08-08'\n</pre>\n<pre class='debug-source'>>sinceDate <- '2016-08-01'\n</pre>\n<pre class='debug-source'>>\n</pre>\n<pre class='debug-source'>>params <- paste("&since=",sinceDate,"&until=",untilDate,sep="")\n</pre>\n<pre class='debug-source'>>#str(params)\n</pre>\n<pre class='debug-source'>>page_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms=params) \n</pre>\n<pre class='debug-source'>>#page_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms='&since=2016-09-23&until=2016-10-02') \n</pre>\n<pre class='debug-source'>>page_fans[1] <- '[YOURPAGEID]/insights/page_fans/lifetime'\n</pre>\n<pre class='debug-source'>>page_fans\n</pre>\n<pre class='debug-out'> id name period\n1 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n2 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n3 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n4 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n5 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n6 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n7 [YOURPAGEID]/insights/page_fans/lifetime page_fans lifetime\n title\n1 Lifetime Total Likes\n2 Lifetime Total Likes\n3 Lifetime Total Likes\n4 Lifetime Total Likes\n5 Lifetime Total Likes\n6 Lifetime Total Likes\n7 Lifetime Total Likes\n description\n1 Lifetime: The total number of people who have liked your Page. (Unique Users)\n2 Lifetime: The total number of people who have liked your Page. (Unique Users)\n3 Lifetime: The total number of people who have liked your Page. (Unique Users)\n4 Lifetime: The total number of people who have liked your Page. (Unique Users)\n5 Lifetime: The total number of people who have liked your Page. (Unique Users)\n6 Lifetime: The total number of people who have liked your Page. (Unique Users)\n7 Lifetime: The total number of people who have liked your Page. (Unique Users)\n value end_time\n1 64 2016-08-01T07:00:00+0000\n2 64 2016-08-02T07:00:00+0000\n3 64 2016-08-03T07:00:00+0000\n4 64 2016-08-04T07:00:00+0000\n5 66 2016-08-05T07:00:00+0000\n6 66 2016-08-06T07:00:00+0000\n7 66 2016-08-07T07:00:00+0000\n</pre>\r\n<div class=\"debug-summarystatistics\">\r\n<table>\r\n<tr><th>Total time:</th><td>0.72s</td></tr>\r\n<tr><th>Time on R server:</th><td title=\"rApacheServe 0.61s (pre 0.00s, post 0.00s) httpget_code() setup for eval 0.00s session$eval 0.59s (pre 0.04s, post 0.03s) unexplained 0.02s apparmor forking (pre 0.02s, post 0.00s)\">0.61s</td></tr>\r\n<tr><th>Time evaluating code:</th><td>0.50s</td></tr>\r\n<tr><th>Bytes sent:</th><td>2,127</td></tr>\r\n<tr><th>Bytes received:</th><td>11,008</td></tr>\r\n</table>\r\n</div>","message":"Loading required package: Rfacebook\n\r\nLoading required package: httr\n\r\nLoading required package: rjson\n\r\nLoading required package: httpuv\n\r\n\nAttaching package: 'Rfacebook'\n\n\r\nThe following object is masked from 'package:methods':\n\n getGroup\n\n","warning":"","table":"{\"Dimensions\":[{\"IsStatistic\":true,\"Elements\":[{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement0\",\"Name\":\"id\",\"WrappedName\":[\"id\"],\"IsText\":true},{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement1\",\"Name\":\"name\",\"WrappedName\":[\"name\"],\"IsText\":true},{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement2\",\"Name\":\"period\",\"WrappedName\":[\"period\"],\"IsText\":true},{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement3\",\"Name\":\"title\",\"WrappedName\":[\"title\"],\"IsText\":true},{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement4\",\"Name\":\"description\",\"WrappedName\":[\"description\"],\"IsText\":true},{\"IsNumber\":true,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement5\",\"Name\":\"value\",\"WrappedName\":[\"value\"],\"IsText\":false},{\"IsNumber\":false,\"IsBoolean\":false,\"IsDateTime\":false,\"IsPercent\":false,\"HasDecimalPlaces\":true,\"DecimalPlaces\":1,\"MoneySymbol\":null,\"IsCategorical\":false,\"Categories\":[],\"SeriesType\":0,\"Id\":\"StatisticsElement6\",\"Name\":\"end_time\",\"WrappedName\":[\"end_time\"],\"IsText\":true}],\"Id\":\"StatisticsDimensionID\",\"Name\":null,\"WrappedName\":null,\"Tiers\":[],\"Count\":7},{\"IsStatistic\":false,\"Elements\":[{\"Id\":\"RowDimensionElement0\",\"Name\":\"1\",\"WrappedName\":[\"1\"]},{\"Id\":\"RowDimensionElement1\",\"Name\":\"2\",\"WrappedName\":[\"2\"]},{\"Id\":\"RowDimensionElement2\",\"Name\":\"3\",\"WrappedName\":[\"3\"]},{\"Id\":\"RowDimensionElement3\",\"Name\":\"4\",\"WrappedName\":[\"4\"]},{\"Id\":\"RowDimensionElement4\",\"Name\":\"5\",\"WrappedName\":[\"5\"]},{\"Id\":\"RowDimensionElement5\",\"Name\":\"6\",\"WrappedName\":[\"6\"]},{\"Id\":\"RowDimensionElement6\",\"Name\":\"7\",\"WrappedName\":[\"7\"]}],\"Id\":\"RowCategoricalDimension\",\"Name\":null,\"WrappedName\":null,\"Tiers\":[],\"Count\":7}],\"DataPoints\":[[{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"[YOURPAGEID]/insights/page_fans/lifetime\",\"WrappedText\":[\"[YOURPAGEID]/insights/\",\"page_fans/lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"page_fans\",\"WrappedText\":[\"page_fans\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"lifetime\",\"WrappedText\":[\"lifetime\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime Total Likes\",\"WrappedText\":[\"Lifetime Total\",\"Likes\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"Lifetime: The total number of people who have liked your Page. (Unique Users)\",\"WrappedText\":[\"Lifetime: The total number of people who have\",\"liked your Page. (Unique Users)\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":64.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":64.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":64.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":64.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":66.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":66.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":66.0,\"WrappedText\":null,\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null}],[{\"Value\":\"2016-08-01T07:00:00+0000\",\"WrappedText\":[\"2016-08-01T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-02T07:00:00+0000\",\"WrappedText\":[\"2016-08-02T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-03T07:00:00+0000\",\"WrappedText\":[\"2016-08-03T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-04T07:00:00+0000\",\"WrappedText\":[\"2016-08-04T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-05T07:00:00+0000\",\"WrappedText\":[\"2016-08-05T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-06T07:00:00+0000\",\"WrappedText\":[\"2016-08-06T07:00\",\":00+0000\"],\"IsBlank\":null,\"Significance\":null,\"ExtraText\":null},{\"Value\":\"2016-08-07T07:00:00+0000\",\"WrappedText\":[\"2016-08-07T07:00\",\":00+0000\"],\"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-_-9\",\"LiveTableFormat\":{},\"AvailableWidth\":936,\"AvailableHeight\":278,\"TableWidth\":null}}","visible":"yes"},"secondsTaken":0.7240718,"updated":"2016-12-12T21:04:35.0288858Z","lastUpdatedMessage":null,"executedCode":"require(\"Rfacebook\")\nrequire(\"httr\")\nlibrary(devtools)\n\n#token <- 'EAAYAnC2rZAhABACeOIfZCs3JpCa82abFKppqy0cLscGjK5FGzXJV0w2LZB2RsvXIaAYK0WR75DhUsBZB1Lw3arRmPZCV1xAuMfHDS44YfnGrAAMiQRK1h8zo6f6HoxepqI9TGspPI9OuBmKnSBDtAl2SmY5xNXjAZD'\n#token <- GET(paste(baseurl,'?client_id=',clientid,'&client_secret=',clientsecret,'&grant_type=client_credentials',sep=\"\"))\n#token = gsub(\"access_token=\", \"\", content(token))\n\n#pageid <- ('516677088511758')\n\nuntilDate <- '2016-08-08'\nsinceDate <- '2016-08-01'\n\nparams <- paste(\"&since=\",sinceDate,\"&until=\",untilDate,sep=\"\")\n#str(params)\npage_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms=params) \n#page_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms='&since=2016-09-23&until=2016-10-02') \npage_fans[1] <- '[YOURPAGEID]/insights/page_fans/lifetime'\npage_fans\n\n","lastSavedCode":"require(\"Rfacebook\")\nrequire(\"httr\")\nlibrary(devtools)\n\n#token <- 'EAAYAnC2rZAhABACeOIfZCs3JpCa82abFKppqy0cLscGjK5FGzXJV0w2LZB2RsvXIaAYK0WR75DhUsBZB1Lw3arRmPZCV1xAuMfHDS44YfnGrAAMiQRK1h8zo6f6HoxepqI9TGspPI9OuBmKnSBDtAl2SmY5xNXjAZD'\n#token <- GET(paste(baseurl,'?client_id=',clientid,'&client_secret=',clientsecret,'&grant_type=client_credentials',sep=\"\"))\n#token = gsub(\"access_token=\", \"\", content(token))\n\n#pageid <- ('516677088511758')\n\nuntilDate <- '2016-08-08'\nsinceDate <- '2016-08-01'\n\nparams <- paste(\"&since=\",sinceDate,\"&until=\",untilDate,sep=\"\")\n#str(params)\npage_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms=params) \n#page_fans <- getInsights(pageid, token, metric='page_fans', period='lifetime', parms='&since=2016-09-23&until=2016-10-02') \npage_fans[1] <- '[YOURPAGEID]/insights/page_fans/lifetime'\npage_fans\n\n","highlightedCodeSpans":[{"start":595,"length":6,"index":2},{"start":603,"length":5,"index":2}],"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,"Errors":null,"Controls":[{"Vertical":true}]},"showDebug":false,"layout":"OutputOnly","size":{"Width":936,"Height":279},"vSplit":0.25,"hSplit":0.45,"updateWarnings":true,"updateMode":"Manual","warnSlow":false,"outputSize":{"Width":936,"Height":278},"Options":{"debugconsole":false,"codeposition":"OutputOnly","size":{"width":936,"height":279},"splitH":0.45,"splitV":0.25,"update warnings":true,"updating":"Manual","warn slow":false}}
\n' // avoid explicitly writing the end script tag
+ '\n'
+ (Util.isForScreenshot() ? '\n' : '\n')
+ body
+ '\n' // avoid explicitly writing the end script tag
+ '\n'
+ '';
var iframe = document.createElement('iframe');
iframe.className = 'r-htmlwidget-iframe'; // so we can style the iframe
this._jqObj[0].appendChild(iframe);
setTimeout(function () {
if (!_this._jqObj.existsInDom())
return;
var iframe_window = iframe.contentWindow;
var document = iframe_window ? iframe_window.document : (iframe.contentDocument && iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
if (!document || !iframe_window)
return;
document.open();
document.write(html);
document.close();
var set_state_changed_hook = function () {
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);
_this._reZoomOutput();
setTimeout(function () { return _this.reload(); }, 100);
setTimeout(function () {
_this.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;
};
RItemGui.prototype._widgetStateChanged = function (new_state) {
if (Util.isDesktop() || Environment.isEditor) {
QServerRequestsCommon.SaveRItemWidgetState({
GUID: this.guids[0],
WidgetState: JSON.stringify(new_state),
SkipFeedbackFrom: {
Requests: [this._subscriptionRequest('GetRControls'),
this._subscriptionRequest('GetREditPreCalcStuff'),
this._subscriptionRequest('GetREditPostCalcStuff')]
}
});
}
};
RItemGui.prototype.reload = function () {
var DOMContentLoaded_event = document.createEvent("Event");
DOMContentLoaded_event.initEvent("DOMContentLoaded", true, true);
window.document.dispatchEvent(DOMContentLoaded_event);
};
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._currentWidgetHead = null;
this._currentWidgetBody = null;
this._currentWidgetState = null;
}
};
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) {
this._codeContainer.detach();
this._outputContainer.detach();
if (this._hsplitter)
this._hsplitter.destroy();
if (this._vsplitter)
this._vsplitter.destroy();
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._readyForTraining = false;
this.guids[0] = guid;
if (!Application.isForDataset()) {
this.guiControlsReadyForTraining = false;
this.subscribe('GetRControls', function (response) { return _this.gotRControls(response); });
}
};
RItemGui.prototype.leaveRItem = function (refresh_r_item) {
bugLogGroup('leaveRItem');
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._readyForTraining = 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
clearTimeout(this._state.autosaveTimer);
clearTimeout(this._state.highlightingTimer);
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);
};
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.getPreCalcStuff = function () {
var _this = this;
this._waitingForPreCalcStuff = true;
$("#no-warnings").html("please wait");
var handle_precalcstuff = function (response) {
if (!_this._editMode)
return;
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.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).
No input form code has been specified. To define inputs, edit the JavaScript code in the "Inputs JavaScript" section of the Properties.
');
return;
}
var vertical = controls.any(function (x) { return !!x["Vertical"]; });
$("#invalid-r-control").text("");
var orig_div = div;
this._committables = [];
$.each(controls, function (i, args) {
var name = args["ControlName"];
var label = args["Label"] ? args["Label"] : "";
var invalid = args["Invalid"];
if (vertical) {
div = $('');
orig_div.append(div);
}
args = $.extend({ 'IsRegressionTesting': Util.isTesting() }, args); // avoids tooltips in DropBox
var control = null;
switch (args["Type"]) {
case "CheckBox": {
var chkbox = new SCCheckBox(name, label, args["Prompt"], args["CheckAlign"], function () {
return _this.setValueForRControl(name, chkbox.checked() ? "true" : "false");
});
chkbox.checked(args["Value"]);
control = chkbox;
break;
}
case "DropBox": {
var dropbox = new RibbonDropBox(name, label, function () { }, function () {
var multi = dropbox.multi();
var value = multi ? dropbox.values().map(function (item) { return item.guid; }).join(";") : dropbox.value() ? dropbox.value().guid : null;
_this.StateChanged("GetRControls", multi ? "SetGuidsForRControl" : "SetGuidForRControl", name, value, function (response) { return _this.gotRControls(response); });
}, args);
_this._dropBoxes.push(dropbox);
control = dropbox;
break;
}
case "ComboBox":
case "StatisticPicker": {
var cbobox = new SCComboBox(name, label, args["Prompt"], false, function () {
return _this.setValueForRControl(name, cbobox.value());
});
cbobox.populateList(args["Values"], false);
cbobox.value(args["Value"]);
cbobox.setOptions(args);
control = cbobox;
break;
}
case "NumberBox":
case "TextBox": {
var numeric = args["Type"] === "NumberBox" || args["Validator"] === "number";
var txtbox = new SCTextBox(name, label, args["Prompt"], function () {
return _this.setValueForRControl(name, txtbox.text());
}, numeric);
txtbox.text(args["Value"]);
txtbox.setOptions(args);
control = txtbox;
_this._committables.push(txtbox);
break;
}
case "NumericUpDown": {
var updown = new RibbonUpDown(name, label, args["Prompt"], function () {
return _this.setValueForRControl(name, updown.value().toString());
});
updown.increment(args["Increment"]);
updown.min(args["Min"]);
updown.max(args["Max"]);
updown.value(args["Value"]);
control = updown;
_this._committables.push(updown);
break;
}
case "ColorPicker": {
var color = new SCPopupColor(name, label, args["Prompt"], 'medium', Util.makeSharedWebUiSpriteImg('colourfill.png'), function () {
return _this.setValueForRControl(name, _this.rgbAsString(color));
}, null, Translate('More Colors...'));
color.value(args["Value"]);
control = color;
break;
}
case "DataEntry": {
var de = new DataEntryButton(name, label, args["Prompt"], 'medium', null, function () {
return _this.setValueForRControl(name, de.value());
});
de.value(args["Value"]);
control = de;
break;
}
case "Label": {
var lbl = new RibbonLabelledText(name, args["Text"], null);
lbl.addToDialog(div, _this.ribbonForControls);
lbl.enabled(true);
break;
}
case "LineBreak": {
div.append($(" "));
break;
}
case "Heading": {
div.append($("
").text(args["Text"]));
break;
}
case "Summary": {
div.append(" ");
div.append($("").text(args["Text"]));
break;
}
}
if (control) {
control.addToDialog(div, _this.ribbonForControls);
control.enabled(true);
_this.inputsControls[name] = control;
if (invalid) {
var jq = control.getJqPrimaryControl();
jq.addClass("ribbon-invalid");
}
}
});
this._rControls.find(".ribbon-dropbox-input")
.each(function (index, item) {
var offset = ribbon_scroll_offsets.filter(function (o) { return o.id === item.id; })[0];
if (offset)
item.scrollTop = offset.top;
});
this._rControlsContainer.scrollTop(old_scroll);
};
RItemGui.prototype.setValueForRControl = function (name, value) {
var _this = this;
bugLog("setValueForRControl: " + name + " = " + value);
this.StateChanged("GetRControls", "SetValueForRControl", name, value, function (response) {
bugLog("setValueForRControl returned");
_this.gotRControls(response);
});
};
RItemGui.prototype.commitTextBoxes = function () {
if (this._committables)
for (var _i = 0, _a = this._committables; _i < _a.length; _i++) {
var textbox = _a[_i];
textbox.onEditCommit(false, "committing gui input controls");
}
};
RItemGui.prototype.rgbAsString = function (color) {
var rgb = RibbonPopupColor.strToColor(color.value()); // "rgb(r, g, b)"
return rgb.replace('rgb(', '').replace(')', ''); // ScriptColorPicker expects "r, g, b"
};
RItemGui.prototype.widthOfLabels = function () {
return this._rControls.find("label".format(this.id())).map(function (i, x) { return $(x).width(); }).toArray().reduce(function (sum, x) { return Math.max(sum, x); }, 0);
};
RItemGui.prototype.StateChanged = function (get_request, set_request, set_name, set_value, get_success, set_success) {
var guids = this.getItemGuids();
if (guids.length > 1)
throw new Error("This is a single-item selected operation only.");
var guid = guids[0];
if (!guid)
throw new Error("no selected guid");
var request = {
Request: set_request,
Guid: guid,
Name: set_name,
Value: set_value
};
if (set_name === "Code")
$.extend(request, { Code: set_value });
if (Util.hashParams()['for_dataset'] === "true") {
Util.qServerRequest(request, set_success);
Util.qServerRequest({
Request: get_request,
GUID: guid
}, function (response) { return get_success(response); });
return;
}
this._hasChangedState = true;
if (Util.isDesktop() || Environment.isEditor) {
Util.qServerRequest(request, function (response) {
if (set_success)
set_success(response);
});
this.committedCurrentValue();
return;
}
throw new Error("Interesting. Why are we changing state in view mode dashboards?");
};
RItemGui.prototype.committedCurrentValue = function () {
this._lastSequenceSent = QServer.getLastSeqSent();
bugLog("%cGui controls Expecting update as a result, will reject any intermediate results until server acks seq# " + this._lastSequenceSent, Util.HighlightStyles.Ludicrous);
};
RItemGui.prototype.setDebugVisibility = function (visible, originated_in_checkbox) {
if (this._state.showDebug === visible)
return;
this._state.showDebug = visible;
if (originated_in_checkbox) {
this.do_flip("div#{0} .flip-1".format(this.id()), visible);
this.changeOption("debugconsole", visible, originated_in_checkbox);
}
else {
this.set_flip("div#{0} .flip-1".format(this.id()), visible);
}
};
RItemGui.prototype.do_flip = function (clss, flipToBack) {
var _this = this;
console.log("flip: " + this._state.oldLayout);
var id = this.id();
$('div#{0} #resizable-box > .splitPanel'.format(id)).css("overflow", "visible");
var other = (this._state.oldLayout === Layout.Top) === clss.endsWith(".flip-0") ? "bottom" : "top";
$('div#{0} #resizable-box .splitPanel-{1}'.format(id, other)).css("z-index", "-1");
$('div#{0} #resizable-box .ui-icon-gripsmall-diagonal-se'.format(id)).css('visibility', "hidden");
var fc = $(clss).closest('.flip-container');
fc.addClass('flip-animating');
setTimeout(function () {
fc.addClass('flip-transition');
if (flipToBack)
$(clss).addClass("flipped");
else
$(clss).removeClass("flipped");
setTimeout(function () {
fc.removeClass('flip-transition');
fc.removeClass('flip-animating');
$('div#{0} #resizable-box .splitPanel-{1}'.format(id, other)).css("z-index", "0");
$('div#{0} #resizable-box > .splitPanel'.format(id)).css("overflow", "hidden");
if (!flipToBack && _this.rItemCodeEditor)
_this.rItemCodeEditor.refresh("flipping");
$('div#{0} #resizable-box .ui-icon-gripsmall-diagonal-se'.format(id)).css('visibility', "visible");
}, 600);
}, 0);
};
RItemGui.prototype.showDependencies = function (svg, width) {
this.clear();
var elt = $('
');
this._addElement(elt);
elt.append($('')
.addClass("ritem-image")
.css("width", 4 * width + "px")
.css("background", "url(data:image/svg+xml;base64,{0})".format(svg)));
};
RItemGui.prototype.showPreview = function (html, is_man_page) {
};
RItemGui.prototype.setLastUpdatedText = function (message) {
this.lastUpdatedMessageMaintainer.setTextAndTooltip(message);
};
RItemGui.prototype.doneDisplaying = function () {
var _this = this;
setTimeout(function () {
_this._readyForTraining = true;
_this.guiControlsReadyForTraining = true;
_this.outputReadyForTraining = true;
if (App.ui.inspector)
App.ui.inspector.update("ready for training");
}, 100, "REALLY ready for training");
};
RItemGui.prototype.getPendingOperations = function () {
var pending = new PendingOperations();
if (!this._readyForTraining) {
pending.add('RItemGui', '', '!_readyForTraining');
return pending;
}
if (!this.guiControlsReadyForTraining) {
pending.add('RItemGui', '', '!guiControlsReadyForTraining');
return pending;
}
if (!this.outputReadyForTraining) {
pending.add('RItemGui', '', '!outputReadyForTraining');
return pending;
}
if (this._waitingForTableStyles) {
pending.add('RItemGui', '', '_waitingForTableStyles');
return pending;
}
if (this._state.outputType === OutputType.WIDGET) {
var widget_iframe = $('.r-htmlwidget-iframe');
if (widget_iframe.length) {
var widget_iframe_element = widget_iframe[0];
if (!widget_iframe_element.contentWindow['HTMLWidgets']) {
pending.add('RItemGui', '', 'HTMLWidget not rendered');
return pending;
}
if (!widget_iframe_element.contentWindow['HTMLWidgets'].isRendered) {
pending.add('RItemGui', '', 'HTMLWidget not rendered');
return pending;
}
var widget_document = widget_iframe_element.contentDocument;
var widget_readystate = widget_document.readyState;
if (widget_readystate !== 'complete') {
pending.add('RItemGui', '', 'HTMLWidget document readyState not complete', widget_readystate);
return pending;
}
var widget_window = widget_iframe_element.contentWindow;
if (widget_window['jQuery']) {
var outstanding_ajax = widget_window['jQuery'].ajax.active !== undefined ? widget_window['jQuery'].ajax.active : widget_window['jQuery'].active;
if (outstanding_ajax !== 0) {
pending.add('RItemGui', '', 'HTMLWidget outstanding jQuery 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. */
RItemGui.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;
};
RItemGui.prototype.getState = function () {
return this._state;
};
RItemGui.prototype.getCodeEditors = function () {
return RibbonCodeEditor.getEditorsFor(this.guids[0]);
};
RItemGui.prototype.hasChangedState = function () {
return this._hasChangedState;
};
return RItemGui;
}());
RItemGui._nextPlotId = 0;
/**
* Allows us to get notfications before ribbon controls change, so that
* we can commit any outstanding text editors (who won't get an onblur
* in time).
*/
var RItemRibbonForControls = (function () {
function RItemRibbonForControls(gui) {
var _this = this;
this.onBeforeChange = new EventSource();
this.onChanged = new EventSource();
this._gui = gui;
this.onBeforeChange.add(function (ctl) {
if (!(ctl instanceof RibbonTextBox) && !(ctl instanceof RibbonUpDown))
_this._gui.commitTextBoxes();
});
}
RItemRibbonForControls.prototype.addToCtlMap = function (ctl) {
};
RItemRibbonForControls.prototype.hideRibbon = function () {
};
return RItemRibbonForControls;
}());
;
// /Scripts/Dashboard/RItem/RItemMultiGui.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 RItemMultiGui = (function (_super) {
__extends(RItemMultiGui, _super);
function RItemMultiGui(guids, centre, state, notification_bar) {
var _this = _super.call(this, guids, centre, state, notification_bar, false) || this;
_this._guids = [];
return _this;
}
RItemMultiGui.prototype.setupBody = function () {
};
RItemMultiGui.prototype.setupLeftSide = function (leftPanel) {
leftPanel.empty();
var contentFrame = $('
');
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();
};
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());
if (this.tooltip())
this.btnjq.prop('title', this.tooltip()).simpleTip();
};
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($("