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', 'content_comment_form', 'content_task_form', 'opinion', 'reason', 'content']; 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("#task_form textarea[name=reason]").parents("div[class=row]"); 66 67 if ($reason_row.length > 0) { 68 $reason_row.hide(); 69 $select = jQuery("#task_form 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 console.log(this); 82 jQuery(this).siblings(".bds_block_content").show(); 83 jQuery(this).find(".toggle").css("background-image", "url(lib/plugins/bds/images/expanded.png)"); 84 }; 85 var hide = function() { 86 jQuery(this).siblings(".bds_block_content").hide(); 87 jQuery(this).find(".toggle").css("background-image", "url(lib/plugins/bds/images/collapsed.png)"); 88 }; 89 90 jQuery(".bds_block") 91 .each(function() { 92 $h1 = jQuery(this).find("h1").html( 93 function(index, oldhtml) { 94 return '<span class="toggle">'+oldhtml+'</span>'; 95 }); 96 97 $h1.find(".toggle").css( 98 { 99 'background': 'url("lib/plugins/bds/images/collapsed.png") no-repeat scroll 4px 50% rgba(0, 0, 0, 0)', 100 'border': 'medium none', 101 'border-radius': '0.3em', 102 'box-shadow': '0.1em 0.1em 0.3em 0 #BBBBBB', 103 'color': '#222222', 104 'padding': '0.3em 0.5em 0.3em 20px', 105 'text-shadow': '0.1em 0.1em #FCFCFC', 106 'cursor': 'pointer' 107 }); 108 109 110 var showed = "bds_history"; 111 var hash = window.location.hash.substring(1); 112 if (hash.indexOf("bez_comment") !== -1) { 113 var showed = "bez_comment"; 114 } else if (hash === "task_form") { 115 var showed = "task_form"; 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