Replaced {{view Discourse.TextField}} with {{textfield}} helper.

This commit is contained in:
Robin Ward 2013-05-20 12:47:59 -04:00
parent b794830a25
commit 1097d51b33
18 changed files with 91 additions and 66 deletions

View file

@ -1,9 +1,9 @@
<div class='admin-controls'>
<div class='span5 controls'>
{{view Discourse.TextField valueBinding="controller.testEmailAddress" placeholderKey="admin.email_logs.test_email_address"}}
{{textField value=testEmailAddress placeholderKey="admin.email_logs.test_email_address"}}
</div>
<div class='span10 controls'>
<button class='btn' {{action sendTestEmail target="controller"}} {{bindAttr disabled="sendTestEmailDisabled"}}>{{i18n admin.email_logs.send_test}}</button>
<button class='btn' {{action sendTestEmail}} {{bindAttr disabled="sendTestEmailDisabled"}}>{{i18n admin.email_logs.send_test}}</button>
{{#if controller.sentTestEmail}}<span class='result-message'>{{i18n admin.email_logs.sent_test}}</span>{{/if}}
</div>
</div>
@ -16,9 +16,9 @@
<th>{{i18n admin.email_logs.email_type}}</th>
</tr>
{{#if controller.content.length}}
{{#if model.length}}
{{#group}}
{{#collection contentBinding="controller.content" tagName="tbody" itemTagName="tr"}}
{{#collection contentBinding="model" tagName="tbody" itemTagName="tr"}}
<td>{{date view.content.created_at}}</td>
<td>
{{#if view.content.user}}

View file

@ -22,7 +22,7 @@
{{#if automatic}}
<h3>{{name}}</h3>
{{else}}
{{view Discourse.TextField valueBinding="name" placeholderKey="admin.groups.name_placeholder"}}
{{textField value=name placeholderKey="admin.groups.name_placeholder"}}
{{/if}}
{{view Discourse.UserSelector id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" usernamesBinding="usernames"}}

View file

@ -1,12 +1,12 @@
<div class='admin-controls'>
<div class='search controls'>
<label>
{{view Ember.Checkbox checkedBinding="controller.onlyOverridden"}}
{{input type="checkbox" checked=onlyOverridden}}
{{i18n admin.site_settings.show_overriden}}
</label>
</div>
<div class='search controls'>
{{view Discourse.TextField valueBinding="controller.filter" placeholderKey="type_to_filter"}}
{{textField value=filter placeHolderKey="type_to_filter"}}
</div>
</div>

View file

@ -9,13 +9,13 @@
</ul>
</div>
<div class='span5 username controls'>
{{view Discourse.TextField valueBinding="controller.username" placeholderKey="username"}}
{{textField value=username placeholderKey="username"}}
</div>
</div>
{{#if hasSelection}}
<div id='selected-controls'>
<button {{action approveUsers target="controller"}} class='btn'>{{countI18n admin.users.approved_selected countBinding="selectedCount"}}</button>
<button {{action approveUsers}} class='btn'>{{countI18n admin.users.approved_selected countBinding="selectedCount"}}</button>
</div>
{{/if}}
@ -49,7 +49,7 @@
{{#each content}}
<tr {{bindAttr class="selected"}}>
{{#if controller.showApproval}}
{{#if showApproval}}
<td>
{{#if can_approve}}
{{view Ember.Checkbox checkedBinding="selected"}}
@ -67,7 +67,7 @@
<td>{{{unbound created_at_age}}}</td>
{{#if controller.showApproval}}
{{#if showApproval}}
<td>
{{#if approved}}
{{i18n yes_value}}

View file

@ -9,7 +9,7 @@
Discourse.UserPrivateMessagesController = Discourse.ObjectController.extend({
editPreferences: function() {
return Discourse.URL.routeTo("/users/" + (this.get('content.username_lower')) + "/preferences");
Discourse.URL.routeTo("/users/" + (this.get('content.username_lower')) + "/preferences");
},
composePrivateMessage: function() {

View file

@ -1,3 +1,15 @@
/**
Allows us to supply bindings without "binding" to a helper.
**/
function normalizeHash(hash, hashTypes) {
for (var prop in hash) {
if (hashTypes[prop] === 'ID') {
hash[prop + 'Binding'] = hash[prop];
delete hash[prop];
}
}
}
/**
Breaks up a long string
@ -66,16 +78,27 @@ Ember.Handlebars.registerHelper('textField', function(options) {
var hash = options.hash,
types = options.hashTypes;
for (var prop in hash) {
if (types[prop] === 'ID') {
hash[prop + 'Binding'] = hash[prop];
delete hash[prop];
}
}
normalizeHash(hash, types);
return Ember.Handlebars.helpers.view.call(this, Discourse.TextField, options);
});
/**
Inserts a Discourse.InputTipView
@method inputTip
@for Handlebars
**/
Ember.Handlebars.registerHelper('inputTip', function(options) {
var hash = options.hash,
types = options.hashTypes;
normalizeHash(hash, types);
return Ember.Handlebars.helpers.view.call(this, Discourse.InputTipView, options);
});
/**
Produces a bound link to a category

View file

@ -35,17 +35,19 @@ Ember.String.i18n = function(scope, options) {
@for Handlebars
**/
Ember.Handlebars.registerHelper('countI18n', function(key, options) {
var view;
view = Discourse.View.extend({
var view = Discourse.View.extend({
tagName: 'span',
render: function(buffer) {
return buffer.push(Ember.String.i18n(key, {
buffer.push(Ember.String.i18n(key, {
count: this.get('count')
}));
},
countChanged: (function() {
return this.rerender();
}).observes('count')
countChanged: function() {
this.rerender();
}.observes('count')
});
return Ember.Handlebars.helpers.view.call(this, view, options);
});

View file

@ -1,6 +1,6 @@
<div class="auto-close-fields">
<i class="icon icon-time"></i>
{{view.label}}
{{view Discourse.TextField valueBinding="view.autoCloseDays" maxlength="3"}}
{{textField value=view.autoCloseDays maxlength="3"}}
{{i18n composer.auto_close_units}}
</div>

View file

@ -32,7 +32,7 @@
{{#if content.creatingPrivateMessage}}
{{view Discourse.UserSelector topicIdBinding="controller.controllers.topic.content.id" excludeCurrentUser="true" id="private-message-users" class="span8" placeholderKey="composer.users_placeholder" tabindex="1" usernamesBinding="content.targetUsernames"}}
{{/if}}
{{view Discourse.TextField valueBinding="content.title" tabindex="2" id="reply-title" maxlength="255" class="span8" placeholderKey="composer.title_placeholder"}}
{{textField value=content.title tabindex="2" id="reply-title" maxlength="255" class="span8" placeholderKey="composer.title_placeholder"}}
{{#unless content.creatingPrivateMessage}}
{{view Discourse.ComboboxViewCategory valueAttribute="name" contentBinding="Discourse.site.categories" valueBinding="content.categoryName"}}
{{#if content.archetype.hasOptions}}

View file

@ -6,8 +6,8 @@
<tr>
<td style="width:80px"><label for='new-account-name'>{{i18n user.name.title}}</label></td>
<td style="width:496px">
{{view Discourse.TextField valueBinding="view.accountName" elementId="new-account-name" autofocus="autofocus"}}
&nbsp;{{view Discourse.InputTipView validationBinding="view.nameValidation"}}
{{textField value=view.accountName id="new-account-name" autofocus="autofocus"}}
&nbsp;{{inputTip validation=nameValidation}}
</td>
</tr>
<tr>
@ -18,8 +18,8 @@
<tr>
<td><label for='new-account-email'>{{i18n user.email.title}}</label></td>
<td>
{{view Ember.TextField valueBinding="view.accountEmail" id="new-account-email"}}
&nbsp;{{view Discourse.InputTipView validationBinding="view.emailValidation"}}
{{input value=view.accountEmail id="new-account-email"}}
&nbsp;{{inputTip validation=view.emailValidation}}
</td>
</tr>
<tr>
@ -30,8 +30,8 @@
<tr>
<td><label for='new-account-username'>{{i18n user.username.title}}</label></td>
<td>
{{view Ember.TextField valueBinding="view.accountUsername" id="new-account-username" maxlength="15"}}
&nbsp;{{view Discourse.InputTipView validationBinding="view.usernameValidation"}}
{{input value=view.accountUsername id="new-account-username" maxlength="15"}}
&nbsp;{{inputTip validation=view.usernameValidation}}
</td>
</tr>
<tr>
@ -43,8 +43,8 @@
<tr>
<td><label for='new-account-password'>{{i18n user.password.title}}</label></td>
<td>
{{view Ember.TextField valueBinding="view.accountPassword" type="password" id="new-account-password"}}
&nbsp;{{view Discourse.InputTipView validationBinding="view.passwordValidation"}}
{{input type="password" value=view.accountPassword id="new-account-password"}}
&nbsp;{{inputTip validation=view.passwordValidation}}
</td>
</tr>
{{/if}}
@ -52,8 +52,8 @@
<tr class="password-confirmation">
<td><label for='new-account-password-confirmation'>{{i18n user.password_confirmation.title}}</label></td>
<td>
{{view Ember.TextField valueBinding="view.accountPasswordConfirm" type="password" id="new-account-password-confirmation"}}
{{view Ember.TextField valueBinding="view.accountChallenge" id="new-account-challenge"}}
{{input type="password" value=view.accountPasswordConfirm id="new-account-confirmation"}}
{{input value=view.accountChallenge id="new-account-challenge"}}
</td>
</tr>

View file

@ -20,7 +20,7 @@
<form>
<section class='field'>
<label>{{i18n category.name}}</label>
{{view Discourse.TextField valueBinding="name" placeholderKey="category.name_placeholder" maxlength="50"}}
{{textField value=name placeholderKey="category.name_placeholder" maxlength="50"}}
</section>
{{#unless is_uncategorized}}
@ -46,13 +46,13 @@
<div class='input-prepend input-append' style="margin-top: 10px;">
<span class='color-title'>{{i18n category.background_color}}:</span>
<span class='add-on'>#</span>{{view Discourse.TextField valueBinding="color" placeholderKey="category.color_placeholder" maxlength="6"}}
<span class='add-on'>#</span>{{textField value=color placeholderKey="category.color_placeholder" maxlength="6"}}
{{view Discourse.ColorsView colorsBinding="view.backgroundColors" usedColorsBinding="view.usedBackgroundColors" valueBinding="color"}}
</div>
<div class='input-prepend input-append'>
<span class='color-title'>{{i18n category.foreground_color}}:</span>
<span class='add-on'>#</span>{{view Discourse.TextField valueBinding="text_color" placeholderKey="category.color_placeholder" maxlength="6"}}
<span class='add-on'>#</span>{{textField value=text_color placeholderKey="category.color_placeholder" maxlength="6"}}
{{view Discourse.ColorsView colorsBinding="view.foregroundColors" valueBinding="text_color"}}
</div>
</div>
@ -63,7 +63,7 @@
<div {{bindAttr class=":modal-tab :options-tab view.securitySelected::invisible"}}>
<section class='field'>
<label>
{{view Ember.Checkbox checkedBinding="secure"}}
{{input type="checkbox" checked=secure}}
{{i18n category.is_secure}}
</label>
{{#if secure}}

View file

@ -1,8 +1,8 @@
<div class="modal-body">
<form>
<label for='username-or-email'>{{i18n forgot_password.invite}}</label>
{{view Discourse.TextField valueBinding="view.accountEmailOrUsername" placeholderKey="login.email_placeholder" elementId="username-or-email" autocorrect="off" autocapitalize="off"}}
</form>
{{textField value=view.accountEmailOrUsername placeholderKey="login.email_placeholder" elementId="username-or-email" autocorrect="off" autocapitalize="off"}}
</form>
</div>
<div class="modal-footer">
<button class='btn btn-large btn-primary' {{bindAttr disabled="view.submitDisabled"}} {{action submit target="view"}}>{{i18n forgot_password.reset}}</button>

View file

@ -1,4 +1,4 @@
<div class="modal-body">
<div class="modal-body">
{{#if view.error}}
<div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button>
@ -11,7 +11,7 @@
{{else}}
<form>
<label>{{i18n topic.invite_reply.email}}</label>
{{view Discourse.TextField valueBinding="view.email" placeholderKey="topic.invite_reply.email_placeholder"}}
{{textField value=view.email placeholderKey="topic.invite_reply.email_placeholder"}}
</form>
{{/if}}
</div>
@ -21,5 +21,5 @@
{{else}}
<button class='btn btn-primary' {{bindAttr disabled="view.disabled"}} {{action createInvite target="view"}}>{{view.buttonTitle}}</button>
{{/if}}
</div>
</div>

View file

@ -1,4 +1,4 @@
<div class="modal-body">
<div class="modal-body">
{{#if view.error}}
<div class="alert alert-error">
<button class="close" data-dismiss="alert">×</button>
@ -11,7 +11,7 @@
{{else}}
<form>
<label>{{i18n topic.invite_private.email_or_username}}</label>
{{view Discourse.TextField valueBinding="view.emailOrUsername" placeholderKey="topic.invite_private.email_or_username_placeholder"}}
{{textField value=view.emailOrUsername placeholderKey="topic.invite_private.email_or_username_placeholder"}}
</form>
{{/if}}
</div>
@ -21,5 +21,5 @@
{{else}}
<button class='btn btn-primary' {{bindAttr disabled="view.disabled"}} {{action invite target="view"}}>{{view.buttonTitle}}</button>
{{/if}}
</div>
</div>

View file

@ -30,7 +30,7 @@
<label for='login-account-name'>{{i18n login.username}}&nbsp;</label>
</td>
<td>
{{view Discourse.TextField valueBinding="view.loginName" placeholderKey="login.email_placeholder" elementId="login-account-name" autocorrect="off" autocapitalize="off" autofocus="autofocus"}}
{{textField value=view.loginName placeholderKey="login.email_placeholder" elementId="login-account-name" autocorrect="off" autocapitalize="off" autofocus="autofocus"}}
</td>
<tr>
<td>

View file

@ -9,7 +9,7 @@
<form>
<label>{{i18n topic.split_topic.topic_name}}</label>
{{view Discourse.TextField valueBinding="view.topicName" placeholderKey="composer.title_placeholder"}}
{{textField value=view.topicName placeholderKey="composer.title_placeholder"}}
</form>
</div>

View file

@ -11,19 +11,19 @@ Discourse.ButtonView = Discourse.View.extend({
classNameBindings: [':btn', ':standard', 'dropDownToggle'],
attributeBindings: ['data-not-implemented', 'title', 'data-toggle', 'data-share-url'],
title: (function() {
title: function() {
return Em.String.i18n(this.get('helpKey') || this.get('textKey'));
}).property('helpKey'),
}.property('helpKey'),
text: (function() {
text: function() {
return Em.String.i18n(this.get('textKey'));
}).property('textKey'),
}.property('textKey'),
render: function(buffer) {
if (this.renderIcon) {
this.renderIcon(buffer);
}
return buffer.push(this.get('text'));
buffer.push(this.get('text'));
}
});

View file

@ -10,22 +10,22 @@ Discourse.InputTipView = Discourse.View.extend({
templateName: 'input_tip',
classNameBindings: [':tip', 'good', 'bad'],
good: (function() {
good: function() {
return !this.get('validation.failed');
}).property('validation'),
}.property('validation'),
bad: (function() {
bad: function() {
return this.get('validation.failed');
}).property('validation'),
}.property('validation'),
triggerRender: (function() {
triggerRender: function() {
return this.rerender();
}).observes('validation'),
}.observes('validation'),
render: function(buffer) {
var icon, reason;
if (reason = this.get('validation.reason')) {
icon = this.get('good') ? 'icon-ok' : 'icon-remove';
var reason = this.get('validation.reason');
if (reason) {
var icon = this.get('good') ? 'icon-ok' : 'icon-remove';
return buffer.push("<i class=\"icon " + icon + "\"></i> " + reason);
}
}