Created
March 16, 2016 01:39
-
-
Save anuraj/6af90fc1d2b5e25b82a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>@ViewBag.Title - My ASP.NET Application</title> | |
| <link href="~/Content/Site.css" rel="stylesheet" type="text/css" /> | |
| <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
| <script src="~/Scripts/modernizr-2.6.2.js"></script> | |
| @*<link href="~/Content/jquery-ui.css" rel="stylesheet" /> | |
| <link href="~/Content/gridstack.css" rel="stylesheet" />*@ | |
| <link href="~/Content/jquery.gridster.css" rel="stylesheet" /> | |
| <style> | |
| gridster ul { | |
| background-color: #EFEFEF; | |
| } | |
| .gridster li { | |
| font-size: 1em; | |
| font-weight: bold; | |
| text-align: center; | |
| line-height: 100%; | |
| } | |
| .gridster { | |
| margin: 0 auto; | |
| opacity: .8; | |
| -webkit-transition: opacity .6s; | |
| -moz-transition: opacity .6s; | |
| -o-transition: opacity .6s; | |
| -ms-transition: opacity .6s; | |
| transition: opacity .6s; | |
| } | |
| .gridster .gs-w { | |
| background: #DDD; | |
| cursor: pointer; | |
| } | |
| .gridster .player { | |
| background: #BBB; | |
| } | |
| .gridster .preview-holder { | |
| border: none !important; | |
| background: red !important; | |
| } | |
| .gridster * { | |
| margin: 0; | |
| padding: 0; | |
| } | |
| ul { | |
| list-style-type: none; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="navbar navbar-inverse navbar-fixed-top"> | |
| <div class="container"> | |
| <div class="navbar-header"> | |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| </button> | |
| @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" }) | |
| </div> | |
| <div class="navbar-collapse collapse"> | |
| <ul class="nav navbar-nav"></ul> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="container body-content"> | |
| @RenderBody() | |
| <hr /> | |
| <footer> | |
| <p>© @DateTime.Now.Year - My ASP.NET Application</p> | |
| </footer> | |
| </div> | |
| <script src="~/Scripts/jquery-1.10.2.min.js"></script> | |
| <script src="~/Scripts/bootstrap.min.js"></script> | |
| @*<script src="~/Scripts/jquery-ui.js"></script> | |
| <script src="~/Scripts/underscore-min.js"></script> | |
| <script src="~/Scripts/gridstack.js"></script>*@ | |
| <script src="~/Scripts/jquery.gridster.js"></script> | |
| @RenderSection("scripts", false) | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @{ | |
| ViewBag.Title = "Index"; | |
| } | |
| <div class="gridster"> | |
| <ul> | |
| @*<li id="widget1" data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget2" data-row="2" data-col="1" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget3" data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget4" data-row="4" data-col="1" data-sizex="2" data-sizey="1"></li> | |
| <li id="widget5" data-row="1" data-col="2" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget6" data-row="2" data-col="2" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget7" data-row="3" data-col="2" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget8" data-row="1" data-col="2" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget9" data-row="2" data-col="2" data-sizex="1" data-sizey="1"></li> | |
| <li id="widget10" data-row="3" data-col="2" data-sizex="1" data-sizey="1"></li>*@ | |
| </ul> | |
| </div> | |
| @section scripts | |
| { | |
| <script type="text/javascript"> | |
| var gridster; | |
| function CreateWidgets(localData) { | |
| $.each(localData, function (i, value) { | |
| console.log(value.id); | |
| gridster.add_widget("<li></li>").attr({ | |
| "data-col": value.col, | |
| "data-row": value.row, | |
| "data-sizex": value.size_x, | |
| "data-sizey": value.size_y, | |
| "id": value.id | |
| }); | |
| }); | |
| } | |
| $(function () { | |
| gridster = $(".gridster ul").gridster({ | |
| widget_base_dimensions: [100, 55], | |
| widget_margins: [5, 5], | |
| serialize_params: function ($w, wgd) { | |
| return { | |
| id: $($w).attr('id'), | |
| col: wgd.col, | |
| row: wgd.row, | |
| size_x: wgd.size_x, | |
| size_y: wgd.size_y, | |
| }; | |
| }, | |
| helper: 'clone', | |
| draggable: { | |
| stop: function (e, ui, $widget) { | |
| var positions = JSON.stringify(this.serialize()); | |
| localStorage.setItem('positions', positions); | |
| } | |
| }, | |
| resize: { | |
| enabled: true, | |
| max_size: [3, 3], | |
| min_size: [1, 2], | |
| stop: function (e, ui, $widget) { | |
| var positions = JSON.stringify(this.serialize()); | |
| localStorage.setItem('positions', positions); | |
| } | |
| } | |
| }).data('gridster'); | |
| var localData = JSON.parse(localStorage.getItem('positions')); | |
| if (localData != null) { | |
| CreateWidgets(localData); | |
| } | |
| else { | |
| CreateWidgets({ "id": "widget1" }); | |
| } | |
| }); | |
| </script> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment