cleaned html of item form

This commit is contained in:
Sanj 2011-07-04 20:58:18 +05:30
parent 71b80fc023
commit 7dbc55a10d

View File

@ -164,15 +164,17 @@ function getJQ(f) {
function getItemForm(f) { function getItemForm(f) {
var $form = $('<div />').addClass("itemForm"); var $form = $('<div />').addClass("itemForm");
var $labelsP = $('<p />').appendTo($form); var $leftCol = $('<div />').addClass("leftCol").appendTo($form);
var $titleLabel = $('<span />').addClass("itemFormLabel").addClass("titleLabel").text("Title").appendTo($labelsP); var $title = $('<p />').addClass("editTitle").appendTo($leftCol);
var $descriptionLabel = $('<span />').addClass("itemFormLabel").addClass("descriptionLabel").text("Description").appendTo($labelsP); var $titleLabel = $('<span />').addClass("itemFormLabel").addClass("titleLabel").text("Title").appendTo($title);
var $inputsP = $('<p />').appendTo($form); var $titleInput = $('<input />').addClass("itemTitle").val(f.title).appendTo($title);
var $titleInput = $('<input />').addClass("itemTitle").val(f.title).appendTo($inputsP);
if (f.can_edit) { if (f.can_edit) {
var $privateLabel = $('<span />').addClass("pvtLabel").text("Private ").appendTo($inputsP); var $pvt = $('<p />').addClass("editPrivate").appendTo($leftCol);
var $pvtCheckbox = $('<input />').attr("type", "checkbox").attr("checked", f.is_private).appendTo($inputsP); var $privateLabel = $('<span />').addClass("pvtLabel").text("Private ").appendTo($pvt);
var $pvtCheckbox = $('<input />').attr("type", "checkbox").attr("checked", f.is_private).appendTo($pvt);
$pvtCheckbox.change(function() { $pvtCheckbox.change(function() {
var checked = $(this).is(":checked"); var checked = $(this).is(":checked");
if (checked) { if (checked) {
@ -194,10 +196,12 @@ function getItemForm(f) {
}, "json"); }, "json");
}); });
} }
var $rightCol = $("<div />").addClass("rightCol").appendTo($form);
var $descriptionInput = $('<textarea />').addClass("itemDescription").val(f.description).appendTo($inputsP); var $desc = $("<p />").addClass("editDescription").appendTo($rightCol);
var $hiddenInput = $('<input />').addClass("itemId").attr("type", "hidden").val(f.id).appendTo($inputsP); var $descriptionLabel = $('<span />').addClass("itemFormLabel").addClass("descriptionLabel").text("Description").appendTo($desc);
var $submitP = $('<p />').addClass("submitInput").appendTo($form); var $descriptionInput = $('<textarea />').addClass("itemDescription").val(f.description).appendTo($desc);
var $hiddenInput = $('<input />').addClass("itemId").attr("type", "hidden").val(f.id).appendTo($desc);
var $submitP = $('<p />').addClass("submitInput").appendTo($rightCol);
var $submit = $('<input />').addClass("submitItem").attr("type", "submit").val("Submit").appendTo($submitP); var $submit = $('<input />').addClass("submitItem").attr("type", "submit").val("Submit").appendTo($submitP);
var $submitStatus = $('<span />').addClass("submitStatus").appendTo($submitP); var $submitStatus = $('<span />').addClass("submitStatus").appendTo($submitP);
$submit.click(function(e) { $submit.click(function(e) {
@ -229,11 +233,20 @@ function getListElement(f) {
var $item = $('<div />').addClass("fileItem").data("data", f); var $item = $('<div />').addClass("fileItem").data("data", f);
var $checkbox = $('<input />').attr("type", "checkbox").addClass("fileCheckbox").appendTo($item); var $checkbox = $('<input />').attr("type", "checkbox").addClass("fileCheckbox").appendTo($item);
var $icon = $('<img />').addClass("fileIcon").attr("src", "/static/images/icons2/" + f.type.toLowerCase() + ".jpg").appendTo($item); var $icon = $('<img />').addClass("fileIcon").attr("src", "/static/images/icons2/" + f.type.toLowerCase() + ".jpg").appendTo($item);
var $study = $('<span />').addClass("fileStudy").text(f.studies[0].name + ": ").appendTo($item); var study_txt = joinStudies(f.studies);
var $study = $('<span />').addClass("fileStudy").text(study_txt + ": ").appendTo($item);
var $title = $('<span />').addClass("fileTitle").text(f.title).appendTo($item); var $title = $('<span />').addClass("fileTitle").text(f.title).appendTo($item);
return $item; return $item;
} }
function joinStudies(studies) {
var arr = [];
for (var i=0; i<studies.length; i++) {
arr.push(studies[i].name);
}
return arr.join(", ");
}
function getSelectedIds() { function getSelectedIds() {
var ids = []; var ids = [];
$('.fileItem').each(function() { $('.fileItem').each(function() {