function twistEntityRequest(twistEntityRequest) { var spinnerOptions = { lines: 13, // The number of lines to draw length: 10, // The length of each line width: 5, // The line thickness radius: 10, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset direction: 1, // 1: clockwise, -1: counterclockwise color: ['#069f43','#1c68cf'], // twist green and twist blue speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'twistAjaxSpinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: '50%', // Top position relative to parent left: '50%' // Left position relative to parent }; $('body').spin(spinnerOptions); var arrTwistPostData = {}; numTwistEntityRequestParametersStart = twistEntityRequest.indexOf('&'); if (numTwistEntityRequestParametersStart == -1) { twistEntityRequestCode = twistEntityRequest; arrTwistPostData['entityRequestCode'] = twistEntityRequestCode; } else { twistEntityRequestCode = twistEntityRequest.substr(0,numTwistEntityRequestParametersStart); arrTwistPostData['entityRequestCode'] = twistEntityRequestCode; twistEntityRequestParameters = twistEntityRequest.substr(numTwistEntityRequestParametersStart+1); arrTwistEntityRequestParameters = twistEntityRequestParameters.split('&'); for(value in arrTwistEntityRequestParameters){ numTwistWhereEqual = (arrTwistEntityRequestParameters[value].indexOf('=')); strTwistArrayKey = arrTwistEntityRequestParameters[value].substr(0,numTwistWhereEqual); strTwistArrayValue = arrTwistEntityRequestParameters[value].substr(numTwistWhereEqual+1); arrTwistPostData[strTwistArrayKey] = strTwistArrayValue; } } loadEntityRequest = '/twist/loadEntityRequest'; $.post(loadEntityRequest, arrTwistPostData, function(returnData) { //$('#twistDebug').html(returnData); //alert(returnData); numObjectCount = (returnData.split('["').length - 1) modal = false; modalCount = 0; while (numObjectCount>0) { numStartDelimiter = returnData.indexOf('["'); numEndDelimiter = returnData.indexOf('"]'); strObjectID = '#' + returnData.substring(numStartDelimiter+2,numEndDelimiter); returnData = returnData.substring(numEndDelimiter+2); if (numObjectCount==1) { numStartDelimiter = returnData.length; } else { numStartDelimiter = returnData.indexOf('["'); } strObjectData = returnData.substring(0,numStartDelimiter); returnData = returnData.substring(numStartDelimiter); numObjectCount = numObjectCount - 1; switch(1==1) { case (strObjectID=='#twistWindow'): windowHeight = (windowHeight>0) ? windowHeight : 600; windowWidth = (windowWidth>0) ? windowWidth : 1200; windowWidth=80; //if ((strObjectID=='#twistModalWindow' && $('#twistModalWindow' + windowID).length==0) || (strObjectID=='#twistWindow' && $('#twistWindow' + windowID).length==0)) { if ((strObjectID=='#twistWindow')) { if ($('#twistWindow' + windowID).length>0) { // closes any matching windows. this won't work long term twistWindowClose(windowID); } $(this).twistWindow({ closeIcon: windowCloseIcon, content: strObjectData, draggable: windowDraggable, entityRequestID: windowEntityRequestID, height: windowHeight, id: windowID, left: ((($(window).width() - windowWidth)/2)-24), modal: windowModal, resizeable: windowResizeable, title: windowTitle, top: windowTop, width: windowWidth, zindex: windowZIndex }); } break; case (strObjectID=='#twistWindowOptions'): windowCenterH = twistParseQueryString(strObjectData,'centerH','|'); windowCenterV = twistParseQueryString(strObjectData,'centerV','|'); windowCloseIcon = twistParseQueryString(strObjectData,'closeIcon','|'); windowDraggable = twistParseQueryString(strObjectData,'draggable','|'); windowEntityRequestID = twistParseQueryString(strObjectData,'entityRequestID','|'); windowHeight = twistParseQueryString(strObjectData,'height','|'); windowID = twistParseQueryString(strObjectData,'id','|'); windowLeft = twistParseQueryString(strObjectData,'left','|'); windowModal = twistParseQueryString(strObjectData,'modal','|'); windowResizeable = twistParseQueryString(strObjectData,'resizeable','|'); windowTitle = twistParseQueryString(strObjectData,'title','|'); windowTop = twistParseQueryString(strObjectData,'top','|'); windowWidth = twistParseQueryString(strObjectData,'width','|'); windowZIndex = twistParseQueryString(strObjectData,'zindex','|'); break; default: //alert('default'); $(strObjectID).html(strObjectData); } } $('body').spin(false); }); } // twist! function to handle entity requests function twistLoadEntityRequest(twistEntityRequest) { var spinnerOptions = { lines: 13, // The number of lines to draw length: 10, // The length of each line width: 5, // The line thickness radius: 10, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset direction: 1, // 1: clockwise, -1: counterclockwise color: ['#069f43','#1c68cf'], // twist green and twist blue speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'twistAjaxSpinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: '50%', // Top position relative to parent left: '50%' // Left position relative to parent }; $('body').spin(spinnerOptions); var arrTwistPostData = {}; numTwistEntityRequestParametersStart = twistEntityRequest.indexOf('&'); if (numTwistEntityRequestParametersStart == -1) { twistEntityRequestCode = twistEntityRequest; arrTwistPostData['entityRequestCode'] = twistEntityRequestCode; } else { twistEntityRequestCode = twistEntityRequest.substr(0,numTwistEntityRequestParametersStart); arrTwistPostData['entityRequestCode'] = twistEntityRequestCode; twistEntityRequestParameters = twistEntityRequest.substr(numTwistEntityRequestParametersStart+1); arrTwistEntityRequestParameters = twistEntityRequestParameters.split('&'); for(value in arrTwistEntityRequestParameters){ numTwistWhereEqual = (arrTwistEntityRequestParameters[value].indexOf('=')); strTwistArrayKey = arrTwistEntityRequestParameters[value].substr(0,numTwistWhereEqual); strTwistArrayValue = arrTwistEntityRequestParameters[value].substr(numTwistWhereEqual+1); arrTwistPostData[strTwistArrayKey] = strTwistArrayValue; } } loadEntityRequest = '/twist/loadEntityRequest'; $.post(loadEntityRequest, arrTwistPostData, function(returnData) { //$('#twistDebug').html(returnData); //alert(returnData); numObjectCount = (returnData.split('["').length - 1) modal = false; modalCount = 0; while (numObjectCount>0) { numStartDelimiter = returnData.indexOf('["'); numEndDelimiter = returnData.indexOf('"]'); strObjectID = '#' + returnData.substring(numStartDelimiter+2,numEndDelimiter); returnData = returnData.substring(numEndDelimiter+2); if (numObjectCount==1) { numStartDelimiter = returnData.length; } else { numStartDelimiter = returnData.indexOf('["'); } strObjectData = returnData.substring(0,numStartDelimiter); returnData = returnData.substring(numStartDelimiter); numObjectCount = numObjectCount - 1; switch(1==1) { case (strObjectID=='#twistWindow'): windowHeight = (windowHeight>0) ? windowHeight : 600; windowWidth = (windowWidth>0) ? windowWidth : 1200; windowWidth=80; //if ((strObjectID=='#twistModalWindow' && $('#twistModalWindow' + windowID).length==0) || (strObjectID=='#twistWindow' && $('#twistWindow' + windowID).length==0)) { if ((strObjectID=='#twistWindow')) { if ($('#twistWindow' + windowID).length>0) { // closes any matching windows. this won't work long term twistWindowClose(windowID); } $(this).twistWindow({ closeIcon: windowCloseIcon, content: strObjectData, draggable: windowDraggable, entityRequestID: windowEntityRequestID, height: windowHeight, id: windowID, left: ((($(window).width() - windowWidth)/2)-24), modal: windowModal, resizeable: windowResizeable, title: windowTitle, top: windowTop, width: windowWidth, zindex: windowZIndex }); } break; case (strObjectID=='#twistWindowOptions'): windowCenterH = twistParseQueryString(strObjectData,'centerH','|'); windowCenterV = twistParseQueryString(strObjectData,'centerV','|'); windowCloseIcon = twistParseQueryString(strObjectData,'closeIcon','|'); windowDraggable = twistParseQueryString(strObjectData,'draggable','|'); windowEntityRequestID = twistParseQueryString(strObjectData,'entityRequestID','|'); windowHeight = twistParseQueryString(strObjectData,'height','|'); windowID = twistParseQueryString(strObjectData,'id','|'); windowLeft = twistParseQueryString(strObjectData,'left','|'); windowModal = twistParseQueryString(strObjectData,'modal','|'); windowResizeable = twistParseQueryString(strObjectData,'resizeable','|'); windowTitle = twistParseQueryString(strObjectData,'title','|'); windowTop = twistParseQueryString(strObjectData,'top','|'); windowWidth = twistParseQueryString(strObjectData,'width','|'); windowZIndex = twistParseQueryString(strObjectData,'zindex','|'); break; default: //alert('default'); $(strObjectID).html(strObjectData); } } $('body').spin(false); }); } // twist! function to parse query strings function twistParseQueryString(queryString,parameter,delimiter) { delimiter = (typeof delimiter === 'undefined') ? '=' : delimiter; var query = {}; var a = queryString.split('&'); for (var i in a) { var b = a[i].split(delimiter); if (b[0]==parameter) { return b[1]; } } return ''; } // twist! function to sort a select list function twistSortSelectListByText(selectID) { var sortOptions = $('#'+ selectID + ' option').sort(function(a, b) { return a.text == b.text ? 0 : a.text < b.text ? -1 : 1 }); $('#' + selectID).html(sortOptions); }; function twistWindowClose(windowHandle) { $('#twistWindow'+windowHandle).remove(); $('#twistWindowVeil' +windowHandle).remove(); $('body').css({ 'overflow':'visible', }); } $(document).on('click','.twistEntityRequest',function() { twistLoadEntityRequest($(this).attr('data-entityRequest')); });