/* ============================================================================= PLUGINS.JS Client: ANZ Author: Tim MacKay - Deloitte Digital ========================================================================== */ (function(window, document, $){ $.fn.setFieldsEnabled = function() { return toggle.call(this, false); }; $.fn.setFieldsDisabled = function() { return toggle.call(this, true); }; $.escapeSelector = function(str) { if (str === null || str === undefined) { return ''; } else { return str.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g,'\\$&'); } }; function toggle(disabledValue) { return this.each(function() { var $container = $(this); var fields = $container.find('input,select,textarea').not('":submit, :reset, :image'); fields.attr('disabled', disabledValue); }); } })(window, document, jQuery); /** * http://jquery.thewikies.com/browser/ */ (function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone|ipad)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery); /** * jQuery.accessibleTooltip - Accessible Tooltip Plugin. * Copyright (c) 2009-2012 Damian Keeghan - dkeeghan@deloitte.com.au * Date: 03/08/2012 * @author Damian Keeghan * @version 1.1 * */ (function($){ //creates an accessibleTooltip from an A tag $.fn.accessibleTooltip = function(options){ var defaults = { speed: 250, associateWithLabel: true, labelText: function(btn){ return $(btn).data('label'); }, helpPrefix: "Help text for", leftOffset: 13, topOffset: -10, preContent: "", buttonStyle: "tooltip-btn", tooltipStyle: "tooltip", isAbbr: false, onShow: function(btn, tooltipDiv){ $(tooltipDiv).animate({opacity: 1}, 0); if($.bgiframe){ $(tooltipDiv).bgiframe(); } }, maxWidth: 350 }; var options = $.extend(defaults, options); return this.each(function(i, el){ var aTooltip = $(this), label = (options.associateWithLabel) ? options.labelText($(aTooltip)) : "", helpText = $(aTooltip).attr("title"), tooltipID = 'tooltip_'+i; if(helpText==""){ $(aTooltip).remove(); } else { var tooltip; if(options.isAbbr){ $(aTooltip).removeAttr('title'); tooltip = $(aTooltip); } else { var buttonLabel = (typeof($(aTooltip).attr('data-tooltip-label')) == 'string') ? $(aTooltip).attr('data-tooltip-label') : options.helpPrefix+" "+label; $(aTooltip).after(""); tooltip = $(aTooltip).parent().find("button."+options.buttonStyle); $(aTooltip).remove(); } $(tooltip).data("isClicked", false); var tooltipContent = "
"; tooltipContent += options.preContent; tooltipContent += "
"; tooltipContent += (options.associateWithLabel) ? "

Help for "+label+"

" : ""; tooltipContent += "

"+helpText+"

"; tooltipContent += (options.associateWithLabel) ? "
End help
" : ""; tooltipContent += "
"; tooltipContent += "
"; $(tooltip).after(tooltipContent); var tooltipDiv = $(tooltip).parent().find("div."+options.tooltipStyle); $(tooltip).off("click").on("click", function(e){ e.preventDefault(); if($(tooltip).data("isClicked")==false){ $(tooltip).data("isClicked", true); setPosition(tooltip, tooltipDiv); if(options.speed==0){ $(tooltipDiv).show(); options.onShow($(aTooltip), $(tooltipDiv)); } else { $(tooltipDiv).fadeIn(options.speed, function(){ options.onShow($(aTooltip), $(tooltipDiv)); }); } } else { if(options.speed==0){ $(tooltipDiv).hide(); $(tooltip).data("isClicked", false); } else { $(tooltipDiv).fadeOut(options.speed, function(){ $(tooltip).data("isClicked", false); }); } } $('body').on('click.accessibleTooltip', function(event) { if (!$(event.target).closest('#'+tooltipID).length) { $(tooltip).trigger('click'); $('body').off('click.accessibleTooltip'); }; }); return false; }); $(tooltip).on("focus mouseover", function(){ if($(tooltip).data("isClicked")==false){ setPosition(tooltip, tooltipDiv); if(options.speed==0){ $(tooltipDiv).show(); options.onShow($(aTooltip), $(tooltipDiv)); } else { $(tooltipDiv).stop().fadeIn(options.speed, function(){ options.onShow($(aTooltip), $(tooltipDiv)); setPosition(tooltip, tooltipDiv); }); } } }); $(tooltip).on("blur mouseout", function(){ if($(tooltip).data("isClicked")==false){ if(options.speed==0){ $(tooltipDiv).hide(); } else { $(tooltipDiv).stop().fadeOut(options.speed); } } }); $(window).resize(function(){ if($(tooltip).data("isClicked")==true){ setPosition(tooltip, tooltipDiv); } }); } }); function setPosition(tooltip, tooltipDiv){ var tooltipDimensions = { top: $(tooltip).position().top, left: $(tooltip).position().left, width: $(tooltip).width(), height: $(tooltip).height() }, tooltipDivHeight = $(tooltipDiv).height(), tooltipDivWidth = $(tooltipDiv).width(), $tooltipContent = $(tooltipDiv).find('.content') // if ie6/7 if(typeof document.body.style.maxWidth !== 'undefined'){ var maxWidth = parseInt($tooltipContent.css('max-width'), 10); if(maxWidth>0 && $tooltipContent.width() > maxWidth){ $tooltipContent.width(maxWidth); } } //var tooltipDivLeftPos = (tooltipDimensions.left + tooltipDimensions.width + options.leftOffset); //var tooltipDivTopPos = tooltipDimensions.top + options.topOffset + $(tooltip).parents(".resultsWindow").scrollTop(); var tooltipDivLeftPos = (tooltipDimensions.left - tooltipDivWidth/2) + options.leftOffset; var tooltipDivTopPos = (tooltipDimensions.top ) - tooltipDivHeight + options.topOffset; $(tooltipDiv).css({top: tooltipDivTopPos, left: tooltipDivLeftPos}); } }; $.fn.resetAccessibleTooltip = function(options){ var defaults = { speed: 250, tooltipStyle: "tooltip" }; var options = $.extend(defaults, options); return this.each(function(){ var tooltip = $(this); var tooltipDiv = $(tooltip).parent().find("div."+options.tooltipStyle); if(options.speed==0){ $(tooltipDiv).hide(); $(tooltip).data("isClicked", false); } else { $(tooltipDiv).fadeOut(options.speed, function(){ $(tooltip).data("isClicked", false); }); } }); } })(jQuery); /** * jQuery.simpleSelect - Simple Select Plugin. * Copyright (c) 2009-2012 Damian Keeghan - dkeeghan@deloitte.com.au * https://github.com/dkeeghan/jQuery-SimpleSelect */ (function($){ $.simpleSelect = function(el, options){ var base = this; base.$el = $(el); base.el = el; //if the simpleSelect code hasn't already run if(typeof(base.$el.data('simpleSelect')) === 'undefined'){ base.$el.data('simpleSelect', base); base.init = function(){ // extend options base.options = $.extend({}, $.simpleSelect.defaultOptions, options); base.$el.wrap('').before('').css('opacity', 0); base.$container = base.$el.closest('.'+base.options.containerClass); base.$label = base.$container.find('.'+base.options.labelClass); if(base.options.slidingDoors){ base.$container.children().wrapAll(''); } base.$container.addClass(base.$el.attr('class')); //bind keyboard/mouse actions base.$el.on('change keyup', function(){ base.$el.trigger('updateLabel.simpleSelect'); }).on('focus', function(){ base.$container.addClass(base.options.focusClass); }).on('blur', function(){ base.$container.removeClass(base.options.focusClass); }).on('updateLabel.simpleSelect', function(){ base.$label.text(base.$el.find('option:selected').text()); }); //do initial label update base.$el.trigger('updateLabel.simpleSelect'); } //initialise base.init(); } } //default options $.simpleSelect.defaultOptions = { containerClass: 'simpleSelect', labelClass: 'simpleLabel', focusClass: 'focus', slidingDoors: true }; $.fn.simpleSelect = function(options){ return this.each(function(){ (new $.simpleSelect(this, options)); }); }; })(jQuery); /* * jQuery FormShowHide v0.1 * https://github.com/dkeeghan/jQuery-FormShowHide */ (function($){ $.formShowHide = function(el, options){ var base = this; base.$el = $(el); base.el = el; //if the simpleSelect code hasn't already run if(typeof(base.$el.data('formShowHide')) === 'undefined'){ // extend options base.options = $.extend({},$.formShowHide.defaultOptions, options); //setup base values base.$el.data('formShowHide', base); base.nodeType = base.el.nodeName.toUpperCase(); base.inputType = (base.nodeType === 'INPUT') ? base.$el.attr('type').toUpperCase() : ''; base.showType = ''; base.showParams = ''; //initialisation function base.init = function(){ var events = 'change.formShowHide keyup.formShowHide check.formShowHide initCheck.formShowHide'; if(base.nodeType === 'SELECT'){ base.$el.off('.formShowHide').on(events, base.onChange); } else if(base.nodeType === 'OPTION'){ base.$el.closest('select').off('.formShowHide').on(events, base.onChange); } else if(base.nodeType === 'INPUT'){ if(base.inputType === 'RADIO'){ var name = base.$el.attr('name'); $('input[name='+name+']').off('.formShowHide').on(events, base.onChange); } else if(base.inputType === 'CHECKBOX'){ base.$el.off('.formShowHide').on(events, base.onChange); } else if(base.inputType === 'TEXT'){ base.showType = base.$el.attr(base.options.show_type_attr); base.showParams = base.$el.attr(base.options.show_params_attr); if(base.showType && base.showParams){ base.showParams = base.convertStrToArr(base.showParams, true); } base.$el.off('.formShowHide').on(events, base.onChange); } } //do initial showhide check on page load base.$el.trigger('initCheck.formShowHide'); } //convert the id string from the element into a jQuery object base.convertStrToArr = function(str, isParam){ isParam = (typeof(isParam) === 'boolean' && isParam === true); str = str.replace(/ +(?= )/g,''); if(str === ''){ return []; } var arr = []; if(str.indexOf(' ') === -1){ arr.push((isParam) ? str : '#'+str); } else { var strs = str.split(' '); $(strs).each(function(i, el){ arr.push((isParam) ? el : '#'+el); }); } return (isParam) ? arr : $.fn.formShowHide.utils.unique(arr); } //check if the show/hide attribute is defined base.checkShowDefined = function($el){ var str = $el.attr(base.options.show_attr); return (typeof(str) === 'undefined') ? '' : str; } base.checkHideDefined = function($el){ var str = $el.attr(base.options.hide_attr); return (typeof(str) === 'undefined') ? '' : str; } //get the IDs to show that are referenced on the element base.idsToShow = function(){ var id = '' if(base.nodeType === 'SELECT' || base.nodeType === 'OPTION'){ var $select = (base.nodeType === 'OPTION') ? base.$el.parent() : base.$el; //show_attr should be shown if selected only id = base.checkShowDefined($select.find('option:selected')); //hide_attr should be shown if NOT selected only $select.find('option').each(function(i, el){ if(!$(el).attr('selected')){ id += ' ' + base.checkHideDefined($(el)); } }); } else if(base.nodeType === 'INPUT'){ if(base.inputType === 'RADIO'){ var name = base.$el.attr('name'); $('input[name='+name+']').each(function(i, el){ if($(el).attr('checked')){ id = base.checkShowDefined($(el)); } else { id += ' ' + base.checkHideDefined($(el)); } }); } else if(base.inputType === 'CHECKBOX'){ if(base.$el.attr('checked')){ id += ' ' + base.checkShowDefined(base.$el); } else { id += ' ' + base.checkHideDefined($(el)); } } else if(base.inputType === 'TEXT'){ if(base.showType && base.showParams){ if(typeof($.formShowHide.types[base.showType]) === 'function' && base.showParams.length > 0){ if($.formShowHide.types[base.showType](base.el, base.showParams)){ id = base.checkShowDefined(base.$el); } } } } } if(typeof(id) === 'undefined'){ //if there aren't any options provided; ignore; return []; } return base.convertStrToArr($.fn.formShowHide.utils.trim(id)); } //get the IDs that are related to the element, but should not be shown base.idsToHide = function(idsToShow){ var id = ''; if(base.nodeType === 'SELECT' || base.nodeType === 'OPTION'){ var $select = (base.nodeType === 'OPTION') ? base.$el.parent() : base.$el; //hide_attr should be hidden if selected only id = base.checkHideDefined($select.find('option:selected')); //show_attr should be hidden if NOT selected only $select.find('option').each(function(i, el){ if(!$(el).attr('selected')){ id += ' ' + base.checkShowDefined($(el)); } }); } else if(base.nodeType === 'INPUT'){ if(base.inputType === 'RADIO'){ var name = base.$el.attr('name'); $('input[name='+name+']').each(function(i, el){ if(!$(el).attr('checked')){ id += ' ' + base.checkShowDefined($(el)); } else { id += ' ' + base.checkHideDefined($(el)); } }); } else if(base.inputType === 'CHECKBOX'){ if(!base.$el.attr('checked')){ id += ' ' + base.checkShowDefined($(el)); } else { id += ' ' + base.checkHideDefined($(el)); } } else if(base.inputType === 'TEXT'){ if(base.showType && base.showParams){ if(typeof($.formShowHide.types[base.showType]) === 'function' && base.showParams.length > 0){ if(!$.formShowHide.types[base.showType](base.el, base.showParams)){ id = base.checkShowDefined(base.$el); } } } } } var idsToHide = base.convertStrToArr($.fn.formShowHide.utils.trim(id)); if(idsToShow.length === idsToHide.length && idsToShow.length === 1){ return idsToHide; } $(idsToShow).each(function(i, el){ for(var i in idsToHide){ if(idsToHide[i] === el){ idsToHide.splice(i,1); return; } } }); return idsToHide; } //on change of select element base.onChange = function(event){ var toShow = base.idsToShow(), toHide = base.idsToHide(toShow); if(toShow.length === toHide.length && $.fn.formShowHide.utils.compare(toShow, toHide)){ //don't show anything } else { $(toShow).each(function(i, el){ if(!$(el).is(':visible')){ if(event.type === 'initCheck'){ base.options.initShow(i, el); } else { base.options.show(i, el); } } else { base.options.showAlreadyVisible(i, el); } }); } $(toHide).each(function(i, el){ var afterHide = function(){ if($(el).hasClass(base.options.reset_class)){ //trigger keyup for validation, trigger check.formShowHide to trigger internal showhide functionality $(el).find('input:text').attr('value', '').trigger('keyup'); //reset selectboxes $(el).find('option:selected').attr('selected', false).end().find('option:first-child').attr('selected', true).trigger('check.formShowHide').trigger('keyup'); //reset radio/checkboxes $(el).find('input:radio, input:checkbox').attr('checked', false).trigger('check.formShowHide').trigger('keyup'); } } if(event.type === 'initCheck'){ base.options.initHide(i, el, afterHide); } else { base.options.hide(i, el, afterHide); } }); } //initialise base.init(); } } //showHide types $.formShowHide.types = { lessThan: function(elem, params){ var param = (typeof(parseInt(params[0], 10)) === 'number') ? parseInt(params[0], 10) : 0, val = ($(elem).val() === '') ? 0 : parseInt($(elem).val(), 10); return (val < param); } } //default options $.formShowHide.defaultOptions = { show: function(i, el, callback){ $(el).show(); if(typeof(callback) === 'function'){ callback(); } }, hide: function(i, el, callback){ $(el).hide(); if(typeof(callback) === 'function'){ callback(); } }, initShow: function(i, el, callback){ $(el).show(); if(typeof(callback) === 'function'){ callback(); } }, initHide: function(i, el, callback){ $(el).hide(); if(typeof(callback) === 'function'){ callback(); } }, showAlreadyVisible: function(i, el){ $(el).show(); }, show_attr: 'data-show-id', show_type_attr: 'data-show-type', show_params_attr: 'data-show-params', hide_attr: 'data-hide-id', reset_class: 'formShowHide_reset' }; $.fn.formShowHide = function(options){ return this.each(function(){ (new $.formShowHide(this, options)); }); }; $.fn.formShowHide.utils = { unique: function(array){ var i = 0; while (i < array.length){ for (k = array.length; k > i; k--){ if (array[k] === array[i]){ array.splice(k,1); } } i++; } return array; }, trim: function(string){ return string.replace(/^\s+/, '').replace(/\s+$/, ''); }, compare: function(arr1, arr2) { if (arr1.length != arr2.length) { return false; } var a = arr1.sort(), b = arr2.sort(); for (var i = 0; arr2[i]; i++) { if (a[i] !== b[i]) { return false; } } return true; } } })(jQuery); /*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * * Version 2.1.3-pre */ (function($){ $.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(s) { s = $.extend({ top : 'auto', // auto == .currentStyle.borderTopWidth left : 'auto', // auto == .currentStyle.borderLeftWidth width : 'auto', // auto == offsetWidth height : 'auto', // auto == offsetHeight opacity : true, src : 'javascript:false;' }, s); var html = '