Created
July 2, 2015 19:11
-
-
Save brianally/dad6b88decd45da3671b to your computer and use it in GitHub Desktop.
Ember.js embed link widget
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['embed-src'], | |
regex : /https?:/, | |
width : null, | |
height : null, | |
src : null, | |
srcGeneric: function() { | |
var src = this.get('src'); | |
// serving the URL without protocol won't work if the page that includes the embed | |
// is not using https :-( | |
return src; | |
// if (src) { | |
// return src.replace(this.get('regex'), ''); | |
// } | |
// return null; | |
}.property('src'), | |
embed: function() { | |
return [ | |
'<iframe src="', | |
this.get('srcGeneric'), | |
'" width="', | |
this.get('width'), | |
'" height="', | |
this.get('height'), | |
'"></iframe>' | |
].join(''); | |
}.property('srcGeneric', 'width', 'height'), | |
actions : { | |
toggleDisplay: function() { | |
var container = this.$().find('.embed-form'); | |
container.toggleClass('open'); | |
if (container.hasClass('open')) { | |
this.$().find('.embed-input').select(); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment