Skip to content
This repository
Browse code

マイページの"もっと見る"を修正

  • Loading branch information...
commit 864a81eb7f38db967e799e533614535f14860128 1 parent 0f95466
Yuya Nishiyama authored November 07, 2012
36  public/js/dist/chatroom.js
@@ -7,11 +7,14 @@
7 7
   syaberi.templates.chat.chatL = Handlebars.compile(
8 8
     '<div class="message-owner-inbox" id="chat-content-{{chatId}}">'+
9 9
         '<div class="owner-icon">'+
10  
-            '<img class="icon_m" src="{{userImage}}">'+
  10
+            '<a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a>'+
11 11
         '</div>'+
12 12
         '<div class="owner-titlebox">'+
13 13
             '<p class="owner-title">{{{message}}}</p>'+
14  
-            '<div class="owner-username"><a href="#">by.{{userName}}</a></div>'+
  14
+            '{{#if extImageUrl}}'+
  15
+            '<img src="{{extImageUrl}}" class="owner-img">'+
  16
+            '{{/if}}'+
  17
+            '<div class="owner-username"><a href="/users/{{userId}}">by.{{userName}}</a></div>'+
15 18
             '<div class="owner-date">{{time}} [1]'+
16 19
             '{{#if isHis}}'+
17 20
             '<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">'+
@@ -24,11 +27,14 @@
24 27
   syaberi.templates.chat.chatR = Handlebars.compile(
25 28
     '<div class="message-member-inbox" id="chat-content-{{chatId}}">'+
26 29
         '<div class="member-icon">'+
27  
-            '<img class="icon_m" src="{{userImage}}">'+
  30
+            '<a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a>'+
28 31
         '</div>'+
29 32
         '<div class="member-titlebox">'+
30 33
             '<p class="member-title">{{{message}}}</p>'+
31  
-            '<div class="member-username"><a href="#">by.{{userName}}</a></div>'+
  34
+            '{{#if extImageUrl}}'+
  35
+            '<img src="{{extImageUrl}}" class="member-img">'+
  36
+            '{{/if}}'+
  37
+            '<div class="member-username"><a href="/users/{{userId}}">by.{{userName}}</a></div>'+
32 38
             '<div class="member-date">{{time}} [2]'+
33 39
             '{{#if isHis}}'+
34 40
             '<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">'+
@@ -85,6 +91,7 @@
85 91
     initialize: function() {
86 92
       this.collection = new syaberi.Chats;
87 93
       this.uploadCancelFlg = 0;
  94
+      this.token = $('#token').val(); //for CSRF
88 95
     },
89 96
     submit: function(event) {
90 97
       var message = $.trim($('#message1').val());
@@ -104,7 +111,8 @@
104 111
           userImage: userImage,
105 112
           message: message,
106 113
           type: CHAT_COMMENT,
107  
-          isUrlOpen: isUrlOpen
  114
+          isUrlOpen: isUrlOpen,
  115
+          token: this.token
108 116
         });
109 117
 
110 118
         this.clearInputUserMessage();
@@ -134,7 +142,8 @@
134 142
           mode: 'destroy',
135 143
           chatroomId: chatroomId,
136 144
           chatId: chatId,
137  
-          userId: userId
  145
+          userId: userId,
  146
+          token: this.token
138 147
         });
139 148
       }
140 149
     },
@@ -215,8 +224,21 @@
215 224
         isOwner: userId === ownerId,
216 225
         isHis: userId === data.userId, //本人の書き込みを表すフラグ
217 226
         isInvite: status !== 2,
218  
-        isUrlOpen: isUrlOpen
  227
+        isUrlOpen: isUrlOpen,
  228
+        extImageUrl: ''
219 229
       };
  230
+
  231
+      // urlの判断
  232
+      if (syaberi.util.isUrl(data.message)) {
  233
+        var tmp_url = syaberi.util.getUrl(data.message);
  234
+
  235
+        // 画像urlの判断
  236
+        if (syaberi.util.isImageUrl(tmp_url)) {
  237
+          // 画像urlで値を上書き
  238
+          params.extImageUrl = tmp_url;
  239
+        }
  240
+      }
  241
+
220 242
       //オーナーのフキダシは向きを変える
