// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project // // All Rights Reserved. See copyright.txt for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. // $Id$ (function ($) { $ = $.extend($, { profilesRefreshCache: function ( baseURI, entry ) { var datespan = $('#profile-date-' + entry); if ($('profile-status-' + entry + ' > span.icon-status-pending').is(':visible')) { return; } $('#profile-status-' + entry + ' > span.icon-status-pending').show(); $('#profile-status-' + entry + ' > span.icon-status-open').hide(); $('#profile-status-' + entry + ' > span.icon-status-closed').hide(); $.post(baseURI + '&refresh=' + escape(entry), function (result) { if (result.slice(0,1) !== '<') { var data = eval('(' + result + ')'); $.each(['open', 'pending', 'closed'], function (key, value) { if (value == data.status) { $('#profile-status-' + entry + ' > span.icon-status-' + value).show(); } else { $('#profile-status-' + entry + ' > span.icon-status-' + value).hide(); } }); datespan.html(data.lastupdate); } else { feedback(tr('Error loading page'), 'error'); } }) .fail(function () { feedback(tr('Error loading page'), 'error'); }); }, previewProfile: function (baseURI, domain, profile) { $('#preview-changes-' + profile).css('display', 'block'); var data = { pd: domain, pp: profile, install: true, dryrun: true, ajax: true }; $.post(baseURI, data, function (result) { var header = $(''); var footer = $(''); var content = $(''); header.html(''); footer.html(''); if (result.trim() != '') { content.html(result); } else { var info = $('
'); var infoTitle = $('

 ' + tr('Information') + '

'); var infoContent = $('

' + tr('Profile without changes') + '

'); info.append(infoTitle); info.append(infoContent); content.html(info); } $('#bootstrap-modal-2 .modal-content').empty(); $('#bootstrap-modal-2 .modal-content').append(header); $('#bootstrap-modal-2 .modal-content').append(content); $('#bootstrap-modal-2 .modal-content').append(footer); $('#bootstrap-modal-2').modal(); }) .fail(function () { feedback(tr('Error loading profile'), 'error'); }) .done(function () { $('#preview-changes-' + profile).css('display', 'none'); }); }, profilesShowDetails: function ( baseURI, id, domain, profile, event, show ) { var nid = id + "-sub"; var infoId = id + "-info"; var prev = $('#' + id); var obj = $('#' + infoId); if ( obj.length > 0 ) { obj.remove(); return; } var infoOb = $('') .css('font-style', 'italic') .css('margin-left', '15px'); prev.children('td').first().append(infoOb); infoOb.html("Loading profile..."); $.post(baseURI + '&getinfo&pd=' + escape(domain) + '&pp=' + escape(profile), function (result) { var data = eval("(" + result + ")"); var row = $(''); row.css('background-color', '#FFFFFF'); var cell = $(''); if ( data.installable || data.already ) { var pStep = $('

'); pStep.css('font-weight', 'bold'); if ( data.installable ) { pStep.html('Click on Apply Now to apply Profile'); } else if ( data.already ) { pStep.html('A version of this profile is already applied.'); } var form = $('
'); var ticket = $(''); form.append(ticket); var span = $('' + tr('Loading profile changes...') + ''); var submit = $(''); var submitPreview = $(''); cell.html(form); $(row).append(cell); var rowNum = 0; for (i in data.userInput) { if ( typeof(data.userInput[i]) != 'string' ) { continue; } var iRow = $('
'); var iLabel = $(''); var iDivField = $('
'); var iField = $(''); iDivField.html(iField); iRow.append(iLabel); iRow.append(iDivField); form.append(iRow); rowNum++; } if ( data.installable ) { submit.attr('name', 'install'); submit.attr('value', 'Apply Now'); submit.attr('class', 'btn btn-primary'); var msg = tr('Apply the profile') + ' ' + profile + '?'; submit.attr('onclick', 'confirmPopup("' + msg + '");'); } else if ( data.already ) { submit.attr('name', 'forget'); submit.attr('value', 'Forget and Re-apply'); submit.attr('class', 'btn btn-primary'); var msg = tr('Re-apply the profile') + ' ' + profile + '?'; submit.attr('onclick', 'confirmPopup("' + msg + '");'); } var divGroupButton = $('
'); var divButton = $('
'); if (rowNum > 0) { divButton.addClass('offset-lg-5'); } divButton.append(submit) divButton.append(submitPreview) divButton.append(span); divButton.append(pStep); divGroupButton.append(divButton); form.append(divGroupButton); var pd = $(''); pd.attr('name', 'pd'); pd.attr('value', domain); form.append(pd); var pp = $(''); pp.attr('name', 'pp'); pp.attr('value', profile); form.append(pp); } else if ( data.error ) { var p = $('

'); p.css('font-weight', 'bold'); p.html(tr("An error occurred during the profile validation. This profile cannot be applied.
Message: ") + data.error); cell.html(p); $(row).append(cell); } else { var p = $('

'); p.css('font-weight', 'bold'); p.html("An error occurred during the profile validation. This profile cannot be applied."); cell.html(p); $(row).append(cell); } if ( data.dependencies.length > 1 ) { var ul = $(''); for (k in data.dependencies) { if ( typeof(data.dependencies[k]) != 'string') { continue; } var li = $('
  • '); var a = $('' + data.dependencies[k] + ''); li.append(a); ul.append(li); } var p = $('

    These profiles will be applied:

    '); cell.append(p); cell.append(ul); } var body = $('
    '); body.css('height', '200px'); body.css('overflow', 'auto'); body.css('border', '2px solid black'); body.css('padding', '8px'); body.css('resize', 'both'); body.css('margin-top', '20px'); body.html(data.content); cell.append(body); $(row).insertAfter(prev); if (data.feedback.length) { alert("Profile issues: \n" + data.feedback); } }) .fail(function () { feedback(tr('Error loading profile'), 'error'); }) .done(function () { infoOb.html(''); }); } }); $(document).on('click', '#select_all_prefs_to_export', function () { if ($(this).is(':checked')) { $("#export_options_container input:visible:not(:checked)").click(); } else { $("#export_options_container input:visible:checked").click(); } }); $(document).on('change', '#export_type', function () { $(".profile_export_list").hide(); $("#" + $(this).val() + "_to_export_list").show(); }); $(document).on('click', '#export_show_added', function () { $(this)[0].form.submit(); }); $(document).on('change', '#repository, #categories', function () { if ($(this).val()) { $(".quickmode_notes").hide(400); } else { $(".quickmode_notes").show(400); } }); if ($("#profile-0").length > 0) { $(".quickmode_notes").hide(); $(window).scrollTop($("#step2").offset().top); } else { $(".quickmode_notes").show(); } }(jQuery));