From a914c2b6d370705dbf4343f969c33cf63f084ebf Mon Sep 17 00:00:00 2001 From: fen Date: Sun, 1 Dec 2013 12:55:17 +0800 Subject: [PATCH 01/65] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E6=B1=87=E6=8A=A5?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/copyright.php | 2 +- usr/themes/default/style.css | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/admin/copyright.php b/admin/copyright.php index 73e94850..0856742e 100644 --- a/admin/copyright.php +++ b/admin/copyright.php @@ -6,7 +6,7 @@ diff --git a/usr/themes/default/style.css b/usr/themes/default/style.css index 4bf98947..afa66016 100644 --- a/usr/themes/default/style.css +++ b/usr/themes/default/style.css @@ -45,7 +45,6 @@ blockquote { margin: 1em 1.5em; padding-left: 1.5em; border-left: 4px solid #F3F3F0; - color: #777; } h1, h2, h3 { From 8ba71ee6ac7b908b304250952219e048ebb501b6 Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 10:18:01 +0800 Subject: [PATCH 02/65] fixed #96 --- admin/editor-js.php | 11 ++++++- var/MarkdownExtraExtended.php | 2 +- var/Typecho/Common.php | 58 ++++++++++++++++++++--------------- 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/admin/editor-js.php b/admin/editor-js.php index a1bbcd64..57b631be 100644 --- a/admin/editor-js.php +++ b/admin/editor-js.php @@ -143,7 +143,15 @@ $(document).ready(function () { }); editor.hooks.chain('onPreviewRefresh', function () { - var diff = $('.diff', preview); + var diff = $('.diff', preview), scrolled = false; + + $('img', preview).load(function () { + if (scrolled) { + preview.scrollTo(diff, { + offset : - 50 + }); + } + }); if (diff.length > 0) { var p = diff.position(), lh = diff.parent().css('line-height'); @@ -153,6 +161,7 @@ $(document).ready(function () { preview.scrollTo(diff, { offset : - 50 }); + scrolled = true; } } }); diff --git a/var/MarkdownExtraExtended.php b/var/MarkdownExtraExtended.php index a23506c8..29527a9f 100644 --- a/var/MarkdownExtraExtended.php +++ b/var/MarkdownExtraExtended.php @@ -3170,7 +3170,7 @@ class MarkdownExtraExtended extends MarkdownExtra { } public function doClearBreaks($text) { - return preg_replace("/\s*((?:
\n)+)\s*(<\/?(?:$this->block_tags_re|li)[^\d])/is", + return preg_replace("/\s*((?:
\n)+)\s*(<\/?(?:$this->block_tags_re|li|dd|dt)[^\d])/is", "\\2", $text); } diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php index 21ebd1ab..0af97ab8 100644 --- a/var/Typecho/Common.php +++ b/var/Typecho/Common.php @@ -112,6 +112,35 @@ class Typecho_Common $safePath = rtrim(__TYPECHO_ROOT_DIR__, '/'); return 0 === strpos($path, $safePath); } + + /** + * __filterAttrs + * + * @param mixed $matches + * @static + * @access public + * @return void + */ + public static function __filterAttrs($matches) + { + $str = trim($matches[2]); + + if (empty($str)) { + return ''; + } + + $attrs = self::__parseAttrs($str); + $parsedAttrs = array(); + $tag = strtolower($matches[1]); + + foreach ($attrs as $key => $val) { + if (in_array($key, self::$_allowableAttributes[$tag])) { + $parsedAttrs[] = " {$key}" . (empty($val) ? '' : "={$val}"); + } + } + + return '<' . $tag . implode('', $parsedAttrs) . '>'; + } /** * 解析属性 @@ -574,33 +603,12 @@ EOF; } } + self::$_allowableAttributes = $allowableAttributes; $html = strip_tags($html, $normalizeTags); + $html = preg_replace_callback("/<([_a-z0-9-]+)(\s+[^>]+)?>/is", + array('Typecho_Common', '__filterAttrs'), $html); - if (empty($dom)) { - $dom = new DOMDocument('1.0', self::$charset); - $dom->encoding = self::$charset; - $dom->xmlStandalone = false; - } - @$dom->loadHTML('' - . '' - . $html . ''); - - foreach($dom->getElementsByTagName('*') as $node){ - $tagName = strtolower($node->tagName); - - for ($i = 0; $i < $node->attributes->length; $i ++) { - $attribute = $node->attributes->item($i); - $name = strtolower($attribute->name); - - if (empty($allowableAttributes[$tagName]) || !in_array($name, $allowableAttributes[$tagName])) { - $node->removeAttributeNode($attribute); - } - } - } - - - $body = $dom->getElementsByTagName('body'); - return $body->length > 0 ? $body->item(0)->nodeValue : ''; + return $html; } /** From 55fb9e01894032f909b6cdf6f851496a9a5c3add Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 10:21:00 +0800 Subject: [PATCH 03/65] =?UTF-8?q?=E7=BB=A7=E7=BB=ADfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Typecho/Common.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php index 0af97ab8..8ef4dd4a 100644 --- a/var/Typecho/Common.php +++ b/var/Typecho/Common.php @@ -123,10 +123,14 @@ class Typecho_Common */ public static function __filterAttrs($matches) { + if (!isset($matches[2])) { + return $matches[0]; + } + $str = trim($matches[2]); if (empty($str)) { - return ''; + return $matches[0]; } $attrs = self::__parseAttrs($str); From ed2b3590a41b7b0e038f2c23a4d2ac669b0405ef Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 11:21:16 +0800 Subject: [PATCH 04/65] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AD=97=E6=AE=B5=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/themes/default/functions.php | 2 -- var/Typecho/Widget/Helper/Form/Element.php | 24 ++++++++----- .../Widget/Helper/Form/Element/Checkbox.php | 1 + .../Widget/Helper/Form/Element/Hidden.php | 1 + .../Widget/Helper/Form/Element/Password.php | 1 + .../Widget/Helper/Form/Element/Radio.php | 1 + .../Widget/Helper/Form/Element/Select.php | 1 + .../Widget/Helper/Form/Element/Submit.php | 2 ++ .../Widget/Helper/Form/Element/Text.php | 1 + .../Widget/Helper/Form/Element/Textarea.php | 2 ++ var/Typecho/Widget/Helper/Layout.php | 10 ++++++ var/Widget/Abstract/Contents.php | 9 ++--- var/Widget/Contents/Post/Edit.php | 34 ++++++++++++++----- 13 files changed, 67 insertions(+), 22 deletions(-) diff --git a/usr/themes/default/functions.php b/usr/themes/default/functions.php index cae4eb02..d4d13225 100644 --- a/usr/themes/default/functions.php +++ b/usr/themes/default/functions.php @@ -15,9 +15,7 @@ function themeConfig($form) { $form->addInput($sidebarBlock->multiMode()); } -/* function themeFields($layout) { $logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO')); $layout->addItem($logoUrl); } -*/ diff --git a/var/Typecho/Widget/Helper/Form/Element.php b/var/Typecho/Widget/Helper/Form/Element.php index c4cb2a14..97e5c00a 100644 --- a/var/Typecho/Widget/Helper/Form/Element.php +++ b/var/Typecho/Widget/Helper/Form/Element.php @@ -38,14 +38,6 @@ abstract class Typecho_Widget_Helper_Form_Element extends Typecho_Widget_Helper_ */ protected $message; - /** - * 表单元素容器 - * - * @access protected - * @var Typecho_Widget_Helper_Layout - */ - protected $container; - /** * 多行输入 * @@ -62,6 +54,14 @@ abstract class Typecho_Widget_Helper_Form_Element extends Typecho_Widget_Helper_ */ protected static $uniqueId = 0; + /** + * 表单元素容器 + * + * @access public + * @var Typecho_Widget_Helper_Layout + */ + public $container; + /** * 输入栏 * @@ -70,6 +70,14 @@ abstract class Typecho_Widget_Helper_Form_Element extends Typecho_Widget_Helper_ */ public $input; + /** + * inputs + * + * @var array + * @access public + */ + public $inputs = array(); + /** * 表单标题 * diff --git a/var/Typecho/Widget/Helper/Form/Element/Checkbox.php b/var/Typecho/Widget/Helper/Form/Element/Checkbox.php index da083240..e2b8af59 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Checkbox.php +++ b/var/Typecho/Widget/Helper/Form/Element/Checkbox.php @@ -44,6 +44,7 @@ class Typecho_Widget_Helper_Form_Element_Checkbox extends Typecho_Widget_Helper_ $this->_options[$value] = new Typecho_Widget_Helper_Layout('input'); $item = $this->multiline(); $id = $this->name . '-' . $this->filterValue($value); + $this->inputs[] = $this->_options[$value]; $item->addItem($this->_options[$value]->setAttribute('name', $this->name . '[]') ->setAttribute('type', 'checkbox') diff --git a/var/Typecho/Widget/Helper/Form/Element/Hidden.php b/var/Typecho/Widget/Helper/Form/Element/Hidden.php index 87004e7f..889bc7e7 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Hidden.php +++ b/var/Typecho/Widget/Helper/Form/Element/Hidden.php @@ -46,6 +46,7 @@ class Typecho_Widget_Helper_Form_Element_Hidden extends Typecho_Widget_Helper_Fo { $input = new Typecho_Widget_Helper_Layout('input', array('name' => $name, 'type' => 'hidden')); $this->container($input); + $this->inputs[] = $input; return $input; } diff --git a/var/Typecho/Widget/Helper/Form/Element/Password.php b/var/Typecho/Widget/Helper/Form/Element/Password.php index 01f04178..811f28c8 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Password.php +++ b/var/Typecho/Widget/Helper/Form/Element/Password.php @@ -36,6 +36,7 @@ class Typecho_Widget_Helper_Form_Element_Password extends Typecho_Widget_Helper_ 'name' => $name, 'type' => 'password', 'class' => 'password')); $this->label->setAttribute('for', $name . '-0-' . self::$uniqueId); $this->container($input); + $this->inputs[] = $input; return $input; } diff --git a/var/Typecho/Widget/Helper/Form/Element/Radio.php b/var/Typecho/Widget/Helper/Form/Element/Radio.php index 08211940..2b1a5396 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Radio.php +++ b/var/Typecho/Widget/Helper/Form/Element/Radio.php @@ -44,6 +44,7 @@ class Typecho_Widget_Helper_Form_Element_Radio extends Typecho_Widget_Helper_For $this->_options[$value] = new Typecho_Widget_Helper_Layout('input'); $item = $this->multiline(); $id = $this->name . '-' . $this->filterValue($value); + $this->inputs[] = $this->_options[$value]; $item->addItem($this->_options[$value]->setAttribute('name', $this->name) ->setAttribute('type', 'radio') diff --git a/var/Typecho/Widget/Helper/Form/Element/Select.php b/var/Typecho/Widget/Helper/Form/Element/Select.php index c2136c7b..f09e2f66 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Select.php +++ b/var/Typecho/Widget/Helper/Form/Element/Select.php @@ -44,6 +44,7 @@ class Typecho_Widget_Helper_Form_Element_Select extends Typecho_Widget_Helper_Fo $this->container($input->setAttribute('name', $name) ->setAttribute('id', $name . '-0-' . self::$uniqueId)); $this->label->setAttribute('for', $name . '-0-' . self::$uniqueId); + $this->inputs[] = $input; foreach ($options as $value => $label) { $this->_options[$value] = new Typecho_Widget_Helper_Layout('option'); diff --git a/var/Typecho/Widget/Helper/Form/Element/Submit.php b/var/Typecho/Widget/Helper/Form/Element/Submit.php index fd69f679..1d88f513 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Submit.php +++ b/var/Typecho/Widget/Helper/Form/Element/Submit.php @@ -35,6 +35,8 @@ class Typecho_Widget_Helper_Form_Element_Submit extends Typecho_Widget_Helper_Fo $this->setAttribute('class', 'typecho-option typecho-option-submit'); $input = new Typecho_Widget_Helper_Layout('button', array('type' => 'submit')); $this->container($input); + $this->inputs[] = $input; + return $input; } diff --git a/var/Typecho/Widget/Helper/Form/Element/Text.php b/var/Typecho/Widget/Helper/Form/Element/Text.php index a62c1bb6..df5b1e9c 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Text.php +++ b/var/Typecho/Widget/Helper/Form/Element/Text.php @@ -36,6 +36,7 @@ class Typecho_Widget_Helper_Form_Element_Text extends Typecho_Widget_Helper_Form 'name' => $name, 'type' => 'text', 'class' => 'text')); $this->container($input); $this->label->setAttribute('for', $name . '-0-' . self::$uniqueId); + $this->inputs[] = $input; return $input; } diff --git a/var/Typecho/Widget/Helper/Form/Element/Textarea.php b/var/Typecho/Widget/Helper/Form/Element/Textarea.php index 72533987..43d0e497 100644 --- a/var/Typecho/Widget/Helper/Form/Element/Textarea.php +++ b/var/Typecho/Widget/Helper/Form/Element/Textarea.php @@ -35,6 +35,8 @@ class Typecho_Widget_Helper_Form_Element_Textarea extends Typecho_Widget_Helper_ $input = new Typecho_Widget_Helper_Layout('textarea', array('id' => $name . '-0-' . self::$uniqueId, 'name' => $name)); $this->label->setAttribute('for', $name . '-0-' . self::$uniqueId); $this->container($input->setClose(false)); + $this->inputs[] = $input; + return $input; } diff --git a/var/Typecho/Widget/Helper/Layout.php b/var/Typecho/Widget/Helper/Layout.php index f78d4ed5..b90c081e 100644 --- a/var/Typecho/Widget/Helper/Layout.php +++ b/var/Typecho/Widget/Helper/Layout.php @@ -166,6 +166,16 @@ class Typecho_Widget_Helper_Layout { $this->_tagName = $tagName; } + + /** + * getTagName + * + * @param mixed $tagName + * @access public + * @return void + */ + public function getTagName($tagName) + {} /** * 设置表单属性 diff --git a/var/Widget/Abstract/Contents.php b/var/Widget/Abstract/Contents.php index 530b8cf9..0af9e2f6 100644 --- a/var/Widget/Abstract/Contents.php +++ b/var/Widget/Abstract/Contents.php @@ -432,15 +432,16 @@ class Widget_Abstract_Contents extends Widget_Abstract list ($type, $name) = explode(':', $name, 2); } - if (isset($exists[$name])) { - unset($exists[$name]); - } - $isFieldReadOnly = $this->pluginHandle(__CLASS__)->trigger($plugged)->isFieldReadOnly($name); if ($plugged && $isFieldReadOnly) { continue; } + if (isset($exists[$name])) { + unset($exists[$name]); + } + + $this->setField($name, $type, $value, $cid); } diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php index 06cd3bea..9d2d2aeb 100644 --- a/var/Widget/Contents/Post/Edit.php +++ b/var/Widget/Contents/Post/Edit.php @@ -496,20 +496,31 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg if ($item instanceof Typecho_Widget_Helper_Form_Element) { $name = $item->input->getAttribute('name'); - if (preg_match("/^fields\[(.+)\]$/", $name, $matches)) { - $name = $matches[1]; - } else { - $item->input->setAttribute('name', 'fields[' . $name . ']'); - } - $isFieldReadOnly = $this->pluginHandle('Widget_Abstract_Contents') ->trigger($plugged)->isFieldReadOnly($name); if ($plugged && $isFieldReadOnly) { - $item->input->setAttribute('readonly', 'readonly'); + continue; + } + + if (preg_match("/^fields\[(.+)\]$/", $name, $matches)) { + $name = $matches[1]; + } else { + foreach ($item->inputs as $input) { + $input->setAttribute('name', 'fields[' . $name . ']'); + } } $item->value($fields->{$name}); - $defaultFields[$name] = array($item->label, $item->input); + + $elements = $item->container->getItems(); + array_shift($elements); + $div = new Typecho_Widget_Helper_Layout('div'); + + foreach ($elements as $el) { + $div->addItem($el); + } + + $defaultFields[$name] = array($item->label, $div); } } @@ -532,6 +543,13 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg ->where('cid = ?', $this->cid)); foreach ($rows as $row) { + $isFieldReadOnly = $this->pluginHandle('Widget_Abstract_Contents') + ->trigger($plugged)->isFieldReadOnly($row['name']); + + if ($plugged && $isFieldReadOnly) { + continue; + } + if (!isset($defaultFields[$row['name']])) { $fields[] = $row; } From 8e26e1f64667255b17d702aecf782c73fec1641e Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 15:26:17 +0800 Subject: [PATCH 05/65] fixed #97 --- var/Typecho/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php index 1ad305c4..d53fb341 100644 --- a/var/Typecho/Request.php +++ b/var/Typecho/Request.php @@ -640,7 +640,7 @@ class Typecho_Request */ public function isSecure() { - return (isset($_SERVER['HTTPS']) && 'on' == $_SERVER['HTTPS']) || (isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']); + return (isset($_SERVER['HTTPS']) && 'off' != $_SERVER['HTTPS']) || (isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']); } /** From 5954b77a2585f558811dc1a3db1c917541ccc72b Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 15:29:02 +0800 Subject: [PATCH 06/65] fixed #93 --- usr/themes/default/sidebar.php | 122 ++++++++++++++++----------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/usr/themes/default/sidebar.php b/usr/themes/default/sidebar.php index 16be4e53..7dfcbc51 100644 --- a/usr/themes/default/sidebar.php +++ b/usr/themes/default/sidebar.php @@ -1,61 +1,61 @@ -
- options->sidebarBlock) || in_array('ShowRecentPosts', $this->options->sidebarBlock)): ?> -
-

