From 3bc77e9a52fad33c49f8692239fd5ca211aa4701 Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 17 Oct 2013 11:39:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=90=9E=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/write-js.php | 80 +++++++++++----------- admin/write-page.php | 153 +++++++++++++++++++------------------------ admin/write-post.php | 6 +- 3 files changed, 110 insertions(+), 129 deletions(-) diff --git a/admin/write-js.php b/admin/write-js.php index 4648d999..93d535d9 100644 --- a/admin/write-js.php +++ b/admin/write-js.php @@ -36,51 +36,53 @@ $(document).ready(function() { // tag autocomplete 提示 var tags = $('#tags'), tagsPre = []; - var items = tags.val().split(','), result = []; - for (var i = 0; i < items.length; i ++) { - var tag = items[i]; + if (tags.length > 0) { + var items = tags.val().split(','), result = []; + for (var i = 0; i < items.length; i ++) { + var tag = items[i]; - if (!tag) { - continue; + if (!tag) { + continue; + } + + tagsPre.push({ + id : tag, + tags : tag + }); } - tagsPre.push({ - id : tag, - tags : tag + tags.tokenInput(next()) { + $data[] = array( + 'id' => $tags->name, + 'tags' => $tags->name + ); + } + echo json_encode($data); + ?>, { + propertyToSearch: 'tags', + tokenValue : 'tags', + searchDelay : 0, + preventDuplicates : true, + animateDropdown : false, + hintText : '', + noResultsText : '此标签不存在, 按回车创建', + prePopulate : tagsPre, + + onResult : function (result) { + return result.slice(0, 5); + } + }); + + // tag autocomplete 提示宽度设置 + $('#token-input-tags').focus(function() { + var t = $('.token-input-dropdown'), + offset = t.outerWidth() - t.width(); + t.width($('.token-input-list').outerWidth() - offset); }); } - tags.tokenInput(next()) { - $data[] = array( - 'id' => $tags->name, - 'tags' => $tags->name - ); - } - echo json_encode($data); - ?>, { - propertyToSearch: 'tags', - tokenValue : 'tags', - searchDelay : 0, - preventDuplicates : true, - animateDropdown : false, - hintText : '', - noResultsText : '此标签不存在, 按回车创建', - prePopulate : tagsPre, - - onResult : function (result) { - return result.slice(0, 5); - } - }); - - // tag autocomplete 提示宽度设置 - $('#token-input-tags').focus(function() { - var t = $('.token-input-dropdown'), - offset = t.outerWidth() - t.width(); - t.width($('.token-input-list').outerWidth() - offset); - }); - // 缩略名自适应宽度 var slug = $('#slug'), sw = slug.width(); diff --git a/admin/write-page.php b/admin/write-page.php index b1950695..35973c1c 100644 --- a/admin/write-page.php +++ b/admin/write-page.php @@ -7,43 +7,57 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
-
+
-
-
-
-
-
    -
  • - -

    - - - , - - @ - - : - -

    -

    -
  • -
  • - -

    -

    -
  • - option($page); ?> + + + advanceOption($page); ?> +
+ have()): ?> modified); ?> -
  • - -

    word()); ?>

    -
  • +
    +

    +

    + %s 创建', + Typecho_Common::url('manage-pages.php?uid=' . $page->author->uid, $options->adminUrl), $page->author->screenName); ?>
    + word()); ?> +

    +
    diff --git a/admin/write-post.php b/admin/write-post.php index e29ed90f..1f9ddd87 100644 --- a/admin/write-post.php +++ b/admin/write-post.php @@ -88,6 +88,8 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);

    + option($post); ?> +
    pass('editor', true)): ?>
    @@ -105,7 +107,6 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);

    - advanceOptionLeft($post); ?>
    @@ -117,13 +118,12 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
  • allow('feed')): ?>checked="true" />
  • - advanceOptionRight($post); ?>
    + advanceOption($post); ?>
    - option($post); ?> have()): ?> modified); ?>
    From 475666933961bfe5d061558bda00731c3da6bc49 Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 17 Oct 2013 12:01:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=A9=E6=8F=90=E7=A4=BA=E6=A1=86?= =?UTF-8?q?=E6=82=AC=E6=B5=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/common-js.php | 4 +- admin/css/style.css | 1 + admin/javascript/typecho.js | 130 ++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) diff --git a/admin/common-js.php b/admin/common-js.php index fb805157..cb41b53c 100644 --- a/admin/common-js.php +++ b/admin/common-js.php @@ -26,7 +26,9 @@ p.slideDown(); } - p.delay(5000).fadeOut(); + p.sticky({ + getWidthFrom : document.body + }).delay(5000).fadeOut(); } })(); diff --git a/admin/css/style.css b/admin/css/style.css index 5b2d5f99..65e8d455 100644 --- a/admin/css/style.css +++ b/admin/css/style.css @@ -440,6 +440,7 @@ button.primary:active, button.primary.active { text-align: center; font-weight: bold; display: none; + margin: 0; -moz-border-radius: 0; -moz-border-radius: 0; diff --git a/admin/javascript/typecho.js b/admin/javascript/typecho.js index d27dbd4d..78c0e961 100644 --- a/admin/javascript/typecho.js +++ b/admin/javascript/typecho.js @@ -1031,3 +1031,133 @@ jQuery.cookie = function (key, value, options) { return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; }; +// Sticky Plugin v1.0.0 for jQuery +// ============= +// Author: Anthony Garand +// Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk) +// Improvements by Leonardo C. Daronco (daronco) +// Created: 2/14/2011 +// Date: 2/12/2012 +// Website: http://labs.anthonygarand.com/sticky +// Description: Makes an element on the page stick on the screen as you scroll +// It will only set the 'top' and 'position' of your element, you +// might need to adjust the width in some cases. + +(function($) { + var defaults = { + topSpacing: 0, + bottomSpacing: 0, + className: 'is-sticky', + wrapperClassName: 'sticky-wrapper', + center: false, + getWidthFrom: '' + }, + $window = $(window), + $document = $(document), + sticked = [], + windowHeight = $window.height(), + scroller = function() { + var scrollTop = $window.scrollTop(), + documentHeight = $document.height(), + dwh = documentHeight - windowHeight, + extra = (scrollTop > dwh) ? dwh - scrollTop : 0; + + for (var i = 0; i < sticked.length; i++) { + var s = sticked[i], + elementTop = s.stickyWrapper.offset().top, + etse = elementTop - s.topSpacing - extra; + + if (scrollTop <= etse) { + if (s.currentTop !== null) { + s.stickyElement + .css('position', '') + .css('top', ''); + s.stickyElement.parent().removeClass(s.className); + s.currentTop = null; + } + } + else { + var newTop = documentHeight - s.stickyElement.outerHeight() + - s.topSpacing - s.bottomSpacing - scrollTop - extra; + if (newTop < 0) { + newTop = newTop + s.topSpacing; + } else { + newTop = s.topSpacing; + } + if (s.currentTop != newTop) { + s.stickyElement + .css('position', 'fixed') + .css('top', newTop); + + if (typeof s.getWidthFrom !== 'undefined') { + s.stickyElement.css('width', $(s.getWidthFrom).width()); + } + + s.stickyElement.parent().addClass(s.className); + s.currentTop = newTop; + } + } + } + }, + resizer = function() { + windowHeight = $window.height(); + }, + methods = { + init: function(options) { + var o = $.extend(defaults, options); + return this.each(function() { + var stickyElement = $(this); + + var stickyId = stickyElement.attr('id'); + var wrapper = $('
    ') + .attr('id', stickyId + '-sticky-wrapper') + .addClass(o.wrapperClassName); + stickyElement.wrapAll(wrapper); + + if (o.center) { + stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"}); + } + + if (stickyElement.css("float") == "right") { + stickyElement.css({"float":"none"}).parent().css({"float":"right"}); + } + + var stickyWrapper = stickyElement.parent(); + // stickyWrapper.css('height', stickyElement.outerHeight()); + sticked.push({ + topSpacing: o.topSpacing, + bottomSpacing: o.bottomSpacing, + stickyElement: stickyElement, + currentTop: null, + stickyWrapper: stickyWrapper, + className: o.className, + getWidthFrom: o.getWidthFrom + }); + }); + }, + update: scroller + }; + + // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer): + if (window.addEventListener) { + window.addEventListener('scroll', scroller, false); + window.addEventListener('resize', resizer, false); + } else if (window.attachEvent) { + window.attachEvent('onscroll', scroller); + window.attachEvent('onresize', resizer); + } + + $.fn.sticky = function(method) { + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method ) { + return methods.init.apply( this, arguments ); + } else { + $.error('Method ' + method + ' does not exist on jQuery.sticky'); + } + }; + $(function() { + setTimeout(scroller, 0); + }); +})(jQuery); +