var __Bookmark = false; function _Bookmark() { if (__Bookmark) return false; _init("_sugar"); _init("_CoreElement"); Bookmark.inherits(CoreElement); Bookmark.method("set", Bookmark_set); Bookmark.method("edit", Bookmark_edit); Bookmark.method("select", Bookmark_select); Bookmark.method("remove", Bookmark_remove); Bookmark.method("getMenuId", Bookmark_getMenuId); Bookmark.method("getHelpId", Bookmark_getHelpId); Bookmark.method("edit", Bookmark_edit); Bookmark.method("cut", Bookmark_cut); Bookmark.method("copy", Bookmark_copy); Bookmark.method("createShortcut", Bookmark_createShortcut); Bookmark.method("toggleEmphasize", Bookmark_toggleEmphasize); __Bookmark = true; return true; } function Bookmark(b) { if (isBookmark(b)) { this.node = b; this.href = this.node.getAttribute("href"); this.name = this.getText(); } } function Bookmark_set(_name, _href) { this.setText(_name); this.setAttr("href", _href); Rosegarden.selected.commitBookmarks(); Rosegarden.setChanged(); } function Bookmark_edit() { Rosegarden.popupMenu.hide(); Rosegarden.dialogTarget = this; Rosegarden.dialog = new Element("edit-bookmark"); this.hide(); var hrefField = new Element("edit-bookmark-href"); var nameField = new Element("edit-bookmark-name"); hrefField.deleteChildren(); nameField.deleteChildren(); var href = this.getAttr("href"); var name = this.getText(); if (this.justCreated) { href = ""; name = ""; } hrefField.node.value = href; nameField.node.value = name; Rosegarden.menu.hide(); Rosegarden.bookmarks.node.insertBefore(Rosegarden.dialog.node, this.node.nextSibling); hrefField.node.focus(); } function Bookmark_select() { var data = getCookie(Rosegarden.COOKIE_CACHE); data = (data == null ? "" : data); _all = this.href + Rosegarden.CACHE_FIELD_SEPERATOR + this.name; data = data.replace(_all + Rosegarden.CACHE_RECORD_SEPERATOR, ""); data = _all + Rosegarden.CACHE_RECORD_SEPERATOR + data; if (data.split(Rosegarden.CACHE_RECORD_SEPERATOR).length > Rosegarden.CACHE_SIZE) { data = data.substring(0, data.lastIndexOf(Rosegarden.CACHE_RECORD_SEPERATOR)); } setCookie(Rosegarden.COOKIE_CACHE, data, Rosegarden.SETTINGS_EXPIRY_DATE); } function Bookmark_remove() { var next = this.getClosestSibling(isA); this.domDelete(); Rosegarden.selected.commitBookmarks(); Rosegarden.register(next); } function Bookmark_getMenuId() { var cssClass = this.getCSSClass(); if (cssClass.indexOf("search-bm") >= 0 || cssClass.indexOf("recent-link") >= 0) { return "menu-search-bm"; } else if (cssClass.indexOf("search-cat") >= 0) { return ""; } else { return "menu-bookmark"; } } function Bookmark_getHelpId() { return "help-bookmark"; } function Bookmark_cut(_delete) { if (!isBoolean(_delete)) { _delete = true; } var bookmark = new Element(this.domCopy(Rosegarden.clipboard.node)); bookmark.deleteCSSClass("highlight"); if (_delete) { this.remove(); Rosegarden.setChanged(); } } function Bookmark_copy() { this.cut(false); } function Bookmark_createShortcut() { var shortcut = Element.create("a", this.name, "href=" + this.href); Rosegarden.shortcuts.node.appendChild(shortcut.node); Rosegarden.setChanged(); } function Bookmark_toggleEmphasize() { if (this.getCSSClass().indexOf("top") < 0) { this.addCSSClass("top"); } else { this.deleteCSSClass("top"); } Rosegarden.selected.commitBookmarks(); Rosegarden.setChanged(); } var __Category = false; function _Category() { if (__Category) return false; _init("_sugar"); _init("_CoreElement"); Category.prototype.dialogLabel = Rosegarden.RENAME_CATEGORY_LABEL; Category.prototype.dialogLabelCreate = Rosegarden.CREATE_CATEGORY_LABEL; Category.inherits(CoreElement); Category.method("getName", Category_getName); Category.method("setName", Category_setName); Category.method("rename", Category_rename); Category.method("updateId", Category_updateId); Category.method("select", Category_select); Category.method("deselect", Category_deselect); Category.method("remove", Category_remove); Category.method("edit", Category_edit); Category.method("move", Category_move); Category.method("moveUp", Category_moveUp); Category.method("moveDown", Category_moveDown); Category.method("paste", Category_paste); Category.method("createShortcut", Category_createShortcut); Category.method("createBookmark", Category_createBookmark); Category.method("createCategory", Category_createCategory); Category.method("createSubCategory", Category_createSubCategory); Category.method("createSubCategories", Category_createSubCategories); Category.method("commitBookmarks", Category_commitBookmarks); Category.method("updateBookmarks", Category_updateBookmarks); Category.method("visit", Category_visit); Category.method("getCategoryPath", Category_getCategoryPath); Category.method("getMenuId", Category_getMenuId); Category.method("getHelpId", Category_getHelpId); Category.method("getDialogLabel", Catgegory_getDialogLabel); Category.copyTo = function (o) {new Node(o).domCopy(Rosegarden.bookmarks.node);}; __Category = true; return true; } function Category(c) { if (isNonEmptyString(c)) { c = document.getElementById(c); } if (isCategoryLabel(c)) { this.node = c; this.category = new Element(this.getClosestSibling(isDiv, true)); } else if (isCategory(c)) { this.category = new Element(c); this.node = this.category.getClosestSibling(isP, false); } if (this.node != null) { this.catId = this.category.getAttr("id"); } } function Category_setName(name) { this.setText(decodeURI(name)); } function Category_getName() { return this.getText(); } function Category_rename(newName) { var oldCatId = this.catId; this.setName(newName); this.updateId(); var shortcuts = Rosegarden.shortcuts.getChildren(isP); for (var i = 0; i < shortcuts.length; i += 1) { var next = new CoreElement(shortcuts[i]); var catId = next.getAttr("cat-id"); if (catId == oldCatId) next.setText(this.getName()); var newCatId = catId.replace(new RegExp(eval("/-" + oldCatId + "-/")), "-" + this.catId + "-"); newCatId = newCatId.replace(new RegExp(eval("/^" + oldCatId + "-/")), this.catId + "-"); newCatId = newCatId.replace(new RegExp(eval("/-" + oldCatId + "$/")), "-" + this.catId); newCatId = newCatId.replace(new RegExp(eval("/^" + oldCatId + "$/")), this.catId); next.setAttr("cat-id", newCatId); } } function Category_updateId() { if (this.id == "Top") { return; } var parentId = new Category(this.node.parentNode).catId; if (parentId == "Top") { this.catId = encodeURI(this.getName().replace(" ", "_")); } else { this.catId = parentId + "-" + encodeURI(this.getName().replace(" ", "_")); } this.category.setAttr("id", this.catId); var children = this.category.getChildren(isP); children.map(function(p) { new Category(p).updateId(); }); } function Category_select(_event) { if (Rosegarden.selected != null) { if (Rosegarden.selected.node == this.node) { return; } Rosegarden.selected.deselect(); } this.setAttr("style", "display: block;"); var ancestors = this.category.getAncestors(isCategory); ancestors.map(function(o) {new Category(o).setAttr("style", "display: block;");}); var children = this.category.getChildren(isP); children.map(function (o) {new Element(o).addCSSClass("sub-category");}); this.updateBookmarks(); var title = Rosegarden.HEADLINE_BM_PREFIX + this.getCategoryPath(); if (this.catId == "Top") { title = Rosegarden.HEADLINE_BM_CACHED; var recents = Rosegarden.getRecentlyVisited(); if (recents != null && recents.length > 0) { recents.map(Category.copyTo); } } else { if (is_ie || is_opera) { title = Rosegarden.HEADLINE_BM; } } new Element("bookmarks-label").setText(decodeURI(title)); Rosegarden.options._lastCategory = this.catId; Rosegarden.saveOptions(); Rosegarden.selected = this; Rosegarden.autoRegister(_event); } function Category_deselect() { this.removeStyle(); var ancestors = this.category.getAncestors(isCategory); ancestors.map(function(o) {new Category(o).removeStyle();}); var children = this.category.getChildren(isP); children.map(function (o) {new Element(o).deleteCSSClass("sub-category");}); Rosegarden.bookmarks.deleteChildren(isA); Rosegarden.selected = null; } function Category_remove() { new Category(this.node.parentNode).select(); var a = this.category.node; var filter = function (o) { return isCategoryShortcut(o) && new CategoryShortcut(o).isDependantOn(a); }; Rosegarden.shortcuts.deleteChildren(filter); var next = this.getClosestSibling(isP); this.category.domDelete(); this.domDelete(); if (!this.justCreated) { Rosegarden.setChanged(); } Rosegarden.register(next); } function Category_edit() { new Category(this.node.parentNode).select(); var field = new Element("edit-element-name"); if (is_ie) { field.setAttr("style", "left: 0em;"); } this.uber("edit"); } function Category_move() { new Category(this.node.parentNode).select(); Rosegarden.popupMenu.hide(); Rosegarden.moved = this; this.deleteCSSClass("highlight"); this.addCSSClass("moved"); document.onkeydown = Rosegarden.handleMoving; } function Category_moveUp() { this.domMoveUpWithin(isP); this.category.domMoveUpWithin(isP); } function Category_moveDown() { this.category.domMoveDownWithin(isDiv); this.domMoveDownWithin(isDiv); } function Category_paste() { this.select(); var children = Rosegarden.clipboard.getChildren(isElement); if (children.length == 0) { alert(Rosegarden.WARN_CLIPBOARD_EMPTY); } else { var dest = this.category.node; children.map(function(o) { new Node(o).domMove(dest); }); this.updateBookmarks(); Rosegarden.setChanged(); } } function Category_createShortcut() { var shortcut = Element.create("p", this.getName(), "cat-id=" + this.catId); Rosegarden.shortcuts.node.appendChild(shortcut.node); Rosegarden.setChanged(); } function Category_createBookmark() { if (this.catId == "Top") { alert(Rosegarden.WARN_NO_BM_IN_TOP); return; } this.select(); var newElement = Element.create("a", "new-bookmark-name", "href=new-bookmark-url"); Rosegarden.bookmarks.node.appendChild(newElement.node); var newBookmark = new Bookmark(newElement.node); newBookmark.justCreated = true; newBookmark.edit(); } function Category_createCategory() { this.select(); var newCategory = this.createSubCategory("justCreated"); newCategory.justCreated = true; newCategory.addCSSClass("sub-category"); newCategory.edit(); } function Category_createSubCategory(_name) { var _catId = _name.replace(/%20/g, "_").replace(/ /g, "_"); var newCatId = this.catId + "-" + _catId; if (this.catId == "Top") { newCatId = _catId; } var newCategory = new Category(newCatId); if (newCategory.node == null) { var newLabel = Element.create("p", decodeURI(_name)); var newCategoryE = Element.create("div", "", "id=" + newCatId); this.category.node.appendChild(newLabel.node); this.category.node.appendChild(newCategoryE.node); newCategory = new Category(newLabel.node); } return newCategory; } function Category_createSubCategories(_path) { var categories = _path.split("/"); var parent = this; for (var i = 0; i < categories.length - 1; i++) { var nextCategory = categories[i]; nextCategory = nextCategory.replace(/_/g, " "); var parent = parent.createSubCategory(nextCategory); } return parent; } function Category_commitBookmarks() { this.category.deleteChildren(isA); var children = Rosegarden.bookmarks.getChildren(isA); var target = this.category.node; children.map(function (o) { var element = new Element(new Node(o).domCopy(target)); element.deleteCSSClass("highlight"); element.deleteCSSClass("moved"); }); } function Category_updateBookmarks() { Rosegarden.bookmarks.deleteChildren(isA); var _bookmarks = this.category.getChildren(isA); _bookmarks.map(Category.copyTo); } function Category_visit(dest) { if (isString(dest)) { var _url = Rosegarden["PREFIX_" + dest]; if (isNonEmptyString(_url)) { window.location = _url + this.getCategoryPath(); } } } function Category_getCategoryPath() { if (this.catId == "Top") return ""; return this.catId.replace(/-/g, '/').replace(/ /g, '_'); } function Category_getMenuId() { if (this.node.parentNode == Rosegarden.categories.node) { return "menu-top-category"; } else { return "menu-category"; } } function Category_getHelpId() { if (this.node == Rosegarden.selected.node) { return "help-selected-category"; } else if (Rosegarden.selected.isGrandchildOf(this.category.node)) { return "help-super-category"; } else { return "help-category"; } } function Catgegory_getDialogLabel() { if (this.justCreated) { return Rosegarden.CREATE_CATEGORY_LABEL; } else { return Rosegarden.RENAME_CATEGORY_LABEL; } } var __Configuration = false; function _Configuration() { if (__Configuration) { return false; } _init("_sugar"); Configuration.method("read", Configuration_read); Configuration.method("write", Configuration_write); __Configuration = true; return true; } function Configuration(_string, _recordSeparator) { this.recordSeparator = ";"; if (isNonEmptyString(_recordSeparator)) { this.recordSeparator = _recordSeparator; } this.read(_string); } function Configuration_read(_string) { if (_string == null) return; var pair = _string.split(this.recordSeparator); for (var i = 0; i < pair.length; i++) { var keyValue = pair[i].split("="); var key = keyValue[0]; var value = keyValue[1]; this[key] = value; } } function Configuration_write() { var _string = ""; for (var property in this) if (property.indexOf("_") == 0) _string += property + "=" + this[property] + this.recordSeparator; return _string; } var __Container = false; function _Container() { if (__Container) return false; _init("_sugar"); _init("_Element"); Container.inherits(Element); Container.method("retrieve", Container_retrieve); Container.method("store", Container_store); Container.prototype.storage = document.getElementById("resources"); __Container = true; return true; } function Container(e) { this.node = e; this.resource = null; } function Container_retrieve(resourceId) { this.store(); this.resource = document.getElementById(resourceId); if (this.resource != null) { this.node.appendChild(this.resource); } } function Container_store() { if (this.resource != null) { Container.prototype.storage.appendChild(this.resource); this.resource = null; } } var __CoreElement = false; function _CoreElement() { if (__CoreElement) { return false; } _init("_sugar"); _init("_html"); CoreElement.inherits(Element); CoreElement.method("rename", CoreElement_rename); CoreElement.method("edit", CoreElement_edit); CoreElement.method("move", CoreElement_move); CoreElement.method("moveUp", CoreElement_moveUp); CoreElement.method("moveDown", CoreElement_moveDown); CoreElement.method("remove", CoreElement_remove); CoreElement.method("getMenuId", CoreElement_getMenuId); CoreElement.method("getHelpId", CoreElement_getHelpId); CoreElement.method("getDialogLabel", CoreElement_getDialogLabel); __CoreElement = true; return true; } function CoreElement(o) { var self = null; if (isCategoryLabel(o) || isCategory(o)) { self = new Category(o); } else if (isShortcut(o)) { if (isCategoryShortcut(o)) { self = new CategoryShortcut(o); } else { self = new Shortcut(o); } } else if (isBookmark(o)) { self = new Bookmark(o); } return self; } function CoreElement_rename(newName) { this.setText(newName); } function CoreElement_edit() { Rosegarden.popupMenu.hide(); Rosegarden.dialogTarget = this; Rosegarden.dialog = new Element("edit-element"); this.hide(); var nameField = new Element("edit-element-name"); nameField.deleteChildren(); var defaultValue = this.getText(); if (this.justCreated) { defaultValue = ""; } var _dialogLabel = this.getDialogLabel(); new Element("edit-element-headline").setText(_dialogLabel); Rosegarden.dialog.domMove(this.node.parentNode, this.node, false); nameField.node.value = defaultValue; nameField.node.focus(); } function CoreElement_move() { Rosegarden.popupMenu.hide(); Rosegarden.moved = this; this.deleteCSSClass("highlight"); this.addCSSClass("moved"); document.onkeydown = Rosegarden.handleMoving; } function CoreElement_moveUp() { this.domMoveUpWithin(function (o) {return isP(o) || isA(o);}); } function CoreElement_moveDown() { this.domMoveDownWithin(isElement); } function CoreElement_remove() { var next = this.getClosestSibling(function (o) { return isP(o) || isA(o); }); this.domDelete(); Rosegarden.setChanged(); Rosegarden.register(next); } function CoreElement_getMenuId() { return this.menuId; } function CoreElement_getHelpId() { return this.helpId; } function CoreElement_getDialogLabel() { return Rosegarden.RENAME_SHORTCUT_LABEL; } var __Debug = false; function _Debug() { if (__Debug) return false; _init("_sugar"); _init("_html"); _init("_Element"); Debug.inherits(Element); Debug.method("debug", Debug_debug); Debug.method("cdebug", Debug_cdebug); __Debug = true; return true; } function Debug() { this.node = new Element("debug").node; } function Debug_debug(message) { if (isString(message)) { if (this.countChildren(isP) > 20) { this.deleteChildren(); } var p = Element.create("p", message); this.node.appendChild(p.node); } } function Debug_cdebug(message, condition) { if (condition == true) { this.debug(message); } } var __dom = false; function _dom() { if (__dom) { return false; } _init("_remedial"); __dom = true; return true; } function isNode(a) { return isObject(a) && isNumber(a.nodeType); } function isElement(a) { return isNode(a) && a.nodeType == 1; } function isTextNode(a) { return isNode(a) && a.nodeType == 3; } var __Element = false; function _Element() { if (__Element) { return false; } _init("_sugar"); _init("_dom"); _init("_String"); _init("_trans"); _init("_Node"); Element.inherits(Node); Element.method("getAbsoluteX", Element_getAbsoluteX); Element.method("getAbsoluteY", Element_getAbsoluteY); Element.method("moveTo", Element_moveTo); Element.method("moveOver", Element_moveOver); Element.method("isOver", Element_isOver); Element.method("getAttr", Element_getAttr); Element.method("setAttr", Element_setAttr); Element.method("getCSSClass", Element_getCSSClass); Element.method("setCSSClass", Element_setCSSClass); Element.method("addCSSClass", Element_addCSSClass); Element.method("deleteCSSClass", Element_deleteCSSClass); Element.method("replaceCSSClass", Element_replaceCSSClass); Element.method("removeStyle", Element_removeStyle); Element.method("show", Element_show); Element.method("hide", Element_hide); Element.method("isHidden", Element_isHidden); Element.method("toggleVisibilty", Element_toggleVisibilty); Element.method("getText", Element_getText); Element.method("setText", Element_setText); Element.method("getHtmlCode", Element_getHtmlCode); Element.create = Element_create; Element.method("reverseText", Element_reverseText); __Element = true; return true; } function Element(e) { if (isElement(e)) { this.node = e; } else if (isNonEmptyString(e)) { this.node = document.getElementById(e); } } function Element_create(tagName, text) { if (isString(tagName) && (text == null || isString(text))) { var element = new Element(document.createElement(tagName)); element.setText(text); for (var i = 2; i < arguments.length; ++i) { var next = arguments[i]; var position = next.indexOf("="); var attributeName = ""; var attributeValue = ""; if (position > 0) { attributeName = next.substring(0, position); attributeValue = next.substring(position + 1, next.length); } element.setAttr(attributeName, attributeValue); } return element; } return null; } function Element_getAbsoluteX() { return getAbsolute(this.node, "offsetLeft"); } function Element_getAbsoluteY(element) { return getAbsolute(this.node, "offsetTop"); } function getAbsolute(element, property) { var r = element[property]; var parent = element.offsetParent; while (parent != null) { r += parent[property]; parent = parent.offsetParent; } return r; } function Element_moveTo(x,y) { this.setAttr("style", "position: absolute; " + "top: " + y + "px; " + "left: " + x + "px;"); } function Element_moveOver(_target, dX, dY) { var target = new Element(_target); var x = target.getAbsoluteX() + target.node.offsetWidth * dX; var y = target.getAbsoluteY() + target.node.offsetHeight * dY; this.moveTo(x,y); } function Element_isOver(x, y) { var tlX = this.getAbsoluteX(); var tlY = this.getAbsoluteY(); var brX = this.getAbsoluteX() + this.node.offsetWidth; var brY = this.getAbsoluteY() + this.node.offsetHeight; return (tlX <= x && x <= brX) && (tlY <= y && y <= brY); } function Element_setAttr(name, value) { if (isString(name) && isString(value)) { if (!is_ie) { this.node.setAttribute(trans(name), value); } else { if (name == "id") { this.node.id = value; } else if (name == "style") { this.node.style.cssText = value; } else { this.node.setAttribute(trans(name), value); } } } } function Element_getAttr(name) { if (isString(name)) { return this.node.getAttribute(trans(name)); } return ""; } function Element_getCSSClass() { return this.node.getAttribute(trans("class")); } function Element_setCSSClass(_class) { var classA = _class.trim(); classA = classA.replace(/\s{2,}/g, " "); this.node.setAttribute(trans("class"), classA); } function Element_addCSSClass(_class, append) { if (!isBoolean(append)) append = true; var classA = this.getCSSClass(); if (isNonEmptyString(classA)) { if (classA.indexOf(_class) < 0) { var newClass = _class + " " + classA; if (append) { newClass = classA + " " + _class; } this.setCSSClass(newClass); } } else { this.setCSSClass(_class); } } function Element_deleteCSSClass(_class) { this.replaceCSSClass(_class, ""); } function Element_replaceCSSClass(classOld, classNew, force) { if (!isBoolean(force)) { force = false; } var regexp = "/(\\s|^)" + classOld + "(\\s|$)/g"; var classA = this.getCSSClass(); if (isNonEmptyString(classA)) { var newClass = classA.replace(new RegExp(eval(regexp)), " " + classNew + " "); this.setCSSClass(newClass); if (force && newClass.indexOf(classNew) < 0) { this.addCSSClass(classNew); } } else { this.setCSSClass(classNew); } } function Element_removeStyle() { if (is_ie) { this.node.style.cssText = ""; } else { this.node.removeAttribute("style"); } } function Element_show() { this.deleteCSSClass("hidden"); } function Element_hide() { this.addCSSClass("hidden"); } function Element_isHidden() { return this.getCSSClass().indexOf("hidden") >= 0; } function Element_toggleVisibilty() { if (this.isHidden()) { this.show(); } else { this.hide(); } } function Element_getText() { var textNode = this.getFirstChild(isTextNode); if (textNode == null || textNode.data == null) { return ""; } else { return textNode.data; } } function Element_setText(text) { if (isString(text)) { var textNode = this.getFirstChild(isTextNode); if (textNode != null) { textNode.data = text; } else { this.node.appendChild(document.createTextNode(text)); } } } function Element_getHtmlCode(elementFilter, attributeNameFilter, attributeValueFilter, indentLevel) { if (!isFunction(elementFilter)) { elementFilter = isElement; } if (!isFunction(attributeNameFilter)) { attributeNameFilter = isString; } if (!isFunction(attributeValueFilter)) { attributeValueFilter = isString; } if (!isNumber(indentLevel)) { indentLevel = -1; } if (!elementFilter(this.node)) return ""; var indentString = ""; for (var i = 0; i < indentLevel; i += 1) { indentString += " "; } var code = "\n" + indentString + "<" + this.node.tagName.toLowerCase(); var _attributes = this.node.attributes; for (var i = 0; i < _attributes.length; i += 1) { var attributeName = _attributes[i].name.toLowerCase(); var attributeValue = _attributes[i].value; if (attributeNameFilter(attributeName) && attributeValueFilter(attributeValue)) { code += ' ' + attributeName + '="' + attributeValue + '"'; } } var children = this.node.childNodes; if (children.length == 0) code += "></" + this.node.tagName.toLowerCase() + ">"; else code += ">"; var hasElementChildren = false; for (var i = 0; i < children.length; i++) { if (isElement(children[i])) { code += new Element(children[i]).getHtmlCode(elementFilter, attributeNameFilter, attributeValueFilter, (indentLevel >= 0 ? indentLevel + 1 : -1)); hasElementChildren = true; } if (isTextNode(children[i])) { if (isNonEmptyString(children[i].data)) { code += children[i].data; } } } var leadString = ""; if (hasElementChildren) { leadString = "\n" + indentString; } if (children.length > 0) code += leadString + "</" + this.node.tagName.toLowerCase() + ">"; return code; } function Element_reverseText() { this.setText(this.getText().reverse()); } var __Help = false; function _Help() { if (__Help) return this; _init("_sugar"); _init("_trans"); _init("_Element"); Help.inherits(Element); Help.method("turnOn", Help_turnOn); Help.method("turnOff", Help_turnOff); Help.method("toggle", Help_toggle); Help.method("update", Help_update); __Help = true; } function Help(canvas, _section) { this.node = canvas; this.section = new Container(_section); } function Help_turnOn() { this.show(); Rosegarden.configuration._help = "true"; new Element("button-help").setText(Rosegarden.HELP_ON); } function Help_turnOff() { this.hide(); Rosegarden.configuration._help = "false"; new Element("button-help").setText(Rosegarden.HELP_OFF); } function Help_toggle() { if (this.isHidden()) { this.turnOn(); } else { this.turnOff(); } } function Help_update(_event) { var helpId = null; if (Rosegarden.moved != null) { return; } if (_event != null) { if (isString(_event)) { helpId = _event; } else { var target = null; if (isNode(_event)) { target = _event; } else { target = _event[trans("target")]; } if (isNode(target)) { var helpId = new Element(target).getAttr("help-id"); if (!isNonEmptyString(helpId)) { var targetE = new CoreElement(target); if (targetE.getHelpId != null) { helpId = targetE.getHelpId(); } } } } } if (!isNonEmptyString(helpId)) { helpId = Rosegarden.editMode ? "help-edit-mode" : "help-view-mode"; } this.section.retrieve(helpId); } var __html = false; function _html() { if (_html){ return this; } _init("_dom"); __html = true; } function isA(o) { return isElement(o) && o.tagName.toLowerCase() == "a"; } function isP(o) { return isElement(o) && o.tagName.toLowerCase() == "p"; } function isSpan(o) { return isElement(o) && o.tagName.toLowerCase() == "span"; } function isH1(o) { return isElement(o) && o.tagName.toLowerCase() == "h1"; } function isDiv(o) { return isElement(o) && o.tagName.toLowerCase() == "div"; } function isInput(o) { return isElement(o) && o.value; } function _init(funcName) { func = eval(funcName); try { func(); } catch (e) { alert("Failed to initialize " + funcName + "! " + e); } } var __misc = false; function _misc() { if (__misc) { return false; } _init("_trans"); __misc = true; return true; } function _write(string, _document) { if (string == null || string.length == 0) return; if (_document == null) _document = document; var rest = string; var cut = rest.indexOf("script"); while (cut > 0) { _document.write(rest.substring(0, cut + 4)); rest = rest.substring(cut + 4); cut = rest.indexOf("script"); } _document.write(rest); } function getURLParameterValue(parameter, url) { if (url == null) url = document.URL; var regex = "/.*" + parameter + "=([^&]*).*/"; var match = new RegExp(eval(regex)).exec(url); if (match != null && match[1] != null) return decodeURI(match[1]); else return null; } function _focus(fieldId) { var field = document.getElementById(fieldId); if (field != null) { field.focus(); } } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return decodeURI(dc.substring(begin + prefix.length, end)); } function setCookie(name, value, expires, path, domain, secure) { var _cookie = name + "=" + encodeURI(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = _cookie; } function checkMandatoryField(field) { if (isInput(field)) { var _value = field.value; if (_value == null || _value.length == 0) { field.focus(); return false } return true; } } var __Node = false; function _Node() { if (__Node) return false; _init("_sugar"); _init("_dom"); _init("_trans"); Node.method("domCopy", Node_domCopy); Node.method("domMove", Node_domMove); Node.method("domMoveWithin", Node_domMoveWithin); Node.method("domMoveUpWithin", Node_domMoveUpWithin); Node.method("domMoveDownWithin", Node_domMoveDownWithin); Node.method("domReplace", Node_domReplace); Node.method("domDelete", Node_domDelete); Node.method("getNthSibling", Node_getNthSibling); Node.method("getClosestSibling", Node_getClosestSibling); Node.method("getFirstChild", Node_getFirstChild); Node.method("getChildren", Node_getChildren); Node.method("deleteChildren", Node_deleteChildren); Node.method("countChildren", Node_countChildren); Node.method("isGrandchildOf", Node_isGrandchildOf); Node.method("isAncestorOf", Node_isAncestorOf); Node.method("getAncestors", Node_getAncestors); Node.method("getAncestor", Node_getAncestor); Node.method("applyToChildren", Node_applyToChildren); Node.method("addEvtListener", Node_addEvtListener); Node.method("removeEvtListener", Node_removeEvtListener); __Node = true; return true; } function Node(n) { if (isNode(n)) { this.node = n; } } function Node_domCopy(destination, anchor) { if (!isNode(anchor)) { anchor = null; } var clone = null; if (isNode(destination)) { clone = this.node.cloneNode(true); destination.insertBefore(clone, anchor); } return clone; } function Node_domMove(destination, anchor, after) { if (!isBoolean(after)) { after = true; } if (isNode(destination)) { if (!isNode(anchor)) { if (after) { anchor = destination.lastChild; } else { anchor = destination.firstChild; } } if (after) { if (anchor == null || anchor.nextSibling == null) { destination.appendChild(this.node); } else { destination.insertBefore(this.node, anchor.nextSibling); } } else { destination.insertBefore(this.node, anchor); } } } function Node_domMoveWithin(filter, next) { if (!isBoolean(next)) { next = true; } if (!isFunction(filter)) { filter = isNode; } var sibling = this.getClosestSibling(filter, next); if (sibling != null) { this.domMove(this.node.parentNode, sibling, next); } } function Node_domMoveUpWithin(filter) { this.domMoveWithin(filter, false); } function Node_domMoveDownWithin(filter) { this.domMoveWithin(filter, true); } function Node_domReplace(byNode) { if (isNode(byNode)) { this.node.parentNode.replaceChild(this.node, byNode); } } function Node_domDelete() { this.node.parentNode.removeChild(this.node); } function Node_getNthSibling(filter, next, nth) { if (!isFunction(filter)) { filter = isNode; } if (!isBoolean(next)) { next = true; } if (!isNumber(nth)) { nth = 1; } if (next) { direction = "nextSibling"; } else { direction = "previousSibling"; } var sibling = this.node; var matches = 0; while (sibling != null && matches < nth) { sibling = sibling[direction]; if (filter(sibling)) { matches++; } } return sibling; } function Node_getClosestSibling(filter, next) { return this.getNthSibling(filter, next, 1); } function Node_getFirstChild(filter) { if (!isFunction(filter)) { filter = isNode; } var first = this.node.firstChild; if (filter(first)) { return first; } else { return new Node(first).getClosestSibling(filter); } return null; } function Node_getChildren(filter) { if (filter == null) filter = isNode; var result = new Array(); var c = 0; var children = this.node.childNodes; for (var i = 0; i < children.length; i++) { if (filter(children[i])) { result[c] = children[i]; c += 1; } } return result; } function Node_deleteChildren(filter) { if (filter == null) filter = isNode; var children = this.node.childNodes; for (var i = children.length; i >= 0; i--) { if (filter(children[i])) { this.node.removeChild(children[i]); } } } function Node_countChildren(filter) { return this.getChildren(filter).length; } function Node_isGrandchildOf(candidate) { if (isNode(candidate)) { var climber = this.node.parentNode; while (climber != null && climber != candidate) { climber = climber.parentNode; } if (climber == candidate) { return true; } } return false; } function Node_isAncestorOf(candidate) { if (isNode(candidate)) { return new Node(candidate).isGrandchildOf(this.node); } return false; } function Node_getAncestors(filter) { if (filter == null) filter = isNode; var result = new Array(); var c = 0; var ancestor = this.node.parentNode; while (ancestor != null) { if (filter(ancestor)) { result[c] = ancestor; c += 1; } ancestor = ancestor.parentNode; } return result; } function Node_getAncestor(filter) { if (!isFunction(filter)) { filter = isNode; } var parent = this.node.parentNode; if (parent == null) return null; if (filter(parent)) { return parent; } else { return new Node(parent).getAncestor(filter); } } function Node_applyToChildren(_function, _class, filter, fromLeavesToRoot) { if (this.node == null) return null; if (!isFunction(_function)) { _function = Node.prototype.countChildren; } if (!isFunction(filter)) { filter = isNode; } if (!isBoolean(fromLeavesToRoot)) { fromLeavesToRoot = true; } var result = null; if (!fromLeavesToRoot && filter(this.node)) { result += _function.apply(this, [arguments[4]]); } var children = this.node.childNodes; for(var i = 0; i < children.length; i += 1) { var nextChild = children.item(i); result += new _class(nextChild).applyToChildren(_function, _class, filter, fromLeavesToRoot, arguments[4]); } if (fromLeavesToRoot && filter(this.node)) { result += _function.apply(this, [arguments[4]]); } return result; } function Node_addEvtListener(type, listener, capture) { if (is_ie) { this.node.attachEvent("on" + type, listener); } else { this.node.addEventListener(type, listener, capture); } } function Node_removeEvtListener(type, listener, capture) { if (is_ie) { this.node.detachEvent("on" + type, listener); } else { this.node.removeEventListener(type, listener, capture); } } var __PopupMenu = false; function _PopupMenu() { if (__PopupMenu) return false; _init("_sugar"); _init("_trans"); _init("_Container"); PopupMenu.inherits(Element); PopupMenu.swiss(Container, "retrieve", "store"); PopupMenu.method("activate", PopupMenu_activate); PopupMenu.method("deactivate", PopupMenu_deactivate); PopupMenu.method("hide", PopupMenu_hide); __PopupMenu = true; return true; } function PopupMenu(e, _dX, _dY, _superMenu) { this.node = e; this.resource = null; this.dX = (_dX != null) ? _dX : 0.5; this.dY = (_dY != null) ? _dY : 0.5; this.invoker = null; this.superMenu = _superMenu; this.subMenu = null; } function PopupMenu_activate(menuId, _invoker) { if (isString(_invoker)) { this.invoker = new Element(_invoker); } else if (_invoker != null) { if (_invoker.node) { this.invoker = _invoker; } else { this.invoker = new Element(_invoker[trans("target")]); } } this.retrieve(menuId); this.moveOver(this.invoker.node, this.dX, this.dY); } function PopupMenu_deactivate(_event) { if (this.superMenu == null || _event == null) { this.store(); this.invoker = null; } else { _event = getEvent(_event); var relatedTarget = _event[trans("relatedTarget")]; var deactivateMenu = true; var deactivateSupermenu = true; if (relatedTarget != null) { if (relatedTarget == this.invoker.node || (relatedTarget.parentNode != null && relatedTarget.parentNode.parentNode == this.node)) { deactivateMenu = false; deactivateSupermenu = false; } if (relatedTarget.parentNode.parentNode == this.superMenu.node) { deactivateSupermenu = false; } } if (deactivateMenu) { this.hide(); this.store(); this.invoker = null; if (this.subMenu != null) { this.subMenu.deactivate(); } } if (deactivateSupermenu) { this.superMenu.deactivate(_event); } } } function PopupMenu_hide() { if (this.subMenu != null) { this.subMenu.hide(); } this.uber("hide"); } var __remedial = false; function _remedial() { if (__remedial) return false; Array.method("map", Array_map); Array.method("append", Array_append); __remedial = true; return true; } function isAlien(a) { return isObject(a) && typeof a.constructor != 'function'; } function isArray(a) { return isObject(a) && a.constructor == Array; } function isBoolean(a) { return typeof a == 'boolean'; } function isEmpty(o) { var i, v; if (isObject(o)) { for (i in o) { v = o[i]; if (isUndefined(v) && isFunction(v)) { return false; } } } return true; } function isFunction(a) { return typeof a == 'function'; } function isNull(a) { return typeof a == 'object' && !a; } function isNumber(a) { return typeof a == 'number' && isFinite(a); } function isObject(a) { return (a && typeof a == 'object') || isFunction(a); } function isString(a) { return typeof a == 'string'; } function isUndefined(a) { return typeof a == 'undefined'; } function Array_map(fnc) { var a = new Array(this.length); for (var i = 0; i < this.length; i++) { a[i] = fnc(this[i]); } return a; } function Array_append(a) { for (var i = 0; i < a.length; i += 1) { this.push(a[i]); } } var __Rosegarden = false; function _Rosegarden() { if (__Rosegarden) return false; _init("_Element"); _init("_misc"); _init("_trans"); _init("_Bookmark"); _init("_Category"); _init("_Configuration"); _init("_PopupMenu"); _init("_Shortcut"); _init("_Help"); _init("_Debug"); Rosegarden.reg = null; Rosegarden.selected = null; Rosegarden.moved = null; Rosegarden.changed = false; Rosegarden.editMode = true; Rosegarden.dialog = null; Rosegarden.dialogTarget = null; Rosegarden.popupMenuOffsetX = 0.4; Rosegarden.USERNAME = document.title.replace("Rosegarden - ", ""); Rosegarden.COOKIE_OPTIONS = "Rosegarden.options." + Rosegarden.USERNAME; Rosegarden.COOKIE_CACHE = "Rosegarden.cache." + Rosegarden.USERNAME; Rosegarden.body = new Element("body"); Rosegarden.shortcuts = new Element("shortcuts"); Rosegarden.categories = new Element("categories"); Rosegarden.bookmarks = new Element("links"); Rosegarden.configuration = new Configuration(new Element("configuration").getText()); Rosegarden.options = new Configuration(getCookie(Rosegarden.COOKIE_OPTIONS), "|"); Rosegarden.menu = new Element("menu"); Rosegarden.popupMenu = new PopupMenu(new Element("popup-menu").node, Rosegarden.popupMenuOffsetX, 0.5); Rosegarden.popupSubMenu = new PopupMenu(new Element("popup-sub-menu").node, Rosegarden.popupMenuOffsetX, 0.5, Rosegarden.popupMenu); Rosegarden.clipboard = new Element("clipboard"); Rosegarden.resources = new Element("resources"); Rosegarden.help = new Help(new Element("help-screen").node, new Element("help").node); Rosegarden.dbg = new Debug("debug"); Rosegarden.CACHE_SIZE = "10"; Rosegarden.CACHE_RECORD_SEPERATOR = "|~|"; Rosegarden.CACHE_FIELD_SEPERATOR = "^°"; Rosegarden.SETTINGS_EXPIRY_DATE = new Date(100000000000000); Rosegarden.WARN_NO_BM_IN_TOP = "It is not possible to create a bookmark in the top category! " + "Use a shortcut instead."; Rosegarden.WARN_OPERATION = "This operation is not possible!"; Rosegarden.WARN_NO_SAVING = "The example Rosegarden does not support saving!"; Rosegarden.WARN_CLIPBOARD_EMPTY = "The clipboard is empty!"; Rosegarden.WARN_NAME_REQUIRED = "Name is required!"; Rosegarden.WARN_URL_REQUIRED = "URL is required!"; Rosegarden.WARN_IMPORT = "Do not forget to save if you want to keep the" + "imported bookmarks in your Rosegarden!"; Rosegarden.PREFIX_ODP = "http:/" + "/www.dmoz.org/"; Rosegarden.PREFIX_GOOGLE = "http:/" + "/www.google.com/Top/"; Rosegarden.PREFIX_FILESYSTEM = Rosegarden.options._filesystem; Rosegarden.HELP_ON = "Help [on]"; Rosegarden.HELP_OFF = "Help [off]"; Rosegarden.EDIT_MODE_ON = "Edit [on]"; Rosegarden.EDIT_MODE_OFF = "Edit [off]"; Rosegarden.HEADLINE_SHORTCUTS = "Shortcuts"; Rosegarden.HEADLINE_CATEGORIES = "Categories"; Rosegarden.HEADLINE_BM_CACHED = "Recently used Bookmarks"; Rosegarden.HEADLINE_BM_PREFIX = "Bookmarks in /"; Rosegarden.HEADLINE_BM = "Bookmarks"; Rosegarden.RENAME_CATEGORY_LABEL = "Rename category"; Rosegarden.CREATE_CATEGORY_LABEL = "Create category"; Rosegarden.RENAME_SHORTCUT_LABEL = "Rename shortcut"; Rosegarden.EDIT_OPTIONS_LABEL = "Options"; Rosegarden.WARN_NO_SAVING_WHILE_EDITING = "You cannot save during editing. Please confirm with 'Enter' " + "or cancel with 'Esc'!"; Rosegarden.save = Rosegarden_save; Rosegarden.setChanged = Rosegarden_setChanged; Rosegarden.toggleEditMode = Rosegarden_toggleEditMode; Rosegarden.getRecentlyVisited = Rosegarden_getRecentlyVisited; Rosegarden.clearRecentlyVisited = Rosegarden_clearRecentlyVisited; Rosegarden.handleCommands = Rosegarden_handleCommands; Rosegarden.handleEditing = Rosegarden_handleEditing; Rosegarden.handleOptionEditing = Rosegarden_handleOptionEditing; Rosegarden.handleMoving = Rosegarden_handleMoving; Rosegarden.register = Rosegarden_register; Rosegarden.unregister = Rosegarden_unregister; Rosegarden.autoRegister = Rosegarden_autoRegister; Rosegarden.activateRegistration = Rosegarden_activateRegistration; Rosegarden.deactivateRegistration = Rosegarden_deactivateRegistration; Rosegarden.search = Rosegarden_search; Rosegarden.findElementToRegister = Rosegarden_findElementToRegister; Rosegarden.focusSearch = Rosegarden_focusSearch; Rosegarden.popupMenu.activate = RosegardenPopupMenu_activate; Rosegarden.popupSubMenu.activate = RosegardenPopupSubMenu_activate; Rosegarden.popupMenu.deactivate = RosegardenPopupSubMenu_deactivate; Rosegarden.showOptions = Rosegarden_showOptions; Rosegarden.hideOptions = Rosegarden_hideOptions; Rosegarden.saveOptions = Rosegarden_saveOptions; Rosegarden.popupMenu.subMenu = Rosegarden.popupSubMenu; Rosegarden.toggleEditMode(false); Rosegarden.help.update(); Rosegarden.activateRegistration(); if (Rosegarden.configuration._help == "false") { Rosegarden.help.turnOff(); } else { Rosegarden.help.turnOn(); } initHeadline(); initMenus(); initFavelets(); initLastSaved(); fixIE(); var catId = getURLParameterValue("select"); if (!isNonEmptyString(catId)) { catId = Rosegarden.options._lastCategory; if (!isNonEmptyString(catId)) { catId = "Top"; } } new Category(catId).select(); var _import = getURLParameterValue("import"); if (_import == "true") alert(Rosegarden.WARN_IMPORT); handleAddBookmark(); handleAddCategory(); new Element("body").addEvtListener("mouseover", function(e) { Rosegarden.help.update(getEvent(e)); }, false); __Rosegarden = true; return true; } function Rosegarden() { } function isShortcut(o) { return isElement(o) && (isA(o) || isP(o)) && new Node(o).isGrandchildOf(Rosegarden.shortcuts.node); } function isBookmarkShortcut(o) { return isA(o) && isShortcut(o); } function isCategoryShortcut(o) { return isP(o) && isShortcut(o); } function isCategory(o) { return isDiv(o) && new Node(o).isGrandchildOf(Rosegarden.categories.node); } function isCategoryLabel(o) { return isP(o) && new Node(o).isGrandchildOf(Rosegarden.categories.node); } function isCoreElement(o) { return isShortcut(o) || isCategoryLabel(o) || isBookmark(o); } function isBookmark(o) { return isA(o) && o.parentNode == Rosegarden.bookmarks.node; } function isSearchResultCat(o) { return isBookmark(o) && (new Element(o).getCSSClass().indexOf("search-cat") >= 0); } function isSearchResultBm(o) { return isBookmark(o) && (new Element(o).getCSSClass().indexOf("search-bm") >= 0); } function Rosegarden_setChanged() { Rosegarden.changed = true; new Element("button-save").setAttr("style", "background-color: #8f3b3f !important;"); } function Rosegarden_toggleEditMode(override) { if (Rosegarden.dialog || Rosegarden.moved) return; if (isBoolean(override)) { Rosegarden.editMode = !override; } if (Rosegarden.editMode) { Rosegarden.editMode = false; new Element("button-create-bookmark").hide(); new Element("button-create-category").hide(); new Element("button-edit").setText(Rosegarden.EDIT_MODE_OFF); Rosegarden.popupMenu.hide(); } else { Rosegarden.editMode = true; new Element("button-create-bookmark").show(); new Element("button-create-category").show(); new Element("button-edit").setText(Rosegarden.EDIT_MODE_ON); PopupMenu.method("deactivate", PopupMenu_deactivate); Rosegarden.popupMenu.show(); } } function Rosegarden_clearRecentlyVisited() { setCookie(Rosegarden.COOKIE_CACHE, "", Rosegarden.SETTINGS_EXPIRY_DATE); if (Rosegarden.selected.catId == "Top") { Rosegarden.bookmarks.deleteChildren(isA); } } function Rosegarden_getRecentlyVisited() { var _data = getCookie(Rosegarden.COOKIE_CACHE); if (_data == null) return; var recents = _data.split(Rosegarden.CACHE_RECORD_SEPERATOR); var result = new Array(); var c = 0; for (var r = 0; r < recents.length; r++) { var nextRecent = recents[r]; var fields = nextRecent.split(Rosegarden.CACHE_FIELD_SEPERATOR); if (isNonEmptyString(fields[0]) && isNonEmptyString(fields[1])) { result[c] = Element.create("a", fields[1], "href=" + fields[0], "class=recent-link").node; c += 1; } } return result; } function Rosegarden_save() { if (getURLParameterValue("example" == "true")) { alert(Rosegarden.WARN_NO_SAVING); return; } if (Rosegarden.dialog !== null) { alert(Rosegarden.WARN_NO_SAVING_WHILE_EDITING); return; } var elementFilter = function(e) { return isA(e) || isP(e) || isDiv(e);}; var attributeNameFilter = function (a) { return isString(a) && (a == "cat-id" || a == "href" || a == "id" || a == "class");}; var attributeValueFilter = function (v) { return isNonEmptyString(v) && (v.indexOf("sub-category") < 0) && (v.indexOf("highlight") < 0);}; var shortcutsData = Rosegarden.shortcuts.getHtmlCode(elementFilter, attributeNameFilter, attributeValueFilter, -1); var categoriesData = Rosegarden.categories.getHtmlCode(elementFilter, attributeNameFilter, attributeValueFilter, -1); new Element("sf-shortcuts-textarea").setText(encodeURI(shortcutsData)); new Element("sf-categories-textarea").setText(encodeURI(categoriesData)); new Element("sf-current-category").setText(encodeURI(Rosegarden.selected.catId)); new Element("sf-configuration").setText(Rosegarden.configuration.write()); new Element("sf-modification-date").setText(Rosegarden.configuration.modificationDate); new Element("save-form").node.submit(); } function RosegardenPopupMenu_activate(menuId, _invoker) { if (Rosegarden.clipboard.node.parentNode == Rosegarden.popupMenu.node) { Rosegarden.clipboard.domMove(Rosegarden.resources.node); } this.dX = Rosegarden.popupMenuOffsetX; if (isBookmark(_invoker.node)) { this.dX = 0.2; if (is_ie) { this.dX = 0.2; } } this.uber("activate", menuId, _invoker); if (Rosegarden.clipboard.countChildren(isElement) > 0 && new Element(menuId).getCSSClass().indexOf("paste") >= 0) { Rosegarden.clipboard.domMove(Rosegarden.popupMenu.node); } } function RosegardenPopupSubMenu_activate(menuId, _invoker) { this.show(); new Element(_invoker[trans("target")]).setAttr("style", "background-color: #8f3b3f;"); this.uber("activate", menuId, _invoker); } function RosegardenPopupSubMenu_deactivate(_event) { this.uber("deactivate", _event); if (this.invoker == null) { Rosegarden.clipboard.domMove(Rosegarden.resources.node); } } function Rosegarden_handleCommands(_event) { if (_event.keyCode == 16) { Rosegarden.toggleEditMode(); } if (_event.keyCode == 112) { Rosegarden.help.toggle() } } function Rosegarden_handleEditing(_event) { if (_event.keyCode == 27 || _event.keyCode == 13) { var target = Rosegarden.dialogTarget; if (_event.keyCode == 27) { if (target.justCreated) { target.remove(); } else { target.show(); } } else { if (isBookmark(target.node)) { var nameField = new Element("edit-bookmark-name").node; if (!checkMandatoryField(nameField)) { alert(Rosegarden.WARN_NAME_REQUIRED); return; } var urlField = new Element("edit-bookmark-href").node; if (!checkMandatoryField(urlField)) { alert(Rosegarden.WARN_URL_REQUIRED); return; } delete(target.justCreated); target.set(nameField.value, urlField.value); target.show(); Rosegarden.selected.commitBookmarks(); } else { var nameField = new Element("edit-element-name").node; if (!checkMandatoryField(nameField)) { alert(Rosegarden.WARN_NAME_REQUIRED); return; } delete(target.justCreated); target.rename(nameField.value); target.show(); } Rosegarden.setChanged(); } Rosegarden.dialog.domMove(Rosegarden.resources.node); Rosegarden.menu.show(); Rosegarden.dialog = null; Rosegarden.dialogTarget = null; Rosegarden.register(Rosegarden.reg); Rosegarden.popupMenu.show(); } } function Rosegarden_handleOptionEditing(_event) { if (_event.keyCode == 27 || _event.keyCode == 13) { if (_event.keyCode == 13) { var fsField = new Element("edit-filesystem"); Rosegarden.options._filesystem = fsField.node.value; Rosegarden.saveOptions(); fsField.node.value = ""; Rosegarden.PREFIX_FILESYSTEM = Rosegarden.options._filesystem; } Rosegarden.hideOptions(); } } function Rosegarden_handleMoving(_event) { _event = getEvent(_event); if (Rosegarden.moved != null) { if (_event.keyCode == 13) { Rosegarden.moved.deleteCSSClass("moved"); if (isBookmark(Rosegarden.moved.node)) { Rosegarden.selected.commitBookmarks(); } Rosegarden.moved = null; document.onkeydown = null; Rosegarden.register(Rosegarden.reg); Rosegarden.popupMenu.show(); Rosegarden.setChanged(); } else if (_event.keyCode == 38) { Rosegarden.moved.moveUp(); } else if (_event.keyCode == 40) { Rosegarden.moved.moveDown(); } } } function Rosegarden_register(o) { if (o == null) { if (Rosegarden.reg != null) { Rosegarden.reg.deleteCSSClass("highlight"); Rosegarden.popupMenu.deactivate(); Rosegarden.reg = null; } } else { var oldreg = Rosegarden.reg; if (!isElement(o)) { o = o[trans("target")]; } if (isCoreElement(o)) { Rosegarden.reg = new CoreElement(o); } else { if (Rosegarden.dialogTarget == null && Rosegarden.moved == null) { Rosegarden.register(null); } } if (Rosegarden.reg) { if (oldreg != null) { oldreg.deleteCSSClass("highlight"); } if (Rosegarden.dialogTarget == null && Rosegarden.moved == null) { Rosegarden.reg.addCSSClass("highlight"); } Rosegarden.popupMenu.activate(Rosegarden.reg.getMenuId(), Rosegarden.reg); } } } function Rosegarden_unregister(_event) { var _event = getEvent(_event); var relatedTarget = _event[trans("relatedTarget")]; if (isDiv(relatedTarget)) { Rosegarden.register(null); } } function Rosegarden_autoRegister(_event) { if (_event != null) { var reg = Rosegarden.findElementToRegister(_event); Rosegarden.help.update(reg); Rosegarden.register(reg); } } function Rosegarden_activateRegistration() { function addEventListeners(o) { o.addEvtListener("mousemove", Rosegarden.register, false); o.addEvtListener("mouseover", Rosegarden.register, false); o.addEvtListener("mouseout", Rosegarden.unregister, false); o.addEvtListener("click", _select, true); } addEventListeners(Rosegarden.shortcuts); addEventListeners(Rosegarden.categories); addEventListeners(Rosegarden.bookmarks); } function Rosegarden_deactivateRegistration() { function removeEventListeners(o) { o.removeEvtListener("mousemove", Rosegarden.register, false); o.removeEvtListener("mouseover", Rosegarden.register, false); o.removeEvtListener("mouseout", Rosegarden.unregister, false); o.removeEvtListener("click", _select, true); } removeEventListeners(Rosegarden.shortcuts); removeEventListeners(Rosegarden.categories); removeEventListeners(Rosegarden.bookmarks); } function _select(_event) { if (Rosegarden.reg != null && Rosegarden.dialogTarget == null && Rosegarden.moved == null && !isSearchResultCat(Rosegarden.reg.node)) { Rosegarden.reg.select(getEvent(_event)); } } function Rosegarden_search(_event) { if (_event == null || (_event.keyCode != 13 && _event.keyCode != 9 && _event.keyCode != 27)) return; var searchString = new Element("search").node.value; if (!isNonEmptyString(searchString)) { return; } Rosegarden.bookmarks.deleteChildren(isA); var searchRoot = Rosegarden.selected.category; if (_event.keyCode == 13) { searchRoot = new Element("Top"); } var counter = 0; var previousCategory = null; var bookmarks = searchRoot.node.getElementsByTagName("a"); for (var i = 0; i < bookmarks.length; i += 1) { var match = false; var nextBookmark = new Element(bookmarks.item(i)); var href = nextBookmark.getAttr("href"); if (href != null && href.toLowerCase().indexOf(searchString) >= 0) { match = true; } else { var text = nextBookmark.getText(); if (text != null && text.toLowerCase().indexOf(searchString) >= 0) { match = true; } } if (match) { counter++; var category = new Category(nextBookmark.node.parentNode); if (category.node != previousCategory ) { var containingCategory = Element.create("a", "/" + category.getCategoryPath(), "class=search-cat", "href=javascript:new Category('" + category.catId + "').select();"); Rosegarden.bookmarks.node.appendChild(containingCategory.node); previousCategory = category.node; } var _copy = nextBookmark.domCopy(Rosegarden.bookmarks.node); new Element(_copy).addCSSClass("search-bm"); } } var title = counter + (counter == 1 ? " result" : " results") + " found for '" + searchString + "'"; new Element("bookmarks-label").setText(title); } function Rosegarden_findElementToRegister(_event) { var bmShortcuts = Rosegarden.shortcuts.node.getElementsByTagName("a"); var catShortcuts = Rosegarden.shortcuts.node.getElementsByTagName("p"); var _categories = Rosegarden.categories.node.getElementsByTagName("p"); var _bookmarks = Rosegarden.bookmarks.node.getElementsByTagName("a"); var _children = new Array(); _children.append(bmShortcuts); _children.append(catShortcuts); _children.append(_categories); _children.append(_bookmarks); _event = getEvent(_event); var reg = null; for (var i = 0; i < _children.length && !reg; i += 1) { if (new Element(_children[i]).isOver(_event.clientX, _event.clientY)) { reg = _children[i]; } } return reg; } function Rosegarden_focusSearch() { if (Rosegarden.dialogTarget == null) { _focus("search"); } } function Rosegarden_showOptions() { Rosegarden.menu.hide(); if (Rosegarden.editMode) { Rosegarden.popupMenu.hide(); } var bmLabel = new Element("bookmarks-label"); bmLabel.setText(Rosegarden.EDIT_OPTIONS_LABEL); bmLabel.setAttr("help-id", "help-options"); Rosegarden.dialog = new Element("edit-options"); Rosegarden.dialogTarget = Rosegarden.selected; Rosegarden.bookmarks.deleteChildren(isA); var filesystem = Rosegarden.options._filesystem; var fsField = new Element("edit-filesystem"); if (filesystem) { fsField.node.value = filesystem; } Rosegarden.bookmarks.node.appendChild(Rosegarden.dialog.node); fsField.node.focus(); } function Rosegarden_hideOptions() { Rosegarden.resources.node.appendChild(Rosegarden.dialog.node); Rosegarden.selected = null; Rosegarden.dialogTarget.select(); Rosegarden.dialogTarget = null; Rosegarden.dialog = null; new Element("bookmarks-label").setAttr("help-id", "help-bookmarks"); if (Rosegarden.editMode) { Rosegarden.popupMenu.show(); } Rosegarden.menu.show(); } function Rosegarden_saveOptions() { setCookie(Rosegarden.COOKIE_OPTIONS, Rosegarden.options.write(), Rosegarden.SETTINGS_EXPIRY_DATE); } function initHeadline() { var _class = "column-header"; if (new Element("shortcuts-label").node == null) { var shortcutsLabel = Element.create("h1", Rosegarden.HEADLINE_SHORTCUTS, "id=" + "shortcuts-label", "class=" + _class, "help-id=help-shortcuts"); Rosegarden.shortcuts.node.insertBefore(shortcutsLabel.node, Rosegarden.shortcuts.node.firstChild); } if (new Element("categories-label").node == null) { var categoriesLabel = Element.create("h1", Rosegarden.HEADLINE_CATEGORIES, "id=" + "categories-label", "class=" + _class, "help-id=help-categories"); Rosegarden.categories.node.insertBefore(categoriesLabel.node, Rosegarden.categories.node.firstChild); } if (new Element("bookmarks-label").node == null) { var boomarksLabel = Element.create("h1", Rosegarden.HEADLINE_BM_CACHED, "id=bookmarks-label", "class=" + _class, "help-id=help-bookmarks"); Rosegarden.bookmarks.node.appendChild(boomarksLabel.node); } } function initMenus() { if (document.URL.indexOf("http") == 0) { if (getCookie("rosegarden") != null) { new Element("button-login").show(); } else { new Element("button-logout").show(); } } else { new Element("button-login").show(); new Element("button-logout").show(); } } function initFavelets() { var urlComplete = document.URL; if (urlComplete.indexOf("http") == 0) { var _url = urlComplete.replace(/^(.*?)\?.*$/,"$1"); var addBookmarkCode = "javascript: document.location = '" + _url + "?" + "type=offline&url=' + encodeURI(document.URL) + '&title=' + encodeURI(document.title); "; var addCategoryCode = "javascript: if (document.URL.match( /http:\\/\\/(www\.)?dmoz.org\\/(.+?\\/)+/ ) == null) { alert('Add Category only works when you are in a category on the website of the Open Directory Project (http:/' + '/dmoz.org)!'); } else { document.location = '" + _url + "?" + "type=offline&category=' + encodeURI(document.URL);}"; var favletHeader = Element.create("h1", "Favelets", "class=column-header", "help-id=help-favelets"); var addBookmarkLink = Element.create("a", "Add Bookmark", "id=bookmark-favelet", "class=button favelet", "help-id=help-bookmark-favelet", "onclick=return false;", "href=" + addBookmarkCode); var addCategoryLink = Element.create("a", "Add Category", "id=category-favelet", "class=button favelet", "help-id=help-category-favelet", "onclick=return false;", "href=" + addCategoryCode); Rosegarden.menu.node.appendChild(favletHeader.node); Rosegarden.menu.node.appendChild(addBookmarkLink.node); Rosegarden.menu.node.appendChild(addCategoryLink.node); } } function initLastSaved() { Rosegarden.menu.node.appendChild(new Element("last-saved").node); } function fixIE() { if (is_ie) { fixLinks(Rosegarden.resources.node, isA); fixLinks(Rosegarden.menu.node, isA); new Element("search-dialog").setAttr("style", "padding-top: 3px !important;"); } } function fixLinks(_element, filter) { if (!isElement(_element)) return; var _links = _element.getElementsByTagName("a"); for (var i = 0; i < _links.length; i++) { var nextLink = _links.item(i); if (filter(nextLink)) if (nextLink.href.length == 0) { nextLink.href = "javascript: function() {return false;}"; } else { nextLink.onclick = ""; } } } function fixIEEditBookmarkDialog(width) { if (is_ie) { var dialog = new Element("edit-bookmark"); var children = dialog.getChildren(isDiv); Rosegarden.dbg.debug("width: " + width); children.map(function (o) { new Element(o).setAttr("style", "width: " + width + "px"); }); } } function handleAddBookmark() { var _url = getURLParameterValue("url"); var _title = getURLParameterValue("title"); if (isNonEmptyString(_url)) { if (!isNonEmptyString(_title)) { _title = _url.replace(/^(.*?)\?.*$/,"$1"); } var newBookmark = Element.create("a", _title, "href=" + _url); Rosegarden.clipboard.node.appendChild(newBookmark.node); Rosegarden.toggleEditMode(true); Rosegarden.setChanged(); } } function handleAddCategory() { var _path = getURLParameterValue("category"); if (isNonEmptyString(_path)) { if(_path.indexOf("http:/" + "/dmoz.org") < 0 && _path.indexOf("http:/" + "/www.dmoz.org")) { return; } _path = _path.replace(/^http:\/\/(www\.)?dmoz\.org\/(.*)\/?$/,"$2"); if (isNonEmptyString(_path)) { var newCategory = new Category("Top").createSubCategories(_path); newCategory.select(); Rosegarden.setChanged(); } } } var __Shortcut = false; function _Shortcut() { if (__Shortcut) return false; _init("_sugar"); _init("_CoreElement"); Shortcut.inherits(CoreElement); Shortcut.prototype.menuId = "menu-bookmark-shortcut"; Shortcut.prototype.helpId = "help-bookmark-shortcut"; CategoryShortcut.inherits(Shortcut); CategoryShortcut.method("select", CategoryShortcut_select); CategoryShortcut.method("visit", CategoryShortcut_visit); CategoryShortcut.method("paste", CategoryShortcut_paste); CategoryShortcut.method("isDependantOn", CategoryShortcut_isDependantOn); CategoryShortcut.prototype.menuId = "menu-category-shortcut"; CategoryShortcut.prototype.helpId = "help-category-shortcut"; __Shortcut = true; return true; } function Shortcut(o) { this.node = o; } function CategoryShortcut(o) { if (isElement(o)) { this.node = o; this.catId = this.getAttr("cat-id"); this.category = new Category(this.catId); } } function CategoryShortcut_select() { this.category.select(); } function CategoryShortcut_visit(dest) { this.category.visit(dest); } function CategoryShortcut_paste() { this.category.paste(); } function CategoryShortcut_edit() { alert("CategoryShortcut_edit"); } function CategoryShortcut_isDependantOn(candidate) { return this.category.isGrandchildOf(candidate); } var __String = false; function _String() { if (__String) { return false; } _init("_sugar"); _init("_remedial"); String.method("entityify", String_entityify); String.method("trim", String_trim); String.method("reverse", String_reverse); __String = true; } function String_entityify() { return this.replace(/&/g, "&amp;").replace(/</g,"&lt;").replace(/>/g, "&gt;"); } function String_trim () { return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); } function String_reverse() { var result = ""; for (var i = this.length - 1; i >= 0; i--) { result += this.substr(i, 1); } return result; } function isNonEmptyString(s) { return !isNull(s) && isString(s) && s.trim().length > 0; } var __sugar = false; function _sugar() { if (__sugar) return false; Function.prototype.method = function(name, func) { this.prototype[name] = func; return this; }; Function.method("inherits", function (parent) { var d = 0; var p = (this.prototype = new parent()); this.method('uber', function uber(name) { var f; var r; var t = d; var v = parent.prototype; if (t) { while (t) { v = v.constructor.prototype; t -= 1; } f = v[name]; } else { f = p[name]; if (f == this[name]) { f = v[name]; } } d += 1; r = f.apply(this, Array.prototype.slice.apply(arguments, [1])); d -= 1; return r; }); return this; }); Function.method('swiss', function (parent) { for (var i = 1; i < arguments.length; i += 1) { var name = arguments[i]; this.prototype[name] = parent.prototype[name]; } }); __sugar = true; return true; } var _map = {}; var agt; var is_ie; var is_opera; var __trans = false; function _trans() { if (__trans) { return this; } agt = navigator.userAgent.toLowerCase(); is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); is_opera = (agt.indexOf("opera") != -1); _map["class"] = "className"; _map["target"] = "srcElement"; _map["relatedTarget"] = "toElement"; _map["click"] = "onclick"; _map["mouseover"] = "onmouseover"; _map["mouseout"] = "onmouseout"; _map["keydown"] = "onkeydown"; _map["keyup"] = "onkeyup"; __trans = true; } function trans(name) { if (is_ie) return (_map[name] == null ? name : _map[name]); return name; } function getEvent(_event) { if (is_ie) { return window.event; } else { return _event; } } 
