Jquery plug-in splitScren implements page split screen switching template special effect _ jquery

Source: Internet
Author: User
This article mainly introduces the jquery plug-in splitScren to implement the special effects of page split screen switching templates. For more information, see the following:

For the purpose of customizing the width and height, the screen blocks are controlled by CSS, and the effect of the equals modules is estimated by js control.

Program description:

HTML structure:

Header

Js call:

// Split-screen data var iframes = [{id: 'frames _ 1', frameName: 'Baidu Click', src :' http://www.baidu.com '}, {Id: 'frames _ 1', frameName: 'Baidu ', src :' http://map.baidu.com '}, {Id: 'frames _ 1', frameName: 'Baidu bottom', src :' http://www.baidu.com '}, {Id: 'frames _ 1', frameName: 'Baidu video', src :' http://v.baidu.com '}, {Id: 'frames _ 1', frameName: 'Baidu news 2', src :' http://news.baidu.com '}, {Id: 'frames _ 1', frameName: 'test6', src: '6.html'}, {id: 'frames _ 1', frameName: 'Baidu News ', src :' http://news.baidu.com '}, {Id: 'frames _ 1', frameName: '000000', src: '6.html'}, {id: 'frames _ 1', frameName: 'Baidu more', src :' http://www.baidu.com /More/'}]; // adaptive screen window. onload = function () {Panel. resize ();} window. onresize = function () {Panel. resize ();} // initialize the split screen var splitScreen = new splitScreen ($ ('# displayArea'), iframes); // listen to the removeSettingCls custom event splitScreen. _ on ('removesettingcls', function () {splitScreen. toggleTopbar (function () {$ ('. ulTab li [data-fp = "setting"] '). removeClass ('currentlil') ;}); // function changeModel (obj) {var for split-screen switching Fpmodel = $ (obj). attr ('data-FP'); if (fpmodel! = "Setting") {splitScreen. screenMode (fpmodel, function () {$ (obj ). addClass ('currentlil '). siblings (). removeClass ('currentli') ;});} else {splitScreen. toggleTopbar (function () {$ (obj ). toggleClass ('currentlil ');});}}

SplitScreen. js code description:

1. define a class

Var splitScreen = function (elem, options) {this. elem = elem; // the area element rendered by the split screen module. this. options = options; // Split-Screen link data this. initialize. apply (this); // initialize the split screen}

2. main prototype methods

SplitScreen. prototype = {initialize: function () {}, // initialization method screenMode: function () {}, // screen sharding method renderPanel: function (){}, // render the sub-screen DOM bindPanel: function () {}// event listener };

3. screenMode () method description:

It is mainly to switch different classes based on different split screens and control the split screen layout through CSS classes. the advantage of writing this should be that you can customize the width and height of the layout, but it is complicated. As follows:

Switch (Number (mode) {case 1: this. data = [['fp-1-1 ']; this. defaultShow = [0]; break; case 2: this. data = [['fp-2-1 '], ['fp-2-2']; this. defaultShow = [1, 2]; break; case 3: this. data = [['fp-3-1 '], ['fp-3-2', 'fp-3-3 ']; this. defaultShow = [1, 2, 3]; break; case 4: this. data = [['fp-4-1 ', 'fp-4-2'], ['fp-4-3 ', 'fp-4-4']; this. defaultShow = [4, 1, 2, 3]; break; case 5: this. data = [['fp-5-1 '], ['fp-5-2'], ['fp-5-3 ', 'fp-5-4', 'fp-5-5 ']; this. defaultShow = [4, 5, 1, 2, 3]; break; case 6: this. data = [['fp-6-1 '], ['fp-6-2', 'fp-6-3 '], ['fp-6-4', 'fp-6-5 ', 'fp-6-6 ']; this. defaultShow = [4, 5, 6, 7, 8, 8]; break; default: alert ("not supported" + mode + "split screen ");}

CSS layout control:

.fp-box{position:absolute;border:1px solid #000;background:#fff;}      .fp-1-1{top:0;left:0;right: 0;bottom: 0;}      .fp-2-1{top:0;left:0;right: 300px;bottom: 0;}      .fp-2-2{top:0;right: 0px;bottom: 0; width: 300px;}      .fp-3-1{top:0;left:0;right: 300px;bottom: 0;}      .fp-3-2{top:0;right: 0;width:300px;height:50%;}      .fp-3-3{top:50%;right: 0;bottom: 0;width:300px;}      .fp-4-1{top:0;left:0;right: 50%;height:50%;}      .fp-4-2{top:50%;left:0;right: 50%;bottom: 0;}      .fp-4-3{top:0;right: 0;width:50%;height:50%;}      .fp-4-4{top:50%;right: 0;bottom: 0;width:50%;}        .fp-5-1{top:0;left:0;right: 300px;bottom: 252px;}      .fp-5-2{top:0px;width:300px;right: 0;bottom: 252px;}      .fp-5-3{height: 250px;left:0;width:30%;bottom: 0;}      .fp-5-4{height: 250px;left:30%;width:30%;bottom: 0;}      .fp-5-5{height: 250px;left:60%;bottom: 0;right: 0;}      .fp-6-1{top:0;left:0;right: 300px;bottom: 252px;}      .fp-6-2{top:0;width:300px;right: 0;height:250px;}      .fp-6-3{top:250px;width:300px;right: 0;bottom: 252px;}      .fp-6-4{height: 250px;left:0;width:30%;bottom: 0;}      .fp-6-5{height: 250px;left:30%;width:30%;bottom: 0;}      .fp-6-6{height: 250px;left:60%;bottom: 0;right: 0;}

Complete code:

HTML:

  
   Fp version2          

Header

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.