diff --git a/xCAT-UI/js/jquery/hoverIntent.js b/xCAT-UI/js/jquery/hoverIntent.js deleted file mode 100644 index af7be848b..000000000 --- a/xCAT-UI/js/jquery/hoverIntent.js +++ /dev/null @@ -1,117 +0,0 @@ -(function($) { - /* hoverIntent by Brian Cherne */ - $.fn.hoverIntent = function(f, g) { - // default configuration options - var cfg = { - sensitivity : 7, - interval : 100, - timeout : 0 - }; - // override configuration options with user supplied object - cfg = $.extend(cfg, g ? { - over : f, - out : g - } : f); - - // instantiate variables - // cX, cY = current X and Y position of mouse, updated by mousemove - // event - // pX, pY = previous X and Y position of mouse, set by mouseover and - // polling interval - var cX, cY, pX, pY; - - // A private function for getting mouse position - var track = function(ev) { - cX = ev.pageX; - cY = ev.pageY; - }; - - // A private function for comparing current and previous mouse position - var compare = function(ev, ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - // compare mouse positions to see if they've crossed the threshold - if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { - $(ob).unbind("mousemove", track); - // set hoverIntent state to true (so mouseOut can be called) - ob.hoverIntent_s = 1; - return cfg.over.apply(ob, [ ev ]); - } else { - // set previous coordinates for next time - pX = cX; - pY = cY; - // use self-calling timeout, guarantees intervals are spaced out - // properly (avoids JavaScript timer bugs) - ob.hoverIntent_t = setTimeout(function() { - compare(ev, ob); - }, cfg.interval); - } - }; - - // A private function for delaying the mouseOut function - var delay = function(ev, ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - ob.hoverIntent_s = 0; - return cfg.out.apply(ob, [ ev ]); - }; - - // A private function for handling mouse 'hovering' - var handleHover = function(e) { - // next three lines copied from jQuery.hover, ignore children - // onMouseOver/onMouseOut - var p = (e.type == "mouseover" ? e.fromElement : e.toElement) - || e.relatedTarget; - while (p && p != this) { - try { - p = p.parentNode; - } catch (e) { - p = this; - } - } - if (p == this) { - return false; - } - - // copy objects to be passed into t (required for event object to be - // passed in IE) - var ev = jQuery.extend( {}, e); - var ob = this; - - // cancel hoverIntent timer if it exists - if (ob.hoverIntent_t) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - } - - // else e.type == "onmouseover" - if (e.type == "mouseover") { - // set "previous" X and Y position based on initial entry point - pX = ev.pageX; - pY = ev.pageY; - // update "current" X and Y position based on mousemove - $(ob).bind("mousemove", track); - // start polling interval (self-calling timeout) to compare - // mouse coordinates over time - if (ob.hoverIntent_s != 1) { - ob.hoverIntent_t = setTimeout(function() { - compare(ev, ob); - }, cfg.interval); - } - - // else e.type == "onmouseout" - } else { - // unbind expensive mousemove event - $(ob).unbind("mousemove", track); - // if hoverIntent state is true, then call the mouseOut function - // after the specified delay - if (ob.hoverIntent_s == 1) { - ob.hoverIntent_t = setTimeout(function() { - delay(ev, ob); - }, cfg.timeout); - } - } - }; - - // bind the function to the two event listeners - return this.mouseover(handleHover).mouseout(handleHover); - }; - -})(jQuery); \ No newline at end of file diff --git a/xCAT-UI/js/jquery/hoverIntent.min.js b/xCAT-UI/js/jquery/hoverIntent.min.js new file mode 100644 index 000000000..3e1b6ae9e --- /dev/null +++ b/xCAT-UI/js/jquery/hoverIntent.min.js @@ -0,0 +1,3 @@ +(function(e){e.fn.hoverIntent=function(l,m){var d={sensitivity:7,interval:100,timeout:0};d=e.extend(d,m?{over:l,out:m}:l);var g,h,i,j,k=function(c){g=c.pageX;h=c.pageY},n=function(c,a){a.hoverIntent_t=clearTimeout(a.hoverIntent_t);if(Math.abs(i-g)+Math.abs(j-h)'); - }, - - // Accept an Array representing a menu structure and turn it into HTML - createMenu : function(menu, cmenu) { - var className = cmenu.className; - $.each(cmenu.theme.split(","), function(i, n) { - className += ' ' + cmenu.themePrefix + n - }); - var $t = $('
') - .click(function() { - cmenu.hide(); - return false; - }); // We wrap a table around it so width can be flexible - var $tr = $(''); - var $td = $(''); - var $div = $('
'); - - // Each menu item is specified as either: - // title:function - // or title: { property:value ... } - for ( var i = 0; i < menu.length; i++) { - var m = menu[i]; - if (m == $.contextMenu.separator) { - $div.append(cmenu.createSeparator()); - } else { - for ( var opt in menu[i]) { - $div.append(cmenu.createMenuItem(opt, menu[i][opt])); // Extracted - // to - // method - // for - // extensibility - } - } - } - if (cmenu.useIframe) { - $td.append(cmenu.createIframe()); - } - $t.append($tr.append($td.append($div))) - return $t; - }, - - // Create an individual menu item - createMenuItem : function(label, obj) { - var cmenu = this; - if (typeof obj == "function") { - obj = { - onclick : obj - }; - } // If passed a simple function, turn it into a property of an object - // Default properties, extended in case properties are passed - var o = $.extend( { - onclick : function() { - }, - className : '', - hoverClassName : cmenu.itemHoverClassName, - icon : '', - disabled : false, - title : '', - hoverItem : cmenu.hoverItem, - hoverItemOut : cmenu.hoverItemOut - }, obj); - // If an icon is specified, hard-code the background-image style. - // Themes that don't show images should take this into account in - // their CSS - var iconStyle = (o.icon) ? 'background-image:url(' + o.icon + ');' : ''; - var $div = $('
') - // If the item is disabled, don't do anything when it is clicked - .click(function(e) { - if (cmenu.isItemDisabled(this)) { - return false; - } else { - return o.onclick.call(cmenu.target, this, cmenu, e) - } - }) - // Change the class of the item when hovered over - .hover(function() { - o.hoverItem - .call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName); - }, function() { - o.hoverItemOut - .call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName); - }); - var $idiv = $('
' + label + '
'); - $div.append($idiv); - return $div; - }, - - // Create a separator row - createSeparator : function() { - return $('
'); - }, - - // Determine if an individual item is currently disabled. This is called each time the item is hovered or - // clicked because the disabled status may change at any time - isItemDisabled : function(item) { - return $(item).is('.' + this.disabledItemClassName); - }, - - // Functions to fire on hover. Extracted to methods for extensibility - hoverItem : function(c) { - $(this).addClass(c); - }, - hoverItemOut : function(c) { - $(this).removeClass(c); - }, - - // Create the shadow object - createShadow : function(cmenu) { - cmenu.shadowObj = $('
') - .css( { - display : 'none', - position : "absolute", - zIndex : 9998, - opacity : cmenu.shadowOpacity, - backgroundColor : cmenu.shadowColor - }); - $(cmenu.appendTo).append(cmenu.shadowObj); - }, - - // Display the shadow object, given the position of the menu itself - showShadow : function(x, y, e) { - var cmenu = this; - if (cmenu.shadow) { - cmenu.shadowObj.css( { - width : (cmenu.menu.width() + cmenu.shadowWidthAdjust) + - "px", - height : (cmenu.menu.height() + cmenu.shadowHeightAdjust) + - "px", - top : (y + cmenu.shadowOffsetY) + "px", - left : (x + cmenu.shadowOffsetX) + "px" - }).addClass(cmenu.shadowClass)[cmenu.showTransition] - (cmenu.showSpeed); - } - }, - - // A hook to call before the menu is shown, in case special processing needs to be done. - // Return false to cancel the default show operation - beforeShow : function() { - return true; - }, - - // Show the context menu - show : function(t, e) { - var cmenu = this, x = e.pageX, y = e.pageY; - cmenu.target = t; // Preserve the object that triggered this - // context menu so menu item click methods can - // see it - if (cmenu.beforeShow() !== false) { - // If the menu content is a function, call it to populate the menu each time it is displayed - if (cmenu.menuFunction) { - if (cmenu.menu) { - $(cmenu.menu).remove(); - } - cmenu.menu = cmenu - .createMenu(cmenu.menuFunction(cmenu, t), cmenu); - cmenu.menu.css( { - display : 'none' - }); - $(cmenu.appendTo).append(cmenu.menu); - } - var $c = cmenu.menu; - x += cmenu.offsetX; - y += cmenu.offsetY; - var pos = cmenu.getPosition(x, y, cmenu, e); // Extracted to - // method for - // extensibility - cmenu.showShadow(pos.x, pos.y, e); - // Resize the iframe if needed - if (cmenu.useIframe) { - $c.find('iframe').css( { - width : $c.width() + cmenu.shadowOffsetX + - cmenu.shadowWidthAdjust, - height : $c.height() + cmenu.shadowOffsetY + - cmenu.shadowHeightAdjust - }); - } - $c.css( { - top : pos.y + "px", - left : pos.x + "px", - position : "absolute", - zIndex : 9999 - })[cmenu.showTransition] - (cmenu.showSpeed, ((cmenu.showCallback) ? function() { - cmenu.showCallback.call(cmenu); - } : null)); - cmenu.shown = true; - $(document).one('click', null, function() { - cmenu.hide() - }); // Handle a single click to the document to hide the menu - } - }, - - // Find the position where the menu should appear, given an x,y of the click event - getPosition : function(clickX, clickY, cmenu, e) { - var x = clickX + cmenu.offsetX; - var y = clickY + cmenu.offsetY - var h = $(cmenu.menu).height(); - var w = $(cmenu.menu).width(); - var dir = cmenu.direction; - if (cmenu.constrainToScreen) { - var $w = $(window); - var wh = $w.height(); - var ww = $w.width(); - if (dir == "down" && (y + h - $w.scrollTop() > wh)) { - dir = "up"; - } - var maxRight = x + w - $w.scrollLeft(); - if (maxRight > ww) { - x -= (maxRight - ww); - } - } - if (dir == "up") { - y -= h; - } - return { - 'x' : x, 'y' : y - }; - }, - - // Hide the menu, of course - hide : function() { - var cmenu = this; - if (cmenu.shown) { - if (cmenu.iframe) { - $(cmenu.iframe).hide(); - } - if (cmenu.menu) { - cmenu.menu[cmenu.hideTransition] - (cmenu.hideSpeed, ((cmenu.hideCallback) ? function() { - cmenu.hideCallback.call(cmenu); - } : null)); - } - if (cmenu.shadow) { - cmenu.shadowObj[cmenu.hideTransition](cmenu.hideSpeed); - } - } - cmenu.shown = false; - } - }; - - // This actually adds the .contextMenu() function to the jQuery namespace - $.fn.contextMenu = function(menu, options) { - var cmenu = $.contextMenu.create(menu, options); - return this.each(function() { - // Show menu on left click - $(this).bind('click', function(e) { - cmenu.show(this, e); - return false; - }); - }); - }; -})(jQuery); diff --git a/xCAT-UI/js/jquery/jquery.contextmenu.min.js b/xCAT-UI/js/jquery/jquery.contextmenu.min.js new file mode 100644 index 000000000..f23f836f1 --- /dev/null +++ b/xCAT-UI/js/jquery/jquery.contextmenu.min.js @@ -0,0 +1,22 @@ +/* + Copyright (c)2005-2009 Matt Kruse (javascripttoolbox.com) + + Dual licensed under the MIT and GPL licenses. + This basically means you can use this code however you want for + free, but don't claim to have written it yourself! + Donations always accepted: http://www.JavascriptToolbox.com/donate/ + + Please do not link to the .js files on javascripttoolbox.com from + your site. Copy the files locally to your server instead. + +*/ +(function(c){c.contextMenu={shadow:true,shadowOffset:0,shadowOffsetX:5,shadowOffsetY:5,shadowWidthAdjust:-3,shadowHeightAdjust:-3,shadowOpacity:0.2,shadowClass:"context-menu-shadow",shadowColor:"black",offsetX:0,offsetY:0,appendTo:"body",direction:"down",constrainToScreen:true,showTransition:"show",hideTransition:"hide",showSpeed:null,hideSpeed:null,showCallback:null,hideCallback:null,className:"context-menu",itemClassName:"context-menu-item",itemHoverClassName:"context-menu-item-hover",disabledItemClassName:"context-menu-item-disabled", +disabledItemHoverClassName:"context-menu-item-disabled-hover",separatorClassName:"context-menu-separator",innerDivClassName:"context-menu-item-inner",themePrefix:"context-menu-theme-",theme:"default",separator:"context-menu-separator",target:null,menu:null,shadowObj:null,bgiframe:null,shown:false,useIframe:false,create:function(b,d){var a=c.extend({},this,d);if(typeof b=="string")a.menu=c(b);else if(typeof b=="function")a.menuFunction=b;else a.menu=a.createMenu(b,a);if(a.menu){a.menu.css({display:"none"}); +c(a.appendTo).append(a.menu)}if(a.shadow){a.createShadow(a);if(a.shadowOffset)a.shadowOffsetX=a.shadowOffsetY=a.shadowOffset}c("body").bind("contextmenu",function(){a.hide()});return a},createIframe:function(){return c('