"use strict";
const EXPORTED_SYMBOLS = ["core", "resources"];
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
const resources = {
browser: {
styles: ["/native/fx/bindings.css"]}};
const WIDGET_NAME = "http://bar.yandex.ru/packages/yandexbar#moikrug";
const core = {
init: function MoikrugWidget_init(api) {
this._api = api;
this._logger = api.logger;
this._loadModules();
}
,
finalize: function MoikrugWidget_finalize() {
delete this.utils;
delete this._api;
delete this._logger;
}
,
buildWidget: function MoikrugWidget_buildWidget(WIID, item) {
item.setAttribute("yb-native-widget-name",WIDGET_NAME);
item.setAttribute("yb-native-widget-wiid",WIID);
item.module = this;
}
,
destroyWidget: function MoikrugWidget_destroyWidget(WIID, item, context) {
item.removeAttribute("yb-native-widget-name");
item.removeAttribute("yb-native-widget-wiid");
}
,
get API() {
return this._api;
}
,
onButtonClick: function MoikrugWidget_onButtonClick(event, widget) {
if (this.yauth.authorized)
{
this.gotoHome(event);
}
 else
{
let dialogParams = {
name: "moikrug",
title: widget.title};
this.yauth.openAuthDialog(event,dialogParams,false,(function () {
this.gotoHome(event);
}
).bind(this));
}

}
,
counterServiceID: 48,
counterXpathExpr: "number(/s/c/moikrug/@v)",
refreshData: function MoikrugWidget_refreshData(event, callback) {
this.counters.forceUpdate(this.counterServiceID,callback);
}
,
gotoHome: function MoikrugWidget_gotoHome(event) {
this.navigate(this._getURL(),1660,event);
}
,
handleMenuCommand: function MoikrugWidget_handleMenuCommand(event) {
var originalTarget = event.originalTarget;
this.navigate(originalTarget.getAttribute("navURL"),originalTarget.getAttribute("statCode"),event);
}
,
navigate: function MoikrugWidget_navigate(pageURL, statAction, origEvent) {
if (statAction)
this.API.Statistics.logShortAction(statAction);
this.API.Controls.navigateBrowser({
url: pageURL,
eventInfo: origEvent});
}
,
_getURL: function MoikrugWidget__getURL() {
return "http://moikrug.ru/threads/?from=bar";
}
,
_STAT_CODES: {
},
_MODULES: {
utils: "utils.jsm",
counters: "counters.jsm",
yauth: "yauth.jsm"},
_loadModules: function MoikrugWidget__loadModules() {
var shAPI = this._api.shareableAPI;
for each(let [moduleName, moduleFileName] in Iterator(this._MODULES)) {
Cu.import(this._api.Package.resolvePath("/native/fx/modules/" + moduleFileName),this);
let module = this[moduleName];
if (typeof module.init == "function")
module.init(shAPI);
}

}
};
