forked from paulkinzett/toolbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.toolbar.min.js
5 lines (5 loc) · 7.6 KB
/
jquery.toolbar.min.js
1
2
3
4
5
<<<<<<< HEAD
if(typeof Object.create!=="function"){Object.create=function(b){function a(){}a.prototype=b;return new a()}}(function(d,c,b,e){var a={init:function(g,h){var f=this;f.elem=h;f.$elem=d(h);f.options=d.extend({},d.fn.toolbar.options,g);f.toolbar=d('<div class="tool-container gradient" />').addClass("tool-"+f.options.position).addClass("tool-rounded").append('<div class="tool-items" />').append('<div class="arrow" />').appendTo("body").css("opacity",0).hide();f.initializeToolbar()},initializeToolbar:function(){var f=this;f.populateContent();f.setTrigger();f.toolbarWidth=f.toolbar.width()},setTrigger:function(){var f=this;f.$elem.on("click",function(g){g.preventDefault();if(f.$elem.hasClass("pressed")){f.hide()}else{f.show()}});if(f.options.hideOnClick){d("html").on("click.toolbar",function(g){if(g.target!=f.elem&&f.$elem.has(g.target).length===0&&f.toolbar.has(g.target).length===0&&f.toolbar.is(":visible")){f.hide()}})}d(c).resize(function(g){g.stopPropagation();if(f.toolbar.is(":visible")){f.toolbarCss=f.getCoordinates(f.options.position,20);f.collistionDetection();f.toolbar.css(f.toolbarCss);f.toolbar.find(".arrow").css(f.arrowCss)}})},populateContent:function(){var g=this;var f=g.toolbar.find(".tool-items");var h=d(g.options.content).clone(true).find("a").addClass("tool-item gradient");f.html(h);f.find(".tool-item").on("click",function(i){i.preventDefault();g.$elem.trigger("toolbarItemClick",this)})},calculatePosition:function(){var f=this;f.arrowCss={};f.toolbarCss=f.getCoordinates(f.options.position,0);f.toolbarCss.position="absolute";f.toolbarCss.zIndex=f.options.zIndex;f.collistionDetection();f.toolbar.css(f.toolbarCss);f.toolbar.find(".arrow").css(f.arrowCss)},getCoordinates:function(f,h){var g=this;g.coordinates=g.$elem.offset();switch(g.options.position){case"top":return{left:g.coordinates.left-(g.toolbar.width()/2)+(g.$elem.width()/2),top:g.coordinates.top-g.$elem.height()-h,right:"auto"};case"left":return{left:g.coordinates.left-(g.toolbar.width()/2)-(g.$elem.width()/2)-h,top:g.coordinates.top-(g.toolbar.height()/2)+(g.$elem.height()/2),right:"auto"};case"right":return{left:g.coordinates.left+(g.toolbar.width()/2)+(g.$elem.width()/3)+h,top:g.coordinates.top-(g.toolbar.height()/2)+(g.$elem.height()/2),right:"auto"};case"bottom":return{left:g.coordinates.left-(g.toolbar.width()/2)+(g.$elem.width()/2),top:g.coordinates.top+g.$elem.height()+h,right:"auto"}}},collistionDetection:function(){var f=this;var g=20;if(f.options.position=="top"||f.options.position=="bottom"){f.arrowCss={left:"50%",right:"50%"};if(f.toolbarCss.left<g){f.toolbarCss.left=g;f.arrowCss.left=f.$elem.offset().left+f.$elem.width()/2-(g)}else{if((d(c).width()-(f.toolbarCss.left+f.toolbarWidth))<g){f.toolbarCss.right=g;f.toolbarCss.left="auto";f.arrowCss.left="auto";f.arrowCss.right=(d(c).width()-f.$elem.offset().left)-(f.$elem.width()/2)-(g)-5}}}},show:function(){var f=this;var g={opacity:1};f.$elem.addClass("pressed");f.calculatePosition();switch(f.options.position){case"top":g.top="-=20";break;case"left":g.left="-=20";break;case"right":g.left="+=20";break;case"bottom":g.top="+=20";break}f.toolbar.show().animate(g,200);f.$elem.trigger("toolbarShown")},hide:function(){var f=this;var g={opacity:0};f.$elem.removeClass("pressed");switch(f.options.position){case"top":g.top="+=20";break;case"left":g.left="+=20";break;case"right":g.left="-=20";break;case"bottom":g.top="-=20";break}f.toolbar.animate(g,200,function(){f.toolbar.hide()});f.$elem.trigger("toolbarHidden")}};d.fn.toolbar=function(f){return this.each(function(){var g=Object.create(a);g.init(f,this)})};d.fn.toolbar.options={content:"#myContent",position:"top",hideOnClick:false,zIndex:120}})(jQuery,window,document);
=======
if(typeof Object.create!=="function"){Object.create=function(b){function a(){}a.prototype=b;return new a()}}(function(d,c,b,e){var a={init:function(g,h){var f=this;f.elem=h;f.$elem=d(h);f.options=d.extend({},d.fn.toolbar.options,g);f.toolbar=d('<div class="tool-container gradient" />').addClass("tool-"+f.options.position).addClass("tool-rounded").append('<div class="tool-items" />').append('<div class="arrow" />').appendTo("body").css("opacity",0).hide();f.toolbar_arrow=f.toolbar.find(".arrow");f.initializeToolbar()},initializeToolbar:function(){var f=this;f.populateContent();f.setTrigger();f.toolbarWidth=f.toolbar.width()},setTrigger:function(){var f=this;f.$elem.on("click",function(g){g.preventDefault();g.stopPropagation();if(f.$elem.hasClass("pressed")){f.hide()}else{f.show()}});d(c).resize(function(g){g.stopPropagation();if(f.toolbar.is(":visible")){f.toolbarCss=f.getCoordinates(f.options.position,20);f.collistionDetection();f.toolbar.css(f.toolbarCss);f.toolbar_arrow.css(f.arrowCss)}})},populateContent:function(){var g=this;var f=g.toolbar.find(".tool-items");var h=d(g.options.content).clone(true).find("a").addClass("tool-item gradient");f.html(h);f.find(".tool-item").on("click",function(i){i.preventDefault();g.$elem.trigger("toolbarItemClick",this)})},calculatePosition:function(){var f=this;f.arrowCss={};f.toolbarCss=f.getCoordinates(f.options.position,0);f.toolbarCss.position="absolute";f.toolbarCss.zIndex=f.options.zIndex;f.collistionDetection();f.toolbar.css(f.toolbarCss);f.toolbar_arrow.css(f.arrowCss)},getCoordinates:function(f,h){var g=this;g.coordinates=g.$elem.offset();switch(g.options.position){case"top":return{left:g.coordinates.left-(g.toolbar.width()/2)+(g.$elem.width()/2),top:g.coordinates.top-g.$elem.height()-h,right:"auto"};case"left":return{left:g.coordinates.left-(g.toolbar.width()/2)-(g.$elem.width()/2)-h,top:g.coordinates.top-(g.toolbar.height()/2)+(g.$elem.height()/2),right:"auto"};case"right":return{left:g.coordinates.left+(g.toolbar.width()/2)+(g.$elem.width()/3)+h,top:g.coordinates.top-(g.toolbar.height()/2)+(g.$elem.height()/2),right:"auto"};case"bottom":return{left:g.coordinates.left-(g.toolbar.width()/2)+(g.$elem.width()/2),top:g.coordinates.top+g.$elem.height()+h,right:"auto"}}},collistionDetection:function(){var f=this;var g=20;if(f.options.position=="top"||f.options.position=="bottom"){f.arrowCss={left:"50%",right:"50%"};if(f.toolbarCss.left<g){f.toolbarCss.left=g;f.arrowCss.left=f.$elem.offset().left+f.$elem.width()/2-(g)}else{if((d(c).width()-(f.toolbarCss.left+f.toolbarWidth))<g){f.toolbarCss.right=g;f.toolbarCss.left="auto";f.arrowCss.left="auto";f.arrowCss.right=(d(c).width()-f.$elem.offset().left)-(f.$elem.width()/2)-(g)-5}}}},show:function(){var f=this;var g={opacity:1};f.$elem.addClass("pressed");f.calculatePosition();switch(f.options.position){case"top":g.top="-=20";break;case"left":g.left="-=20";break;case"right":g.left="+=20";break;case"bottom":g.top="+=20";break}f.bindHideEvent();f.toolbar.show().animate(g,200);f.$elem.trigger("toolbarShown")},bindHideEvent:function(){var f=this;var g="click.toolbar";if(f.options.hideOnClick){d("html").off(g).on(g,function(h){if(f.toolbar.has(h.target).length===0){f.hide()}})}},hide:function(){var f=this;var g={opacity:0};f.$elem.removeClass("pressed");switch(f.options.position){case"top":g.top="+=20";break;case"left":g.left="+=20";break;case"right":g.left="-=20";break;case"bottom":g.top="-=20";break}f.toolbar.animate(g,200,function(){f.toolbar.hide()});f.$elem.trigger("toolbarHidden")},getToolbarElement:function(){return this.toolbar.find(".tool-items")}};d.fn.toolbar=function(g){if(d.isPlainObject(g)){return this.each(function(){var i=Object.create(a);i.init(g,this);d(this).data("toolbarObj",i)})}else{if(typeof g==="string"&&g.indexOf("_")!==0){var f=d(this).data("toolbarObj");var h=f[g];return h.apply(f,d.makeArray(arguments).slice(1))}}};d.fn.toolbar.options={content:"#myContent",position:"top",hideOnClick:false,zIndex:120}})(jQuery,window,document);
>>>>>>> cf58621a7d945afcbf7bd64d90d3597338c35499