221 243
       if (ownerId === data.userId) {
222 244
         chatTemplate = syaberi.templates.chat.chatL(params);
2  public/js/dist/chatroom.min.js
... ...
@@ -1 +1 @@
1  
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.chat={},e.templates.chat.chatL=Handlebars.compile('<div class="message-owner-inbox" id="chat-content-{{chatId}}"><div class="owner-icon"><img class="icon_m" src="{{userImage}}"></div><div class="owner-titlebox"><p class="owner-title">{{{message}}}</p><div class="owner-username"><a href="#">by.{{userName}}</a></div><div class="owner-date">{{time}} [1]{{#if isHis}}<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">{{/if}}</div></div></div>'),e.templates.chat.chatR=Handlebars.compile('<div class="message-member-inbox" id="chat-content-{{chatId}}"><div class="member-icon"><img class="icon_m" src="{{userImage}}"></div><div class="member-titlebox"><p class="member-title">{{{message}}}</p><div class="member-username"><a href="#">by.{{userName}}</a></div><div class="member-date">{{time}} [2]{{#if isHis}}<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">{{/if}}</div>{{#if isInvite}}{{#unless isUrlOpen}}{{#if isOwner}}<a href="javascript:void(0);" class="start_chat" data-userid="{{userId}}" data-chatid="{{chatId}}">[招待]</a>{{/if}}{{/unless}}{{/if}}</div></div>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chat=Backbone.Model.extend({id:null,userId:null,userName:null,type:null,body:null,image:null,time:null,url:"/chats"}),e.Chats=Backbone.Collection.extend({model:e.Chat,url:"/chats"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=1,n=2,r=3;e.ChatView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","keydown #message1":"keydown","click img.delete_cmt":"destroy","click a.start_chat":"invite","change #uploadings_input":"upload","change #message1":"uploadOff"},initialize:function(){this.collection=new e.Chats,this.uploadCancelFlg=0},submit:function(n){var r=$.trim($("#message1").val());if(r&&r!==""){var i=$("html").data("chatroom"),s=$("html").data("userid"),o=$("html").data("username"),u=$("html").data("userimage"),a=$("html").data("urlopen");return e.socket.emit("message",{mode:"create",chatroomId:i,userId:s,userName:o,userImage:u,message:r,type:t,isUrlOpen:a}),this.clearInputUserMessage(),!1}},keydown:function(e){if(e.shiftKey!==!0&&e.keyCode===13)return this.submit(e),!1},destroy:function(t){if(window.confirm("本当に削除しますか?")){var n=$(t.target),r=n.data("chatid"),i=$("html").data("chatroom"),s=$("html").data("userid");e.socket.emit("message",{mode:"destroy",chatroomId:i,chatId:r,userId:s})}},invite:function(e){var t=$(e.target),n=t.data("userid"),r=t.data("chatid"),i=$("html").data("chatroom");window.confirm("このユーザとチャットを開始しますか?")&&$.ajax({type:"POST",url:"/chatrooms/"+i+"/invite",data:"member="+n+"&chat="+r,success:function(e){location.href="/chatrooms/"+i+"/open"}})},upload:function(){$("#uploadings_input").upload("/upload",function(e){if(e){var t=e,n=t.split('": "'),r=n[1].split('"}</pre>'),i=$("input#uploadings_input").val().split("\\"),s;for(var o=0;o<i.length;o++)if(i[o].indexOf(".jpg")!=-1||i[o].indexOf(".jpeg")!=-1||i[o].indexOf(".JPG")!=-1||i[o].indexOf(".png")!=-1||i[o].indexOf(".PNG")!=-1||i[o].indexOf(".gif")!=-1||i[o].indexOf(".GIF")!=-1)s=i[o];$("#message1").val(s),this.uploadCancelFlg=1,$("#message1").attr("disabled","disabled"),$("#realUpfile").val(r[0])}},"html")},uploadOff:function(){$("#message1").removeAttr("disabled"),this.uploadCancelFlg===1&&($("input#uploadings_input").val(""),this.uploadCancelFlg=0)},appendMessage:function(t){var n,r=$("html").data("status"),i=$("html").data("urlopen"),s=$("html").data("userid"),o=$("html").data("ownerid"),u={chatId:t.chatId,userImage:t.userImage,userId:t.userId,userName:t.userName,time:t.time,message:t.message,isOwner:s===o,isHis:s===t.userId,isInvite:r!==2,isUrlOpen:i};o===t.userId?n=e.templates.chat.chatL(u):n=e.templates.chat.chatR(u),$("#lines1").append(n),!i&&t.userId===s&&o!=s&&$("#section_thread_bottom").animate({height:"hide",opacity:"hide"},"slow")},destroyMessage:function(e){var t=e.chatId,n=$("html").data("userid"),r=$("html").data("ownerid");n&&r!=n&&e.userId===n&&$("#section_thread_bottom").animate({height:"show",opacity:"1.0"},"slow"),$("#chat-content-"+t).animate({height:"hide",opacity:"hide"},"slow",function(){$("#chat-content-"+t).remove()})},render:function(){},clearInputUserMessage:function(){$("#message1").val("").focus(),$("#html_image_preview").remove(),$("#user_up_img").remove(),$("#drop_message").show()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=$("html").data("host"),n=$("html").data("chatroom"),r=$("html").data("urlopen"),i;r?i=t+"/chatrooms/"+n+"/open?id="+n+"&urlopen="+r:i=t+"/chatrooms/"+n+"?id="+n,e.socket=io.connect(i),$(function(){var t=new e.ChatView;t.render(),Backbone.emulateHTTP=!0,e.socket.on("connect",function(){}),e.socket.on("message",function(e){e.mode==="create"?t.appendMessage(e):e.mode==="destroy"&&t.destroyMessage(e)}),e.socket.on("disconnect",function(e){})})}.call(this);
  1
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.chat={},e.templates.chat.chatL=Handlebars.compile('<div class="message-owner-inbox" id="chat-content-{{chatId}}"><div class="owner-icon"><a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a></div><div class="owner-titlebox"><p class="owner-title">{{{message}}}</p>{{#if extImageUrl}}<img src="{{extImageUrl}}" class="owner-img">{{/if}}<div class="owner-username"><a href="/users/{{userId}}">by.{{userName}}</a></div><div class="owner-date">{{time}} [1]{{#if isHis}}<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">{{/if}}</div></div></div>'),e.templates.chat.chatR=Handlebars.compile('<div class="message-member-inbox" id="chat-content-{{chatId}}"><div class="member-icon"><a href="/users/{{userId}}"><img class="icon_m" src="{{userImage}}"></a></div><div class="member-titlebox"><p class="member-title">{{{message}}}</p>{{#if extImageUrl}}<img src="{{extImageUrl}}" class="member-img">{{/if}}<div class="member-username"><a href="/users/{{userId}}">by.{{userName}}</a></div><div class="member-date">{{time}} [2]{{#if isHis}}<img src="/img/remove.gif" width="12" height="12" alt="閉じる" class="delete_cmt" data-chatid="{{chatId}}">{{/if}}</div>{{#if isInvite}}{{#unless isUrlOpen}}{{#if isOwner}}<a href="javascript:void(0);" class="start_chat" data-userid="{{userId}}" data-chatid="{{chatId}}">[招待]</a>{{/if}}{{/unless}}{{/if}}</div></div>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chat=Backbone.Model.extend({id:null,userId:null,userName:null,type:null,body:null,image:null,time:null,url:"/chats"}),e.Chats=Backbone.Collection.extend({model:e.Chat,url:"/chats"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=1,n=2,r=3;e.ChatView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","keydown #message1":"keydown","click img.delete_cmt":"destroy","click a.start_chat":"invite","change #uploadings_input":"upload","change #message1":"uploadOff"},initialize:function(){this.collection=new e.Chats,this.uploadCancelFlg=0,this.token=$("#token").val()},submit:function(n){var r=$.trim($("#message1").val());if(r&&r!==""){var i=$("html").data("chatroom"),s=$("html").data("userid"),o=$("html").data("username"),u=$("html").data("userimage"),a=$("html").data("urlopen");return e.socket.emit("message",{mode:"create",chatroomId:i,userId:s,userName:o,userImage:u,message:r,type:t,isUrlOpen:a,token:this.token}),this.clearInputUserMessage(),!1}},keydown:function(e){if(e.shiftKey!==!0&&e.keyCode===13)return this.submit(e),!1},destroy:function(t){if(window.confirm("本当に削除しますか?")){var n=$(t.target),r=n.data("chatid"),i=$("html").data("chatroom"),s=$("html").data("userid");e.socket.emit("message",{mode:"destroy",chatroomId:i,chatId:r,userId:s,token:this.token})}},invite:function(e){var t=$(e.target),n=t.data("userid"),r=t.data("chatid"),i=$("html").data("chatroom");window.confirm("このユーザとチャットを開始しますか?")&&$.ajax({type:"POST",url:"/chatrooms/"+i+"/invite",data:"member="+n+"&chat="+r,success:function(e){location.href="/chatrooms/"+i+"/open"}})},upload:function(){$("#uploadings_input").upload("/upload",function(e){if(e){var t=e,n=t.split('": "'),r=n[1].split('"}</pre>'),i=$("input#uploadings_input").val().split("\\"),s;for(var o=0;o<i.length;o++)if(i[o].indexOf(".jpg")!=-1||i[o].indexOf(".jpeg")!=-1||i[o].indexOf(".JPG")!=-1||i[o].indexOf(".png")!=-1||i[o].indexOf(".PNG")!=-1||i[o].indexOf(".gif")!=-1||i[o].indexOf(".GIF")!=-1)s=i[o];$("#message1").val(s),this.uploadCancelFlg=1,$("#message1").attr("disabled","disabled"),$("#realUpfile").val(r[0])}},"html")},uploadOff:function(){$("#message1").removeAttr("disabled"),this.uploadCancelFlg===1&&($("input#uploadings_input").val(""),this.uploadCancelFlg=0)},appendMessage:function(t){var n,r=$("html").data("status"),i=$("html").data("urlopen"),s=$("html").data("userid"),o=$("html").data("ownerid"),u={chatId:t.chatId,userImage:t.userImage,userId:t.userId,userName:t.userName,time:t.time,message:t.message,isOwner:s===o,isHis:s===t.userId,isInvite:r!==2,isUrlOpen:i,extImageUrl:""};if(e.util.isUrl(t.message)){var a=e.util.getUrl(t.message);e.util.isImageUrl(a)&&(u.extImageUrl=a)}o===t.userId?n=e.templates.chat.chatL(u):n=e.templates.chat.chatR(u),$("#lines1").append(n),!i&&t.userId===s&&o!=s&&$("#section_thread_bottom").animate({height:"hide",opacity:"hide"},"slow")},destroyMessage:function(e){var t=e.chatId,n=$("html").data("userid"),r=$("html").data("ownerid");n&&r!=n&&e.userId===n&&$("#section_thread_bottom").animate({height:"show",opacity:"1.0"},"slow"),$("#chat-content-"+t).animate({height:"hide",opacity:"hide"},"slow",function(){$("#chat-content-"+t).remove()})},render:function(){},clearInputUserMessage:function(){$("#message1").val("").focus(),$("#html_image_preview").remove(),$("#user_up_img").remove(),$("#drop_message").show()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={},t=$("html").data("host"),n=$("html").data("chatroom"),r=$("html").data("urlopen"),i;r?i=t+"/chatrooms/"+n+"/open?id="+n+"&urlopen="+r:i=t+"/chatrooms/"+n+"?id="+n,e.socket=io.connect(i),$(function(){var t=new e.ChatView;t.render(),Backbone.emulateHTTP=!0,e.socket.on("connect",function(){}),e.socket.on("message",function(e){e.mode==="create"?t.appendMessage(e):e.mode==="destroy"&&t.destroyMessage(e)}),e.socket.on("disconnect",function(e){})})}.call(this);
36  public/js/dist/common.js
@@ -14683,6 +14683,42 @@ Handlebars.template = Handlebars.VM.template;
14683 14683
       var newdate = year+"-"+month+"-"+day+"T"+hour+":"+minute+":"+second+"Z";
14684 14684
 
14685 14685
       return newdate;
  14686
+    },
  14687
+    // URLかどうかの判定
  14688
+    isUrl: function(text) {
  14689
+      if (text.length == 0) {
  14690
+        return false;
  14691
+      }
  14692
+      text.match(/(http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=:;_]*)?)/);
  14693
+
  14694
+      if (RegExp.$1 != null && RegExp.$1.length > 0) {
  14695
+        return true;
  14696
+      }
  14697
+      return false;
  14698
+    },
  14699
