]> source.dussan.org Git - redmine.git/commitdiff
replace tabs to spaces and fix indents public/javascripts/context_menu.js
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 16 Feb 2012 01:35:23 +0000 (01:35 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 16 Feb 2012 01:35:23 +0000 (01:35 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8889 e93f8b46-1217-0410-a6f0-8f06a7374b81

public/javascripts/context_menu.js

index a383ebe00393d00af76bd981c96d46a45ced75cc..d6d800a28df2a5c1ded7a7fd70cf08f2f70fef06 100644 (file)
@@ -5,42 +5,42 @@ var observingContextMenuClick;
 
 ContextMenu = Class.create();
 ContextMenu.prototype = {
-       initialize: function (url) {
-       this.url = url;
-       this.createMenu();
+  initialize: function (url) {
+  this.url = url;
+  this.createMenu();
 
-       if (!observingContextMenuClick) {
-               Event.observe(document, 'click', this.Click.bindAsEventListener(this));
-               Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
-               observingContextMenuClick = true;
-       }
-       
-       this.unselectAll();
-       this.lastSelected = null;
-       },
+  if (!observingContextMenuClick) {
+    Event.observe(document, 'click', this.Click.bindAsEventListener(this));
+    Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
+    observingContextMenuClick = true;
+  }
+  
+  this.unselectAll();
+  this.lastSelected = null;
+  },
   
-       RightClick: function(e) {
-               this.hideMenu();
-               // do not show the context menu on links
-               if (Event.element(e).tagName == 'A') { return; }
-               var tr = Event.findElement(e, 'tr');
-               if (tr == document || tr == undefined  || !tr.hasClassName('hascontextmenu')) { return; }
-               Event.stop(e);
-               if (!this.isSelected(tr)) {
-                       this.unselectAll();
-                       this.addSelection(tr);
-                       this.lastSelected = tr;
-               }
-               this.showMenu(e);
-       },
+  RightClick: function(e) {
+    this.hideMenu();
+    // do not show the context menu on links
+    if (Event.element(e).tagName == 'A') { return; }
+    var tr = Event.findElement(e, 'tr');
+    if (tr == document || tr == undefined  || !tr.hasClassName('hascontextmenu')) { return; }
+    Event.stop(e);
+    if (!this.isSelected(tr)) {
+      this.unselectAll();
+      this.addSelection(tr);
+      this.lastSelected = tr;
+    }
+    this.showMenu(e);
+  },
 
   Click: function(e) {
-               if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
-                       Event.stop(e)
-                       return;
-               }
-       this.hideMenu();
-       if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
+    if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
+      Event.stop(e)
+      return;
+    }
+    this.hideMenu();
+    if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
     if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) {      
       var tr = Event.findElement(e, 'tr');
       if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) {
@@ -114,7 +114,7 @@ ContextMenu.prototype = {
     var max_height;
 
     $('context-menu').style['left'] = (render_x + 'px');
-    $('context-menu').style['top'] = (render_y + 'px');                
+    $('context-menu').style['top'] = (render_y + 'px');    
     Element.update('context-menu', '');
 
     new Ajax.Updater({success:'context-menu'}, this.url, 
@@ -123,34 +123,34 @@ ContextMenu.prototype = {
        evalScripts:true,
        parameters:Form.serialize(Event.findElement(e, 'form')),
        onComplete:function(request){
-                                dims = $('context-menu').getDimensions();
-                                menu_width = dims.width;
-                                menu_height = dims.height;
-                                max_width = mouse_x + 2*menu_width;
-                                max_height = mouse_y + menu_height;
-                       
-                                var ws = window_size();
-                                window_width = ws.width;
-                                window_height = ws.height;
-                       
-                                /* display the menu above and/or to the left of the click if needed */
-                                if (max_width > window_width) {
-                                  render_x -= menu_width;
-                                  $('context-menu').addClassName('reverse-x');
-                                } else {
-                                        $('context-menu').removeClassName('reverse-x');
-                                }
-                                if (max_height > window_height) {
-                                  render_y -= menu_height;
-                                  $('context-menu').addClassName('reverse-y');
-                                } else {
-                                        $('context-menu').removeClassName('reverse-y');
-                                }
-                                if (render_x <= 0) render_x = 1;
-                                if (render_y <= 0) render_y = 1;
-                                $('context-menu').style['left'] = (render_x + 'px');
-                                $('context-menu').style['top'] = (render_y + 'px');
-                                
+         dims = $('context-menu').getDimensions();
+         menu_width = dims.width;
+         menu_height = dims.height;
+         max_width = mouse_x + 2*menu_width;
+         max_height = mouse_y + menu_height;
+      
+         var ws = window_size();
+         window_width = ws.width;
+         window_height = ws.height;
+      
+         /* display the menu above and/or to the left of the click if needed */
+         if (max_width > window_width) {
+           render_x -= menu_width;
+           $('context-menu').addClassName('reverse-x');
+         } else {
+           $('context-menu').removeClassName('reverse-x');
+         }
+         if (max_height > window_height) {
+           render_y -= menu_height;
+           $('context-menu').addClassName('reverse-y');
+         } else {
+           $('context-menu').removeClassName('reverse-y');
+         }
+         if (render_x <= 0) render_x = 1;
+         if (render_y <= 0) render_y = 1;
+         $('context-menu').style['left'] = (render_x + 'px');
+         $('context-menu').style['top'] = (render_y + 'px');
+         
          Effect.Appear('context-menu', {duration: 0.20});
          if (window.parseStylesheets) { window.parseStylesheets(); } // IE
       }})
@@ -187,8 +187,8 @@ ContextMenu.prototype = {
   },
   
   checkSelectionBox: function(tr, checked) {
-       var inputs = Element.getElementsBySelector(tr, 'input');
-       if (inputs.length > 0) { inputs[0].checked = checked; }
+    var inputs = Element.getElementsBySelector(tr, 'input');
+    if (inputs.length > 0) { inputs[0].checked = checked; }
   },
   
   isSelected: function(tr) {
@@ -205,32 +205,32 @@ ContextMenu.prototype = {
 }
 
 function toggleIssuesSelection(el) {
-       var boxes = el.getElementsBySelector('input[type=checkbox]');
-       var all_checked = true;
-       for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } }
-       for (i = 0; i < boxes.length; i++) {
-               if (all_checked) {
-                       boxes[i].checked = false;
-                       boxes[i].up('tr').removeClassName('context-menu-selection');
-               } else if (boxes[i].checked == false) {
-                       boxes[i].checked = true;
-                       boxes[i].up('tr').addClassName('context-menu-selection');
-               }
-       }
+  var boxes = el.getElementsBySelector('input[type=checkbox]');
+  var all_checked = true;
+  for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } }
+  for (i = 0; i < boxes.length; i++) {
+    if (all_checked) {
+      boxes[i].checked = false;
+      boxes[i].up('tr').removeClassName('context-menu-selection');
+    } else if (boxes[i].checked == false) {
+      boxes[i].checked = true;
+      boxes[i].up('tr').addClassName('context-menu-selection');
+    }
+  }
 }
 
 function window_size() {
-    var w;
-    var h;
-    if (window.innerWidth) {
-       w = window.innerWidth;
-       h = window.innerHeight;
-    } else if (document.documentElement) {
-       w = document.documentElement.clientWidth;
-       h = document.documentElement.clientHeight;
-    } else {
-       w = document.body.clientWidth;
-       h = document.body.clientHeight;
-    }
-    return {width: w, height: h};
+  var w;
+  var h;
+  if (window.innerWidth) {
+    w = window.innerWidth;
+    h = window.innerHeight;
+  } else if (document.documentElement) {
+    w = document.documentElement.clientWidth;
+    h = document.documentElement.clientHeight;
+  } else {
+    w = document.body.clientWidth;
+    h = document.body.clientHeight;
+  }
+  return {width: w, height: h};
 }