Cross-border easyui window (window) -- limits the range of easyui window activity and window easyui

Source: Internet
Author: User

Cross-border easyui window (window) -- limits the range of easyui window activity and window easyui

A problem occurs when easyui window is used. If the window is dragged or changed by hours, it cannot be returned if the window is out of the browser range.

Because the browser does not display the scroll bar. You need to refresh the page again.

So I wrote a method to limit the activity range of the form (only visible in the browser ):


<Div id = "createSchoolWindow" class = "easyui-window" title = "New School"
Data-options = "modal: true, closed: true, minimizable: false, iconCls: 'icon-add '"
Style = "width: 530px; height: pixel PX; padding: 10px;">
<Form id = "createSchoolForm" method = "post">
<Table>
<Tr>
<Td> school name: </td>
<Td> <input class = "easyui-validatebox" type = "text" name = "name" data-options = "required: true"> </input> </td>
<Td> School website: </td>
<Td> <input class = "easyui-validatebox" type = "text" name = "webSite" data-options = "validType: 'url' "/> </input> </td>
</Tr>
<Tr>
<Td> contact name: </td>
<Td> <input class = "easyui-validatebox" type = "text" name = "linkman"> </input> </td>
<Td> contact number: </td>
<Td> <input class = "easyui-validatebox" type = "text" name = "linkmanPhone"> </input> </td>
</Tr>
<Tr>
<Td> school address: </td>
<Td colspan = "3"> <textarea rows = "4" cols = "25" name = "addr"> </textarea> </td>
</Tr>
<Tr>
<Td> Note: </td>
<Td colspan = "3">
<Textarea rows = "4" cols = "25" name = "remark"> </textarea>
</Td>
</Tr>
<Tr>
<Td colspan = "4" align = "center">
<A href = "#" class = "easyui-linkbutton" onclick = "createSchool ();" icon = "icon-save"> save </a>
<A href = "#" class = "easyui-linkbutton" onclick = "closeCreateSchoolWindow ();" icon = "icon-cancel"> close </a>
</Td>
</Tr>
</Table>
</Form>
</Div>


/*

The principle is very simple: register the onMove and onResize events, and automatically reply when the event is out of bounds:

*/

$ (Document). ready (function (){


$ ("# CreateSchoolWindow"). window ({
OnMove: function (left, top ){
// Console. log (this. left + "-" + top );
If (left <0 ){
$ ("# CreateSchoolWindow"). window ("resize", {left: 0 });
}
If (top <0 ){
$ ("# CreateSchoolWindow"). window ("resize", {top: 0 });
}
},
OnResize: function (width, height ){
Var w = $ (window). width (); // visible width
Var h = $ (window). height (); // visible height
Var left = $ ("# createSchoolWindow"). window ("options"). left; // left distance of the form
Var top = $ ("# createSchoolWindow"). window ("options"). top; // distance to the right of the form
If (width + left)> w ){
$ ("# CreateSchoolWindow"). window ("resize", {width: w-left });
}
If (height + top)> h ){
$ ("# CreateSchoolWindow"). window ("resize", {height: h-top });
}
}
});

});


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.