+    // URLの取得
  14700
+    getUrl: function(text) {
  14701
+      if (text.length == 0) {
  14702
+        return false;
  14703
+      }
  14704
+      text.match(/(http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=:;_]*)?)/);
  14705
+
  14706
+      if (RegExp.$1 != null && RegExp.$1.length > 0) {
  14707
+        return RegExp.$1;
  14708
+      }
  14709
+      return false;
  14710
+    },
  14711
+    // 画像URLの判定
  14712
+    isImageUrl: function(url) {
  14713
+      if (url.length == 0) {
  14714
+        return false;
  14715
+      }
  14716
+      url.match(/(\.(jpg|jpeg|gif|png)$)/i);
  14717
+
  14718
+      if (RegExp.$1 != null && RegExp.$1.length > 0) {
  14719
+        return true;
  14720
+      }
  14721
+      return false;
14686 14722
     }
14687 14723
   };
14688 14724
 
2  public/js/dist/common.min.js
1 addition, 1 deletion not shown
4  public/js/dist/createChatroom.js
@@ -56,6 +56,7 @@
56 56
     initialize: function() {
57 57
       this.model = new syaberi.Chatroom;
58 58
       Backbone.Validation.bind(this);
  59
+      this.token = $('#token').val(); //for CSRF
59 60
     },
