1/************************************************************************* 2* 3* ADOBE SYSTEMS INCORPORATED 4* Copyright 2008 Adobe Systems Incorporated 5* All Rights Reserved. 6* 7* NOTICE: Adobe permits you to use, modify, and distribute this file 8* in accordance with the terms of the Adobe license agreement accompanying 9* it. If you have received this file from a source other than Adobe, then 10* your use, modification, or distribution of it requires the prior written 11* permission of Adobe. 12* 13* AdobePatentID="B564" 14* AdobePatentID="B565" 15* 16**************************************************************************/ 17 18ICE = {}; 19 20// Set the ICE.useConfig flag to false in case you do not want to use the ice.conf.js file or if 21// this file is missing form your server. This should be done to avoid HTTP error code 404. 22ICE.useConfig = true; 23 24(function () { 25 var isNotInIde = parent == window || ( parent != window && !(/ide\.htm/i).test(parent.location.href) ); 26 if (isNotInIde) { 27 /* 28 * This setting defines the default shortcut for launching the InContext Editing Login 29 * dialog on any PC machine. 30 * 31 * DO NOT MODIFY THIS CONSTANT! 32 * 33 * Instead modify the ICE.USER_LOGIN_PC variable inside the ice.conf.js file. 34 */ 35 ICE.DEFAULT_LOGIN_PC = "CTRL+E"; 36 37 /* 38 * This setting defines the default shortcut for launching the InContext Editing Login 39 * dialog on any MAC machine. 40 * 41 * DO NOT MODIFY THIS CONSTANT! 42 * 43 * Instead modify the ICE.USER_LOGIN_MAC variable inside the ice.conf.js file. 44 */ 45 ICE.DEFAULT_LOGIN_MAC = "CMD+E"; 46 47 /** 48 * Gets the relative path based on the ice.js includes. 49 */ 50 ICE.getSiteRoot = function() { 51 var searchPath = "includes/ice/ice.js"; 52 var s = null; 53 var url = ''; 54 var scripts = document.getElementsByTagName("script"); 55 for (var i=0; i<scripts.length; i++) { 56 url = scripts[i].src.toLowerCase(); 57 if (typeof url != "undefined") { 58 if (url.indexOf(searchPath) != -1) { 59 s = scripts[i].src; 60 break; 61 } 62 } 63 } 64 65 s = s.substring(0, s.length - searchPath.length); 66 67 if (!/http/i.test(s)) { 68 // This Happens on IE 69 var m = s.match(/\.\.\//g); 70 var deep = m?m.length:0; 71 var loca = window.location; 72 var path = loca.pathname.replace(/\/([^\/]*)$/, '/'); 73 var temp = path.split('/'); 74 var newLength = temp.length - deep - 1; 75 temp.length = (newLength >= 0) ? newLength : 0; 76 path = temp.join('/') + '/'; 77 s = loca.protocol + '//'+ loca.hostname + (loca.port?':' + loca.port:'') + path; 78 } 79 80 return s; 81 }; 82 83 /** 84 * Adds a link to the current configuration file to the page HEAD so the values in this file become available 85 */ 86 ICE.getConfig = function() { 87 var scr = document.createElement('SCRIPT'); 88 scr.type = 'text/javascript'; 89 var head=document.getElementsByTagName('HEAD')[0]; 90 head.appendChild(scr); 91 scr.onreadystatechange = scr.onload = function(e) { 92 e = e || event; 93 if (e.type == 'readystatechange') { 94 if (typeof this.jsloaded == 'undefined' && (this.readyState == 'complete')){ 95 this.jsloaded = true; 96 ICE.attachKeyEvent(); 97 } 98 } else { 99 ICE.attachKeyEvent(); 100 } 101 }; 102 var siteRoot = ICE.getSiteRoot(); 103 scr.src = siteRoot + 'includes/ice/ice.conf.js'; 104 }; 105 106 /** 107 * This function begins the actual edit by pointing the browser to the new URL. 108 */ 109 ICE.startEdit = function() { 110 var siteRoot = ICE.getSiteRoot(); 111 var siteRootParts = siteRoot.replace(/\/$/gi, "").split("/"); 112 113 var redirectTo = window.location.href; 114 115 var pathname = window.location.pathname; 116 117 //In webkit the pathname is decoded and the pound and space characters are unescaped. 118 //Pound and space and ampersand must be escaped before applying encodeURIComponent on the page "hash parameter". 119 var shouldBeEscapedArray=['#', ' ', '&']; 120 var shouldBeEscapedRegexp = new RegExp("("+shouldBeEscapedArray.join("|")+")", "gi"); 121 var escapedPathname = pathname.replace(shouldBeEscapedRegexp, function(s, c) { 122 return escape(c); 123 }); 124 if (escapedPathname != pathname) { 125 var l = window.location; 126 redirectTo = l.protocol + '//' + l.host + escapedPathname + l.search + l.hash; 127 } 128 129 var redirecttoParts = redirectTo.split("/"); 130 131 // Remove the no of parts identical with the no of parts from siteRoot => will obtain the part after the site root form the URL 132 redirecttoParts.splice(0, siteRootParts.length); 133 redirectTo = redirecttoParts.join("/"); 134 135 redirectTo = siteRoot + 'includes/ice/ide.html#page=' + encodeURIComponent(redirectTo); 136 137 // Do the actual redirect 138 window.location.href = redirectTo; 139 }; 140 141 /** 142 * This function attaches key events so we catch the combination that will launch the InContext Editing Login UI 143 */ 144 ICE.attachKeyEvent = function() { 145 var platform = navigator.userAgent.match(/mac/i) ? "MAC" : "PC"; 146 var shortcut = ICE['DEFAULT_LOGIN_' + platform]; 147 148 if (typeof ICE['USER_LOGIN_' + platform] == 'string') { 149 shortcut = ICE['USER_LOGIN_' + platform]; 150 } 151 152 if (shortcut !== '' && shortcut.indexOf('+') != -1) { 153 ICE.shortcut = { 154 ctrlKey: shortcut.indexOf('CTRL+') != -1, 155 altKey: shortcut.indexOf('ALT+') != -1, 156 metaKey: shortcut.indexOf('CMD+') != -1,
157 shiftKey: shortcut.indexOf('SHIFT+') != -1, 158 keyCode: shortcut.slice(-1).charCodeAt(0), 159 platform: platform 160 }; 161 162 ICE.isShortcutPressed = function(event) { 163 var retVal = true; 164 retVal = retVal && (ICE.shortcut.ctrlKey ? event.ctrlKey : !event.ctrlKey); 165 if (ICE.shortcut.platform == "MAC") { 166 retVal = retVal && (ICE.shortcut.metaKey ? event.metaKey : !event.metaKey); 167 } 168 retVal = retVal && (ICE.shortcut.altKey ? event.altKey : !event.altKey); 169 retVal = retVal && (ICE.shortcut.shiftKey ? event.shiftKey : !event.shiftKey); 170 retVal = retVal && (ICE.shortcut.keyCode == event.keyCode); 171 return retVal; 172 }; 173 174 ICE.onkeydown = function (e) { 175 e = e || event; 176 if (ICE.isShortcutPressed(e)) { 177 //stop keyboard shortcut and redirect to ICE IDE 178 try{e.cancelBubble = true;}catch(err){} 179 try{e.returnValue = false;}catch(err){} 180 try{e.stopPropagation();}catch(err){} 181 try{e.preventDefault();}catch(err){} 182 ICE.startEdit(); 183 return false; 184 } 185 }; 186 187 if (document.addEventListener) { 188 document.addEventListener('keydown', ICE.onkeydown, false); 189 } else if (document.attachEvent) { 190 document.attachEvent('onkeydown', ICE.onkeydown); 191 } else { 192 document.onkeydown = ICE.onkeydown; 193 } 194 } 195 }; 196 197 /** 198 * Depending on the current setting - to use or not the config file - we'll decide to read the config or not 199 */ 200 if (ICE.useConfig) { 201 // If the site owner has decided to use the ice.conf.js we'll go ahead and read it 202 ICE.getConfig(); 203 } else { 204 // Otherwise we'll go with the defaults 205 ICE.attachKeyEvent(); 206 } 207 } 208})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.