From 7dbc55a10dfc7b6e1bd16a39a35c9e2310c16e67 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 4 Jul 2011 20:58:18 +0530 Subject: [PATCH] cleaned html of item form --- edgware/static/js/files/browse.js | 39 ++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/edgware/static/js/files/browse.js b/edgware/static/js/files/browse.js index eb5c22d..658fe26 100644 --- a/edgware/static/js/files/browse.js +++ b/edgware/static/js/files/browse.js @@ -164,15 +164,17 @@ function getJQ(f) { function getItemForm(f) { var $form = $('').addClass("itemForm"); - var $labelsP = $('
').appendTo($form); - var $titleLabel = $('').addClass("itemFormLabel").addClass("titleLabel").text("Title").appendTo($labelsP); - var $descriptionLabel = $('').addClass("itemFormLabel").addClass("descriptionLabel").text("Description").appendTo($labelsP); - var $inputsP = $('').appendTo($form); - var $titleInput = $('').addClass("itemTitle").val(f.title).appendTo($inputsP); + var $leftCol = $('').addClass("leftCol").appendTo($form); + var $title = $('').addClass("editTitle").appendTo($leftCol); + var $titleLabel = $('').addClass("itemFormLabel").addClass("titleLabel").text("Title").appendTo($title); + var $titleInput = $('').addClass("itemTitle").val(f.title).appendTo($title); + + if (f.can_edit) { - var $privateLabel = $('').addClass("pvtLabel").text("Private ").appendTo($inputsP); - var $pvtCheckbox = $('').attr("type", "checkbox").attr("checked", f.is_private).appendTo($inputsP); + var $pvt = $('').addClass("editPrivate").appendTo($leftCol); + var $privateLabel = $('').addClass("pvtLabel").text("Private ").appendTo($pvt); + var $pvtCheckbox = $('').attr("type", "checkbox").attr("checked", f.is_private).appendTo($pvt); $pvtCheckbox.change(function() { var checked = $(this).is(":checked"); if (checked) { @@ -194,10 +196,12 @@ function getItemForm(f) { }, "json"); }); } - - var $descriptionInput = $('').addClass("itemDescription").val(f.description).appendTo($inputsP); - var $hiddenInput = $('').addClass("itemId").attr("type", "hidden").val(f.id).appendTo($inputsP); - var $submitP = $('').addClass("submitInput").appendTo($form); + var $rightCol = $("").addClass("rightCol").appendTo($form); + var $desc = $("").addClass("editDescription").appendTo($rightCol); + var $descriptionLabel = $('').addClass("itemFormLabel").addClass("descriptionLabel").text("Description").appendTo($desc); + var $descriptionInput = $('').addClass("itemDescription").val(f.description).appendTo($desc); + var $hiddenInput = $('').addClass("itemId").attr("type", "hidden").val(f.id).appendTo($desc); + var $submitP = $('').addClass("submitInput").appendTo($rightCol); var $submit = $('').addClass("submitItem").attr("type", "submit").val("Submit").appendTo($submitP); var $submitStatus = $('').addClass("submitStatus").appendTo($submitP); $submit.click(function(e) { @@ -228,12 +232,21 @@ function getListElement(f) { // console.log(f); var $item = $('').addClass("fileItem").data("data", f); var $checkbox = $('').attr("type", "checkbox").addClass("fileCheckbox").appendTo($item); - var $icon = $('').addClass("fileIcon").attr("src", "/static/images/icons2/" + f.type.toLowerCase() + ".jpg").appendTo($item); - var $study = $('').addClass("fileStudy").text(f.studies[0].name + ": ").appendTo($item); + var $icon = $('').addClass("fileIcon").attr("src", "/static/images/icons2/" + f.type.toLowerCase() + ".jpg").appendTo($item); + var study_txt = joinStudies(f.studies); + var $study = $('').addClass("fileStudy").text(study_txt + ": ").appendTo($item); var $title = $('').addClass("fileTitle").text(f.title).appendTo($item); return $item; } +function joinStudies(studies) { + var arr = []; + for (var i=0; i