⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kupubasetools.js

📁 一个使用struts+hibernate+spring开发的完的网站源代码。
💻 JS
📖 第 1 页 / 共 5 页
字号:
            this.addtablediv.style.display = "none";            this.edittablediv.style.display = "block";            var align = this.tool._getColumnAlign(selNode);            selectSelectItem(this.alignselect, align);            selectSelectItem(this.classselect, table.className);            if (this.toolboxel) {                this.toolboxel.className = this.activeclass;            };        } else {            this.edittablediv.style.display = "none";            this.addtablediv.style.display = "block";            this.alignselect.selectedIndex = 0;            this.classselect.selectedIndex = 0;            if (this.toolboxel) {                this.toolboxel.className = this.plainclass;            };        };    };    this.addTable = function() {        /* add a table */        var rows = this.newrowsinput.value;        var cols = this.newcolsinput.value;        var makeHeader = this.makeheaderinput.checked;        var classchooser = document.getElementById("kupu-table-classchooser-add");        var tableclass = this.classselect.options[this.classselect.selectedIndex].value;                this.tool.createTable(rows, cols, makeHeader, tableclass);    };    this.setColumnAlign = function() {        /* set the alignment of the current column */        var newalign = this.alignselect.options[this.alignselect.selectedIndex].value;        this.tool.setColumnAlign(newalign);    };    this.setTableClass = function() {        /* set the class for the current table */        var sel_class = this.classselect.options[this.classselect.selectedIndex].value;        if (sel_class) {            this.tool.setTableClass(sel_class);        };    };};TableToolBox.prototype = new KupuToolBox;function ListTool(addulbuttonid, addolbuttonid, ulstyleselectid, olstyleselectid) {    /* tool to set list styles */    this.addulbutton = document.getElementById(addulbuttonid);    this.addolbutton = document.getElementById(addolbuttonid);    this.ulselect = document.getElementById(ulstyleselectid);    this.olselect = document.getElementById(olstyleselectid);    this.style_to_type = {'decimal': '1',                            'lower-alpha': 'a',                            'upper-alpha': 'A',                            'lower-roman': 'i',                            'upper-roman': 'I',                            'disc': 'disc',                            'square': 'square',                            'circle': 'circle',                            'none': 'none'                            };    this.type_to_style = {'1': 'decimal',                            'a': 'lower-alpha',                            'A': 'upper-alpha',                            'i': 'lower-roman',                            'I': 'upper-roman',                            'disc': 'disc',                            'square': 'square',                            'circle': 'circle',                            'none': 'none'                            };        this.initialize = function(editor) {        /* attach event handlers */        this.editor = editor;        this._fixTabIndex(this.addulbutton);        this._fixTabIndex(this.addolbutton);        this._fixTabIndex(this.ulselect);        this._fixTabIndex(this.olselect);        addEventHandler(this.addulbutton, "click", this.addUnorderedList, this);        addEventHandler(this.addolbutton, "click", this.addOrderedList, this);        addEventHandler(this.ulselect, "change", this.setUnorderedListStyle, this);        addEventHandler(this.olselect, "change", this.setOrderedListStyle, this);        this.ulselect.style.display = "none";        this.olselect.style.display = "none";        this.editor.logMessage('List style tool initialized');    };    this._handleStyles = function(currnode, onselect, offselect) {        if (this.editor.config.use_css) {            var currstyle = currnode.style.listStyleType;        } else {            var currstyle = this.type_to_style[currnode.getAttribute('type')];        }        selectSelectItem(onselect, currstyle);        offselect.style.display = "none";        onselect.style.display = "inline";        offselect.selectedIndex = 0;    };    this.updateState = function(selNode) {        /* update the visibility and selection of the list type pulldowns */        // we're going to walk through the tree manually since we want to         // check on 2 items at the same time        for (var currnode=selNode; currnode; currnode=currnode.parentNode) {            var tag = currnode.nodeName.toLowerCase();            if (tag == 'ul') {                this._handleStyles(currnode, this.ulselect, this.olselect);                return;            } else if (tag == 'ol') {                this._handleStyles(currnode, this.olselect, this.ulselect);                return;            }        }        with(this.ulselect) {            selectedIndex = 0;            style.display = "none";        };        with(this.olselect) {            selectedIndex = 0;            style.display = "none";        };    };    this.addList = function(command) {        this.ulselect.style.display = "inline";        this.olselect.style.display = "none";        this.editor.execCommand(command);        this.editor.focusDocument();    };    this.addUnorderedList = function() {        /* add an unordered list */        this.addList("insertunorderedlist");    };    this.addOrderedList = function() {        /* add an ordered list */        this.addList("insertorderedlist");    };    this.setListStyle = function(tag, select) {        /* set the type of an ul */        var currnode = this.editor.getSelectedNode();        var l = this.editor.getNearestParentOfType(currnode, tag);        var style = select.options[select.selectedIndex].value;        if (this.editor.config.use_css) {            l.style.listStyleType = style;        } else {            l.setAttribute('type', this.style_to_type[style]);        }        this.editor.focusDocument();        this.editor.logMessage('List style changed');    };    this.setUnorderedListStyle = function() {        /* set the type of an ul */        this.setListStyle('ul', this.ulselect);    };    this.setOrderedListStyle = function() {        /* set the type of an ol */        this.setListStyle('ol', this.olselect);    };};ListTool.prototype = new KupuTool;function ShowPathTool() {    /* shows the path to the current element in the status bar */    this.updateState = function(selNode) {        /* calculate and display the path */        var path = '';        var url = null; // for links we want to display the url too        var currnode = selNode;        while (currnode != null && currnode.nodeName != '#document') {            if (currnode.nodeName.toLowerCase() == 'a') {                url = currnode.getAttribute('href');            };            path = '/' + currnode.nodeName.toLowerCase() + path;            currnode = currnode.parentNode;        }                try {            window.status = url ?                     (path.toString() + ' - contains link to \'' + url.toString() + '\'') :                    path;        } catch (e) {            this.editor.logMessage('Could not set status bar message, ' +                                    'check your browser\'s security settings.',                                     1);        };    };};ShowPathTool.prototype = new KupuTool;function ViewSourceTool() {    /* tool to provide a 'show source' context menu option */    this.sourceWindow = null;        this.viewSource = function() {        /* open a window and write the current contents of the iframe to it */        if (this.sourceWindow) {            this.sourceWindow.close();        };        this.sourceWindow = window.open('#', 'sourceWindow');                //var transform = this.editor._filterContent(this.editor.getInnerDocument().documentElement);        //var contents = transform.xml;         var contents = '<html>\n' + this.editor.getInnerDocument().documentElement.innerHTML + '\n</html>';                var doc = this.sourceWindow.document;        doc.write('\xa0');        doc.close();        var body = doc.getElementsByTagName("body")[0];        while (body.hasChildNodes()) {            body.removeChild(body.firstChild);        };        var pre = doc.createElement('pre');        var textNode = doc.createTextNode(contents);        body.appendChild(pre);        pre.appendChild(textNode);    };        this.createContextMenuElements = function(selNode, event) {        /* create the context menu element */        return new Array(new ContextMenuElement('View source', this.viewSource, this));    };};ViewSourceTool.prototype = new KupuTool;function DefinitionListTool(dlbuttonid) {    /* a tool for managing definition lists        the dl elements should behave much like plain lists, and the keypress        behaviour should be similar    */    this.dlbutton = document.getElementById(dlbuttonid);        this.initialize = function(editor) {        /* initialize the tool */        this.editor = editor;        this._fixTabIndex(this.dlbutton);        addEventHandler(this.dlbutton, 'click', this.createDefinitionList, this);        addEventHandler(editor.getInnerDocument(), 'keyup', this._keyDownHandler, this);        addEventHandler(editor.getInnerDocument(), 'keypress', this._keyPressHandler, this);    };    // even though the following methods may seem view related, they belong     // here, since they describe core functionality rather then view-specific    // stuff    this.handleEnterPress = function(selNode) {        var dl = this.editor.getNearestParentOfType(selNode, 'dl');        if (dl) {            var dt = this.editor.getNearestParentOfType(selNode, 'dt');            if (dt) {                if (dt.childNodes.length == 1 && dt.childNodes[0].nodeValue == '\xa0') {                    this.escapeFromDefinitionList(dl, dt, selNode);                    return;                };                var selection = this.editor.getSelection();                var startoffset = selection.startOffset();                var endoffset = selection.endOffset();                 if (endoffset > startoffset) {                    // throw away any selected stuff                    selection.cutChunk(startoffset, endoffset);                    selection = this.editor.getSelection();                    startoffset = selection.startOffset();                };                                var ellength = selection.getElementLength(selection.parentElement());                if (startoffset >= ellength - 1) {                    // create a new element                    this.createDefinition(dl, dt);                } else {                    var doc = this.editor.getInnerDocument();                    var newdt = selection.splitNodeAtSelection(dt);                    var newdd = doc.createElement('dd');                    while (newdt.hasChildNodes()) {                        if (newdt.firstChild != newdt.lastChild || newdt.firstChild.nodeName.toLowerCase() != 'br') {                            newdd.appendChild(newdt.firstChild);                        };                    };                    newdt.parentNode.replaceChild(newdd, newdt);                    selection.selectNodeContents(newdd);                    selection.collapse();                };            } else {                var dd = this.editor.getNearestParentOfType(selNode, 'dd');                if (!dd) {                    this.editor.logMessage('Not inside a definition list element!');                    return;                };                if (dd.childNodes.length == 1 && dd.childNodes[0].nodeValue == '\xa0') {                    this.escapeFromDefinitionList(dl, dd, selNode);                    return;                };                var selection = this.editor.getSelection();                var startoffset = selection.startOffset();                var endoffset = selection.endOffset();                if (endoffset > startoffset) {                    // throw away any selected stuff                    selection.cutChunk(startoffset, endoffset);                    selection = this.editor.getSelection();                    startoffset = selection.startOffset();                };                var ellength = selection.getElementLength(selection.parentElement());                if (startoffset >= ellength - 1) {                    // create a new element                    this.createDefinitionTerm(dl, dd);                } else {                    // add a break and continue in this element                    var br = this.editor.getInnerDocument().createElement('br');                    this.editor.insertNodeAtSelection(br, 1);                    //var selection = this.editor.getSelection();                    //selection.moveStart(1);                    selection.collapse(true);                };            };        };    };    this.handleTabPress = function(selNode) {    };    this._keyDownHandler = function(event) {        var selNode = this.editor.getSelectedNode();        var dl = this.editor.getNearestParentOfType(selNode, 'dl');        if (!dl) {            return;        };        switch (event.keyCode) {            case 13:                if (event.preventDefault) {                    event.preventDefault();                } else {                    event.returnValue = false;                };                br

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -