@@ -1317,3 +1317,26 @@ jQuery.cookie = function (key, value, options) {
|
||||
};
|
||||
|
||||
})( jQuery );
|
||||
|
||||
jQuery.fn.css2 = jQuery.fn.css;
|
||||
jQuery.fn.css = function() {
|
||||
if (arguments.length) return jQuery.fn.css2.apply(this, arguments);
|
||||
var attr = ['font-family','font-size','font-weight','font-style','color', 'box-sizing',
|
||||
'text-transform','text-decoration','letter-spacing', 'box-shadow',
|
||||
'line-height','text-align','vertical-align','direction','background-color',
|
||||
'background-image','background-repeat','background-position',
|
||||
'background-attachment','opacity','width','height','top','right','bottom',
|
||||
'left','margin-top','margin-right','margin-bottom','margin-left',
|
||||
'padding-top','padding-right','padding-bottom','padding-left',
|
||||
'border-top-width','border-right-width','border-bottom-width',
|
||||
'border-left-width','border-top-color','border-right-color',
|
||||
'border-bottom-color','border-left-color','border-top-style',
|
||||
'border-right-style','border-bottom-style','border-left-style','position',
|
||||
'display','visibility','z-index','overflow-x','overflow-y','white-space',
|
||||
'clip','float','clear','cursor','list-style-image','list-style-position',
|
||||
'list-style-type','marker-offset'];
|
||||
var len = attr.length, obj = {};
|
||||
for (var i = 0; i < len; i++)
|
||||
obj[attr[i]] = jQuery.fn.css2.call(this, attr[i]);
|
||||
return obj;
|
||||
};
|
||||
|
||||
+24
-12
@@ -109,20 +109,32 @@ $(document).ready(function() {
|
||||
var slug = $('#slug');
|
||||
|
||||
if (slug.length > 0) {
|
||||
var sw = slug.width();
|
||||
if (slug.val().length > 0) {
|
||||
slug.css('width', 'auto').attr('size', slug.val().length);
|
||||
var justifySlug = $('<div />').css(slug.css()).css({
|
||||
'display' : 'none',
|
||||
'width' : 'auto'
|
||||
}).insertAfter(slug), originalWidth = slug.width();
|
||||
|
||||
function justifySlugWidth() {
|
||||
var html = slug.val().replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/(( )*) /g, '$1 ')
|
||||
.replace(/\n/g, '<br />')
|
||||
.replace(/<br \/>[ ]*$/, '<br />-')
|
||||
.replace(/<br \/> /g, '<br /> ');
|
||||
|
||||
justifySlug.css('min-width', html.length > 0
|
||||
? 'inherit' : originalWidth);
|
||||
|
||||
justifySlug.html(html);
|
||||
slug.width(justifySlug.width());
|
||||
}
|
||||
|
||||
slug.bind('input propertychange', function () {
|
||||
var t = $(this), l = t.val().length;
|
||||
|
||||
if (l > 0) {
|
||||
t.css('width', 'auto').attr('size', l);
|
||||
} else {
|
||||
t.css('width', sw).removeAttr('size');
|
||||
}
|
||||
}).width();
|
||||
slug.bind('input propertychange', justifySlugWidth);
|
||||
justifySlugWidth();
|
||||
}
|
||||
|
||||
// 原始的插入图片和文件
|
||||
|
||||
Reference in New Issue
Block a user