<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
@@ -70,19 +53,23 @@
:homework => @homework.id
}) do |f|%>
- 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
+ 提示:作品名称和描述中不要出现真实的姓名信息
+
<%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %>
-
+
<%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%>
+
-
+
diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js
index 9ffbf8b93..8362217a7 100644
--- a/public/javascripts/new_user.js
+++ b/public/javascripts/new_user.js
@@ -179,94 +179,73 @@ function regexStudentWorkDescription()
}
}
-//textarea自适应高度
-(function($){
-
- $.fn.autoResize = function(options) {
-
- // Just some abstracted details,
- // to make plugin users happy:
- var settings = $.extend({
- onResize : function(){},
- animate : true,
- animateDuration : 150,
- animateCallback : function(){},
- extraSpace : 20,
- limit: 1000
- }, options);
-
- // Only textarea's auto-resize:
- this.filter('textarea').each(function(){
-
- // Get rid of scrollbars and disable WebKit resizing:
- var textarea = $(this).css({resize:'none','overflow-y':'hidden'}),
-
- // Cache original height, for use later:
- origHeight = textarea.height(),
-
- // Need clone of textarea, hidden off screen:
- clone = (function(){
-
- // Properties which may effect space taken up by chracters:
- var props = ['height','width','lineHeight','textDecoration','letterSpacing'],
- propOb = {};
-
- // Create object of styles to apply:
- $.each(props, function(i, prop){
- propOb[prop] = textarea.css(prop);
- });
-
- // Clone the actual textarea removing unique properties
- // and insert before original textarea:
- return textarea.clone().removeAttr('id').removeAttr('name').css({
- position: 'absolute',
- top: 0,
- left: -9999
- }).css(propOb).attr('tabIndex','-1').insertBefore(textarea);
-
- })(),
- lastScrollTop = null,
- updateSize = function() {
-
- // Prepare the clone:
- clone.height(0).val($(this).val()).scrollTop(10000);
-
- // Find the height of text:
- var scrollTop = Math.max(clone.scrollTop(), origHeight) + settings.extraSpace,
- toChange = $(this).add(clone);
-
- // Don't do anything if scrollTip hasen't changed:
- if (lastScrollTop === scrollTop) { return; }
- lastScrollTop = scrollTop;
-
- // Check for limit:
- if ( scrollTop >= settings.limit ) {
- $(this).css('overflow-y','hidden');
- return;
- }
- // Fire off callback:
- settings.onResize.call(this);
-
- // Either animate or directly apply height:
- settings.animate && textarea.css('display') === 'block' ?
- toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback)
- : toChange.height(scrollTop);
- };
-
- // Bind namespaced handlers to appropriate events:
- textarea
- .unbind('.dynSiz')
- .bind('keyup.dynSiz', updateSize)
- .bind('keydown.dynSiz', updateSize)
- .bind('change.dynSiz', updateSize);
-
- });
-
- // Chain:
- return this;
-
+//textarea自适应高度 纯js写的 有浏览器判断
+/**
+ * 文本框根据输入内容自适应高度
+ * @param {HTMLElement} 输入框元素
+ * @param {Number} 设置光标与输入框保持的距离(默认0)
+ * @param {Number} 设置最大高度(可选)
+ */
+var autoTextarea = function (elem, extra, maxHeight) {
+ extra = extra || 0;
+ var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
+ isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
+ addEvent = function (type, callback) {
+ elem.addEventListener ?
+ elem.addEventListener(type, callback, false) :
+ elem.attachEvent('on' + type, callback);
+ },
+ getStyle = elem.currentStyle ? function (name) {
+ var val = elem.currentStyle[name];
+
+ if (name === 'height' && val.search(/px/i) !== 1) {
+ var rect = elem.getBoundingClientRect();
+ return rect.bottom - rect.top -
+ parseFloat(getStyle('paddingTop')) -
+ parseFloat(getStyle('paddingBottom')) + 'px';
+ };
+
+ return val;
+ } : function (name) {
+ return getComputedStyle(elem, null)[name];
+ },
+ minHeight = parseFloat(getStyle('height'));
+
+
+ elem.style.resize = 'none';
+
+ var change = function () {
+ var scrollTop, height,
+ padding = 0,
+ style = elem.style;
+
+ if (elem._length === elem.value.length) return;
+ elem._length = elem.value.length;
+
+ if (!isFirefox && !isOpera) {
+ padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
+ };
+ scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
+
+ elem.style.height = minHeight + 'px';
+ if (elem.scrollHeight > minHeight) {
+ if (maxHeight && elem.scrollHeight > maxHeight) {
+ height = maxHeight - padding;
+ style.overflowY = 'auto';
+ } else {
+ height = elem.scrollHeight - padding;
+ style.overflowY = 'hidden';
+ };
+ style.height = height + extra + 'px';
+ scrollTop += parseInt(style.height) - elem.currHeight;
+ document.body.scrollTop = scrollTop;
+ document.documentElement.scrollTop = scrollTop;
+ elem.currHeight = parseInt(style.height);
+ };
};
-
-
-})(jQuery);
\ No newline at end of file
+ addEvent('propertychange', change);
+ addEvent('input', change);
+ addEvent('focus', change);
+ change();
+};
\ No newline at end of file