Ui. Core. js (not modified)

Source: Internet
Author: User

/*
* Jquery UI 1.5.3
*
* Copyright (c) 2008 Paul bakaus (ui.jquery.com)
* Dual licensed under the MIT (mit-license.txt)
* And GPL (gpl-license.txt) licenses.
*
* Http://docs.jquery.com/UI
*/
; (Function ($ ){

$. UI = {
Plugin :{
Add: function (module, option, set ){
VaR proto = $. UI [module]. Prototype;
For (var I in set ){
Proto. plugins [I] = Proto. plugins [I] | [];
Proto. plugins [I]. Push ([option, set [I]);
}
},
Call: function (instance, name, argS ){
VaR set = instance. plugins [name];
If (! Set) {return ;}
For (VAR I = 0; I <set. length; I ++ ){
If (instance. Options [set [I] [0]) {
Set [I] [1]. Apply (instance. element, argS );
}
}
}
},
Csscache :{},
CSS: function (name ){
If ().ui.css cache [name]) {return 2.16.ui.css cache [name];}
VaR TMP = $ ('<Div class = "UI-gen"> 'salary .addclass(name).css ({position: 'absolute', top: '-5000px', left: '-5000px ', display: 'block '}). appendto ('body ');
// If (! $. Browser. Safari)
// TMP. appendto ('body ');
// Opera and Safari Set width and height to 0px instead of auto
// Safari returns rgba (0, 0, 0) When bgcolor is not set
.Ui.css cache [name] = !! (
(! (/Auto | default/cmd.test(tmp.css ('cursor ') | (/^ [1-9]/cmd.test(tmp.css ('height ')) | (/^ [1-9]/pai.test(tmp.css ('width') |
! (/NONE/pai.test(tmp.css ('backgroundage') |! (/Transparent | rgba \ (0, 0, 0, 0 \)/pai.test(tmp.css ('backgroundcolor ')))
);
Try {$ ('body'). Get (0). removechild (TMP. Get (0);} catch (e ){}
Return response .ui.css cache [name];
},
Disableselection: function (EL ){
$ (EL). ATTR ('unselectable', 'on' example .css ('your userselect', 'None ');
},
Enableselection: function (EL ){
$ (EL). ATTR ('unselectable', 'off'example .css ('your userselect ','');
},
Hasscroll: function (E, ){
VaR scroll =/top/. Test (A | "TOP ")? 'Rolltop': 'rollleft', has = false;
If (E [scroll]> 0) return true; E [scroll] = 1;
Has = E [scroll]> 0? True: false; E [scroll] = 0;
Return has;
}
};

/** Jquery core modifications and additions **/

VaR _ remove = $. FN. Remove;
$. FN. Remove = function (){
$ ("*", This). Add (this). triggerhandler ("Remove ");
Return _ remove. Apply (this, arguments );
};

// $. Widget is a factory to create jquery plugins
// Taking some boilerplate code out of the plugin code
// Created by Scott Gonz lez and J rn zaefferer
Function getter (namespace, plugin, method ){
VaR methods = $ [namespace] [plugin]. getter | [];
Methods = (typeof methods = "string "? Methods. Split (/,? \ S +/): methods );
Return ($. inarray (method, methods )! =-1 );
}

$. Widget = function (name, prototype ){
VaR namespace = Name. Split (".") [0];
Name = Name. Split (".") [1];
// Create plugin Method
$. FN [name] = function (options ){
VaR ismethodcall = (typeof Options = 'string '),
ARGs = array. Prototype. Slice. Call (arguments, 1 );
If (ismethodcall & getter (namespace, name, options )){
VaR instance = $. Data (this [0], name );
Return (instance? Instance [Options]. Apply (instance, argS)
: Undefined );
}
Return this. Each (function (){
VaR instance = $. Data (this, name );
If (ismethodcall & instance & $. isfunction (instance [Options]) {
Instance [Options]. Apply (instance, argS );
} Else if (! Ismethodcall ){
$. Data (this, name, new $ [namespace] [name] (This, options ));
}
});
};
// Create widget Constructor
$ [Namespace] [name] = function (element, options ){
VaR self = this;
This. widgetname = Name;
This. widgetbaseclass = namespace + '-' + name;
This. Options = $. Extend ({}, $. widget. defaults, $ [namespace] [name]. defaults, options );
This. Element = $ (element)
. BIND ('setdata. '+ name, function (E, key, value ){
Return self. setdata (Key, value );
})
. BIND ('getdata. '+ name, function (E, key ){
Return self. getdata (key );
})
. BIND ('delete', function (){
Return self. Destroy ();
});
This. INIT ();
};
// Add widget prototype
$ [Namespace] [name]. Prototype = $. Extend ({}, $. widget. prototype, prototype );
};

$. Widget. Prototype = {
Init: function (){},
Destroy: function (){
This. element. removedata (this. widgetname );
},
Getdata: function (key ){
Return this. Options [Key];
},
Setdata: function (Key, value ){
This. Options [Key] = value;
If (Key = 'Disabled '){
This. Element [value? 'Addclass': 'removeclass '] (
This. widgetbaseclass + '-disabled ');
}
},
Enable: function (){
This. setdata ('Disabled ', false );
},
Disable: function (){
This. setdata ('Disabled ', true );
}
};

$. Widget. defaults = {
Disabled: false
};

/** Mouse interaction plugin **/

$. UI. Mouse = {
Mouseinit: function (){
VaR self = this;
This. element. BIND ('mousedown. '+ this. widgetname, function (e ){
Return self. mousedown (E );
});
// Prevent Text Selection in IE
If ($. browser. MSIE ){
This. _ mouseunselectable = This. element. ATTR ('unselectable ');
This. element. ATTR ('unselectable', 'on ');
}
This. Started = false;
},
// Todo: Make sure destroying one instance of mouse doesn't mess
// Other instances of Mouse
Mousedestroy: function (){
This. element. Unbind ('.' + this. widgetname );
// Restore Text Selection in IE
($. Browser. MSIE
& This. element. ATTR ('unselectable', this. _ mouseunselectable ));
},
Mousedown: function (e ){
// We may have missed mouseup (out of window)
(This. _ mousestarted & this. mouseup (e ));
This. _ mousedownevent = E;
VaR self = This,
Btnisleft = (E. Which = 1 ),
Eliscancel = (typeof this. Options. Cancel = "string "? Certificate (e.target).parents().add(e.tar get). Filter (this. Options. Cancel). Length: false );
If (! Btnisleft | eliscancel |! This. mousecapture (E )){
Return true;
}
This. _ mousedelaymet =! This. Options. delay;
If (! This. _ mousedelaymet ){
This. _ mousedelaytimer = setTimeout (function (){
Self. _ mousedelaymet = true;
}, This. Options. Delay );
}
If (this. mousedistancemet (e) & this. mousedelaymet (E )){
This. _ mousestarted = (this. mousestart (e )! = False );
If (! This. _ mousestarted ){
E. preventdefault ();
Return true;
}
}
// These delegates are required to keep Context
This. _ mousemovedelegate = function (e ){
Return self. mousemove (E );
};
This. _ mouseupdelegate = function (e ){
Return self. mouseup (E );
};
$ (Document)
. BIND ('mousemove. '+ this. widgetname, this. _ mousemovedelegate)
. BIND ('mouseup. '+ this. widgetname, this. _ mouseupdelegate );
Return false;
},
Mousemove: function (e ){
// Ie mouseup check-mouseup happened when mouse was out of window
If ($. browser. MSIE &&! E. Button ){
Return this. mouseup (E );
}
If (this. _ mousestarted ){
This. mousedrag (E );
Return false;
}
If (this. mousedistancemet (e) & this. mousedelaymet (E )){
This. _ mousestarted =
(This. mousestart (this. _ mousedownevent, e )! = False );
(This. _ mousestarted? This. mousedrag (e): This. mouseup (e ));
}
Return! This. _ mousestarted;
},
Mouseup: function (e ){
$ (Document)
. Unbind ('mousemove. '+ this. widgetname, this. _ mousemovedelegate)
. Unbind ('mouseup. '+ this. widgetname, this. _ mouseupdelegate );
If (this. _ mousestarted ){
This. _ mousestarted = false;
This. mousestop (E );
}
Return false;
},
Mousedistancemet: function (e ){
Return (math. Max (
Math. Abs (this. _ mousedownevent. pagex-E. pagex ),
Math. Abs (this. _ mousedownevent. Pagey-E. Pagey)
)> = This. Options. Distance
);
},
Mousedelaymet: function (e ){
Return this. _ mousedelaymet;
},
// These are placeholder methods, to be overriden by extending plugin
Mousestart: function (e ){},
Mousedrag: function (e ){},
Mousestop: function (e ){},
Mousecapture: function (e) {return true ;}
};

$. UI. Mouse. defaults = {
Cancel: NULL,
Distance: 1,
Delay: 0
};

}) (Jquery );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.