/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage * @package js * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ var TranslateInline = Class.create(); TranslateInline.prototype = { initialize: function(trigEl, ajaxUrl, area){ this.ajaxUrl = ajaxUrl; this.area = area; this.trigTimer = null; this.trigContentEl = null; $$('*[translate]').each(this.initializeElement.bind(this)); var scope = this; Ajax.Responders.register({onComplete: function() {setTimeout(scope.reinitElements.bind(scope), 50)}}); this.trigEl = $(trigEl); this.trigEl.observe('mouseover', this.trigHideClear.bind(this)); this.trigEl.observe('mouseout', this.trigHideDelayed.bind(this)); this.trigEl.observe('click', this.formShow.bind(this)); this.helperDiv = document.createElement('div'); }, initializeElement: function(el) { if(!el.initializedTranslate) { el.addClassName('translate-inline'); el.initializedTranslate = true; Event.observe(el, 'mouseover', this.trigShow.bind(this, el)); Event.observe(el, 'mouseout', this.trigHideDelayed.bind(this)); } }, reinitElements: function (el) { $$('*[translate]').each(this.initializeElement.bind(this)); }, trigShow: function (el) { this.trigHideClear(); var p = Element.cumulativeOffset(el); this.trigEl.style.left = p[0]+'px'; this.trigEl.style.top = p[1]+'px'; this.trigEl.style.display = 'block'; this.trigContentEl = el; }, trigHide: function() { this.trigEl.style.display = 'none'; this.trigContentEl = null; }, trigHideDelayed: function () { this.trigTimer = window.setTimeout(this.trigHide.bind(this), 500); }, trigHideClear: function() { clearInterval(this.trigTimer); }, formShow: function () { if (this.formIsShown) { return; } this.formIsShown = true; var el = this.trigContentEl; if (!el) { return; } eval('var data = '+el.getAttribute('translate')); var content = '