{"version":3,"sources":["js/uc-alert.js"],"names":["$","Drupal","drupalSettings","cookies","alertFeedUrl","window","location","hostname","indexOf","replace","getJSON","data","length","alertId","alertTimestamp","prepend","site_alert","ucws_site_alert_id","ucws_site_alert_timestamp","ucws_site_alert_bgcolour","ucws_site_alert_message","ucws_site_alert_link","ucws_site_alert_date","ucws_site_alert_time","$siteAlert","addClass","alertCookieName","isAlertMinimized","get","isUserLoggedIn","user","uid","slideDown","removeClass","on","oneDayFromNow","Date","setTime","getTime","cookieDomain","set","expires","sameSite","secure","domain","slideToggle","this","toggleClass","jQuery","Cookies"],"mappings":"CAUA,SAAWA,EAAGC,EAAQC,EAAgBC,GACpC,aAgDA,IAAIC,EAAe,iDACfC,OAAOC,SAASC,SAASC,QAAQ,aAAe,EAClDJ,EAAeA,EAAaK,QAAQ,QAAS,YAEtCJ,OAAOC,SAASC,SAASC,QAAQ,YAAc,IACtDJ,EAAeA,EAAaK,QAAQ,gBAAiB,MAGvDT,EAAEU,QAAQN,GAAc,SAAUO,GAEhC,GAAIA,EAAKC,OAAQ,CAEf,IAKIC,EAAUF,EAAK,GAAuB,mBACtCG,EAAiBH,EAAK,GAA8B,0BACvCA,EAAK,GAA4B,wBAGlDX,EAAE,UAAUe,QA9DP,+CADcC,EA+DeL,EAAK,IA9DyBM,mBAA3D,+BAC8BD,EAAWE,0BADzC,eAEcF,EAAWG,yBAFzB,4fAuBgCH,EAAWI,wBAvB3C,8BAwB6BJ,EAAWK,qBAxBxC,uEA6B6BL,EAAWM,qBA7BxC,6BA8B6BN,EAAWO,qBA9BxC,6CAiEL,IAAIC,EAAaxB,EAAE,iBACnBA,EAAE,UAAWwB,GAAYC,SAAS,aAGlCzB,EAAE,QAAQyB,SAAS,cAGnB,IAAIC,EApBa,aAoBkBb,EAAUC,EAIzCa,EAvBe,yBAuBKxB,EAAQyB,IAAIF,GAChCG,OAA2C,IAAnB3B,QACK,IAAxBA,EAAe4B,WACa,IAA5B5B,EAAe4B,KAAKC,KAC3B7B,EAAe4B,KAAKC,IAAM,EAGvBJ,GAAqBE,IAGxB7B,EAAE,eAAgBwB,GAAYQ,YAC9BhC,EAAE,qBAAsBwB,GAAYS,YAAY,WAGhDjC,EAAE,qBAAsBwB,GAAYU,GAAG,SAAS,WAE9C,IAAIC,EAAgB,IAAIC,KACxBD,EAAcE,QAAQF,EAAcG,UAAY,OAEhD,IAAIC,EAAe,GACflC,OAAOC,SAASC,SAASC,QAAQ,gBAAkB,IACrD+B,EAAe,eAEjBpC,EAAQqC,IAAId,EA9CG,uBA8C4B,CACzCe,QAASN,EACTO,SAAU,OACVC,QAAQ,EACRC,OAAQL,QAMdvC,EAAE,qBAAsBwB,GAAYU,GAAG,SAAS,WAC9ClC,EAAE,eAAgBwB,GAAYqB,cAC9B7C,EAAE8C,MAAMC,YAAY,cAhH1B,IAAuB/B,KARzB,CA6HGgC,OAAQ/C,OAAQC,eAAgBG,OAAO4C","file":"uc-alert.js","sourcesContent":["/*\n * Ô°ÇøÒùÂÒ Global Alert\n *\n * This script requests alerts from /feeds/alerts (the\n * Global Alert originator), and inserts the alert message into the beginning\n * of the
when they are available.\n *\n * When someone minimizes the Alert, the script will set a 24hr snooze cookie.\n */\n\n(function ($, Drupal, drupalSettings, cookies) {\n 'use strict';\n\n /**\n * Generate the alert from template.\n *\n * @return string\n */\n function generateAlert(site_alert) {\n return '
' +\n '
' +\n '
' +\n '' +\n '
' +\n '
' +\n '
' +\n '
' +\n '

' +\n '' + site_alert.ucws_site_alert_message + ' ' +\n '' + site_alert.ucws_site_alert_link + '' +\n '

' +\n '
' +\n '
' +\n '

' +\n '' + site_alert.ucws_site_alert_date + '' +\n '' + site_alert.ucws_site_alert_time + '' +\n '

' +\n '
' +\n '
' +\n '
' +\n '
' +\n '
';\n }\n\n // Use the appropriate environment related feed url.\n var alertFeedUrl = 'https://live-ucalgary.ucalgary.ca/feeds/alerts';\n if (window.location.hostname.indexOf('staging-') > -1) {\n alertFeedUrl = alertFeedUrl.replace(/live-/, 'staging-');\n }\n else if (window.location.hostname.indexOf('.docker') > -1) {\n alertFeedUrl = alertFeedUrl.replace(/^.*:\\/\\/.+?\\//, '/');\n }\n\n $.getJSON(alertFeedUrl, function (data) {\n\n if (data.length) {\n // Cookie settings.\n var cookieName = 'ucws-alert';\n var cookieHidden = 'ucws-alert-dismissed';\n var eventCategory = 'Site Alert';\n\n // Grab our JSON data values.\n var alertId = data[0]['ucws_site_alert_id'];\n var alertTimestamp = data[0]['ucws_site_alert_timestamp'];\n var alertTitle = data[0]['ucws_site_alert_message'];\n\n // Add the alert to page.\n $('header').prepend(generateAlert(data[0]));\n\n // Newly added alert container.\n var $siteAlert = $('#global-alert');\n $('.link a', $siteAlert).addClass('read-more');\n\n // Add CSS so the alert is visible (initially minimized).\n $('body').addClass('site-alert');\n\n // Unique cookie name based on NID and saved/updated timestamp.\n var alertCookieName = cookieName + alertId + alertTimestamp;\n\n // Has the user seen this alert already and minimized it, or is\n // the user logged in (automatically close to access edit tabs)?\n var isAlertMinimized = (cookies.get(alertCookieName) === cookieHidden);\n var isUserLoggedIn = typeof drupalSettings !== 'undefined' &&\n typeof drupalSettings.user !== 'undefined' &&\n typeof drupalSettings.user.uid !== 'undefined' &&\n drupalSettings.user.uid > 0;\n\n // Maximize the alert.\n if (!isAlertMinimized && !isUserLoggedIn) {\n\n // Maximize the alert and change the tab to close button.\n $('.row.content', $siteAlert).slideDown();\n $('.row.controls .btn', $siteAlert).removeClass('btn-tab');\n\n // Set a cookie if the user minimizes the alert.\n $('.row.controls .btn', $siteAlert).on('click', function () {\n // Determine cookie expiry date.\n var oneDayFromNow = new Date();\n oneDayFromNow.setTime(oneDayFromNow.getTime() + (60 * 60 * 24000));\n // Determine the domain setting to allow site-wide dismiss.\n var cookieDomain = '';\n if (window.location.hostname.indexOf('ucalgary.ca') > -1) {\n cookieDomain = 'ucalgary.ca';\n }\n cookies.set(alertCookieName, cookieHidden, {\n expires: oneDayFromNow,\n sameSite: 'None',\n secure: true,\n domain: cookieDomain\n });\n });\n }\n\n // Initialize toggle function for the display of the alert.\n $('.row.controls .btn', $siteAlert).on('click', function () {\n $('.row.content', $siteAlert).slideToggle();\n $(this).toggleClass('btn-tab');\n });\n }\n });\n\n})(jQuery, Drupal, drupalSettings, window.Cookies);\n"]}