mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-03-26 07:44:10 +08:00
use jquery-tmpl
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"underscore": "~1.7.0",
|
||||
"jquery": "~2.1.2",
|
||||
"backbone": "~1.1.2",
|
||||
"moment": "~2.9.0"
|
||||
"moment": "~2.9.0",
|
||||
"jquery-tmpl": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ $ ->
|
||||
alert jqXHR.statusText
|
||||
.success callback
|
||||
|
||||
tmpl: (selector) ->
|
||||
cache = $(selector).template()
|
||||
|
||||
return (view_data) ->
|
||||
return $.tmpl cache, view_data
|
||||
|
||||
RP.initLocale()
|
||||
|
||||
$('nav a').each ->
|
||||
|
||||
@@ -16,8 +16,8 @@ $ ->
|
||||
idAttribute: '_id'
|
||||
|
||||
initialize: ->
|
||||
@replies = new ReplyCollection
|
||||
url: @url() + '/replies'
|
||||
@replies = new ReplyCollection()
|
||||
@replies.url = @url() + '/replies'
|
||||
|
||||
@once 'change', =>
|
||||
@replies.reset @get 'replies'
|
||||
@@ -45,7 +45,7 @@ $ ->
|
||||
className: 'list-group-item clearfix'
|
||||
|
||||
initialize: ->
|
||||
@template = _.template $('#reply-template').html()
|
||||
@template = RP.tmpl '#reply-template'
|
||||
@model.on 'change', @render.bind @
|
||||
|
||||
render: ->
|
||||
@@ -70,10 +70,10 @@ $ ->
|
||||
|
||||
@model.fetch()
|
||||
|
||||
@templateContent = _.template $('#content-template').html()
|
||||
@templateActions = _.template $('#actions-template').html()
|
||||
@templateAccountInfo = _.template $('#account-info-template').html()
|
||||
@templateMembers = _.template $('#members-template').html()
|
||||
@templateContent = RP.tmpl '#content-template'
|
||||
@templateActions = RP.tmpl '#actions-template'
|
||||
@templateAccountInfo = RP.tmpl '#account-info-template'
|
||||
@templateMembers = RP.tmpl '#members-template'
|
||||
|
||||
render: ->
|
||||
view_data = @model.toJSON()
|
||||
@@ -108,7 +108,7 @@ $ ->
|
||||
tagName: 'tr'
|
||||
|
||||
initialize: ->
|
||||
@template = _.template $('#list-item-template').html()
|
||||
@template = RP.tmpl '#list-item-template'
|
||||
|
||||
render: ->
|
||||
view_data = @model.toJSON()
|
||||
|
||||
@@ -23,8 +23,8 @@ prepend sidebar
|
||||
|
||||
append footer
|
||||
script(src='/script/ticket.js')
|
||||
script(id='list-item-template', type='text/template')
|
||||
script(id='list-item-template', type='text/x-jquery-tmpl')
|
||||
td
|
||||
a(href='/ticket/view/{{_id}}') {{title}}
|
||||
a(href='/ticket/view/${_id}') ${title}
|
||||
td
|
||||
span(class='text-{{color}}') {{RP.t('ticket_status.' + status)}}
|
||||
span(class='text-${color}') ${RP.t('ticket_status.' + status)}
|
||||
|
||||
@@ -26,64 +26,64 @@ prepend sidebar
|
||||
append footer
|
||||
script(src='/bower_components/moment/moment.js')
|
||||
script(src='/script/ticket.js')
|
||||
script(id='content-template', type='text/template')
|
||||
script(id='content-template', type='text/x-jquery-tmpl')
|
||||
header
|
||||
| {{title}}
|
||||
span.small(class='text-{{color}}') {{RP.t('ticket_status.' + status)}}
|
||||
| ${title}
|
||||
span.small(class='text-${color}') ${RP.t('ticket_status.' + status)}
|
||||
|
||||
p {:content_html}}
|
||||
script(id='reply-template', type='text/template')
|
||||
p {{html content_html}}
|
||||
script(id='reply-template', type='text/x-jquery-tmpl')
|
||||
a.pull-left
|
||||
img.img-avatar(src='{{account.preferences.avatar_url}}')
|
||||
img.img-avatar(src='${account.preferences.avatar_url}')
|
||||
.list-content
|
||||
{% if (content_html) { %}
|
||||
p {:content_html}}
|
||||
{% } else { %}
|
||||
p {{content}}
|
||||
{% }; %}
|
||||
{{if content_html}}
|
||||
p {{html content_html}}
|
||||
{{else}}
|
||||
p ${content}
|
||||
{{/if}}
|
||||
p
|
||||
span.label.label-info {{account.username}}
|
||||
{% if (created_at) { %}
|
||||
span.label.label-default(title='{{created_at}}') {{moment(created_at).fromNow()}}
|
||||
{% } else { %}
|
||||
span.label.label-info ${account.username}
|
||||
{{if created_at}}
|
||||
span.label.label-default(title='${created_at}') ${moment(created_at).fromNow()}
|
||||
{{else}}
|
||||
span.label.label-default ...
|
||||
{% }; %}
|
||||
script(id='actions-template', type='text/template')
|
||||
{% if (status != 'closed') { %}
|
||||
{{/if}}
|
||||
script(id='actions-template', type='text/x-jquery-tmpl')
|
||||
{{if status != 'closed'}}
|
||||
header= t('ticket.create_reply')
|
||||
{% }; %}
|
||||
{{/if}}
|
||||
|
||||
form.form-horizontal
|
||||
{% if (status != 'closed') { %}
|
||||
{{if status != 'closed'}}
|
||||
.form-group.padding
|
||||
textarea.form-control(name='content', rows='5')
|
||||
{% }; %}
|
||||
{{/if}}
|
||||
.form-group.padding
|
||||
{% if (status == 'closed') { %}
|
||||
{{if status == 'closed'}}
|
||||
button(disabled).btn.btn-lg.btn-primary= t('ticket_status.closed')
|
||||
{% } else { %}
|
||||
{{else}}
|
||||
button.btn.btn-lg.btn-primary.action-reply(type='button')= t('ticket.create_reply')
|
||||
button(type='button', data-status='closed').btn.btn-lg.btn-danger.action-status= t('ticket.close_ticket')
|
||||
{% }; %}
|
||||
{{/if}}
|
||||
if account.isAdmin()
|
||||
{% if (status == 'open' || status == 'pending') { %}
|
||||
{{if status == 'open' || status == 'pending'}}
|
||||
button(type='button', data-status='finish').btn.btn-lg.btn-success.action-status= t('ticket.finish_ticket')
|
||||
{% }; %}
|
||||
{% if (status == 'closed') { %}
|
||||
{{/if}}
|
||||
{{if status == 'closed'}}
|
||||
button(type='button', data-status='open').btn.btn-lg.btn-success.action-status= t('ticket.reopen_ticket')
|
||||
{% }; %}
|
||||
script(id='account-info-template', type='text/template')
|
||||
{% if (account) { %}
|
||||
{{/if}}
|
||||
script(id='account-info-template', type='text/x-jquery-tmpl')
|
||||
{{if account}}
|
||||
a.pull-left
|
||||
img.img-avatar(src='{{account.preferences.avatar_url}}')
|
||||
img.img-avatar(src='${account.preferences.avatar_url}')
|
||||
p
|
||||
span.label.label-info {{account.username}}
|
||||
span.label.label-info ${account.username}
|
||||
br
|
||||
span.label.label-default(title='{{created_at}}') {{moment(created_at).fromNow()}}
|
||||
{% }; %}
|
||||
script(id='members-template', type='text/template')
|
||||
span.label.label-default(title='${created_at}') ${moment(created_at).fromNow()}
|
||||
{{/if}}
|
||||
script(id='members-template', type='text/x-jquery-tmpl')
|
||||
header= t('ticket.members')
|
||||
{% members.forEach(function(member) { %}
|
||||
{{each members}}
|
||||
a.pull-left
|
||||
img.img-avatar(src='{{member.preferences.avatar_url}}', alt='{{member.username}}')
|
||||
{% }); %}
|
||||
img.img-avatar(src='${$value.preferences.avatar_url}', alt='${$value.username}')
|
||||
{{/each}}
|
||||
|
||||
Reference in New Issue
Block a user