From d25dcf36691bcfac406be9e416f470925170afc7 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 9 Oct 2013 11:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/css/style.css | 5 +- admin/javascript/typecho.js | 318 +++++++++++++++++++++++++++++++ admin/manage-metas.php | 194 +++++++++++-------- admin/manage-pages.php | 2 +- var/Widget/Abstract/Contents.php | 2 +- 5 files changed, 440 insertions(+), 81 deletions(-) diff --git a/admin/css/style.css b/admin/css/style.css index 02a08f0a..867bf6bc 100644 --- a/admin/css/style.css +++ b/admin/css/style.css @@ -357,6 +357,10 @@ button.primary:active, button.primary.active { white-space: nowrap; } +.dropdown-menu li p { + padding: 5px 13px; +} + .dropdown-menu li a { display: block; padding: 3px 15px; @@ -2389,7 +2393,6 @@ ul.autocompleter-choices span.autocompleter-queried { .typecho-page-main ul.tag-list li.checked, .typecho-page-main ul.tag-list li.even.checked { background: none; - font-weight: bold; text-decoration: underline; } diff --git a/admin/javascript/typecho.js b/admin/javascript/typecho.js index 02d648f2..c0a4d844 100644 --- a/admin/javascript/typecho.js +++ b/admin/javascript/typecho.js @@ -76,6 +76,324 @@ })($); +/** + * TableDnD plug-in for JQuery, allows you to drag and drop table rows + * You can set up various options to control how the system will work + * Copyright © Denis Howlett + * Licensed like jQuery, see http://docs.jquery.com/License. + * + * Configuration options: + * + * onDragStyle + * This is the style that is assigned to the row during drag. There are limitations to the styles that can be + * associated with a row (such as you can't assign a border—well you can, but it won't be + * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as + * a map (as used in the jQuery css(...) function). + * onDropStyle + * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations + * to what you can do. Also this replaces the original style, so again consider using onDragClass which + * is simply added and then removed on drop. + * onDragClass + * This class is added for the duration of the drag and then removed when the row is dropped. It is more + * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default + * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your + * stylesheet. + * onDrop + * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table + * and the row that was dropped. You can work out the new order of the rows by using + * table.rows. + * onDragStart + * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the + * table and the row which the user has started to drag. + * onAllowDrop + * Pass a function that will be called as a row is over another row. If the function returns true, allow + * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under + * the cursor. It returns a boolean: true allows the drop, false doesn't allow it. + * scrollAmount + * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the + * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2, + * FF3 beta) + * + * Other ways to control behaviour: + * + * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows + * that you don't want to be draggable. + * + * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form + * []=&[]= so that you can send this back to the server. The table must have + * an ID as must all the rows. + * + * Known problems: + * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0 + * + * Version 0.2: 2008-02-20 First public version + * Version 0.3: 2008-02-07 Added onDragStart option + * Made the scroll amount configurable (default is 5 as before) + * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes + * Added onAllowDrop to control dropping + * Fixed a bug which meant that you couldn't set the scroll amount in both directions + * Added serialise method + */ +(function (jQuery) { +jQuery.tableDnD = { + /** Keep hold of the current table being dragged */ + currentTable : null, + /** Keep hold of the current drag object if any */ + dragObject: null, + /** The current mouse offset */ + mouseOffset: null, + /** Remember the old value of Y so that we don't do too much processing */ + oldY: 0, + + /** Actually build the structure */ + build: function(options) { + // Make sure options exists + options = options || {}; + // Set up the defaults if any + + this.each(function() { + // Remember the options + this.tableDnDConfig = { + onDragStyle: options.onDragStyle, + onDropStyle: options.onDropStyle, + // Add in the default class for whileDragging + onDragClass: options.onDragClass ? options.onDragClass : "tDnD_whileDrag", + onDrop: options.onDrop, + onDragStart: options.onDragStart, + scrollAmount: options.scrollAmount ? options.scrollAmount : 5 + }; + // Now make the rows draggable + jQuery.tableDnD.makeDraggable(this); + }); + + // Now we need to capture the mouse up and mouse move event + // We can use bind so that we don't interfere with other event handlers + jQuery(document) + .bind('mousemove', jQuery.tableDnD.mousemove) + .bind('mouseup', jQuery.tableDnD.mouseup); + + // Don't break the chain + return this; + }, + + /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */ + makeDraggable: function(table) { + // Now initialise the rows + var rows = table.rows; //getElementsByTagName("tr") + var config = table.tableDnDConfig; + for (var i=0; i jQuery.tableDnD.oldY; + // update the old value + jQuery.tableDnD.oldY = y; + // update the style to show we're dragging + if (config.onDragClass) { + dragObj.addClass(config.onDragClass); + } else { + dragObj.css(config.onDragStyle); + } + // If we're over a row then move the dragged row to there so that the user sees the + // effect dynamically + var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); + if (currentRow) { + // TODO worry about what happens when there are multiple TBODIES + if (movingDown && jQuery.tableDnD.dragObject != currentRow) { + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling); + } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) { + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow); + } + } + } + + return false; + }, + + /** We're only worried about the y position really, because we can only move rows up and down */ + findDropTargetRow: function(draggedRow, y) { + var rows = jQuery.tableDnD.currentTable.rows; + for (var i=0; i rowY - rowHeight) && (y < (rowY + rowHeight))) { + // that's the row we're over + // If it's the same as the current row, ignore it + if (row == draggedRow) {return null;} + var config = jQuery.tableDnD.currentTable.tableDnDConfig; + if (config.onAllowDrop) { + if (config.onAllowDrop(draggedRow, row)) { + return row; + } else { + return null; + } + } else { + // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic) + var nodrop = $(row).hasClass("nodrop"); + if (! nodrop) { + return row; + } else { + return null; + } + } + return row; + } + } + return null; + }, + + mouseup: function(e) { + if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) { + var droppedRow = jQuery.tableDnD.dragObject; + var config = jQuery.tableDnD.currentTable.tableDnDConfig; + // If we have a dragObject, then we need to release it, + // The row will already have been moved to the right place so we just reset stuff + if (config.onDragClass) { + jQuery(droppedRow).removeClass(config.onDragClass); + } else { + jQuery(droppedRow).css(config.onDropStyle); + } + jQuery.tableDnD.dragObject = null; + if (config.onDrop) { + // Call the onDrop method if there is one + config.onDrop(jQuery.tableDnD.currentTable, droppedRow); + } + jQuery.tableDnD.currentTable = null; // let go of the table too + } + }, + + serialize: function() { + if (jQuery.tableDnD.currentTable) { + var result = ""; + var tableId = jQuery.tableDnD.currentTable.id; + var rows = jQuery.tableDnD.currentTable.rows; + for (var i=0; i 0) result += "&"; + result += tableId + '[]=' + rows[i].id; + } + return result; + } else { + return "Error: No Table id set, you need to set an id on your table and every row"; + } + } +} + +jQuery.fn.extend( + { + tableDnD : jQuery.tableDnD.build + } +); +})($); + + /** 初始化全局对象 */ var Typecho = {}; diff --git a/admin/manage-metas.php b/admin/manage-metas.php index b38c9a31..eb599ab6 100644 --- a/admin/manage-metas.php +++ b/admin/manage-metas.php @@ -16,22 +16,25 @@ include 'menu.php'; type) || 'category' == $request->get('type')): ?> to($categories); ?> -
+
-

: - , -     - : - , - , - +

+ +
+ + +
+
- +
@@ -53,7 +56,7 @@ include 'menu.php'; have()): ?> next()): ?> - alt(' class="even"', ''); ?> id="theId(); ?>"> + alt(' class="even"', ''); ?> id="mid-theId(); ?>">
name(); ?> @@ -77,24 +80,26 @@ include 'menu.php';
-
to($tags); ?> -
+
-

: - , -     - : - , - , - - -

+
+ +
+ + +
+
-
    +
      have()): ?> next()): ?>
    • @@ -125,66 +130,99 @@ include 'menu.php'; diff --git a/admin/manage-pages.php b/admin/manage-pages.php index 70058fa2..7842e8a1 100644 --- a/admin/manage-pages.php +++ b/admin/manage-pages.php @@ -32,7 +32,7 @@ $stat = Typecho_Widget::widget('Widget_Stat'); - +
      diff --git a/var/Widget/Abstract/Contents.php b/var/Widget/Abstract/Contents.php index a4d56208..62ec5145 100644 --- a/var/Widget/Abstract/Contents.php +++ b/var/Widget/Abstract/Contents.php @@ -462,7 +462,7 @@ class Widget_Abstract_Contents extends Widget_Abstract /** 处理附件 */ if ('attachment' == $type) { - $content = unserialize($value['text']); + $content = @unserialize($value['text']); //增加数据信息 $value['attachment'] = new Typecho_Config($content);