| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /* 2 * dialog_core.js 3 */ 4 5 var el, 6 offsetBefore, offsetAfter, 7 heightBefore, heightAfter, 8 widthBefore, widthAfter, 9 dragged; 10 11 function dlg() { 12 return el.data("dialog").element.parents(".ui-dialog:first"); 13 } 14 15 function isOpen(why) { 16 ok(dlg().is(":visible"), why); 17 } 18 19 function isNotOpen(why) { 20 ok(!dlg().is(":visible"), why); 21 } 22 23 function drag(handle, dx, dy) { 24 var d = dlg(); 25 offsetBefore = d.offset(); 26 heightBefore = d.height(); 27 widthBefore = d.width(); 28 //this mouseover is to work around a limitation in resizable 29 //TODO: fix resizable so handle doesn't require mouseover in order to be used 30 $(handle, d).simulate("mouseover"); 31 $(handle, d).simulate("drag", { 32 dx: dx || 0, 33 dy: dy || 0 34 }); 35 dragged = { dx: dx, dy: dy }; 36 offsetAfter = d.offset(); 37 heightAfter = d.height(); 38 widthAfter = d.width(); 39 } 40 41 function moved(dx, dy, msg) { 42 msg = msg ? msg + "." : ""; 43 var actual = { left: offsetAfter.left, top: offsetAfter.top }; 44 var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy }; 45 same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); 46 } 47 48 function shouldmove(why) { 49 var handle = $(".ui-dialog-titlebar", dlg()); 50 drag(handle, 50, 50); 51 moved(50, 50, why); 52 } 53 54 function shouldnotmove(why) { 55 var handle = $(".ui-dialog-titlebar", dlg()); 56 drag(handle, 50, 50); 57 moved(0, 0, why); 58 } 59 60 function resized(dw, dh, msg) { 61 msg = msg ? msg + "." : ""; 62 var actual = { width: widthAfter, height: heightAfter }; 63 var expected = { width: widthBefore + dw, height: heightBefore + dh }; 64 same(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); 65 } 66 67 function shouldresize(why) { 68 var handle = $(".ui-resizable-se", dlg()); 69 drag(handle, 50, 50); 70 resized(50, 50, why); 71 } 72 73 function shouldnotresize(why) { 74 var handle = $(".ui-resizable-se", dlg()); 75 drag(handle, 50, 50); 76 resized(0, 0, why); 77 } 78 79 function broder(el, side){ 80 return parseInt(el.css('border-' + side + '-width'), 10); 81 } 82 83 function margin(el, side) { 84 return parseInt(el.css('margin-' + side), 10); 85 } 86 87 (function($) { 88 89 module("dialog: core"); 90 91 test("element types", function() { 92 var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' 93 + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' 94 + ',acronym,code,samp,kbd,var,img,object,hr' 95 + ',input,button,label,select,iframe').split(','); 96 97 $.each(typeNames, function(i) { 98 var typeName = typeNames[i]; 99 el = $(document.createElement(typeName)).appendTo('body'); 100 (typeName == 'table' && el.append("<tr><td>content</td></tr>")); 101 el.dialog(); 102 ok(true, '$("<' + typeName + '/>").dialog()'); 103 el.dialog("destroy"); 104 el.remove(); 105 }); 106 }); 107 108 test("title id", function() { 109 expect(3); 110 111 var titleId; 112 113 // reset the uuid so we know what values to expect 114 $.ui.dialog.uuid = 0; 115 116 el = $('<div></div>').dialog(); 117 titleId = dlg().find('.ui-dialog-title').attr('id'); 118 equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id'); 119 el.remove(); 120 121 el = $('<div></div>').dialog(); 122 titleId = dlg().find('.ui-dialog-title').attr('id'); 123 equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id'); 124 el.remove(); 125 126 el = $('<div id="foo"/>').dialog(); 127 titleId = dlg().find('.ui-dialog-title').attr('id'); 128 equals(titleId, 'ui-dialog-title-foo', 'carried over title id'); 129 el.remove(); 130 }); 131 132 test("ARIA", function() { 133 expect(4); 134 135 el = $('<div></div>').dialog(); 136 137 equals(dlg().attr('role'), 'dialog', 'dialog role'); 138 139 var labelledBy = dlg().attr('aria-labelledby'); 140 ok(labelledBy.length > 0, 'has aria-labelledby attribute'); 141 equals(dlg().find('.ui-dialog-title').attr('id'), labelledBy, 142 'proper aria-labelledby attribute'); 143 144 equals(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button', 145 'close link role'); 146 147 el.remove(); 148 }); 149 150 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |