function drawJavascript($nosave) { static $drawnJavascript = false; if ($drawnJavascript) { return; } global $xoopsUser; $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; // Left in for possible future use by the rankOrderList element type or other elements that might use jQuery //print "<script type=\"text/javascript\" src=\"".XOOPS_URL."/modules/formulize/libraries/jquery/jquery-1.3.2.min.js\"></script><script type=\"text/javascript\" src=\"".XOOPS_URL."/modules/formulize/libraries/jquery/jquery-ui-1.7.2.custom.min.js\"></script>"; //$GLOBALS['formulize_jQuery_included'] = true; print "\n<script type='text/javascript'>\n"; print " initialize_formulize_xhr();\n"; print " var formulizechanged=0;\n"; print " var formulize_xhr_returned_check_for_unique_value = 'notreturned';\n"; if (isset($GLOBALS['formulize_fckEditors'])) { print "function FCKeditor_OnComplete( editorInstance ) { \n"; print " editorInstance.Events.AttachEvent( 'OnSelectionChange', formulizeFCKChanged ) ;\n"; print "}\n"; print "function formulizeFCKChanged( editorInstance ) { \n"; print " formulizechanged=1; \n"; print "}\n"; } ?> window.onbeforeunload = function (e) { if(formulizechanged) { var e = e || window.event; var confirmationText = "<?php print _formulize_CONFIRMNOSAVE_UNLOAD; ?> "; // message may have single quotes in it! // For IE and Firefox prior to version 4 if (e) { e.returnValue = confirmationText; } // For Safari return confirmationText; } }; <?php print $codeToIncludejQueryWhenNecessary; if (intval($_POST['yposition']) > 0) { print "\njQuery(window).load(function () {\n"; print "\tjQuery(window).scrollTop(" . intval($_POST['yposition']) . ");\n"; print "});\n"; } ?> function showPop(url) { if (window.formulize_popup == null) { formulize_popup = window.open(url,'formulize_popup','toolbar=no,scrollbars=yes,resizable=yes,width=800,height=550,screenX=0,screenY=0,top=0,left=0'); } else { if (window.formulize_popup.closed) { formulize_popup = window.open(url,'formulize_popup','toolbar=no,scrollbars=yes,resizable=yes,width=800,height=550,screenX=0,screenY=0,top=0,left=0'); } else { window.formulize_popup.location = url; } } window.formulize_popup.focus(); } function validateAndSubmit(leave) { var formulize_numbersonly_found= false; jQuery(".numbers-only-textbox").each(function() { if(jQuery(this).val().match(/[a-z]/i) !== null) { var answer = confirm ("You have entered "+jQuery(this).val()+" in a box that is supposed to have numbers only. The letters will be removed if you save. Is this OK?" ); if (!answer){ jQuery(this).focus(); formulize_numbersonly_found = true; } } }); if (formulize_numbersonly_found){ return false; } <?php if (!$nosave) { // need to check for add or update permissions on the current user and this entry before we include this javascript, otherwise they should not be able to save the form ?> var validate = xoopsFormValidate_formulize(); // this is an optional form validation function which can be provided by a screen template or form text element if (window.formulizeExtraFormValidation && typeof(window.formulizeExtraFormValidation) === 'function') { validate = window.formulizeExtraFormValidation(); } if(validate) { if(typeof savedPage != 'undefined' && savedPage && savedPrevPage) { // set in submitForm and will have values if we're on the second time around of a two step validation, like a uniqueness check with the server multipageSetHiddenFields(savedPage, savedPrevPage); } jQuery(".subform-accordion-container").map(function() { subelementid = jQuery(this).attr('subelementid'); window.document.getElementById('subform_entry_'+subelementid+'_active').value = jQuery(this).accordion( "option", "active" ); }); jQuery('#submitx').attr('disabled', 'disabled'); if(jQuery('.formulize-form-submit-button')) { jQuery('.formulize-form-submit-button').attr('disabled', 'disabled'); } if(jQuery('#save_and_leave_button')) { jQuery('#save_and_leave_button').attr('disabled', 'disabled'); } jQuery('#yposition').val(jQuery(window).scrollTop()); if (formulizechanged) { window.document.getElementById('formulizeform').style.opacity = 0.5; window.document.getElementById('savingmessage').style.display = 'block'; window.scrollTo(0,0); formulizechanged = 0; // don't want to trigger the beforeunload warning } if (leave) { jQuery('#save_and_leave').val(1); } window.document.formulize.submit(); } <?php } // end of if not $nosave ?> } <?php print "\tfunction verifyDone() {\n"; //print " alert(formulizechanged);\n"; if (!$nosave) { print "\tif(formulizechanged==0) {\n"; } print "\t\tremoveEntryLocks('submitGoParent');\n"; // true causes the go_parent form to submit if (!$nosave) { print "\t} else {\n"; print "\t\tvar answer = confirm (\"" . _formulize_CONFIRMNOSAVE . "\");\n"; print "\t\tif (answer) {\n"; print "\t\t\tformulizechanged = 0;\n"; // don't want to trigger the beforeunload warning print "\t\t\tremoveEntryLocks('submitGoParent');\n"; // true causes the go_parent form to submit print "\t\t}\n"; print "\t}\n"; } print " return false;"; // removeEntryLocks calls the go_parent form for us print "\t}\n"; print " function removeEntryLocks(action) {\n"; global $entriesThatHaveBeenLockedThisPageLoad; if (count($entriesThatHaveBeenLockedThisPageLoad) > 0) { print "var killLocks = " . formulize_javascriptForRemovingEntryLocks(); print "\t\tkillLocks.done(function() { \n"; print "\t\t\tformulize_javascriptForAfterRemovingLocks(action);\n"; print "\t\t\t});\n"; } else { print "formulize_javascriptForAfterRemovingLocks(action);\n"; } print " }\n"; ?> function formulize_javascriptForAfterRemovingLocks(action) { if(action == 'submitGoParent') { window.document.go_parent.submit(); } else { var formAction = jQuery('form[name=formulize]').attr('action'); var formData = jQuery('form[name=formulize]').serialize(); jQuery.ajax({ type: "POST", url: formAction, data: formData, success: function(html, x){ document.open(); document.write(html); document.close(); } }); } } <?php print "\tfunction add_sub(sfid, numents, instance_id) {\n"; print "\t\tdocument.formulize.target_sub.value=sfid;\n"; print "\t\tdocument.formulize.numsubents.value=numents;\n"; print "\t\tdocument.formulize.target_sub_instance.value=instance_id;\n"; print "\t\tvalidateAndSubmit();\n"; print "\t}\n"; print "\tfunction sub_del(sfid) {\n"; print "\t\tvar answer = confirm ('" . _formulize_DEL_ENTRIES . "')\n"; print "\t\tif (answer) {\n"; print "\t\t\tdocument.formulize.deletesubsflag.value=sfid;\n"; print "\t\t\tvalidateAndSubmit();\n"; print "\t\t} else {\n"; print "\t\t\treturn false;\n"; print "\t\t}\n"; print "\t}\n"; print "\tfunction goSub(ent, fid) {\n"; print "\t\tdocument.formulize.goto_sub.value = ent;\n"; print "\t\tdocument.formulize.goto_sfid.value = fid;\n"; //print " document.formulize.submit();\n"; print "\t\tvalidateAndSubmit();\n"; print "\t}\n"; //added by Cory Aug 27, 2005 to make forms printable print "function PrintPop(ele_allowed) {\n"; print "\t\twindow.document.printview.elements_allowed.value=ele_allowed;\n"; // nmc 2007.03.24 - added print "\t\twindow.document.printview.submit();\n"; print "}\n"; //added by Cory Aug 27, 2005 to make forms printable print "function PrintAllPop() {\n"; // nmc 2007.03.24 - added print "\t\twindow.document.printview.elements_allowed.value='';\n"; // nmc 2007.03.24 - added print "\t\twindow.document.printview.submit();\n"; // nmc 2007.03.24 - added print "}\n"; // nmc 2007.03.24 - added // try and catch changes in a datebox element print "jQuery(document).ready(function() {\r\n jQuery(\"img[title='" . _CALENDAR . "']\").click(function() {\r\n\tformulizechanged=1;\t\t\r\n }); \r\n});\r\n\n"; drawXhrJavascript(); ?> jQuery(document).ready(function() { jQuery(".icms-date-box").each(function(){ date_input = jQuery(this); var options = {}; // copy datepicker_defaults so the original is not modified jQuery.extend(options, datepicker_defaults); var min_date = date_input.attr('min-date'); if (min_date && min_date.length > 0) { // adjust so that the date does use the current time zone min_date = new Date(min_date); min_date.setTime(min_date.getTime() + min_date.getTimezoneOffset()*60*1000); options.minDate = new Date(min_date); } var max_date = date_input.attr('max-date'); if (max_date && max_date.length > 0) { // adjust so that the date does use the current time zone max_date = new Date(max_date); max_date.setTime(max_date.getTime() + max_date.getTimezoneOffset()*60*1000); options.maxDate = new Date(max_date); } if (options.minDate || options.maxDate) { date_input.datepicker("destroy"); date_input.datepicker(options); } }); }); function check_date_limits(element_id) { var date_input = jQuery("#"+element_id); var min_date = date_input.attr('min-date'); var max_date = date_input.attr('max-date'); var selected_date = new Date(date_input.datepicker('getDate')); <?php // if the selected_date is not valid then getTime() returns NaN (not-a-number) // NaN is NOT equal to NaN, so the comparison ensures the date is valid ?> if (selected_date.getTime() === selected_date.getTime()) { if (min_date && min_date.length > 0) { min_date = new Date(min_date); <?php // adjust the time zone before displaying the date, otherwise it could show the wrong day if // the user and server are in different time zones ?> min_date.setTime(min_date.getTime() + (min_date.getTimezoneOffset() * 60 * 1000)); if (selected_date < min_date) { // date is too far in the past selected_date = null; date_input.val(''); alert("The date you selected is too far in the past.\n\n"+ "Please select a date on or after "+min_date.toDateString()+"."); } } if (null != selected_date && max_date && max_date.length > 0) { max_date = new Date(max_date); <?php // adjust the time zone before displaying the date, otherwise it could show the wrong day if // the user and server are in different time zones ?> max_date.setTime(max_date.getTime() + (max_date.getTimezoneOffset() * 60 * 1000)); if (selected_date > max_date) { // date is too far in the future date_input.val(''); alert("The date you selected is too far in the future.\n\n"+ "Please select a date on or before "+max_date.toDateString()+"."); } } } else { // not a valid date date_input.val(''); } } <?php print "</script>\n"; $drawnJavascript = true; }
function interfaceJavascript($fid, $frid, $currentview, $useWorking, $useXhr, $lockedColumns) { ?> <script type='text/javascript'> if (typeof jQuery == 'undefined') { var head = document.getElementsByTagName('head')[0]; script = document.createElement('script'); script.id = 'jQuery'; script.type = 'text/javascript'; script.src = '<?php print XOOPS_URL; ?> /modules/formulize/libraries/jquery/jquery-1.4.2.min.js'; head.appendChild(script); } <?php if ($useXhr) { print " initialize_formulize_xhr();\n"; drawXhrJavascript(); print "</script>"; print "<script type=\"text/javascript\" src=\"" . XOOPS_URL . "/modules/formulize/libraries/jquery/jquery-1.4.2.min.js\"></script>\n"; print "<script type='text/javascript'>"; print "var elementStates = new Array();"; print "var savingNow = \"\";"; print "var elementActive = \"\";"; ?> function renderElement(handle,element_id,entryId,fid,check) { if(elementStates[handle] == undefined) { elementStates[handle] = new Array(); } if(elementStates[handle][entryId] == undefined) { if(elementActive) { // this is a bit cheap...we should be able to track multiple elements open at once. But there seem to be race condition issues in the asynchronous requests that we have to track down. This UI restriction isn't too bad though. alert("<?php print _formulize_CLOSE_FORM_ELEMENT; ?> "); return false; } elementActive = true; elementStates[handle][entryId] = jQuery("#deDiv_"+handle+"_"+entryId).html(); var formulize_xhr_params = []; formulize_xhr_params[0] = handle; formulize_xhr_params[1] = element_id; formulize_xhr_params[2] = entryId; formulize_xhr_params[3] = fid; formulize_xhr_send('get_element_html',formulize_xhr_params); } else { if(check && savingNow == "") { savingNow = true; jQuery("#deDiv_"+handle+"_"+entryId).fadeTo("fast",0.33); if(jQuery("[name='de_"+fid+"_"+entryId+"_"+element_id+"[]']").length > 0) { nameToUse = "[name='de_"+fid+"_"+entryId+"_"+element_id+"[]']"; } else { nameToUse = "[name='de_"+fid+"_"+entryId+"_"+element_id+"']"; } jQuery.post("<?php print XOOPS_URL; ?> /modules/formulize/include/readelements.php", jQuery(nameToUse+",[name='decue_"+fid+"_"+entryId+"_"+element_id+"']").serialize(), function(data) { if(data) { alert(data); } else { // need to get the current value, and then prep it, and then format it var formulize_xhr_params = []; formulize_xhr_params[0] = handle; formulize_xhr_params[1] = element_id; formulize_xhr_params[2] = entryId; formulize_xhr_params[3] = fid; formulize_xhr_send('get_element_value',formulize_xhr_params); } }); } else if(check) { // do nothing...only allow one saving operation at a time } else { jQuery("#deDiv_"+handle+"_"+entryId).html(elementStates[handle][entryId]); elementStates[handle].splice(entryId, 1); elementActive = ""; } } } function renderElementHtml(elementHtml,params) { handle = params[0]; element_id = params[1]; entryId = params[2]; fid = params[3]; jQuery("#deDiv_"+handle+"_"+entryId).html(elementHtml+"<br /><a href=\"\" onclick=\"javascript:renderElement('"+handle+"', "+element_id+", "+entryId+", "+fid+",1);return false;\"><img src=\"<?php print XOOPS_URL; ?> /modules/formulize/images/check.gif\" /></a> <a href=\"\" onclick=\"javascript:renderElement('"+handle+"', "+element_id+", "+entryId+", "+fid+");return false;\"><img src=\"<?php print XOOPS_URL; ?> /modules/formulize/images/x-wide.gif\" /></a>"); } function renderElementNewValue(elementValue,params) { handle = params[0]; element_id = params[1]; entryId = params[2]; fid = params[3]; jQuery("#deDiv_"+handle+"_"+entryId).fadeTo("fast",1); jQuery("#deDiv_"+handle+"_"+entryId).html(elementValue); elementStates[handle].splice(entryId, 1); savingNow = ""; elementActive = ""; } <?php } ?> window.document.controls.ventry.value = ''; window.document.controls.loadreport.value = ''; function warnLock() { alert('<?php print _formulize_DE_WARNLOCK; ?> '); return false; } function clearSearchHelp(formObj, defaultHelp) { if(formObj.firstbox.value == defaultHelp) { formObj.firstbox.value = ""; } } function showPop(url) { window.document.controls.ventry.value = ''; if (window.formulize_popup == null) { formulize_popup = window.open(url,'formulize_popup','toolbar=no,scrollbars=yes,resizable=yes,width=800,height=550,screenX=0,screenY=0,top=0,left=0'); } else { if (window.formulize_popup.closed) { formulize_popup = window.open(url,'formulize_popup','toolbar=no,scrollbars=yes,resizable=yes,width=800,height=550,screenX=0,screenY=0,top=0,left=0'); } else { window.formulize_popup.location = url; } } window.formulize_popup.focus(); } function confirmDel() { var answer = confirm ('<?php print _formulize_DE_CONFIRMDEL; ?> '); if (answer) { window.document.controls.delconfirmed.value = 1; window.document.controls.ventry.value = ''; showLoading(); } else { return false; } } function confirmClone() { var clonenumber = prompt("<?php print _formulize_DE_CLONE_PROMPT; ?> ", "1"); if(eval(clonenumber) > 0) { window.document.controls.cloneconfirmed.value = clonenumber; window.document.controls.ventry.value = ''; window.document.controls.forcequery.value = 1; showLoading(); } else { return false; } } function sort_data(col) { if(window.document.controls.sort.value == col) { var ord = window.document.controls.order.value; if(ord == 'SORT_DESC') { window.document.controls.order.value = 'SORT_ASC'; } else { window.document.controls.order.value = 'SORT_DESC'; } } else { window.document.controls.order.value = 'SORT_ASC'; } window.document.controls.sort.value = col; window.document.controls.ventry.value = ''; showLoading(); } function runExport(type) { window.document.controls.xport.value = type; window.document.controls.ventry.value = ''; showLoading(); } function showExport() { window.document.getElementById('exportlink').style.display = 'block'; } //Select All and Clear All new JQuery Function Instead the Javascript function selectAll(check) { $('.formulize_selection_checkbox').each(function(){ $('.formulize_selection_checkbox').attr('checked', true); }); } function unselectAll(uncheck) { $('.formulize_selection_checkbox').each(function(){ $('.formulize_selection_checkbox').attr('checked', false); }); } /* --------------------------------------- The selectall and clearall functions are based on a function by Vincent Puglia, GrassBlade Software site: http://members.aol.com/grassblad NOTE: MUST RETROFIT THIS SO IN ADDITION TO CHECKING TYPE, WE ARE CHECKING FOR 'delete_' in the name, so we can have other checkbox elements in the screen templates! ------------------------------------------- */ /* function selectAll(formObj) { for (var i=0;i < formObj.length;i++) { fldObj = formObj.elements[i]; if (fldObj.type == 'checkbox') { fldObj.checked = true; } } } function clearAll(formObj) { for (var i=0;i < formObj.length;i++) { fldObj = formObj.elements[i]; if (fldObj.type == 'checkbox') { fldObj.checked = false; } } } */ function delete_view(formObj, pubstart, endstandard) { for (var i=0; i < formObj.currentview.options.length; i++) { if (formObj.currentview.options[i].selected) { if( i > endstandard && i < pubstart && formObj.currentview.options[i].value != "") { var answer = confirm ('<?php print _formulize_DE_CONF_DELVIEW; ?> '); if (answer) { window.document.controls.delview.value = 1; window.document.controls.ventry.value = ''; showLoading(); } else { return false; } } else { if(formObj.currentview.options[i].value != "") { alert('<?php print _formulize_DE_DELETE_ALERT; ?> '); } return false; } } } } function change_view(formObj, pickgroups, endstandard) { for (var i=0; i < formObj.currentview.options.length; i++) { if (formObj.currentview.options[i].selected) { if(i == pickgroups && pickgroups != 0) { <?php print "showPop('" . XOOPS_URL . "/modules/formulize/include/changescope.php?fid={$fid}&frid={$frid}&scope={$currentview}');"; ?> return false; } else { if ( formObj.currentview.options[i].value == "" ) { return false; } else { window.document.controls.loadreport.value = 1; if(i <= endstandard && window.document.controls.lockcontrols.value == 1) { window.document.controls.resetview.value = 1; window.document.controls.curviewid.value = ""; } window.document.controls.lockcontrols.value = 0; window.document.controls.ventry.value = ''; showLoading(); } } } } } function addNew(flag) { if(flag=='proxy') { window.document.controls.ventry.value = 'proxy'; } else if(flag=='single') { window.document.controls.ventry.value = 'single'; } else { window.document.controls.ventry.value = 'addnew'; } window.document.controls.submit(); } function goDetails(viewentry, screen) { window.document.controls.ventry.value = viewentry; if(screen>0) { window.document.controls.overridescreen.value = screen; } window.document.controls.submit(); } function cancelCalcs() { window.document.controls.calc_cols.value = ''; window.document.controls.calc_calcs.value = ''; window.document.controls.calc_blanks.value = ''; window.document.controls.calc_grouping.value = ''; window.document.controls.hlist.value = 0; window.document.controls.hcalc.value = 1; window.document.controls.ventry.value = ''; showLoading(); } function customButtonProcess(caid, entries) { window.document.controls.caid.value = caid; window.document.controls.caentries.value = entries; showLoading(); } function hideList() { window.document.controls.hlist.value = 1; window.document.controls.hcalc.value = 0; window.document.controls.ventry.value = ''; showLoading(); } function showList() { window.document.controls.hlist.value = 0; window.document.controls.hcalc.value = 1; window.document.controls.ventry.value = ''; showLoading(); } function killSearch() { window.document.controls.asearch.value = ''; window.document.controls.ventry.value = ''; showLoading(); } function forceQ() { window.document.controls.forcequery.value = 1; showLoading(); } function showLoading() { window.document.controls.formulize_scrollx.value = jQuery(window).scrollTop(); window.document.controls.formulize_scrolly.value = jQuery(window).scrollLeft(); <?php if ($useWorking) { print "window.document.getElementById('listofentries').style.opacity = 0.5;\n"; print "window.document.getElementById('workingmessage').style.display = 'block';\n"; print "window.scrollTo(0,0);\n"; } ?> window.document.controls.ventry.value = ''; window.document.controls.submit(); } function showLoadingReset() { <?php if ($useWorking) { print "window.document.getElementById('listofentries').style.opacity = 0.5;\n"; print "window.document.getElementById('workingmessage').style.display = 'block';\n"; print "window.scrollTo(0,0);\n"; } ?> window.document.resetviewform.submit(); } function pageJump(page) { window.document.controls.formulize_LOEPageStart.value = page; showLoading(); } function getPaddingNumber(element,paddingType) { var value = element.css(paddingType).replace(/[A-Za-z$-]/g, "");; return value; } var floatingContents = new Array(); function toggleColumnInFloat(column) { jQuery('.column'+column).map(function () { var columnAddress = jQuery(this).attr('id').split('_'); var row = columnAddress[1]; if(floatingContents[column] == true) { jQuery('#floatingcelladdress_'+row+' #cellcontents_'+row+'_'+column).remove(); jQuery('#celladdress_'+row+'_'+column).css('display', 'table-cell'); jQuery(this).removeClass('now-scrolling'); } else { jQuery('#floatingcelladdress_'+row).append(jQuery(this).html()); var paddingTop = getPaddingNumber(jQuery(this),'padding-top'); var paddingBottom = getPaddingNumber(jQuery(this),'padding-bottom'); var paddingLeft = getPaddingNumber(jQuery(this),'padding-left'); var paddingRight = getPaddingNumber(jQuery(this),'padding-right'); jQuery('#floatingcelladdress_'+row+' #cellcontents_'+row+'_'+column).css('width', (parseInt(jQuery(this).width())+parseInt(paddingLeft)+parseInt(paddingRight))); jQuery('#floatingcelladdress_'+row+' #cellcontents_'+row+'_'+column).css('height', (parseInt(jQuery(this).height())+parseInt(paddingTop)+parseInt(paddingBottom))); jQuery(this).addClass('now-scrolling'); } }); if(floatingContents[column] == true) { floatingContents[column] = false; jQuery(this).removeClass("heading-locked").addClass("heading-unlocked"); } else { floatingContents[column] = true; } } function setScrollDisplay(element) { if(element.scrollLeft() > 0) { var maxWidth = 0; jQuery(".now-scrolling").css('display', 'none'); jQuery(".floating-column").css('display', 'table-cell'); } else { jQuery(".floating-column").css('display', 'none'); jQuery(".now-scrolling").css('display', 'table-cell'); } } jQuery(window).load(function() { jQuery('.lockcolumn').live("click", function() { var lockData = jQuery(this).attr('id').split('_'); var column = lockData[1]; if(floatingContents[column] == true) { jQuery(this).removeClass("heading-locked").addClass("heading-unlocked"); var curColumnsArray = jQuery('#formulize_lockedColumns').val().split(','); var curColumnsHTML = ''; for (var i=0; i < curColumnsArray.length; i++) { if(curColumnsArray[i] != column) { if(curColumnsHTML != '') { curColumnsHTML = curColumnsHTML+','; } curColumnsHTML = curColumnsHTML+curColumnsArray[i]; } } jQuery('#formulize_lockedColumns').val(curColumnsHTML); } else { jQuery(this).removeClass("heading-unlocked").addClass("heading-locked"); var curColumnsHTML = jQuery('#formulize_lockedColumns').val(); jQuery('#formulize_lockedColumns').val(curColumnsHTML+','+column); } toggleColumnInFloat(column); return false; }); jQuery(window).scrollTop(<?php print intval($_POST['formulize_scrollx']); ?> ); jQuery(window).scrollLeft(<?php print intval($_POST['formulize_scrolly']); ?> ); <?php foreach ($lockedColumns as $thisColumn) { if (is_numeric($thisColumn)) { print "toggleColumnInFloat(" . intval($thisColumn) . ");\n"; } } ?> jQuery('#resbox').scroll(function () { setScrollDisplay(jQuery('#resbox')); }); jQuery(window).scroll(function () { setScrollDisplay(jQuery(window)); }); var saveButtonOffset = jQuery('#floating-list-of-entries-save-button').offset(); saveButtonOffset.left = 15; floatSaveButton(saveButtonOffset); jQuery(window).scroll(function () { floatSaveButton(saveButtonOffset); }); }); function floatSaveButton(saveButtonOffset) { var scrollBottom = jQuery(window).height() - jQuery(window).scrollTop(); if (saveButtonOffset && (saveButtonOffset.top > scrollBottom || jQuery(window).width() < jQuery(document).width())) { jQuery('#floating-list-of-entries-save-button').addClass('save_button_fixed'); jQuery('#floating-list-of-entries-save-button').addClass('ui-corner-all'); if(saveButtonOffset.top <= scrollBottom) { jQuery('#floating-list-of-entries-save-button').css('bottom', jQuery(window).height() - saveButtonOffset.top - jQuery('#floating-list-of-entries-save-button').height()); } if(jQuery(window).scrollLeft() < saveButtonOffset.left) { newSaveButtonOffset = saveButtonOffset.left - jQuery(window).scrollLeft(); } else if(jQuery(window).scrollLeft() > 0){ newSaveButtonOffset = 0; } else { newSaveButtonOffset = saveButtonOffset.left; } jQuery('#floating-list-of-entries-save-button').css('left', newSaveButtonOffset); } else if(saveButtonOffset) { jQuery('#floating-list-of-entries-save-button').removeClass('save_button_fixed'); jQuery('#floating-list-of-entries-save-button').removeClass('ui-corner-all'); }; } jQuery(window).scroll(function () { jQuery('.floating-column').css('margin-top', ((window.pageYOffset)*-1)); }); </script> <?php }