summaryrefslogtreecommitdiffstats
path: root/media/js/views/modals.js
diff options
context:
space:
mode:
Diffstat (limited to 'media/js/views/modals.js')
-rw-r--r--media/js/views/modals.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/media/js/views/modals.js b/media/js/views/modals.js
index e1d2fa7..a6d1c41 100644
--- a/media/js/views/modals.js
+++ b/media/js/views/modals.js
@@ -86,6 +86,29 @@
}
});
+ window.LCB.RoomPasswordModalView = Backbone.View.extend({
+ events: {
+ 'click .btn-primary': 'enterRoom'
+ },
+ initialize: function(options) {
+ this.render();
+ this.$password = this.$('input.lcb-room-password-required');
+ },
+ render: function() {
+ // this.$el.on('shown.bs.modal hidden.bs.modal',
+ // _.bind(this.refresh, this));
+ },
+ show: function(options) {
+ this.callback = options.callback;
+ this.$password.val('');
+ this.$el.modal('show');
+ },
+ enterRoom: function() {
+ this.$el.modal('hide');
+ this.callback(this.$password.val());
+ }
+ });
+
window.LCB.AuthTokensModalView = Backbone.View.extend({
events: {
'click .generate-token': 'generateToken',
@@ -176,4 +199,67 @@
}
});
+ window.LCB.GiphyModalView = Backbone.View.extend({
+ events: {
+ 'keypress .search-giphy': 'stopReturn',
+ 'keyup .search-giphy': 'loadGifs'
+ },
+ initialize: function(options) {
+ this.render();
+ },
+ render: function() {
+ this.$el.on('shown.bs.modal hidden.bs.modal',
+ _.bind(this.refresh, this));
+ },
+ refresh: function() {
+ this.$el.find('.giphy-results ul').empty();
+ this.$('.search-giphy').val('').focus();
+ },
+ stopReturn: function(e) {
+ if(e.keyCode === 13) {
+ return false;
+ }
+ },
+ loadGifs: _.throttle(function() {
+ console.log(1)
+ var that = this;
+ var search = this.$el.find('.search-giphy').val();
+
+ $.get('https://api.giphy.com/v1/gifs/search?limit=24&rating=pg-13&api_key=dc6zaTOxFJmzC&q=' + search)
+ .done(function(result) {
+ var images = result.data.filter(function(entry) {
+ return entry.images.fixed_width.url;
+ }).map(function(entry) {
+ return entry.images.fixed_width.url;
+ });
+
+ that.appendGifs(images);
+ });
+ }, 400, {leading: false}),
+ appendGifs: function(images) {
+ var eles = images.map(function(url) {
+ var that = this;
+ var $img = $('<img src="' + url +
+ '" alt="gif" data-dismiss="modal"/></li>');
+
+ $img.click(function() {
+ var src = $(this).attr('src');
+ $('.lcb-entry-input:visible').val(src);
+ $('.lcb-entry-button:visible').click();
+ that.$el.modal('hide');
+ });
+
+ return $("<li>").append($img);
+ }, this);
+
+ var $div = this.$el.find('.giphy-results ul');
+
+ $div.empty();
+
+ eles.forEach(function($ele) {
+ $div.append($ele);
+ });
+ }
+ });
+
}(window, $, _);