Пример #1
0
 /**
  * Class constructor/
  * Init JavaScript
  */
 public function __construct()
 {
     parent::__construct();
     $this->_objectId = 'id';
     $this->_blockGroup = 'referafriend';
     $this->_controller = 'adminhtml_rules';
     $this->_updateButton('save', 'label', Mage::helper('referafriend')->__('Save Rule'));
     $this->_updateButton('delete', 'label', Mage::helper('referafriend')->__('Delete Rule'));
     $this->_addButton('saveandcontinue', array('label' => Mage::helper('adminhtml')->__('Save And Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save'), -100);
     $this->_formScripts[] = "\n            \n           document.observe('dom:loaded', function() {  \n            \n                if(\$('target_type').getValue() == " . AW_Referafriend_Model_Rule::TARGET_SIGNUPS_QTY . ") {                      \n                   processOptionsForSignUp('none');                   \n                }\n                \n           }); \n           \n\n         function processOptionsForSignUp(type) {           \n\n                var  actionOpt = \$('action_type').options;\n\n                var addOption = true;\n                for(i in actionOpt) {   \n                    try{                \n                        if(actionOpt[i].value == " . AW_Referafriend_Model_Rule::TARGET_PURCHASE_AMOUNT . ") {                                             \n                            addOption = false;  \n                            if(type == 'none') { \$(actionOpt[i]).remove(); }\n                         }    \n                      } catch(e)  {  }\n                 } \n            \n                if(type == 'block' && addOption === true) {  \n                    var option= document.createElement('option');\n                    option.text= '" . AW_Referafriend_Model_Rule::getSignUpTargetAction() . "';\n                    option.value = " . AW_Referafriend_Model_Rule::TARGET_PURCHASE_AMOUNT . ";\n                     try\n                       {\n                        // for IE earlier than version 8\n                        actionOpt.add(option,actionOpt.options[null]);\n                       }\n                     catch (e)\n                       {\n                        actionOpt.add(option,null);\n                       }        \n                 }         \n               \n                   if(type == 'none') {    \n                        var orderTrig = document.getElementsByName('pre_trig_count');\n\n                            for(e in orderTrig) {\n                                if(orderTrig[e].type == 'text') {\n                                    orderTrig[e].value = '0';                        \n                                }                    \n                            }           \n\n                         \$('pre_trig_count').up(1).hide();\n                   }\n                   else {\n                        \$('pre_trig_count').up(1).show();\n                   }     \n               \n           }\n \n\n            function saveAndContinueEdit(){\n                editForm.submit(\$('edit_form').action+'back/edit/');\n            }\n            checkTarget = function(){\n             \n                if(\$('target_type').getValue() == " . AW_Referafriend_Model_Rule::TARGET_SIGNUPS_QTY . ") {                    \n                    processOptionsForSignUp('none');\n                }\n                else {                   \n                    processOptionsForSignUp('block');\n                }\n \n                if ( ( \$('target_type').getValue() == " . AW_Referafriend_Model_Rule::TARGET_SIGNUPS_QTY . " )\n                    || (\$('action_type').getValue() == " . AW_Referafriend_Model_Rule::ACTION_PERCENT_REF_FLATRATE . ") ){\n                    \$('applies').value = " . AW_Referafriend_Model_Rule::APPLY_ALL_CUSTOMERS . ";\n                    \$('applies').up(1).hide();\n                } else {\n                    \$('applies').up(1).show();\n                }\n                if ( \$('target_type').getValue() == " . AW_Referafriend_Model_Rule::TARGET_SIGNUPS_QTY . " ){\n                    \$('orders_limit').value = '0';\n                    \$('orders_limit').up(1).hide();\n                } else {\n                    \$('orders_limit').up(1).show();\n                }                \n                explainRule();\n            };\n            checkAction = function(){\n                checkTarget();\n                explainRule();\n            };\n            checkAction();\n        ";
 }