Kawai Wiki

Rev

Rev 145 | Rev 153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 145 Rev 149
Line 61... Line 61...
61
        $(document).ready(function() {
61
        $(document).ready(function() {
62
        
62
        
63
        	<mtw:if test="showForm" value="login">
63
        	<mtw:if test="showForm" value="login">
64
				showLoginDialog();
64
				showLoginDialog();
65
			</mtw:if>
65
			</mtw:if>
-
 
66
-
 
67
            <mtw:if test="showForm" value="addNewUser">
-
 
68
                showAddNewUserDialog(false);
-
 
69
            </mtw:if>
66
			
70
			
67
			<mtw:if test="showForm" value="add">
71
			<mtw:if test="showForm" value="add">
68
				showCreateNewPageDialog();
72
				showCreateNewPageDialog();
69
			</mtw:if>	
-
 
70
			
-
 
-
 
73
			</mtw:if>
-
 
74
-
 
75
            <mtw:outMessage>
-
 
76
                alert('<mtw:out />');
-
 
77
            </mtw:outMessage>
-
 
78
71
			$('#loginDialog').keyup(function(e) {
79
			$('#loginDialog').keyup(function(e) {
72
    			if (e.keyCode == 13) {
80
    			if (e.keyCode == 13) {
73
        			$('#loginForm').submit();
81
        			$('#loginForm').submit();
74
    			}
82
    			}
75
			});
83
			});
Line 91... Line 99...
91
					} else if (resp.status == 'error') {
99
					} else if (resp.status == 'error') {
92
						$('#uploadResults').append('<tr><td style="color: red;">' + resp.msg + '</td></tr>');    				
100
						$('#uploadResults').append('<tr><td style="color: red;">' + resp.msg + '</td></tr>');    				
93
					}
101
					}
94
				}
102
				}
95
			});
103
			});
96
			
-
 
-
 
104
-
 
105
            // ajax add new user:
-
 
106
-
 
107
	        
-
 
108
            $('#usernameLoading').hide();
-
 
109
    
-
 
110
            $('#addNewUserUsername').blur( function() {
-
 
111
    
-
 
112
                $('#usernameMessage').hide();
-
 
113
    
-
 
114
                if ($('#addNewUserUsername').val().trim() != '') {
-
 
115
-
 
116
                    $('#usernameLoading').show();
-
 
117
    
-
 
118
                    $.post("<mtw:contextPath />/User.check.mtw", {
-
 
119
                        username : $('#addNewUserUsername').val()
-
 
120
                    }, function(response) {
-
 
121
                        $('#usernameMessage').fadeOut();
-
 
122
                        setTimeout("usernameResult('"
-
 
123
                                + escape(response) + "')", 400);
-
 
124
                    });
-
 
125
                }
-
 
126
    
-
 
127
                return false;
-
 
128
            });
-
 
129
97
        });
130
        });
98
        
131
        
