Browse Source

remove use of modal dialogs

damien 11 years ago
parent
commit
1279ab8b14
2 changed files with 171 additions and 101 deletions
  1. 73 97
      pboard/pboard/templates/dashboard.mak
  2. 98 4
      pboard/pboard/templates/master.mak

+ 73 - 97
pboard/pboard/templates/dashboard.mak View File

@@ -1,45 +1,64 @@
1 1
 <%inherit file="local:templates.master"/>
2
-<%def name="get_icon_class_from_node_type(node_type)">
3 2
 
4
-</%def>
5 3
 
6
-<%def name="node_treeview(node_list, indentation=0)">
7
-  % if len(node_list)>0:
8
-    <!--ul style="list-style:none; margin-left: ${(indentation+1)*0.5}em;"-->
9
-    % for node in node_list:
10
-      <tr title="Last updated: ${node.updated_at}">
11
-        <td style="padding-left: ${(indentation+1)*0.5}em;">
12
-          <a href="?node=${node.node_id}" title="${node.data_label}">
13
-            <i class='${node.getIconClass()}'></i>
14
-            % if len(node.data_label)<=15:
15
-              ${node.data_label}
16
-            % else:
17
-              ${node.data_label[0:15]}...
18
-            % endif
19
-          </a>
20
-        </td>
21
-        <td class="text-right">
22
-          <a href="${tg.url('/move_node_upper?node_id=%i'%(node.node_id))}" title="Move up"><i class=" icon-g-up-arrow"></i></a>
23
-          <a href="${tg.url('/move_node_lower?node_id=%i'%(node.node_id))}" title="Move down"><i class=" icon-g-down-arrow"></i></a>
24
-          <a href="" title="Edit"><i class="icon-g-edit"></i></a>
25
-        </td>
26
-      </tr>
27
-      ${node_treeview(node.getChildren(), indentation+1)}
28
-    % endfor
29
-    <!--/ul-->
4
+
5
+<%def name="node_treeview(node_list, indentation=-1)">
6
+  % if indentation==-1:
7
+    <tr>
8
+      <td style="padding-left: ${(indentation+1)*0.8}em;">
9
+        <a href="?node=0" title="${_('Root')}">
10
+          <i class='icon-g-folder-open'></i>
11
+          ${_('Root')}
12
+        </a>
13
+      </td>
14
+      <td class="text-right">
15
+        <div class="pod-toolbar">
16
+          <a href="${tg.url('/create_document?parent_id=0')}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
17
+        </div>
18
+      </td>
19
+    </tr>
20
+    ${node_treeview(node_list, 0)}
21
+  % else:
22
+    % if len(node_list)>0:
23
+      % for node in node_list:
24
+        <tr title="Last updated: ${node.updated_at}">
25
+          <td style="padding-left: ${(indentation+1)*0.5}em;">
26
+            <a href="?node=${node.node_id}" title="${node.data_label}">
27
+              <i class='${node.getIconClass()}'></i>
28
+              % if len(node.data_label)<=15:
29
+                ${node.data_label}
30
+              % else:
31
+                ${node.data_label[0:15]}...
32
+              % endif
33
+            </a>
34
+          </td>
35
+          <td class="text-right">
36
+            <div class="pod-toolbar">
37
+              <a href="${tg.url('/move_node_upper?node_id=%i'%(node.node_id))}" title="${_('Move up')}"><i class="icon-g-up-arrow"></i></a>
38
+              <a href="${tg.url('/move_node_lower?node_id=%i'%(node.node_id))}" title="${_('Move down')}"><i class="icon-g-down-arrow"></i></a>
39
+              <a href="${tg.url('/create_document?parent_id=%i'%(node.node_id))}" title="${_('Add child document')}"><i class="icon-g-circle-plus"></i></a>
40
+            </div>
41
+          </td>
42
+        </tr>
43
+        ${node_treeview(node.getChildren(), indentation+1)}
44
+      % endfor
45
+    % endif
30 46
   % endif
31 47
 </%def>
32 48
 
33
-<%def name="node_treeview_in_select_field(node_list, indentation)">
49
+<%def name="node_treeview_in_select_field(node_list, indentation, selected_id=0)">
34 50
     % if len(node_list)>0:
