1/* DOKUWIKI:include jquery.dataTables.js */ 2/* DOKUWIKI:include jquery.dataTables.yadcf.js */ 3 4bds = {}; 5 6bds.gup = function (name) { 7 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 8 var regexS = "[\\?&]" + name + "=([^&#]*)"; 9 var regex = new RegExp(regexS); 10 var results = regex.exec(window.location.href); 11 if (results == null) 12 return ""; 13 else 14 return results[1]; 15}; 16 17jQuery(document).ready(function() { 18 var ids = ['description', 'cause', 'content', 'task', 'reason']; 19 20 for (var i = 0; i < ids.length; i++) { 21 var textarea = jQuery("#" + ids[i]); 22 if (textarea.length > 0) { 23 textarea.before('<div id="toolbar'+ids[i]+'"></div>'); 24 if (textarea.parents("form").find("input[name=id]").length === 0) { 25 textarea.before('<input type="hidden" name="id" value="'+bds.gup('id')+'" />'); 26 } 27 initToolbar('toolbar'+ids[i], ids[i], toolbar); 28 } 29 } 30 31 //show/hide opinion 32 $opinion_row = jQuery("#bds_change_issue textarea[name=opinion]").parents("div[class=row]"); 33 34 if ($opinion_row.length > 0) { 35 var $select = jQuery("#bds_change_issue select[name=state]"); 36 switch ($select.val()) { 37 case "0": 38 case "1": 39 $opinion_row.hide(); 40 break; 41 42 case "2": 43 case "3": 44 case "4": 45 $opinion_row.show(); 46 break; 47 } 48 $select.change(function() { 49 switch (jQuery(this).val()) { 50 case "0": 51 case "1": 52 $opinion_row.hide(); 53 break; 54 55 case "2": 56 case "3": 57 case "4": 58 $opinion_row.show(); 59 break; 60 } 61 }); 62 } 63 64 //show/hide reason 65 $reason_row = jQuery("#bez_tasks textarea[name=reason]").parents("div[class=row]"); 66 67 if ($reason_row.length > 0) { 68 $reason_row.hide(); 69 $select = jQuery("#bez_tasks select[name=state]"); 70 var prev_val = $select.val(); 71 $select.change(function() { 72 if (jQuery(this).val() === prev_val) { 73 $reason_row.hide(); 74 } else { 75 $reason_row.show(); 76 } 77 }); 78 } 79 80 var show = function() { 81 jQuery(this).siblings(".bds_block_content").show(); 82 jQuery(this).find(".toggle").css("background-image", "url(lib/plugins/bds/images/expanded.png)"); 83 }; 84 var hide = function() { 85 jQuery(this).siblings(".bds_block_content").hide(); 86 jQuery(this).find(".toggle").css("background-image", "url(lib/plugins/bds/images/collapsed.png)"); 87 }; 88 89 jQuery(".bds_block") 90 .each(function() { 91 $h1 = jQuery(this).find("h1").html( 92 function(index, oldhtml) { 93 return '<span class="toggle">'+oldhtml+'</span>'; 94 }); 95 96 $h1.find(".toggle").css( 97 { 98 'background': 'url("lib/plugins/bds/images/collapsed.png") no-repeat scroll 4px 50% rgba(0, 0, 0, 0)', 99 'border': 'medium none', 100 'border-radius': '0.3em', 101 'box-shadow': '0.1em 0.1em 0.3em 0 #BBBBBB', 102 'color': '#222222', 103 'padding': '0.3em 0.5em 0.3em 20px', 104 'text-shadow': '0.1em 0.1em #FCFCFC', 105 'cursor': 'pointer' 106 }); 107 108 109 var hash = window.location.hash.substring(1); 110 if (hash.indexOf("k") === 0) { 111 var showed = "bez_comments"; 112 } else if (hash.indexOf("p") === 0) { 113 var showed = "bez_causes"; 114 } else if (hash.indexOf("z") === 0) { 115 var showed = "bez_tasks"; 116 } else if (hash === "bds_change_issue") { 117 var showed = "bds_change_issue"; 118 } 119 120 if (jQuery(this).attr("id") === showed) { 121 jQuery(this).find(".toggle").css("background-image", "url(lib/plugins/bds/images/expanded.png)"); 122 jQuery(this).find("h1").toggle(hide, show); 123 } else { 124 jQuery(this).find(".bds_block_content").hide(); 125 jQuery(this).find("h1").toggle(show, hide); 126 } 127 }); 128 jQuery(".bds_block .history_anchor").click(function() { 129 show.call(jQuery("#bds_history h1")[0]); 130 }); 131 132}); 133