actions.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. $(document).ready(function(){
  2. /* ajax modal call */
  3. $(".modal-ajax").click(function(){
  4. $('#modal_ajax').find('.modal-title').html($(this).attr('data-title'));
  5. $('#modal_ajax').find('.modal-body').load($(this).attr('href'));
  6. $('#modal_ajax').modal('show');
  7. lists();
  8. return false;
  9. });
  10. /* ajax modal call */
  11. /* wide modal */
  12. $(".modal-wide").click(function(){
  13. var modal = $(this).attr('href');
  14. $(modal).on('show.bs.modal', function () {
  15. $(this).find('.modal-dialog').css({width: $(window).width()-30,height: $(window).height(),'padding-top': 15, 'padding-bottom': 15});
  16. });
  17. $(modal).on('shown.bs.modal', function () {
  18. $(this).find('.scroll').height($(window).height()-105).mCustomScrollbar("update");
  19. });
  20. $(modal).modal('show');
  21. });
  22. /* eof wide modal */
  23. /* tasks */
  24. $(".tasks_view_block").click(function(){
  25. $(".tasks").removeClass('tasks_list');
  26. });
  27. $(".tasks_view_list").click(function(){
  28. $(".tasks").addClass('tasks_list');
  29. });
  30. /* eof tasks */
  31. /* navigation */
  32. $(".page-sidebar").hover(function(){
  33. if($('.page-container').hasClass('page-sidebar-narrow')){
  34. $(this).css('width',230);
  35. $(".page-content").css('margin-left',230);
  36. $(".page-navigation-hide").css('display','block');
  37. }
  38. },function(){
  39. if($('.page-container').hasClass('page-sidebar-narrow')){
  40. $(this).removeAttr('style');
  41. $(".page-content").removeAttr('style');
  42. $(".page-navigation-hide").removeAttr('style');
  43. $(".page-navigation li ul").removeAttr('style');
  44. }
  45. });
  46. $(".psn-control").click(function(){
  47. if($('.page-container').hasClass('page-sidebar-narrow')){
  48. $('.page-container').removeClass('page-sidebar-narrow');
  49. $(this).parent('.control').removeClass('active');
  50. }else{
  51. $('.page-container').addClass('page-sidebar-narrow');
  52. $(this).parent('.control').addClass('active');
  53. }
  54. return false;
  55. });
  56. $(".page-navigation li a").click(function(){
  57. var ul = $(this).parent('li').children('ul');
  58. if(ul.length == 1){
  59. if(ul.is(':visible'))
  60. ul.slideUp('fast');
  61. else
  62. ul.slideDown('fast');
  63. return false;
  64. }
  65. });
  66. /* eof navigation */
  67. /* block */
  68. $(".block-remove").click(function(){
  69. $(this).parents(".block").fadeOut('slow',function(){
  70. $(this).remove();
  71. });
  72. return false;
  73. });
  74. $(".block-toggle").click(function(){
  75. var content = $(this).parents(".block").children('div').not('.header');
  76. if(content.is(':visible')){
  77. content.slideUp();
  78. $(this).find('span').removeClass('icon-chevron-down').addClass('icon-chevron-up');
  79. }else{
  80. content.slideDown();
  81. $(this).find('span').removeClass('icon-chevron-up').addClass('icon-chevron-down');
  82. }
  83. return false;
  84. });
  85. /* eof block */
  86. /* input file */
  87. $(".file .btn,.file input:text").click(function(){
  88. var block = $(this).parents('.file');
  89. block.find('input:file').click();
  90. block.find('input:file').change(function(){
  91. block.find('input:text').val(block.find('input:file').val());
  92. });
  93. });
  94. /* eof input file */
  95. /* user change */
  96. $(".user-change-button").click(function(){
  97. $(this).parents(".block").find('.user-change').animate({opacity: 0},400,function(){
  98. $(this).find('img').attr('src','img/user.jpg');
  99. $(this).animate({opacity: 1},400);
  100. });
  101. $(this).parents(".block").find(".user-change-row").fadeIn(800);
  102. $(this).remove();
  103. });
  104. /* table checkall */
  105. $("table .checkall").click(function(){
  106. var iC = $(this).parents('th').index();
  107. var tB = $(this).parents('table').find('tbody');
  108. if($(this).is(':checked'))
  109. tB.find('tr').each(function(){
  110. var cb = $(this).find('td:eq('+iC+') input:checkbox');
  111. cb.parent('span').addClass('checked');
  112. cb.attr('checked',false);
  113. });
  114. else
  115. tB.find('tr').each(function(){
  116. var cb = $(this).find('td:eq('+iC+') input:checkbox');
  117. cb.parent('span').removeClass('checked')
  118. cb.attr('checked',false);
  119. });
  120. });
  121. /* eof table checkall */
  122. /* statusbar */
  123. $(".stbar, .statusbar-close").click(function(){
  124. statusbar($(this).attr('href'));
  125. return false;
  126. });
  127. /* eof statusbar */
  128. /* remove content from ui spinner buttons */
  129. $(".ui-spinner").find('span').html('');
  130. /* icons */
  131. $(".icons-list .col-md-3").click(function(){
  132. var text = $(this).html();
  133. var r = /<(\w+)[^>]*>.*<\/\1>/gi;
  134. var icon = $.trim(text.replace(r,""));
  135. $("#modal_icon .modal-body .list").html('<div class="list-item"><div class="list-text"><p>&lt;i class="'+icon+'">&lt;/i></p></div></div>'
  136. +'<div class="list-item"><div class="list-text"><p>&lt;span class="'+icon+'">&lt;/span></p></div></div>'
  137. +'<div class="list-item"><div class="list-text"><p>.'+icon+'</p></div></div>');
  138. $("#modal_icon .modal-body .icons-list-icon").html("").append('<span class="'+icon+'"></span>');
  139. $("#modal_icon").modal('show');
  140. });
  141. /* eof icons */
  142. });
  143. $(window).bind("load", function() {
  144. gallery();
  145. thumbs();
  146. lists();
  147. page();
  148. });
  149. $(window).resize(function(){
  150. /* vertical tabs */
  151. $(".nav-tabs-vertical").each(function(){
  152. var h = $(this).find('.nav-tabs').height();
  153. $(this).find('.tabs').css('min-height',h);
  154. });
  155. /* eof vertical tabs */
  156. gallery();
  157. thumbs();
  158. lists();
  159. page();
  160. });
  161. function page(){
  162. if($("body").width() < 768){
  163. $(".page-container").addClass("page-sidebar-narrow");
  164. $(".page-navigation li ul").removeAttr('style');
  165. }
  166. }
  167. function lists(){
  168. $(".list").each(function(){
  169. var items = $(this).find(".list-controls");
  170. if(items.length > 0)
  171. items.each(function(){
  172. $(this).height($(this).parent('.list-item').height()-10).css('line-height',$(this).parent('.list-item').height()-10+'px');
  173. });
  174. });
  175. }
  176. function gallery(){
  177. var w_block = $(".gallery").width()-20;
  178. var w_item = $(".gallery a").width();
  179. var c_items = Math.floor( w_block/w_item );
  180. var m_items = Math.round( (w_block-w_item*c_items)/(c_items*2) );
  181. if(w_block < (m_items*2+w_item)*c_items) m_items = m_items - 1;
  182. $(".gallery a").css('margin',m_items+2);
  183. }
  184. function thumbs(){
  185. $(".gallery-list").each(function(){
  186. var maxImgHeight = 0;
  187. var maxTextHeight = 0;
  188. $(this).find(".gallery-item").each(function(){
  189. var imgHeight = $(this).find('a > img').height();
  190. var textHeight = $(this).find('.text').height();
  191. maxImgHeight = maxImgHeight < imgHeight ? imgHeight : maxImgHeight;
  192. maxTextHeight = maxTextHeight < textHeight ? textHeight : maxTextHeight;
  193. });
  194. $(this).find('.gallery-list .gallery-image').height(maxImgHeight);
  195. $(this).find('.gallery-list .gallery-content .text').height(maxTextHeight);
  196. });
  197. var w_block = $(".gallery-list").width();
  198. var w_item = $(".gallery-list .gallery-item").width()+10;
  199. var c_items = Math.floor(w_block/w_item);
  200. var m_items = Math.floor( ((w_block - (w_item*c_items)) / c_items)/2);
  201. $(".gallery-list .gallery-item").css('margin',m_items);
  202. }
  203. function statusbar(id){
  204. $(".statusbar").hide();
  205. if($(id).is(":hidden")) $(id).fadeIn();
  206. }
  207. function tsp(value,state,pos){
  208. $("#tsp").remove();
  209. var period = null;
  210. if($.isArray(value)){
  211. period = value;
  212. value = value[0];
  213. }
  214. var tsp = '<div id="tsp"'+(pos!=null?' class="tsp-'+pos+'"':'')+'><div class="tsp-progress'+(state!=null?' tsp-'+state:'')+'" style="width:'+value+'%;"></div></div>';
  215. $('body').append(tsp);
  216. if(period !== null){
  217. i = period[0];
  218. timer = setInterval(function(){
  219. $("#tsp .tsp-progress").css('width',i+'%'); i++;
  220. if (i > period[1]) clearInterval(timer);
  221. }, 20);
  222. }
  223. }