From ee76e5f58e806cacd184f9cb12bce26a476bfbab Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 22 Jan 2007 12:11:49 +0000 Subject: [PATCH] Moved drag+drop and YahooUI library into templates/default/ to be used in shared installation environments --- docs/NEWS | 3 + include/admin/plugins.inc.php | 2 +- templates/default/YahooUI/treeview/YAHOO.js | 63 + .../default/YahooUI/treeview/license.txt | 35 + .../default/YahooUI/treeview/treeview.js | 1490 +++++++++++++++++ templates/default/admin/media_choose.tpl | 8 +- templates/default/dragdrop.js | 802 +++++++++ templates/default/imgedit.js | 302 ++++ 8 files changed, 2700 insertions(+), 5 deletions(-) create mode 100644 templates/default/YahooUI/treeview/YAHOO.js create mode 100644 templates/default/YahooUI/treeview/license.txt create mode 100644 templates/default/YahooUI/treeview/treeview.js create mode 100644 templates/default/dragdrop.js create mode 100644 templates/default/imgedit.js diff --git a/docs/NEWS b/docs/NEWS index 6b64436..0efadfd 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.2 () ------------------------------------------------------------------------ + * Moved drag+drop and YahooUI library into templates/default/ to + be used in shared installation environments (garvinhicking) + * Improve WP importer by only fetching real posts (attachments/static only optional) and splitting a post into extended/normal entry. Thanks to jtb! diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index beab2c8..baa669f 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -472,7 +472,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
'; + echo ''; echo '
' . PREFERENCE_USE_JS_WARNING . '
'; } diff --git a/templates/default/YahooUI/treeview/YAHOO.js b/templates/default/YahooUI/treeview/YAHOO.js new file mode 100644 index 0000000..33e3ff4 --- /dev/null +++ b/templates/default/YahooUI/treeview/YAHOO.js @@ -0,0 +1,63 @@ +/* +Copyright (c) 2006 Yahoo! Inc. All rights reserved. +version 0.9.0 +*/ + +/** + * @class The Yahoo global namespace + */ +var YAHOO = function() { + + return { + + /** + * Yahoo presentation platform utils namespace + */ + util: {}, + + /** + * Yahoo presentation platform widgets namespace + */ + widget: {}, + + /** + * Yahoo presentation platform examples namespace + */ + example: {}, + + /** + * Returns the namespace specified and creates it if it doesn't exist + * + * YAHOO.namespace("property.package"); + * YAHOO.namespace("YAHOO.property.package"); + * + * Either of the above would create YAHOO.property, then + * YAHOO.property.package + * + * @param {String} sNameSpace String representation of the desired + * namespace + * @return {Object} A reference to the namespace object + */ + namespace: function( sNameSpace ) { + + if (!sNameSpace || !sNameSpace.length) { + return null; + } + + var levels = sNameSpace.split("."); + + var currentNS = YAHOO; + + // YAHOO is implied, so it is ignored if it is included + for (var i=(levels[0] == "YAHOO") ? 1 : 0; i '; + } + + var f = document.createElement("div"); + var s = f.style; + s.position = "absolute"; + s.top = "-1000px"; + s.left = "-1000px"; + f.innerHTML = sb.join(""); + + document.body.appendChild(f); +}; + +YAHOO.widget.TreeView.addHandler(window, + "load", YAHOO.widget.TreeView.preload); + +/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ + +/** + * @class Abstract node class + * @constructor + * @param oData {object} a string or object containing the data that will + * be used to render this node + * @param oParent {YAHOO.widget.Node} this node's parent node + * @param expanded {boolean} the initial expanded/collapsed state + */ +YAHOO.widget.Node = function(oData, oParent, expanded) { + if (oParent) { this.init(oData, oParent, expanded); } +}; + +YAHOO.widget.Node.prototype = { + + /** + * The index for this instance obtained from global counter in YAHOO.widget.TreeView. + * + * @type int + */ + index: 0, + + /** + * This node's child node collection. + * + * @type YAHOO.widget.Node[] + */ + children: null, + + /** + * Tree instance this node is part of + * + * @type YAHOO.widget.TreeView + */ + tree: null, + + /** + * The data linked to this node. This can be any object or primitive + * value, and the data can be used in getNodeHtml(). + * + * @type object + */ + data: null, + + /** + * Parent node + * + * @type YAHOO.widget.Node + */ + parent: null, + + /** + * The depth of this node. We start at -1 for the root node. + * + * @type int + */ + depth: -1, + + /** + * The href for the node's label. If one is not specified, the href will + * be set so that it toggles the node. + * + * @type string + */ + href: null, + + /** + * The label href target, defaults to current window + * + * @type string + */ + target: "_self", + + /** + * The node's expanded/collapsed state + * + * @type boolean + */ + expanded: false, + + /** + * Can multiple children be expanded at once? + * + * @type boolean + */ + multiExpand: true, + + /** + * Should we render children for a collapsed node? It is possible that the + * implementer will want to render the hidden data... @todo verify that we + * need this, and implement it if we do. + * + * @type boolean + */ + renderHidden: false, + + /** + * Flag that is set to true the first time this node's children are rendered. + * + * @type boolean + */ + childrenRendered: false, + + /** + * This node's previous sibling + * + * @type YAHOO.widget.Node + */ + previousSibling: null, + + /** + * This node's next sibling + * + * @type YAHOO.widget.Node + */ + nextSibling: null, + + /** + * We can set the node up to call an external method to get the child + * data dynamically. + * + * @type boolean + * @private + */ + _dynLoad: false, + + /** + * Function to execute when we need to get this node's child data. + * + * @type function + */ + dataLoader: null, + + /** + * This is true for dynamically loading nodes while waiting for the + * callback to return. + * + * @type boolean + */ + isLoading: false, + + /** + * The toggle/branch icon will not show if this is set to false. This + * could be useful if the implementer wants to have the child contain + * extra info about the parent, rather than an actual node. + * + * @type boolean + */ + hasIcon: true, + + /** + * Initializes this node, gets some of the properties from the parent + * + * @param oData {object} a string or object containing the data that will + * be used to render this node + * @param oParent {YAHOO.widget.Node} this node's parent node + * @param expanded {boolean} the initial expanded/collapsed state + */ + init: function(oData, oParent, expanded) { + this.data = oData; + this.children = []; + this.index = YAHOO.widget.TreeView.nodeCount; + ++YAHOO.widget.TreeView.nodeCount; + this.expanded = expanded; + + // oParent should never be null except when we create the root node. + if (oParent) { + this.tree = oParent.tree; + this.parent = oParent; + this.href = "javascript:" + this.getToggleLink(); + this.depth = oParent.depth + 1; + this.multiExpand = oParent.multiExpand; + + oParent.appendChild(this); + } + }, + + /** + * Appends a node to the child collection. + * + * @param node {YAHOO.widget.Node} the new node + * @return {YAHOO.widget.Node} the child node + * @private + */ + appendChild: function(node) { + if (this.hasChildren()) { + var sib = this.children[this.children.length - 1]; + sib.nextSibling = node; + node.previousSibling = sib; + } + + this.tree.regNode(node); + this.children[this.children.length] = node; + return node; + + }, + + /** + * Returns a node array of this node's siblings, null if none. + * + * @return YAHOO.widget.Node[] + */ + getSiblings: function() { + return this.parent.children; + }, + + /** + * Shows this node's children + */ + showChildren: function() { + if (!this.tree.animateExpand(this.getChildrenEl())) { + if (this.hasChildren()) { + this.getChildrenEl().style.display = ""; + } + } + }, + + /** + * Hides this node's children + */ + hideChildren: function() { + + if (!this.tree.animateCollapse(this.getChildrenEl())) { + this.getChildrenEl().style.display = "none"; + } + }, + + /** + * Returns the id for this node's container div + * + * @return {string} the element id + */ + getElId: function() { + return "ygtv" + this.index; + }, + + /** + * Returns the id for this node's children div + * + * @return {string} the element id for this node's children div + */ + getChildrenElId: function() { + return "ygtvc" + this.index; + }, + + /** + * Returns the id for this node's toggle element + * + * @return {string} the toggel element id + */ + getToggleElId: function() { + return "ygtvt" + this.index; + }, + + /** + * Returns this node's container html element + * + * @return {Object} the container html element + */ + getEl: function() { + return document.getElementById(this.getElId()); + }, + + /** + * Returns the div that was generated for this node's children + * + * @return {Object} this node's children div + */ + getChildrenEl: function() { + return document.getElementById(this.getChildrenElId()); + }, + + /** + * Returns the element that is being used for this node's toggle. + * + * @return {Object} this node's toggel html element + */ + getToggleEl: function() { + return document.getElementById(this.getToggleElId()); + }, + + /** + * Generates the link that will invoke this node's toggle method + * + * @return {string} the javascript url for toggling this node + */ + getToggleLink: function() { + return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," + + this.index + ").toggle()"; + }, + + /** + * Hides this nodes children (creating them if necessary), changes the + * toggle style. + */ + collapse: function() { + // Only collapse if currently expanded + if (!this.expanded) { return; } + + if (!this.getEl()) { + this.expanded = false; + return; + } + + // hide the child div + this.hideChildren(); + this.expanded = false; + + if (this.hasIcon) { + this.getToggleEl().className = this.getStyle(); + } + + // fire the collapse event handler + this.tree.onCollapse(this); + }, + + /** + * Shows this nodes children (creating them if necessary), changes the + * toggle style, and collapses its siblings if multiExpand is not set. + */ + expand: function() { + // Only expand if currently collapsed. + if (this.expanded) { return; } + + if (!this.getEl()) { + this.expanded = true; + return; + } + + if (! this.childrenRendered) { + this.getChildrenEl().innerHTML = this.renderChildren(); + } + + this.expanded = true; + if (this.hasIcon) { + this.getToggleEl().className = this.getStyle(); + } + + // We do an extra check for children here because the lazy + // load feature can expose nodes that have no children. + + // if (!this.hasChildren()) { + if (this.isLoading) { + this.expanded = false; + return; + } + + if (! this.multiExpand) { + var sibs = this.getSiblings(); + for (var i=0; i 0 || + (checkForLazyLoad && this.isDynamic() && !this.childrenRendered) ); + }, + + /** + * Expands if node is collapsed, collapses otherwise. + */ + toggle: function() { + if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) { + if (this.expanded) { this.collapse(); } else { this.expand(); } + } + }, + + /** + * Returns the markup for this node and its children. + * + * @return {string} the markup for this node and its expanded children. + */ + getHtml: function() { + var sb = []; + sb[sb.length] = '
'; + sb[sb.length] = this.getNodeHtml(); + sb[sb.length] = this.getChildrenHtml(); + sb[sb.length] = '
'; + return sb.join(""); + }, + + /** + * Called when first rendering the tree. We always build the div that will + * contain this nodes children, but we don't render the children themselves + * unless this node is expanded. + * + * @return {string} the children container div html and any expanded children + * @private + */ + getChildrenHtml: function() { + var sb = []; + sb[sb.length] = '
= this.depth || depth < 0) { + return null; + } + + var p = this.parent; + + while (p.depth > depth) { + p = p.parent; + } + + return p; + }, + + /** + * Returns the css class for the spacer at the specified depth for + * this node. If this node's ancestor at the specified depth + * has a next sibling the presentation is different than if it + * does not have a next sibling + * + * @param {int} depth the depth of the ancestor. + * @return {string} the css class for the spacer + */ + getDepthStyle: function(depth) { + return (this.getAncestor(depth).nextSibling) ? + "ygtvdepthcell" : "ygtvblankdepthcell"; + }, + + /** + * Get the markup for the node. This is designed to be overrided so that we can + * support different types of nodes. + * + * @return {string} the html for this node + */ + getNodeHtml: function() { + return ""; + } + +}; + +/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ + +/** + * @class A custom YAHOO.widget.Node that handles the unique nature of + * the virtual, presentationless root node. + * + * @extends YAHOO.widget.Node + * @constructor + */ +YAHOO.widget.RootNode = function(oTree) { + // Initialize the node with null params. The root node is a + // special case where the node has no presentation. So we have + // to alter the standard properties a bit. + this.init(null, null, true); + + /** + * For the root node, we get the tree reference from as a param + * to the constructor instead of from the parent element. + * + * @type YAHOO.widget.TreeView + */ + this.tree = oTree; +}; +YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node(); + +// overrides YAHOO.widget.Node +YAHOO.widget.RootNode.prototype.getNodeHtml = function() { + return ""; +}; + +/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ + +/** + * @class The default node presentation. The first parameter should be + * either a string that will be used as the node's label, or an object + * that has a string propery called label. By default, the clicking the + * label will toggle the expanded/collapsed state of the node. By + * changing the href property of the instance, this behavior can be + * changed so that the label will go to the specified href. + * + * @extends YAHOO.widget.Node + * @constructor + * @param oData {object} a string or object containing the data that will + * be used to render this node + * @param oParent {YAHOO.widget.Node} this node's parent node + * @param expanded {boolean} the initial expanded/collapsed state + */ +YAHOO.widget.TextNode = function(oData, oParent, expanded) { + if (oParent) { + this.init(oData, oParent, expanded); + this.setUpLabel(oData); + } +}; + +YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node(); + +/** + * The CSS class for the label href. Defaults to ygtvlabel, but can be + * overridden to provide a custom presentation for a specific node. + * + * @type string + */ +YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel"; + +/** + * The derived element id of the label for this node + * + * @type string + */ +YAHOO.widget.TextNode.prototype.labelElId = null; + +/** + * The text for the label. It is assumed that the oData parameter will + * either be a string that will be used as the label, or an object that + * has a property called "label" that we will use. + * + * @type string + */ +YAHOO.widget.TextNode.prototype.label = null; + +/** + * Sets up the node label + * + * @param oData string containing the label, or an object with a label property + */ +YAHOO.widget.TextNode.prototype.setUpLabel = function(oData) { + if (typeof oData == "string") { + oData = { label: oData }; + } + this.label = oData.label; + + // update the link + if (oData.href) { + this.href = oData.href; + } + + // set the target + if (oData.target) { + this.target = oData.target; + } + + this.labelElId = "ygtvlabelel" + this.index; +}; + +/** + * Returns the label element + * + * @return {object} the element + */ +YAHOO.widget.TextNode.prototype.getLabelEl = function() { + return document.getElementById(this.labelElId); +}; + +// overrides YAHOO.widget.Node +YAHOO.widget.TextNode.prototype.getNodeHtml = function() { + var sb = new Array(); + + sb[sb.length] = ''; + sb[sb.length] = ''; + + for (i=0;i '; + } + + var getNode = 'YAHOO.widget.TreeView.getNode(\'' + + this.tree.id + '\',' + this.index + ')'; + + sb[sb.length] = ' '; + sb[sb.length] = ''; + sb[sb.length] = ''; + } + + if (this.hasIcon) { + sb[sb.length] = ' '; + if (this.hasChildren(true)) { + sb[sb.length] = ' onmouseover="this.className='; + sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; + sb[sb.length] = this.tree.id + '\',' + this.index + ').getHoverStyle()"'; + sb[sb.length] = ' onmouseout="this.className='; + sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; + sb[sb.length] = this.tree.id + '\',' + this.index + ').getStyle()"'; + } + sb[sb.length] = ''; + } + + sb[sb.length] = ' - - + + {/if} - - + +
'; + sb[sb.length] = '