60 61
     submit: function(event) {
61 62
       event.preventDefault();
@@ -89,7 +90,8 @@
89 90
           categoryId: categoryId,
90 91
           title: title,
91 92
           description: description,
92  
-          publicYN: publicYN
  93
+          publicYN: publicYN,
  94
+          token: this.token
93 95
         }, {
94 96
           success: function(model, res) {
95 97
             var chatroomId = res.chatroomId;
2  public/js/dist/createChatroom.min.js
... ...
@@ -1 +1 @@
1  
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.CreateChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","blur input.title":"setSearchText","focus input.title":"clearSearchText"},initialize:function(){this.model=new e.Chatroom,Backbone.Validation.bind(this)},submit:function(e){e.preventDefault();var t=this;this._clearSearchText($("#title1")),this._clearSearchText($("#title2"));var n=$.trim($("#categoryId").val()),r=$.trim($("#title1").val()),i=$.trim($("#title2").val()),s=$.trim($("#description").val()),o=$("#publicYN").val();this.model.set({categoryId:n,title1:r,title2:i,description:s,publicYN:o});if(this.model.isValid()){var u=r+"けど、"+i+"について、話しませんか?";this.model.save({categoryId:n,title:u,description:s,publicYN:o},{success:function(e,t){var n=t.chatroomId;location.href="/chatrooms/"+n},error:function(e,t){alert(t.responseText)}})}this.model.bind("validated:invalid",function(e,n){for(key in n){var r=n[key];if(key==="title1"||key==="title2")key="title";$("#error_"+key).text(r)}t._setSearchText($("#title1")),t._setSearchText($("#title2"))})},clearSearchText:function(e){var t=$(e.target);this._clearSearchText(t)},_clearSearchText:function(e){e.val()===e.prop("defaultValue")&&e.css("color","#000").val("")},setSearchText:function(e){var t=$(e.target);this._setSearchText(t)},_setSearchText:function(e){$.trim(e.val())===""&&e.css("color","#999").val(e.prop("defaultValue"))},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.CreateChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
  1
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.CreateChatroomView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit","blur input.title":"setSearchText","focus input.title":"clearSearchText"},initialize:function(){this.model=new e.Chatroom,Backbone.Validation.bind(this),this.token=$("#token").val()},submit:function(e){e.preventDefault();var t=this;this._clearSearchText($("#title1")),this._clearSearchText($("#title2"));var n=$.trim($("#categoryId").val()),r=$.trim($("#title1").val()),i=$.trim($("#title2").val()),s=$.trim($("#description").val()),o=$("#publicYN").val();this.model.set({categoryId:n,title1:r,title2:i,description:s,publicYN:o});if(this.model.isValid()){var u=r+"けど、"+i+"について、話しませんか?";this.model.save({categoryId:n,title:u,description:s,publicYN:o,token:this.token},{success:function(e,t){var n=t.chatroomId;location.href="/chatrooms/"+n},error:function(e,t){alert(t.responseText)}})}this.model.bind("validated:invalid",function(e,n){for(key in n){var r=n[key];if(key==="title1"||key==="title2")key="title";$("#error_"+key).text(r)}t._setSearchText($("#title1")),t._setSearchText($("#title2"))})},clearSearchText:function(e){var t=$(e.target);this._clearSearchText(t)},_clearSearchText:function(e){e.val()===e.prop("defaultValue")&&e.css("color","#000").val("")},setSearchText:function(e){var t=$(e.target);this._setSearchText(t)},_setSearchText:function(e){$.trim(e.val())===""&&e.css("color","#999").val(e.prop("defaultValue"))},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.CreateChatroomView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
66  public/js/dist/mypage.js
@@ -6,34 +6,25 @@
6 6
 
7 7
   //チャットルーム一覧
8 8
   syaberi.templates.mypage.list = Handlebars.compile(
9  
-    '<article class="timeline">'+
10  
-      '<div class="smatc">'+
11  
-        '<div class="topthumb_b">'+
12  
-        /**
13  
-          '<a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">'+
14  
-            '<img src="/data/{{chatroom.id}}/images/thumb_m.jpg"'+
15  
-              'onerror=\'this.src="/img/common/nowprinting_m.jpg"\' class="dec_thumb_m">'+
16  
-          '</a>'+
17  
-          **/
  9
+    '<div class="room">'+
  10
+        '<div class="room-inbox">'+
  11
+            '<div class="room-icon">'+
  12
+                '<a href="http://{{host}}{{chatroom.ownerpage}}">'+
  13
+                  '<img class="icon_m" src="{{chatroom.ownerimage}}">'+
  14
+                '</a>'+
  15
+            '</div>'+
  16
+            '<div class="room-titlebox">'+
  17
+                '<h2 class="room-title"><a href="http://{{host}}/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h2>'+
  18
+                '<div class="cat-icon"><a href="#">{{chatroom.category}}</a></div>'+
  19
+                '<div class="room-username"><a href="http://{{host}}{{chatroom.ownerpage}}">by.{{chatroom.owner}}</a></div>'+
  20
+            '</div>'+
  21
+            '<div class="room-button">'+
  22
+                '<a href="http://{{host}}/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">'+
  23
+                  '<input type="button" class="button_yg" value="話す">'+
  24
+                '</a>'+
  25
+            '</div>'+
18 26
         '</div>'+
19  
-        '<h3><a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h3>'+
20  
-        '<p>{{chatroom.description}}</p>'+
21  
-        '<table class="table_b">'+
22  
-          '<tr>'+
23  
-            '<td>'+
24  
-            '<ul class="article_ul_b" id="dec-supporters-{{chatroom.id}}"></ul>'+
25  
-            '</td>'+
26  
-            '<td class="join_b">'+
27  
-              '{{chatroom.member}}<span>人<br>参加</span>'+
28  
-            '</td>'+
29  
-          '</tr>'+
30  
-        '</table>'+
31  
-        '<div class="to_detailb padt5 txtc">'+
32  
-        '<a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">'+
33  
-          '<img src="/img/top_to_detail_b.gif" alt="詳細">'+
34  
-        '</a>'+
35  
-      '</div>'+
36  
-    '</article>'
  27
+    '</div>'
37 28
   );
38 29
 
39 30
   //プロフィール編集
@@ -65,7 +56,7 @@
65 56
         '</tr>'+
66 57
       '</table>'+
67 58
       '<div class="txtc magt20 magb200">'+
68  
-        '<input type="image" src="/img/makecommunity_submit.png" width="396" height="73" alt="送信" id="submit_1">'+
  59
+        '<input type="button" class="button_g full_width" id="submit_1" value="保存">'+
69 60
       '</div>'+
70 61
     '</form>'
71 62
   );
@@ -169,23 +160,24 @@
169 160
       this.model = new syaberi.User;
170 161
       this.collection = new syaberi.Chatrooms;
171 162
       this.mode = 'owner';
  163
+      this.token = $('#token').val(); //for CSRF
172 164
       Backbone.Validation.bind(this);
173 165
     },
