Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
BO: Fix synchronous loaded scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shudrum committed Oct 31, 2016
1 parent bf1a13d commit 73fd8db
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 23 deletions.
Expand Up @@ -249,9 +249,6 @@
required: ""
}
},
submitHandler: function(form) {
form.submit();
},
// override jquery validate plugin defaults for bootstrap 3
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
Expand Down Expand Up @@ -317,4 +314,3 @@
</div>

{/block}

Expand Up @@ -123,7 +123,12 @@
}
});
{/if}
$(document).ready(function(){
function startTree() {
if (typeof $.fn.tree === 'undefined') {
setTimeout(startTree, 100);
return;
}
$('#{$id|escape:'html':'UTF-8'}').tree('collapseAll');
$('#{$id|escape:'html':'UTF-8'}').find(':input[type=radio]').click(treeClickFunc);
Expand Down Expand Up @@ -151,5 +156,6 @@
{else}
$('#collapse-all-{$id|escape:'html':'UTF-8'}').hide();
{/if}
});
}
startTree();
</script>
Expand Up @@ -35,22 +35,28 @@
{if isset($typeahead_source) && isset($id)}

<script type="text/javascript">
$(document).ready(
function()
{
$(function() {
function startTypeahead() {
if (typeof $.typeahead === 'undefined') {
setTimeout(startTypeahead, 100);
return;
}
$("#{$id|escape:'html':'UTF-8'}").typeahead(
{
name: "{$name|escape:'html':'UTF-8'}",
valueKey: 'name',
local: [{$typeahead_source}]
});
$("#{$id|escape:'html':'UTF-8'}").keypress(function( event ) {
if ( event.which == 13 ) {
$("#{$id|escape:'html':'UTF-8'}").keypress(function (event) {
if (event.which == 13) {
event.stopPropagation();
}
});
}
);
startTypeahead();
});
</script>
{/if}
{/if}
4 changes: 3 additions & 1 deletion classes/tree/Tree.php
Expand Up @@ -390,7 +390,9 @@ public function render($data = null)
$js_path = __PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/tree.js';
if ($this->getContext()->controller->ajax) {
if (!$this->_no_js) {
$html = '<script type="text/javascript" src="'.$js_path.'"></script>';
$html = '<script type="text/javascript">
$(function(){ $.getScript(\''.$js_path.'\'); });
</script>';
}
} else {
$this->getContext()->controller->addJs($js_path);
Expand Down
5 changes: 4 additions & 1 deletion classes/tree/TreeToolbarSearch.php
Expand Up @@ -58,7 +58,10 @@ public function render()
}

if ($this->getContext()->controller->ajax) {
$html = '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js"></script>';
$path = __PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js';
$html = '<script type="text/javascript">
$(function(){ $.getScript(\''.$path.'\'); });
</script>';
} else {
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js');
}
Expand Down
5 changes: 4 additions & 1 deletion classes/tree/TreeToolbarSearchCategories.php
Expand Up @@ -55,7 +55,10 @@ public function render()
}

if ($this->getContext()->controller->ajax) {
$html = '<script type="text/javascript" src="'.__PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js"></script>';
$path = __PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js';
$html = '<script type="text/javascript">
$(function(){ $.getScript(\''.$path.'\'); });
</script>';
} else {
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js');
}
Expand Down
6 changes: 0 additions & 6 deletions js/admin/products.js
Expand Up @@ -259,7 +259,6 @@ product_tabs['Combinations'] = new function(){
context: document.body,
dataType: 'json',
context: this,
async: false,
success: function(data) {
// color the selected line
parent.siblings().removeClass('selected-line');
Expand Down Expand Up @@ -336,7 +335,6 @@ product_tabs['Combinations'] = new function(){
context: document.body,
dataType: 'json',
context: this,
async: false,
success: function(data) {
if (data.status == 'ok')
{
Expand Down Expand Up @@ -368,7 +366,6 @@ product_tabs['Combinations'] = new function(){
context: document.body,
dataType: 'json',
context: this,
async: false,
success: function(data) {
if (data.status == 'ok')
{
Expand Down Expand Up @@ -739,7 +736,6 @@ product_tabs['Prices'] = new function(){
},
dataType: 'json',
context: this,
async: false,
success: function(data) {
if (data !== null)
{
Expand Down Expand Up @@ -1711,7 +1707,6 @@ function ajaxAction (url, action, success_callback, failure_callback){
},
dataType: 'json',
context: this,
async: false,
success: function(data) {
if (data.status == 'ok')
{
Expand Down Expand Up @@ -1911,6 +1906,5 @@ $(document).ready(function() {
$('#product_form').submit(function(e) {
$('#selectedCarriers option').attr('selected', 'selected');
$('#selectAttachment1 option').attr('selected', 'selected');
return true;
});
});
7 changes: 7 additions & 0 deletions js/admin/tinymce.inc.js
@@ -1,5 +1,12 @@
function tinySetup(config)
{
if (typeof tinyMCE === 'undefined') {
setTimeout(function() {
tinySetup(config);
}, 100);
return;
}

if(!config)
config = {};

Expand Down
3 changes: 2 additions & 1 deletion js/tiny_mce/tiny_mce.js
Expand Up @@ -9,4 +9,5 @@ var final_path = path_array.join('/');
window.tinyMCEPreInit = {};
window.tinyMCEPreInit.base = final_path+'/js/tiny_mce';
window.tinyMCEPreInit.suffix = '.min';
$('head').append($('<script>').attr('type', 'text/javascript').attr('src', final_path + '/js/tiny_mce/tinymce.min.js'));

$.getScript(final_path+'/js/tiny_mce/tinymce.min.js');

0 comments on commit 73fd8db

Please sign in to comment.