PageRenderTime 65ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/public/assets2/js/uncompressed/core.js

https://gitlab.com/rohiri/SIINDI
JavaScript | 463 lines | 290 code | 154 blank | 19 comment | 51 complexity | 3d1f7081f3fae5c9e1bc8bca4b0d437c MD5 | raw file
  1. /* -------------------- Check Browser --------------------- */
  2. function browser() {
  3. var isOpera = !!(window.opera && window.opera.version); // Opera 8.0+
  4. var isFirefox = testCSS('MozBoxSizing'); // FF 0.8+
  5. var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
  6. // At least Safari 3+: "[object HTMLElementConstructor]"
  7. var isChrome = !isSafari && testCSS('WebkitTransform'); // Chrome 1+
  8. //var isIE = /*@cc_on!@*/false || testCSS('msTransform'); // At least IE6
  9. function testCSS(prop) {
  10. return prop in document.documentElement.style;
  11. }
  12. if (isOpera) {
  13. return false;
  14. }else if (isSafari || isChrome) {
  15. return true;
  16. } else {
  17. return false;
  18. }
  19. }
  20. jQuery(document).ready(function($){
  21. /* ---------- Remove elements in IE8 ---------- */
  22. if(jQuery.browser.version.substring(0, 2) == "8.") {
  23. $('.hideInIE8').remove();
  24. }
  25. /* ---------- Disable moving to top ---------- */
  26. $('a[href="#"][data-top!=true]').click(function(e){
  27. e.preventDefault();
  28. });
  29. /* ---------- Notifications ---------- */
  30. $('.noty').click(function(e){
  31. e.preventDefault();
  32. var options = $.parseJSON($(this).attr('data-noty-options'));
  33. noty(options);
  34. });
  35. /* ---------- Tabs ---------- */
  36. $('#myTab a:first').tab('show');
  37. $('#myTab a').click(function (e) {
  38. e.preventDefault();
  39. $(this).tab('show');
  40. });
  41. /* ---------- Tooltip ---------- */
  42. $('[rel="tooltip"],[data-rel="tooltip"]').tooltip({"placement":"bottom",delay: { show: 400, hide: 200 }});
  43. /* ---------- Popover ---------- */
  44. $('[rel="popover"],[data-rel="popover"],[data-toggle="popover"]').popover();
  45. /* ---------- Fullscreen ---------- */
  46. $('#toggle-fullscreen').button().click(function () {
  47. var button = $(this), root = document.documentElement;
  48. if (!button.hasClass('active')) {
  49. $('#thumbnails').addClass('modal-fullscreen');
  50. if (root.webkitRequestFullScreen) {
  51. root.webkitRequestFullScreen(
  52. window.Element.ALLOW_KEYBOARD_INPUT
  53. );
  54. } else if (root.mozRequestFullScreen) {
  55. root.mozRequestFullScreen();
  56. }
  57. } else {
  58. $('#thumbnails').removeClass('modal-fullscreen');
  59. (document.webkitCancelFullScreen ||
  60. document.mozCancelFullScreen ||
  61. $.noop).apply(document);
  62. }
  63. });
  64. $('.btn-close').click(function(e){
  65. e.preventDefault();
  66. $(this).parent().parent().parent().fadeOut();
  67. });
  68. $('.btn-minimize').click(function(e){
  69. e.preventDefault();
  70. var $target = $(this).parent().parent().next('.box-content');
  71. if($target.is(':visible')) $('i',$(this)).removeClass('fa fa-chevron-up').addClass('fa fa-chevron-down');
  72. else $('i',$(this)).removeClass('fa fa-chevron-down').addClass('fa fa-chevron-up');
  73. $target.slideToggle('slow', function() {
  74. widthFunctions();
  75. });
  76. });
  77. $('.btn-setting').click(function(e){
  78. e.preventDefault();
  79. $('#myModal').modal('show');
  80. });
  81. });
  82. /* ---------- Delete Comment ---------- */
  83. jQuery(document).ready(function($){
  84. $('.discussions').find('.delete').click(function(){
  85. $(this).parent().fadeTo("slow", 0.00, function(){ //fade
  86. $(this).slideUp("slow", function() { //slide up
  87. $(this).remove(); //then remove from the DOM
  88. });
  89. });
  90. });
  91. });
  92. /* ---------- IE8 list style hack (:nth-child(odd)) ---------- */
  93. jQuery(document).ready(function($){
  94. if($('.messagesList').width()) {
  95. if(jQuery.browser.version.substring(0, 2) == "8.") {
  96. $('ul.messagesList li:nth-child(2n+1)').addClass('odd');
  97. }
  98. }
  99. });
  100. /* ---------- Check Retina ---------- */
  101. function retina(){
  102. retinaMode = (window.devicePixelRatio > 1);
  103. return retinaMode;
  104. }
  105. jQuery(document).ready(function($){
  106. /* ---------- Add class .active to current link ---------- */
  107. $('ul.main-menu li a').each(function(){
  108. if($($(this))[0].href==String(window.location)) {
  109. $(this).parent().addClass('active');
  110. }
  111. });
  112. $('ul.main-menu li ul li a').each(function(){
  113. if($($(this))[0].href==String(window.location)) {
  114. $(this).parent().addClass('active');
  115. $(this).parent().parent().show();
  116. }
  117. });
  118. /* ---------- Submenu ---------- */
  119. $('.dropmenu').click(function(e){
  120. e.preventDefault();
  121. $(this).parent().find('ul').slideToggle();
  122. });
  123. });
  124. /* ---------- Main Menu Open/Close ---------- */
  125. jQuery(document).ready(function($){
  126. var startFunctions = true;
  127. $('#main-menu-toggle').click(function(){
  128. if($(this).hasClass('open')){
  129. $(this).removeClass('open').addClass('close');
  130. var span = $('#content').attr('class');
  131. var spanNum = parseInt(span.replace( /^\D+/g, ''));
  132. var newSpanNum = spanNum + 2;
  133. var newSpan = 'span' + newSpanNum;
  134. $('#content').addClass('full');
  135. $('.navbar-brand').addClass('noBg');
  136. $('#sidebar-left').hide();
  137. } else {
  138. $(this).removeClass('close').addClass('open');
  139. var span = $('#content').attr('class');
  140. var spanNum = parseInt(span.replace( /^\D+/g, ''));
  141. var newSpanNum = spanNum - 2;
  142. var newSpan = 'span' + newSpanNum;
  143. $('#content').removeClass('full');
  144. $('.navbar-brand').removeClass('noBg');
  145. $('#sidebar-left').show();
  146. }
  147. });
  148. });
  149. jQuery(document).ready(function($){
  150. if($(".boxchart").length) {
  151. if (retina()) {
  152. $(".boxchart").sparkline('html', {
  153. type: 'bar',
  154. height: '60', // Double pixel number for retina display
  155. barWidth: '8', // Double pixel number for retina display
  156. barSpacing: '2', // Double pixel number for retina display
  157. barColor: '#ffffff',
  158. negBarColor: '#eeeeee'}
  159. );
  160. if (jQuery.browser.mozilla) {
  161. if (!!navigator.userAgent.match(/Trident\/7\./)) {
  162. $(".boxchart").css('zoom',0.5);
  163. } else {
  164. $(".boxchart").css('MozTransform','scale(0.5,0.5)').css('height','30px;');
  165. $(".boxchart").css('height','30px;').css('margin','-15px 15px -15px -15px');
  166. }
  167. } else {
  168. $(".boxchart").css('zoom',0.5);
  169. }
  170. } else {
  171. $(".boxchart").sparkline('html', {
  172. type: 'bar',
  173. height: '30',
  174. barWidth: '4',
  175. barSpacing: '1',
  176. barColor: '#ffffff',
  177. negBarColor: '#eeeeee'}
  178. );
  179. }
  180. }
  181. if($('.chart-stat').length) {
  182. if (retina()) {
  183. $(".chart-stat > .chart").each(function(){
  184. var chartColor = $(this).css('color');
  185. $(this).sparkline('html', {
  186. width: '180%',//Width of the chart - Defaults to 'auto' - May be any valid css width - 1.5em, 20px, etc (using a number without a unit specifier won't do what you want) - This option does nothing for bar and tristate chars (see barWidth)
  187. height: 80,//Height of the chart - Defaults to 'auto' (line height of the containing tag)
  188. lineColor: chartColor,//Used by line and discrete charts to specify the colour of the line drawn as a CSS values string
  189. fillColor: false,//Specify the colour used to fill the area under the graph as a CSS value. Set to false to disable fill
  190. spotColor: false,//The CSS colour of the final value marker. Set to false or an empty string to hide it
  191. maxSpotColor: false,//The CSS colour of the marker displayed for the maximum value. Set to false or an empty string to hide it
  192. minSpotColor: false,//The CSS colour of the marker displayed for the mimum value. Set to false or an empty string to hide it
  193. spotRadius: 2,//Radius of all spot markers, In pixels (default: 1.5) - Integer
  194. lineWidth: 2//In pixels (default: 1) - Integer
  195. });
  196. if (jQuery.browser.mozilla) {
  197. if (!!navigator.userAgent.match(/Trident\/7\./)) {
  198. $(this).css('zoom',0.5);
  199. } else {
  200. $(this).css('MozTransform','scale(0.5,0.5)');
  201. $(this).css('height','40px;').css('margin','-20px 0px -20px -25%');
  202. }
  203. } else {
  204. $(this).css('zoom',0.5);
  205. }
  206. });
  207. } else {
  208. $(".chart-stat > .chart").each(function(){
  209. var chartColor = $(this).css('color');
  210. $(this).sparkline('html', {
  211. width: '90%',//Width of the chart - Defaults to 'auto' - May be any valid css width - 1.5em, 20px, etc (using a number without a unit specifier won't do what you want) - This option does nothing for bar and tristate chars (see barWidth)
  212. height: 40,//Height of the chart - Defaults to 'auto' (line height of the containing tag)
  213. lineColor: chartColor,//Used by line and discrete charts to specify the colour of the line drawn as a CSS values string
  214. fillColor: false,//Specify the colour used to fill the area under the graph as a CSS value. Set to false to disable fill
  215. spotColor: false,//The CSS colour of the final value marker. Set to false or an empty string to hide it
  216. maxSpotColor: false,//The CSS colour of the marker displayed for the maximum value. Set to false or an empty string to hide it
  217. minSpotColor: false,//The CSS colour of the marker displayed for the mimum value. Set to false or an empty string to hide it
  218. spotRadius: 2,//Radius of all spot markers, In pixels (default: 1.5) - Integer
  219. lineWidth: 2//In pixels (default: 1) - Integer
  220. });
  221. });
  222. }
  223. }
  224. });
  225. jQuery(document).ready(function($){
  226. /* ---------- ToDo List Action Buttons ---------- */
  227. if($(".todo-actions").length) {
  228. $(".todo-actions > a").click(function(){
  229. if ($(this).find('i').attr('class') == 'fa fa-square-o') {
  230. $(this).find('i').removeClass('fa fa-square-o').addClass('fa fa-check-square-o');
  231. $(this).parent().parent().find('span').css({ opacity: 0.25 });
  232. $(this).parent().parent().find('.desc').css('text-decoration', 'line-through');
  233. } else {
  234. $(this).find('i').removeClass('fa fa-check-square-o').addClass('fa fa-square-o');
  235. $(this).parent().parent().find('span').css({ opacity: 1 });
  236. $(this).parent().parent().find('.desc').css('text-decoration', 'none');
  237. }
  238. return false;
  239. });
  240. /* ---------- ToDo List Active Sortable List ---------- */
  241. $(function() {
  242. $(".todo-list").sortable();
  243. $(".todo-list").disableSelection();
  244. });
  245. }
  246. });
  247. function hexToRgb(hex) {
  248. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  249. return result ? {
  250. r: parseInt(result[1], 16),
  251. g: parseInt(result[2], 16),
  252. b: parseInt(result[3], 16)
  253. } : null;
  254. }
  255. function rgbToRgba(rgb, alpha) {
  256. if (jQuery.browser.version <= 8.0) {
  257. rgb = hexToRgb(rgb);
  258. rgba = 'rgba('+ rgb.r +','+ rgb.g +','+ rgb.b +','+ alpha +')';
  259. } else {
  260. rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  261. rgba = 'rgba('+ rgb[1] +','+ rgb[2] +','+ rgb[3] +','+ alpha +')';
  262. }
  263. return rgba;
  264. }
  265. $(document).ready(function(){
  266. widthFunctions();
  267. });
  268. /* ---------- Page width functions ---------- */
  269. $(window).bind("resize", widthFunctions);
  270. function widthFunctions(e) {
  271. if($('.timeline')) {
  272. $('.timeslot').each(function(){
  273. var timeslotHeight = $(this).find('.task').outerHeight();
  274. $(this).css('height',timeslotHeight);
  275. });
  276. }
  277. var sidebarLeftHeight = $('#sidebar-left').outerHeight();
  278. var contentHeight = $('#content').height();
  279. var contentHeightOuter = $('#content').outerHeight();
  280. var headerHeight = $('header').height();
  281. var footerHeight = $('footer').height();
  282. var winHeight = $(window).height();
  283. var winWidth = $(window).width();
  284. if (winWidth > 767) {
  285. if (winHeight - 80 > sidebarLeftHeight) {
  286. $('#sidebar-left').css('min-height',winHeight-headerHeight-footerHeight);
  287. }
  288. if (winHeight - 80 > contentHeight) {
  289. $('#content').css('min-height',winHeight-headerHeight-footerHeight);
  290. }
  291. $('#white-area').css('height',contentHeightOuter);
  292. } else {
  293. $('#sidebar-left').css('min-height','0px');
  294. $('#white-area').css('height','auto');
  295. }
  296. if (winWidth < 768) {
  297. if($('.chat-full')) {
  298. $('.chat-full').each(function(){
  299. $(this).addClass('alt');
  300. });
  301. }
  302. } else {
  303. if($('.chat-full')) {
  304. $('.chat-full').each(function(){
  305. $(this).removeClass('alt');
  306. });
  307. }
  308. }
  309. }