-
    - widget('Widget_Contents_Post_Recent') - ->parse('
  • {title}
  • '); ?> -
-
- - - options->sidebarBlock) || in_array('ShowRecentComments', $this->options->sidebarBlock)): ?> -
-

-
    - widget('Widget_Comments_Recent')->to($comments); ?> - next()): ?> -
  • author(false); ?>excerpt(35, '...'); ?>
  • - -
-
- - - options->sidebarBlock) || in_array('ShowCategory', $this->options->sidebarBlock)): ?> -
-

-
    - widget('Widget_Metas_Category_List') - ->parse('
  • {name} ({count})
  • '); ?> -
-
- - - options->sidebarBlock) || in_array('ShowArchive', $this->options->sidebarBlock)): ?> -
-

-
    - widget('Widget_Contents_Post_Date', 'type=month&format=F Y') - ->parse('
  • {date}
  • '); ?> -
-
- - - options->sidebarBlock) || in_array('ShowOther', $this->options->sidebarBlock)): ?> -
-

- -
- - -
+
+ options->sidebarBlock) && in_array('ShowRecentPosts', $this->options->sidebarBlock)): ?> +
+

+
    + widget('Widget_Contents_Post_Recent') + ->parse('
  • {title}
  • '); ?> +
+
+ + + options->sidebarBlock) && in_array('ShowRecentComments', $this->options->sidebarBlock)): ?> +
+