174 166
     getOwnerChatrooms: function(event) {
175 167
       this.init_list();
176  
-      $('#ownerChatrooms').addClass('on');
  168
+      $('li', '#owner-chatrooms').addClass('active');
177 169
       this.mode = 'owner';
178 170
       this.getChatrooms();
179 171
     },
180 172
     getEntryChatrooms: function(event) {
181 173
       this.init_list();
182  
-      $('#entryChatrooms').addClass('on');
  174
+      $('li', '#entry-chatrooms').addClass('active');
183 175
       this.mode = 'entry';
184 176
       this.getChatrooms();
185 177
     },
186 178
     getJoinChatrooms: function(event) {
187 179
       this.init_list();
188  
-      $('#joinChatrooms').addClass('on');
  180
+      $('li', '#join-chatrooms').addClass('active');
189 181
       this.mode = 'join';
190 182
       this.getChatrooms();
191 183
     },
@@ -212,6 +204,7 @@
212 204
           if (chatrooms) {
213 205
             $.each(response.chatrooms, function(key, chatroom) {
214 206
               var template = syaberi.templates.mypage.list({
  207
+                host: $('html').data('host'),
215 208
                 chatroom: chatroom,
216 209
                 isUrlOpen: self.mode === 'entry' ? false : true
217 210
               });
@@ -231,6 +224,8 @@
231 224
       var description = $('html').data('profiledescription');
232 225
 
233 226
       this.init_list();
  227
+      $('li', '#edit-profile').addClass('active');
  228
+
234 229
       var template = syaberi.templates.mypage.profile({
235 230
         userName: userName,
236 231
         email: email,
@@ -258,7 +253,8 @@
258 253
           userId: userId,
259 254
           userName: userName,
260 255
           email: email,
261  
-          description: description
  256
+          description: description,
  257
+          token: this.token
262 258
         }, {
263 259
           success: function() {
264 260
             location.href = '/mypage';
@@ -279,9 +275,11 @@
279 275
       this.getOwnerChatrooms();
280 276
     },
281 277
     init_list: function() {
282  
-      $('article', '#hakunetsu_area').removeClass('on');
  278
+      $('li', '#owner-chatrooms').removeClass('active');
  279
+      $('li', '#join-chatrooms').removeClass('active');
  280
+      $('li', '#edit-profile').removeClass('active');
283 281
       return $('#article_area').empty();
284  
-    },
  282
+    }
285 283
   });
286 284
 
287 285
 }).call(this);
