jQuery(document).ready(function($){ "use strict"; /** * Adding functionality for Upload input boxes in Custom Fields and Options * New Code (new media manager) * * IMPORTANT: Needs wp_enqueue_media(); anywhere in the theme to work in other * places than regular post editor. We are calling it as soon as we initiate the * QI Framework. * * Credit to: https://github.com/thomasgriffin/New-Media-Image-Uploader/blob/master/js/media.js */ // Prepare the variable that holds our custom media manager var qiMedia, qiMediaGallery; // For simple uploads jQuery(document).on('click', '.upload_file_button', function() { var thisButton = jQuery(this), uploadID = thisButton.prev('input'); qiMedia = wp.media.frames.qiMedia = wp.media({ frame: 'select', title: adminscripts_localized.mediaTitle, button: { text: adminscripts_localized.mediaButton }, }); qiMedia.on('select', function(){ // Grab our attachment selection and construct a JSON representation of the model. var media_attachment = qiMedia.state().get('selection').first().toJSON(); // Send the attachment URL to our custom input field via jQuery. uploadID.val( media_attachment.url ); }); qiMedia.open(); return false; }); // For Gallery Uploads jQuery(document).on('click', '.gallery_pick_button', function() { var thisButton = jQuery(this), uploadID = thisButton.prev('input'); qiMediaGallery = wp.media.frames.qiMediaGallery = wp.media({ frame: 'post', title: adminscripts_localized.mediaTitle, button: { text: adminscripts_localized.mediaButton }, }); qiMediaGallery.on( 'update', function(selection){ // Send the gallery shortcode to our custom input field via jQuery. uploadID.val( wp.media.gallery.shortcode( selection ).string() ); }); qiMediaGallery.open(); return false; }); /** * Adding functionality for repeatable input boxes */ jQuery('.repeatable-add').click(function() { var thisRepeat = jQuery(this), field = thisRepeat.closest('td').find('.custom_repeatable li:last').clone(true), fieldLocation = thisRepeat.closest('td').find('.custom_repeatable li:last'); // Reset new item, and increase index number for inputs jQuery('input, textarea, select', field).val('').attr('name', function(index, name) { if (name) { return name.replace(/(\d+)/, function(fullMatch, n) { return Number(n) + 1; }); } }); // Increase new item title index var index = parseInt( jQuery('.repeat-index', field).html() ); jQuery('.repeat-index', field).html(++index); // Insert newly added item in DOM field.insertAfter(fieldLocation, jQuery(this).closest('td')); return false; }); jQuery('.repeatable-remove').click(function(){ if ( jQuery('.custom_repeatable .fields-set').length != 1 ) { jQuery(this).parents('li').remove(); } else { // If there is only one set, just clean it up jQuery(this).parent().find('input').val(''); } return false; }); // Setting a variable var sortablePrevChecked; jQuery('.custom_repeatable').sortable({ opacity: 0.6, revert: true, cursor: 'move', handle: '.sort', start: function(event, ui) { sortablePrevChecked = ui.item.find('input:checked').val(); }, update: function(event, ui) { // Renumber Array indexes when re ordered jQuery('.custom_repeatable li .fields-set').each(function(rowIndex){ jQuery(this).find('input[name], textarea[name]').each(function(){ var selectName; selectName = jQuery(this).attr('name'); selectName = selectName.replace(/\[[0-9]+\]/g, '['+rowIndex+']'); jQuery(this).attr('name',selectName); // sortablePrevChecked.prop('checked', true); }); }); // alert(sortablePrevChecked); ui.item.find(':radio[value='+sortablePrevChecked+']').prop("checked", true); }, }); // Enable Fieldset Toggle jQuery('.custom_repeatable .fields-toggle').click(function(){ var thisToggle = jQuery(this); thisToggle.next('.fields-wrapper').slideToggle(); thisToggle.find('i').toggleClass('fa-flip-vertical'); }); // End repeatable section // Enables Color Picker for Admin Options jQuery('.quadropickcolor').click( function(e) { var colorPicker = jQuery(this).next('div'), input = jQuery(this).prev('input'); jQuery(colorPicker).farbtastic(input); colorPicker.children().show(); e.preventDefault(); jQuery(document).mousedown( function() { jQuery(colorPicker).children().hide(); jQuery('#bg-color').trigger('change'); }); }); /** * Post selection and pickers functionality */ var generalEditLink = jQuery('.qi-general-edit-link').val(), generalPostLink = jQuery('.qi-general-post-link').val(), selTemplate = jQuery('#page_template').val(), maybeIntPreview = selTemplate == 'template-modular.php' ? '&qi=internal-preview' : ''; // Enables Posts Select functionality in custom fields jQuery('.posts-adder').click(function(){ // Grab all selected var $selPosts = jQuery(this).prev('.posts-picker').find('option:selected'), $listContainer = jQuery(this).next(); // Map them and construct icon prefixed li's with Posts' ID as data-id $selPosts.map(function(){ // Get current posts list and check if current post is already there var $currentPosts = $listContainer.next().val().split(', '); if ( jQuery.inArray( jQuery(this).val(), $currentPosts ) == -1 ) { var thisId = jQuery(this).val(); // If it isn't, add it $listContainer.append('
  • '); } }); // Grabs current li's data IDs and puts them into the hidden field var $postsIds = ''; $listContainer.find('li').each(function(){ $postsIds += jQuery(this).data('id') + ', '; }); if ( $postsIds !== '' ) { $listContainer.next().val($postsIds); } }); // Enables Posts Select functionality in custom fields on double click jQuery('.posts-picker option').dblclick(function() { // Grab all selected + general edit link var $selPosts = jQuery(this), $listContainer = $selPosts.parent().siblings('ul'); // Map them and construct icon prefixed li's with Posts' ID as data-id $selPosts.map(function(){ // Get current posts list and check if current post is already there var $currentPosts = $listContainer.next().val().split(', '); if ( jQuery.inArray( jQuery(this).val(), $currentPosts ) == -1 ) { var thisId = jQuery(this).val(); // If it isn't, add it $listContainer.append('
  • '); } }); // Grabs current li's data IDs and puts them into the hidden field var $postsIds = ''; $listContainer.find('li').each(function(){ $postsIds += jQuery(this).data('id') + ', '; }); if ( $postsIds != '' ) { $listContainer.next().val($postsIds); } }); // Enables Posts Sorting in Posts Select fields jQuery('.sel-posts-container').sortable({ opacity: 0.6, revert: true, cursor: 'move', handle: '.li-mover', update: function (e, ui) { // Grabs current li's data IDs and puts them into the hidden field var $postsIds = ''; jQuery(this).find('li').each(function(){ $postsIds += jQuery(this).data('id') + ', '; }); jQuery(this).next().val($postsIds); } }); // Enables Remover for posts list items jQuery(document).on("click", '.remove-post', function(e){ // Grab parent variable position before we swipe this li out var $containerUl = jQuery(this).parents('ul'); // Remove this Parent li jQuery(this).parents('li').remove(); // Grabs current li's data IDs and puts them into the hidden field var $postsIds = ''; $containerUl.find('li').each(function(){ $postsIds += jQuery(this).data('id') + ', '; }); $containerUl.next().val($postsIds); }); // Removes empty select boxes when nothing to show jQuery('.posts-picker').each(function(){ if ( ! jQuery(this).find('option').length ) { jQuery(this).hide(); jQuery(this).next('.posts-adder').hide(); } }); /** * Handles selection boxes appearing when chosing selection methods */ // First, hide the selectors by default and show already chosen selector var allSelectors = jQuery('.qcustom-selector, .qtax-selector, .qformat-selector').parents('tr'); jQuery('select[id*=_method]').each(function(){ jQuery(this).parents('tr').siblings('tr').find('.qcustom-selector, .qtax-selector, .qformat-selector').parents('tr').hide(); jQuery(this).parents('tr').siblings('tr').find('.q' + jQuery(this).val() + '-selector').parents('tr').fadeIn(); }) // Then, detect change on selection method and show the proper select box jQuery('select[id*=_method]').change(function(){ jQuery(this).parents('tr').siblings('tr').find('.qcustom-selector, .qtax-selector, .qformat-selector').parents('tr').hide(); jQuery(this).parents('tr').siblings('tr').find('.q' + jQuery(this).val() + '-selector').parents('tr').fadeIn(); }) /** * Little handler to make Greyed Out custom fields take full width space */ jQuery('#quadro_page_greyed_out').parent('td').prev('th').hide(); /** * Ajax Function for Options Backup and Restore */ jQuery('#quadro_backup_button').live('click', function(){ var answerText = jQuery('#backup_confirm').val(), answer = confirm(answerText); if ( answer ) { var clickedObject = jQuery(this), clickedID = jQuery(this).attr('id'), nonce = jQuery('#quadro_nonce').val(); var data = { action: 'quadro_ajax_options_action', type: 'backup_options', security: nonce }; jQuery.post(ajaxurl, data, function(response) { //check nonce if( response == -1 ) { //failed } else { window.setTimeout(function(){ location.reload(); }, 1000); } }); } return false; }); //restore button jQuery('#quadro_restore_button').live('click', function(){ var answerText = jQuery('#restore_confirm').val(), answer = confirm(answerText); if ( answer ){ var nonce = jQuery('#quadro_nonce').val(); var data = { action: 'quadro_ajax_options_action', type: 'restore_options', security: nonce }; jQuery.post(ajaxurl, data, function(response) { //check nonce if( response == -1 ) { //failed } else { window.setTimeout(function(){ location.reload(); }, 1000); } }); } return false; }); /** * Select All Btn For Textareas */ jQuery('#quadro_select_button').live('click', function(){ jQuery(this).prev('textarea').select(); return false; }); /** * Ajax Transfer (Import/Export) Option */ jQuery('#quadro_import_button').live('click', function(){ var answerText = jQuery('#import_confirm').val(), answer = confirm(answerText); if ( answer ) { var nonce = jQuery('#quadro_nonce').val(); var import_data = jQuery('#export_data').val(); var data = { action: 'quadro_ajax_options_action', type: 'import_options', security: nonce, data: import_data }; jQuery.post(ajaxurl, data, function(response) { //check nonce if ( response == -1 ) { //failed } else { window.setTimeout(function(){ location.reload(); }, 1000); } }); } return false; }); /** * Ajax Dummy Content Install Option */ jQuery('#quadro_dcontent_button').live('click', function(){ var answerText = jQuery('#dcontent_confirm').val(), answerSuccess = jQuery('#dcontent_success').val(), answer = confirm(answerText); if ( answer ) { var nonce = jQuery('#quadro_nonce').val(), loaderImg = jQuery('.loader-icon'); loaderImg.fadeIn(); var data = { action: 'quadro_ajax_options_action', type: 'dcontent_import', security: nonce, }; jQuery.post(ajaxurl, data, function(response) { //check nonce if ( response == -1 ) { // Failed loaderImg.fadeOut(); alert(adminscripts_localized.importFail); } else { loaderImg.fadeOut(function(){ var answerSuccessResp = confirm(answerSuccess); if (answerSuccessResp){ window.setTimeout(function(){ location.reload(); }, 1000); } }); } }); } return false; }); /** * Ajax Function for QuadroIdeas.com User check */ jQuery('#quadro_user_check').live('click', function(){ var nonce = jQuery('#quadro_nonce').val(); var data = { action: 'quadro_ajax_options_action', type: 'user_check', security: nonce }; jQuery.post(ajaxurl, data, function(response) { alert(response); }); return false; }); /** * Ajax Portfolio Transients Delete Option */ jQuery('#quadro_portf_transients_delete_button').live('click', function(){ var nonce = jQuery('#quadro_nonce').val(); var data = { action: 'quadro_ajax_options_action', type: 'portfolio_transients_delete', security: nonce, }; jQuery.post(ajaxurl, data, function(response) { //check nonce if ( response == -1 ) { //failed } else { alert(adminscripts_localized.portfTransientsRefreshed); } }); return false; }); /** * Ajax Set Skin Option */ jQuery('#quadro_skin_button').live('click', function(){ var answerText = jQuery('#skin_confirm').val(), answer = confirm(answerText); if (answer){ var nonce = jQuery('#quadro_nonce').val(); var sel_option = jQuery('.skin-select-radio:checked').val(); var selected_skin = jQuery.parseJSON(jQuery('#'+sel_option+'-skin').val()); var data = { action: 'quadro_ajax_options_action', type: 'set_skin', security: nonce, data: selected_skin }; jQuery.post(ajaxurl, data, function(response) { //check nonce if(response==-1){ //failed } else { alert(response); window.setTimeout(function(){ location.reload(); }, 1000); } }); } return false; }); // Show or Hide Modules Metaboxes depending on Selected Modules // Add Module type to body class // ************************************************************ if ( jQuery('#mod-type-metabox').length ) { var moduleSelector = jQuery('#quadro_mod_type'); // First, get selected type on loading and display metabox var selType = moduleSelector.val(); // Show or Hide Metabox jQuery('#mod-' + selType + '-qi-type-metabox').addClass('selected-type-metabox'); // Add module class to body jQuery('body').addClass('qimodule-' + selType); // Reset Shown Module on change moduleSelector.change(function(){ var selType = moduleSelector.val(); // Show or Hide Metabox jQuery('.selected-type-metabox').fadeOut().removeClass('selected-type-metabox'); jQuery('#mod-' + selType + '-qi-type-metabox').fadeIn().addClass('selected-type-metabox').removeClass('tab-hidden'); // Add module class to body jQuery('body').alterClass('qimodule-*').addClass('qimodule-' + selType); // Scroll to editor if Canvas selected if ( selType == 'canvas' ) { // jQuery('html, body').animate({scrollTop: 0}, 600); jQuery('html, body').animate({ scrollTop: jQuery('#postdivrich').offset().top-20 }, 800); } }); } // Show or Hide Specific Theme Options depending on selected theme options // ************************************************************ function showHideFields() { // Function to loop through all hidden fields and show/hide if conditions met jQuery('*[data-hide="hideme"]').each(function(){ var showConditions = jQuery(this).data('if'), conditionsCount = showConditions.length; jQuery.each(showConditions, function(index, item) { if ( jQuery('[name$="['+item['id']+']"]'+item['type']).val() == item['val'] ) conditionsCount = conditionsCount - 1; }); // We substracted 1 per each met condition, so we'll // show the option field if the count has reached 0. // Hide it, if the count isn't 0. if ( conditionsCount == 0 ) { jQuery(this).parents('tr').fadeIn('fast'); } else { jQuery(this).parents('tr').hide(); } }); } // Show or hide fields if conditions met showHideFields(); // Trigger conditions check once form changes jQuery('#quadro_options_form').change(function(){ showHideFields(); }) // Show or Hide Template Metaboxes depending on Selected Template // ************************************************************ if ( jQuery('#page_template').length ) { // First, get selected type on loading and display metabox var selTemplate = jQuery('#page_template').val(); // Hide editor for Modular Template if ( selTemplate == 'template-modular.php' ) jQuery('#postdivrich').hide(); // Present according option metaboxes selTemplate = selTemplate.substring(selTemplate.indexOf('-') +1).split('.'); jQuery('#' + selTemplate[0] + '-qi-template-metabox').addClass('selected-template-metabox'); // Reset Shown Module on change jQuery("#page_template").live('change',function(){ var selTemplate = jQuery(this).val(); // Hide or show editor for Modular Template if ( selTemplate == 'template-modular.php' ) { jQuery('#postdivrich').hide(); } else { jQuery('#postdivrich').show(); } // Present according option metaboxes selTemplate = selTemplate.substring(selTemplate.indexOf('-') +1).split('.'); jQuery('.selected-template-metabox').removeClass('selected-template-metabox'); jQuery('#' + selTemplate[0] + '-qi-template-metabox').addClass('selected-template-metabox'); }); } // Togles Pattern Selector display in Custom Fields jQuery('#pattern-picker-opener').click(function(){ jQuery('#pattern-selector').toggle(); }); // Opens Colorbox Lightbox for Icon Picker jQuery('.icon-picker-opener').live('click', function() { var thisHandler = jQuery(this), thisPicker = thisHandler.next().find('.icons-wrapper'); jQuery.colorbox({ width: '60%', height: '80%', close: '', inline: true, href: thisPicker, onComplete: function(){ // Adds focus on icon search when opening icon selector jQuery('.icon-search').focus(); }, onCleanup: function(){ if ( thisPicker.find('.icon-selector input:checked + i').attr('class') ) { // Adds copy of selected icon to Working Fields (input + icon placeholder) thisHandler.prev('i').attr('class', 'icon-placeholder ' + thisPicker.find('.icon-selector input:checked + i').attr('class')); thisHandler.siblings('input').val(thisPicker.find('.icon-selector input:checked + i').attr('class')); } }, }); }); // Enable Icon Picker opening when clicking // on selected icon jQuery('.icon-placeholder').click(function(){ jQuery(this).next('a').click(); }); // Make the icon picker close on double clicks over icons jQuery('.icon-selector i').dblclick(function() { jQuery.colorbox.close(); }); // Responds to Icon Search for Icon Picker jQuery('.icon-search').keyup(function(){ var iSearcher = jQuery(this), iSearch = iSearcher.val(), iPicker = iSearcher.parent().next('.icon-selector'); // Hide all labels to begin with iPicker.find('h3, label').hide(); // Show Icons which contain the searched terms var iShow = iPicker.find('i[class*="' + iSearch + '"]'); iShow.parent().show(); iShow.parent().parent().prev('h3').show(); // Show all if search empty if ( iSearch == '' ) iPicker.find('h3, label').show(); }); /** * Adds Portfolio Sortable Functionality in backend */ jQuery('#sortable-table tbody').sortable({ axis: 'y', handle: '.draggable', placeholder: 'ui-state-highlight', forcePlaceholderSize: true, update: function(event, ui) { var theOrder = jQuery(this).sortable('toArray'); var data = { action: 'quadro_update_portfolio_order', postType: jQuery(this).attr('data-post-type'), order: theOrder }; jQuery.post(ajaxurl, data); jQuery('.order-updated').fadeTo('slow', 1).animate({opacity: 1.0}, 600).fadeTo('slow', 0); } }).disableSelection(); // Dismisses Welcome Panel message jQuery('.welc-msg-dismiss').click(function(){ jQuery('#qi-welcome-panel').fadeOut(); return false; }); /** * Handling Mailchimp Form Option-Cookies to avoid * showing it again after the user has already * submitted the form once successfully. */ if ( jQuery('#mc_embed_signup').length ) { var mcForm = document.getElementById('mce-success-response'); if( window.addEventListener ) { // Normal browsers mcForm.addEventListener('DOMSubtreeModified', mailchimpSent, false); } else if ( window.attachEvent ) { // IE mcForm.attachEvent('DOMSubtreeModified', mailchimpSent); } } function mailchimpSent() { // Store cookie for this user stating it has already // submitted the form once successfully var nonce = jQuery('#mailchimp_nonce').val(); var data = { action: 'quadro_mailchimp_submit_check', security: nonce }; // Call function via ajax jQuery.post(ajaxurl, data, function(response) {}); } // Adding 'internal-preview' parameter to Modules Preview button if ( jQuery('body').hasClass('post-type-quadro_mods') ) { if ( jQuery('#view-post-btn').length ) { var currentPreview = jQuery('#view-post-btn a').attr('href'); // Match with ? or & for previous parameters if ( currentPreview.indexOf('?') >= 0 ) { var parmSign = '&'; } else { var parmSign = '?'; } jQuery('#view-post-btn a, #message.updated a').attr('href', currentPreview + parmSign + 'qi=internal-preview'); } if ( jQuery('.row-actions').length ) { var currentView, parameterSign, thisPreviewLink; jQuery('.row-actions .view a').each(function(){ thisPreviewLink = jQuery(this); currentView = thisPreviewLink.attr('href'); // Match with ? or & for previous parameters if ( currentView.indexOf('?') >= 0 ) { parameterSign = '&'; } else { parameterSign = '?'; } thisPreviewLink.attr('href', currentView + parameterSign + 'qi=internal-preview'); }); } } /** * Adding "Add to Page" & "Duplicate" links to Module Type select metabox */ jQuery('#mod-type-metabox').find('td').append('
    '); jQuery('.module-helpers').append(''+ adminscripts_localized.addThisModule +''); jQuery('.module-helpers').append(''+adminscripts_localized.dupThisModule +''); /** * Modify add to page button if module already published */ if ( jQuery('#original_post_status').val() == 'publish' ) { jQuery('.in-mod-addto-page').removeClass('in-mod-addto-page').addClass('in-mod-addto-page-publish'); } /** * Ask for module publishing before enabling add to page functionality */ jQuery(document).on( 'click', '.in-mod-addto-page', function(e){ e.preventDefault(); alert(adminscripts_localized.publishFirst); }); /** * Handling "Add this Module to Page" */ jQuery('.in-mod-addto-page-publish').colorbox({ width: '60%', height: '80%', close: '', inline: true, onComplete: function(){ // Grab previously loaded content if there is one var prevLoaded = jQuery('#already-loaded').val(); if ( prevLoaded == undefined ) { // Run first Ajax function var data = { action: 'qi_ajax_module_adder' }; jQuery.post(ajaxurl, data, function(response) { if( response != -1 ) { jQuery('#qi-page-adder').html(response); // Set previously loaded content jQuery('#already-loaded').val('loaded'); } }); } }, }); jQuery(document).on( 'change', '#qi-modular-pages', function(){ var data = { action: 'qi_ajax_module_fields', page_id: jQuery(this).val(), mod_id: jQuery('#post_ID').val(), }; jQuery.post(ajaxurl, data, function(response) { if( response != -1 ) { jQuery('.qi-page-modules').html(response); jQuery('.added-module').fadeIn(); // Enables Posts Sorting in Posts Select fields jQuery('.sel-posts-container').sortable({ opacity: 0.6, revert: true, cursor: 'move', handle: '.li-mover', update: function (e, ui) { // Grabs current li's data IDs and puts them into the hidden field var $postsIds = ''; jQuery(this).find('li').each(function(){ $postsIds += jQuery(this).data('id') + ', '; }); jQuery(this).next().val($postsIds); } }); } }); }); jQuery(document).on( 'click', '#page-mods-save', function(e){ e.preventDefault(); var data = { action: 'qi_ajax_module_save', page_id: jQuery('#qi-modular-pages').val(), mods_list: jQuery('#modules-to-save').val(), }; jQuery.post(ajaxurl, data, function(response) { if( response != -1 ) { jQuery('.saved-mods-receiver').html(response).fadeIn(); } }); }); }); /** * jQuery alterClass plugin * https://gist.github.com/peteboere/1517285 * * Remove element classes with wildcard matching. Optionally add classes: * $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' ) * * Copyright (c) 2011 Pete Boere (the-echoplex.net) * Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php * */ (function ( $ ) { $.fn.alterClass = function ( removals, additions ) { var self = this; if ( removals.indexOf( '*' ) === -1 ) { // Use native jQuery methods if there is no wildcard matching self.removeClass( removals ); return !additions ? self : self.addClass( additions ); } var patt = new RegExp( '\\s' + removals. replace( /\*/g, '[A-Za-z0-9-_]+' ). split( ' ' ). join( '\\s|\\s' ) + '\\s', 'g' ); self.each( function ( i, it ) { var cn = ' ' + it.className + ' '; while ( patt.test( cn ) ) { cn = cn.replace( patt, ' ' ); } it.className = $.trim( cn ); }); return !additions ? self : self.addClass( additions ); }; })( jQuery ); /*! Colorbox 1.6.0 license: MIT http://www.jacklmoore.com/colorbox */ (function(t,e,i){function n(i,n,o){var r=e.createElement(i);return n&&(r.id=Z+n),o&&(r.style.cssText=o),t(r)}function o(){return i.innerHeight?i.innerHeight:t(i).height()}function r(e,i){i!==Object(i)&&(i={}),this.cache={},this.el=e,this.value=function(e){var n;return void 0===this.cache[e]&&(n=t(this.el).attr("data-cbox-"+e),void 0!==n?this.cache[e]=n:void 0!==i[e]?this.cache[e]=i[e]:void 0!==X[e]&&(this.cache[e]=X[e])),this.cache[e]},this.get=function(e){var i=this.value(e);return t.isFunction(i)?i.call(this.el,this):i}}function h(t){var e=W.length,i=(A+t)%e;return 0>i?e+i:i}function a(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():o())/100:1)*parseInt(t,10))}function s(t,e){return t.get("photo")||t.get("photoRegex").test(e)}function l(t,e){return t.get("retinaUrl")&&i.devicePixelRatio>1?e.replace(t.get("photoRegex"),t.get("retinaSuffix")):e}function d(t){"contains"in y[0]&&!y[0].contains(t.target)&&t.target!==v[0]&&(t.stopPropagation(),y.focus())}function c(t){c.str!==t&&(y.add(v).removeClass(c.str).addClass(t),c.str=t)}function g(e){A=0,e&&e!==!1&&"nofollow"!==e?(W=t("."+te).filter(function(){var i=t.data(this,Y),n=new r(this,i);return n.get("rel")===e}),A=W.index(_.el),-1===A&&(W=W.add(_.el),A=W.length-1)):W=t(_.el)}function u(i){t(e).trigger(i),ae.triggerHandler(i)}function f(i){var o;if(!G){if(o=t(i).data(Y),_=new r(i,o),g(_.get("rel")),!$){$=q=!0,c(_.get("className")),y.css({visibility:"hidden",display:"block",opacity:""}),I=n(se,"LoadedContent","width:0; height:0; overflow:hidden; visibility:hidden"),b.css({width:"",height:""}).append(I),j=T.height()+k.height()+b.outerHeight(!0)-b.height(),D=C.width()+H.width()+b.outerWidth(!0)-b.width(),N=I.outerHeight(!0),z=I.outerWidth(!0);var h=a(_.get("initialWidth"),"x"),s=a(_.get("initialHeight"),"y"),l=_.get("maxWidth"),f=_.get("maxHeight");_.w=(l!==!1?Math.min(h,a(l,"x")):h)-z-D,_.h=(f!==!1?Math.min(s,a(f,"y")):s)-N-j,I.css({width:"",height:_.h}),J.position(),u(ee),_.get("onOpen"),O.add(S).hide(),y.focus(),_.get("trapFocus")&&e.addEventListener&&(e.addEventListener("focus",d,!0),ae.one(re,function(){e.removeEventListener("focus",d,!0)})),_.get("returnFocus")&&ae.one(re,function(){t(_.el).focus()})}var p=parseFloat(_.get("opacity"));v.css({opacity:p===p?p:"",cursor:_.get("overlayClose")?"pointer":"",visibility:"visible"}).show(),_.get("closeButton")?B.html(_.get("close")).appendTo(b):B.appendTo("
    "),w()}}function p(){y||(V=!1,E=t(i),y=n(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),v=n(se,"Overlay").hide(),M=t([n(se,"LoadingOverlay")[0],n(se,"LoadingGraphic")[0]]),x=n(se,"Wrapper"),b=n(se,"Content").append(S=n(se,"Title"),F=n(se,"Current"),P=t('