mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
ES6: grouped-each
helper and moved event dispatcher to an initializer
This commit is contained in:
parent
5df04de1cc
commit
ac89b3eb7e
8 changed files with 64 additions and 53 deletions
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
Discourse is not interested in watching `mouseMove` or `touchMove` events on an Ember views,
|
||||
so we remove them from the events the EventDispatcher watches for.
|
||||
*/
|
||||
Ember.EventDispatcher.reopen({
|
||||
events: {
|
||||
touchstart : 'touchStart',
|
||||
touchend : 'touchEnd',
|
||||
touchcancel : 'touchCancel',
|
||||
keydown : 'keyDown',
|
||||
keyup : 'keyUp',
|
||||
keypress : 'keyPress',
|
||||
mousedown : 'mouseDown',
|
||||
mouseup : 'mouseUp',
|
||||
contextmenu : 'contextMenu',
|
||||
click : 'click',
|
||||
dblclick : 'doubleClick',
|
||||
focusin : 'focusIn',
|
||||
focusout : 'focusOut',
|
||||
mouseenter : 'mouseEnter',
|
||||
mouseleave : 'mouseLeave',
|
||||
submit : 'submit',
|
||||
input : 'input',
|
||||
change : 'change',
|
||||
dragstart : 'dragStart',
|
||||
drag : 'drag',
|
||||
dragenter : 'dragEnter',
|
||||
dragleave : 'dragLeave',
|
||||
dragover : 'dragOver',
|
||||
drop : 'drop',
|
||||
dragend : 'dragEnd'
|
||||
}
|
||||
});
|
|
@ -108,8 +108,7 @@ DiscourseGroupedEach.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
Ember.Handlebars.registerHelper('groupedEach', function(path, options) {
|
||||
function groupedEachHelper(path, options) {
|
||||
if (arguments.length === 4) {
|
||||
Ember.assert("If you pass more than one argument to the groupedEach helper, it must be in the form #groupedEach foo in bar", arguments[1] === "in");
|
||||
|
||||
|
@ -130,4 +129,11 @@ Ember.Handlebars.registerHelper('groupedEach', function(path, options) {
|
|||
options.hash.dataSourceBinding = path;
|
||||
options.data.insideGroup = true;
|
||||
new DiscourseGroupedEach(this, path, options).render();
|
||||
}
|
||||
|
||||
Ember.Handlebars.registerHelper('groupedEach', function() {
|
||||
Em.warn("The `groupedEach` helper is deprecated. Use `grouped-each` instead.");
|
||||
return groupedEachHelper.apply(this, Array.prototype.slice.apply(arguments));
|
||||
});
|
||||
|
||||
Ember.Handlebars.registerHelper('grouped-each', groupedEachHelper);
|
|
@ -0,0 +1,38 @@
|
|||
export default {
|
||||
name: "ember-events",
|
||||
|
||||
initialize: function () {
|
||||
|
||||
// By default Ember listens to too many events. This tells it the only events
|
||||
// we're interested in.
|
||||
Ember.EventDispatcher.reopen({
|
||||
events: {
|
||||
touchstart : 'touchStart',
|
||||
touchend : 'touchEnd',
|
||||
touchcancel : 'touchCancel',
|
||||
keydown : 'keyDown',
|
||||
keyup : 'keyUp',
|
||||
keypress : 'keyPress',
|
||||
mousedown : 'mouseDown',
|
||||
mouseup : 'mouseUp',
|
||||
contextmenu : 'contextMenu',
|
||||
click : 'click',
|
||||
dblclick : 'doubleClick',
|
||||
focusin : 'focusIn',
|
||||
focusout : 'focusOut',
|
||||
mouseenter : 'mouseEnter',
|
||||
mouseleave : 'mouseLeave',
|
||||
submit : 'submit',
|
||||
input : 'input',
|
||||
change : 'change',
|
||||
dragstart : 'dragStart',
|
||||
drag : 'drag',
|
||||
dragenter : 'dragEnter',
|
||||
dragleave : 'dragLeave',
|
||||
dragover : 'dragOver',
|
||||
drop : 'drop',
|
||||
dragend : 'dragEnd'
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
|
@ -17,7 +17,7 @@
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#groupedEach topic in topics}}
|
||||
{{#grouped-each topic in topics}}
|
||||
<tr {{bind-attr class="archived"}}>
|
||||
<td class='main-link'>
|
||||
{{topic-status topic=topic}}
|
||||
|
@ -69,7 +69,7 @@
|
|||
<td class="activity"></td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<h3><i class='fa fa-envelope'></i> {{i18n private_message_info.title}}</h3>
|
||||
<div class='participants clearfix'>
|
||||
{{#groupedEach details.allowed_groups}}
|
||||
{{#grouped-each details.allowed_groups}}
|
||||
<div class='user group'>
|
||||
#{{unbound name}}
|
||||
</div>
|
||||
{{/groupedEach}}
|
||||
{{#groupedEach details.allowed_users}}
|
||||
{{/grouped-each}}
|
||||
{{#grouped-each details.allowed_users}}
|
||||
<div class='user'>
|
||||
{{#link-to 'user' this}}
|
||||
{{avatar this imageSize="small"}}
|
||||
|
@ -17,7 +17,7 @@
|
|||
<a class='remove-invited' {{action removeAllowedUser this}}><i class="fa fa-times"></i></a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</div>
|
||||
{{#if details.can_invite_to}}
|
||||
<div class='controls'>
|
||||
|
|
|
@ -45,21 +45,21 @@
|
|||
</li>
|
||||
{{/if}}
|
||||
<li {{bind-attr class=":avatars mapCollapsed::hidden"}}>
|
||||
{{#groupedEach participant in details.fewParticipants}}{{topic-participant participant=participant}}{{/groupedEach}}
|
||||
{{#grouped-each participant in details.fewParticipants}}{{topic-participant participant=participant}}{{/grouped-each}}
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
{{#unless mapCollapsed}}
|
||||
<section class='avatars clearfix'>
|
||||
{{#groupedEach participant in details.participants}}{{topic-participant participant=participant}}{{/groupedEach}}
|
||||
{{#grouped-each participant in details.participants}}{{topic-participant participant=participant}}{{/grouped-each}}
|
||||
</section>
|
||||
|
||||
{{#if infoLinks}}
|
||||
<section class='links'>
|
||||
|
||||
<table class='topic-links'>
|
||||
{{#groupedEach infoLinks}}
|
||||
{{#grouped-each infoLinks}}
|
||||
<tr>
|
||||
<td>
|
||||
<span class='badge badge-notification clicks' title='{{i18n topic_map.clicks count=clicks}}'>{{clicks}}</span>
|
||||
|
@ -71,7 +71,7 @@
|
|||
{{link-domain this}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</table>
|
||||
|
||||
{{#if showAllLinksControls}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{#if loaded}}
|
||||
{{#if topics}}
|
||||
<table class="topic-list">
|
||||
{{#groupedEach topic in topics}}
|
||||
{{#grouped-each topic in topics}}
|
||||
<tr {{bind-attr class="archived"}}>
|
||||
<td>
|
||||
<div class='main-link clearfix'>
|
||||
|
@ -59,7 +59,7 @@
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</table>
|
||||
{{else}}
|
||||
<div class='alert alert-info'>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{#groupedEach model.content}}
|
||||
{{#grouped-each model.content}}
|
||||
<div {{bind-attr class=":item hidden deleted moderator_action"}}>
|
||||
<div class='clearfix info'>
|
||||
<a href="{{unbound userUrl}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div></a>
|
||||
|
@ -10,10 +10,10 @@
|
|||
<span class="type">{{unbound descriptionHtml}}</span>
|
||||
</div>
|
||||
<p class='excerpt'>{{{unbound excerpt}}}</p>
|
||||
{{#groupedEach children}}
|
||||
{{#grouped-each children}}
|
||||
<div class='child-actions'>
|
||||
<i class="icon {{unbound icon}}"></i>
|
||||
{{#groupedEach items}}
|
||||
{{#grouped-each items}}
|
||||
{{#if bookmarkType}}
|
||||
<button class="btn btn-default remove-bookmark" {{action removeBookmark this}}>
|
||||
<i class="fa fa-times"></i>
|
||||
|
@ -22,11 +22,11 @@
|
|||
{{/if}}
|
||||
<a href="{{unbound userUrl}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="tiny" extraClasses="actor" ignoreTitle="true"}}</div></a>
|
||||
{{#if edit_reason}} — <span class="edit-reason">{{unbound edit_reason}}</span>{{/if}}
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</div>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
</div>
|
||||
{{/groupedEach}}
|
||||
{{/grouped-each}}
|
||||
{{#if loading}}
|
||||
<div class='spinner'>{{i18n loading}}</div>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in a new issue