- lessonPosition: function ($td, lesson) {
- $td.attr("rowspan", lesson.clocks);
- $td.append(schedule.lesson.createLessonProp(lesson));
- if (lesson.color != undefined && lesson.color != "") {
- $td.find("div.tb-base:last").CSS("border-color", lesson.color);
- }
- var lines = new Array();
- var tempObj = {};
- lines.push(lesson.startClock);
- var length = parseInt(lesson.clocks);
- var startLine = parseInt(lesson.startClock);
- for (var j = 1; j < length; j++) {
- var line = (startLine + j);
- var $tempTd = $("table#tb tr[data-id='" + line + "'] td[data-id='" + lesson.classDay + "']");
- if ($tempTd != undefined && $.trim($tempTd.html()) != "") {
- var tmpH = parseInt(lesson.clocks) + parseInt($tempTd.attr("rowspan") - line);
- $td.attr("rowspan", tmpH);
- $td.append($tempTd.html());
- if ($tempTd.attr("data-cons") != undefined) {
- var tempLines = $tempTd.attr("data-cons").split(",");
- for (var i = 0; i < tempLines.length; i++) {
- lines.push(tempLines[i]);
- tempObj[tempLines[i]] = tempLines[i];
- }
- }
- }
- $tempTd.remove();
- if (tempObj[line] == undefined) {
- tempObj[line] = line;
- lines.push(line);
- }
- }
- $td.attr("data-cons", lines);
- //课程分列展示
- var $cur = $td.find("div.tb-base:last");
- $cur.css("position", "absolute");
- var topmins=schedule.lesson.setLessonTop($td, $cur);
- var mins = (Date.parseExtend(lesson.endTime).getTime() - Date.parseExtend(lesson.beginTime).getTime()) / (60 * 1000);
- var height = mins * 21 / 30-3;
- if(height>$td.height()&&topmins<0) {
- height=(mins+topmins) * 21 / 30-3;
- }
- lesson.height = height;
- $td.find("div.tb-base:last").css("height", (height + "px"));
- if (height <= 60) {
- $td.find("div.tb-base:last").children("h4").css("padding-top", "0");
- }
- var lessonCount = $td.find("div.tb-base").length;
- var width = schedule.lesson.getLessonWidth(lessonCount,lesson);
- var canCount = 25;
- if (schedule.days == 7) {
- canCount = 18;
- }
- $td.find("div.tb-base").each(function (index, item) {
- var $item = $(item);
- $item.css("width", (width + "px"));
- $item.css("left", (index * (width + 5) + "px"));
- if (width < 40) {
- $item.children("h4").css("padding-top", "0");
- }
- if (canCount - index - 1 < 0) {
- $item.css("display", "none");
- }
- });
- //课程重叠展示
- /*var lessonCount = $td.find("div.tb-base").length;
- if(lessonCount==2) {
- $td.find("div.tb-base").addClass("w40");
- }*/
- /*if(lessonCount>2) {
- var tempCons = $td.attr("data-cons").split(",");
- var dateTop = new Date(1900, 1, 1, 8, 0, 0);
- dateTop.setMinutes(dateTop.getMinutes() + (parseInt(tempCons[0]) - 1) * 30);
- var tdHeight = tempCons.length * 21;
- var arr = [];
- $td.find("div.tb-base").each(function(index,item) {
- var $item = $(item);
- var itemDate = Date.parseExtend($item.attr("data-beginTime"));
- itemDate.setFullYear(1900);
- itemDate.setMonth(1);
- itemDate.setDate(1);
- var itemLess = { };
- if(itemDate<=dateTop) {
- itemLess.top = 0;
- } else {
- var mins=(itemDate.getTime() - dateTop.getTime()) / (60 * 1000);
- itemLess.top = mins * 21 / 30;
- }
- var result = schedule.lesson.getLessonTop(arr, itemLess);
- $td.find("div.tb-base").removeClass("w40");
- $item.css("position","absolute");
- $item.css("top", result.lesson.top);
- var itemHeight = parseInt($item.attr("data-height"));
- if((itemHeight+result.lesson.top)>tdHeight) {
- tdHeight = itemHeight + result.lesson.top;
- $td.css("height", tdHeight+"px");
- }
- });
- }*/
- }
- //该片段来自于http://www.codesnippet.cn/detail/040320148883.html
来源: http://www.codesnippet.cn/detail/040320148883.html