-
-
Save jemgold/5563372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.RadClass = Em.Object.extend( | |
itemId: ((key, value)-> | |
if arguments.length == 2 and value | |
name = value.split(' ') | |
@set('firstName', name[0]) | |
@set('lastName', name.slice(1).join(' ')) | |
if @get('firstName') or @get('lastName') | |
"#{@get('firstName')} #{@get('lastName')}" | |
else | |
null | |
).property('firstName', 'lastName') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+computed firstName, lastName | |
fullName: (key, value) -> | |
if arguments.length == 2 and value | |
name = value.split(' ') | |
@firstName = name[0] | |
@lastName = name.slice(1).join(' ') | |
if @firstName or @lastName | |
"#{@firstName} #{@lastName}" | |
else | |
null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fullName: Ember.computed(function (key, value) { | |
var name; | |
if (get$(arguments, 'length') === 2 && value) { | |
name = value.split(' '); | |
set$(this, 'firstName', name[0]); | |
set$(this, 'lastName', name.slice(1).join(' ')); | |
} | |
if (get$(this, 'firstName') || get$(this, 'lastName')) { | |
return '' + get$(this, 'firstName') + ' ' + get$(this, 'lastName'); | |
} else { | |
return null; | |
} | |
}).property('firstName', 'lastName')f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fullName: function(key, value) { | |
if (arguments.length === 2 && value) { | |
var name = value.split(' '); | |
this.set('firstName', name[0]); | |
this.set('lastName', name.slice(1).join(' ')); | |
} | |
var firstName = this.get('firstName') || ''; | |
var lastName = this.get('lastName') || ''; | |
if (firstName || lastName) { | |
return firstName + ' ' + lastName; | |
} else { | |
return null; | |
} | |
}.property('firstName', 'lastName') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment