Jihan Kim 2014-02-28
ui.Common: add sDescription param on alert, confirm, ajaxConfirm
@9a5e1b601f53cd831c26e1299edd356e832a4937
app/assets/stylesheets/less/_yobiUI.less
--- app/assets/stylesheets/less/_yobiUI.less
+++ app/assets/stylesheets/less/_yobiUI.less
@@ -483,6 +483,13 @@
             font-weight:bold; font-size:18px;
             margin-bottom:20px; line-height:1.5em;
         }
+
+        .desc {
+            text-align:center;
+            font-weight: normal; font-size: 14px;
+            margin: 20px 0 25px; line-height: 150%;
+            color: #555;
+        }
     }
 }
 
app/views/common/scripts.scala.html
--- app/views/common/scripts.scala.html
+++ app/views/common/scripts.scala.html
@@ -3,13 +3,16 @@
 
 @**<!-- yobi.ui.Dialog -->**@
 <div id="yobiDialog" class="modal hide fade yobiDialog" tabindex="-1" role="dialog" aria-hidden="true">
-	<div class="btn-dismiss"><button type="button" class="btn-transparent" data-dismiss="modal">&times;</button></div>
-	<div class="message">
-		<p class="center-text msg"></p>
-		<p class="center-txt buttons">
-			<button type="button" class="ybtn ybtn-info" data-dismiss="modal">@Messages("button.confirm")</button>
-		</p>
-	</div>
+    <div class="btn-dismiss"><button type="button" class="btn-transparent" data-dismiss="modal">&times;</button></div>
+    <div class="message">
+        <div class="center-text">
+            <p class="msg"></p>
+            <p class="desc"></p>
+        </div>
+        <div class="center-txt buttons">
+            <button type="button" class="ybtn ybtn-info" data-dismiss="modal">@Messages("button.confirm")</button>
+        </div>
+    </div>
 </div>
 @**<!-- //yobi.ui.Dialog -->**@
 
@@ -20,7 +23,7 @@
 	<div class="btn-dismiss"><button type="button" class="btn-transparent">&times;</button></div>
 	<div class="center-text">
         <span class="v"></span>
-        <p class="msg"></p>
+        <div class="msg"></div>
     </div>
 </div>
 </script>
public/javascripts/common/yobi.Common.js
--- public/javascripts/common/yobi.Common.js
+++ public/javascripts/common/yobi.Common.js
@@ -250,13 +250,14 @@
      * Show alert dialog
      * @param {String} sMessage Message string
      * @param {Function} fOnAfterHide Call this function after hidden dialog (optional)
+     * @param {String} sDescription Description string (optional)
      */