35 51
       % if indentation==0:
36 52
         <option style="margin-left: ${0.5*indentation}em; color: #CCC;" value="0">no parent...</option>
37 53
       % endif
38 54
       % for node in node_list:
39
-        <option style="margin-left: ${0.5*indentation}em;" value="${node.node_id}">${node.data_label}</option>
40
-        ${node_treeview_in_select_field(node.getChildren(), indentation+1)}
55
+        % if selected_id!=node.node_id:
56
+          <option style="margin-left: ${0.5*indentation}em;" value="${node.node_id}">${node.data_label}</option>
57
+        % else:
58
+          <option style="margin-left: ${0.5*indentation}em;" value="${node.node_id}" selected>${node.data_label}</option>
59
+        % endif
60
+        ${node_treeview_in_select_field(node.getChildren(), indentation+1, selected_id)}
41 61
       % endfor
42
-      </ul>
43 62
     % endif
44 63
 </%def>
45 64
 
@@ -53,48 +72,6 @@ Learning TurboGears 2.3: Quick guide to the Quickstart pages.
53 72
         Documents
54 73
       </legend>
55 74
 
56
-      <!-- Button to trigger modal -->
57
-      <p>
58
-        <a href="#addFolderNode" role="button" class="btn" data-toggle="modal">
59
-          <i class="icon-g-circle-plus"></i> Create document</a>
60
-      </p>
61
-      <!-- Modal -->
62
-      <div id="addFolderNode" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
63
-        <div class="modal-header">
64
-          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
65
-          <h3 id="myModalLabel">Create a new page</h3>
66
-        </div>
67
-        <div class="modal-body">
68
-          <form id="create_document_form" method="POST" action="${tg.url('/create_document')}" class="form-horizontal">
69
-            <div class="control-group">
70
-              <label class="control-label" for="data_label">Title</label>
71
-              <div class="controls">
72
-                <input type="text" id="data_label" name="data_label" placeholder="page title...">
73
-              </div>
74
-            </div>
75
-            <div class="control-group">
76
-              <label class="control-label" for="parent_id">As child of...</label>
77
-              <div class="controls">
78
-                <select id="parent_id" name="parent_id" placeholder="as child of...">
79
-                  ${node_treeview_in_select_field(root_node_list, 0)}
80
-                </select>
81
-              </div>
82
-            </div>
83
-            <div class="control-group">
84
-              <label class="control-label" for="data_content">Description</label>
85
-              <div class="controls">
86
-
87
-                <textarea id="data_content" name="data_content"></textarea>
88
-              </div>
89
-            </div>
90
-          </form>
91
-        </div>
92
-        <div class="modal-footer">
93
-          <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
94
-          <button id="create_document_save_button" class="btn btn-primary">Save changes</button>
95
-        </div>
96
-      </div>
97
-
98 75
       <div>
99 76
         <table class="table table-striped table-hover table-condensed">
100 77
           ${node_treeview(root_node_list)}
@@ -103,49 +80,48 @@ Learning TurboGears 2.3: Quick guide to the Quickstart pages.
103 80
     </div>
104 81
     <div class="span5">
105 82
       <div class="page-header">
106
-        <h3>${current_node.data_label}</h3>
83
+        <h3 id="current-document-title">${current_node.data_label}</h3>
84
+        <form id="current-document-title-edit-form" method='post' action='${tg.url('/edit_label')}'>
85
+          <div class="input-prepend input-append">
86
+            <input type='hidden' name='node_id' value='${current_node.node_id}'/>
87
+            <button id="current-document-title-edit-cancel-button" type="button" class="btn" title="${_('Cancel editing')}"><i class="icon-g-ban"></i></button>
88
+            <input type='text' name='data_label' value='${current_node.data_label}' class="span2" />
89
+            <button id='current-document-title-save-cancel-button' type="button" class="btn" title="${_('Save')}"><i class="icon-g-edit"></i></button>
90
+          </div>
91
+        </form>
107 92
       </div>
108 93
 
109
-      <div class="btn-group">
110
-        <button class="btn"><i class="icon-g-edit"></i> Edit</button>
111
-
112
-      </div>
113 94
 
