| OLD | NEW |
| 1 // Copyright 2014 The Cloud Input Tools Authors. All Rights Reserved. | 1 // Copyright 2014 The Cloud Input Tools Authors. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS-IS" BASIS, | 10 // distributed under the License is distributed on an "AS-IS" BASIS, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (element.readOnly) { | 54 if (element.readOnly) { |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 switch (element.tagName.toUpperCase()) { | 58 switch (element.tagName.toUpperCase()) { |
| 59 case 'TEXTAREA': | 59 case 'TEXTAREA': |
| 60 return true; | 60 return true; |
| 61 case 'INPUT': | 61 case 'INPUT': |
| 62 return (element.type.toUpperCase() == 'TEXT' || | 62 return (element.type.toUpperCase() == 'TEXT' || |
| 63 element.type.toUpperCase() == 'SEARCH'); | 63 element.type.toUpperCase() == 'SEARCH'); |
| 64 case 'DIV': | |
| 65 return element.isContentEditable; | |
| 66 case 'IFRAME': | 64 case 'IFRAME': |
| 67 // Accessing iframe's contents or properties throws exception when the | 65 // Accessing iframe's contents or properties throws exception when the |
| 68 // iframe is not hosted on the same domain. | 66 // iframe is not hosted on the same domain. |
| 69 // When it happens, ignore it and consider this iframe isn't editable. | 67 // When it happens, ignore it and consider this iframe isn't editable. |
| 70 /** @preserveTry */ | 68 /** @preserveTry */ |
| 71 try { | 69 try { |
| 72 var ifdoc = i18n.input.common.dom.getSameDomainFrameDoc(element); | 70 var ifdoc = i18n.input.common.dom.getSameDomainFrameDoc(element); |
| 73 return !!ifdoc && (ifdoc.designMode && | 71 return !!ifdoc && (ifdoc.designMode && |
| 74 ifdoc.designMode.toUpperCase() == 'ON' || | 72 ifdoc.designMode.toUpperCase() == 'ON' || |
| 75 ifdoc.body && ifdoc.body.isContentEditable); | 73 ifdoc.body && ifdoc.body.isContentEditable); |
| 76 } catch (e) { | 74 } catch (e) { |
| 77 return false; | 75 return false; |
| 78 } | 76 } |
| 77 default: |
| 78 return !!element.isContentEditable; |
| 79 } | 79 } |
| 80 | |
| 81 return false; | |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 | 82 |
| 85 /** | 83 /** |
| 86 * Sets class names to an element. | 84 * Sets class names to an element. |
| 87 * | 85 * |
| 88 * @param {Element} elem Element to set class names. | 86 * @param {Element} elem Element to set class names. |
| 89 * @param {Array.<string>} classes Class names. | 87 * @param {Array.<string>} classes Class names. |
| 90 */ | 88 */ |
| 91 i18n.input.common.dom.setClasses = function(elem, classes) { | 89 i18n.input.common.dom.setClasses = function(elem, classes) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 var frame = dom.createDom(goog.dom.TagName.IFRAME, { | 183 var frame = dom.createDom(goog.dom.TagName.IFRAME, { |
| 186 'frameborder': '0', | 184 'frameborder': '0', |
| 187 'scrolling': 'no', | 185 'scrolling': 'no', |
| 188 'style': 'background-color:transparent;border:0;display:none;' | 186 'style': 'background-color:transparent;border:0;display:none;' |
| 189 }); | 187 }); |
| 190 dom.append(/** @type {!Element} */ (doc.body), frame); | 188 dom.append(/** @type {!Element} */ (doc.body), frame); |
| 191 var frameDoc = dom.getFrameContentDocument(frame); | 189 var frameDoc = dom.getFrameContentDocument(frame); |
| 192 | 190 |
| 193 var css = i18n.input.common.GlobalSettings.alternativeImageUrl ? | 191 var css = i18n.input.common.GlobalSettings.alternativeImageUrl ? |
| 194 i18n.input.common.GlobalSettings.css.replace( | 192 i18n.input.common.GlobalSettings.css.replace( |
| 195 /\/\/ssl.gstatic.com\/inputtools\/images/g, | 193 /^(?:https?:)?\/\/ssl.gstatic.com\/inputtools\/images/g, |
| 196 i18n.input.common.GlobalSettings.alternativeImageUrl) : | 194 i18n.input.common.GlobalSettings.alternativeImageUrl) : |
| 197 i18n.input.common.GlobalSettings.css; | 195 i18n.input.common.GlobalSettings.css; |
| 198 goog.style.installStyles( | 196 goog.style.installStyles( |
| 199 'html body{border:0;margin:0;padding:0} html,body{overflow:hidden}' + | 197 'html body{border:0;margin:0;padding:0} html,body{overflow:hidden}' + |
| 200 css, /** @type {!Element} */(frameDoc.body)); | 198 css, /** @type {!Element} */(frameDoc.body)); |
| 201 return frame; | 199 return frame; |
| 202 }; | 200 }; |
| 203 | 201 |
| 204 | 202 |
| 205 /** | 203 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 220 * @param {Element} iframe The iframe wrapper element. | 218 * @param {Element} iframe The iframe wrapper element. |
| 221 */ | 219 */ |
| 222 i18n.input.common.dom.copyNecessaryStyle = function(element, iframe) { | 220 i18n.input.common.dom.copyNecessaryStyle = function(element, iframe) { |
| 223 goog.style.setContentBoxSize(iframe, goog.style.getSize(element)); | 221 goog.style.setContentBoxSize(iframe, goog.style.getSize(element)); |
| 224 goog.array.forEach(i18n.input.common.dom.iframeWrapperProperty_, | 222 goog.array.forEach(i18n.input.common.dom.iframeWrapperProperty_, |
| 225 function(property) { | 223 function(property) { |
| 226 goog.style.setStyle(iframe, property, | 224 goog.style.setStyle(iframe, property, |
| 227 goog.style.getComputedStyle(element, property)); | 225 goog.style.getComputedStyle(element, property)); |
| 228 }); | 226 }); |
| 229 }; | 227 }; |
| OLD | NEW |