PageRenderTime 61ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/cache/smarty/compile/d9/36/d6/d936d632ec23c697576ecc385563ecddbef3c795.file.ajax.tpl.php

https://gitlab.com/nghiep5890/prestashop
PHP | 263 lines | 239 code | 24 blank | 0 comment | 36 complexity | 2f87e1f4761b8b384bd73abc6f9cba79 MD5 | raw file
  1. <?php /* Smarty version Smarty-3.1.19, created on 2016-11-24 17:38:17
  2. compiled from "C:\xampp\htdocs\prestashop\admin\themes\default\template\controllers\products\helpers\uploader\ajax.tpl" */ ?>
  3. <?php /*%%SmartyHeaderCode:12150583717790bc713-88528642%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
  4. $_valid = $_smarty_tpl->decodeProperties(array (
  5. 'file_dependency' =>
  6. array (
  7. 'd936d632ec23c697576ecc385563ecddbef3c795' =>
  8. array (
  9. 0 => 'C:\\xampp\\htdocs\\prestashop\\admin\\themes\\default\\template\\controllers\\products\\helpers\\uploader\\ajax.tpl',
  10. 1 => 1452073828,
  11. 2 => 'file',
  12. ),
  13. ),
  14. 'nocache_hash' => '12150583717790bc713-88528642',
  15. 'function' =>
  16. array (
  17. ),
  18. 'variables' =>
  19. array (
  20. 'id' => 0,
  21. 'name' => 0,
  22. 'url' => 0,
  23. 'multiple' => 0,
  24. 'max_files' => 0,
  25. 'files' => 0,
  26. 'post_max_size' => 0,
  27. 'default_language' => 0,
  28. ),
  29. 'has_nocache_code' => false,
  30. 'version' => 'Smarty-3.1.19',
  31. 'unifunc' => 'content_5837177922ba28_97558951',
  32. ),false); /*/%%SmartyHeaderCode%%*/?>
  33. <?php if ($_valid && !is_callable('content_5837177922ba28_97558951')) {function content_5837177922ba28_97558951($_smarty_tpl) {?>
  34. <div class="form-group">
  35. <div class="col-lg-12">
  36. <input id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  37. " type="file" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  38. []"<?php if (isset($_smarty_tpl->tpl_vars['url']->value)) {?> data-url="<?php echo $_smarty_tpl->tpl_vars['url']->value;?>
  39. "<?php }?><?php if (isset($_smarty_tpl->tpl_vars['multiple']->value)&&$_smarty_tpl->tpl_vars['multiple']->value) {?> multiple="multiple"<?php }?> style="width:0px;height:0px;" />
  40. <button class="btn btn-default" data-style="expand-right" data-size="s" type="button" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  41. -add-button">
  42. <i class="icon-folder-open"></i> <?php if (isset($_smarty_tpl->tpl_vars['multiple']->value)&&$_smarty_tpl->tpl_vars['multiple']->value) {?><?php echo smartyTranslate(array('s'=>'Add files...'),$_smarty_tpl);?>
  43. <?php } else { ?><?php echo smartyTranslate(array('s'=>'Add file...'),$_smarty_tpl);?>
  44. <?php }?>
  45. </button>
  46. </div>
  47. </div>
  48. <div class="well" style="display:none">
  49. <div id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  50. -files-list"></div>
  51. <button class="ladda-button btn btn-primary" data-style="expand-right" type="button" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  52. -upload-button" style="display:none;">
  53. <span class="ladda-label"><i class="icon-check"></i> <?php if (isset($_smarty_tpl->tpl_vars['multiple']->value)&&$_smarty_tpl->tpl_vars['multiple']->value) {?><?php echo smartyTranslate(array('s'=>'Upload files'),$_smarty_tpl);?>
  54. <?php } else { ?><?php echo smartyTranslate(array('s'=>'Upload file'),$_smarty_tpl);?>
  55. <?php }?></span>
  56. </button>
  57. </div>
  58. <div class="row" style="display:none">
  59. <div class="alert alert-success" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  60. -success"></div>
  61. </div>
  62. <div class="row" style="display:none">
  63. <div class="alert alert-danger" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  64. -errors"></div>
  65. </div>
  66. <script type="text/javascript">
  67. function humanizeSize(bytes)
  68. {
  69. if (typeof bytes !== 'number') {
  70. return '';
  71. }
  72. if (bytes >= 1000000000) {
  73. return (bytes / 1000000000).toFixed(2) + ' GB';
  74. }
  75. if (bytes >= 1000000) {
  76. return (bytes / 1000000).toFixed(2) + ' MB';
  77. }
  78. return (bytes / 1000).toFixed(2) + ' KB';
  79. }
  80. $( document ).ready(function() {
  81. <?php if (isset($_smarty_tpl->tpl_vars['multiple']->value)&&isset($_smarty_tpl->tpl_vars['max_files']->value)) {?>
  82. var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  83. _max_files = <?php echo $_smarty_tpl->tpl_vars['max_files']->value-count($_smarty_tpl->tpl_vars['files']->value);?>
  84. ;
  85. <?php }?>
  86. <?php if (isset($_smarty_tpl->tpl_vars['files']->value)&&$_smarty_tpl->tpl_vars['files']->value) {?>
  87. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  88. -images-thumbnails').parent().show();
  89. <?php }?>
  90. var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  91. _upload_button = Ladda.create( document.querySelector('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  92. -upload-button' ));
  93. var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  94. _total_files = 0;
  95. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  96. ').fileupload({
  97. dataType: 'json',
  98. async: false,
  99. autoUpload: false,
  100. singleFileUploads: true,
  101. maxFileSize: <?php echo $_smarty_tpl->tpl_vars['post_max_size']->value;?>
  102. ,
  103. start: function (e) {
  104. <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  105. _upload_button.start();
  106. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  107. -upload-button').unbind('click'); //Important as we bind it for every elements in add function
  108. },
  109. fail: function (e, data) {
  110. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  111. -errors').html(data.errorThrown.message).parent().show();
  112. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  113. -files-list').html('').parent().hide();
  114. },
  115. done: function (e, data) {
  116. if (data.result) {
  117. if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  118. !== 'undefined') {
  119. for (var i=0; i<data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  120. .length; i++) {
  121. if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  122. [i].error !== 'undefined' && data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  123. [i].error != '') {
  124. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  125. -errors').html('<strong>'+data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  126. [i].name+'</strong> : '+data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  127. [i].error).parent().show();
  128. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  129. -files-list').html('').parent().hide();
  130. }
  131. else
  132. {
  133. $(data.context).appendTo($('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  134. -success'));
  135. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  136. -success').parent().show();
  137. if (data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  138. [i] !== null && data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  139. [i].status == 'ok')
  140. {
  141. var response = data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
  142. [i];
  143. var cover = "icon-check-empty";
  144. var legend = '';
  145. if (response.cover == "1")
  146. cover = "icon-check-sign";
  147. if (typeof response.legend !== 'undefined' && response.legend != null)
  148. legend = response.legend[<?php echo intval($_smarty_tpl->tpl_vars['default_language']->value);?>
  149. ];
  150. imageLine(response.id, response.path, response.position, cover, response.shops, legend);
  151. $("#countImage").html(parseInt($("#countImage").html()) + 1);
  152. $("#img" + id).remove();
  153. $("#imageTable").tableDnDUpdate();
  154. }
  155. }
  156. }
  157. }
  158. $(data.context).find('button').remove();
  159. }
  160. },
  161. }).on('fileuploadalways', function (e, data) {
  162. <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  163. _total_files--;
  164. if (<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  165. _total_files == 0)
  166. {
  167. <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  168. _upload_button.stop();
  169. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  170. -upload-button').unbind('click');
  171. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  172. -files-list').parent().hide();
  173. }
  174. }).on('fileuploadadd', function(e, data) {
  175. if (typeof <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  176. _max_files !== 'undefined') {
  177. if (<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  178. _total_files >= <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  179. _max_files) {
  180. e.preventDefault();
  181. alert('<?php echo smartyTranslate(array('s'=>sprintf('You can upload a maximum of %s files',$_smarty_tpl->tpl_vars['max_files']->value)),$_smarty_tpl);?>
  182. ');
  183. return;
  184. }
  185. }
  186. data.context = $('<div/>').addClass('form-group').appendTo($('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  187. -files-list'));
  188. var file_name = $('<span/>').append('<i class="icon-picture-o"></i> <strong>'+data.files[0].name+'</strong> ('+humanizeSize(data.files[0].size)+')').appendTo(data.context);
  189. var button = $('<button/>').addClass('btn btn-default pull-right').prop('type', 'button').html('<i class="icon-trash"></i> <?php echo smartyTranslate(array('s'=>'Remove file'),$_smarty_tpl);?>
  190. ').appendTo(data.context).on('click', function() {
  191. <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  192. _total_files--;
  193. data.files = null;
  194. var total_elements = $(this).parent().siblings('div.form-group').length;
  195. $(this).parent().remove();
  196. if (total_elements == 0) {
  197. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  198. -files-list').html('').parent().hide();
  199. }
  200. });
  201. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  202. -files-list').parent().show();
  203. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  204. -upload-button').show().bind('click', function () {
  205. if (data.files != null)
  206. data.submit();
  207. });
  208. <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  209. _total_files++;
  210. }).on('fileuploadprocessalways', function (e, data) {
  211. var index = data.index, file = data.files[index];
  212. if (file.error) {
  213. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  214. -errors').append('<div class="form-group"><i class="icon-picture-o"></i> <strong>'+file.name+'</strong> ('+humanizeSize(file.size)+') : '+file.error+'</div>').parent().show();
  215. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  216. -files-list').html('').parent().hide();
  217. $(data.context).find('button').trigger('click');
  218. }
  219. }).on('fileuploadsubmit', function (e, data) {
  220. var params = new Object();
  221. $('input[id^="legend_"]').each(function()
  222. {
  223. id = $(this).prop("id").replace("legend_", "legend[") + "]";
  224. params[id] = $(this).val();
  225. });
  226. data.formData = params;
  227. });
  228. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  229. -add-button').on('click', function() {
  230. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  231. -success').html('').parent().hide();
  232. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  233. -errors').html('').parent().hide();
  234. $('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
  235. ').trigger('click');
  236. });
  237. });
  238. </script>
  239. <?php }} ?>