From a17c65ee9fb4f593af23f0075e8823a2a272d2e7 Mon Sep 17 00:00:00 2001 From: Nicolas Siver Date: Tue, 2 Jun 2015 22:20:09 +0300 Subject: [PATCH] move item template to file --- public/src/admin/manage/categories.js | 42 +++++-------------- .../partials/categories/category-item.tpl | 26 ++++++++++++ 2 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 src/views/admin/partials/categories/category-item.tpl diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index 0eef50ec0e..bf087b3e8c 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -2,15 +2,19 @@ /*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH*/ define('admin/manage/categories', function() { - var Categories = {}, newCategoryId = -1, sortables; + var Categories = {}, newCategoryId = -1, sortables, itemTemplate; Categories.init = function() { - socket.emit('admin.categories.getAll', function(error, payload){ - if(error){ - return app.alertError(error.message); - } + $.get(RELATIVE_PATH + '/templates/admin/partials/categories/category-item.tpl', function(data){ + itemTemplate = data; + + socket.emit('admin.categories.getAll', function(error, payload){ + if(error){ + return app.alertError(error.message); + } - Categories.render(payload); + Categories.render(payload); + }); }); $('button[data-action="create"]').on('click', Categories.create); @@ -130,31 +134,7 @@ define('admin/manage/categories', function() { function renderListItem(categoryEntity){ var listItem = $(templates.parse( - '
' + - '
' + - '
' + - '
' + - '' + - '
' + - '
' + - '
{name}
' + - '

{description}

' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
    ' + - '
  • {topic_count}
  • ' + - '
  • {post_count}
  • ' + - '
' + - '
' + - '' + - 'Edit' + - '
' + - '
' + - '
' + - '
', + itemTemplate, categoryEntity )); diff --git a/src/views/admin/partials/categories/category-item.tpl b/src/views/admin/partials/categories/category-item.tpl new file mode 100644 index 0000000000..579c2156f9 --- /dev/null +++ b/src/views/admin/partials/categories/category-item.tpl @@ -0,0 +1,26 @@ +
+
+
+
+ +
+
+
{name}
+ +

{description}

+
+
+
+
+
+
    +
  • {topic_count}
  • +
  • {post_count}
  • +
+
+ + Edit +
+
+
+
\ No newline at end of file