+
    + widget('Widget_Comments_Recent')->to($comments); ?> + next()): ?> +
  • author(false); ?>excerpt(35, '...'); ?>
  • + +
+
+ + + options->sidebarBlock) && in_array('ShowCategory', $this->options->sidebarBlock)): ?> +
+

+
    + widget('Widget_Metas_Category_List') + ->parse('
  • {name} ({count})
  • '); ?> +
+
+ + + options->sidebarBlock) && in_array('ShowArchive', $this->options->sidebarBlock)): ?> +
+

+
    + widget('Widget_Contents_Post_Date', 'type=month&format=F Y') + ->parse('
  • {date}
  • '); ?> +
+
+ + + options->sidebarBlock) && in_array('ShowOther', $this->options->sidebarBlock)): ?> +
+

+ +
+ + +
From 78a386ff41bfec3ff48b954d044228171340ec6a Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 15:32:43 +0800 Subject: [PATCH 07/65] fixed #99 --- usr/themes/default/functions.php | 4 ++++ var/Widget/Archive.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/usr/themes/default/functions.php b/usr/themes/default/functions.php index d4d13225..0e63bb92 100644 --- a/usr/themes/default/functions.php +++ b/usr/themes/default/functions.php @@ -15,7 +15,11 @@ function themeConfig($form) { $form->addInput($sidebarBlock->multiMode()); } + +/* function themeFields($layout) { $logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点LOGO地址'), _t('在这里填入一个图片URL地址, 以在网站标题前加上一个LOGO')); $layout->addItem($logoUrl); } +*/ + diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php index 5483219f..583f5489 100644 --- a/var/Widget/Archive.php +++ b/var/Widget/Archive.php @@ -1239,7 +1239,7 @@ class Widget_Archive extends Widget_Abstract_Contents (table.contents.status = ? AND table.contents.authorId = ?)', 'publish', 'hidden', 'private', $this->user->uid); } else { - $select = $this->select()->where('table.contents.status = ? OR table.contents.status', + $select = $this->select()->where('table.contents.status = ? OR table.contents.status = ?', 'publish', 'hidden'); } } else { From 3c00fda61cf7d7a4e43deb4f305c03ea22ddda84 Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 2 Dec 2013 17:17:53 +0800 Subject: [PATCH 08/65] fixed #98 --- admin/js/tokeninput.js | 8 ++++++-- admin/user.php | 2 +- admin/write-js.php | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/admin/js/tokeninput.js b/admin/js/tokeninput.js index 4f03c440..c571299e 100755 --- a/admin/js/tokeninput.js +++ b/admin/js/tokeninput.js @@ -502,6 +502,10 @@ $.TokenList = function (input, url_or_data, settings) { item[settings.propertyToSearch] = input_box.val(); } + if (!item) { + return false; + } + // See if the token already exists and select it if we don't want duplicates if(token_count > 0 && settings.preventDuplicates) { var found_existing_token = null; @@ -803,7 +807,7 @@ $.TokenList = function (input, url_or_data, settings) { // Attach the success callback ajax_params.success = function(results) { if($.isFunction(settings.onResult)) { - results = settings.onResult.call(hidden_input, results); + results = settings.onResult.call(hidden_input, results, query); } cache.add(cache_key, settings.jsonContainer ? results[settings.jsonContainer] : results); @@ -822,7 +826,7 @@ $.TokenList = function (input, url_or_data, settings) { }); if($.isFunction(settings.onResult)) { - results = settings.onResult.call(hidden_input, results); + results = settings.onResult.call(hidden_input, results, query); } cache.add(cache_key, results); populate_dropdown(query, results); diff --git a/admin/user.php b/admin/user.php index 7b0b1ed7..227d9e14 100644 --- a/admin/user.php +++ b/admin/user.php @@ -1,6 +1,5 @@ @@ -19,5 +18,6 @@ include 'menu.php'; diff --git a/admin/write-js.php b/admin/write-js.php index d09c6c19..8b370446 100644 --- a/admin/write-js.php +++ b/admin/write-js.php @@ -77,7 +77,22 @@ $(document).ready(function() { noResultsText : '', prePopulate : tagsPre, - onResult : function (result) { + onResult : function (result, query) { + if (!query) { + return result; + } + + if (!result) { + result = []; + } + + if (!result[0] || result[0]['id'] != query) { + result.unshift({ + id : query, + tags : query + }); + } + return result.slice(0, 5); } }); From 51d31fe7cdf313f010e0c09e9bcbf4fc21175e60 Mon Sep 17 00:00:00 2001 From: fen Date: Mon, 2 Dec 2013 18:48:55 +0800 Subject: [PATCH 09/65] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=AF=BC=E8=88=AA=E8=8F=9C=E5=8D=95=E5=9C=A8?= =?UTF-8?q?=20IE=2010=20=E4=B8=8B=E6=97=A0=E6=B3=95=E8=B4=9F=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/css/style.css | 4 ++++ admin/profile.php | 2 +- admin/scss/_buttons.scss | 1 + admin/scss/style.scss | 5 +++++ usr/themes/default/style.css | 3 ++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/admin/css/style.css b/admin/css/style.css index f2ffbfc9..bda5405b 100644 --- a/admin/css/style.css +++ b/admin/css/style.css @@ -503,6 +503,10 @@ button { .front-archive { padding-left: 1.5em; } +.profile-avatar { + border: 1px dashed #D9D9D6; + max-width: 100%; } + /** 增加配置面板内部的错误样式 by 70 */ /** * 安装样式 diff --git a/admin/profile.php b/admin/profile.php index 35dbef18..153205a0 100644 --- a/admin/profile.php +++ b/admin/profile.php @@ -11,7 +11,7 @@ $stat = Typecho_Widget::widget('Widget_Stat');
-

