home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Narzedzia
/
AIMP2
/
aimp_2.61.583.exe
/
$TEMP
/
YandexPackSetup.msi
/
fil76F7AB211F257DA46B50B20704903322
< prev
next >
Wrap
Text File
|
2010-07-12
|
24KB
|
756 lines
function fillTooltip(aTooltip) {
let tooltipNode = document.tooltipNode.parentNode;
if (!(tooltipNode && tooltipNode.localName == "hbox" && tooltipNode.hasAttribute("yaTooltiptext")))
return false;
let tooltiptext = tooltipNode.getAttribute("yaTooltiptext")
.replace(/^\s+/, '')
.replace(/\s+$/, '')
.replace(/([\/\-&\?\.])/g, "$1\u200B")
.replace(/(\S{5})(\S{5})/g, "$1\u200B$2");
if (!tooltiptext)
return false;
if (tooltiptext.length > 1000)
tooltiptext = tooltiptext.substr(0, 1000) + "\u2026";
let descr = aTooltip.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "div")[0];
descr.textContent = tooltiptext;
aTooltip.style.height = "";
window.setTimeout(function() {
aTooltip.style.height = aTooltip.boxObject.height + "px";
}, 0);
return true;
}
var YaAnimator = {
_animateTimer: null,
_animateDelay: 15,
_animateIncrement: 40,
_diffHeight: null,
get targetHeight() {
try {
return parseInt(window.getComputedStyle(document.getElementById("yasearch-grids-container"), "").height);
} catch (e) {}
return 0;
},
init: function() {
var me = this;
setTimeout(function() { me.init_(); }, 10);
},
init_: function() {
this._diffHeight = this.targetHeight ? Math.abs(window.innerHeight - this.targetHeight) : 0;
},
get _sizeIncrement() {
if (this._diffHeight === null)
return 0;
let diff = this.targetHeight - window.innerHeight + this._diffHeight;
if (diff > this._animateIncrement)
return this._animateIncrement;
if (diff < -this._animateIncrement)
return -this._animateIncrement;
return diff;
},
_setUpAnimationTimer: function() {
if (!this._animateTimer)
this._animateTimer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
else
this._animateTimer.cancel();
this._animateTimer.initWithCallback(this, this._animateDelay,
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
},
notify: function(aTimer) {
if (!document)
aTimer.cancel();
if (aTimer == this._animateTimer) {
let increment = this._sizeIncrement;
if (increment == 0) {
aTimer.cancel();
} else {
window.innerHeight += increment;
}
}
},
animate: function() {
window.setTimeout(function(me) {
me._setUpAnimationTimer();
}, 100, this);
},
switchToPanel: function(aGridName) {
let gridId = "yasearch-" + aGridName + "-grid";
let grid = document.getElementById("yasearch-grids-container").firstChild;
while (grid) {
grid.hidden = (grid.id != gridId);
grid = grid.nextSibling;
}
let docElement = document.documentElement;
document.title = docElement.getAttribute("yaTitle" + aGridName);
docElement.setAttribute("style", docElement.getAttribute("yaStyle" + aGridName));
try {
window.sizeToContent();
} catch(e) {}
this.animate();
}
}
var YaYaRu = {
nsIYa: Components.classes["@yandex.ru/yasearch;1"].getService(Components.interfaces.nsIYaSearch).wrappedJSObject,
__currentState: 1,
get state() {
return this.__currentState;
},
set state(val) {
if (!window.YaYaRu)
return null;
let stateName;
for (var state in this.STATES) {
if (val === this.STATES[state]) {
stateName = state;
break;
}
}
document.getElementById("yasearch-bookmark-grid").setAttribute("yayaruState", stateName.replace(/_/g, '-'));
document.getElementById("yaru-settings-informer-deck").selectedIndex = val - 1;
YaAnimator.animate();
this.__currentState = val;
if (val >= this.STATES.HAS_NO_JOURNAL)
this.expandSettings();
this._checkFormEnabled();
return this.state;
},
STATES: {
NO_DATA: 1,
REQUEST: 2,
ERROR: 3,
DELETED_JOURNAL: 4,
HAS_NO_JOURNAL: 5,
HAS_JOURNAL: 6
},
get enabled() {
return (this.state >= this.STATES.HAS_NO_JOURNAL);
},
get requestDone() {
return (this.state > this.STATES.REQUEST);
},
get exportChecked() {
return document.getElementById("yaru-settings-checkbox").checked;
},
set exportChecked(val) {
document.getElementById("yaru-settings-checkbox").checked = !!val;
return this.exportChecked;
},
_checkFormEnabled: function() {
let exportCheckbox = document.getElementById("yaru-settings-checkbox");
exportCheckbox.disabled = !(this.enabled && YaBookmarks.enabled);
let disabled = !(this.enabled && YaBookmarks.enabled && exportCheckbox.checked);
let i = 0,
radiogroups = document.getElementsByTagName("radiogroup");
while (radiogroups.item(i))
radiogroups.item(i++).disabled = disabled;
document.getElementById("yaru-settings-communities-menulist").disabled = disabled;
let communitiesRadioGroup = document.getElementById("yaru-settings-communities-group");
let clubsRadio = communitiesRadioGroup.getItemAtIndex(1);
clubsRadio.setAttribute("disabled", (disabled || communitiesRadioGroup.getAttribute("yaHasClubs") == "false"));
this.checkPublicSettingsEnabled();
},
onCommand: function(aCommandType) {
switch (aCommandType) {
case "checkbox":
this._checkFormEnabled();
break;
case "communities-radio":
let communitiesMenulist = document.getElementById("yaru-settings-communities-menulist");
if (communitiesMenulist.selectedIndex == 0)
communitiesMenulist.selectedIndex = 1;
break;
case "communities-menulist":
document.getElementById("yaru-settings-communities-group").selectedIndex = 1;
break;
case "reload-friends-data":
this.refreshYaRuUserFriendsData();
break;
default:
break;
}
this.checkPublicSettingsEnabled();
},
checkPublicSettingsEnabled: function() {
document.getElementById("yaru-settings-public-group").disabled =
!(this.enabled && YaBookmarks.enabled && this.exportChecked) ||
(document.getElementById("yaru-settings-communities-group").selectedIndex == 1);
},
expandSettings: function(aState) {
if (typeof aState !== "boolean")
aState = this.prefsObject.get("yaruBlockExpanded");
else
this.prefsObject.set("yaruBlockExpanded", !!aState);
let yaruSettingsRows = document.getElementsByAttribute("yaCollapsed", "*");
let i = 0,
state = !aState,
row;
while ((row = yaruSettingsRows.item(i++)))
row.setAttribute("yaCollapsed", state);
YaAnimator.animate();
},
requestServerData: function() {
if (this.state == this.STATES.REQUEST)
return;
this.state = this.STATES.REQUEST;
var me = this;
this.nsIYa.yaBookmarks.refreshYaRuUserData(function(args){
me.prepeareDialogCallback.apply(me, [args])
});
},
_informerLabelsHack: function() {
try {
var diff = 0;
let informerDeck = document.getElementById("yaru-settings-informer-deck");
let settingsCheckbox = document.getElementById("yaru-settings-checkbox");
let labelElement = settingsCheckbox.labelElement || settingsCheckbox.boxObject.lastChild;
diff = parseInt(labelElement.boxObject.x - informerDeck.boxObject.x + 1, 10);
if (diff > 0 && diff < 100)
informerDeck.style.marginLeft = diff + "px";
} catch(e) {}
try {
if (diff > 0 && diff < 100)
document.getElementById("yaru-settings-communities-group").lastChild.style.marginLeft = diff + "px";
} catch(e) {}
},
prepeareDialog: function() {
setTimeout(function(me){me._informerLabelsHack()},0,this)
this.restoreUserPrefs();
let i = 1, row;
while ((row = document.getElementById("yaru-settings-container-" + i++)))
row.setAttribute("hidden", "false");
let ressurectLink = document.getElementById("yaru-settings-informer-ressurect-link");
if (ressurectLink && ressurectLink.hasAttribute("href") && this.nsIYa.username) {
ressurectLink.setAttribute("href", ressurectLink.getAttribute("href")
.replace(/wow\.ya\.ru\//, this.nsIYa.username + ".ya.ru/"))
}
this.requestServerData();
},
prepeareDialogCallback: function(aData) {
if ("xml" !== typeof aData) {
this.state = this.STATES.ERROR;
} else {
if (aData.has_not_journal.length()) {
document.getElementById("yaru-settings-communities-group").getItemAtIndex(0).setAttribute("value", "create");
this.state = this.STATES.HAS_NO_JOURNAL;
} else {
switch (aData.has_journal.@status.toString()) {
case "deleted":
this.state = this.STATES.DELETED_JOURNAL;
this.exportChecked = false;
break;
case "normal":
if (aData.has_journal.toString() > "") {
this.rebuildCommunitiesList(aData);
this.state = this.STATES.HAS_JOURNAL;
break;
}
default:
this.state = this.STATES.ERROR;
break;
}
}
}
},
rebuildCommunitiesList: function(aData) {
let uidValue = (aData.has_journal.@status.toString() == "normal" &&
aData.has_journal.toString()) ?
aData.has_journal.toString() : "";
document.getElementById("yaru-settings-communities-group").getItemAtIndex(0).setAttribute("value", uidValue);
let menu = document.getElementById("yaru-settings-communities-menulist");
let menuItemCount = menu.menupopup.childNodes.length;
while (menuItemCount-- > 1)
menu.removeItemAt(menuItemCount);
let communities = aData.communities.community;
for (let i = 0, len = communities.length(); i < len; i++) {
let label = communities[i].title.toString();
let value = communities[i].feed_id.toString();
if (label && value)
menu.appendItem(label, value);
}
menuItemCount = menu.menupopup.childNodes.length;
document.getElementById("yaru-settings-communities-group").setAttribute("yaHasClubs", (menuItemCount > 1));
if (menuItemCount > 1)
menu.selectedIndex = 1;
},
getPostData: function() {
var data = null;
if (this.enabled && this.exportChecked) {
let postInCommunities = (document.getElementById("yaru-settings-communities-group").selectedIndex == 1);
let uidItem = postInCommunities ? document.getElementById("yaru-settings-communities-menulist") :
document.getElementById("yaru-settings-communities-group").selectedItem;
if (uidItem && !uidItem.disabled && uidItem.getAttribute("value")) {
data = {feed_id: uidItem.getAttribute("value")};
if (postInCommunities) {
data.status = 10;
} else {
let publicItem = document.getElementById("yaru-settings-public-group").selectedItem;
if (publicItem && !publicItem.disabled && publicItem.hasAttribute("value"))
data.status = publicItem.getAttribute("value");
}
}
}
return data;
},
setLiveWindowData: function(aData) {
this.nsIYa.DOMUtils.replaceNode(aData, document.getElementById("yasearch-livewindow-post-props"));
this.refreshYaRuUserFriendsData();
},
refreshYaRuUserFriendsData: function() {
if (this.state == this.STATES.HAS_NO_JOURNAL) {
document.getElementById("yasearch-bookmarks-add-dialog").setAttribute("yaShowLiveCheckbox", "false");
} else {
var me = this;
this.nsIYa.yaBookmarks.refreshYaRuUserFriendsData(function(args) {
me.refreshYaRuUserFriendsDataCallback.apply(me, [args])
});
}
var selectedIndex = 0;
if (document.getElementById("yasearch-livewindow-deck").selectedIndex != selectedIndex) {
document.getElementById("yasearch-livewindow-deck").selectedIndex = selectedIndex;
YaAnimator.animate();
}
},
refreshYaRuUserFriendsDataCallback: function(aData) {
let linksDiv = document.getElementById("yasearch-livewindow-firends-links");
while (linksDiv.firstChild)
linksDiv.removeChild(linksDiv.firstChild);
this.nsIYa.DOMUtils.appendNode(aData, linksDiv);
document.getElementById("yasearch-livewindow-deck").selectedIndex = 1;
YaAnimator.animate();
},
get prefsObject() {
return this.nsIYa.yaBookmarks.yaruPrefs;
},
restoreUserPrefs: function() {
this.exportChecked = this.prefsObject.get("yaruExportChecked");
if (this.prefsObject.get("yaruAddHelpShowed"))
document.getElementById("yaru-settings-informer-deck").setAttribute("yaHiddenIndex", "5");
let publicPref = this.prefsObject.get("yaruPublicVal");
let publicRadiogroup = document.getElementById("yaru-settings-public-group");
let radio, i = 0;
while ((radio = publicRadiogroup.getItemAtIndex(i++))) {
if (radio.getAttribute("value") == publicPref) {
publicRadiogroup.selectedItem = radio;
break;
}
}
},
saveUserPrefs: function() {
if (this.state == this.STATES.NO_DATA)
return;
if (this.enabled)
this.prefsObject.set("yaruExportChecked", this.exportChecked);
let publicItem = document.getElementById("yaru-settings-public-group").selectedItem;
if (publicItem && publicItem.hasAttribute("value"))
this.prefsObject.set("yaruPublicVal", publicItem.getAttribute("value"));
}
};
var YaBookmarks = {
nsIYa: Components.classes["@yandex.ru/yasearch;1"].getService(Components.interfaces.nsIYaSearch).wrappedJSObject,
get enabledPanelName() {
return document.getElementById("yasearch-bookmarks-add-dialog").getAttribute("yaEnabledPanelName");
},
set enabledPanelName(aName) {
if (this.enabledPanelName != aName) {
YaAnimator.switchToPanel(aName);
document.getElementById("yasearch-bookmarks-add-dialog").setAttribute("yaEnabledPanelName", aName);
}
return this.enabledPanelName;
},
handleListChange: function(list) {
document.getElementById("yasearch-bookmarks-newfolder").disabled =
list.selectedIndex != 0 && !list.selectedItem.hasAttribute("yafolderid");
},
__enabled: false,
get enabled() {
return this.__enabled;
},
set enabled(val) {
this.__enabled = !!val;
this.checkFormEnabled();
return this.__enabled;
},
checkFormEnabled: function() {
this._checkFormEnabled();
if (window.YaYaRu)
window.YaYaRu._checkFormEnabled();
this.enableAcceptButton();
},
enableAcceptButton: function() {
let disabled = !this.enabled ||
(document.getElementById("yasearch-bookmarks-row-url").hidden != true && document.getElementById("yasearch-bookmarks-url").value == "") ||
document.getElementById("yasearch-bookmarks-name").value == "";
document.documentElement.getButton("accept").disabled = disabled;
},
_checkFormEnabled: function() {
let disabled = !this.enabled;
let textboxes = document.getElementsByTagName("textbox");
let i = 0;
while (textboxes.item(i))
textboxes.item(i++).disabled = disabled;
document.getElementById("yasearch-bookmarks-tags").disabled = disabled;
document.getElementById("yasearch-bookmarks-folder").disabled = disabled;
},
init: function() {
YaAnimator.init();
this.enabled = false;
this.stringBundleSet = document.getElementById("yasearch-string-bundle-bookmarks");
let closeLiveWindowButton = document.documentElement.getButton("extra1");
closeLiveWindowButton.setAttribute("label", this.stringBundleSet.getString("closeWindowButtonLabel"));
closeLiveWindowButton.setAttribute("oncommand", "window.close()");
let aBrowser = window.arguments[0],
aExistId = window.arguments[2];
this.mode = aExistId ? "edit" : "add";
let documentTitleType = "yaTitlebookmarks";
let bookmark = null;
switch (this.mode) {
case "add":
var pageData = this.nsIYa.yaBookmarks.getBrowserPageData(aBrowser);
document.getElementById("yasearch-bookmarks-url").value = pageData.url;
document.getElementById("yasearch-bookmarks-name").value = pageData.name;
document.getElementById("yasearch-bookmarks-descr").value = pageData.descr;
YaYaRu.prepeareDialog();
break;
case "edit":
bookmark = this.nsIYa.bookmarksGetItemById(aExistId);
document.getElementById("yasearch-bookmarks-url").value = bookmark.url;
document.getElementById("yasearch-bookmarks-name").value = bookmark.name;
document.getElementById("yasearch-bookmarks-descr").value = bookmark.descr;
if (bookmark.type == "folder") {
document.getElementById("yasearch-bookmarks-row-url").hidden = true;
document.getElementById("yasearch-bookmarks-row-tags").hidden = true;
documentTitleType = "yaTitlefolderEdit";
} else {
documentTitleType = "yaTitlebookmarkEdit";
}
this.bookmark = bookmark;
break;
}
document.title = document.documentElement.getAttribute(documentTitleType);
document.getElementById("yasearch-bookmarks-tags").initWithValue(bookmark ? bookmark.tags : "");
var me = this;
this.nsIYa.bookmarksPrepeareDialog(function(args){ me.init_.apply(me, [args]) } )
},
init_: function(aData) {
if ("string" == typeof aData)
return this.exitWithError(aData);
this.nsIYa.DOMUtils.replaceNode(aData, document.getElementById("yasearch-bookmarks-folder"));
var bookmarksFolderMenu = document.getElementById("yasearch-bookmarks-folder");
if (bookmarksFolderMenu.nodeName != "menulist")
document.documentElement.cancelDialog();
let folder = window.arguments[1];
switch (this.mode) {
case "add":
if (!folder)
folder = this.nsIYa.yaBookmarks.lastUsedFolder.toString();
break;
case "edit":
folder = this.bookmark.parentId;
if (this.bookmark.type == "folder") {
var folderForEdit = bookmarksFolderMenu.getElementsByAttribute("yafolderid", this.bookmark.id)[0];
if (!folderForEdit)
return this.exitWithError("input");
folderForEdit.setAttribute("disabled","true");
}
break;
}
if (folder && folder != "0") {
let selectedFolder = bookmarksFolderMenu.getElementsByAttribute("yafolderid", folder)[0];
if (selectedFolder)
bookmarksFolderMenu.selectedItem = selectedFolder;
else if (this.mode !== "add")
return this.exitWithError("input");
}
this.enabled = true;
return true;
},
showError: function(aErrorType) {
this.nsIYa.yaBookmarks.showError(aErrorType, this.mode);
},
exitWithError: function(aErrorType) {
if (document) {
this.showError(aErrorType);
setTimeout(function() { document.documentElement.cancelDialog(); }, 10);
}
return false;
},
bookmarkActionCallback: function(aData) {
if ("string" == typeof aData) {
YaBookmarks.enabled = true;
if (aData == "wow_error") {
if (YaBookmarks.confirmOnYaRuNotAvailable())
YaBookmarks.onDialogAccept(true);
} else {
YaBookmarks.showError(aData);
}
} else {
var closeDialog = true;
var postedInYaRu = false;
if (aData && aData instanceof Components.interfaces.nsIDOMElement) {
postedInYaRu = true;
if (!YaYaRu.prefsObject.get("yaruLiveWindowDisabled")) {
closeDialog = false;
YaYaRu.setLiveWindowData(aData);
YaBookmarks.enabledPanelName = "livewindow";
}
}
if (closeDialog)
setTimeout(function(){document.documentElement.cancelDialog()},2);
YaYaRu.prefsObject.onHelpShowed(postedInYaRu);
}
},
confirmOnYaRuNotAvailable: function() {
let prompter = this.nsIYa.promptService;
let flags = prompter.BUTTON_POS_0 * prompter.BUTTON_TITLE_IS_STRING +
prompter.BUTTON_POS_1 * prompter.BUTTON_TITLE_IS_STRING +
prompter.BUTTON_POS_0_DEFAULT;
let rv = prompter.confirmEx(window,
this.stringBundleSet.getString("YaRuNotAvailableTitle"),
this.stringBundleSet.getString("YaRuNotAvailableMsg"),
flags,
this.stringBundleSet.getString("YaRuNotAvailableButtonYes"),
this.stringBundleSet.getString("YaRuNotAvailableButtonReturn"),
null, null, {});
return !(rv === 1);
},
onDialogAccept: function(aOnlyBookmarks) {
if (this.enabledPanelName == "livewindow")
return true;
if (this.mode == "add")
YaYaRu.saveUserPrefs();
var newFolder,
exFolderId = document.getElementById("yasearch-bookmarks-folder").selectedItem.getAttribute("yafolderid") || 0;
if (exFolderId == 0 && document.getElementById("yasearch-bookmarks-folder").selectedIndex != 0) {
newFolder = document.getElementById("yasearch-bookmarks-folder").selectedItem.getAttribute("label");
} else {
newFolder = document.getElementById("yasearch-bookmarks-newfolder").disabled ? "" : document.getElementById("yasearch-bookmarks-newfolder").value;
}
var bm = { name: document.getElementById("yasearch-bookmarks-name").value,
url: document.getElementById("yasearch-bookmarks-row-url").hidden != true ? document.getElementById("yasearch-bookmarks-url").value : "",
descr: document.getElementById("yasearch-bookmarks-descr").value,
tags: document.getElementById("yasearch-bookmarks-tags").value,
folder: exFolderId,
nfolder: newFolder,
yaru: aOnlyBookmarks ? null : YaYaRu.getPostData(),
callback: this.bookmarkActionCallback
};
this.nsIYa.yaBookmarks.lastUsedFolder = exFolderId;
if (this.mode == "add" && !YaYaRu.enabled && !aOnlyBookmarks && YaYaRu.exportChecked) {
if (!this.confirmOnYaRuNotAvailable())
return false;
YaYaRu.exportChecked = false;
bm.yaru = null;
}
this.enabled = false;
if (this.mode == "edit") {
bm.id = this.bookmark.id;
bm.type = this.bookmark.type;
bm.folderOld = this.bookmark.parentId;
bm._old_info = this.bookmark;
this.nsIYa.bookmarksEditItem(bm);
} else {
this.nsIYa.bookmarksInsertNewItem(bm);
}
return false;
},
handleWindowClick: function(aEvent) {
var target = aEvent.originalTarget;
var targetHref = target.getAttribute("href") || target.getAttribute("yahref");
if (!targetHref)
target = target.parentNode;
if (target && target.getAttribute)
targetHref = targetHref || target.getAttribute("href") || target.getAttribute("yahref");
if (targetHref) {
var action = target.hasAttribute("yaLinkAction") ? target.getAttribute("yaLinkAction") : null;
var linkTarget = target.hasAttribute("yaLinkTarget") ? target.getAttribute("yaLinkTarget") : "tab";
this.nsIYa.loadURI(targetHref, aEvent, (action ? {action:action} : null));
return false;
}
return true;
}
};