// JavaScript Document /* Create our object to hold all functions and vars ---------------------------------------------------------*/ var objAdmin = {}; /* ---------------------------------------------------------*/ objAdmin.admin_url = "http://booktrustadmin.kentlyons.com/admin/"; objAdmin.site_url = "http://booktrustadmin.kentlyons.com/"; /* ----------------------------------------------------- @description update div that is to be replaced @param data data to replace div with ---------------------------------------------------------*/ objAdmin.updateAssignment = function( data/*string*/) { //---------------------------------------------- var holder = document.getElementById(objAdmin.holderDiv); var all_items= document.getElementById(objAdmin.div); holder.removeChild(all_items); //---------------------------------------------- //---------------------------------------------- var new_all_items = document.createElement("div"); new_all_items.setAttribute("id", objAdmin.div); new_all_items.innerHTML = data; holder.appendChild(new_all_items); /*Create new col arrays*/ col2Array=$('ul#col02 li').sortable('toAray'); col1Array=$('ul#col01 li').sortable('toAray'); for(var i=0; i"); } /*------------------------------------------------------- @description assign or unassign items after item has been dragged @param obj obj passed containing new contents of columns --------------------------------------------------------- */ objAdmin.changeAssignment = function (obj) { // get new arrays for col1 and col2 col1=$('ul#col01 li'); col2=$('ul#col02 li'); for(var i=0; iobjAdmin.col1.length){ action="assignItem"; } else{ action="unassignItem"; } // compare columns in length to comaprison is done with larger one if(col1.length>col2.length){ activeCol=col1; compareCol=objAdmin.col1; } else{ activeCol=col2; compareCol=objAdmin.col2; } // compare columns in length to comaprison is done with larger one if(activeCol.length"; newDiv.setAttribute("id", "message"); holder.appendChild(newDiv); $("#messagebox").show("slow"); // reset session var baseURL = objAdmin.admin_url; var controller = "section/"; var cFunction ="resetStatus/"; var newURL = baseURL + controller + cFunction; $.ajax({ type: "POST", url: newURL }); window.setTimeout(function() { jQuery('#status').fadeOut('slow'); }, 1500); } objAdmin.populateInput= function (value){ var input = document.getElementById("autocomplete_field"); input.value=value; $('#suggestions1').hide(); } /* ------------------------------------------------------ @description hide a div @param id id of div to hide ---------------------------------------------------------*/ objAdmin.hide=function(id){ var element = document.getElementById(id); element.style.display="none"; } /* ------------------------------------------------------ @description fill the autuo complete field with data ---------------------------------------------------------*/ objAdmin.fill=function (thisValue) { $('#inputString').val(thisValue); $('#suggestions').hide(); } /* ------------------------------------------------------ @description assign books ---------------------------------------------------------*/ objAdmin.assignBooks=function (id) { var tagElement = document.getElementById('tags'); var limitElement = document.getElementById('limit'); var typeElement = document.getElementById('typeId'); if(tagElement.value.lenght!=0 && limitElement.value.length!=0){ var baseURL = objAdmin.admin_url; var url = baseURL+"book/assign_books"; $.ajax({ type: "POST", url: url, data: 'tags=' + tagElement.value+'&id=' + id+'&limit='+limitElement.value+'&type='+typeElement.value, success: objAdmin.reloadPage }); } else{ alert("Please enter valid entries"); } }