$(document).ready(function () { new Toggle(); // Button with Dropdown List $(".button-dd").click(function (e) { e.stopPropagation(); var btnCt = $(this); var btn = btnCt.children('.button'); var menu = btnCt.children('ul'); if (btnCt.hasClass('open') == false) { btnCt.addClass('open'); btn.attr('aria-expanded', true); menu.attr('aria-hidden', false); $('html').bind('click.button-dd', function () { closeMenu(); }); } else { closeMenu(); } function closeMenu() { btnCt.removeClass('open'); btn.attr('aria-expanded', false); menu.attr('aria-hidden', true); $('html').unbind('click.button-dd'); } }); // Initialize SVG.DropDown if ($.isFunction($.fn.dropDown)) { $(".dropDown").dropDown(); } // @For: Field Instructions // @Usage: Add class to input of 'helper' or 'helper warn' and title for helper text $('input:text.helper,textarea.helper').each(function (index, el) { if ($(el).attr('title') != undefined && $(el).attr('title') != '') { var title = $(el).attr('title'); $(el).removeAttr('title'); var iconClass = $(el).hasClass('warn') ? "icon-warning" : "icon-info"; var helperClass = $(el).hasClass('bottom') ? "field-helper-bottom" : "field-helper"; var helper = $('
').attr('class', helperClass).text(title).appendTo($(el).parent()); var icon = $('').attr('class', iconClass).prependTo(helper); $(el).focus(function () { helper.fadeIn('fast'); }) .blur(function () { helper.hide(); }); } }); // @For: Making field readonly until user clicks Edit; confirm dialog optional //Usage: Add class to input of 'readOnly-editable'; optionally add dialog div with class 'readOnly-editable-dialog' after input $('input:text.readOnly-editable').each(function (index, el) { var val = $(el).val(); var buttonOnly = $(el).hasClass('buttonOnly'); if (val != "") { $(el).hide(); var alert = false; if ($(el).parent().find('.readOnly-editable-dialog').length > 0) { var confirm = $('.readOnly-editable-dialog').dialog({ autoOpen: false, dialogClass: 'dialog-alert', draggable: false, resizable: false }); alert = true; } var readOnlyCt = $('
').addClass('readOnly-editable-ct').hide(); var button = $('').text('Edit').addClass('button-small').click(function (e) { if (!alert) { showField(); } else { confirm.dialog('option', 'buttons', { "Ok": function () { $(this).dialog('close'); showField(); }, "Cancel": function () { $(this).dialog('close'); } }); confirm.dialog('open'); } function showField() { if (buttonOnly) { button.hide(); } else { readOnlyCt.hide(); } $(el).fadeIn(); } }); if (buttonOnly) { button.appendTo($(el).parent()); } else { readOnlyCt.prependTo($(el).parent()); $('').addClass('readOnly-editable-text').text(val).appendTo(readOnlyCt); button.appendTo(readOnlyCt); readOnlyCt.fadeIn(); } } }); // @For: Add helper text to any text field // @Usage: helperText($('#inputId'), 'Type Here', 'classToAdd'); helperText = function (textBoxInput, helperText, helperTextClass) { $(textBoxInput) .val(helperText) .addClass(helperTextClass) .focus(function () { if ($(this).hasClass(helperTextClass)) { $(this).val(""); $(this).removeClass(helperTextClass); } }) .blur(function () { if ($(this).val() == "") { $(this).addClass(helperTextClass); $(this).val(helperText); } }); } // Renders Radios into Toggle Buttons $('.radioButtons').buttonset(); $('.content-main').on('click', '.member-modal', function (e) { e.preventDefault(); var card = core.modal.init($('
'), { maxHeight: 760, content: $(this).attr('href'), refresh: function () { card.center(); } }).open(); }); /* show info modals */ $('.content-main').on('click', '.modal-info', function (e) { e.preventDefault(); var options = {}; if ($(this).attr('title')) { options.title = $(this).attr('title'); } core.modal.init($($(this).attr('href')), options).open(); }); });