$(document).on("pageshow", "#LoginPage", function() { $('.login_feedback').delay(3000).fadeOut(700); $('.bttn_reset').click(function() { $('.login_feedback').hide(); }); var now = new Date() var offset = now.getTimezoneOffset(); $('#jsoffset').val(offset); }); $(document).on("pageshow", "#ReadMessagePage", function() { // polyfill for scoped styles var isIE = !!navigator.userAgent.match(/MSIE/); var isOpera = !!navigator.userAgent.match(/Opera/); if (!isIE && !isOpera) { $.scoped(); } }); $(document).on("pageshow", "#ContactsPage", function() { $('#SearchFilter').bindWithDelay('keyup input propertychange change', function() { $('#ContactsList').load('ContactsList.aspx?filter=' + $('#SearchFilter').val(), function() { $(this).trigger('create'); }); }, 1000); }); // // Element type // var ELEMENT_NODE_TYPE = 1; var ATTRIBUTE_NODE_TYPE = 2; var TEXT_NODE_TYPE = 3; var CDATA_SECTION_NODE_TYPE = 4; var DOCUMENT_NODE_TYPE = 9 function GetXMLValue(oNode) { if (!oNode) { return ''; } if (oNode.nodeType == TEXT_NODE_TYPE) { return oNode.nodeValue; } else if (oNode.firstChild && oNode.firstChild.nodeType == TEXT_NODE_TYPE) { return oNode.firstChild.nodeValue; } try { if (oNode.firstChild) return oNode.firstChild.nodeValue; else { if (oNode.nodeValue) { return oNode.nodeValue; } else { return ''; } } } catch (e) { try { if (oNode.nodeValue) return oNode.nodeValue; // for ie else return ''; } catch (e) { return ''; } } } function getAttrString(BaseNode, sTag) { if (BaseNode != null) { return GetXMLValue(BaseNode.attributes.getNamedItem(sTag)); } return ''; } function getNodeString(BaseNode, sTag) { if (BaseNode != null) { return GetXMLValue(BaseNode.getElementsByTagName(sTag)[0]); } return ''; } function ProcessMailCheckResult(responseXML) { try { var BaseNode = responseXML.getElementsByTagName("BASEELEMENT")[0]; if (BaseNode != null) { var sRV = getNodeString(BaseNode, 'RETURNVALUE'); var iState = parseInt(getNodeString(BaseNode, 'STATE')); var iNewMessageCount = parseInt(getNodeString(BaseNode, 'NEWMESSAGECOUNT')); if ((location.href.toLowerCase().indexOf('messagelist.aspx') > -1) && ((iNewMessageCount > 0) || (iState == 1))) { location.href = 'MessageList.aspx?TD=' + (new Date()).getTime(); ; } } } catch (ex) { if (window.console) { console.log('ProcessMailCheckResult: Parser error'); } } } function LaunchNewMailChecker() { setTimeout(CheckForNewMail, 30000); //wait for 30 seconds before we ask } function split(val) { return val.split(/,\s*/); } function extractLast(term) { return split(term).pop(); } function clearComposeControls() { //enable fields $("#Body").val(''); $("#ToRecipients").val(''); $("#BccRecipients").val(''); $("#CcRecipients").val(''); $("#Subject").val(''); //enable send and save buttons $('#jsSend').button('enable'); $('#jsSave').button('enable'); } function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } $(document).on("pageshow", "#ComposePage", function (event) { // clear the form whenever we show the compose page if (typeof clearUploadSelector !== 'undefined') { try { clearUploadSelector(); } catch (ex) {} } var sMode = getParameterByName('Mode', window.location); if (sMode == null) { sMode = ''; } else { sMode = sMode.toLowerCase(); } if (sMode == 'compose' || sMode == '') { clearComposeControls() } }); $(document).on("pageinit", "#ComposePage", function (event) { $('#ToRecipients, #CcRecipients, #BccRecipients').bind('keydown', function (event) { // Don't navigate away from the field on tab when selecting an item. if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) { event.preventDefault(); } }).autocomplete( { delay: 1000, appendTo: '#ComposeAutoComplete', source: function (request, response) { $.getJSON("ComposeSuggestions.aspx", { term: extractLast(request.term) }, response); }, messages: { noResults: '', results: function () { } }, search: function () { // custom minLength var term = extractLast(this.value); if (term.length < 3) { return false; } }, focus: function () { // prevent value inserted on focus return false; }, select: function (event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end terms.push(""); var sParsed = terms.join(", "); if (endsWith(sParsed,", ")) { sParsed = sParsed.substring(0, sParsed.length - 2); } this.value = sParsed; return false; } }).each(function () { $(this).data('ui-autocomplete')._renderItem = function (ul, item) { var $a = $('').attr({ href: '#' }).html(item.label); var $item = $('
  • ').data('item.ui-autocomplete', item).append($a).appendTo(ul); // jQuery Mobile enhancement. if (ul.attr('data-role') != 'listview') { ul.attr({ 'data-role': 'listview', 'data-inset': 'true' }).listview(); } else { ul.listview('refresh'); } // We have to bind to the click event to activate the clicked item, because the jQuery ui menu widget has // strange activation behaviour, relying on mouseenter event instead of the click, which presumably will not // work on a touch screen. In any case, it also assumes a structure to the list items, which does not match // what jQuery Mobile does with its enhancements. $item.click(function (event) { // ul.menu('activate', event, $item); ul.menu('focus', event, $item); // hide the helper once we click (presumably the activate event used to do this) $('.ui-helper-hidden-accessible').hide(); }); return $item; }; }); function endsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } /* $("#defaultpanel").on("panelopen", function (event, ui) { //setting overflow : hidden and binding "touchmove" with event which returns false $('body').css("overflow", "hidden").on("touchmove", stopScroll); }); $("#defaultpanel").on("panelclose", function (event, ui) { //remove the overflow: hidden property. Also, remove the "touchmove" event. $('body').css("overflow", "auto").off("touchmove"); }); function stopScroll() { return false; } */ //end functions }); $(document).on("pageshow", "#AppointmentDetailsPage", function() { $('#StartDate').bind('datebox', function(e, passed) { if (passed.method == 'close') { var start = $('#StartDate').datebox('getTheDate'); var end = $('#EndDate').datebox('getTheDate'); if (start > end) { $('#EndDate').val($('#StartDate').val()); } } }); });