114 95
       <div class="btn-group">
115 96
         <a class="btn btn-primary" href="#"><i class="icon-g-stats icon-g-white"></i> Status</a>
116 97
         <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
117 98
         <ul class="dropdown-menu">
118
-        
119
-          
120
-  
121 99
           <li><a class="btn-success" href="#"><i class="icon-g-sun"></i> Open</a></li>
122 100
           <li><a class="btn-warning" href="#"><i class="icon-g-rotation-lock"></i> in Standby</a></li>
123 101
           <li><a class="btn-danger"  href="#"><i class="icon-g-circle-exclamation-mark"></i> Hot</a></li>
124 102
           <li><a class="btn " href="#"><i class="icon-g-ok"></i> Finished</a></li>
125 103
           <li><a class="btn btn-disabled" href="#"><i class="icon-g-ban"></i> Archived</a></li>
126 104
         </ul>
127
-
128 105
       </div>
129
-
130 106
       <div class="btn-group">
131
-        <a class="btn btn-primary" href="#" ><i class="icon-g-circle-plus icon-g-white"></i> Add</a>
132
-        <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
133
-        <ul class="dropdown-menu">
134
-          <li><a href="#"><i class="icon-g-calendar" ></i> Event</a></li>
135
-          <li><a href="#"><i class="icon-g-comments"></i> Comment</a></li>
136
-          <li><a href="#"><i class="icon-g-user"></i> Contact</a></li>
137
-          <li><a href="#"><i class="icon-g-attach"></i> File</a></li>
138
-        </ul>
107
+        <button id='current-document-content-edit-button' class="btn"><i class='icon-g-edit'></i> ${_('Edit')}</button>
139 108
       </div>
140
-
141 109
       <div class="btn-group">
142
-        <button class="btn btn-danger"><i class="icon-g-white icon-g-remove"></i> Delete</button>
143
-      </div>
144
-      
145
-    
146
-      <div>
147
-        ${current_node.data_content|n}
110
+        <a href='${tg.url('/force_delete_node?node_id=%i'%(current_node.node_id))}' id='current-document-force-delete-button' class="btn btn-danger"><i class="icon-g-white icon-g-remove"></i> ${_('Delete')}</a>
148 111
       </div>
112
+      <p>
113
+        <div id='current-document-content' class="">
114
+          ${current_node.data_content|n}
115
+        </div>
116
+        <form id="current-document-content-edit-form" method='post' action='${tg.url('/edit_content')}'>
117
+          <input type='hidden' name='node_id' value='${current_node.node_id}'/>
118
+          <textarea id="current_node_textarea" name='data_content' spellcheck="false" wrap="off" autofocus placeholder="Enter something ...">
119
+            ${current_node.data_content|n}
120
+          </textarea>
121
+          <button id="current-document-content-edit-cancel-button" type="button" class="btn" title="${_('Cancel editing')}"><i class="icon-g-ban"></i> ${_('Cancel')}</button>
122
+          <button id='current-document-content-edit-save-button' type="button" class="btn" title="${_('Save')}"><i class="icon-g-edit"></i>  ${_('Save')}</button>
123
+        </form>
124
+      </p>
149 125
     </div>
150 126
     <div class="span4">
151 127
       <div class="tabbable">

+ 98 - 4
pboard/pboard/templates/master.mak View File

@@ -36,6 +36,18 @@
36 36
           padding-right: 20px;
37 37
         }
38 38
       }
39
+      
40
+div.pod-toolbar {
41
+  visibility: hidden;
42
+}
43
+tr:Hover td div.pod-toolbar {
44
+  visibility: visible;
45
+}
46
+
47
+h3:Hover div.pod-toolbar {
48
+  visibility: visible;
49
+}
50
+
39 51
     </style>
40 52
 </head>
41 53
 <body class="${self.body_class()}">
@@ -57,9 +69,11 @@
57 69
 <script src="/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.js"></script>
58 70
 
59 71
 <style>
60
-#addFolderNode {
61
-  width: 800px;
62
-  margin-left: -400px;
72
+tr:Hover td div.pod-toolbar {
73
+  visibility: hidden;
74
+}
75
+tr:Hover td div.pod-toolbar {
76
+  visibility: visible;
63 77
 }
