application.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // This is a manifest file that'll be compiled into including all the files listed below.
  2. // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
  3. // be included in the compiled file accessible from http://example.com/assets/application.js
  4. // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  5. // the compiled file.
  6. //
  7. //= require ./app/lib/core/jquery-2.1.1.js
  8. //= require ./app/lib/core/jquery-ui-1.11.2.js
  9. //= require ./app/lib/core/underscore-1.7.0.js
  10. //= require ./app/lib/animations/velocity.min.js
  11. //= require ./app/lib/animations/velocity.ui.js
  12. //not_used= require_tree ./app/lib/spine
  13. //= require ./app/lib/spine/spine.coffee
  14. //= require ./app/lib/spine/ajax.coffee
  15. //= require ./app/lib/spine/local.coffee
  16. //= require ./app/lib/spine/route.coffee
  17. //= require ./app/lib/flot/jquery.flot.js
  18. //= require ./app/lib/flot/jquery.flot.selection.js
  19. //not_used= require_tree ./app/lib/bootstrap
  20. //= require ./app/lib/bootstrap/dropdown.js
  21. //= require ./app/lib/bootstrap/tooltip.js
  22. //= require ./app/lib/bootstrap/popover.js
  23. //= require ./app/lib/bootstrap/popover-enhance.js
  24. // modified by Felix Jan-2014
  25. //= require ./app/lib/bootstrap/modal.js
  26. //= require ./app/lib/bootstrap/tab.js
  27. //= require ./app/lib/bootstrap/transition.js
  28. //= require ./app/lib/bootstrap/button.js
  29. //= require ./app/lib/bootstrap/collapse.js
  30. //= require_tree ./app/lib/base
  31. //= require ./app/index.js.coffee
  32. // IE8 workaround for missing console.log
  33. if (!window.console) {
  34. window.console = {}
  35. }
  36. if (!console.log) {
  37. console.log = function(){}
  38. }
  39. function escapeRegExp(str) {
  40. return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  41. }
  42. Date.prototype.getWeek = function() {
  43. var onejan = new Date(this.getFullYear(),0,1);
  44. return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
  45. }
  46. function difference(object1, object2) {
  47. var changes = {};
  48. for ( var name in object1 ) {
  49. if ( name in object2 ) {
  50. if ( _.isObject( object2[name] ) && !_.isArray( object2[name] ) ) {
  51. var diff = difference( object1[name], object2[name] );
  52. if ( !_.isEmpty( diff ) ) {
  53. changes[name] = diff;
  54. }
  55. } else if ( !_.isEqual( object1[name], object2[name] ) ) {
  56. changes[name] = object2[name];
  57. }
  58. }
  59. }
  60. return changes;
  61. }
  62. // taken from http://stackoverflow.com/questions/4459928/how-to-deep-clone-in-javascript
  63. function clone(item) {
  64. if (!item) { return item; } // null, undefined values check
  65. var types = [ Number, String, Boolean ],
  66. result;
  67. // normalizing primitives if someone did new String('aaa'), or new Number('444');
  68. types.forEach(function(type) {
  69. if (item instanceof type) {
  70. result = type( item );
  71. }
  72. });
  73. if (typeof result == "undefined") {
  74. if (Object.prototype.toString.call( item ) === "[object Array]") {
  75. result = [];
  76. item.forEach(function(child, index, array) {
  77. result[index] = clone( child );
  78. });
  79. } else if (typeof item == "object") {
  80. // testing that this is DOM
  81. if (item.nodeType && typeof item.cloneNode == "function") {
  82. var result = item.cloneNode( true );
  83. } else if (!item.prototype) { // check that this is a literal
  84. if (item instanceof Date) {
  85. result = new Date(item);
  86. } else {
  87. // it is an object literal
  88. result = {};
  89. for (var i in item) {
  90. result[i] = clone( item[i] );
  91. }
  92. }
  93. } else {
  94. // depending what you would like here,
  95. // just keep the reference, or create new object
  96. if (false && item.constructor) {
  97. // would not advice to do that, reason? Read below
  98. result = new item.constructor();
  99. } else {
  100. result = item;
  101. }
  102. }
  103. } else {
  104. result = item;
  105. }
  106. }
  107. return result;
  108. }
  109. jQuery.event.special.remove = {
  110. remove: function(e) {
  111. if (e.handler) e.handler();
  112. }
  113. };
  114. // start application
  115. jQuery(function(){
  116. new App.Run();
  117. });