Browse code

Backbonove view a templates pre popup (cherry picked from commit 0920812)

Cinan Rakosnik authored on 16/05/2013 at 11:29:41
Showing 6 changed files
... ...
@@ -10,6 +10,9 @@
10 10
 #= require _main
11 11
 #= require chat
12 12
 
13
+aa = new Xmpp.Views.Popup.NewAccountView()
14
+aa.render();
15
+
13 16
 App.Com.connect( (connected_jid) ->
14 17
   App.Com.initRoster(->
15 18
     App.Com.startFetchingVcards()
16 19
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+%h1 Add new account
1
+%form{ action: '#', id: 'asd' }
2
+  %label{for: 'jid'}
3
+    %strong Jabber ID
4
+  %input{type: 'text', name: 'jid', class: 'text', placeholder: 'nick@example.com'}
5
+
6
+  %label{for: 'pass'}
7
+    %strong Password
8
+  %input{type: 'password', name: 'password', class: 'text'}
9
+
10
+  %input{type: 'submit', value: "#{I18n.t('sessions.new.form-send')}", class: 'button'}
0 11
\ No newline at end of file
1 12
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+%a.close.icon-x{ alt: "#{I18n.t('chat.close')}", href: '#' }
0 1
\ No newline at end of file
1 2
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+Xmpp.Views.Popup ||= {}
1
+
2
+class Xmpp.Views.Popup.PopupView extends Backbone.View
3
+  superTemplate: JST["backbone/templates/popup/popup"]
4
+  el: $('#js-popup')
5
+
6
+  render: (childHtml) ->
7
+    $(@el).html(@superTemplate()).append(childHtml)
0 8
\ No newline at end of file
1 9
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+Xmpp.Views.Popup ||= {}
1
+
2
+class Xmpp.Views.Popup.NewAccountView extends Xmpp.Views.Popup.PopupView
3
+  template: JST["backbone/templates/popup/add_account"]
4
+
5
+  events:
6
+    'submit form': 'addAccount'
7
+
8
+  render: ->
9
+    super(@template())
10
+    $(@el).css(width: '20%')
11
+
12
+  addAccount: (e) ->
13
+    e.preventDefault()
14
+    jid = $(@el).find('input[name=jid]').val()
15
+    pass = $(@el).find('input[name=password]').val()
16
+    $.ajax(
17
+      url: '/sessions'
18
+      type: 'POST'
19
+      data:
20
+        jid: jid,
21
+        password: pass,
22
+        override: 1
23
+      success: (msg) ->
24
+        App.debug msg
25
+    )
0 26
\ No newline at end of file
... ...
@@ -6,9 +6,11 @@
6 6
     I18n.defaultLocale = "#{I18n.default_locale}";
7 7
     I18n.locale = "#{I18n.locale}";
8 8
 
9
-- if flash[:notice]
10
-  %div.alert.alert-notice
11
-    = flash[:notice]
9
+%div.chat-alert.alert-notice.no-top-border.top-border#js-popup
10
+  - if flash[:notice]
11
+    %a.close.icon-x{ alt: "#{I18n.t('chat.close')}", href: '#' }
12
+    %h1
13
+      = flash[:notice]
12 14
 
13 15
 .container
14 16
   .leftside.left