From 5c7f185600ee3c09f566cac373ffea1945529346 Mon Sep 17 00:00:00 2001 From: Christophe Verbinnen Date: Fri, 21 Jan 2011 11:59:41 +0100 Subject: [PATCH] some css --- css/jquery.tag.css | 5 +++++ js/jquery.tag.min.js | 2 +- source/jquery.tag.js | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/css/jquery.tag.css b/css/jquery.tag.css index 951414f..934159e 100644 --- a/css/jquery.tag.css +++ b/css/jquery.tag.css @@ -84,8 +84,13 @@ line-height:20px; } +.jTagLabels{ + padding:5px; +} + .jTagLabels label{ font-weight:bold; padding:5px; cursor:pointer; + float:left; } diff --git a/js/jquery.tag.min.js b/js/jquery.tag.min.js index 680f3c3..305ac56 100644 --- a/js/jquery.tag.min.js +++ b/js/jquery.tag.min.js @@ -1 +1 @@ -(function(a){a.extend(a.fn,{tag:function(b){var c={minWidth:100,minHeight:100,defaultWidth:100,defaultHeight:100,maxHeight:null,maxWidth:null,save:null,remove:null,canTag:true,canDelete:true,autoShowDrag:false,autoComplete:null,defaultTags:null,clickToTag:true,draggable:true,resizable:true,showTag:"hover",showLabels:true,debug:false};var b=a.extend(c,b);return this.each(function(){var d=a(this);d.data("options",b);a(window).load(function(){d.wrap('
');d.wrap('
');a("
").insertAfter(a(".jTagArea"));a('
').insertBefore(d);d.parent().css("backgroundImage","url("+d.attr("src")+")");d.parent().width(d.width());d.parent().height(d.height());d.parent().parent().width(d.width());d.parent().parent().height(d.height());d.hide();if(b.autoShowDrag){d.showDrag()}a(".jTagTag").live("mouseenter",function(){if(a(".jTagDrag").length==0){a(this).css("opacity",1);a(this).find("span").show();d.disableClickToTag()}});a(".jTagTag").live("mouseleave",function(){if(a(".jTagDrag").length==0){if(b.showTag=="hover"){a(this).css("opacity",0);a(this).find("span").hide()}d.enableClickToTag()}});if(b.showLabels&&b.showTag!="always"){a(".jTagLabels label").live("mouseenter",function(){a("#"+a(this).attr("rel")).css("opacity",1).find("span").show()});a(".jTagLabels label").live("mouseleave",function(){a("#"+a(this).attr("rel")).css("opacity",0).find("span").hide()})}if(b.canDelete){a(".jTagDeleteTag").live("click",function(){if(b.remove){b.remove(a(this).parent().parent().getId())}d.enableClickToTag();a(this).parent().parent().remove()})}if(b.defaultTags){a.each(b.defaultTags,function(e,f){d.addTag(f.width,f.height,f.top,f.left,f.label,f.id)})}d.enableClickToTag()})})},hideDrag:function(){obj=a(this);var b=obj.data("options");a(".jTagOverlay").removeClass("jTagPngOverlay");a(".jTagDrag").remove();if(b.showTag=="always"){a(".jTagTag").show()}obj.enableClickToTag()},showDrag:function(f){obj=a(this);obj.disableClickToTag();var c=obj.data("options");var b=function(){border=parseInt(a(".jTagDrag").css("borderTopWidth"));left_pos=parseInt(a(".jTagDrag").attr("offsetLeft"))+border;top_pos=parseInt(a(".jTagDrag").attr("offsetTop"))+border;return"-"+left_pos+"px -"+top_pos+"px"};if(a(".jTagDrag").length==1){return}if(!c.canTag){return}if(c.showTag=="always"){a(".jTagTag").hide()}a('
').appendTo(a(".jTagOverlay"));a(".jTagOverlay").addClass("jTagPngOverlay");a(".jTagDrag").css("backgroundImage","url("+obj.attr("src")+")");if(f){function d(e){var g=curtop=0;if(e.offsetParent){do{g+=e.offsetLeft;curtop+=e.offsetTop}while(e=e.offsetParent);return[g,curtop]}}pos=d(obj.parent()[0]);x=Math.max(0,f.pageX-pos[0]-(c.defaultWidth/2));y=Math.max(0,f.pageY-pos[1]-(c.defaultHeight/2));if(x+a(".jTagDrag").width()>obj.parent().width()){x=obj.parent().width()-a(".jTagDrag").width()-2}if(y+a(".jTagDrag").height()>obj.parent().height()){y=obj.parent().height()-a(".jTagDrag").height()-2}}else{x=0;y=0}a(".jTagDrag").css("top",y).css("left",x);if(c.autoComplete){a("#jTagLabel").autocomplete({source:c.autoComplete})}a(".jTagSaveBtn").click(function(){label=a("#jTagLabel").val();if(label==""){alert("The label cannot be empty");return}height=a(this).parent().parent().height();width=a(this).parent().parent().width();top_pos=a(this).parent().parent().attr("offsetTop");left=a(this).parent().parent().attr("offsetLeft");tagobj=obj.addTag(width,height,top_pos,left,label);if(c.save){c.save(width,height,top_pos,left,label,tagobj)}});a(".jTagSaveClose").click(function(){obj.hideDrag()});if(c.resizable){a(".jTagDrag").resizable({containment:obj.parent(),minWidth:c.minWidth,minHeight:c.minHeight,maxWidht:c.maxWidth,maxHeight:c.maxHeight,resize:function(){a(".jTagDrag").css({backgroundPosition:b()})},stop:function(){a(".jTagDrag").css({backgroundPosition:b()})}})}if(c.draggable){a(".jTagDrag").draggable({containment:obj.parent(),drag:function(){a(".jTagDrag").css({backgroundPosition:b()})},stop:function(){a(".jTagDrag").css({backgroundPosition:b()})}})}a(".jTagDrag").css({backgroundPosition:b()})},addTag:function(d,f,e,g,b,h){obj=a(this);var c=obj.data("options");tag=a('
'+b+"
").appendTo(a(".jTagOverlay"));if(h){tag.setId(h)}if(c.canDelete){obj.parent().find(".jTagDeleteTag").show()}if(c.showTag=="always"){a(".jTagTag").css("opacity",1)}if(c.showLabels){a("").appendTo(a(".jTagLabels"))}obj.hideDrag();return tag},setId:function(b){if(a(this).hasClass("jTagTag")){a(this).data("tagid",b)}else{alert("Wrong object")}},getId:function(b){if(a(this).hasClass("jTagTag")){return a(this).data("tagid")}else{alert("Wrong object")}},enableClickToTag:function(){obj=a(this);var b=obj.data("options");if(b.clickToTag){obj.parent().mousedown(function(c){obj.showDrag(c);obj.parent().unbind("mousedown")})}},disableClickToTag:function(){obj=a(this);var b=obj.data("options");if(b.clickToTag){obj.parent().unbind("mousedown")}}})})(jQuery); \ No newline at end of file +(function(a){a.extend(a.fn,{tag:function(b){var c={minWidth:100,minHeight:100,defaultWidth:100,defaultHeight:100,maxHeight:null,maxWidth:null,save:null,remove:null,canTag:true,canDelete:true,autoShowDrag:false,autoComplete:null,defaultTags:null,clickToTag:true,draggable:true,resizable:true,showTag:"hover",showLabels:true,debug:false};var b=a.extend(c,b);return this.each(function(){var d=a(this);d.data("options",b);a(window).load(function(){d.wrap('
');d.wrap('
');a("
").insertAfter(a(".jTagArea"));a('
').insertBefore(d);d.parent().css("backgroundImage","url("+d.attr("src")+")");d.parent().width(d.width());d.parent().height(d.height());d.parent().parent().width(d.width());d.hide();if(b.autoShowDrag){d.showDrag()}a(".jTagTag").live("mouseenter",function(){if(a(".jTagDrag").length==0){a(this).css("opacity",1);a(this).find("span").show();d.disableClickToTag()}});a(".jTagTag").live("mouseleave",function(){if(a(".jTagDrag").length==0){if(b.showTag=="hover"){a(this).css("opacity",0);a(this).find("span").hide()}d.enableClickToTag()}});if(b.showLabels&&b.showTag!="always"){a(".jTagLabels label").live("mouseenter",function(){a("#"+a(this).attr("rel")).css("opacity",1).find("span").show()});a(".jTagLabels label").live("mouseleave",function(){a("#"+a(this).attr("rel")).css("opacity",0).find("span").hide()})}if(b.canDelete){a(".jTagDeleteTag").live("click",function(){if(b.remove){b.remove(a(this).parent().parent().getId())}d.enableClickToTag();a(this).parent().parent().remove()})}if(b.defaultTags){a.each(b.defaultTags,function(e,f){d.addTag(f.width,f.height,f.top,f.left,f.label,f.id)})}d.enableClickToTag()})})},hideDrag:function(){obj=a(this);var b=obj.data("options");a(".jTagOverlay").removeClass("jTagPngOverlay");a(".jTagDrag").remove();if(b.showTag=="always"){a(".jTagTag").show()}obj.enableClickToTag()},showDrag:function(f){obj=a(this);obj.disableClickToTag();var c=obj.data("options");var b=function(){border=parseInt(a(".jTagDrag").css("borderTopWidth"));left_pos=parseInt(a(".jTagDrag").attr("offsetLeft"))+border;top_pos=parseInt(a(".jTagDrag").attr("offsetTop"))+border;return"-"+left_pos+"px -"+top_pos+"px"};if(a(".jTagDrag").length==1){return}if(!c.canTag){return}if(c.showTag=="always"){a(".jTagTag").hide()}a('
').appendTo(a(".jTagOverlay"));a(".jTagOverlay").addClass("jTagPngOverlay");a(".jTagDrag").css("backgroundImage","url("+obj.attr("src")+")");if(f){function d(e){var g=curtop=0;if(e.offsetParent){do{g+=e.offsetLeft;curtop+=e.offsetTop}while(e=e.offsetParent);return[g,curtop]}}pos=d(obj.parent()[0]);x=Math.max(0,f.pageX-pos[0]-(c.defaultWidth/2));y=Math.max(0,f.pageY-pos[1]-(c.defaultHeight/2));if(x+a(".jTagDrag").width()>obj.parent().width()){x=obj.parent().width()-a(".jTagDrag").width()-2}if(y+a(".jTagDrag").height()>obj.parent().height()){y=obj.parent().height()-a(".jTagDrag").height()-2}}else{x=0;y=0}a(".jTagDrag").css("top",y).css("left",x);if(c.autoComplete){a("#jTagLabel").autocomplete({source:c.autoComplete})}a(".jTagSaveBtn").click(function(){label=a("#jTagLabel").val();if(label==""){alert("The label cannot be empty");return}height=a(this).parent().parent().height();width=a(this).parent().parent().width();top_pos=a(this).parent().parent().attr("offsetTop");left=a(this).parent().parent().attr("offsetLeft");tagobj=obj.addTag(width,height,top_pos,left,label);if(c.save){c.save(width,height,top_pos,left,label,tagobj)}});a(".jTagSaveClose").click(function(){obj.hideDrag()});if(c.resizable){a(".jTagDrag").resizable({containment:obj.parent(),minWidth:c.minWidth,minHeight:c.minHeight,maxWidht:c.maxWidth,maxHeight:c.maxHeight,resize:function(){a(".jTagDrag").css({backgroundPosition:b()})},stop:function(){a(".jTagDrag").css({backgroundPosition:b()})}})}if(c.draggable){a(".jTagDrag").draggable({containment:obj.parent(),drag:function(){a(".jTagDrag").css({backgroundPosition:b()})},stop:function(){a(".jTagDrag").css({backgroundPosition:b()})}})}a(".jTagDrag").css({backgroundPosition:b()})},addTag:function(d,f,e,g,b,h){obj=a(this);var c=obj.data("options");tag=a('
'+b+"
").appendTo(a(".jTagOverlay"));if(h){tag.setId(h)}if(c.canDelete){obj.parent().find(".jTagDeleteTag").show()}if(c.showTag=="always"){a(".jTagTag").css("opacity",1)}if(c.showLabels){a("").appendTo(a(".jTagLabels"))}obj.hideDrag();return tag},setId:function(b){if(a(this).hasClass("jTagTag")){a(this).data("tagid",b)}else{alert("Wrong object")}},getId:function(b){if(a(this).hasClass("jTagTag")){return a(this).data("tagid")}else{alert("Wrong object")}},enableClickToTag:function(){obj=a(this);var b=obj.data("options");if(b.clickToTag){obj.parent().mousedown(function(c){obj.showDrag(c);obj.parent().unbind("mousedown")})}},disableClickToTag:function(){obj=a(this);var b=obj.data("options");if(b.clickToTag){obj.parent().unbind("mousedown")}}})})(jQuery); \ No newline at end of file diff --git a/source/jquery.tag.js b/source/jquery.tag.js index b8745ed..0e048b1 100644 --- a/source/jquery.tag.js +++ b/source/jquery.tag.js @@ -62,7 +62,6 @@ obj.parent().height(obj.height()); obj.parent().parent().width(obj.width()); - obj.parent().parent().height(obj.height()); obj.hide();