1 // ========================================================================== 2 // Project: The M-Project - Mobile HTML5 Application Framework 3 // Copyright: (c) 2010 M-Way Solutions GmbH. All rights reserved. 4 // Creator: Dominik 5 // Date: 23.11.2010 6 // License: Dual licensed under the MIT or GPL Version 2 licenses. 7 // http://github.com/mwaylabs/The-M-Project/blob/master/MIT-LICENSE 8 // http://github.com/mwaylabs/The-M-Project/blob/master/GPL-LICENSE 9 // ========================================================================== 10 11 m_require('ui/dialog.js'); 12 13 /** 14 * @class 15 * 16 * This is the prototype for any confirm dialog view. It is derived from M.DialogView 17 * and mainly used for implementing a confirm dialog view specific render method. 18 * 19 * @extends M.DialogView 20 */ 21 M.ConfirmDialogView = M.DialogView.extend( 22 /** @scope M.ConfirmDialogView.prototype */ { 23 24 /** 25 * The type of this object. 26 * 27 * @type String 28 */ 29 type: 'M.ConfirmDialogView', 30 31 /** 32 * The default title of an confirm dialog. 33 * 34 * @type String 35 */ 36 title: 'Confirm', 37 38 /** 39 * The default message of an confirm dialog. 40 * 41 * @type String 42 */ 43 message: '', 44 45 /** 46 * The default transition of an confirm dialog. 47 * 48 * @type String 49 */ 50 transition: M.TRANSITION.POP, 51 52 /** 53 * Determines whether the confirm dialog gets a default ok button. 54 * 55 * @type Boolean 56 */ 57 hasOkButton: YES, 58 59 /** 60 * Determines whether the confirm dialog gets a default cancel button. 61 * 62 * @type Boolean 63 */ 64 hasCancelButton: YES, 65 66 /** 67 * Renders an confirm dialog as a pop-up page. 68 * 69 * @private 70 * @returns {String} The confirm dialog view's html representation. 71 */ 72 render: function() { 73 this.html = '<div data-role="dialog" id="' + this.id + '">'; 74 this.html += '<div data-role="header" data-position="fixed"><h1>' + this.title + '</h1></div>'; 75 this.html += '<div data-role="content">' + this.message; 76 77 if(this.hasOkButton) { 78 var button = M.ButtonView.design({ 79 value: 'OK', 80 cssClass: 'b', 81 target: this, 82 action: 'dialogWillClose', 83 role: 'onOk' 84 }); 85 this.buttonIds.push(button.id); 86 this.html += button.render(); 87 } 88 89 if(this.hasCancelButton) { 90 var button = M.ButtonView.design({ 91 value: 'Cancel', 92 cssClass: 'c', 93 target: this, 94 action: 'dialogWillClose', 95 role: 'onCancel' 96 }); 97 this.buttonIds.push(button.id); 98 this.html += button.render(); 99 } 100 101 this.html += '</div>'; 102 103 this.html += '</div>'; 104 105 $('body').append(this.html); 106 } 107 108 });