<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <code>google_translate_j3</code>
    <name>Google Translate for Journal3 Theme</name>
    <version>1.1</version>
    <author>VanStudio</author>
    <link>https://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=vanstudio</link>
    <file path="catalog/controller/common/header.php">
        <operation error="skip">
            <search><![CDATA[return $this->load->view('common/header', $data);]]></search>
            <add position="before"><![CDATA[		if ($this->config->get('module_google_translate_status') == 2) {
            $data['language']=$this->load->controller('common/language');
        }]]></add>
        </operation>
    </file>
    <file path="admin/view/template/extension/module/google_translate_edit.twig">
        <operation error="skip">
            <search><![CDATA[<option value="2" {% if module_google_translate_view == 2 %}selected="selected"{% endif %} >{{ text_default_theme }}</option>]]></search>
            <add position="after"><![CDATA[                    <option value="3" {% if module_google_translate_view == 3 %}selected="selected"{% endif %} >Journal3 Theme</option>]]></add>
        </operation>
        <operation error="skip">
            <search><![CDATA[<select name="module_google_translate_language" id="input-status" class="form-control">]]></search>
            <add position="after"><![CDATA[<option value="" {% if module_google_translate_language is null or module_google_translate_language == 0 %}selected="selected"{% endif %} >None</option>]]></add>
        </operation>
    </file>
    <file path="catalog/controller/common/language.php">
        <operation error="skip">
            <search><![CDATA[return $this->load->view('common/language', $data);]]></search>
            <add position="before"><![CDATA[		if (file_exists(DIR_APPLICATION . 'controller/extension/module/google_translate.php') && $this->config->get('module_google_translate_status') == 2) {
            $data['google_translate'] = $this->load->controller('extension/module/google_translate');
        }]]></add>
        </operation>
    </file>
    <file path="catalog/view/theme/journal3/template/common/language.twig">
        <operation error="skip">
            <search><![CDATA[</form>]]></search>
            <add position="after"><![CDATA[    {{ google_translate }}]]></add>
        </operation>
    </file>
    <file path="catalog/view/theme/*/template/extension/module/google_translate.twig">
        <operation error="skip">
            <search><![CDATA[{% if ga_status %}]]></search>
            <add position="after"><![CDATA[
{% if ga_view == 3 %}
    {% if ga_status == 1 %}
        <div id="language" class="language">
    {% endif %}
    <div id="google_translate_element"></div><script type="text/javascript">
        function googleTranslateElementInit() {
            new google.translate.TranslateElement({
                {% if ga_language %}
                pageLanguage: '{{ ga_language }}',
                {% endif %}
                {% if ga_specific %}
                includedLanguages: '{{ ga_languages }}',
                {% endif %}
                autoDisplay: false,
                {% if ga_multiple %}
                multilanguagePage: false,
                {% endif %}
                {% if ga_track and analytics_id %}
                gaTrack: true,
                gaId: '{{ analytics_id }}'
                {% endif %}
        }, 'google_translate_element');
        }
        var googleTranslateScript = document.createElement('script');
  googleTranslateScript.type = 'text/javascript';
  googleTranslateScript.async = true;
  googleTranslateScript.src = 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
  ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild(googleTranslateScript);
    </script>
    <form class="g-translate">
      <div class="dropdown drop-menu">
        <button type="button" class="dropdown-toggle" data-toggle="dropdown">
          <span class="language-flag-title">
            {% if ga_icon %}<span class="symbol"><i class="fa fa-language no-link" style="border:none" aria-hidden="true"></i></span>{% endif %}
            {% if ga_label %}<span class="language-title">{{ ga_label }}</span>{% endif %}
          </span>
        </button>
        <div class="dropdown-menu j-dropdown">
          <ul class="j-menu">
          </ul>
        </div>
      </div>
    </form>

<style>
    #google_translate_element { display: none !important }
    .g-translate .dropdown-menu .j-menu { overflow: auto; max-height: 412px }
    .mobile-header-active .language .dropdown-toggle { min-width: 28px }
</style>

<script type="text/javascript"><!--
	$(".g-translate button").mouseenter(function() {
		if ($('.g-translate ul.j-menu li').length == 0) {
			$(".g-translate ul.j-menu").empty();
			$("select.goog-te-combo > option").each(function() {
				$(".g-translate ul.j-menu").append('<li><a class="language-select" data-value="' + $(this).val() + '"><span class="language-flag"></span><span class="language-title-dropdown">' + $(this).text() + '</span></a></li>');
			});
			$(".g-translate ul a").on('click', function(e) {
				$("select.goog-te-combo").val($(this).data('value'));
				fireEvent($("select.goog-te-combo").get(0), 'change');
			});
		}
	});

    function fireEvent(element,event){
        if (document.createEventObject){
            var evt = document.createEventObject();
            return element.fireEvent('on'+event,evt)
        }
        else{
            var evt = document.createEvent("HTMLEvents");
            evt.initEvent(event, true, true );
            return !element.dispatchEvent(evt);
        }
    }
    {% if ga_start %}
     setTimeout(function(){
      $("select.goog-te-combo").val('{{ ga_start }}');
      fireEvent($("select.goog-te-combo").get(0), 'change');
     }, 2000);
    {% endif %}
    //--></script>
    {% if ga_status == 1 %}
        </div>
    {% endif %}
{% else %}
        ]]></add>
        </operation>
        <operation error="skip">
            <search><![CDATA[</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>]]></search>
            <add position="replace"><![CDATA[
    </script>
</div>
{% endif %}
<div>]]></add>
        </operation>
    </file>
    <file path="admin/controller/extension/module/google_translate.php">
        <operation error="skip">
            <search><![CDATA[if (isset($this->request->post['module_google_translate_specific'])) {]]></search>
            <add position="before"><![CDATA[        if (isset($this->request->post['module_google_translate_start_language'])) {
            $data['module_google_translate_start_language'] = $this->request->post['module_google_translate_start_language'];
        } elseif (isset($store_info['module_google_translate_start_language'])) {
            $data['module_google_translate_start_language'] = $store_info['module_google_translate_start_language'];
        } else {
            $data['module_google_translate_start_language'] = '';
        }

        if (isset($this->request->post['module_google_translate_language_icon'])) {
            $data['module_google_translate_language_icon'] = $this->request->post['module_google_translate_language_icon'];
        } elseif (isset($store_info['module_google_translate_language_icon'])) {
            $data['module_google_translate_language_icon'] = $store_info['module_google_translate_language_icon'];
        } else {
            $data['module_google_translate_language_icon'] = 0;
        }]]></add>
        </operation>
    </file>
    <file path="admin/view/template/extension/module/google_translate_edit.twig">
        <operation error="skip">
            <search><![CDATA[<option value="2" {% if module_google_translate_view == 2 %}selected="selected"{% endif %} >{{ text_default_theme }}</option>]]></search>
            <add position="after"><![CDATA[
<option value="3" {% if module_google_translate_view == 3 %}selected="selected"{% endif %} >Journal2 Theme</option>]]></add>
        </operation>
        <operation error="skip">
            <search><![CDATA[<label class="col-sm-2 control-label" for="input-specific">{{ entry_specific }}</label>]]></search>
            <add position="before"><![CDATA[                <label class="col-sm-2 control-label" for="input-start_language">Start Language</label>
                <div class="col-sm-10">
                  <select name="module_google_translate_start_language" id="input-start_language" class="form-control">
                        <option value="" {% if module_google_translate_start_language == false %}selected="selected"{% endif %} >None</option>
                      {% for key, language in languages %}
                        <option value="{{ key }}" {% if module_google_translate_start_language == key %}selected="selected"{% endif %} >{{ language }}</option>
                      {% endfor %}
                  </select>
                </div>
              </div>
              <div class="form-group">]]></add>
        </operation>
        <operation error="skip">
            <search><![CDATA[<label class="col-sm-2 control-label" for="input-label">]]></search>
            <add position="before"><![CDATA[                <label class="col-sm-2 control-label" for="input-icon">Language Icon</label>
                <div class="col-sm-10">
                  <label class="radio-inline"><input type="radio" name="module_google_translate_language_icon" value="0" {% if module_google_translate_language_icon == 0 %}checked="checked"{% endif %} >
                      {{ text_disabled }}
                  </label>
                  <label class="radio-inline"><input type="radio" name="module_google_translate_language_icon" value="1" {% if module_google_translate_language_icon == 1 %}checked="checked"{% endif %} >
                      {{ text_enabled }}
                  </label>
                </div>
              </div>
              <div class="form-group">]]></add>
        </operation>
    </file>
    <file path="catalog/controller/extension/module/google_translate.php">
        <operation error="skip">
            <search><![CDATA[return $this->load->view($this->mPath, $data);]]></search>
            <add position="before"><![CDATA[        $data['ga_icon'] = $this->config->get('module_google_translate_language_icon');
        $data['ga_start'] = $this->config->get('module_google_translate_start_language') ? isset($_COOKIE['googtrans']) ? 0 : $this->config->get('module_google_translate_start_language') : 0;]]></add>
        </operation>
    </file>
    <file path="catalog/view/theme/journal3/template/journal3/module/filter.twig">
        <operation error="skip">
            <search><![CDATA[{{ j3.countBadge(subitem.value, subitem.total) }}]]></search>
            <add position="replace"><![CDATA[<p>{{ j3.countBadge(subitem.value, subitem.total) }}</p>]]></add>
        </operation>
        <operation error="skip">
            <search><![CDATA[<div class="filter-{{ item_input }}">]]></search>
            <add position="replace"><![CDATA[<div class="filter-{{ item_input }} {% if (item.title == 'Brands' or item.title == 'Бренды' or item.title == 'Zīmoli') %}notranslate{% endif %}">]]></add>
        </operation>
    </file>
    <file path="catalog/view/theme/journal3/template/journal3/module/manufacturers.twig">
        <operation error="skip">
            <search><![CDATA[<div class="{{ j3.classes(classes) }}">]]></search>
            <add position="replace"><![CDATA[<div class="{{ j3.classes(classes) }} notranslate">]]></add>
        </operation>
    </file>
</modification>