mail) . '?s=220&r=X' . +

mail) . '?s=220&r=X' . '&d=" alt="' . $user->screenName . '" />'; ?>

screenName(); ?>
name(); ?>

%s 篇 Blog,并有 %s 条关于你的评论在已设定的 %s 个分类中.', diff --git a/admin/scss/_buttons.scss b/admin/scss/_buttons.scss index 76b50d1c..fb489e47 100644 --- a/admin/scss/_buttons.scss +++ b/admin/scss/_buttons.scss @@ -10,6 +10,7 @@ cursor: pointer; @include border-radius(2px); + // @include transition-property(background-color); @include transition-duration(.4s); &:hover { diff --git a/admin/scss/style.scss b/admin/scss/style.scss index 69226433..0073099d 100644 --- a/admin/scss/style.scss +++ b/admin/scss/style.scss @@ -166,6 +166,11 @@ a.button:hover, a.balloon-button:hover { padding-left: 1.5em; } +.profile-avatar { + border: 1px dashed #D9D9D6; + max-width: 100%; +} + /** 增加配置面板内部的错误样式 by 70 */ diff --git a/usr/themes/default/style.css b/usr/themes/default/style.css index afa66016..005e00a0 100644 --- a/usr/themes/default/style.css +++ b/usr/themes/default/style.css @@ -106,7 +106,7 @@ textarea { /* Navigation menu */ #nav-menu { - margin: 25px 0 -1px; + margin: 25px 0 0; padding: 0; } #nav-menu a { @@ -114,6 +114,7 @@ textarea { margin-right: -1px; padding: 0 20px; border: 1px solid #EEE; + border-bottom: none; height: 32px; line-height: 32px; color: #444; From e1ff8c522847a3fdedacc245973737e9858ab860 Mon Sep 17 00:00:00 2001 From: fen Date: Tue, 3 Dec 2013 11:21:56 +0800 Subject: [PATCH 10/65] =?UTF-8?q?=E7=89=BA=E7=89=B2=E7=82=B9=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/css/style.css | 24 ++++++++++++------------ admin/header.php | 5 +---- admin/scss/_buttons.scss | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/admin/css/style.css b/admin/css/style.css index bda5405b..4f32deb9 100644 --- a/admin/css/style.css +++ b/admin/css/style.css @@ -127,10 +127,6 @@ button { -ms-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; - -webkit-transition-duration: 0.4s; - -moz-transition-duration: 0.4s; - -o-transition-duration: 0.4s; - transition-duration: 0.4s; display: inline-block; padding: 0 12px; height: 32px; @@ -138,6 +134,10 @@ button { vertical-align: middle; zoom: 1; } button:hover { + -webkit-transition-duration: 0.4s; + -moz-transition-duration: 0.4s; + -o-transition-duration: 0.4s; + transition-duration: 0.4s; background-color: #dbdbd6; } button:active, button.active { background-color: #dbdbd6; } @@ -168,12 +168,12 @@ button { -ms-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; - -webkit-transition-duration: 0.4s; - -moz-transition-duration: 0.4s; - -o-transition-duration: 0.4s; - transition-duration: 0.4s; color: #FFF; } .primary:hover { + -webkit-transition-duration: 0.4s; + -moz-transition-duration: 0.4s; + -o-transition-duration: 0.4s; + transition-duration: 0.4s; background-color: #3c6a81; } .primary:active, .primary.active { background-color: #3c6a81; } @@ -193,12 +193,12 @@ button { -ms-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; - -webkit-transition-duration: 0.4s; - -moz-transition-duration: 0.4s; - -o-transition-duration: 0.4s; - transition-duration: 0.4s; color: #FFF; } .btn-warn:hover { + -webkit-transition-duration: 0.4s; + -moz-transition-duration: 0.4s; + -o-transition-duration: 0.4s; + transition-duration: 0.4s; background-color: #a4403f; } .btn-warn:active, .btn-warn.active { background-color: #a4403f; } diff --git a/admin/header.php b/admin/header.php index c929ceb1..1328da9e 100644 --- a/admin/header.php +++ b/admin/header.php @@ -15,10 +15,7 @@ $header = ' - - - + diff --git a/admin/scss/_buttons.scss b/admin/scss/_buttons.scss index fb489e47..e87d6f76 100644 --- a/admin/scss/_buttons.scss +++ b/admin/scss/_buttons.scss @@ -11,9 +11,9 @@ @include border-radius(2px); // @include transition-property(background-color); - @include transition-duration(.4s); &:hover { + @include transition-duration(.4s); background-color: darken($color, 6%); } &:active, &.active { From 9875a00221ba20ae97c6bdc87e0803b2f5cbc2e7 Mon Sep 17 00:00:00 2001 From: joyqi Date: Tue, 3 Dec 2013 11:57:36 +0800 Subject: [PATCH 11/65] =?UTF-8?q?=E4=BF=AE=E5=89=AA=E6=92=B0=E5=86=99?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/write-js.php | 13 ++++++++++++- admin/write-page.php | 10 ++++++---- admin/write-post.php | 34 ++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/admin/write-js.php b/admin/write-js.php index 8b370446..5588bbd6 100644 --- a/admin/write-js.php +++ b/admin/write-js.php @@ -218,12 +218,23 @@ $(document).ready(function() { return false; }); - // 高级选项控制 $('#advance-panel-btn').click(function() { $('#advance-panel').toggle(); return false; }); + + // 自动隐藏密码框 + $('#visibility').change(function () { + var val = $(this).val(), password = $('#post-password'); + console.log(val); + + if ('password' == val) { + password.removeClass('hidden'); + } else { + password.addClass('hidden'); + } + }); // 草稿删除确认 $('.edit-draft-notice a').click(function () { diff --git a/admin/write-page.php b/admin/write-page.php index 92acb854..aba77a73 100644 --- a/admin/write-page.php +++ b/admin/write-page.php @@ -89,10 +89,12 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);

