Jquery-based QQ online customer plug-in

Source: Internet
Author: User
[Javascript]/* this plug-in is based on Jquery */(function ($) {$. fn. sonlinefunction (options) {varopts $. extend ({}, $. fn. sonline. defualts, options); $. fn. setList (opts); // call the list to set if (opts. defa. [javascript]
/* This plug-in is based on Jquery */
(Function ($ ){
$. Fn. Sonline = function (options ){
Var opts = $. extend ({}, $. fn. Sonline. defualts, options );
$. Fn. setList (opts); // call list settings
If (opts. DefaultsOpen = false ){
$. Fn. Sonline. close (opts. Position, 0 );
} Www.2cto.com
$ ("# SonlineBox"). hover (function (){
// Expand
$. Fn. Sonline. open (opts. Position );
}, Function (){
// Close
$. Fn. Sonline. close (opts. Position, "fast ");
});
// Close the button
$ ("# SonlineBox>. contentBox>. closeTrigger "). live ("click", function () {$. fn. sonline. close (opts. position, "fast ");});
// Ie6 compatible or scrolling display
If ($. browser. msie & ($. browser. version = "6.0 ")&&! $. Support. style | opts. Effect = true) {$. fn. Sonline. scrollType ();}
Else if (opts. Effect = false) {$ ("# SonlineBox" ).css ({position: "fixed "});}
}
// Plugin defaults
$. Fn. Sonline. defualts = {
Position: "left", // left or right
Top: 200, // The distance from the Top. The default value is PX.
Effect: true, // scroll or fixed in two ways. boolean value: true or
DefaultsOpen: false, // expand by default: true, shrink by default: false
Qqlist: "" // use commas (,) to separate multiple QQ accounts. Use commas (,) to separate QQ accounts from customer service accounts (| ).
}

// Expand
$. Fn. Sonline. open = function (positionType ){
Var widthValue = $ ("# SonlineBox>. contentBox"). width ();
If (positionType = "left") {$ ("# SonlineBox>. contentBox"). animate ({left: 0}, "fast ");}
Else if (positionType = "right") {$ ("# SonlineBox>. contentBox"). animate ({right: 0}, "fast ");}
$ ("# SonlineBox" ).css ({width: widthValue + 4 });
$ ("# SonlineBox>. openTrigger"). hide ();
}
 
// Close
$. Fn. Sonline. close = function (positionType, speed ){
$ ("# SonlineBox>. openTrigger"). show ();
Var widthValue = $ ("# SonlineBox>. openTrigger"). width ();
Var allWidth = (-($ ("# SonlineBox>. contentBox"). width ()-6 );
If (positionType = "left") {$ ("# SonlineBox>. contentBox"). animate ({left: allWidth}, speed );}
Else if (positionType = "right") {$ ("# SonlineBox>. contentBox"). animate ({right: allWidth}, speed );}
$ ("# SonlineBox"). animate ({width: widthValue}, speed );

}
 
// Sub-plug-in: Set LIST Parameters
$. Fn. setList = function (opts ){
$ ("Body"). append ("Customer Service Center ");
If (opts. Qqlist = "") {$ ("# SonlineBox>. contentBox>. listBox"). append ("

No online customer service is available.

")}
Else {var qqListHtml = $. fn. Sonline. splitStr (opts); $ ("# SonlineBox>. contentBox>. listBox"). append (qqListHtml );}
If (opts. Position = "left") {$ ("# SonlineBox" ..css ({left: 0 });}
Else if (opts. Position = "right") {$ ("# SonlineBox" ).css ({right: 0 })}
$ ("# SonlineBox" ).css ({top: opts. Top });
Var allHeights = 0;
If ($ ("# SonlineBox>. contentBox"). height () <$ ("# SonlineBox>. openTrigger"). height ()){
AllHeights = $ ("# SonlineBox>. openTrigger"). height () + 4;
} Else {allHeights =$ ("# SonlineBox>. contentBox"). height () + 4 ;}
$ ("# SonlineBox"). height (allHeights );
If (opts. Position = "left") {$ ("# SonlineBox>. openTrigger" ).css ({left: 0 });}
Else if (opts. Position = "right") {$ ("# SonlineBox>. openTrigger" ).css ({right: 0 });}
}

// Sliding effect
$. Fn. Sonline. scrollType = function (){
$ ("# SonlineBox" ).css ({position: "absolute "});
Var topNum = parseInt ($ ("# SonlineBox" ).css ("top") + "");
$ (Window). scroll (function (){
Var scrollTopNum = $ (window). scrollTop (); // obtain the height of the page to be rolled
$ ("# SonlineBox"). stop (true, true). delay (0). animate ({top: scrollTopNum + topNum}, "slow ");
});
}

// Separate QQ
$. Fn. Sonline. splitStr = function (opts ){
Var strs = new Array (); // defines an Array
Var QqlistText = opts. Qqlist;
Strs = QqlistText. split (","); // delimiter
Var QqHtml = ""
For (var I = 0; I Var subStrs = new Array (); // defines an Array
Var subQqlist = strs [I];
SubStrs = subQqlist. split ("|"); // delimiter
QqHtml = QqHtml + "" + subStrs [1] + ":"
}
Return QqHtml;
}
}) (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.