JAVASCRIPT 37
Pe-ap.js Guest on 17th July 2020 11:20:48 AM
  1. /*!
  2.  * jQuery integration v1.3b1 / Intégration jQuery v1.3b1
  3.  * Web Experience Toolkit (WET) / Boîte à outils de l'expérience Web (BOEW)
  4.  * Terms and conditions of use: http://tbs-sct.ircan.gc.ca/projects/gcwwwtemplates/wiki/Terms
  5.  * Conditions régissant l'utilisation : http://tbs-sct.ircan.gc.ca/projects/gcwwwtemplates/wiki/Conditions
  6.  */
  7.  
  8. /** JavaScript / JQuery Capabilities with Name-spaced HTML **/
  9. var PE = {
  10.     progress: function(props){
  11.  
  12.            /** Page Language - is set by the Meta Data Element [ dc.language ] **/
  13.             PE.language =  this.find_language();
  14.            /** Page Language - end **/
  15.            /** JS Location - The browser helps set this up for us **/
  16.             PE.liblocation = jQuery("script[id='progressive']").attr('src').replace("pe-ap.js","");
  17.             /** JS Location - end **/
  18.             PE.uiloaded = false;
  19.             /** jquery ui load state **/
  20.  
  21.             /** Load mandatory supporting library and plugins features **/
  22.             PE.load('wet-boew.utils.js');
  23.             PE.load('wet-boew.skipnav.js');
  24.             PE.load('jquery.hotkeys.js');
  25.             PE.load('jquery.metadata.js');
  26.             PE.load('wet-boew.tooltips.js');
  27.  
  28.             /** Load supporting plugins **/
  29.                         PE.load('jquery.resize-events.js');
  30.             PE.load('wet-boew.pngfix.js');
  31.                         PE.load('wet-boew.storage.js');
  32.                        
  33.                         /** Load dialog plugin */
  34.                         PE.load('wet-boew.dialog.js');
  35.  
  36.                         PE.parameters = props /** DEPRECATED: Backward Compatibility **/ ;
  37.  
  38.                         for(key in PE.parameters) {
  39.                                 /** This is new functionality that will allow for plug-ins to be dynamically loaded per page
  40.                                  *  Approach : Parameters passed to be PE object are in a Key / Value pair
  41.                                  *  Data Model : Key - is the name of the property which will be the name of the plug-in file
  42.                                  *                 : Value - will be the parameters ( if any ) to pass to the plug-in main function
  43.                                  *  Notes : All methods will be fired on the Document.Ready JQuery to ensure proper DOM Loading
  44.                                  *  **/
  45.                                 var myPluginLoader = PE.liblocation+"plugins/wet-boew."+[key]+".js?";
  46.  
  47.                                 if ( typeof(PE.parameters[key]) == 'object' )
  48.                                 {
  49.                                         var nCount = 0;
  50.                                         for (var name in PE.parameters[key])
  51.                                         {
  52.                                                 var aMpersand = (nCount > 0 ) ? "&" : "" ;
  53.                                                 myPluginLoader += "" + aMpersand + name + "=" +  escape(PE.parameters[key][name]);
  54.                                                 ++nCount;
  55.                                         }
  56.                                 }else {
  57.                                         myPluginLoader += "id=" +  PE.parameters[key];
  58.                                 };
  59.                                 /** Append the script to the page DOM for autoloading ( Safari 2 & Opera 8 safe ) **/
  60.                                 document.write('<script type="text/javascript" src="'+myPluginLoader+'" id="wet-boew_plugin_'+[key]+'"><\/script>');
  61.                         }
  62.                        
  63.                         PE.load('wet-boew.equalheight.js');
  64.     },
  65.        
  66.         url : function(d){d=d||window.location.href;if(!/^\w+:/.test(d)){var e=document.createElement('img');e.src=d;d=e.src}var o={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","filename","query","anchor"],parser:{query:/(?:^|&)([^&=]*)=?([^&]*)/g,url:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)[email protected])?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var m=o.parser.url.exec(d);var f={};f.absolute=d;var i=14;while(i--)f[o.key[i]]=m[i]||"";f.parameter={};f[o.key[12]].replace(o.parser.query,function(a,b,c){if(b)f.parameter[b]=c});$.extend(true,f,{queryTokenized : (function(a){var b={};while(a[0]){var p = a.splice(0,1)[0].split("=");b[p[0]] = p[1];}return b;})(f.query.split("&")), pathTokenized : (f.path.split("/"))});return f},
  67.  
  68.     /** language definition function **/
  69.    find_language : function() {
  70.           // let try to find it in the HTML tag
  71.           if ( jQuery("html").attr('lang') ) // force en - fr normalization
  72.                 return ( jQuery("html").attr('lang').indexOf('en') == 0 ) ? 'eng' : 'fra' ;
  73.           // else lets try the metadata route // this should be safe enough to handle multilanguages
  74.           return jQuery("meta[name='dc.language'], meta[name='dcterms.language']").attr('content');
  75.    },
  76.  
  77.            /** Load Required Obligatory Scripts
  78.             *   Method: Brute force to ensure Safari 2 compatiblity
  79.             *   TODO: We may want to look at creator a more elegant Loader method
  80.             *             maybe through an ini file
  81.             *  **/
  82.  
  83.    load: function(jsSrc, jParam){
  84.         if (jParam){
  85.                 document.write('<script type="text/javascript" src="'+PE.liblocation+"lib/"+jsSrc+'?'+jParam+'"><\/script>');
  86.         }else {
  87.                 document.write('<script type="text/javascript" src="'+PE.liblocation+"lib/"+jsSrc+'"><\/script>');
  88.         }
  89.  
  90.     },
  91.  
  92.    load_ui: function(themeenabled){
  93.         // stop the ui from being loaded more than once
  94.          if (PE.uiloaded){ return true };
  95.  
  96.          var use_theme = (typeof(themeenabled)!='undefined') ? themeenabled : "use-theme";
  97.          /** load the jquery ui file **/
  98.          document.write('<script type="text/javascript" src="'+PE.liblocation +"lib/ui/jquery-ui.min.js"+'"><\/script>');
  99.  
  100.          if (use_theme != "no-theme") {
  101.          // load the default style
  102.          var $link = jQuery('<link rel="stylesheet" type="text/css" media="all" />').appendTo('head');
  103.  
  104.         $link.attr(
  105.         {
  106.                 href: PE.liblocation + "support/ui/themes/default/jquery-ui.css",
  107.                 rel: 'stylesheet',
  108.                 type: 'text/css',
  109.                 media: 'all'
  110.                 });
  111.          }
  112.          PE.uiloaded = true;
  113.      },
  114.  
  115.     /** Requested by User
  116.      *  - Suggestion :  http://tbs-sct.ircan.gc.ca/issues/796?lang=eng
  117.      ***********************/
  118.     loadExternal: function(jsSrc){
  119.          document.write('<script type="text/javascript" src="'+jsSrc+'"><\/script>');
  120.     },
  121.  
  122.     loadParams : function (name, plugin){
  123.         return jQuery("script[id='wet-boew_plugin_" + name + "']").attr('src');
  124.     }
  125. };
  126.  
  127.  
  128.  
  129.  
  130. $.extend(window, {cssEnabled : null});
  131.  
  132. $(document).ready(function() {
  133.         //Functionality to detect if CSS enabled at the browser level
  134.         cssTest = $("<div id=\"cssTest\" style=\"height:0px;\">&#160;</div>");
  135.         $("body").append(cssTest);
  136.         cssEnabled = cssTest.height() === 0;
  137.         $.extend(window, {cssEnabled : cssEnabled});
  138.         $("#cssTest").remove();
  139.        
  140.          //Set the metadata type (HTML5 or XHTML)
  141.         if (jQuery("html").attr("xml:lang")  == undefined || jQuery("html").attr("xml:lang")  == ""){
  142.                 jQuery.metadata.setType("html5");
  143.         }
  144. });

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.