-
    -
  • status == 'publish' || !$page->status) { ?> checked="true" />
  • -
  • status == 'hidden') { ?> checked="true" />
  • -
+

+ +

diff --git a/admin/write-post.php b/admin/write-post.php index 0681a3d4..b65429c9 100644 --- a/admin/write-post.php +++ b/admin/write-post.php @@ -100,25 +100,24 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
pass('editor', true)): ?>
- -
    + +

    + status == 'publish' && !$post->password) || !$post->status) { ?> checked="true" /> -

  • status == 'hidden') { ?> checked="true" />
  • -
  • password) { ?> checked="true" />
  • -
  • status == 'private') { ?> checked="true" />
  • + + + + -
  • pass('editor', true) || $post->status == 'waiting') { ?> checked="true" />
  • -
+ + +

+

password) == 0): ?> class="hidden"> + +

-
- -

-

-
-
    @@ -130,6 +129,13 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
+ +
+ +

+

+
+ advanceOption($post); ?>
From a8399ef1c2c8995cd5e96b74a7c45bc4486314d5 Mon Sep 17 00:00:00 2001 From: joyqi Date: Tue, 3 Dec 2013 16:12:38 +0800 Subject: [PATCH 12/65] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AD=97=E6=AE=B5=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- var/Widget/Abstract/Contents.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/var/Widget/Abstract/Contents.php b/var/Widget/Abstract/Contents.php index 0af9e2f6..6ce33bd3 100644 --- a/var/Widget/Abstract/Contents.php +++ b/var/Widget/Abstract/Contents.php @@ -409,6 +409,18 @@ class Widget_Abstract_Contents extends Widget_Abstract ->where('cid = ?', $cid)); } + /** + * 检查字段名是否符合要求 + * + * @param string $name + * @access public + * @return boolean + */ + public function checkFieldName($name) + { + return preg_match("/^[_a-z][_a-z0-9]*$/i", $name); + } + /** * 保存自定义字段 * @@ -432,6 +444,10 @@ class Widget_Abstract_Contents extends Widget_Abstract list ($type, $name) = explode(':', $name, 2); } + if (!$this->checkFieldName($name)) { + continue; + } + $isFieldReadOnly = $this->pluginHandle(__CLASS__)->trigger($plugged)->isFieldReadOnly($name); if ($plugged && $isFieldReadOnly) { continue; @@ -441,7 +457,6 @@ class Widget_Abstract_Contents extends Widget_Abstract unset($exists[$name]); } - $this->setField($name, $type, $value, $cid); } @@ -463,7 +478,8 @@ class Widget_Abstract_Contents extends Widget_Abstract */ public function setField($name, $type, $value, $cid) { - if (empty($name) || !in_array($type, array('str', 'int', 'float'))) { + if (empty($name) || !$this->checkFieldName($name) + || !in_array($type, array('str', 'int', 'float'))) { return false; } @@ -503,6 +519,10 @@ class Widget_Abstract_Contents extends Widget_Abstract */ public function incrIntField($name, $value, $cid) { + if (!$this->checkFieldName($name)) { + return false; + } + $exist = $this->db->fetchRow($this->db->select('type')->from('table.fields') ->where('cid = ? AND name = ?', $cid, $name)); $value = intval($value); From b9cf37d8158f75e2136c114b31d356616b03bb7e Mon Sep 17 00:00:00 2001 From: joyqi Date: Tue, 3 Dec 2013 20:27:43 +0800 Subject: [PATCH 13/65] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/js/pagedown.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/admin/js/pagedown.js b/admin/js/pagedown.js index 49c49236..fa398f12 100644 --- a/admin/js/pagedown.js +++ b/admin/js/pagedown.js @@ -1086,7 +1086,16 @@ else } function _DoItalicsAndBold(text) { + // must go first: + text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, + "$2"); + text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, + "$2"); + + return text; + +/* // must go first: text = text.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, "$1$3$4"); @@ -1095,6 +1104,7 @@ else "$1$3$4"); return text; +*/ } function _DoBlockQuotes(text) { From 7da8d5a0bea9bc28681538d1c0b8ee77518260ef Mon Sep 17 00:00:00 2001 From: joyqi Date: Thu, 5 Dec 2013 23:57:08 +0800 Subject: [PATCH 14/65] fixed #102 --- var/MarkdownExtraExtended.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/var/MarkdownExtraExtended.php b/var/MarkdownExtraExtended.php index 29527a9f..7558c6f9 100644 --- a/var/MarkdownExtraExtended.php +++ b/var/MarkdownExtraExtended.php @@ -1334,12 +1334,13 @@ class Markdown { $this->tail = ''; if ($level < 0) { - $link = preg_replace("/\){1," . (- $level) . "}$/", $link, array($this, '_doAutoLinks_url_callback_callback')); + $link = preg_replace_callback("/\){1," . (- $level) . "}$/", + array($this, '_doAutoLinks_url_callback_callback'), $link); } - $url = $this->encodeAttribute($matches[2] . $matches[3]); + $url = $this->encodeAttribute($protocol . $link); $link = "$url"; - return '<' . $protocol . $this->hashPart($link) . '>' . $this->tail; + return $this->hashPart($link) . $this->tail; } protected function _doAutoLinks_email_callback($matches) { From 6a9d2ea5eb2763139ec191c249ff2b37a5848c78 Mon Sep 17 00:00:00 2001 From: joyqi Date: Fri, 6 Dec 2013 09:20:02 +0800 Subject: [PATCH 15/65] fix crlf --- admin/js/timepicker.js | 4268 ++++++++--------- license.txt | 562 +-- usr/plugins/ConnectToTwitter/Plugin.php | 288 +- usr/plugins/Creole/Creole_Wiki.php | 3198 ++++++------ usr/plugins/Creole/Parse.inc.php | 524 +- usr/plugins/Creole/Parse/Address.php | 132 +- usr/plugins/Creole/Parse/Blockquote.php | 350 +- usr/plugins/Creole/Parse/Box.php | 160 +- usr/plugins/Creole/Parse/Break.php | 144 +- usr/plugins/Creole/Parse/Center.php | 156 +- usr/plugins/Creole/Parse/Delimiter.php | 134 +- usr/plugins/Creole/Parse/Footnote.php | 164 +- usr/plugins/Creole/Parse/Heading.php | 194 +- usr/plugins/Creole/Parse/Horiz.php | 114 +- usr/plugins/Creole/Parse/Image.php | 132 +- usr/plugins/Creole/Parse/List.php | 486 +- usr/plugins/Creole/Parse/Newline.php | 118 +- usr/plugins/Creole/Parse/Paragraph.php | 276 +- usr/plugins/Creole/Parse/Prefilter.php | 106 +- usr/plugins/Creole/Parse/Preformatted.php | 136 +- usr/plugins/Creole/Parse/Raw.php | 122 +- usr/plugins/Creole/Parse/Strong.php | 164 +- usr/plugins/Creole/Parse/Table.php | 412 +- usr/plugins/Creole/Parse/Tighten.php | 72 +- usr/plugins/Creole/Parse/Tt.php | 156 +- usr/plugins/Creole/Parse/Url.php | 216 +- usr/plugins/Creole/Plugin.php | 144 +- usr/plugins/Creole/Render.inc.php | 436 +- usr/plugins/PostToQzone/Plugin.php | 370 +- usr/plugins/ShareCode/Plugin.php | 154 +- .../tiny_mce/plugins/coder/editor_plugin.js | 158 +- .../plugins/inlinepopups/template.htm | 774 +-- .../tiny_mce/plugins/media/css/content.css | 12 +- .../tiny_mce/plugins/media/css/media.css | 32 +- .../tiny_mce/plugins/media/js/embed.js | 146 +- .../tiny_mce/plugins/media/js/media.js | 1260 ++--- .../TinyMCE/tiny_mce/plugins/media/media.htm | 1644 +++---- .../plugins/morebreak/editor_plugin.js | 148 +- .../tiny_mce/themes/advanced/about.htm | 112 +- .../tiny_mce/themes/advanced/anchor.htm | 62 +- .../tiny_mce/themes/advanced/charmap.htm | 106 +- .../tiny_mce/themes/advanced/color_picker.htm | 150 +- .../tiny_mce/themes/advanced/image.htm | 170 +- .../tiny_mce/themes/advanced/js/about.js | 144 +- .../tiny_mce/themes/advanced/js/anchor.js | 74 +- .../tiny_mce/themes/advanced/js/charmap.js | 650 +-- .../themes/advanced/js/color_picker.js | 506 +- .../tiny_mce/themes/advanced/js/image.js | 490 +- .../tiny_mce/themes/advanced/js/link.js | 312 +- .../themes/advanced/js/source_editor.js | 124 +- .../TinyMCE/tiny_mce/themes/advanced/link.htm | 126 +- .../themes/advanced/skins/typecho/content.css | 72 +- .../themes/advanced/skins/typecho/dialog.css | 260 +- .../themes/advanced/skins/typecho/ui.css | 456 +- .../themes/advanced/source_editor.htm | 62 +- .../tiny_mce/utils/editable_selects.js | 138 +- .../TinyMCE/tiny_mce/utils/form_utils.js | 398 +- usr/plugins/TinyMCE/tiny_mce/utils/mctabs.js | 152 +- .../TinyMCE/tiny_mce/utils/validate.js | 438 +- usr/plugins/ZenCoding/zen_textarea.js | 2 +- usr/themes/default/404.php | 30 +- usr/themes/default/archive.php | 70 +- usr/themes/default/comments.php | 96 +- usr/themes/default/index.php | 68 +- usr/themes/default/page.php | 28 +- usr/themes/default/post.php | 42 +- 66 files changed, 11700 insertions(+), 11700 deletions(-) diff --git a/admin/js/timepicker.js b/admin/js/timepicker.js index ab1d9b18..644703ff 100644 --- a/admin/js/timepicker.js +++ b/admin/js/timepicker.js @@ -1,2134 +1,2134 @@ -/*! jQuery Timepicker Addon - v1.4 - 2013-08-11 -* http://trentrichardson.com/examples/timepicker -* Copyright (c) 2013 Trent Richardson; Licensed MIT */ -(function ($) { - - /* - * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" - */ - $.ui.timepicker = $.ui.timepicker || {}; - if ($.ui.timepicker.version) { - return; - } - - /* - * Extend jQueryUI, get it started with our version number - */ - $.extend($.ui, { - timepicker: { - version: "1.4" - } - }); - - /* - * Timepicker manager. - * Use the singleton instance of this class, $.timepicker, to interact with the time picker. - * Settings for (groups of) time pickers are maintained in an instance object, - * allowing multiple different settings on the same page. - */ - var Timepicker = function () { - this.regional = []; // Available regional settings, indexed by language code - this.regional[''] = { // Default regional settings - currentText: 'Now', - closeText: 'Done', - amNames: ['AM', 'A'], - pmNames: ['PM', 'P'], - timeFormat: 'HH:mm', - timeSuffix: '', - timeOnlyTitle: 'Choose Time', - timeText: 'Time', - hourText: 'Hour', - minuteText: 'Minute', - secondText: 'Second', - millisecText: 'Millisecond', - microsecText: 'Microsecond', - timezoneText: 'Time Zone', - isRTL: false - }; - this._defaults = { // Global defaults for all the datetime picker instances - showButtonPanel: true, - timeOnly: false, - showHour: null, - showMinute: null, - showSecond: null, - showMillisec: null, - showMicrosec: null, - showTimezone: null, - showTime: true, - stepHour: 1, - stepMinute: 1, - stepSecond: 1, - stepMillisec: 1, - stepMicrosec: 1, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - microsec: 0, - timezone: null, - hourMin: 0, - minuteMin: 0, - secondMin: 0, - millisecMin: 0, - microsecMin: 0, - hourMax: 23, - minuteMax: 59, - secondMax: 59, - millisecMax: 999, - microsecMax: 999, - minDateTime: null, - maxDateTime: null, - onSelect: null, - hourGrid: 0, - minuteGrid: 0, - secondGrid: 0, - millisecGrid: 0, - microsecGrid: 0, - alwaysSetTime: true, - separator: ' ', - altFieldTimeOnly: true, - altTimeFormat: null, - altSeparator: null, - altTimeSuffix: null, - pickerTimeFormat: null, - pickerTimeSuffix: null, - showTimepicker: true, - timezoneList: null, - addSliderAccess: false, - sliderAccessArgs: null, - controlType: 'slider', - defaultValue: null, - parse: 'strict' - }; - $.extend(this._defaults, this.regional['']); - }; - - $.extend(Timepicker.prototype, { - $input: null, - $altInput: null, - $timeObj: null, - inst: null, - hour_slider: null, - minute_slider: null, - second_slider: null, - millisec_slider: null, - microsec_slider: null, - timezone_select: null, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - microsec: 0, - timezone: null, - hourMinOriginal: null, - minuteMinOriginal: null, - secondMinOriginal: null, - millisecMinOriginal: null, - microsecMinOriginal: null, - hourMaxOriginal: null, - minuteMaxOriginal: null, - secondMaxOriginal: null, - millisecMaxOriginal: null, - microsecMaxOriginal: null, - ampm: '', - formattedDate: '', - formattedTime: '', - formattedDateTime: '', - timezoneList: null, - units: ['hour', 'minute', 'second', 'millisec', 'microsec'], - support: {}, - control: null, - - /* - * Override the default settings for all instances of the time picker. - * @param {Object} settings object - the new settings to use as defaults (anonymous object) - * @return {Object} the manager object - */ - setDefaults: function (settings) { - extendRemove(this._defaults, settings || {}); - return this; - }, - - /* - * Create a new Timepicker instance - */ - _newInst: function ($input, opts) { - var tp_inst = new Timepicker(), - inlineSettings = {}, - fns = {}, - overrides, i; - - for (var attrName in this._defaults) { - if (this._defaults.hasOwnProperty(attrName)) { - var attrValue = $input.attr('time:' + attrName); - if (attrValue) { - try { - inlineSettings[attrName] = eval(attrValue); - } catch (err) { - inlineSettings[attrName] = attrValue; - } - } - } - } - - overrides = { - beforeShow: function (input, dp_inst) { - if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) { - return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst); - } - }, - onChangeMonthYear: function (year, month, dp_inst) { - // Update the time as well : this prevents the time from disappearing from the $input field. - tp_inst._updateDateTime(dp_inst); - if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { - tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); - } - }, - onClose: function (dateText, dp_inst) { - if (tp_inst.timeDefined === true && $input.val() !== '') { - tp_inst._updateDateTime(dp_inst); - } - if ($.isFunction(tp_inst._defaults.evnts.onClose)) { - tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst); - } - } - }; - for (i in overrides) { - if (overrides.hasOwnProperty(i)) { - fns[i] = opts[i] || null; - } - } - - tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, { - evnts: fns, - timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); - }); - tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) { - return val.toUpperCase(); - }); - tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) { - return val.toUpperCase(); - }); - - // detect which units are supported - tp_inst.support = detectSupport( - tp_inst._defaults.timeFormat + - (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') + - (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : '')); - - // controlType is string - key to our this._controls - if (typeof(tp_inst._defaults.controlType) === 'string') { - if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') { - tp_inst._defaults.controlType = 'select'; - } - tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType]; - } - // controlType is an object and must implement create, options, value methods - else { - tp_inst.control = tp_inst._defaults.controlType; - } - - // prep the timezone options - var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60, - 0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840]; - if (tp_inst._defaults.timezoneList !== null) { - timezoneList = tp_inst._defaults.timezoneList; - } - var tzl = timezoneList.length, tzi = 0, tzv = null; - if (tzl > 0 && typeof timezoneList[0] !== 'object') { - for (; tzi < tzl; tzi++) { - tzv = timezoneList[tzi]; - timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) }; - } - } - tp_inst._defaults.timezoneList = timezoneList; - - // set the default units - tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) : - ((new Date()).getTimezoneOffset() * -1); - tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin : - tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour; - tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin : - tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute; - tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin : - tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second; - tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin : - tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec; - tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin : - tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec; - tp_inst.ampm = ''; - tp_inst.$input = $input; - - if (tp_inst._defaults.altField) { - tp_inst.$altInput = $(tp_inst._defaults.altField).css({ - cursor: 'pointer' - }).focus(function () { - $input.trigger("focus"); - }); - } - - if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { - tp_inst._defaults.minDate = new Date(); - } - if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) { - tp_inst._defaults.maxDate = new Date(); - } - - // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. - if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) { - tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); - } - if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) { - tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime()); - } - if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) { - tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime()); - } - if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) { - tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime()); - } - tp_inst.$input.bind('focus', function () { - tp_inst._onFocus(); - }); - - return tp_inst; - }, - - /* - * add our sliders to the calendar - */ - _addTimePicker: function (dp_inst) { - var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); - - this.timeDefined = this._parseTime(currDT); - this._limitMinMaxDateTime(dp_inst, false); - this._injectTimePicker(); - }, - - /* - * parse the time string from input value or _setTime - */ - _parseTime: function (timeString, withDate) { - if (!this.inst) { - this.inst = $.datepicker._getInst(this.$input[0]); - } - - if (withDate || !this._defaults.timeOnly) { - var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); - try { - var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults); - if (!parseRes.timeObj) { - return false; - } - $.extend(this, parseRes.timeObj); - } catch (err) { - $.timepicker.log("Error parsing the date/time string: " + err + - "\ndate/time string = " + timeString + - "\ntimeFormat = " + this._defaults.timeFormat + - "\ndateFormat = " + dp_dateFormat); - return false; - } - return true; - } else { - var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults); - if (!timeObj) { - return false; - } - $.extend(this, timeObj); - return true; - } - }, - - /* - * generate and inject html for timepicker into ui datepicker - */ - _injectTimePicker: function () { - var $dp = this.inst.dpDiv, - o = this.inst.settings, - tp_inst = this, - litem = '', - uitem = '', - show = null, - max = {}, - gridSize = {}, - size = null, - i = 0, - l = 0; - - // Prevent displaying twice - if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { - var noDisplay = ' style="display:none;"', - html = '
' + '
' + o.timeText + '
' + - '
'; - - // Create the markup - for (i = 0, l = this.units.length; i < l; i++) { - litem = this.units[i]; - uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1); - show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem]; - - // Added by Peter Medeiros: - // - Figure out what the hour/minute/second max should be based on the step values. - // - Example: if stepMinute is 15, then minMax is 45. - max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10); - gridSize[litem] = 0; - - html += '
' + o[litem + 'Text'] + '
' + - '
'; - - if (show && o[litem + 'Grid'] > 0) { - html += '
'; - - if (litem === 'hour') { - for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) { - gridSize[litem]++; - var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o); - html += ''; - } - } - else { - for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) { - gridSize[litem]++; - html += ''; - } - } - - html += '
' + tmph + '' + ((m < 10) ? '0' : '') + m + '
'; - } - html += '
'; - } - - // Timezone - var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone; - html += '
' + o.timezoneText + '
'; - html += '
'; - - // Create the elements from string - html += '
'; - var $tp = $(html); - - // if we only want time picker... - if (o.timeOnly === true) { - $tp.prepend('
' + '
' + o.timeOnlyTitle + '
' + '
'); - $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); - } - - // add sliders, adjust grids, add events - for (i = 0, l = tp_inst.units.length; i < l; i++) { - litem = tp_inst.units[i]; - uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1); - show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem]; - - // add the slider - tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]); - - // adjust the grid and add click event - if (show && o[litem + 'Grid'] > 0) { - size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']); - $tp.find('.ui_tpicker_' + litem + ' table').css({ - width: size + "%", - marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"), - marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0', - borderCollapse: 'collapse' - }).find("td").click(function (e) { - var $t = $(this), - h = $t.html(), - n = parseInt(h.replace(/[^0-9]/g), 10), - ap = h.replace(/[^apm]/ig), - f = $t.data('for'); // loses scope, so we use data-for - - if (f === 'hour') { - if (ap.indexOf('p') !== -1 && n < 12) { - n += 12; - } - else { - if (ap.indexOf('a') !== -1 && n === 12) { - n = 0; - } - } - } - - tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n); - - tp_inst._onTimeChange(); - tp_inst._onSelectHandler(); - }).css({ - cursor: 'pointer', - width: (100 / gridSize[litem]) + '%', - textAlign: 'center', - overflow: 'hidden' - }); - } // end if grid > 0 - } // end for loop - - // Add timezone options - this.timezone_select = $tp.find('.ui_tpicker_timezone').append('').find("select"); - $.fn.append.apply(this.timezone_select, - $.map(o.timezoneList, function (val, idx) { - return $("