-    function showAlert(sMessage, fOnAfterHide){
+    function showAlert(sMessage, fOnAfterHide, sDescription){
         if(!htVar.oAlertDialog){
             htVar.oAlertDialog = new yobi.ui.Dialog("#yobiDialog");
         }
 
-        htVar.oAlertDialog.show(sMessage, {
+        htVar.oAlertDialog.show(sMessage, sDescription, {
             "fOnAfterHide": fOnAfterHide
         });
     }
@@ -265,17 +266,21 @@
      * Show confirm dialog
      * @param {String} sMessage Message string
      * @param {Function} fCallback Call this function after click button
-     * @param {Array} aButtonLabels Specifying button labels (optional)
-     * @param {Array} aButtonStyles Specifying button CSS Class names (optional)
+     * @param {String} sDescription Description string (optional)
+     * @param {Hash Table} htOptions
+     * @param {Array} htOptions.aButtonLabels Specifying button labels (optional)
+     * @param {Array} htOptions.aButtonStyles Specifying button CSS Class names (optional)
      */
-    function showConfirm(sMessage, fCallback, aButtonLabels, aButtonStyles){
+    function showConfirm(sMessage, fCallback, sDescription, htOptions){
         if(!htVar.oConfirmDialog){
             htVar.oConfirmDialog = new yobi.ui.Dialog("#yobiDialog");
         }
 
-        aButtonLabels = aButtonLabels || [Messages("button.cancel"), Messages("button.confirm")];
+        htOptions = htOptions || {};
+        var aButtonStyles = htOptions.aButtonStyles;
+        var aButtonLabels = htOptions.aButtonLabels || [Messages("button.cancel"), Messages("button.confirm")];
 
-        htVar.oConfirmDialog.show(sMessage, {
+        htVar.oConfirmDialog.show(sMessage, sDescription, {
            "fOnClickButton": fCallback,
            "aButtonLabels" : aButtonLabels,
            "aButtonStyles" : aButtonStyles
@@ -287,13 +292,15 @@
      *
      * @param {String} sMessage confirm message
      * @param {Hash Table} htAjaxOptions jQuery.ajax settings
+     * @param {String} sDescription Description string (optional)
+     * @param {Hash Table} htConfirmOptions showConfirm options (optional)
      */
-    function ajaxConfirm(sMessage, htAjaxOptions){
+    function ajaxConfirm(sMessage, htAjaxOptions, sDescription, htConfirmOptions){
         showConfirm(sMessage, function(htData){
             if(htData.nButtonIndex === 1){
                 $.ajax(htAjaxOptions);
             }
-        });
+        }, sDescription, htConfirmOptions);
     }
 
     /**
public/javascripts/common/yobi.ui.Dialog.js
--- public/javascripts/common/yobi.ui.Dialog.js
+++ public/javascripts/common/yobi.ui.Dialog.js
@@ -55,6 +55,7 @@
         function _initElement(sContainer){
             htElement.welContainer = $(sContainer).clone();
             htElement.welMessage = htElement.welContainer.find(".msg");
+            htElement.welDescription = htElement.welContainer.find(".desc");
             htElement.welButtons = htElement.welContainer.find(".buttons");
             htElement.welContainer.modal({
                 "show": false
@@ -74,7 +75,7 @@
          * 메시지 출력
          * @param {String} sMessage
          */
-        function showDialog(sMessage, htOptions){
+        function showDialog(sMessage, sDescription, htOptions){
             htVar.fOnAfterShow = htOptions.fOnAfterShow;
             htVar.fOnAfterHide = htOptions.fOnAfterHide;
             htVar.fOnClickButton = htOptions.fOnClickButton;
@@ -85,6 +86,7 @@
 
             htElement.welButtons.html(sButtonHTML);
             htElement.welMessage.html($yobi.nl2br(sMessage));
+            htElement.welDescription.html($yobi.nl2br(sDescription || ""));
             htElement.welContainer.modal("show");
         }
 
public/javascripts/service/yobi.project.Member.js
--- public/javascripts/service/yobi.project.Member.js
+++ public/javascripts/service/yobi.project.Member.js
@@ -158,18 +158,19 @@
         function _onClickDelete(){
             var sURL = $(this).attr("data-href");
 
-            $yobi.confirm(Messages("project.member.deleteConfirm"), function(htData){
-                if(htData.nButtonIndex === 1){
-                    $.ajax(sURL, {
-                        "method"  : "delete",
-                        "dataType": "html",
-                        "success" : _onSuccessDeleteMember,
-                        "error"   : _onErrorDeleteMember
-                    });
-                }
-            },
-            [Messages("button.no"), Messages("button.yes")],
-            ["ybtn-default", "ybtn-danger"]);
+            $yobi.ajaxConfirm(Messages("project.member.deleteConfirm"),
+                {
+                    "url"     : sURL,
+                    "method"  : "delete",
+                    "dataType": "html",
+                    "success" : _onSuccessDeleteMember,
+                    "error"   : _onErrorDeleteMember
+                },
+                "",
+                {
+                    "aButtonLabels": [Messages("button.no"), Messages("button.yes")],
+                    "aButtonStyles": ["ybtn-default", "ybtn-danger"]
+                });
         }
 
         /**
Add a comment
List