64 78
 </style>
65 79
 
@@ -76,8 +90,87 @@
76 90
 
77 91
             <script>
78 92
               $(document).ready(function() {
79
-                $('#data_content').wysihtml5();
93
+               
94
+                $('#data_content').wysihtml5({
95
+                  "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
96
+                  "emphasis": true, //Italics, bold, etc. Default true
97
+                  "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
98
+                  "html": true, //Button which allows you to edit the generated HTML. Default false
99
+                  "link": false, //Button to insert a link. Default true
100
+                  "image": false, //Button to insert an image. Default true,
101
+                  // "color": true //Button to change color of font  
102
+                });
103
+                
104
+                $('#data_content').css("width", "30em");
105
+                $('#data_content').css("height", "12em");
106
+
107
+                $('#data_content_edit').wysihtml5({
108
+                  "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
109
+                  "emphasis": true, //Italics, bold, etc. Default true
110
+                  "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
111
+                  "html": true, //Button which allows you to edit the generated HTML. Default false
112
+                  "link": false, //Button to insert a link. Default true
113
+                  "image": false, //Button to insert an image. Default true,
114
+                  // "color": true //Button to change color of font  
115
+                });
116
+                
117
+                $('#data_content_edit').css("width", "30em");
118
+                $('#data_content_edit').css("height", "12em");
119
+                
120
+                          $('#current_node_textarea').wysihtml5({
121
+            "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
122
+            "emphasis": true, //Italics, bold, etc. Default true
123
+            "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
124
+            "html": true, //Button which allows you to edit the generated HTML. Default false
125
+            "link": false, //Button to insert a link. Default true
126
+            "image": false, //Button to insert an image. Default true,
127
+            // "color": true //Button to change color of font  
128
+          });
129
+                $('#current_node_textarea').css('margin-bottom', '0');
130
+                $('#current_node_textarea').css("min-height", "12em");
131
+                $('#current_node_textarea').addClass("span5");
132
+
133
+
134
+                /* Edit title form */
135
+                $("#current-document-title-edit-form" ).css("display", "none");
136
+                $("#current-document-title" ).dblclick(function() {
137
+                  $("#current-document-title" ).css("display", "none");
138
+                  $("#current-document-title-edit-form" ).css("display", "block");
139
+                });
140
+                $("#current-document-title-edit-cancel-button" ).click(function() {
141
+                  $("#current-document-title" ).css("display", "block");
142
+                  $("#current-document-title-edit-form" ).css("display", "none");
143
+                });
144
+                $('#current-document-title-save-cancel-button').on('click', function(e){
145
+                  // We don't want this to act as a link so cancel the link action
146
+                  e.preventDefault();
147
+                  $('#current-document-title-edit-form').submit();
148
+                });
149
+
150
+                /* Edit content form */
151
+                $("#current-document-content-edit-form" ).css("display", "none");
152
+                $("#current-document-content-edit-button" ).click(function() {
153
+                  $("#current-document-content" ).css("display", "none");
154
+                  $("#current-document-content-edit-form" ).css("display", "block");
155
+                });
156
+                $("#current-document-content" ).dblclick(function() {
157
+                  $("#current-document-content" ).css("display", "none");
158
+                  $("#current-document-content-edit-form" ).css("display", "block");
159
+                });
160
+                $("#current-document-content-edit-cancel-button" ).click(function() {
161
+                  $("#current-document-content" ).css("display", "block");
162
+                  $("#current-document-content-edit-form" ).css("display", "none");
163
+                });
164
+                $('#current-document-content-edit-save-button').on('click', function(e){
165
+                  // We don't want this to act as a link so cancel the link action
166
+                  e.preventDefault();
167
+                  $('#current-document-content-edit-form').submit();
168
+                });
169
+
170
+                /* Force delete content form */
171
+
80 172
               });
173
+              
81 174
             </script>
82 175
 </body>
83 176
 
@@ -167,4 +260,5 @@
167 260
   </div><!-- /.navbar -->
168 261
 </%def>
169 262
 
263
+
170 264
 </html>