Fixed some javascript bugs in Enano 1.1.6
authorDan
Thu, 23 Jul 2009 17:22:03 -0400
changeset 35 1dd30d7bf29f
parent 34 5e9bd8e5c6bf
child 36 60e80cd47b61
Fixed some javascript bugs in Enano 1.1.6
plugins/gallery/canvas.js
plugins/gallery/tagging.js
--- a/plugins/gallery/canvas.js	Tue May 05 19:08:45 2009 -0400
+++ b/plugins/gallery/canvas.js	Thu Jul 23 17:22:03 2009 -0400
@@ -4,8 +4,8 @@
 
 function canvas_click(obj)
 {
-  var click_x = mouseX - $(obj).Left();
-  var click_y = mouseY - $(obj).Top() + getScrollOffset();
+  var click_x = mouseX - $dynano(obj).Left();
+  var click_y = mouseY - $dynano(obj).Top() + getScrollOffset();
   
   if ( obj.canvas_in_draw )
   {
@@ -63,8 +63,8 @@
 {
   var inner_width = width - 2;
   var inner_height = height - 2;
-  var top = $(obj).Top() + y;
-  var left = $(obj).Left() + x;
+  var top = $dynano(obj).Top() + y;
+  var left = $dynano(obj).Left() + x;
   
   // draw outer box
   var div_outer = document.createElement('div');
@@ -102,17 +102,17 @@
 {
   if ( !obj.canvas_box_obj )
     return false;
-  var rel_x = mouseX - $(obj).Left();
-  var rel_y = mouseY - $(obj).Top() + getScrollOffset();
+  var rel_x = mouseX - $dynano(obj).Left();
+  var rel_y = mouseY - $dynano(obj).Top() + getScrollOffset();
   var new_width = rel_x - obj.canvas_box_obj.rootX;
   var new_height = rel_y - obj.canvas_box_obj.rootY;
   var rootX = obj.canvas_box_obj.rootX;
   var rootY = obj.canvas_box_obj.rootY;
   // Limit dimensions to width - origin_x and height - origin_y
-  if ( new_width + rootX > $(obj).Width() )
-    new_width = $(obj).Width() - rootX;
-  if ( new_height + rootY > $(obj).Height() )
-    new_height = $(obj).Height() - rootY;
+  if ( new_width + rootX > $dynano(obj).Width() )
+    new_width = $dynano(obj).Width() - rootX;
+  if ( new_height + rootY > $dynano(obj).Height() )
+    new_height = $dynano(obj).Height() - rootY;
   // If going to the top or left of the origin, avoid negative width/height by moving the box
   if ( new_width < 1 )
   {
@@ -147,10 +147,10 @@
   canvas_restore_mousemove();
   obj.canvas_in_draw = false;
   obj.canvas = {
-    top: $(obj.canvas_box_obj).Top() - $(obj).Top(),
-    left: $(obj.canvas_box_obj).Left() - $(obj).Left(),
-    width: $(obj.canvas_box_obj).Width(),
-    height: $(obj.canvas_box_obj).Height()
+    top: $dynano(obj.canvas_box_obj).Top() - $dynano(obj).Top(),
+    left: $dynano(obj.canvas_box_obj).Left() - $dynano(obj).Left(),
+    width: $dynano(obj.canvas_box_obj).Width(),
+    height: $dynano(obj.canvas_box_obj).Height()
   }
   obj.onclick = function(e)
   {
--- a/plugins/gallery/tagging.js	Tue May 05 19:08:45 2009 -0400
+++ b/plugins/gallery/tagging.js	Thu Jul 23 17:22:03 2009 -0400
@@ -12,8 +12,8 @@
 function snapr_process_canvas_add(obj, tag_data)
 {
   obj.onclick = null;
-  var abs_x = $(obj).Left() + obj.canvas.left;
-  var abs_y = $(obj).Top()  + obj.canvas.top;
+  var abs_x = $dynano(obj).Left() + obj.canvas.left;
+  var abs_y = $dynano(obj).Top()  + obj.canvas.top;
   var height = obj.canvas.height + 2;
   
   var entry_div = document.createElement('div');
@@ -38,7 +38,11 @@
   a_add.href = '#';
   a_add.onclick = function()
   {
-    snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, this.previousSibling.previousSibling.value);
+    var el = this.previousSibling;
+    while ( el.tagName != 'TEXTAREA' )
+      el = el.previousSibling;
+    
+    snapr_finalize_canvas_add(this.parentNode, this.parentNode.parentNode.canvas, el.value);
     return false;
   }
   a_add.appendChild(document.createTextNode('Add tag'));
@@ -173,8 +177,8 @@
       snapr_run_tag_editor(this);
     }
   }
-  var abs_x = $(newbox).Left();
-  var abs_y = $(newbox).Top() + $(newbox).Height() + 2;
+  var abs_x = $dynano(newbox).Left();
+  var abs_y = $dynano(newbox).Top() + $dynano(newbox).Height() + 2;
   var noteObj = document.createElement('div');
   newbox.noteObj = noteObj;
   noteObj.className = 'snapr_tag';
@@ -220,9 +224,9 @@
 function snapr_run_tag_editor(obj)
 {
   obj.onclick = null;
-  var abs_x = $(obj).Left();
-  var abs_y = $(obj).Top();
-  var height = $(obj).Height() + 2;
+  var abs_x = $dynano(obj).Left();
+  var abs_y = $dynano(obj).Top();
+  var height = $dynano(obj).Height() + 2;
   
   var value = obj.nextSibling.innerHTML;
   var regex = new RegExp('<br>', 'g');
@@ -307,7 +311,7 @@
   ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=edit_tag&tag=' + ajaxEscape(value) + '&canvas_params=' + ajaxEscape(canvas_json) + '&tag_id=' + note_id, snapr_process_ajax_tag_packet);
 }
 
-function snapr_process_ajax_tag_packet()
+function snapr_process_ajax_tag_packet(ajax)
 {
   if ( ajax.readyState == 4 && ajax.status == 200 )
   {