]> source.dussan.org Git - archiva.git/commitdiff
use a dialog confirm based on bootstrap modal, jqueryui was a bit ugly
authorOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:56 +0000 (13:53 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:56 +0000 (13:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225532 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main-tmpl.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/login.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js

index 10ba056520bab3c20b113e0b5636e2e2297eb6d2..9295369d303e3bed617be40016a280e0e60f0508 100644 (file)
  * specific language governing permissions and limitations
  * under the License.
  */
-require(["text!archiva/templates/menu.html","text!archiva/templates/topbar.html","text!archiva/templates/message.html"],
-  function(menu,topbar,message) {
+require(["text!archiva/templates/menu.html","text!archiva/templates/topbar.html","text!archiva/templates/message.html",
+          "text!archiva/templates/modal.html"],
+  function(menu,topbar,message,modal) {
 
     // template loading
     $.tmpl( menu, $.i18n.map ).appendTo("#html-fragments");
     $.tmpl( topbar, $.i18n.map ).appendTo("#html-fragments");
+    $.tmpl( modal, $.i18n.map ).appendTo("#html-fragments");
     $("#html-fragments").append(message);
     $.log("main-tmpl.js menu loaded");
   }
index 5c43413317be5170091108c1f435c40a31cd7bc8..d0d2a84e3efc7bea662eda41f5958d8abd5aea41 100644 (file)
@@ -26,6 +26,9 @@
             <span class="label notice">${register}</span>
           </a>
         </li>
+          <li>
+            <a href="#" onclick="openDialogConfirm(function(){alert('ok')}, 'okMessage', 'cancelMessage', 'title')">test</a>
+          </li>
       </ul>
       <form class="pull-right" action="">
         <input type="text" placeholder="Search" />
index 26014bde0a65c6887742518178c1359f7dd01030..ff39934b8eed494d4c236fba40e462a9e0c2386e 100644 (file)
@@ -102,4 +102,78 @@ clearForm=function(selectorStr){
     $(this).val("");
   });
 
+}
+
+/**
+ * open a confirm dialog based on bootstrap modal
+ * @param okFn callback function to call on ok confirm
+ * @param okMessage
+ * @param cancelMessage
+ * @param title
+ */
+openDialogConfirm=function(okFn, okMessage, cancelMessage, title,bodyText){
+  if (window.modalConfirmDialog==null) {
+    window.modalConfirmDialog = $("#dialog-confirm-modal").modal({backdrop:'static',show:false});
+    window.modalConfirmDialog.bind('hidden', function () {
+      $("#dialog-confirm-modal-header-title").html("");
+      $("#dialog-confirm-modal-body-text").html("");
+    })
+    $("#dialog-confirm-modal-cancel").on("click", function(){
+      window.modalConfirmDialog.modal('hide');
+    });
+  }
+  $("#dialog-confirm-modal-header-title").html(title);
+  $("#dialog-confirm-modal-body-text").html(bodyText);
+  if (okMessage){
+    $("#dialog-confirm-modal-ok").html(okMessage);
+  }
+  if (cancelMessage){
+    $("#dialog-confirm-modal-cancel").html(cancelMessage);
+  }
+  window.modalConfirmDialog.modal('show');
+
+  // unbind previous events !!
+  $("#dialog-confirm-modal-ok").off( );
+  $("#dialog-confirm-modal-ok").on("click", okFn);
+
+}
+
+/**
+ * return a small spinner html img element
+ */
+smallSpinnerImg=function(){
+  return "<img id=\"login-spinner\" src=\"images/small-spinner.gif\"/>";
+};
+
+closeDialogConfirm=function(){
+  window.modalConfirmDialog.modal('hide');
+}
+
+closeDialogConfirmui=function(){
+  $("#dialog-confirm" ).dialog("close");
+}
+
+/**
+ * open a confirm dialog with jqueryui
+ * @param okFn callback function to call on ok confirm
+ * @param okMessage
+ * @param cancelMessage
+ * @param title
+ */
+openDialogConfirmui=function(okFn, okMessage, cancelMessage, title){
+  $("#dialog-confirm" ).dialog({
+    resizable: false,
+    title: title,
+    modal: true,
+    show: 'slide',
+    buttons: [{
+      text: okMessage,
+      click: okFn},
+      {
+      text: cancelMessage,
+      click:function() {
+        $(this).dialog( "close" );
+      }
+    }]
+  });
 }
\ No newline at end of file
index e4fa4a93503bf2c3e4f1fad30e85c09fbd7d6d36..d738f49cd19849de631d0e1ac8f1d719346e305a 100644 (file)
@@ -52,42 +52,6 @@ $(function() {
     //nothing
   });
 
-  /**
-   * return a small spinner html img element
-   */
-  smallSpinnerImg=function(){
-    return "<img id=\"login-spinner\" src=\"images/small-spinner.gif\"/>";
-  };
-
-  /**
-   * open a confirm dialog
-   * @param okFn callback function to call on ok confirm
-   * @param okMessage
-   * @param cancelMessage
-   * @param title
-   */
-  openDialogConfirm=function(okFn, okMessage, cancelMessage, title){
-    $("#dialog-confirm" ).dialog({
-      resizable: false,
-      title: title,
-      modal: true,
-      show: 'slide',
-      buttons: [{
-        text: okMessage,
-        click: okFn},
-        {
-        text: cancelMessage,
-        click:function() {
-          $(this).dialog( "close" );
-        }
-      }]
-    });
-  }
-
-  closeDialogConfirm=function(){
-    $("#dialog-confirm" ).dialog("close");
-  }
-
   /**
    * return a user see user.js if user logged otherwise null
    */
index 0bb3d60fe16e0897d3dcf7639f14b12026bd417e..9c47b955967fe68b75f6cc289eb7b5b917bcb0e9 100644 (file)
@@ -23,7 +23,7 @@
       </form>
   </div>
   <div class="modal-footer" id="modal-login-footer">
-      <button class="btn primary" onclick="return login();" id="modal-login-ok">${login}</button>
+    <button class="btn primary" onclick="return login();" id="modal-login-ok">${login}</button>
   </div>
 </div>
 
index d3a99be3ce8ad0821cd61bfb9fa703dd7953be69..aa141af3cb686d32ee19cd9da2dbe9a79a500917 100644 (file)
@@ -132,7 +132,7 @@ $(function() {
 
       this.deleteUser=function() {
         clearUserMessages();
-        // FIXME i18n
+
         var currentUser = this;
         openDialogConfirm(function(){
           $.ajax("restServices/redbackServices/userService/deleteUser/"+currentUser.username(), {