99
        function prepareEditPageDialog(myDialog, theTitle) {
132
        function prepareEditPageDialog(myDialog, theTitle) {
100
133
101
            options = {
134
            options = {
Line 678... Line 711...
678
            $('#loginFormName').val('<mtw:out value="bodyColumn.name" />');
711
            $('#loginFormName').val('<mtw:out value="bodyColumn.name" />');
679
            $('#loginFormLang').val('<mtw:out value="bodyColumn.lang" />');
712
            $('#loginFormLang').val('<mtw:out value="bodyColumn.lang" />');
680
713
681
            myDialog = $('#loginDialog');
714
            myDialog = $('#loginDialog');
682
            myDialog = prepareLoginDialog(myDialog);
715
            myDialog = prepareLoginDialog(myDialog);
-
 
716
            myDialog.dialog('open');
-
 
717
-
 
718
            return false;
-
 
719
        }
-
 
720
-
 
721
        function showAddNewUserDialog(hideUsernameMessage) {
-
 
722
-
 
723
            myDialog = $('#addNewUserDialog');
-
 
724
            myDialog = prepareAddNewUserDialog(myDialog, hideUsernameMessage);
683
            myDialog.dialog('open');
725
            myDialog.dialog('open');
684
726
685
            return false;
727
            return false;
686
        }
728
        }
687
        
729
        
688
        function clearLoginForm() {
730
        function clearLoginForm() {
689
        	$('#loginUsername').val('');
731
        	$('#loginUsername').val('');
690
        	$('#loginPassword').val('');
732
        	$('#loginPassword').val('');
691
        	$('#loginUsernameError').text('');
733
        	$('#loginUsernameError').text('');
692
        	$('#loginPasswordError').text('');
734
        	$('#loginPasswordError').text('');
-
 
735
        }
-
 
736
-
 
737
        function clearAddNewUserForm() {
-
 
738
        	$('#addNewUserUsername').val('');
-
 
739
        	$('#addNewUserPassword').val('');
-
 
740
        	$('#addNewUserPassconf').val('');
-
 
741
        	$('#addNewUserGroup').val('');
-
 
742
        	$('#usernameMessage').text('');
-
 
743
        	$('#addNewUserPasswordError').text('');
-
 
744
        	$('#addNewUserPassconfError').text('');
-
 
745
        	$('#addNewUserGroupError').text('');
693
        }
746
        }
694
        
747
        
695
        function clearCreateNewPageForm() {
748
        function clearCreateNewPageForm() {
696
        	$('#createNewPageName').val('');
749
        	$('#createNewPageName').val('');
697
        	$('#createNewPageTitle').val('');
750
        	$('#createNewPageTitle').val('');
Line 713... Line 766...
713
                title: "Login:",
766
                title: "Login:",
714
                buttons: [
767
                buttons: [
715
                          {
768
                          {
716
                                text: "Login",
769
                                text: "Login",
717
                                click: function() { $('#loginForm').submit(); }
770
                                click: function() { $('#loginForm').submit(); }
-
 
771
                          },
-
 
772
                          {
-
 
773
                                text: "Cancel",
-
 
774
                                click: function() {  $(this).dialog("close"); }
-
 
775
                          }
-
 
776
                      ]
-
 
777
           };
-
 
778
-
 
779
          myDialog.dialog(options);
-
 
780
-
 
781
          return myDialog;
-
 
782
        }
-
 
783
-
 
784
        function prepareAddNewUserDialog(myDialog, hideUsernameMessage) {
-
 
785
-
 
786
        	$('#usernameLoading').hide();
-
 
787
            if (hideUsernameMessage) $('#usernameMessage').text('');
-
 
788
-
 
789
            options = {
-
 
790
                close: function() { clearAddNewUserForm(); },
-
 
791
                autoOpen: false,
-
 
792
                width: 550,
-
 
793
                modal: true,
-
 
794
                title: "Add New User:",
-
 
795
                buttons: [
-
 
796
                          {
-
 
797
                                text: "Add",
-
 
798
                                click: function() { $('#addNewUserForm').submit(); }
718
                          },
799
                          },
719
                          {
800
                          {
720
                                text: "Cancel",
801
                                text: "Cancel",
721
                                click: function() {  $(this).dialog("close"); }
802
                                click: function() {  $(this).dialog("close"); }
722
                          }
803
                          }
Line 759... Line 840...
759
            myDialog.dialog('open');
840
            myDialog.dialog('open');
760
841
761
            return false;
842
            return false;
762
        }
843
        }
763
        
844
        
764
    </script>
-
 
-
 
845
        function usernameResult(response) {
-
 
846
        
-
 
847
                $('#usernameLoading').hide();
-
 
848
        
-
 
849
                var res = unescape(response);
-
 
850
        
-
 
851
                if (res == "error") {
-
 
852
        
-
 
853
                    $('#usernameMessage')
-
 
854
                            .html(
-
 
855
                                    '<font color="red"><b>Error!</b></font>');
-
 
856
                    $('#usernameMessage').fadeIn();
-
 
857
        
-
 
858
                } else if (res == "success") {
-
 
859
        
-
 
860
                    $('#usernameMessage').html(
-
 
861
                            '<img src="<mtw:contextPath />/images/chk.gif" />');
-
 
862
                    $('#usernameMessage').fadeIn();
-
 
863
        
-
 
864
                } else if (res == "already") {
-
 
865
        
-
 
866
                    $('#usernameMessage')
-
 
867
                            .html(
-
 
868
                                    '<font color="red"><b>Username already exists!</b></font>');
-
 
869
                    $('#usernameMessage').fadeIn();
-
 
870
                }
-
 
871
            }
-
 
872
        </script>
765
873
766
</head>
874
</head>
767
875
768
<body class="composite">
876
<body class="composite">
-
 
877
-
 
878
<!--  For adding username -->
-
 
879
<div id="addNewUserDialog" style="display: none;">
-
 
880
        <form action="<mtw:contextPath />/User.add.mtw" method="post" id="addNewUserForm">
-
 
881
            <table>
-
 
882
                <tr>
-
 
883
                    <td width="10%">
-
 
884
                        Username:
-
 
885
                    </td>
-
 
886
                    <td>
-
 
887
                        <mtw:input name="username" id="addNewUserUsername" size="20" maxlength="30" />
-
 
888
                        <span id="usernameLoading">
-
 
889
                            <img src="<mtw:contextPath />/images/loading.gif" />
-
 
890
                        </span>
-
 
891
                        <span id="usernameMessage">
-
 
892
                            <mtw:outError field="username">
-
 
893
                                <font color="red">
-
 
894
                                    <b><mtw:out /></b>
-
 
895
                                </font>
-
 
896
                            </mtw:outError>
-
 
897
                        </span>
-
 
898
                    </td>
-
 
899
                </tr>
-
 
900
                <tr>
-
 
901
                    <td>
-
 
902
                        Password:
-
 
903
                    </td>
-
 
904
                    <td>
-
 
905
                        <mtw:input name="password" type="password" size="20" maxlength="20" id="addNewUserPassword" /> 
-
 
906
                        <span id="addNewUserPasswordError">
-
 
907
                            <mtw:outError field="password">
-
 
908
                                <font color="red">
-
 
909
                                    <b><mtw:out /></b>
-
 
910
                                </font>
-
 
911
                        </mtw:outError>
-
 
912
                        </span>
-
 
913
                    </td>
-
 
914
                </tr>
-
 
915
                <tr>
-
 
916
                    <td>
-
 
917
                        Confirm:
-
 
918
                    </td>
-
 
919
                    <td>
-
 
920
                        <mtw:input name="passconf" type="password" size="20" maxlength="20" id="addNewUserPassconf" /> 
-
 
921
                        <span id="addNewUserPassconfError">
-
 
922
                            <mtw:outError field="passconf">
-
 
923
                                <font color="red">
-
 
924
                                <b><mtw:out /></b>
-
 
925
                            </font>
-
 
926
                        </mtw:outError>
-
 
927
                        </span>
-
 
928
                    </td>
-
 
929
                </tr>
-
 
930
                <tr>
-
 
931
                    <td>
-
 
932
                        Group:
-
 
933
                    </td>
-
 
934
                    <td>
-
 
935
                        <mtw:select name="groupId" list="groups" emptyField="true" id="addNewUserGroup" />
-
 
936
                        <span id="addNewUserGroupError">
-
 
937
                        <mtw:outError field="groupId">
-
 
938
                            <font color="red">
-
 
939
                                <b><mtw:out /></b>
-
 
940
                            </font>
-
 
941
                        </mtw:outError>
-
 
942
                        </span>
-
 
943
                    </td>
-
 
944
                </tr>
-
 
945
            </table>
-
 
946
        </form>
-
 
947
</div>
769
948
770
<!-- For Testing -->
949
<!-- For Testing -->
771
<div id="dialog" title="Dialog Title" style="display: none;">I'm in a dialog</div>
950
<div id="dialog" title="Dialog Title" style="display: none;">I'm in a dialog</div>
772
951
773
<!-- Close Confirm -->
952
<!-- Close Confirm -->
Line 1029... Line 1208...
1029
                <a href="#" onclick="return showListLastRevisionsDialog('<mtw:out value="bodyColumn.language.locale" />', '<mtw:out value="bodyColumn.language" />', false);">Last Updates</a> |
1208
                <a href="#" onclick="return showListLastRevisionsDialog('<mtw:out value="bodyColumn.language.locale" />', '<mtw:out value="bodyColumn.language" />', false);">Last Updates</a> |
1030
                <a href="#" onclick="return showLoginDialog();">Login</a>
1209
                <a href="#" onclick="return showLoginDialog();">Login</a>
1031
            </mtw:isLogged>
1210
            </mtw:isLogged>
1032
            <mtw:isLogged>
1211
            <mtw:isLogged>
1033
                <a href="#" onclick="return showCreateNewPageDialog();">Create New Page</a> |
1212
                <a href="#" onclick="return showCreateNewPageDialog();">Create New Page</a> |
-
 
1213
                <a href="#" onclick="return showAddNewUserDialog(true);">Add New User</a> |
1034
                <a href="#" onclick="return showListAllPagesDialog(<mtw:out value="sessionUser.admin" />);">List Pages</a> |
1214
                <a href="#" onclick="return showListAllPagesDialog(<mtw:out value="sessionUser.admin" />);">List Pages</a> |
1035
                
1215
                
1036
                <mtw:hasAuthorization groups="admin, editor">
1216
                <mtw:hasAuthorization groups="admin, editor">
1037
                
1217
                
1038
                <mtw:if test="css.preview" value="true">
1218
                <mtw:if test="css.preview" value="true">