mirror of
https://github.com/typecho/typecho.git
synced 2025-03-19 01:19:40 +01:00
Merge branch 'master' of https://github.com/typecho/typecho-replica
This commit is contained in:
commit
9d064518c3
@ -1,6 +1,14 @@
|
||||
(function (w) {
|
||||
w.Typecho = {
|
||||
insertFileToEditor : function (file, url, isImage) {}
|
||||
insertFileToEditor : function (file, url, isImage) {},
|
||||
editorResize : function (id, url) {
|
||||
$('#' + id).resizeable({
|
||||
minHeight : 100,
|
||||
afterResize : function (h) {
|
||||
$.post(url, {size : h});
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
})(window);
|
||||
|
||||
@ -23,6 +31,69 @@
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.resizeable = function (options) {
|
||||
var s = $.extend({
|
||||
minHeight : 100,
|
||||
afterResize : null
|
||||
}, options);
|
||||
|
||||
return this.each(function () {
|
||||
var r = $('<span class="resize"><i></i></span>').insertAfter(this),
|
||||
staticOffset, iLastMousePos = 0, iMin = s.minHeight, t = this;
|
||||
|
||||
function startDrag(e) {
|
||||
textarea = $(e.data.el);
|
||||
textarea.blur();
|
||||
iLastMousePos = mousePosition(e).y;
|
||||
|
||||
staticOffset = textarea.height() - iLastMousePos;
|
||||
textarea.css('opacity', 0.25);
|
||||
|
||||
$(document).mousemove(performDrag).mouseup(endDrag);
|
||||
return false;
|
||||
}
|
||||
|
||||
function performDrag(e) {
|
||||
var iThisMousePos = mousePosition(e).y,
|
||||
iMousePos = staticOffset + iThisMousePos;
|
||||
if (iLastMousePos >= (iThisMousePos)) {
|
||||
iMousePos -= 5;
|
||||
}
|
||||
|
||||
iLastMousePos = iThisMousePos;
|
||||
iMousePos = Math.max(iMin, iMousePos);
|
||||
textarea.height(iMousePos + 'px');
|
||||
|
||||
if (iMousePos < iMin) {
|
||||
endDrag(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function endDrag(e) {
|
||||
var h = textarea.outerHeight();
|
||||
$(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
|
||||
|
||||
textarea.css('opacity', 1);
|
||||
textarea.focus();
|
||||
textarea = null;
|
||||
|
||||
staticOffset = null;
|
||||
iLastMousePos = 0;
|
||||
|
||||
if (s.afterResize) {
|
||||
s.afterResize.call(t, h);
|
||||
}
|
||||
}
|
||||
|
||||
function mousePosition(e) {
|
||||
return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop };
|
||||
}
|
||||
|
||||
r.bind('mousedown', {el : this}, startDrag);
|
||||
});
|
||||
};
|
||||
|
||||
// 表格选择插件
|
||||
$.fn.tableSelectable = function (options) {
|
||||
var table = this, s = $.extend({
|
||||
|
@ -34,6 +34,9 @@ $(document).ready(function() {
|
||||
minute : (new Date()).getMinutes()
|
||||
});
|
||||
|
||||
// text 自动拉伸
|
||||
Typecho.editorResize('text', '<?php $options->index('/action/ajax?do=editorResize'); ?>');
|
||||
|
||||
// tag autocomplete 提示
|
||||
var tags = $('#tags'), tagsPre = [];
|
||||
|
||||
|
@ -29,7 +29,6 @@ Typecho_Widget::widget('Widget_Contents_Page_Edit')->to($page);
|
||||
<p class="mono url-slug"><?php echo preg_replace("/\{slug\}/i", $input, $permalink); ?></p>
|
||||
<p>
|
||||
<textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text" name="text" class="w-100 mono"><?php echo htmlspecialchars($page->text); ?></textarea>
|
||||
<span class="resize"><i></i></span>
|
||||
</p>
|
||||
|
||||
<?php include 'file-upload.php'; ?>
|
||||
|
@ -34,7 +34,6 @@ Typecho_Widget::widget('Widget_Contents_Post_Edit')->to($post);
|
||||
|
||||
<p>
|
||||
<textarea style="height: <?php $options->editorSize(); ?>px" autocomplete="off" id="text" name="text" class="w-100 mono"><?php echo htmlspecialchars($post->text); ?></textarea>
|
||||
<span class="resize"><i></i></span>
|
||||
</p>
|
||||
|
||||
<?php include 'file-upload.php'; ?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user