1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32:
33: class Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
34: extends Mage_Adminhtml_Block_Abstract
35: implements Varien_Data_Form_Element_Renderer_Interface
36: {
37: protected $_template = 'paypal/system/config/fieldset/hint.phtml';
38:
39: 40: 41: 42: 43: 44:
45: public function render(Varien_Data_Form_Element_Abstract $element)
46: {
47: $elementOriginalData = $element->getOriginalData();
48: if (isset($elementOriginalData['help_link'])) {
49: $this->setHelpLink($elementOriginalData['help_link']);
50: }
51: $js = '
52: paypalToggleSolution = function(id, url) {
53: var doScroll = false;
54: Fieldset.toggleCollapse(id, url);
55: if ($(this).hasClassName("open")) {
56: $$(".with-button button.button").each(function(anotherButton) {
57: if (anotherButton != this && $(anotherButton).hasClassName("open")) {
58: $(anotherButton).click();
59: doScroll = true;
60: }
61: }.bind(this));
62: }
63: if (doScroll) {
64: var pos = Element.cumulativeOffset($(this));
65: window.scrollTo(pos[0], pos[1] - 45);
66: }
67: }
68:
69: togglePaypalSolutionConfigureButton = function(button, enable) {
70: var $button = $(button);
71: $button.disabled = !enable;
72: if ($button.hasClassName("disabled") && enable) {
73: $button.removeClassName("disabled");
74: } else if (!$button.hasClassName("disabled") && !enable) {
75: $button.addClassName("disabled");
76: }
77: }
78:
79: // check store-view disabling Express Checkout
80: document.observe("dom:loaded", function() {
81: var ecButton = $$(".pp-method-express button.button")[0];
82: var ecEnabler = $$(".paypal-ec-enabler")[0];
83: if (typeof ecButton == "undefined" || typeof ecEnabler != "undefined") {
84: return;
85: }
86: var $ecButton = $(ecButton);
87: $$(".with-button button.button").each(function(configureButton) {
88: if (configureButton != ecButton && !configureButton.disabled
89: && !$(configureButton).hasClassName("paypal-ec-separate")
90: ) {
91: togglePaypalSolutionConfigureButton(ecButton, false);
92: }
93: });
94: });
95: ';
96: return $this->toHtml() . $this->helper('adminhtml/js')->getScript($js);
97: }
98: }
99: