socialforge/public/javascripts/application.js

2391 lines
92 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//= require_directory ./rateable
//= require_directory ./rateable
//= require jquery.min
//= require jquery.infinitescroll
/* Redmine - project management software
Copyright (C) 2006-2013 Jean-Philippe Lang */
//未登录弹框提示
function login_notice_box(url){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="'+ url +'" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">您还没有登录,不能提交作品<br/>请登录</p><div class="cl"></div>'+
'<a href="'+ url +'" class="fr sy_btn_blue mt10 mr10" style="margin-right: 124px;">知道了</a></div></div>';
pop_box_new(htmlvalue, 300, 170);
}
//动态高度控制
function description_show_hide(id){
showNormalImage('activity_description_'+id);
if($("#intro_content_"+id).height() > 810) {
$("#intro_content_show_"+id).show();
}
$("#intro_content_show_"+id).click(function(){
$("#activity_description_"+id).toggleClass("maxh360");
$("#intro_content_show_"+id).hide();
$("#intro_content_hide_"+id).show();
});
$("#intro_content_hide_"+id).click(function(){
$("#activity_description_"+id).toggleClass("maxh360");
$("#intro_content_hide_"+id).hide();
$("#intro_content_show_"+id).show();
});
}
//名片的显示
function user_card_show_hide() {
// $(".homepagePostPortrait").mouseover(function(){
// $(".userCard").css("display","none");
// onImage = true;
// $(this).children(".userCard").css("display","block");
// });
// $(".homepagePostPortrait").mouseout(function(){
// var cur = $(this);
// onImage = false;
// setTimeout(function(){
// if (onUserCard == false && onImage == false){
// $(cur).children(".userCard").css("display", "none");
// }
// }, 500);
// });
// $(".userCard").mouseover(function(){
// onUserCard = true;
// $(this).css("display","block");
// });
// $(".userCard").mouseout(function(){
// onUserCard = false;
// $(this).css("display","none");
// });
}
function cleanArray (actual){
var newArray = new Array();
for (var i = 0; i< actual.length; i++){
if (actual[i]){
newArray.push(actual[i]);
}
}
return newArray;
}
function checkAll(id, checked) {
if (checked) {
$('#'+id).find('input[type=checkbox]').attr('checked', true);
} else {
$('#'+id).find('input[type=checkbox]').removeAttr('checked');
}
}
function toggleCheckboxesBySelector(selector) {
var all_checked = true;
$(selector).each(function(index) {
if (!$(this).is(':checked')) { all_checked = false; }
});
$(selector).attr('checked', !all_checked);
}
function showAndScrollTo(id, focus) {
$('#'+id).show();
if (focus !== null) {
$('#'+focus).focus();
}
$('html, body').animate({scrollTop: $('#'+id).offset().top}, 400);
}
function toggleRowGroup(el) {
var tr = $(el).parents('tr').first();
var n = tr.next();
tr.toggleClass('open');
while (n.length && !n.hasClass('group')) {
n.toggle();
n = n.next('tr');
}
}
function collapseAllRowGroups(el) {
var tbody = $(el).parents('tbody').first();
tbody.children('tr').each(function(index) {
if ($(this).hasClass('group')) {
$(this).removeClass('open');
} else {
$(this).hide();
}
});
}
function expandAllRowGroups(el) {
var tbody = $(el).parents('tbody').first();
tbody.children('tr').each(function(index) {
if ($(this).hasClass('group')) {
$(this).addClass('open');
} else {
$(this).show();
}
});
}
function toggleAllRowGroups(el) {
var tr = $(el).parents('tr').first();
if (tr.hasClass('open')) {
collapseAllRowGroups(el);
} else {
expandAllRowGroups(el);
}
}
function toggleFieldset(el) {
var fieldset = $(el).parents('fieldset').first();
fieldset.toggleClass('collapsed');
fieldset.children('div').toggle();
}
function hideFieldset(el) {
var fieldset = $(el).parents('fieldset').first();
fieldset.toggleClass('collapsed');
fieldset.children('div').hide();
}
function initFilters(){
$('#add_filter_select').change(function(){
addFilter($(this).val(), '', []);
});
$('#filters-table td.field input[type=checkbox]').each(function(){
toggleFilter($(this).val());
});
$('#filters-table td.field input[type=checkbox]').on('click',function(){
toggleFilter($(this).val());
});
$('#filters-table .toggle-multiselect').on('click',function(){
toggleMultiSelect($(this).siblings('select'));
});
$('#filters-table input[type=text]').on('keypress', function(e){
if (e.keyCode == 13) submit_query_form("query_form");
});
}
function addFilter(field, operator, values) {
var fieldId = field.replace('.', '_');
var tr = $('#tr_'+fieldId);
if (tr.length > 0) {
tr.show();
} else {
buildFilterRow(field, operator, values);
}
$('#cb_'+fieldId).attr('checked', true);
toggleFilter(field);
$('#add_filter_select').val('').children('option').each(function(){
if ($(this).attr('value') == field) {
$(this).attr('disabled', true);
}
});
}
function buildFilterRow(field, operator, values) {
var fieldId = field.replace('.', '_');
var filterTable = $("#filters-table");
var filterOptions = availableFilters[field];
var operators = operatorByType[filterOptions['type']];
var filterValues = filterOptions['values'];
var i, select;
var tr = $('<tr class="filter">').attr('id', 'tr_'+fieldId).html(
'<td class="field"><input checked="checked" id="cb_'+fieldId+'" name="f[]" value="'+field+'" type="checkbox"><label for="cb_'+fieldId+'"> '+filterOptions['name']+'</label></td>' +
'<td class="operator"><select id="operators_'+fieldId+'" name="op['+field+']"></td>' +
'<td class="values"></td>'
);
filterTable.append(tr);
select = tr.find('td.operator select');
for (i=0;i<operators.length;i++){
var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]);
if (operators[i] == operator) { option.attr('selected', true); }
select.append(option);
}
select.change(function(){ toggleOperator(field); });
switch (filterOptions['type']){
case "list":
case "list_optional":
case "list_status":
case "list_subprojects":
tr.find('td.values').append(
'<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
' <span class="toggle-multiselect"><a>复选/multi-select</a></span></span>'
);
select = tr.find('td.values select');
if (values.length > 1) { select.attr('multiple', true); }
for (i=0;i<filterValues.length;i++){
var filterValue = filterValues[i];
var option = $('<option>');
if ($.isArray(filterValue)) {
option.val(filterValue[1]).text(filterValue[0]);
if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);}
} else {
option.val(filterValue).text(filterValue);
if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);}
}
select.append(option);
}
break;
case "date":
case "date_past":
tr.find('td.values').append(
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="10" class="value date_value" /></span>' +
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="10" class="value date_value" /></span>' +
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="3" class="value" /> '+labelDayPlural+'</span>'
);
$('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions);
$('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions);
$('#values_'+fieldId).val(values[0]);
break;
case "string":
case "text":
tr.find('td.values').append(
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="30" class="value" /></span>'
);
$('#values_'+fieldId).val(values[0]);
break;
case "relation":
tr.find('td.values').append(
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'" size="6" class="value" /></span>' +
'<span style="display:none;"><select class="value" name="v['+field+'][]" id="values_'+fieldId+'_1"></select></span>'
);
$('#values_'+fieldId).val(values[0]);
select = tr.find('td.values select');
for (i=0;i<allProjects.length;i++){
var filterValue = allProjects[i];
var option = $('<option>');
option.val(filterValue[1]).text(filterValue[0]);
if (values[0] == filterValue[1]) { option.attr('selected', true); }
select.append(option);
}
case "integer":
case "float":
tr.find('td.values').append(
'<span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_1" size="6" class="value" /></span>' +
' <span style="display:none;"><input type="text" name="v['+field+'][]" id="values_'+fieldId+'_2" size="6" class="value" /></span>'
);
$('#values_'+fieldId+'_1').val(values[0]);
$('#values_'+fieldId+'_2').val(values[1]);
break;
}
}
function toggleFilter(field) {
var fieldId = field.replace('.', '_');
if ($('#cb_' + fieldId).is(':checked')) {
$("#operators_" + fieldId).show().removeAttr('disabled');
toggleOperator(field);
} else {
$("#operators_" + fieldId).hide().attr('disabled', true);
enableValues(field, []);
}
}
function enableValues(field, indexes) {
var fieldId = field.replace('.', '_');
$('#tr_'+fieldId+' td.values .value').each(function(index) {
if ($.inArray(index, indexes) >= 0) {
$(this).removeAttr('disabled');
$(this).parents('span').first().show();
} else {
$(this).val('');
$(this).attr('disabled', true);
$(this).parents('span').first().hide();
}
if ($(this).hasClass('group')) {
$(this).addClass('open');
} else {
$(this).show();
}
});
}
function toggleOperator(field) {
var fieldId = field.replace('.', '_');
var operator = $("#operators_" + fieldId);
switch (operator.val()) {
case "!*":
case "*":
case "t":
case "ld":
case "w":
case "lw":
case "l2w":
case "m":
case "lm":
case "y":
case "o":
case "c":
enableValues(field, []);
break;
case "><":
enableValues(field, [0,1]);
break;
case "<t+":
case ">t+":
case "><t+":
case "t+":
case ">t-":
case "<t-":
case "><t-":
case "t-":
enableValues(field, [2]);
break;
case "=p":
case "=!p":
case "!p":
enableValues(field, [1]);
break;
default:
enableValues(field, [0]);
break;
}
}
function toggleMultiSelect(el) {
if (el.attr('multiple')) {
el.removeAttr('multiple');
} else {
el.attr('multiple', true);
}
}
function submit_query_form(id) {
selectAllOptions("selected_columns");
$('#'+id).submit();
}
function showTab(name) {
$('div#content .tab-content').hide();
$('div.tabs a').removeClass('selected');
$('#tab-content-' + name).show();
$('#tab-' + name).addClass('selected');
return false;
}
function moveTabRight(el) {
var lis = $(el).parents('div.tabs').first().find('ul').children();
var tabsWidth = 0;
var i = 0;
lis.each(function(){
if ($(this).is(':visible')) {
tabsWidth += $(this).width() + 6;
}
});
if (tabsWidth < $(el).parents('div.tabs').first().width() - 60) { return; }
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
lis.eq(i).hide();
}
function moveTabLeft(el) {
var lis = $(el).parents('div.tabs').first().find('ul').children();
var i = 0;
while (i<lis.length && !lis.eq(i).is(':visible')) { i++; }
if (i>0) {
lis.eq(i-1).show();
}
}
function displayTabsButtons() {
var lis;
var tabsWidth = 0;
var el;
$('div.tabs').each(function() {
el = $(this);
lis = el.find('ul').children();
lis.each(function(){
if ($(this).is(':visible')) {
tabsWidth += $(this).width() + 6;
}
});
if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) {
el.find('div.tabs-buttons').hide();
} else {
el.find('div.tabs-buttons').show();
}
});
}
function setPredecessorFieldsVisibility() {
var relationType = $('#relation_relation_type');
if (relationType.val() == "precedes" || relationType.val() == "follows") {
$('#predecessor_fields').show();
} else {
$('#predecessor_fields').hide();
}
}
function showModal(id, width) {
var el = $('#'+id).first();
if (el.length === 0 || el.is(':visible')) {return;}
var title = el.find('h3.title').text();
el.dialog({
width: width,
modal: true,
resizable: false,
dialogClass: 'modal',
title: title
});
el.find("input[type=text], input[type=submit]").first().focus();
}
function hideModal(el) {
if($("#popupWrap").length > 0){
$("#popupWrap").remove();
}
else{
var modal;
if (el) {
modal = $(el).parents('.ui-dialog-content');
} else {
modal = $('#ajax-modal');
}
modal.dialog("close");
}
}
function submitPreview(url, form, target) {
$.ajax({
url: url,
type: 'post',
data: $('#'+form).serialize(),
success: function(data){
$('#'+target).html(data);
}
});
}
function collapseScmEntry(id) {
$('.'+id).each(function() {
if ($(this).hasClass('open')) {
collapseScmEntry($(this).attr('id'));
}
$(this).hide();
});
$('#'+id).removeClass('open');
}
function expandScmEntry(id) {
$('.'+id).each(function() {
$(this).show();
if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) {
expandScmEntry($(this).attr('id'));
}
});
$('#'+id).addClass('open');
}
function scmEntryClick(id, url) {
el = $('#'+id);
if (el.hasClass('open')) {
collapseScmEntry(id);
el.addClass('collapsed');
return false;
} else if (el.hasClass('loaded')) {
expandScmEntry(id);
el.removeClass('collapsed');
return false;
}
if (el.hasClass('loading')) {
return false;
}
el.addClass('loading');
$.ajax({
url: url,
success: function(data){
el.after(data);
el.addClass('open').addClass('loaded').removeClass('loading');
}
});
return true;
}
function randomKey(size) {
var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
var key = '';
for (i = 0; i < size; i++) {
key += chars[Math.floor(Math.random() * chars.length)];
}
return key;
}
// Can't use Rails' remote select because we need the form data
function updateIssueFrom(url) {
$.ajax({
url: url,
type: 'post',
data: $('#issue-form').serialize()
});
}
function updateBulkEditFrom(url) {
$.ajax({
url: url,
type: 'post',
data: $('#bulk_edit_form').serialize()
});
}
function clearMessage(id) {
$('#'+id).val("");
}
function observeAutocompleteField(fieldId, url, options) {
$(document).ready(function() {
$('#'+fieldId).autocomplete($.extend({
source: url,
select: function(e,ui){self.location="/issues/"+ui.item.value;},
minLength: 1,
search: function(){$('#'+fieldId).addClass('ajax-loading');},
response: function(){$('#'+fieldId).removeClass('ajax-loading');
}
}, options));
$('#'+fieldId).addClass('autocomplete');
});
}
function observeSearchfield(fieldId, targetId, url) {
$('#'+fieldId).each(function() {
var $this = $(this);
$this.addClass('autocomplete');
$this.attr('data-value-was', $this.val());
var check = function() {
var val = $this.val();
if ($this.attr('data-value-was') != val){
$this.attr('data-value-was', val);
$.ajax({
url: url,
type: 'get',
dataType: 'jsonp',
data: {q: $this.val()},
success: function(data){ if(targetId) $('#'+targetId).html(data); },
beforeSend: function(){ $this.addClass('ajax-loading'); }, // 添加成员加载完成前,显示载入中
complete: function(){ $this.removeClass('ajax-loading'); } // 完成后,移除
});
}
};
var reset = function() {
if (timer) {
clearInterval(timer);
timer = setInterval(check, 300);
}
};
var timer = setInterval(check, 300);
$this.bind('keyup click mousemove', reset);
});
}
function observeProjectModules() {
var f = function() {
/* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */
if ($('#project_enabled_module_names_issue_tracking').attr('checked')) {
$('#project_trackers').show();
}else{
$('#project_trackers').hide();
}
};
$(window).load(f);
$('#project_enabled_module_names_issue_tracking').change(f);
}
function initMyPageSortable(list, url) {
$('#list-'+list).sortable({
connectWith: '.block-receiver',
tolerance: 'pointer',
update: function(){
$.ajax({
url: url,
type: 'post',
data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})}
});
}
});
$("#list-top, #list-left, #list-right").disableSelection();
}
var warnLeavingUnsavedMessage;
function warnLeavingUnsaved(message) {
warnLeavingUnsavedMessage = message;
$('form').submit(function(){
$('textarea').removeData('changed');
});
$('textarea').change(function(){
$(this).data('changed', 'changed');
});
window.onbeforeunload = function(){
// var warn = false;
// $('textarea').blur().each(function(){
// if ($(this).data('changed')) {
// warn = true;
// }
// });
// if (warn) {return warnLeavingUnsavedMessage;}
};
}
function setupHeartBeat(){
var time = 60*1000*30; // 30 mins
setInterval(function(){$.getJSON('/account/heartbeat');},time);
}
function setupAjaxIndicator() {
$('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){
return;
}
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
$('#ajax-indicator').show();
}
});
$('#ajax-indicator').bind('ajaxStop', function() {
$('#ajax-indicator').hide();
if(MathJax && MathJax.Hub)
MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话手动执行MathJax的公式显示
try{
prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化
}catch (e){
}
});
}
function hideOnLoad() {
$('.hol').hide();
}
function addFormObserversForDoubleSubmit() {
$('form[method=post]').each(function() {
if (!$(this).hasClass('multiple-submit')) {
$(this).submit(function(form_submission) {
if ($(form_submission.target).attr('data-submitted')) {
form_submission.preventDefault();
} else {
$(form_submission.target).attr('data-submitted', true);
}
});
}
});
}
function blockEventPropagation(event) {
event.stopPropagation();
event.preventDefault();
}
function toggleAndSettingWordsVal(parent_widget, text_widget, value){
text_widget.val(value)
parent_widget.slideToggle(400)
}
function transpotUrl (scope) {
$(scope).each(function(){
var tmpContent = $(this).html();
tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,]+)/gi,"$1<a href='$2$3' target='_blank'>$2$3<\/a>");
// tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,]+)/gi,"$1<a href='http:\/\/$2' style='color:blue' target='_blank'>$2</a>");
$(this).html(tmpContent);
});
}
$(document).ready(setupAjaxIndicator);
$(document).ready(setupHeartBeat);
$(document).ready(hideOnLoad);
$(document).ready(addFormObserversForDoubleSubmit);
function img_thumbnails() {
$('.thumbnails a').colorbox({rel:'nofollow'});
$('.attachments').find('a').each(function(index, element) {
var href_value = $(element).attr('href');
if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) {
$(element).colorbox({rel:'nofollow'});
}
});
$('.for_img_thumbnails').find('a').each(function(index, element) {
var href_value = $(element).attr('href');
if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) {
$(element).colorbox({rel:'nofollow'});
}
});
}
$(document).ready(img_thumbnails);
function TimeClose(dateText, inst) {
if(inst.id=="issue_start_date"){
time=dateText;
}
}
var time=new Date();
function TimeBeforeShow(input){
if(input.id=="issue_due_date"){
//var minDate = $(input).datepicker('option', 'minDate');
var tempdata=$("#issue_start_date").attr("value");
$(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/")));
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
}
}
function SetMinValue(){
/// var tempdata=$("#issue_start_date").attr("value");
//$('.selector').datepicker('option', 'minDate', '12/25/2012');
//alert(tempdata);
//$("#issue_due_date").datepicker({
// minDate: new Date(2014,08,23)
//var datepickerOptions=
//{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
//alert( $('.issue_due_date').length);
//$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23));
//$("#issue_due_date").datepicker(datepickerOptions);
//$("##{issue_due_date}").datepicker(datepickerOptions);
//$("#issue_due_date").datepicker(
// {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}
//)
//});
}
function PrecentChange(obj){
var _v= obj;
if(_v==100)
{
//var select=$("select[id='issue_status_id']");
$("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected");
}
else if(_v==0)
{
//alert(1);
$("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected");
}
else if(_v!=100&&_v!=0)
{
// alert(2);
$("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected");
}
}
//added by lizanle 日期選擇js
function HS_DateAdd(interval,number,date){
number = parseInt(number);
if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])}
if (typeof(date)=="object"){var date = date}
switch(interval){
case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break;
case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break;
case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break;
case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break;
}
}
function checkDate(year,month,date){
var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"];
var returnDate = "";
if (year%4==0){enddate[1]="29"}
if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date}
return returnDate;
}
function WeekDay(date){
var theDate;
if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);}
if (typeof(date)=="object"){theDate = date}
return theDate.getDay();
}
function HS_calender(){
var lis = "";
var style = "";
/*可以把下面的css剪切出去独立一个css文件*/
style +="<style type='text/css'>";
style +=".calender { width:170px; height:auto; font-size:12px; margin-right:14px; background:url(calenderbg.gif) no-repeat right center #fff; border:1px solid #397EAE; padding:1px}";
style +=".calender ul {list-style-type:none; margin:0; padding:0;}";
style +=".calender .day { background-color:#EDF5FF; height:20px;}";
style +=".calender li { list-style-type: none; float: left; margin: 0 0px; padding: 0 !important; background: #ffffff; background-image: none !important;}";
style +=".calender .day li,.calender .date li{ float:left; width:14%; height:20px; line-height:20px; text-align:center}";
style +=".calender li a { text-decoration:none; font-family:Tahoma; font-size:11px; color:#333}";
style +=".calender li a:hover { color:#f30; text-decoration:underline}";
style +=".calender li a.hasArticle {font-weight:bold; color:#f60 !important}";
style +=".lastMonthDate, .nextMonthDate {color:#bbb;font-size:11px}";
style +=".selectThisYear a, .selectThisMonth a{text-decoration:none; margin:0 2px; color:#000; font-weight:bold}";
style +=".calender .LastMonth, .calender .NextMonth{ text-decoration:none; color:#000; font-size:18px; font-weight:bold; line-height:16px;}";
style +=".calender .LastMonth { float:left;}";
style +=".calender .NextMonth { float:right;}";
style +=".calenderBody {clear:both}";
style +=".calenderTitle {text-align:center;height:20px; line-height:20px; clear:both}";
style +=".today { background-color:#ffffaa;border:1px solid #f60; padding:2px}";
style +=".today a { color:#f30; }";
style +=".calenderBottom {clear:both; border-top:1px solid #ddd; padding: 3px 0; text-align:left}";
style +=".calenderBottom a {text-decoration:none; margin:2px !important; font-weight:bold; color:#000}";
style +=".calenderBottom a.closeCalender{float:right}";
style +=".closeCalenderBox {float:right; border:1px solid #000; background:#fff; font-size:9px; width:11px; height:11px; line-height:11px; text-align:center;overflow:hidden; font-weight:normal !important}";
style +="</style>";
var now;
if (typeof(arguments[0])=="string"){
selectDate = arguments[0].split("-");
var year = selectDate[0];
var month = parseInt(selectDate[1])-1+"";
var date = selectDate[2];
now = new Date(year,month,date);
}else if (typeof(arguments[0])=="object"){
now = arguments[0];
}
var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate();
var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01");
var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01");
var thisMonthEndDate = thisMonthLastDate.getDate();
var thisMonthEndDay = thisMonthLastDate.getDay();
var todayObj = new Date();
today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate();
for (i=0; i<lastMonthDate; i++){ // Last Month's Date
lis = "<li class='lastMonthDate'>"+lastMonthEndDate+"</li>" + lis;
lastMonthEndDate--;
}
for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date
if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){
var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i;
lis += "<li><a href=javascript:void(0) class='today' onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
}else{
lis += "<li><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
}
}
var j=1;
for (i=thisMonthEndDay; i<6; i++){ // Next Month's Date
lis += "<li class='nextMonthDate'>"+j+"</li>";
j++;
}
lis += style;
var CalenderTitle = "<a href='javascript:void(0)' class='NextMonth' onclick=HS_calender(HS_DateAdd('m',1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Next Month'>&raquo;</a>";
CalenderTitle += "<a href='javascript:void(0)' class='LastMonth' onclick=HS_calender(HS_DateAdd('m',-1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Previous Month'>&laquo;</a>";
CalenderTitle += "<span class='selectThisYear'><a href='javascript:void(0)' onclick='CalenderselectYear(this)' title='Click here to select other year' >"+now.getFullYear()+"</a></span>年<span class='selectThisMonth'><a href='javascript:void(0)' onclick='CalenderselectMonth(this)' title='Click here to select other month'>"+(parseInt(now.getMonth())+1).toString()+"</a></span>月";
if (arguments.length>1){
arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis;
arguments[1].parentNode.innerHTML = CalenderTitle;
}else{
var CalenderBox = style+"<div class='calender'><div class='calenderTitle'>"+CalenderTitle+"</div><div class='calenderBody'><ul class='day'><li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li></ul><ul class='date' id='thisMonthDate'>"+lis+"</ul></div><div class='calenderBottom'><a href='javascript:void(0)' class='closeCalender' onclick='closeCalender(this)'>&times;</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+todayString+"'>Today</a></span></span></div></div>";
return CalenderBox;
}
}
function _selectThisDay(d){
var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode;
boxObj.targetObj.value = d.title;
boxObj.parentNode.removeChild(boxObj);
}
function closeCalender(d){
var boxObj = d.parentNode.parentNode.parentNode;
boxObj.parentNode.removeChild(boxObj);
}
function CalenderselectYear(obj){
var opt = "";
var thisYear = obj.innerHTML;
for (i=1970; i<=2020; i++){
if (i==thisYear){
opt += "<option value="+i+" selected>"+i+"</option>";
}else{
opt += "<option value="+i+">"+i+"</option>";
}
}
opt = "<select onblur='selectThisYear(this)' onchange='selectThisYear(this)' style='font-size:11px'>"+opt+"</select>";
obj.parentNode.innerHTML = opt;
}
function selectThisYear(obj){
HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode);
}
function CalenderselectMonth(obj){
var opt = "";
var thisMonth = obj.innerHTML;
for (i=1; i<=12; i++){
if (i==thisMonth){
opt += "<option value="+i+" selected>"+i+"</option>";
}else{
opt += "<option value="+i+">"+i+"</option>";
}
}
opt = "<select onblur='selectThisMonth(this)' onchange='selectThisMonth(this)' style='font-size:11px'>"+opt+"</select>";
obj.parentNode.innerHTML = opt;
}
function selectThisMonth(obj){
HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode);
}
function HS_setDate(inputObj){
var calenderObj = document.createElement("span");
calenderObj.innerHTML = HS_calender(new Date());
calenderObj.style.position = "absolute";
calenderObj.targetObj = inputObj;
inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling);
}
//lizanle 刷新函数
function redo() {
window.location.reload()
}
function encodeHomeworkUrl(url, is_base64){
if(typeof is_base64 === 'boolean' && is_base64){
return '/zipdown/download?base64file='+url;
}
var file = encodeURI(url).replace(/\+/g, '%2B');
return '/zipdown/download?file='+file;
}
//// 作业附件删除
$(function(){
$('.attachments a.delete-homework-icon').bind('ajax:complete', //this will work
function(event, data, status, xhr) { //note parametes
$(this).parent('p').remove();
console.log("delete complete.");
});
$('a.tb_all').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){
var res = JSON.parse(data.responseText);
if(res.err == -1){
var htmlvalue = '<div id="muban_popup_box" style="width:390px;"><div class="muban_popup_top"><h3 class="fl">温馨提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15 mr10 ml10"><p class="text_c f14">因附件资料超过500M您可以每个附件依次下载</br>或者请通过微信或者QQ联系Trustie管理员辅助您打包下载</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10" style="margin-right: 155px;" onclick="hideModal();">确&nbsp;&nbsp;定</a></div></div>';
pop_box_new(htmlvalue,390,166);
return;
}
if (res.err == -2) {
alert("该作业没有任何附件可下载");
return;
}
if(res.length < 1 ){
alert("该作业没有任何附件可下载");
return;
}
if(res.length==1){
if(res[0].base64file){
location.href = encodeHomeworkUrl(res[0].base64file, true);return;
}
location.href = encodeHomeworkUrl(res[0].file);return;
}
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
}
if(res[i].base64file){
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].base64file, true) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
} else {
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].file) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
}
}
}
});
$('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) {
if(status == 'success'){
var res = JSON.parse(data.responseText);
if(res.err == -1){
var htmlvalue = '<div id="muban_popup_box" style="width:390px;"><div class="muban_popup_top"><h3 class="fl">温馨提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15 mr10 ml10"><p class="text_c f14">因附件资料超过500M您可以每个附件依次下载</br>或者请通过微信或者QQ联系Trustie管理员辅助您打包下载</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10" style="margin-right: 155px;" onclick="hideModal();">确&nbsp;&nbsp;定</a></div></div>';
pop_box_new(htmlvalue,390,166);
return;
}
if (res.err == -2) {
alert("该作业没有任何附件可下载");
return;
}
if(res.length < 1 ){
alert("该作业没有任何附件可下载");
return;
}
else
{
if(res.length==1){
if(res[0].base64file){
location.href = encodeHomeworkUrl(res[0].base64file, true);return;
}
location.href = encodeHomeworkUrl(res[0].file);return;
}
document.getElementById('light').style.display='block';
$container = $('#light .upload_box_ul');
$container.empty();
for(var i = 0; i <res.length; ++i){
var des = '';
if(res.count > 1){
des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载';
} else {
des = '第'+res[i].index+'个学生的作品下载';
}
if(res[i].base64file){
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].base64file, true) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
} else {
$('<li><span class="upload_box_span" >'+(i+1)+'.</span> <a href="'+ encodeHomeworkUrl(res[i].file) +'">'+des+'</a><span class="c_grey">&nbsp;&nbsp;(共'+res[i].size+'M</span> </li>').appendTo($container);
}
}
}
}
});
});
//firefox的pre标签换行
$(document).ready(function () {
var userAgent = navigator.userAgent.toLowerCase();
var browser = {
version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1],
safari: /webkit/.test(userAgent),
opera: /opera/.test(userAgent),
msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};
if (browser.mozilla || browser.opera){
$("pre").addClass("break_word_firefox");
}
else{
$("pre").addClass("break_word");
}
});
//点击发送资源弹出框中的组织,要更改选择栏目中的内容
//@dom 选中的radio值为org_id
function change_org_subfield(url){
$.ajax({
type:'get',
url:url
})
}
//点击图片即显示大图
function showNormalImage(id) {
var description_images=$('div#'+id).find("img");
if (description_images.length>0) {
for (var i=0; i<description_images.length; i++){
var image=$(description_images[i]);
var _path = getRootPath();
//如果图片是视频图片,不处理。
if($(image).hasClass("mediaIco")){
var _src = _path+"/"+$(image).attr('src');
$(image).attr('src',_src);
return;
}
//已被加链接则不处理
if ($(image).parent() && $(image).parent().attr('href')){
return;
}
//无格式的图片不让点击显示大图,显示的话会有问题
var tmpsrc = image.attr('src');
if(tmpsrc){
if (tmpsrc.indexOf('.gif') >= 0 || tmpsrc.indexOf('.jpg') >= 0 || tmpsrc.indexOf('.jpeg') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.bmp') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.BMP') >= 0 || tmpsrc.indexOf('.JPEG') >= 0 || tmpsrc.indexOf('.JPG') >= 0 || tmpsrc.indexOf('.PNG') >= 0 || tmpsrc.indexOf('.GIF') >= 0) {
var element = $("<a></a>").attr("href", image.attr('src'));
image.wrap(element);
$(image).parent().colorbox({rel: 'nofollow', close: "关闭", returnFocus: false});
}
}
}
//$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框
}
}
//文件、帖子、通知分享
function org_id_click(){
var sendText = $("input[name='org_id']:checked").next().text();
var orgDirection = "目标地址:";
$(".orgDirection").text(orgDirection + sendText);
}
function subfield_click(){
var sendText = $("input[name='org_id']:checked").next().text();
var orgDirection = "目标地址:";
var sendColumn = $("input[name='subfield']:checked").next().text();
$(".orgDirection").text(orgDirection + sendText + " / " + sendColumn);
}
//send_type:发送的类型file对应文件message对应帖子news对应通知或新闻
function observeSearchfieldOnInput(fieldId, url,send_id,send_ids, send_type) {
$('#'+fieldId).each(function() {
var $this = $(this);
$this.addClass('autocomplete');
$this.attr('data-value-was', $this.val());
var check = function() {
var val = $this.val();
if ($this.attr('data-value-was') != val){
$this.attr('data-value-was', val);
$.ajax({
url: url,
type: 'get',
data: {search: $this.val(),send_id:send_id,send_ids:send_ids, send_type:send_type, is_observe:true},
success: function(data){ },
beforeSend: function(){ $this.addClass('ajax-loading'); },
complete: function(){ $this.removeClass('ajax-loading'); }
});
}
};
var reset = function() {
if (timer) {
clearInterval(timer);
timer = setInterval(check, 500);
}
};
var timer = setInterval(check, 500);
$this.bind('keyup click mousemove', reset);
});
}
function check_des(event){
if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址组织不能为空');
return false;
}else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){
event.preventDefault();
$(".orgDirection").text('目标地址栏目不能为空');
return false;
}else{
return true;
}
}
var sendType = '1';
var lastSendType ;//初始为发送到我的课程
function show_send(id, user_id, send_type){
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project',
data:{send_id:id, send_type:send_type}
});
}else if(lastSendType == '1'){
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_course',
data:{send_id:id, send_type:send_type}
});
}else if( lastSendType == '3'){//组织
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_org',
data:{send_id:id, send_type:send_type}
});
}else{
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_course',
data:{send_id:id, send_type:send_type}
});
}
}
//为了隐藏非项目功能
//var sendType = '1';
var lastSendType ;//初始为发送到我的项目
function show_send_hidden(id, user_id, send_type){
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project',
data:{send_id:id, send_type:send_type}
});
}else if( lastSendType == '2'){//组织
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_org',
data:{send_id:id, send_type:send_type}
});
}else{
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project',
data:{send_id:id, send_type:send_type}
});
}
}
//id 发送的id
//发送的id数组
//send_type:发送的类型file对应文件message对应帖子news对应通知或新闻
function chooseSendType(res_id,res_ids, user_id, send_type){
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if(lastSendType != null) { //不是第一次点击的时候
if (sendType == '1') {
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_course',
data:{send_id:res_id, send_type:send_type}
});
} else if(sendType == '2') {
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project',
data:{send_id:res_id, send_type:send_type}
});
}else if(sendType == '3'){
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_org',
data:{send_id:res_id, send_type:send_type}
});
}
}
lastSendType = sendType;
}
function chooseSendType2(res_id,res_ids, user_id, send_type, type){
console.log(res_ids);
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if(lastSendType != null) { //不是第一次点击的时候
if (sendType == '1') {
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_course' + '?' + "&type=" + type,
data:{send_id:res_id, send_ids:res_ids ,send_type:send_type}
});
} else if(sendType == '2') {
console.log(res_ids);
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project' + '?' + "&type=" + type,
data:{send_id:res_id, send_ids:res_ids, send_type:send_type}
});
}else if(sendType == '3'){
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_org' + '?' + "&type=" + type,
data:{send_id:res_id, send_ids:res_ids, send_type:send_type}
});
}
}
lastSendType = sendType;
}
//隐藏项目其它信息特用
function chooseSendType2hidden(res_id,res_ids, user_id, send_type, type){
console.log(res_ids);
sendType = $(".resourcesSendType").val();
if (sendType === lastSendType) {
return;
} else if(lastSendType != null) { //不是第一次点击的时候
if (sendType == '1') {
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_project' + '?' + "&type=" + type,
data:{send_id:res_id, send_ids:res_ids ,send_type:send_type}
});
}else if(sendType == '2'){
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_org' + '?' + "&type=" + type,
data:{send_id:res_id, send_ids:res_ids, send_type:send_type}
});
}
}
lastSendType = sendType;
}
//组织新建和配置中选择组织为私有后disbled掉允许游客下载选项
function disable_down(source, des, hint){
if (source.attr("checked")){
des.attr("disabled", false);
hint.html("");
}
else{
des.attr("checked", false);
des.attr("disabled", true);
hint.html("(私有组织不允许游客下载资源)");
}
}
function getRootPath(){
//获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
var curWwwPath=window.document.location.href;
//获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
var pathName=window.document.location.pathname;
var pos=curWwwPath.indexOf(pathName);
//获取主机地址,如: http://localhost:8083
var localhostPaht=curWwwPath.substring(0,pos);
//获取带"/"的项目名,如:/uimcardprj
// var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
var projectName="";
return(localhostPaht+projectName);
}
//自动保存草稿
var editor2;
function elocalStorage(editor,mdu,id){
if (window.sessionStorage){
editor2 = editor;
var oc = window.sessionStorage.getItem('content'+mdu);
if(oc !== null ){
if(arguments[2]){
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" onclick="rec_data(\'content\',\''+ mdu + '\',' + id + ')">恢复</a> ? / <a style="cursor: pointer;" onclick="clear_data(\'content\',\''+ mdu + '\',' + id + ')">不恢复</a>';
$("#e_tips_"+id).html(h);
}else{
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" onclick="rec_data(\'content\',\''+ mdu + '\')">恢复</a> ? / <a style="cursor: pointer;" onclick="clear_data(\'content\',\''+ mdu + '\')">不恢复</a>';
$("#e_tips").html(h);
}
}
setInterval(function() {
d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
h = h < 10 ? '0' + h : h;
m = m < 10 ? '0' + m : m;
s = s < 10 ? '0' + s : s;
editor.sync();
if(!editor.isEmpty()){
add_data("content",mdu,editor.html());
var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip";
var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips";
$(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 ");
$(id2).html("");
}
},10000);
}else{
$('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!');
}
}
function add_data(k,mdu,d){
window.sessionStorage.setItem(k+mdu,d);
}
function rec_data(k,mdu,id){
if(window.sessionStorage.getItem(k+mdu) !== null){
editor2.html(window.sessionStorage.getItem(k+mdu));
clear_data(k,mdu,id);
}
}
function clear_data(k,mdu,id){
window.sessionStorage.removeItem(k+mdu);
var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip";
var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips";
if(k == 'content'){
$(id2).html("");
}else{
$(id1).html("");
}
}
function expand_reply(container,btnid){
var target = $(container).children();
var btn = $(btnid);
if(btn.data('init')=='0'){
btn.data('init',1);
btn.html('收起回复');
target.show();
}else{
btn.data('init',0);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
}
function expand_all_reply(container, btnid, id, type, div_id) {
var target = $(container);
var btn = $(btnid);
if (btn.data('init') == '0') {
btn.data('init', 1);
$.get(
'/users/all_journals',
{
type: type,
id: id,
div_id: div_id
},
function(data) {
}
);
btn.html('收起回复');
//target.show();
} else if(btn.data('init') == '1') {
btn.data('init', 3);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
else {
btn.data('init', 1);
btn.html('收起回复');
target.show();
}
}
function expand_reply_homework(container, btnid, id, type, div_id, user_activity_id) {
var target = $(container);
var btn = $(btnid);
if (btn.data('init') == '0') {
btn.data('init', 1);
$.get(
'/users/all_journals',
{
type: type,
id: id,
div_id: div_id,
user_activity_id: user_activity_id
},
function(data) {
}
);
btn.html('收起回复');
//target.show();
} else if(btn.data('init') == '1') {
btn.data('init', 3);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
else {
btn.data('init', 1);
btn.html('收起回复');
target.show();
}
}
//by yk 列表描述将文字和起来去掉空格多于100就显示省略号
function description_showwords_ellipsis(id,num){
var str = "";
$("#intro_content_"+id).each(function () {
str = str + $(this).text();
});
//去掉空格
str = str.replace(/[\f\n\r\t\v]/gi,'');
if(str.length > num){
str = str.substring(0,num)+"...";
}
$("#intro_content_"+id).html(str);
$("#intro_content_"+id).show();
}
//by yk 弹框 valuehtml代码或跳转其他页面代码 tWidth = 580 tTop=30 tLeft=50
function pop_up_box(value,tWidth,tTop,tLeft){
if(!tWidth){
var tWidth = 580;
}
if(!tTop){
var tTop = 30;
}
if(!tLeft){
var tLeft = 50;
}
$("#ajax-modal").html(value);
showModal('ajax-modal', tWidth + "px");
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-right: 5px; margin-top:-10px;right:0;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
function hideModal(){
$('#ajax-modal').hide();
}
}
// 公共弹框样式
// 建议左右栏的Width460Height190
// 建议宽屏对应值Width760Height500
function pop_box_new(value, Width, Height){
w = ($(window).width() - Width)/2;
h = ($(window).height() - Height)/2;
var container =$('<div></div>');
container.attr('id','popupWrap');
$(document.body).append(container);
$("#popupWrap").html(value);
$("#popupWrap").show();
$('#popupWrap').css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed","z-index":"99999","background-color":"#fff","box-shadow": "0px 2px 8px rgba(146, 153, 169, 0.5)"});
$('#popupWrap').find("a[class*='close']").click(function(){
$("#popupWrap").hide();
});
// w = ($(window).width() - Width)/2;
// h = ($(window).height() - Height)/2;
// $("#ajax-modal").html(value);
// showModal('ajax-modal', Width + 'px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').parent().css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed"});
// $('#ajax-modal').parent().removeClass("resourceUploadPopup popbox_polls popbox");
// $('#ajax-modal').css({"padding":"0","overflow":"hidden"});
// $('#ajax-modal').parent().attr("id","popupWrap");
//拖拽
function Drag(id) {
this.div = document.getElementById(id);
if (this.div) {
this.div.style.cursor = "move";
this.div.style.position = "fixed";
}
this.disX = 0;
this.disY = 0;
var _this = this;
this.div.onmousedown = function (evt) {
_this.getDistance(evt);
document.onmousemove = function (evt) {
_this.setPosition(evt);
};
_this.div.onmouseup = function () {
_this.clearEvent();
}
}
}
Drag.prototype.getDistance = function (evt) {
var oEvent = evt || event;
this.disX = oEvent.clientX - this.div.offsetLeft;
this.disY = oEvent.clientY - this.div.offsetTop;
};
Drag.prototype.setPosition = function (evt) {
var oEvent = evt || event;
var l = oEvent.clientX - this.disX;
var t = oEvent.clientY - this.disY;
if (l <= 0) {
l = 0;
}
else if (l >= document.documentElement.clientWidth - this.div.offsetWidth) {
l = document.documentElement.clientWidth - this.div.offsetWidth;
}
if (t <= 0) {
t = 0;
}
else if (t >= document.documentElement.clientHeight - this.div.offsetHeight) {
t = document.documentElement.clientHeight - this.div.offsetHeight;
}
this.div.style.left = l + "px";
this.div.style.top = t + "px";
};
Drag.prototype.clearEvent = function () {
this.div.onmouseup = null;
document.onmousemove = null;
};
new Drag("popupWrap");
$("#popupWrap input, #popupWrap textarea, #popupWrap ul, #popupWrap a").mousedown(function(event){
event.stopPropagation();
new Drag("popupWrap");
});
}
function close_modal(){
$("#popupWrap").hide();
}
// 公共提示弹框样式
//function pop_box_tip_new(value, Width, Top, Left){
// $("#ajax-modal").html(value);
// showModal('ajax-modal', Width + 'px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"});
// $('#ajax-modal').css({"padding":"0"});
//}
//显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框
function autoMedia(id){
var rootPath = getRootPath();
function _mediaType(src) {
if (/\.(rm|rmvb)(\?|$)/i.test(src)) {
return 'audio/x-pn-realaudio-plugin';
}
if (/\.(swf|flv)(\?|$)/i.test(src)) {
return 'application/x-shockwave-flash';
}
return 'video/x-ms-asf-plugin';
}
if (rootPath.indexOf("https") < 0){
$("#"+id+" img").each(function(){
if ($(this).attr("class") == "mediaIco"){
var href = $(this).parent().attr("href");
//正则取地址
if (href){
var url = href.split("open('")[1].split("',")[0];
if (url != ""){
var type = _mediaType(url);
//1.video/x-ms-asf-plugin 类型的视频播放不了,2.audio/x-pn-realaudio-plugin没试过3.application/x-shockwave-flash可以播放
if (type != "video/x-ms-asf-plugin"){
var width = 550;
var height = 400;
var html = '<embed src="'+url+'" allowFullScreen="true" quality="high" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="always" type="'+type+'"></embed>';
$(this).parent().replaceWith(html);
}
}
}
}
});
}
}
//yk 自动识别URL 并加上链接
function autoUrl(id){
if ($("#"+id).children().length > 0 ){
$("#"+id+" p,#"+ id +" span,#"+id+" em,#"+id+" h1,#"+id+" h2,#"+id+" h3,#"+id+" h4,#"+id+" strong,#"+id+" b,#"+id+" font,#"+id+" i").each(function(){
if ($(this).children().length == 0){
var html = $(this).text();
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|cn)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[A-Za-z0-9_\-\.~]+)*(\?[A-Za-z0-9+_\-\.%=&]*)?(\/([A-Za-z0-9_\-\.]*)(\?[A-Za-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http://
var reStr = full;
if (full.length > 0){
if (full.indexOf("://") >= 0){
reStr = "<a style='color:#136ec2' target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
}
else{
reStr = "<a style='color:#136ec2' target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
}
}
return reStr ;
});
try{
$(this).html(html);
}
catch (e)
{
console.log(e.name + ": " + e.message);
}
}
});
}
else{
var html = $("#"+id).text();
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|cn)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[A-Za-z0-9_\-\.~]+)*(\?[A-Za-z0-9+_\-\.%=&]*)?(\/([A-Za-z0-9_\-\.]*)(\?[A-Za-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http://
var reStr = full;
if (full.length > 0){
if (full.indexOf("://") >= 0){
reStr = "<a style='color:#136ec2' target='_Blank' href="+"'"+full+"'"+">"+full+"</a>";
}
else{
reStr = "<a style='color:#136ec2' target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
}
}
return reStr ;
});
try{
$("#"+id).html(html);
}
catch (e)
{
console.log(e.name + ": " + e.message);
}
}
if(!(!!window.ActiveXObject || "ActiveXObject" in window)){
autoMedia(id);
}
}
//编辑资源描述
function show_edit_file_description(id) {
$("#file_description_show_"+id).hide();
$("#file_description_edit_"+id).show();
$("#file_description_edit_"+id).focus();
}
//编辑资源描述之后提交
function edit_file_description(url,id){
$.get(
url,
{id: id ,description: $("#file_description_edit_"+id).val() },
function (data) {
}
);
}
//展开课程大纲列表中的班级
function expand_course_list(id, target, btnid, count) {
var target = $(target);
var btn = $(btnid);
if(btn.data('init')=='0'){
btn.data('init',1);
btn.html('点击收起');
target.show();
}else{
btn.data('init',0);
btn.html('共'+count+ '个班级,点击全部展开');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
btn.parent().show();
}
}
//点击删除时的确认弹框: 不走destroy方法
function delete_confirm_box(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
//点击删除时的确认弹框: 走destroy方法,remote为true
function delete_confirm_box_2(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-method="delete" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
//点击删除时的确认弹框: 走destroy方法
function delete_confirm_box_3(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-method="delete">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
//提示框:只有一个按钮,点击关闭弹框
function notice_sure_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:350px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 124px;">知道了</a></div></div>';
pop_box_new(htmlvalue, 350, 140);
}
//提示框:只有一个确定按钮,点击关闭弹框
function notice_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 124px;">确定</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
// 长提示框:只有一个确定按钮,点击关闭弹框
function long_notice_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:450px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15 pl10 pr10"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 189px;">确定</a></div></div>';
pop_box_new(htmlvalue, 450, 140);
}
//提示框:只有一个确定按钮,点击跳转
function notice_box_redirect(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="'+ url +'" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
'<a href="'+ url +'" class="fr sy_btn_blue mt10 mr10" style="margin-right: 174px;">确定</a></div></div>';
pop_box_new(htmlvalue, 400, 140);
}
//删除组织成员
function ifDeleteOrgMember(id,name){
var htmlvalue = "</br><div style='width:550px;text-align:center'>您确定要删除"+name+"吗?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='deleteOrgMember("+id+")'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>" +
"<script>function deleteOrgMember(id){" +
"$.ajax({\n\
url: '/org_member/deleteOrgMember',\n\
type: 'get',\n\
dataType: 'jsonp',\n\
data: {id:id},\n\
success: function(data){},\n\
});\n\
hideModal();}</script>";
pop_up_box(htmlvalue,580,30,50);
}
//省市下拉框
function showcity(province, cityField) {
switch (province) {
case "北京" :
var cityOptions = new Array(
"东城", "西城", "朝阳", "丰台", "石景山", "海淀", "门头沟",
"房山", "通州", "顺义", "昌平", "大兴", "平谷", "怀柔", "密云", "延庆");
break;
case "上海" :
var cityOptions = new Array(
"崇明", "黄浦", "卢湾", "徐汇", "长宁", "静安", "普陀", "闸北", "虹口", "杨浦", "闵行",
"宝山", "嘉定", "浦东", "金山", "松江", "青浦", "南汇", "奉贤");
break;
case "广东" :
var cityOptions = new Array(
"广州", "深圳", "珠海", "东莞", "中山", "佛山", "惠州", "河源", "潮州", "江门", "揭阳", "茂名",
"梅州", "清远", "汕头", "汕尾", "韶关", "顺德", "阳江", "云浮", "湛江", "肇庆");
break;
case "江苏" :
var cityOptions = new Array(
"南京", "常熟", "常州", "海门", "淮安", "江都", "江阴", "昆山", "连云港", "南通",
"启东", "沭阳", "宿迁", "苏州", "太仓", "泰州", "同里", "无锡", "徐州", "盐城",
"扬州", "宜兴", "仪征", "张家港", "镇江", "周庄");
break;
case "重庆" :
var cityOptions = new Array(
"万州", "涪陵", "渝中", "大渡口", "江北", "沙坪坝", "九龙坡", "南岸", "北碚", "万盛",
"双挢", "渝北", "巴南", "黔江", "长寿", "綦江", "潼南", "铜梁", "大足", "荣昌", "壁山",
"梁平", "城口", "丰都", "垫江", "武隆", "忠县", "开县", "云阳", "奉节", "巫山", "巫溪",
"石柱", "秀山", "酉阳", "彭水", "江津", "合川", "永川", "南川");
break;
case "安徽" :
var cityOptions = new Array(
"合肥", "安庆", "蚌埠", "亳州", "巢湖", "滁州", "阜阳", "贵池", "淮北", "淮化", "淮南",
"黄山", "九华山", "六安", "马鞍山", "宿州", "铜陵", "屯溪", "芜湖", "宣城");
break;
case "福建" :
var cityOptions = new Array(
"福州", "厦门", "泉州", "漳州", "龙岩", "南平", "宁德", "莆田", "三明");
break;
case "甘肃" :
var cityOptions = new Array(
"兰州", "白银", "定西", "敦煌", "甘南", "金昌", "酒泉", "临夏", "平凉", "天水",
"武都", "武威", "西峰", "张掖");
break;
case "广西" :
var cityOptions = new Array(
"南宁", "百色", "北海", "桂林", "防城港", "贵港", "河池", "贺州", "柳州", "钦州", "梧州", "玉林");
break;
case "贵州" :
var cityOptions = new Array(
"贵阳", "安顺", "毕节", "都匀", "凯里", "六盘水", "铜仁", "兴义", "玉屏", "遵义");
break;
case "海南" :
var cityOptions = new Array(
"海口", "儋县", "陵水", "琼海", "三亚", "通什", "万宁");
break;
case "河北" :
var cityOptions = new Array(
"石家庄", "保定", "北戴河", "沧州", "承德", "丰润", "邯郸", "衡水", "廊坊", "南戴河", "秦皇岛",
"唐山", "新城", "邢台", "张家口");
break;
case "黑龙江" :
var cityOptions = new Array(
"哈尔滨", "北安", "大庆", "大兴安岭", "鹤岗", "黑河", "佳木斯", "鸡西", "牡丹江", "齐齐哈尔",
"七台河", "双鸭山", "绥化", "伊春");
break;
case "河南" :
var cityOptions = new Array(
"郑州", "安阳", "鹤壁", "潢川", "焦作", "济源", "开封", "漯河", "洛阳", "南阳", "平顶山",
"濮阳", "三门峡", "商丘", "新乡", "信阳", "许昌", "周口", "驻马店");
break;
case "香港" :
var cityOptions = new Array(
"香港", "九龙", "新界");
break;
case "湖北" :
var cityOptions = new Array(
"武汉", "恩施", "鄂州", "黄冈", "黄石", "荆门", "荆州", "潜江", "十堰", "随州", "武穴",
"仙桃", "咸宁", "襄阳", "襄樊", "孝感", "宜昌");
break;
case "湖南" :
var cityOptions = new Array(
"长沙", "常德", "郴州", "衡阳", "怀化", "吉首", "娄底", "邵阳", "湘潭", "益阳", "岳阳",
"永州", "张家界", "株洲");
break;
case "江西" :
var cityOptions = new Array(
"南昌", "抚州", "赣州", "吉安", "景德镇", "井冈山", "九江", "庐山", "萍乡",
"上饶", "新余", "宜春", "鹰潭");
break;
case "吉林" :
var cityOptions = new Array(
"长春", "吉林", "白城", "白山", "珲春", "辽源", "梅河", "四平", "松原", "通化", "延吉");
break;
case "辽宁" :
var cityOptions = new Array(
"沈阳", "鞍山", "本溪", "朝阳", "大连", "丹东", "抚顺", "阜新", "葫芦岛", "锦州",
"辽阳", "盘锦", "铁岭", "营口");
break;
case "澳门" :
var cityOptions = new Array("澳门");
break;
case "内蒙古" :
var cityOptions = new Array(
"呼和浩特", "阿拉善盟", "包头", "赤峰", "东胜", "海拉尔", "集宁", "临河", "通辽", "乌海",
"乌兰浩特", "锡林浩特");
break;
case "宁夏" :
var cityOptions = new Array(
"银川", "固源", "石嘴山", "吴忠");
break;
case "青海" :
var cityOptions = new Array(
"西宁", "德令哈", "格尔木", "共和", "海东", "海晏", "玛沁", "同仁", "玉树");
break;
case "山东" :
var cityOptions = new Array(
"济南", "滨州", "兖州", "德州", "东营", "菏泽", "济宁", "莱芜", "聊城", "临沂",
"蓬莱", "青岛", "曲阜", "日照", "泰安", "潍坊", "威海", "烟台", "枣庄", "淄博");
break;
case "山西" :
var cityOptions = new Array(
"太原", "长治", "大同", "候马", "晋城", "离石", "临汾", "宁武", "朔州", "忻州",
"阳泉", "榆次", "运城");
break;
case "陕西" :
var cityOptions = new Array(
"西安", "安康", "宝鸡", "汉中", "渭南", "商州", "绥德", "铜川", "咸阳", "延安", "榆林");
break;
case "四川" :
var cityOptions = new Array(
"成都", "巴中", "达川", "德阳", "都江堰", "峨眉山", "涪陵", "广安", "广元", "九寨沟",
"康定", "乐山", "泸州", "马尔康", "绵阳", "眉山", "南充", "内江", "攀枝花", "遂宁",
"汶川", "西昌", "雅安", "宜宾", "自贡", "资阳");
break;
case "台湾" :
var cityOptions = new Array(
"台北", "基隆", "台南", "台中", "高雄", "屏东", "南投", "云林", "新竹", "彰化", "苗栗",
"嘉义", "花莲", "桃园", "宜兰", "台东", "金门", "马祖", "澎湖");
break;
case "天津" :
var cityOptions = new Array(
"天津", "和平", "东丽", "河东", "西青", "河西", "津南", "南开", "北辰", "河北", "武清", "红挢",
"塘沽", "汉沽", "大港", "宁河", "静海", "宝坻", "蓟县");
break;
case "新疆" :
var cityOptions = new Array(
"乌鲁木齐", "阿克苏", "阿勒泰", "阿图什", "博乐", "昌吉", "东山", "哈密", "和田", "喀什",
"克拉玛依", "库车", "库尔勒", "奎屯", "石河子", "塔城", "吐鲁番", "伊宁");
break;
case "西藏" :
var cityOptions = new Array(
"拉萨", "阿里", "昌都", "林芝", "那曲", "日喀则", "山南");
break;
case "云南" :
var cityOptions = new Array(
"昆明", "大理", "保山", "楚雄", "大理", "东川", "个旧", "景洪", "开远", "临沧", "丽江",
"六库", "潞西", "曲靖", "思茅", "文山", "西双版纳", "玉溪", "中甸", "昭通");
break;
case "浙江" :
var cityOptions = new Array(
"杭州", "安吉", "慈溪", "定海", "奉化", "海盐", "黄岩", "湖州", "嘉兴", "金华", "临安",
"临海", "丽水", "宁波", "瓯海", "平湖", "千岛湖", "衢州", "江山", "瑞安", "绍兴", "嵊州",
"台州", "温岭", "温州", "余姚", "舟山");
break;
case "海外" :
var cityOptions = new Array(
"美国", "日本", "英国", "法国", "德国", "其他");
break;
default:
var cityOptions = new Array("");
break;
}
cityField.options.length = 0;
for (var i = 0; i < cityOptions.length; i++) {
cityField.options[i] = new Option(cityOptions[i], cityOptions[i]);
/*
if (cityField.options[i].value==city)
{
//alert("here put City ok!");
document.oblogform["city"].selectedIndex = i;
}*/
}
}
function regex_syllabus_name() {
var name = $.trim($("#new_syllabus_name").val());
if(name.length < 2)
{
$("#new_syllabus_name_notice").show();
return false;
}
else
{
$("#new_syllabus_name_notice").hide();
return true;
}
}
function alert_new_syllabus(course_id, flag){
htmlvalue = "<div><h2 style='text-align: center'>新建课程</h2><ul>" +
"<li class='ml45'>" +
"<label><span class='c_red'>*</span>&nbsp;课程名称&nbsp;&nbsp;</label>" +
"<input type='text' name='title' id='new_syllabus_name' class='name_input' placeholder='例如:设计管理' maxlength='100' onkeyup='regex_syllabus_name();'><br>" +
"<span class='c_red' id='new_syllabus_name_notice' style='display: none; font-size: 12px;'>课程名称不能为空且至少有两个字符</span>" +
"</li>" +
"<div class='cl'></div>" +
"<li class='ml45'>" +
"<label><span class='c_white'>*</span>&nbsp;英文名称&nbsp;&nbsp;</label>" +
"<input type='text' name='eng_name' id='new_syllabus_eng_name' placeholder='例如Management of design' class='name_input' maxlength='100'>" +
"</li>" +
"<div class='cl'></div>" +
"<li class='ml90' >" +
"<a href='javascript:void(0)' style='margin-left: 145px;' class='Blue-btn fl' onclick='admin_new_syllabus("+course_id+","+flag+");' >提交</a>" +
"<a href='javascript:void(0)' style='margin-left: 50px;' class='Blue-btn fl' onclick='hideModal();' >取消</a>" +
"<div class='cl'></div>" +
"</li>" +
"</ul></div>";
pop_up_box(htmlvalue,600,30,50);
}
function admin_new_syllabus(course_id, flag){
if(regex_syllabus_name()) {
$.ajax({
type: "post",
url: "/admin/create_syllabus",
data: {course_id: course_id,
title: $("#new_syllabus_name").val(),
eng_name: $("#new_syllabus_eng_name").val(),
flag: flag},
success: function (data) {
}
});
hideModal();
}
}
//执行修改courseName方法
function updateCourseName(){
if(isdb){
isdb = false;
if($("#renameCourseName").val() == tagName){ //如果值一样,则恢复原来的状态
ele.parent().css("border","");
ele.parent().html(tagNameHtml);
}
else{
$.post(
'<%= admin_update_course_name_path %>',
{"course_id": tagId, "name": $("#renameCourseName").val().trim()}
);
}
}
}
function edit_school_name(url,id){
if($("#school_name_edit_"+id).val() == ""){
$("#apply_title_"+id).show();
$("#school_name_edit_"+id).hide();
return;
}
$.get(
url,
{id: id ,name: $("#school_name_edit_"+id).val() },
function (data) {
$("#school_name_edit_"+id).val("");
if(data.status == 0){
$("#apply_title_"+data.id).show();
$("#school_name_edit_"+data.id).hide();
$("#apply_title_"+data.id).text(data.name);
}
else{
$("#apply_title_"+data.id).show();
$("#school_name_edit_"+data.id).hide();
}
}
);
}
function show_edit_school_name(id){
$("#apply_title_"+id).hide();
$("#school_name_edit_"+id).val($("#apply_title_"+id).text());
$("#school_name_edit_"+id).show();
$("#school_name_edit_"+id).focus();
}
function edit_school_address(url,id){
if($("#school_address_edit_"+id).val() == ""){
$("#apply_address_"+id).show();
$("#school_address_edit_"+id).hide();
return;
}
$.get(
url,
{id: id ,address: $("#school_address_edit_"+id).val() },
function (data) {
$("#school_address_edit_"+data.id).val("");
if(data.status == 0){
$("#apply_address_"+data.id).show();
$("#school_address_edit_"+data.id).hide();
$("#apply_address_"+data.id).text(data.address);
}
else{
$("#apply_address_"+data.id).show();
$("#school_address_edit_"+data.id).hide();
}
}
);
}
function show_edit_school_address(id){
$("#apply_address_"+id).hide();
$("#school_address_edit_"+id).val($("#apply_address_"+id).text());
$("#school_address_edit_"+id).show();
$("#school_address_edit_"+id).focus();
}
function edit_school_province(url,id){
var province = $("#school_province_edit_"+id).val();
var city = $("#schoolCity_"+id).val();
if((province == "")||(city == "")){
$("#apply_province_"+id).show();
$("#school_province_edit_"+id).hide();
$("#schoolCity_"+id).hide();
return;
}
$.get(
url,
{id: id ,province: province,city:city },
function (data) {
if(data.status == 0){
$("#apply_province_"+data.id).show();
$("#school_province_edit_"+data.id).hide();
$("#schoolCity_"+data.id).hide();
init_province_and_city(document.getElementById('school_province_edit_'+data.id), data.province, document.getElementById('schoolCity_'+data.id), data.city);
$("#apply_province_"+data.id).text(data.province+data.city);
}
else{
$("#apply_province_"+data.id).show();
$("#school_province_edit_"+data.id).hide();
$("#schoolCity_"+data.id).hide();
}
}
);
}
function init_province_and_city(pField, province, cField, city) {
for (var i = 0; i < pField.options.length; i++) {
if (pField.options[i].value == province) {
pField.selectedIndex = i;
}
}
showcity(province, cField);
for (var i = 0; i < cField.options.length; i++) {
if (cField.options[i].value == city) {
cField.selectedIndex = i;
}
}
}
function show_edit_school_province(id){
$("#apply_province_"+id).hide();
$("#school_province_edit_"+id).show();
$("#schoolCity_"+id).show();
}
//自动搜索
function throttle_search(e, condition, url) {
if($(e.target).val().trim() == condition && condition != '')
{
return;
}
condition = $(e.target).val().trim();
$.ajax({
url: url,
data:{search: e.target.value},
type:'get'
});
}
function throttle_me(method, context, e, condition, url){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context, e, condition, url);
},500);
}
//头像、logo编辑图标显隐
function edit_img(){
$(".homepageEditProfile").parent().mouseover(function(){
$(".homepageEditProfile").show();
});
$(".homepageEditProfile").parent().mouseout(function(){
$(".homepageEditProfile").hide();
});
}
$(document).ready(edit_img);
//自适应高度
function autoHeight(id, baseheight) {
var obj = $(id);
obj.height(baseheight);
var scrollVal = obj[0].scrollHeight;
obj.height(scrollVal);
obj.on('input',function(){
obj.height(baseheight);
var scrollVal = obj[0].scrollHeight;
obj.height(scrollVal);
});
};
function getIssueStatistics(url){
var tracker_id = $("#tracker_id").attr("value");
var subject = $("#v_subject").attr("value");
var assigned_to_id = $("#assigned_to_id").attr("value");
var fixed_version_id = $("#fixed_version_id").attr("value");
var status_id = $("#status_id").attr("value");
var done_ratio = $("#done_ratio").attr("value");
var test = $("#test").attr("value");
var author_id = $("#author_id").attr("value");
var priority_id = $("#priority_id").attr("value");
var issue_create_date_start = $("#issue_date_start_issue_export").attr("value");
var issue_create_date_end = $("#issue_date_end_issue_export").attr("value");
$.ajax({
url: url,
type: 'get',
data: {tracker_id: tracker_id,subject:subject,assigned_to_id:assigned_to_id, fixed_version_id:fixed_version_id, status_id:status_id,done_ratio:done_ratio,test:test,author_id:author_id,priority_id:priority_id,issue_create_date_start:issue_create_date_start,issue_create_date_end:issue_create_date_end},
success: function(data){ },
beforeSend: function(){ },
complete: function(){}
});
}
function archive_course(id, type, source){
if(type == 0){
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>您是否确定归档此班级</p>' +
'<a href="javascript:void(0);" class="btn btn-grey mt10 mr10" onclick="hideModal();">取&nbsp;&nbsp;消</a>' +
'<a href="/courses/'+ id +'/archive_course?source='+ source +'&type=0" class="btn btn-blue mt10" onclick="hideModal();" data-remote="true">确&nbsp;&nbsp;定</a></div></div></div>';
pop_box_new(htmlvalue, 400, 132);
} else{
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>您和您的学生将可以重新在此班级中互动<br/>此班级的动态会在首页中显示<br/><br/>' +
'您是否确定恢复此班级</p><a href="javascript:void(0);" class="btn btn-grey mt10 mr10" onclick="hideModal();">取&nbsp;&nbsp;消</a>' +
'<a href="/courses/'+ id +'/archive_course?source='+ source +'&type=1" class="btn btn-blue mt10" onclick="hideModal();" data-remote="true">确&nbsp;&nbsp;定</a></div></div></div>';
pop_box_new(htmlvalue, 400, 200);
}
}
//判断是不是IE浏览器
function is_IE(){
if(navigator.userAgent.toLowerCase().indexOf('msie') > -1){
return true;
}else{
return false;
}
}
function init_exercise_quetison_editor(params){
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"74px",height:"74px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
edit.iframe.height(48);
//this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight+30 : (params.kindutil.GECKO ? body.offsetHeight+26:body.offsetHeight+30)), 48));
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+30, 48));
},
afterBlur:function(){
params.textarea.blur();
if(this.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\]*[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*[\]*<\/\w*\>\s*$/.test(this.edit.html())) {
this.edit.html("<span id='hint' style='color:#999999;font-size:12px;'>"+params.placeholder+"</span>");
this.resize("100%", null);
}
},
afterFocus: function(){
var edit = this.edit;
var body = edit.doc.body;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\]*[\]*[\u4e00-\u9fa5]*[\]*[\u4e00-\u9fa5]*[\。]*[\]*<\/\w*\>\s*$/.test(edit.html())){
edit.html("");
}
this.resize("100%", null);
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
edit.html(params.textarea.innerHTML);
if(this.isEmpty()) {
edit.html("<span id='hint' style='color:#999999;font-size:12px;'>"+params.placeholder+"</span>");
}
}
}).loadPlugin('paste');
//editor.focus();
return editor;
}
function toggle_student_score(id){
$('#score_list_' + id).toggle();
if($('#score_list_' + id).is(':visible')){
$("#toggle_score_" + id).html("收起评阅详情");
} else{
$("#toggle_score_" + id).html("展开评阅详情");
}
}
function get_email_info(id, subject) {
task = setInterval(search_email_status, 2000);
var count = 0;
function search_email_status() {
count = count + 1;
if(count > 3){
clearInterval(task);
} else {
$.ajax({
url: '/account/get_email_info?user_id=' + id + '&subject=' + subject,
type: 'get',
success: function (data) {
$("#email_log_detail").parent().show();
if (data.result == "succuss") {
$("#email_log_detail").html("邮件概况:" + data.message);
if (data.message != "未查询到相关数据" && data.message != "发信中") {
clearInterval(task);
}
} else {
$("#email_log_detail").html("邮件概况:无法查询邮件概况");
clearInterval(task);
}
},
error: function () {
$("#email_log_detail").html("邮件概况:无法查询邮件概况");
$("#email_log_detail").parent().show();
clearInterval(task);
}
});
}
}
}
function scroll_height(num){
window.location.href="#student_work_"+num;
var top=$(document).scrollTop();
//var mt=$("#homework_table").css("margin-top");
$(document).scrollTop(parseInt(top));
}