2  public/js/dist/mypage.min.js
... ...
@@ -1 +1 @@
1  
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.mypage={},e.templates.mypage.list=Handlebars.compile('<article class="timeline"><div class="smatc"><div class="topthumb_b"></div><h3><a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h3><p>{{chatroom.description}}</p><table class="table_b"><tr><td><ul class="article_ul_b" id="dec-supporters-{{chatroom.id}}"></ul></td><td class="join_b">{{chatroom.member}}<span>人<br>参加</span></td></tr></table><div class="to_detailb padt5 txtc"><a href="/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}"><img src="/img/top_to_detail_b.gif" alt="詳細"></a></div></article>'),e.templates.mypage.profile=Handlebars.compile('<form action="" method=""><table id="makecommunity_table"><tr><th>ニックネーム<br><span style="color:#FF1881">※必須</span></th><td><div class="input_makecommunity_name_area"><input type="text" name="userName" id="userName" value="{{{userName}}}"></div><span id="error_userName" class="error"></span></td></tr><tr><th>メールアドレス<br><span style="color:#FF1881">※必須</span></th><td><div class="input_makecommunity_name_area"><input type="text" name="email" id="email" value="{{email}}"></div><span id="error_email" class="error"></span></td></tr><tr><th>紹介文</th><td><div class="input_makecommunity_name_area"><textarea name="description" id="description" cols="80" rows="8">{{{description}}}</textarea></div><span id="error_description" class="error"></span></td></tr></table><div class="txtc magt20 magb200"><input type="image" src="/img/makecommunity_submit.png" width="396" height="73" alt="送信" id="submit_1"></div></form>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.MyPageView=Backbone.View.extend({el:$("html"),events:{"click #owner-chatrooms":"getOwnerChatrooms","click #entry-chatrooms":"getEntryChatrooms","click #join-chatrooms":"getJoinChatrooms","click #edit-profile":"showProfile","click #submit_1":"editProfile","click #view-more-events":"getMore"},initialize:function(){this.model=new e.User,this.collection=new e.Chatrooms,this.mode="owner",Backbone.Validation.bind(this)},getOwnerChatrooms:function(e){this.init_list(),$("#ownerChatrooms").addClass("on"),this.mode="owner",this.getChatrooms()},getEntryChatrooms:function(e){this.init_list(),$("#entryChatrooms").addClass("on"),this.mode="entry",this.getChatrooms()},getJoinChatrooms:function(e){this.init_list(),$("#joinChatrooms").addClass("on"),this.mode="join",this.getChatrooms()},getMore:function(e){var t=this.collection.nextPage;this.getChatrooms(t)},getChatrooms:function(t){var n=this;t=t||1;var r=$("html").data("profileid");$("#view-more-events").hide(),$("#view-more-loader").show(),this.collection.fetch({data:{profileId:r,mode:this.mode,page:t},success:function(t,r){var i=r.chatrooms;i&&$.each(r.chatrooms,function(t,r){var i=e.templates.mypage.list({chatroom:r,isUrlOpen:n.mode==="entry"?!1:!0});$("#article_area").append(i)}),$("#view-more-loader").hide(),r.nextPage!==0&&$("#view-more-events").show()}})},showProfile:function(t){var n=$("html").data("profilename"),r=$("html").data("profileemail"),i=$("html").data("profiledescription");this.init_list();var s=e.templates.mypage.profile({userName:n,email:r,description:i});$("#article_area").append(s)},editProfile:function(e){e.preventDefault();var t=$("html").data("profileid"),n=$.trim($("#userName").val()),r=$.trim($("#email").val()),i=$.trim($("#description").val());this.model.set({userId:t,userName:n,email:r,description:i,isUpdate:!0}),this.model.isValid()&&this.model.save({userId:t,userName:n,email:r,description:i},{success:function(){location.href="/mypage"},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})},render:function(){this.getOwnerChatrooms()},init_list:function(){return $("article","#hakunetsu_area").removeClass("on"),$("#article_area").empty()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.MyPageView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
  1
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.templates=this.syaberi.templates!=null?this.syaberi.templates:this.syaberi.templates={},e.templates.mypage={},e.templates.mypage.list=Handlebars.compile('<div class="room"><div class="room-inbox"><div class="room-icon"><a href="http://{{host}}{{chatroom.ownerpage}}"><img class="icon_m" src="{{chatroom.ownerimage}}"></a></div><div class="room-titlebox"><h2 class="room-title"><a href="http://{{host}}/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}">{{chatroom.title}}</a></h2><div class="cat-icon"><a href="#">{{chatroom.category}}</a></div><div class="room-username"><a href="http://{{host}}{{chatroom.ownerpage}}">by.{{chatroom.owner}}</a></div></div><div class="room-button"><a href="http://{{host}}/chatrooms/{{chatroom.id}}{{#if isUrlOpen}}/open{{/if}}"><input type="button" class="button_yg" value="話す"></a></div></div></div>'),e.templates.mypage.profile=Handlebars.compile('<form action="" method=""><table id="makecommunity_table"><tr><th>ニックネーム<br><span style="color:#FF1881">※必須</span></th><td><div class="input_makecommunity_name_area"><input type="text" name="userName" id="userName" value="{{{userName}}}"></div><span id="error_userName" class="error"></span></td></tr><tr><th>メールアドレス<br><span style="color:#FF1881">※必須</span></th><td><div class="input_makecommunity_name_area"><input type="text" name="email" id="email" value="{{email}}"></div><span id="error_email" class="error"></span></td></tr><tr><th>紹介文</th><td><div class="input_makecommunity_name_area"><textarea name="description" id="description" cols="80" rows="8">{{{description}}}</textarea></div><span id="error_description" class="error"></span></td></tr></table><div class="txtc magt20 magb200"><input type="button" class="button_g full_width" id="submit_1" value="保存"></div></form>')}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.Chatroom=Backbone.Model.extend({id:null,title1:null,title2:null,description:null,categoryId:null,userId:null,publicYN:null,validation:{categoryId:[{required:!0,msg:"カテゴリを選択してください"}],title1:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],title2:[{required:!0,msg:"部屋名を入力してください"},{rangeLength:[0,100],msg:"部屋名は100文字以下で入力してください"}],description:[],publicYN:[{required:!0,msg:"公開設定を選択してください"}]},url:"/chatrooms"}),e.Chatrooms=Backbone.Collection.extend({model:e.Chatroom,url:"/chatrooms",nextPage:2,parse:function(e){return this.nextPage=e.nextPage,e.chatrooms}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.MyPageView=Backbone.View.extend({el:$("html"),events:{"click #owner-chatrooms":"getOwnerChatrooms","click #entry-chatrooms":"getEntryChatrooms","click #join-chatrooms":"getJoinChatrooms","click #edit-profile":"showProfile","click #submit_1":"editProfile","click #view-more-events":"getMore"},initialize:function(){this.model=new e.User,this.collection=new e.Chatrooms,this.mode="owner",this.token=$("#token").val(),Backbone.Validation.bind(this)},getOwnerChatrooms:function(e){this.init_list(),$("li","#owner-chatrooms").addClass("active"),this.mode="owner",this.getChatrooms()},getEntryChatrooms:function(e){this.init_list(),$("li","#entry-chatrooms").addClass("active"),this.mode="entry",this.getChatrooms()},getJoinChatrooms:function(e){this.init_list(),$("li","#join-chatrooms").addClass("active"),this.mode="join",this.getChatrooms()},getMore:function(e){var t=this.collection.nextPage;this.getChatrooms(t)},getChatrooms:function(t){var n=this;t=t||1;var r=$("html").data("profileid");$("#view-more-events").hide(),$("#view-more-loader").show(),this.collection.fetch({data:{profileId:r,mode:this.mode,page:t},success:function(t,r){var i=r.chatrooms;i&&$.each(r.chatrooms,function(t,r){var i=e.templates.mypage.list({host:$("html").data("host"),chatroom:r,isUrlOpen:n.mode==="entry"?!1:!0});$("#article_area").append(i)}),$("#view-more-loader").hide(),r.nextPage!==0&&$("#view-more-events").show()}})},showProfile:function(t){var n=$("html").data("profilename"),r=$("html").data("profileemail"),i=$("html").data("profiledescription");this.init_list(),$("li","#edit-profile").addClass("active");var s=e.templates.mypage.profile({userName:n,email:r,description:i});$("#article_area").append(s)},editProfile:function(e){e.preventDefault();var t=$("html").data("profileid"),n=$.trim($("#userName").val()),r=$.trim($("#email").val()),i=$.trim($("#description").val());this.model.set({userId:t,userName:n,email:r,description:i,isUpdate:!0}),this.model.isValid()&&this.model.save({userId:t,userName:n,email:r,description:i,token:this.token},{success:function(){location.href="/mypage"},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})},render:function(){this.getOwnerChatrooms()},init_list:function(){return $("li","#owner-chatrooms").removeClass("active"),$("li","#join-chatrooms").removeClass("active"),$("li","#edit-profile").removeClass("active"),$("#article_area").empty()}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.MyPageView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
4  public/js/dist/register.js
@@ -41,6 +41,7 @@
41 41
     },
42 42
     initialize: function() {
43 43
       this.model = new syaberi.User;
  44
+      this.token = $('#token').val(); //for CSRF
44 45
       Backbone.Validation.bind(this);
45 46
     },
46 47
     submit: function(event) {
@@ -64,7 +65,8 @@
64 65
           this.model.save({
65 66
             userName: userName,
66 67
             email: email,
67  
-            description: description
  68
+            description: description,
  69
+            token: this.token
68 70
           }, {
69 71
             success: function() {
70 72
               var returnUrl = $.cookie('returnUrl');
2  public/js/dist/register.min.js
... ...
@@ -1 +1 @@
1  
-(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.RegisterView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit"},initialize:function(){this.model=new e.User,Backbone.Validation.bind(this)},submit:function(e){e.preventDefault();var t=$.trim($("#userName").val()),n=$.trim($("#email").val()),r=$.trim($("#description").val()),i=$("#terms_check").is(":checked");i?(this.model.set({userName:t,email:n,description:r}),this.model.isValid()&&this.model.save({userName:t,email:n,description:r},{success:function(){var e=$.cookie("returnUrl");location.href=e},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})):alert("利用規約に同意する必要があります")},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.RegisterView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
  1
+(function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.User=Backbone.Model.extend({id:null,userName:null,email:null,description:null,validation:{userName:[{required:!0,msg:"ニックネームを入力してください"},{rangeLength:[1,255],msg:"ニックネームは255文字以下で入力してください"}],email:[{required:!0,msg:"メールアドレスを入力してください"},{pattern:"email",msg:"メールアドレスの形式が不正です。"},{rangeLength:[3,255],msg:"メールアドレスは3文字以上255文字以下で入力してください"}],description:[]},url:"/users"}),e.Users=Backbone.Collection.extend({model:e.User,url:"/users"})}).call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};e.RegisterView=Backbone.View.extend({el:$("html"),events:{"click #submit_1":"submit"},initialize:function(){this.model=new e.User,this.token=$("#token").val(),Backbone.Validation.bind(this)},submit:function(e){e.preventDefault();var t=$.trim($("#userName").val()),n=$.trim($("#email").val()),r=$.trim($("#description").val()),i=$("#terms_check").is(":checked");i?(this.model.set({userName:t,email:n,description:r}),this.model.isValid()&&this.model.save({userName:t,email:n,description:r,token:this.token},{success:function(){var e=$.cookie("returnUrl");location.href=e},error:function(e,t){alert(t.responseText)}}),this.model.bind("validated:invalid",function(e,t){for(key in t)$("#error_"+key).text(t[key])})):alert("利用規約に同意する必要があります")},render:function(){}})}.call(this),function(){var e=this.syaberi!=null?this.syaberi:this.syaberi={};$(function(){var t=new e.RegisterView;t.render(),Backbone.emulateHTTP=!0})}.call(this);
1  views/mypage.ejs
@@ -88,6 +88,7 @@
88 88
                 </div>
89 89
 
90 90
                 <div id="article_area"></div><!-- article_area -->
  91
+                <div id="view-more-events"><a href="javascript:void(0);"><input type="button" class="button_yg full_width" value="もっと見る"></a></div>
91 92
 
92 93
             </div><!-- left-content -->
93 94
 

0 notes on commit 864a81e

Please sign in to comment.
Something went wrong with that request. Please try again.