clean up common.js
[snf-cloudcms] / cloudcms / static / cloudcms / js / common.js
index 5eedd03..69465a8 100644 (file)
@@ -1,16 +1,5 @@
-function isIpadIphone(){
-  var flag = false;
-    var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone");
-    var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
-    if(isiPhone > -1) { flag = true; }
-    if(isiPad > -1) { flag = true; }
-    return flag;
-}
-
 function setContainerMinHeight( applicableDiv){
-
   if ( $(applicableDiv).length > 0 ) {
-    //var h = $('.header').height(); div.header is not found
     var f = $('.footer').height();
     var w = $(window).height();
     var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) );
@@ -20,25 +9,6 @@ function setContainerMinHeight( applicableDiv){
   }
 }
 
-function tableFixedCols(table, firstColWidth ){
-       ColsNum = $('table th').size();
-       var ColWidth = parseFloat( (100 - firstColWidth)/ColsNum ).toFixed(0);
-       var ColWidthPercentage = ColWidth+'%';
-       var firstColWidthPercentage = firstColWidth+'%';
-       $('.projects table th, .projects  table td').attr('width',ColWidthPercentage );
-       $('.projects table tr td:first-child,.projects  table tr th:first-child').attr('width',firstColWidthPercentage );
-}
-
-function addClassHover(hoverEl, applicableEl){
-       $(hoverEl).hover(
-      function () {
-        $(applicableEl).addClass('red-border')
-      },
-      function () {
-        $(applicableEl).removeClass('red-border');
-    });
-}
-
 //equal heights
 (function($) {
        $.fn.equalHeights = function(minHeight, maxHeight) {
@@ -55,9 +25,16 @@ function addClassHover(hoverEl, applicableEl){
        }
 })(jQuery);
 
-
-
 // fix for iPhone - iPad orientation bug
+function isIpadIphone(){
+  var flag = false;
+    var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone");
+    var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
+    if(isiPhone > -1) { flag = true; }
+    if(isiPad > -1) { flag = true; }
+    return flag;
+}
+
 var metas = document.getElementsByTagName('meta');
 function resetViewport() {
   var i;
@@ -88,23 +65,10 @@ if (navigator.userAgent.match(/iPhone/i)) {
 }
 //end of fix
 
-function setFixedLtBar(){
-  var diff = ( $(window).height() - $('.footer').outerHeight() ) - $('.details .lt').height();
-  if ( $('.details .lt').height() < $('.details .rt').height() ) {
-    if ( ($(window).scrollTop() > window.fixEloffsetTop) && diff>0 ) {
-      fixEl.addClass('fixed');
-    } else {
-      fixEl.removeClass('fixed');
-    }
-  }
-  console.log(diff,'diff');
-}
-
 $(document).ready(function() {
 
 
   setContainerMinHeight('.container .wrapper');
-  tableFixedCols('my-projects', 25);
 
   $('.show-extra').click(function(e) {
       e.preventDefault();
@@ -115,11 +79,6 @@ $(document).ready(function() {
       $(this).parents('.bg-wrap').find('.extra').slideUp(600);
   });
 
-  $('.box-more p').click(function(e) {
-      $(this).siblings('.clearfix').toggle('slow');
-      $(this).parents('.box-more').toggleClass('border');
-  });
-
        var fixTopMessageHeight = function() {
                var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom'));
                $('.mainlogo').css('marginTop','-'+topMargin+'px');
@@ -149,14 +108,6 @@ $(document).ready(function() {
         });
     });
 
-       $('select.dropkicked').dropkick({
-               change: function (value, label) {
-                   $(this).parents('form').submit();
-               }
-       });
-
-  $('.with-info select').attr('tabindex','1');
-  $('.with-info select').dropkick();
   $('.top-msg .success').parents('.top-msg').addClass('success');
   $('.top-msg .error').parents('.top-msg').addClass('error');
   $('.top-msg .warning').parents('.top-msg').addClass('warning');
@@ -188,137 +139,6 @@ $(document).ready(function() {
     }
   );
 
-  $(function() {
-    $( "#id_start_date" ).datepicker({
-      minDate: 0,
-      defaultDate: "+0",
-      dateFormat: "yy-mm-dd",
-      onSelect: function( selectedDate ) {
-        $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate );
-      }
-    });
-    $( "#id_end_date" ).datepicker({
-      defaultDate: "+3w",
-      dateFormat: "yy-mm-dd",
-      onSelect: function( selectedDate ) {
-        $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate );
-      }
-    });
-  });
-
-       $('table .more-info').click(function(e){
-               e.preventDefault();
-               $(this).toggleClass('open');
-               if ($(this).hasClass('open')){
-                       $(this).html('- less info ')
-               } else {
-                       $(this).html('+ more info ')
-               }
-               $(this).parents('tr').next('tr').toggle();
-       });
-
-       $('.projects .details .edit').click( function(e){
-               e.preventDefault();
-               $(this).parents('.details').children('.data').hide();
-               $(this).parents('.details').children('.editable').slideDown(500, 'linear');
-               $(this).hide();
-       });
-
-       $('.editable .form-row').each(function() {
-               if ( $(this).hasClass('with-errors') ){
-                       $('.editable').show();
-                       $('.projects .details a.edit, .projects .details .data').hide();
-               }
-       });
-
-       $("input.leave, input.join").click(function () {
-               $('dialog').hide();
-               $(this).parents('.msg-wrap').find('.dialog').show();
-               return false;
-  });
-
-  $('.msg-wrap .no').click( function(e){
-    e.preventDefault();
-    $(this).parents('.dialog').hide();
-  });
-
-  $('.msg-wrap .yes').click( function(e){
-    e.preventDefault();
-    $(this).parents('.dialog').siblings('form').submit();
-       });
-
-  $('.hidden-submit input[readonly!="True"]').focus(function () {
-    $('.hidden-submit .form-row.submit').slideDown(500);
-  });
-
-  setTimeout(function() {
-    if ($('input#id_username').val()){
-      $('input#id_username').siblings('label').css('opacity','0');
-    };
-    if ($('input#id_password').val()){
-      $('input#id_password').siblings('label').css('opacity','0');
-    }
-  }, 100);
-
-       $('.landing-page .cms').hover(
-    function () {
-      el = $('.cloudbar ul.services li').first();
-      var offset = el.offset();
-      positionX = offset.left;
-      $('#hand').css('left',positionX);
-      $('#hand').show();
-    },
-    function () {
-      $('#hand').hide();
-    }
-  );
-
-  $('.landing-page .pithos').hover(
-    function () {
-      el = $('.cloudbar ul.services li:nth-child(3)');
-      var offset = el.offset();
-      positionX = offset.left;
-      left = parseInt(positionX) +20;
-      $('#hand').css('left',left+'px');
-      $('#hand').show();
-    }, 
-    function () {
-      $('#hand').hide();
-    }
-  );
-
-  $('.landing-page .cyclades').hover(
-    function () {
-      el = $('.cloudbar ul.services li:nth-child(2)').first();
-      var offset = el.offset();
-      positionX = offset.left;
-      left = parseInt(positionX) +20;
-      $('#hand').css('left',left+'px');
-      $('#hand').show();
-    },
-    function () {
-      $('#hand').hide();
-    }
-  );
-  $('.landing-page .dashboard').hover(
-    function () {
-      el = $('.cloudbar .profile');
-      var offset = el.offset();
-      positionX = offset.left +50;
-      $('#hand').css('left',positionX);
-      $('#hand').show();
-    },
-    function () {
-      $('#hand').hide();
-    }
-  );
-  $('.pagination a.disabled').click(function(e){
-    e.preventDefault();
-  });
-
-       // fix for recaptcha fields
-       $('#okeanos_recaptcha').parents('.form-row').find('.extra-img').hide();
-
   fixEl = $('.details .lt');
   if (fixEl.length){ window.fixEloffsetTop = fixEl.offset().top;}
 
@@ -329,9 +149,19 @@ $(document).ready(function() {
 $(window).resize(function() {
   setContainerMinHeight('.container .wrapper');
   $(".stats-block li em").equalHeights();
+  $(window).scroll(function () {
+    setFixedLtBar();
+  });
 });
 
 /* js for fixed faq/userguide side nav */
 $(window).scroll(function () {
-  setFixedLtBar();
+  var diff = ( $(window).height() - $('.footer').outerHeight() ) - $('.details .lt').height();
+  if ( $('.details .lt').height() < $('.details .rt').height() ) {
+    if ( ($(window).scrollTop() > window.fixEloffsetTop) && diff>0 ) {
+      fixEl.addClass('fixed');
+    } else {
+      fixEl.removeClass('fixed');
+    }
+  }
 });
\ No newline at end of file