diff --git a/.jshintrc b/.jshintrc
index 7ceeca24af..a3b7e45610 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,13 +1,26 @@
{
- "curly": true,
- "eqeqeq": true,
- "immed": true,
- "latedef": true,
- "newcap": true,
- "noarg": true,
- "sub": true,
- "undef": true,
- "boss": true,
- "eqnull": true,
- "browser": true
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "expr":true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "browser": true,
+ "node": true,
+ "qunit": true,
+
+ "globals": {
+ "jQuery": true,
+ "define": false,
+ "require": false,
+ "delay": false,
+ "debounce": false,
+ "throttle": false,
+ "Gridster": false
+ }
}
diff --git a/Gruntfile.js b/Gruntfile.js
index 7c0d28f01a..e07520a678 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,183 +1,160 @@
/*global module:false*/
-module.exports = function(grunt) {
+module.exports = function (grunt) {
- // Project configuration.
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
- meta: {
- banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
- '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
- '<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
- '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
- ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n\n',
+ // Project configuration.
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ meta: {
+ banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+ '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+ '<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n\n',
- minibanner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
- '<%= grunt.template.today("yyyy-mm-dd") %> - ' +
- '<%= pkg.homepage ? "* " + pkg.homepage + " - " : "" %>' +
- 'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
- ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */ '
- },
- concat: {
- options: {
- stripBanners: true,
- banner: '<%= meta.banner %>'
- },
- dist_js: {
- src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
- dest: 'dist/jquery.<%= pkg.name %>.js'
- },
+ minibanner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+ '<%= grunt.template.today("yyyy-mm-dd") %> - ' +
+ '<%= pkg.homepage ? "* " + pkg.homepage + " - " : "" %>' +
+ 'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */ '
+ },
+ concat: {
+ options: {
+ stripBanners: true,
+ banner: '<%= meta.banner %>'
+ },
+ dist_js: {
+ src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
+ dest: 'dist/jquery.<%= pkg.name %>.js'
+ },
- dist_extras_js: {
- src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js', 'src/jquery.<%= pkg.name %>.extras.js'],
- dest: 'dist/jquery.<%= pkg.name %>.with-extras.js'
- },
+ dist_extras_js: {
+ src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js', 'src/jquery.<%= pkg.name %>.extras.js'],
+ dest: 'dist/jquery.<%= pkg.name %>.with-extras.js'
+ },
- dist_css: {
- src: ['src/jquery.<%= pkg.name %>.css'],
- dest: 'dist/jquery.<%= pkg.name %>.css'
- },
+ dist_css: {
+ src: ['src/jquery.<%= pkg.name %>.css'],
+ dest: 'dist/jquery.<%= pkg.name %>.css'
+ }
+ },
+ uglify: {
+ options: {
+ banner: '<%= meta.minibanner %>'
+ },
+ dist: {
+ files: {
+ 'dist/jquery.<%= pkg.name %>.min.js': ['<%= concat.dist_js.dest %>']
+ }
+ },
- dist_demo_js: {
- src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js'],
- dest: 'gh-pages/dist/jquery.<%= pkg.name %>.js'
- },
+ dist_extras: {
+ files: {
+ 'dist/jquery.<%= pkg.name %>.with-extras.min.js': ['<%= concat.dist_extras_js.dest %>']
+ }
+ }
+ },
+ cssmin: {
+ compress: {
+ options: {
+ keepSpecialComments: 0,
+ banner: '<%= meta.minibanner %>'
+ },
+ files: {
+ "dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"]
+ }
+ }
+ },
+ jshint: {
+ options: {
+ verbose: true,
+ reporter: require('jshint-stylish'),
+ jshintrc: '.jshintrc'
+ },
+ files: ['GruntFile.js', 'src/**/*.js','sample/**/*.js', 'test/**/*.js']
+ },
+ yuidoc: {
+ compile: {
+ "name": 'gridster.js',
+ "description": 'gridster.js, a drag-and-drop multi-column jQuery grid plugin',
+ "version": 'v<%= pkg.version %>',
+ "url": 'http://gridster.net/',
+ "logo": 'https://ducksboard.com/static/images/svg/logo-ducksboard-black-small.svg',
+ options: {
+ paths: "src/",
+ outdir: "gh-pages/docs/"
+ }
+ }
+ },
+ copy: {
+ dist: {
+ files: [{
+ expand: true,
+ dest: 'gh-pages/',
+ src: ['dist/*', 'demos/**']
+ }]
+ }
+ },
+ 'gh-pages': {
+ target: {
+ options: {
+ message: 'update docs for changes from v<%= pkg.version %> ',
+ base: 'gh-pages',
+ add: true,
+ push: false
+ },
+ src: '**'
+ }
+ },
+ bump: {
+ options: {
+ files: ['package.json', 'bower.json'],
+ updateConfigs: ['pkg'],
+ commit: true,
+ commitMessage: 'Release v%VERSION%',
+ commitFiles: ['package.json', 'bower.json', 'CHANGELOG.md', 'dist/'], // '-a' for all files
+ createTag: true,
+ tagName: 'v%VERSION%',
+ tagMessage: 'Version %VERSION%',
+ push: false,
+ pushTo: 'origin',
+ gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
+ }
+ },
+ clean: {
+ dist: ['.grunt','gh-pages', 'dist']
+ },
+ changelog: {
+ options: {
+ dest: 'CHANGELOG.md'
+ }
+ },
+ watch: {
+ files: ['libs/*.js', 'src/*.js', 'src/*.css', 'Gruntfile.js'],
+ tasks: ['concat', 'uglify', 'cssmin']
+ }
+ });
- dist_extras_demo_js: {
- src: ['src/jquery.coords.js', 'src/jquery.collision.js', 'src/utils.js', 'src/jquery.draggable.js', 'src/jquery.<%= pkg.name %>.js', 'src/jquery.<%= pkg.name %>.extras.js'],
- dest: 'gh-pages/dist/jquery.<%= pkg.name %>.with-extras.js'
- },
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
+ grunt.loadNpmTasks('grunt-contrib-yuidoc');
+ grunt.loadNpmTasks('grunt-bump');
+ grunt.loadNpmTasks('grunt-conventional-changelog');
+ grunt.loadNpmTasks('grunt-gh-pages');
- dist_demo_css: {
- src: ['src/jquery.<%= pkg.name %>.css'],
- dest: 'gh-pages/dist/jquery.<%= pkg.name %>.css'
- }
- },
- uglify: {
- options: {
- banner: '<%= meta.minibanner %>'
- },
- dist: {
- files: {
- 'dist/jquery.<%= pkg.name %>.min.js': ['<%= concat.dist_js.dest %>']
- }
- },
+ // Default task.
+ grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'cssmin']);
+ grunt.registerTask('build', ['default']);
+ grunt.registerTask('docs', ['clean', 'build', 'yuidoc', 'copy:dist', 'gh-pages']);
- dist_extras: {
- files: {
- 'dist/jquery.<%= pkg.name %>.with-extras.min.js': ['<%= concat.dist_extras_js.dest %>']
- }
- },
-
- dist_demo: {
- files: {
- 'gh-pages/dist/jquery.<%= pkg.name %>.min.js': ['<%= concat.dist_js.dest %>']
- }
- },
-
- dist_extras_demo: {
- files: {
- 'gh-pages/dist/jquery.<%= pkg.name %>.with-extras.min.js': ['<%= concat.dist_extras_js.dest %>']
- }
- }
- },
- cssmin: {
- compress: {
- options: {
- keepSpecialComments: 0,
- banner: '<%= meta.minibanner %>'
- },
- files: {
- "dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"],
- "gh-pages/dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"]
- }
- }
- },
- jshint: {
- files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
- },
- watch: {
- files: ['<%= lint.files %>', 'src/jquery.<%= pkg.name %>.css'],
- tasks: 'min concat'
- },
- jshint: {
- options: {
- curly: true,
- eqeqeq: true,
- immed: true,
- latedef: true,
- newcap: true,
- noarg: true,
- sub: true,
- undef: true,
- boss: true,
- eqnull: true,
- browser: true
- },
- globals: {
- jQuery: true
- }
- },
- yuidoc: {
- compile: {
- "name": 'gridster.js',
- "description": 'gridster.js, a drag-and-drop multi-column jQuery grid plugin',
- "version": '0.1.0',
- "url": 'http://gridster.net/',
- "logo": 'https://ducksboard.com/static/images/svg/logo-ducksboard-black-small.svg',
- options: {
- paths: "src/",
- outdir: "gh-pages/docs/"
- }
- }
- },
-
- bump: {
- options: {
- files: ['package.json', 'bower.json'],
- updateConfigs: ['pkg'],
- commit: true,
- commitMessage: 'Release v%VERSION%',
- commitFiles: ['package.json', 'bower.json', 'CHANGELOG.md', 'dist/'], // '-a' for all files
- createTag: true,
- tagName: 'v%VERSION%',
- tagMessage: 'Version %VERSION%',
- push: false,
- pushTo: 'origin',
- gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
- }
- },
-
- changelog: {
- options: {
- dest: 'CHANGELOG.md'
- }
- },
-
- watch: {
- files: ['libs/*.js', 'src/*.js', 'src/*.css', 'Gruntfile.js'],
- tasks: ['concat', 'uglify', 'cssmin']
- }
- });
-
-
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-cssmin');
- grunt.loadNpmTasks('grunt-contrib-yuidoc');
- grunt.loadNpmTasks('grunt-bump');
- grunt.loadNpmTasks('grunt-conventional-changelog');
-
- // Default task.
- grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'cssmin']);
- grunt.registerTask('build', ['default']);
- grunt.registerTask('docs', ['yuidoc']);
-
- grunt.registerTask('release:patch', ['build', 'bump-only:patch', 'build', 'docs', 'changelog']);
- grunt.registerTask('release:minor', ['build', 'bump-only:minor', 'build', 'docs', 'changelog']);
- grunt.registerTask('release:major', ['build', 'bump-only:major', 'build', 'docs', 'changelog']);
- grunt.registerTask('release:git', ['build', 'bump-only:git', 'build', 'docs', 'changelog', 'bump-commit']);
- grunt.registerTask('release:commit', ['bump-commit']);
+ grunt.registerTask('release:patch', ['build', 'bump-only:patch', 'build', 'docs', 'changelog']);
+ grunt.registerTask('release:minor', ['build', 'bump-only:minor', 'build', 'docs', 'changelog']);
+ grunt.registerTask('release:major', ['build', 'bump-only:major', 'build', 'docs', 'changelog']);
+ grunt.registerTask('release:git', ['build', 'bump-only:git', 'build', 'docs', 'changelog', 'bump-commit']);
+ grunt.registerTask('release:commit', ['bump-commit']);
};
diff --git a/sample/SwapDrop.html b/demos/SwapDrop.html
similarity index 84%
rename from sample/SwapDrop.html
rename to demos/SwapDrop.html
index bdc2ca050f..0f3aff562b 100644
--- a/sample/SwapDrop.html
+++ b/demos/SwapDrop.html
@@ -4,13 +4,10 @@
Gridster Grid Swapping Demo
-
-
-
+
+
-
-
-
+
-
+
Grid with larger widgets swapping spots with smaller ones
This demo represents using the branch in swap mode. This works best with shift_larger_widgets_down set to "false". However, smaller widgets do
not displace larger ones.
diff --git a/demos/adding-widgets-dynamically.html b/demos/adding-widgets-dynamically.html
new file mode 100644
index 0000000000..0a80d3ad0e
--- /dev/null
+++ b/demos/adding-widgets-dynamically.html
@@ -0,0 +1,54 @@
+
+
+
+ Demo » Add widgets dynamically » gridster.js
+
+
+
+
+
+
+
+
+
+Add widgets dynamically
+
+Create a grid adding widgets from an Array (not from HTML) using add_widget
method. Widget position (col, row) not specified.
+
+
+
+
+
+
+
diff --git a/demos/assets/css/demo.css b/demos/assets/css/demo.css
new file mode 100644
index 0000000000..ff504a18bd
--- /dev/null
+++ b/demos/assets/css/demo.css
@@ -0,0 +1,94 @@
+body {
+ background: #004756;
+ font-size: 16px;
+ font-family: 'Helvetica Neue', Arial, sans-serif;
+ color: #ffffff;
+ margin: 0;
+}
+
+h1, h2, h3, p {
+ margin: 10px;
+}
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+/* Gridster styles */
+.demo {
+ margin: 3em 0;
+ padding: 7.5em 0 5.5em;
+ background: #004756;
+}
+
+.demo:hover .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;
+}
+
+.content {
+ color: white;
+}
+
+.gridster .gs-w {
+ background: #61A9CF;
+ cursor: pointer;
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
+}
+
+.gridster .player {
+ -webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
+ box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
+ background: #BBB;
+}
+
+.gridster .gs-w.try {
+ background-image: url(../img/sprite.png);
+ background-repeat: no-repeat;
+ background-position: 37px -169px;
+
+}
+
+.gridster .preview-holder {
+ border: none !important;
+ border-radius: 0 !important;
+ background: red !important;
+}
+
+ul {
+ list-style-type: none;
+}
+
+li {
+ list-style: none;
+ font-weight: bold
+}
+
+.gridster ul {
+ background-color: #EFEFEF;
+}
+
+.gridster li {
+ font-size: 1em;
+ font-weight: bold;
+ text-align: center;
+ line-height: 100%;
+}
+
+.gridster-box {
+ position: relative;
+ width: 100%;
+ height: 100%;
+}
+
+.controls {
+ margin-bottom: 20px;
+}
diff --git a/sample/img/sprite.png b/demos/assets/img/sprite.png
similarity index 100%
rename from sample/img/sprite.png
rename to demos/assets/img/sprite.png
diff --git a/demos/assets/js/plugins.js b/demos/assets/js/plugins.js
new file mode 100644
index 0000000000..70bb435972
--- /dev/null
+++ b/demos/assets/js/plugins.js
@@ -0,0 +1,25 @@
+// Avoid `console` errors in browsers that lack a console.
+(function () {
+ var method;
+ var noop = function () {
+ };
+ var methods = [
+ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
+ 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
+ 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
+ 'timeStamp', 'trace', 'warn'
+ ];
+ var length = methods.length;
+ var console = (window.console = window.console || {});
+
+ while (length--) {
+ method = methods[length];
+
+ // Only stub undefined methods.
+ if (!console[method]) {
+ console[method] = noop;
+ }
+ }
+}());
+
+// Place any jQuery/helper plugins in here.
diff --git a/demos/custom-drag-handle.html b/demos/custom-drag-handle.html
new file mode 100644
index 0000000000..2a670a4ce6
--- /dev/null
+++ b/demos/custom-drag-handle.html
@@ -0,0 +1,96 @@
+
+
+
+ Demo » Custom drag handle » gridster.js
+
+
+
+
+
+
+
+
+
+Custom drag handle
+
+Restricts dragging from starting unless the mousedown occurs on the specified element(s).
+
+
+
+
+
+
+ 0
+
+
+
+ 1
+
+
+
+ 2
+
+
+
+ 3
+
+
+
+
+ 4
+
+
+
+ 5
+
+
+
+ 6
+
+
+
+ 7
+
+
+
+ 8
+
+
+
+
+ 9
+
+
+
+
+
+
+
+
+
diff --git a/demos/dynamic-grid-width.html b/demos/dynamic-grid-width.html
new file mode 100644
index 0000000000..43ec4c06f2
--- /dev/null
+++ b/demos/dynamic-grid-width.html
@@ -0,0 +1,52 @@
+
+
+
+ Demo » Dynamic grid width » gridster.js
+
+
+
+
+
+
+
+
+Dynamic grid width
+
+Drag or resize some widgets to the right side. Use max_cols
option to set a maximum number of columns for the grid.
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+
+
+
+
+
+
diff --git a/demos/expandable-widgets.html b/demos/expandable-widgets.html
new file mode 100644
index 0000000000..19d591ece2
--- /dev/null
+++ b/demos/expandable-widgets.html
@@ -0,0 +1,65 @@
+
+
+
+ Demo » Expandable widgets » gridster.js
+
+
+
+
+
+
+
+
+Expandable widgets
+
+Expand widgets when hover on them using resize_widget
method.
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+
+
+
+
+
+
+
+
diff --git a/demos/grid-from-serialize.html b/demos/grid-from-serialize.html
new file mode 100644
index 0000000000..e0f387abd2
--- /dev/null
+++ b/demos/grid-from-serialize.html
@@ -0,0 +1,103 @@
+
+
+
+ Demo » Grid from serialize » gridster.js
+
+
+
+
+
+
+
+
+Build grid from serialized positions
+
+Build a entire new grid from previously stored positions obtained with serialize
method.
+
+
+ Build from serialize
+
+
+
+
+
+
+
diff --git a/demos/index.html b/demos/index.html
new file mode 100644
index 0000000000..eacada845c
--- /dev/null
+++ b/demos/index.html
@@ -0,0 +1,38 @@
+
+
+
+ Gridster Demos
+
+
+
+
+
+
+
+
Samples
+
+
+
+
+
+
diff --git a/demos/jquery.gridster.demo2.html b/demos/jquery.gridster.demo2.html
new file mode 100644
index 0000000000..2ee5863688
--- /dev/null
+++ b/demos/jquery.gridster.demo2.html
@@ -0,0 +1,59 @@
+
+
+
+
+ demo
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demos/multiple-grids.html b/demos/multiple-grids.html
new file mode 100644
index 0000000000..bdd08a34a8
--- /dev/null
+++ b/demos/multiple-grids.html
@@ -0,0 +1,71 @@
+
+
+
+ Demo » Multiple gridster intances » gridster.js
+
+
+
+
+
+
+
+
+Multiple gridster instances with different configurations
+
+When using multiple gridster instances on the same page you can scope the CSS code generated by gridster using namespace
config
+ option.
+
+Demo 1
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+
+
+
+
+Demo 2
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+
+
+
+
+
+
diff --git a/demos/resize-limits.html b/demos/resize-limits.html
new file mode 100644
index 0000000000..f1d63221d2
--- /dev/null
+++ b/demos/resize-limits.html
@@ -0,0 +1,76 @@
+
+
+
+ Demo » Resize » gridster.js
+
+
+
+
+
+
+
+
+Resize with limits
+
+Use resize.max_size
and resize.min_size
config options or data-max-sizex
, data-max-sizey
,
+ data-min-sizex
and data-min-sizey
HTML attributes to limit widget dimensions when resizing.
+
+If a global max_size is specified through the config option, can be overwrited in specified widgets with HTML data-attributes or using set_widget_max_size
+ method.
+
+
+
+
+
+ 0
+
+ Overwrited to 2, 6
+
+
+ 1
+
+ Overwrited max-size to 6, 2
+
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+
+ 9
+
+ Overwrited min-size to 3, 3
+
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+
+
+
+
+
+
diff --git a/demos/resize.html b/demos/resize.html
new file mode 100644
index 0000000000..6a5684c1fd
--- /dev/null
+++ b/demos/resize.html
@@ -0,0 +1,65 @@
+
+
+
+ Demo » Resize » gridster.js
+
+
+
+
+
+
+
+
+Resize
+
+Grab the right or bottom border and drag to the desired width or height.
+
+
+ Resize random widget
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+
+
+
+
+
+
+
+
diff --git a/sample/responsive.html b/demos/responsive.html
similarity index 88%
rename from sample/responsive.html
rename to demos/responsive.html
index 1a4ce8b6c6..b35eed2f43 100644
--- a/sample/responsive.html
+++ b/demos/responsive.html
@@ -3,14 +3,10 @@
Gridster Responsive Demo
-
-
-
+
+
-
-
-
-
+
-
-
This demo represents using the branch in responsive mode. This makes the grid as wide as the screen and responds to changes in browser width.
+
Responsive Layout
+
This demo represents using the branch in responsive mode. This makes the grid as wide as the screen and responds to changes in browser
+ width.
diff --git a/demos/serialize.html b/demos/serialize.html
new file mode 100644
index 0000000000..3a4cfe7295
--- /dev/null
+++ b/demos/serialize.html
@@ -0,0 +1,89 @@
+
+
+
+ Demo » Serialize » gridster.js
+
+
+
+
+
+
+
+
+
+
+Serialize positions
+
+Use serialize
method to get widget positions. It returns a Array of objects that can be used as a JSON object.
+
+
+ Serialize
+
+
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+
+ 4
+ 5
+ 6
+ 7
+ 8
+
+ 9
+
+ 10
+ 11
+ 12
+ 13
+
+ 14
+ 15
+
+ 16
+
+
+
+
+
+
diff --git a/demos/using-drag-callbacks.html b/demos/using-drag-callbacks.html
new file mode 100644
index 0000000000..469db738b7
--- /dev/null
+++ b/demos/using-drag-callbacks.html
@@ -0,0 +1,75 @@
+
+
+
+ Demo » Using drag callbacks » gridster.js
+
+
+
+
+
+
+
+
+
+
+Drag callbacks
+
+Drag some widgets and see the log below.
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+
+
+
+Log
+
+
+
+
+
+
diff --git a/demos/using-resize-callbacks.html b/demos/using-resize-callbacks.html
new file mode 100644
index 0000000000..5e7c86425a
--- /dev/null
+++ b/demos/using-resize-callbacks.html
@@ -0,0 +1,78 @@
+
+
+
+ Demo » Using resize callbacks » gridster.js
+
+
+
+
+
+
+
+
+
+
+Resize callbacks
+
+Resize some widgets and see the log below.
+
+
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+
+
+
+Log
+
+
+
+
+
+
diff --git a/dist/jquery.gridster.css b/dist/jquery.gridster.css
index 7a2a5aed82..56b00dfd76 100644
--- a/dist/jquery.gridster.css
+++ b/dist/jquery.gridster.css
@@ -1,13 +1,12 @@
-/*! gridster.js - v0.6.6 - 2015-04-09
+/*! gridster.js - v0.6.6 - 2015-04-10
* http://gridster.net/
-* Copyright (c) 2015 decksterteam; Licensed MIT */
+* Copyright (c) 2015 ducksboard; Licensed MIT */
.gridster {
position:relative;
}
.gridster > * {
- margin: 0 auto;
-webkit-transition: height .4s, width .4s;
-moz-transition: height .4s, width .4s;
-o-transition: height .4s, width .4s;
diff --git a/dist/jquery.gridster.js b/dist/jquery.gridster.js
index f391768435..8517de5ca9 100644
--- a/dist/jquery.gridster.js
+++ b/dist/jquery.gridster.js
@@ -1,6 +1,6 @@
-/*! gridster.js - v0.6.6 - 2015-04-09
+/*! gridster.js - v0.6.6 - 2015-04-10
* http://gridster.net/
-* Copyright (c) 2015 decksterteam; Licensed MIT */
+* Copyright (c) 2015 ducksboard; Licensed MIT */
;(function(root, factory) {
if(typeof exports === 'object') {
@@ -366,76 +366,89 @@
}));
-;(function(window, undefined) {
+(function (window, undefined) {
- /* Delay, debounce and throttle functions taken from underscore.js
- *
- * Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
- * Investigative Reporters & Editors
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
+ /* Delay, debounce and throttle functions taken from underscore.js
+ *
+ * Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
+ * Investigative Reporters & Editors
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
- window.delay = function(func, wait) {
- var args = Array.prototype.slice.call(arguments, 2);
- return setTimeout(function(){ return func.apply(null, args); }, wait);
- };
+ window.delay = function (func, wait) {
+ var args = Array.prototype.slice.call(arguments, 2);
+ return setTimeout(function () {
+ return func.apply(null, args);
+ }, wait);
+ };
- window.debounce = function(func, wait, immediate) {
- var timeout;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) func.apply(context, args);
- };
- if (immediate && !timeout) func.apply(context, args);
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- };
- };
+ window.debounce = function (func, wait, immediate) {
+ var timeout;
+ return function () {
+ var context = this, args = arguments;
+ var later = function () {
+ timeout = null;
+ if (!immediate) {
+ func.apply(context, args);
+ }
+ };
+ if (immediate && !timeout) {
+ func.apply(context, args);
+ }
+ clearTimeout(timeout);
+ timeout = setTimeout(later, wait);
+ };
+ };
- window.throttle = function(func, wait) {
- var context, args, timeout, throttling, more, result;
- var whenDone = debounce(
- function(){ more = throttling = false; }, wait);
- return function() {
- context = this; args = arguments;
- var later = function() {
- timeout = null;
- if (more) func.apply(context, args);
- whenDone();
- };
- if (!timeout) timeout = setTimeout(later, wait);
- if (throttling) {
- more = true;
- } else {
- result = func.apply(context, args);
- }
- whenDone();
- throttling = true;
- return result;
- };
- };
+ window.throttle = function (func, wait) {
+ var context, args, timeout, throttling, more, result;
+ var whenDone = debounce(
+ function () {
+ more = throttling = false;
+ }, wait);
+ return function () {
+ context = this;
+ args = arguments;
+ var later = function () {
+ timeout = null;
+ if (more) {
+ func.apply(context, args);
+ }
+ whenDone();
+ };
+ if (!timeout) {
+ timeout = setTimeout(later, wait);
+ }
+ if (throttling) {
+ more = true;
+ } else {
+ result = func.apply(context, args);
+ }
+ whenDone();
+ throttling = true;
+ return result;
+ };
+ };
})(window);
@@ -515,9 +528,8 @@
this.options = $.extend({}, defaults, options);
this.$document = $(document);
this.$container = $(el);
- this.$scroll_container = this.options.scroll_container == window ?
+ this.$scroll_container = this.options.scroll_container === window ?
$(window) : this.$container.closest(this.options.scroll_container);
- this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
this.player_min_left = 0 + this.options.offset_left;
this.id = uniqId();
@@ -537,7 +549,7 @@
this.events();
$window.bind(this.nsEvent('resize'),
- throttle($.proxy(this.calculate_dimensions, this), 200));
+ throttle($.proxy(this.calculate_dimensions, this), 200));
};
fn.nsEvent = function(ev) {
@@ -568,8 +580,7 @@
};
fn.get_actual_pos = function($el) {
- var pos = $el.position();
- return pos;
+ return $el.position();
};
@@ -704,14 +715,13 @@
};
- fn.calculate_dimensions = function(e) {
+ fn.calculate_dimensions = function() {
this.scroller_height = this.$scroll_container.height();
this.scroller_width = this.$scroll_container.width();
};
fn.drag_handler = function(e) {
- var node = e.target.nodeName;
// skip if drag is disabled, or click was not done with the mouse primary button
if (this.disabled || e.which !== 1 && !isTouch) {
return;
@@ -767,7 +777,6 @@
var offset = this.$container.offset();
this.baseX = Math.round(offset.left);
this.baseY = Math.round(offset.top);
- this.initial_container_width = this.options.container_width || this.$container.width();
if (this.options.helper === 'clone') {
this.$helper = this.$player.clone()
@@ -779,11 +788,8 @@
this.scroll_container_offset_y = this.$scroll_container.scrollTop();
this.scroll_container_offset_x = this.$scroll_container.scrollLeft();
- this.scroll_offset_y = 0;
- this.scroll_offset_x = 0;
this.el_init_offset = this.$player.offset();
this.player_width = this.$player.width();
- this.player_height = this.$player.height();
this.set_limits(this.options.container_width);
@@ -1030,7 +1036,7 @@
this.options.draggable = $.extend(true, {}, this.options.draggable,
{scroll_container: this.options.scroll_container});
this.$el = $(el);
- this.$scroll_container = this.options.scroll_container == window ?
+ this.$scroll_container = this.options.scroll_container === window ?
$(window) : this.$el.closest(this.options.scroll_container);
this.$wrapper = this.$el.parent();
this.$widgets = this.$el.children(
@@ -1316,7 +1322,7 @@
}, this), 0);
}
- return $w.fadeIn({complete: function () { if(callback) callback.call(this); }});
+ return $w.fadeIn({complete: function () { if(callback) {callback.call(this);} }});
};
@@ -1378,7 +1384,7 @@
fn.add_resize_handle = function($w) {
var $append_to = this.options.resize.handle_append_to ? $(this.options.resize.handle_append_to, $w) : $w;
- if ( ($append_to.children("span[class~='" + this.resize_handle_class + "']")).length == 0 ) {
+ if ( ($append_to.children("span[class~='" + this.resize_handle_class + "']")).length === 0 ) {
$(this.resize_handle_tpl).appendTo( $append_to );
}
@@ -1832,7 +1838,9 @@
$nexts.not($exclude).each($.proxy(function(i, w) {
var $w = $( w ),
wgd = $w.coords().grid;
+ /*jshint -W018 */
if ( !(wgd.row <= (row + size_y - 1))) { return; }
+ /*jshint +W018 */
var diff = (row + size_y) - wgd.row;
this.move_widget_down($w, diff);
}, this));
@@ -1925,7 +1933,7 @@
if($w){
this.remove_widget($w);
}
- }
+ };
/**
@@ -2005,7 +2013,8 @@
$widgets || ($widgets = this.$widgets);
var result = [];
$widgets.each($.proxy(function(i, widget) {
- if(typeof($(widget).coords().grid) != "undefined"){
+ var $w = $(widget);
+ if(typeof($w.coords().grid) !== 'undefined'){
result.push(this.options.serialize_params($w, $w.coords().grid) );
}
}, this));
@@ -2615,12 +2624,12 @@
size_x = Math.max(Math.min(size_x, max_size_x), min_size_x);
size_x = Math.min(max_cols, size_x);
width = (max_size_x * wbd_x) + ((size_x - 1) * margin_x );
- max_width = Math.min(width, limit_width);
- min_width = (min_size_x * wbd_x) + ((size_x - 1) * margin_x);
+ var max_width = Math.min(width, limit_width);
+ var min_width = (min_size_x * wbd_x) + ((size_x - 1) * margin_x);
size_y = Math.max(Math.min(size_y, max_size_y), min_size_y);
- max_height = (max_size_y * wbd_y) + ((size_y - 1) * margin_y);
- min_height = (min_size_y * wbd_y) + ((size_y - 1) * margin_y);
+ var max_height = (max_size_y * wbd_y) + ((size_y - 1) * margin_y);
+ var min_height = (min_size_y * wbd_y) + ((size_y - 1) * margin_y);
if (this.resize_dir.right) {
size_y = this.resize_initial_sizey;
@@ -2858,10 +2867,10 @@
//Move queued widgets
if(swap && this.can_placeholder_be_set(to_col, to_row, player_size_x, player_size_y)){
for(var key in this.w_queue){
- var col = parseInt(key.split("_")[0]);
- var row = parseInt(key.split("_")[1]);
- if (this.w_queue[key] != "full"){
- this.new_move_widget_to(this.w_queue[key], col, row);
+ var _col = parseInt(key.split("_")[0]);
+ var _row = parseInt(key.split("_")[1]);
+ if (this.w_queue[key] !== "full"){
+ this.new_move_widget_to(this.w_queue[key], _col, _row);
}
}
this.set_placeholder(to_col, to_row);
@@ -2898,12 +2907,12 @@
if(this.is_occupied(colc,rowc)){
occupied = true;
} else if(key in this.w_queue){
- if(this.w_queue[key] == "full"){
+ if(this.w_queue[key] === 'full'){
occupied = true;
continue;
}
- $tw = this.w_queue[key];
- tgd = $tw.coords().grid;
+ var $tw = this.w_queue[key];
+ var tgd = $tw.coords().grid;
//remove queued items if no longer under player.
if(!this.is_widget_under_player(tgd.col,tgd.row)){
delete this.w_queue[key];
@@ -2922,7 +2931,7 @@
}
return occupied;
- }
+ };
fn.can_placeholder_be_set = function(col, row, player_size_x, player_size_y){
var can_set = true;
@@ -2945,10 +2954,10 @@
}
}
return can_set;
- }
+ };
fn.queue_widget = function(col, row, $widget){
- var $w = $widget
+ var $w = $widget;
var wgd = $w.coords().grid;
var primary_key = col+"_"+row;
if (primary_key in this.w_queue){
@@ -2962,7 +2971,7 @@
var colc = col + c;
var rowc = row + r;
var key = colc+"_"+rowc;
- if (key == primary_key){
+ if (key === primary_key){
continue;
}
this.w_queue[key] = "full";
@@ -2970,7 +2979,7 @@
}
return true;
- }
+ };
fn.is_widget_queued_and_can_move = function($widget){
var queued = false;
@@ -2979,10 +2988,10 @@
}
for(var key in this.w_queue){
- if(this.w_queue[key] == "full"){
+ if(this.w_queue[key] === "full"){
continue;
}
- if(this.w_queue[key].attr("data-col") == $widget.attr("data-col") && this.w_queue[key].attr("data-row") == $widget.attr("data-row")){
+ if(this.w_queue[key].attr("data-col") === $widget.attr("data-col") && this.w_queue[key].attr("data-row") === $widget.attr("data-row")){
queued = true;
//test whole space
var $w = this.w_queue[key];
@@ -3004,24 +3013,24 @@
}
}
- return queued
- }
+ return queued;
+ };
fn.is_in_queue = function(col,row, $widget){
var queued = false;
var key = col+"_"+row;
if ((key in this.w_queue)){
- if (this.w_queue[key] == "full"){
+ if (this.w_queue[key] === "full"){
queued = true;
} else {
- $tw = this.w_queue[key];
- tgd = $tw.coords().grid;
+ var $tw = this.w_queue[key];
+ var tgd = $tw.coords().grid;
if(!this.is_widget_under_player(tgd.col,tgd.row)){
- delete this.w_queue[key]
+ delete this.w_queue[key];
queued = false;
- } else if(this.w_queue[key].attr("data-col") == $widget.attr("data-col") && this.w_queue[key].attr("data-row") == $widget.attr("data-row")) {
- delete this.w_queue[key]
+ } else if(this.w_queue[key].attr("data-col") === $widget.attr("data-col") && this.w_queue[key].attr("data-row") === $widget.attr("data-row")) {
+ delete this.w_queue[key];
queued = false;
} else {
queued = true;
@@ -3030,7 +3039,7 @@
}
return queued;
- }
+ };
/**
@@ -3107,7 +3116,7 @@
// overlaps player
var y = (to_row + this.player_grid_data.size_y) - wgd.row;
if (this.can_go_down($w)){
- console.log("In Move Down!")
+ console.log("In Move Down!");
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
}
@@ -3351,8 +3360,8 @@
if (moved_down || changed_column) {
$nexts.each($.proxy(function(i, widget) {
//Make sure widget is at it's topmost position
- $w = $(widget);
- wgd = $w.coords().grid;
+ var $w = $(widget);
+ var wgd = $w.coords().grid;
var can_go_widget_up = this.can_go_widget_up(wgd);
@@ -3507,12 +3516,13 @@
while (++r <= p_bottom_row ) {
var common = true;
+ /*jshint -W083 */
$.each(upper_rows, function(col, rows) {
if ($.isArray(rows) && $.inArray(r, rows) === -1) {
common = false;
}
});
-
+ /*jshint +W083 */
if (common === true) {
valid_rows.push(r);
if (valid_rows.length === size_y) {
@@ -3649,12 +3659,14 @@
var self = this;
var cols = this.cells_occupied_by_player.cols;
if(this.options.shift_larger_widgets_down){
+ /*jshint -W083 */
for (var c = 0, cl = cols.length; c < cl; c++) {
this.for_each_widget_below(cols[c], row, function(tcol, trow) {
console.log("from_on_stop_overlapping_row");
self.move_widget_up(this, self.player_grid_data.size_y);
});
}
+ /*jshint +W083 */
}
};
@@ -3674,7 +3686,7 @@
this.$changed = this.$changed.add($widget);
return this;
- }
+ };
/**
@@ -4012,10 +4024,10 @@
if ($(this).hasClass($gr.options.static_class)){
can_go_down = false;
}
- })
+ });
return can_go_down;
- }
+ };
fn.can_go_up = function($el) {
@@ -4213,13 +4225,13 @@
};
fn.clean_up_changed = function(){
- $gr = this;
+ var $gr = this;
$gr.$changed.each(function(){
if($gr.options.shift_larger_widgets_down){
$gr.move_widget_up($(this));
}
});
- }
+ };
@@ -4514,8 +4526,8 @@
/* generate CSS styles for cols */
for(i = 1; i <= opts.cols + 1; i++) {
styles += (opts.namespace + ' [data-col="' + i + '"] { left:' +
- (full_width ? this.options.widget_margins[0] : ((i * opts.widget_margins[0]) + ((i - 1) * opts.widget_base_dimensions[0])))
- + 'px; }\n');
+ (full_width ? this.options.widget_margins[0] :
+ ((i * opts.widget_margins[0]) + ((i - 1) * opts.widget_base_dimensions[0]))) + 'px; }\n');
}
/* generate CSS styles for rows */
@@ -4531,7 +4543,8 @@
for (var x = 1; x <= max_size_x; x++) {
styles += (opts.namespace + ' [data-sizex="' + x + '"] { width:' +
- (full_width ? ($(window).width() - this.options.widget_margins[0] * 2) : ((x * opts.widget_base_dimensions[0]) + ((x - 1) * opts.widget_margins[0]))) + 'px; }\n');
+ (full_width ? ($(window).width() - this.options.widget_margins[0] * 2) :
+ ((x * opts.widget_base_dimensions[0]) + ((x - 1) * opts.widget_margins[0]))) + 'px; }\n');
}
this.remove_style_tags();
diff --git a/dist/jquery.gridster.min.css b/dist/jquery.gridster.min.css
index 19a92086bf..eb8a9f4b61 100644
--- a/dist/jquery.gridster.min.css
+++ b/dist/jquery.gridster.min.css
@@ -1,2 +1,2 @@
-/*! gridster.js - v0.6.6 - 2015-04-09 - * http://gridster.net/ - Copyright (c) 2015 decksterteam; Licensed MIT */
-.gridster{position:relative}.gridster>*{margin:0 auto;-webkit-transition:height .4s,width .4s;-moz-transition:height .4s,width .4s;-o-transition:height .4s,width .4s;-ms-transition:height .4s,width .4s;transition:height .4s,width .4s}.gridster .gs-w{z-index:2;position:absolute}.gridster.collapsed{height:auto!important}.gridster.collapsed .gs-w{position:static!important}.ready .gs-w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s;-moz-transition:opacity .3s,left .3s,top .3s;-o-transition:opacity .3s,left .3s,top .3s;transition:opacity .3s,left .3s,top .3s}.ready .gs-w:not(.preview-holder),.ready .resize-preview-holder{-webkit-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-moz-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-o-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;transition:opacity .3s,left .3s,top .3s,width .3s,height .3s}.gridster .preview-holder{z-index:1;position:absolute;background-color:#fff;border-color:#fff;opacity:.3}.gridster .player-revert{z-index:10!important;-webkit-transition:left .3s,top .3s!important;-moz-transition:left .3s,top .3s!important;-o-transition:left .3s,top .3s!important;transition:left .3s,top .3s!important}.gridster .dragging,.gridster .resizing{z-index:10!important;-webkit-transition:all 0s!important;-moz-transition:all 0s!important;-o-transition:all 0s!important;transition:all 0s!important}.gs-resize-handle{position:absolute;z-index:1}.gs-resize-handle-both{width:20px;height:20px;bottom:-8px;right:-8px;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pg08IS0tIEdlbmVyYXRvcjogQWRvYmUgRmlyZXdvcmtzIENTNiwgRXhwb3J0IFNWRyBFeHRlbnNpb24gYnkgQWFyb24gQmVhbGwgKGh0dHA6Ly9maXJld29ya3MuYWJlYWxsLmNvbSkgLiBWZXJzaW9uOiAwLjYuMSAgLS0+DTwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DTxzdmcgaWQ9IlVudGl0bGVkLVBhZ2UlMjAxIiB2aWV3Qm94PSIwIDAgNiA2IiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjojZmZmZmZmMDAiIHZlcnNpb249IjEuMSINCXhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbDpzcGFjZT0icHJlc2VydmUiDQl4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjZweCIgaGVpZ2h0PSI2cHgiDT4NCTxnIG9wYWNpdHk9IjAuMzAyIj4NCQk8cGF0aCBkPSJNIDYgNiBMIDAgNiBMIDAgNC4yIEwgNCA0LjIgTCA0LjIgNC4yIEwgNC4yIDAgTCA2IDAgTCA2IDYgTCA2IDYgWiIgZmlsbD0iIzAwMDAwMCIvPg0JPC9nPg08L3N2Zz4=);background-position:top left;background-repeat:no-repeat;cursor:se-resize;z-index:20}.gs-resize-handle-x{top:0;bottom:13px;right:-5px;width:10px;cursor:e-resize}.gs-resize-handle-y{left:0;right:13px;bottom:-5px;height:10px;cursor:s-resize}.gs-w:hover .gs-resize-handle,.resizing .gs-resize-handle{opacity:1}.gs-resize-handle,.gs-w.dragging .gs-resize-handle{opacity:0}.gs-resize-disabled .gs-resize-handle{display:none!important}[data-max-sizex="1"] .gs-resize-handle-x,[data-max-sizey="1"] .gs-resize-handle-y,[data-max-sizey="1"][data-max-sizex="1"] .gs-resize-handle{display:none!important}
\ No newline at end of file
+/*! gridster.js - v0.6.6 - 2015-04-10 - * http://gridster.net/ - Copyright (c) 2015 ducksboard; Licensed MIT */
+.gridster{position:relative}.gridster>*{-webkit-transition:height .4s,width .4s;-moz-transition:height .4s,width .4s;-o-transition:height .4s,width .4s;-ms-transition:height .4s,width .4s;transition:height .4s,width .4s}.gridster .gs-w{z-index:2;position:absolute}.gridster.collapsed{height:auto!important}.gridster.collapsed .gs-w{position:static!important}.ready .gs-w:not(.preview-holder),.ready .resize-preview-holder{-webkit-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-moz-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;-o-transition:opacity .3s,left .3s,top .3s,width .3s,height .3s;transition:opacity .3s,left .3s,top .3s,width .3s,height .3s}.gridster .preview-holder{z-index:1;position:absolute;background-color:#fff;border-color:#fff;opacity:.3}.gridster .player-revert{z-index:10!important;-webkit-transition:left .3s,top .3s!important;-moz-transition:left .3s,top .3s!important;-o-transition:left .3s,top .3s!important;transition:left .3s,top .3s!important}.gridster .dragging,.gridster .resizing{z-index:10!important;-webkit-transition:all 0s!important;-moz-transition:all 0s!important;-o-transition:all 0s!important;transition:all 0s!important}.gs-resize-handle{position:absolute;z-index:1}.gs-resize-handle-both{width:20px;height:20px;bottom:-8px;right:-8px;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pg08IS0tIEdlbmVyYXRvcjogQWRvYmUgRmlyZXdvcmtzIENTNiwgRXhwb3J0IFNWRyBFeHRlbnNpb24gYnkgQWFyb24gQmVhbGwgKGh0dHA6Ly9maXJld29ya3MuYWJlYWxsLmNvbSkgLiBWZXJzaW9uOiAwLjYuMSAgLS0+DTwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DTxzdmcgaWQ9IlVudGl0bGVkLVBhZ2UlMjAxIiB2aWV3Qm94PSIwIDAgNiA2IiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjojZmZmZmZmMDAiIHZlcnNpb249IjEuMSINCXhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbDpzcGFjZT0icHJlc2VydmUiDQl4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjZweCIgaGVpZ2h0PSI2cHgiDT4NCTxnIG9wYWNpdHk9IjAuMzAyIj4NCQk8cGF0aCBkPSJNIDYgNiBMIDAgNiBMIDAgNC4yIEwgNCA0LjIgTCA0LjIgNC4yIEwgNC4yIDAgTCA2IDAgTCA2IDYgTCA2IDYgWiIgZmlsbD0iIzAwMDAwMCIvPg0JPC9nPg08L3N2Zz4=);background-position:top left;background-repeat:no-repeat;cursor:se-resize;z-index:20}.gs-resize-handle-x{top:0;bottom:13px;right:-5px;width:10px;cursor:e-resize}.gs-resize-handle-y{left:0;right:13px;bottom:-5px;height:10px;cursor:s-resize}.gs-w:hover .gs-resize-handle,.resizing .gs-resize-handle{opacity:1}.gs-resize-handle,.gs-w.dragging .gs-resize-handle{opacity:0}.gs-resize-disabled .gs-resize-handle,[data-max-sizex="1"] .gs-resize-handle-x,[data-max-sizey="1"] .gs-resize-handle-y,[data-max-sizey="1"][data-max-sizex="1"] .gs-resize-handle{display:none!important}
\ No newline at end of file
diff --git a/dist/jquery.gridster.min.js b/dist/jquery.gridster.min.js
index a0673ea31b..3a56a53a85 100644
--- a/dist/jquery.gridster.min.js
+++ b/dist/jquery.gridster.min.js
@@ -1,2 +1,2 @@
-/*! gridster.js - v0.6.6 - 2015-04-09 - * http://gridster.net/ - Copyright (c) 2015 decksterteam; Licensed MIT */ !function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-coords",["jquery"],b):a.GridsterCoords=b(a.$||a.jQuery)}(this,function(a){function b(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var c=b.prototype;return c.init=function(){this.set(),this.original_coords=this.get()},c.set=function(a,b){var c=this.el;if(c&&!a&&(this.data=c.offset(),this.data.width=c.width(),this.data.height=c.height()),c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return void 0===e.left&&(e.left=e.x1),void 0===e.top&&(e.top=e.y1),this.coords.x1=e.left,this.coords.y1=e.top,this.coords.x2=e.left+e.width,this.coords.y2=e.top+e.height,this.coords.cx=e.left+e.width/2,this.coords.cy=e.top+e.height/2,this.coords.width=e.width,this.coords.height=e.height,this.coords.el=c||!1,this},c.update=function(b){if(!b&&!this.el)return this;if(b){var c=a.extend({},this.data,b);return this.data=c,this.set(!0,!0)}return this.set(!0),this},c.get=function(){return this.coords},c.destroy=function(){this.el.removeData("coords"),delete this.el},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new b(this,arguments[0]);return this.data("coords",a),a},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-collision",["jquery","gridster-coords"],b):a.GridsterCollision=b(a.$||a.jQuery,a.GridsterCoords)}(this,function(a,b){function c(b,c,e){this.options=a.extend(d,e),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],this.set_colliders(c),this.init()}var d={colliders_context:document.body,overlapping_region:"C"};c.defaults=d;var e=c.prototype;return e.init=function(){this.find_collisions()},e.overlaps=function(a,b){var c=!1,d=!1;return(b.x1>=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)&&(c=!0),(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)&&(d=!0),c&&d},e.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2f;f++)-1===a.inArray(e[f],b)&&c.call(this,e[f]);for(var h=0,i=b.length;i>h;h++)-1===a.inArray(b[h],e)&&d.call(this,b[h])},e.find_collisions=function(b){for(var c=this,d=this.options.overlapping_region,e=[],f=[],g=this.colliders||this.$colliders,h=g.length,i=c.$element.coords().update(b||!1).get();h--;){var j=c.$colliders?a(g[h]):g[h],k=j.isCoords?j:j.coords(),l=k.get(),m=c.overlaps(i,l);if(m){var n=c.detect_overlapping_region(i,l);if(n===d||"all"===d){var o=c.calculate_overlapped_area_coords(i,l),p=c.calculate_overlapped_area(o);if(0!==p){var q={area:p,area_coords:o,region:n,coords:l,player_coords:i,el:j};c.options.on_overlap&&c.options.on_overlap.call(this,q),e.push(k),f.push(q)}}}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(e,c.options.on_overlap_start,c.options.on_overlap_stop),this.last_colliders_coords=e,f},e.get_closest_colliders=function(a){var b=this.find_collisions(a);return b.sort(function(a,b){return"C"===a.region&&"C"===b.region?a.coords.y1this.player_max_left?e=this.player_max_left:e=q&&(l=n+h,t>l&&(this.$scroll_container[i](l),this["scroll_offset_"+a]+=h)),r>=s&&(l=n-h,l>0&&(this.$scroll_container[i](l),this["scroll_offset_"+a]-=h)),this},j.manage_scroll=function(a){this.scroll_in("x",a),this.scroll_in("y",a)},j.calculate_dimensions=function(a){this.scroller_height=this.$scroll_container.height(),this.scroller_width=this.$scroll_container.width()},j.drag_handler=function(b){b.target.nodeName;if(!this.disabled&&(1===b.which||f)&&!this.ignore_drag(b)){var c=this,d=!0;return this.$player=a(b.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(b),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$document.on(this.pointer_events.move,function(a){var b=c.get_mouse_pos(a),e=Math.abs(b.left-c.mouse_init_pos.left),f=Math.abs(b.top-c.mouse_init_pos.top);return e>c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging===!0&&c.on_dragmove.call(c,a),!1):!1}),f?void 0:!1}},j.on_dragstart=function(a){if(a.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var b=this.$container.offset();return this.baseX=Math.round(b.left),this.baseY=Math.round(b.top),this.initial_container_width=this.options.container_width||this.$container.width(),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_container_offset_y=this.$scroll_container.scrollTop(),this.scroll_container_offset_x=this.$scroll_container.scrollLeft(),this.scroll_offset_y=0,this.scroll_offset_x=0,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_height=this.$player.height(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,a,this.get_drag_data(a)),!1},j.on_dragmove=function(a){var b=this.get_drag_data(a);this.options.autoscroll&&this.manage_scroll(b),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:b.position.left,top:b.position.top});var c=this.last_position||b.position;return b.prev_position=c,this.options.drag&&this.options.drag.call(this.$player,a,b),this.last_position=b.position,!1},j.on_dragstop=function(a){var b=this.get_drag_data(a);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,a,b),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},j.on_select_start=function(a){return this.disabled||this.ignore_drag(a)?void 0:!1},j.enable=function(){this.disabled=!1},j.disable=function(){this.disabled=!0},j.destroy=function(){this.disable(),this.$container.off(this.ns),this.$document.off(this.ns),d.off(this.ns),a.removeData(this.$container,"drag")},j.ignore_drag=function(b){return this.options.handle?!a(b.target).is(this.options.handle):a.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(b):a(b.target).is(this.options.ignore_dragging.join(", "))},a.fn.gridDraggable=function(a){return new b(this,a)},a.fn.dragg=function(c){return this.each(function(){a.data(this,"drag")||a.data(this,"drag",new b(this,c))})},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery"),require("./jquery.draggable.js"),require("./jquery.collision.js"),require("./jquery.coords.js"),require("./utils.js")):"function"==typeof define&&define.amd?define(["jquery","gridster-draggable","gridster-collision"],b):a.Gridster=b(a.$||a.jQuery,a.GridsterDraggable,a.GridsterCollision)}(this,function(a,b,c){function d(b,c){this.options=a.extend(!0,{},g,c),this.options.draggable=this.options.draggable||{},this.options.draggable=a.extend(!0,{},this.options.draggable,{scroll_container:this.options.scroll_container}),this.$el=a(b),this.$scroll_container=this.options.scroll_container==window?a(window):this.$el.closest(this.options.scroll_container),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=a([]),this.w_queue={},this.min_widget_width=this.options.widget_base_dimensions[0],this.min_widget_height=this.options.widget_base_dimensions[1],this.min_col_count=this.options.min_cols,this.prev_col_count=this.min_col_count,this.is_responsive()&&(this.min_widget_width=this.get_responsive_col_width()),this.generated_stylesheets=[],this.$style_tags=a([]),this.options.auto_init&&this.init()}function e(a){for(var b=["col","row","size_x","size_y"],c={},d=0,e=b.length;e>d;d++){var f=b[d];if(!(f in a))throw new Error("Not exists property `"+f+"`");var g=a[f];if(!g||isNaN(g))throw new Error("Invalid value of `"+f+"` property");c[f]=+g}return c}var f=a(window),g={namespace:"",widget_selector:"li",static_class:"static",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,max_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,auto_init:!0,center_widgets:!1,responsive_breakpoint:!1,scroll_container:window,shift_larger_widgets_down:!0,serialize_params:function(a,b){return{col:b.col,row:b.row,size_x:b.size_x,size_y:b.size_y}},collision:{},draggable:{items:".gs-w:not(.static)",distance:4,ignore_dragging:b.defaults.ignore_dragging.slice(0)},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};d.defaults=g,d.generated_stylesheets=[],d.sort_by_row_asc=function(b){return b=b.sort(function(b,c){return b.row||(b=a(b).coords().grid,c=a(c).coords().grid),b=e(b),c=e(c),b.row>c.row?1:-1})},d.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row>b.row||a.row===b.row&&a.col>b.col?1:-1})},d.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.col>b.col?1:-1})},d.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row+a.size_ythis.cols){var k=i+(b-1)-this.cols,l=i-k;j=Math.max(1,l)}c>h&&this.add_faux_rows(Math.max(c-h,0));var m=g+b-1;m>this.cols&&this.add_faux_cols(m-this.cols);var n={col:j,row:f.row,size_x:b,size_y:c};return this.mutate_widget_in_gridmap(a,f,n),this.set_dom_grid_height(),this.set_dom_grid_width(),e&&e.call(this,n.size_x,n.size_y),a},h.expand_widget=function(b,c,d,e,f){var g=b.coords().grid,h=Math.floor((a(window).width()-2*this.options.widget_margins[0])/this.min_widget_width);c=c||Math.min(h,this.cols),d||(d=g.size_y);var i=g.size_y;b.attr("pre_expand_col",g.col),b.attr("pre_expand_sizex",g.size_x),b.attr("pre_expand_sizey",g.size_y);var j=e||1;d>i&&this.add_faux_rows(Math.max(d-i,0));var k={col:j,row:g.row,size_x:c,size_y:d};return this.mutate_widget_in_gridmap(b,g,k),this.set_dom_grid_height(),this.set_dom_grid_width(),f&&f.call(this,k.size_x,k.size_y),b},h.collapse_widget=function(a,b){var c=a.coords().grid,d=parseInt(a.attr("pre_expand_sizex")),e=parseInt(a.attr("pre_expand_sizey")),f=parseInt(a.attr("pre_expand_col")),g={col:f,row:c.row,size_x:d,size_y:e};return this.mutate_widget_in_gridmap(a,c,g),this.set_dom_grid_height(),this.set_dom_grid_width(),b&&b.call(this,g.size_x,g.size_y),a},h.fit_to_content=function(a,b,c,d){var e=a.coords().grid,f=this.$wrapper.width(),g=this.$wrapper.height(),h=this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0],i=this.options.widget_base_dimensions[1]+2*this.options.widget_margins[1],j=Math.ceil((f+2*this.options.widget_margins[0])/h),k=Math.ceil((g+2*this.options.widget_margins[1])/i),l={col:e.col,row:e.row,size_x:Math.min(b,j),size_y:Math.min(c,k)};return this.mutate_widget_in_gridmap(a,e,l),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,l.size_x,l.size_y),a},h.center_widgets=debounce(function(){var b,c=this.$wrapper.width();b=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0];var d=2*Math.floor(Math.max(Math.floor(c/b),this.min_col_count)/2);this.options.min_cols=d,this.options.max_cols=d,this.options.extra_cols=0,this.options.max_size_x=d,this.set_dom_grid_width(d),this.cols=d;var e=(d-this.prev_col_count)/2;return 0>e?(this.get_min_col()>-1*e?this.shift_cols(e):this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)):e>0?(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.shift_cols(e)},this),0)):(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)),this.prev_col_count=d,this},200),h.get_min_col=function(){return Math.min.apply(Math,this.$widgets.map(a.proxy(function(b,c){return this.get_cells_occupied(a(c).coords().grid).cols},this)).get())},h.shift_cols=function(b){var c=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));c=d.sort_by_row_and_col_asc(c),c.each(a.proxy(function(c,d){var e=a(d.el),f=e.coords().grid,g=parseInt(e.attr("data-col")),h={col:Math.max(Math.round(g+b),1),row:f.row,size_x:f.size_x,size_y:f.size_y};setTimeout(a.proxy(function(){this.mutate_widget_in_gridmap(e,f,h)},this),0)},this))},h.resize_widget_dimensions=function(b){b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1];this.serialize();return this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this},h.mutate_widget_in_gridmap=function(b,c,d){var e=c.size_y,f=this.get_cells_occupied(c),g=this.get_cells_occupied(d),h=[];a.each(f.cols,function(b,c){-1===a.inArray(c,g.cols)&&h.push(c)});var i=[];a.each(g.cols,function(b,c){-1===a.inArray(c,f.cols)&&i.push(c)});var j=[];a.each(f.rows,function(b,c){-1===a.inArray(c,g.rows)&&j.push(c)});var k=[];if(a.each(g.rows,function(b,c){-1===a.inArray(c,f.rows)&&k.push(c)}),this.remove_from_gridmap(c),i.length){var l=[d.col,d.row,d.size_x,Math.min(e,d.size_y),b];this.empty_cells.apply(this,l)}if(k.length){var m=[d.col,d.row,d.size_x,d.size_y,b];this.empty_cells.apply(this,m)}if(c.col=d.col,c.row=d.row,c.size_x=d.size_x,c.size_y=d.size_y,this.add_to_gridmap(d,b),b.removeClass("player-revert"),b.data("coords").update({width:d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],height:d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1]}),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),h.length){var n=[h[0],d.row,h[h.length-1]-h[0]+1,Math.min(e,d.size_y),b];this.remove_empty_cells.apply(this,n)}if(j.length){var o=[d.col,d.row,d.size_x,d.size_y,b];this.remove_empty_cells.apply(this,o)}return this.move_widget_up(b),this},h.empty_cells=function(b,c,d,e,f){var g=this.widgets_below({col:b,row:c-e,size_x:d,size_y:e});return g.not(f).each(a.proxy(function(b,d){var f=a(d),g=f.coords().grid;if(g.row<=c+e-1){var h=c+e-g.row;this.move_widget_down(f,h)}},this)),this.set_dom_grid_height(),this},h.remove_empty_cells=function(a,b,c,d,e){this.widgets_below({col:a,row:b,size_x:c,size_y:d});return this.set_dom_grid_height(),this},h.next_position=function(a,b){a||(a=1),b||(b=1);for(var c,e=this.gridmap,f=e.length,g=[],h=1;f>h;h++){c=e[h].length;for(var i=1;c>=i;i++){var j=this.can_move_to({size_x:a,size_y:b},h,i);j&&g.push({col:h,row:i,size_y:b,size_x:a})}}return g.length?d.sort_by_row_and_col_asc(g)[0]:!1},h.remove_by_grid=function(a,b){var c=this.is_widget(a,b);c&&this.remove_widget(c)},h.remove_widget=function(b,c,d){var e=b instanceof a?b:a(b),f=e.coords().grid;a.isFunction(c)&&(d=c,c=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(e);var g=this.widgets_below(e);return this.remove_from_gridmap(f),e.fadeOut(a.proxy(function(){e.remove(),c||g.each(a.proxy(function(b,c){this.move_widget_up(a(c),f.size_y)},this)),this.set_dom_grid_height(),d&&d.call(this,b)},this)),this},h.remove_all_widgets=function(b){return this.$widgets.each(a.proxy(function(a,c){this.remove_widget(c,!0,b)},this)),this},h.serialize=function(b){b||(b=this.$widgets);var c=[];b.each(a.proxy(function(b,d){"undefined"!=typeof a(d).coords().grid&&c.push(this.options.serialize_params($w,$w.coords().grid))},this))},h.serialize_changed=function(){return this.serialize(this.$changed)},h.dom_to_coords=function(a){return{col:parseInt(a.attr("data-col"),10),row:parseInt(a.attr("data-row"),10),size_x:parseInt(a.attr("data-sizex"),10)||1,size_y:parseInt(a.attr("data-sizey"),10)||1,max_size_x:parseInt(a.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(a.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(a.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(a.attr("data-min-sizey"),10)||!1,el:a}},h.register_widget=function(b){var c=b instanceof a,d=c?this.dom_to_coords(b):b,e=!1;c||(b=d.el);var f=this.can_go_widget_up(d);if(f&&(d.row=f,b.attr("data-row",f),this.$el.trigger("gridster:positionchanged",[d]),e=!0),this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:d.size_x,size_y:d.size_y},d.col,d.row)){if(!b.hasClass(".disp_ad"))return b.remove(),!1;a.extend(d,this.next_position(d.size_x,d.size_y)),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),e=!0}return b.data("coords",b.coords()),b.data("coords").grid=d,this.add_to_gridmap(d,b),this.options.resize.enabled&&this.add_resize_handle(b),e},h.update_widget_position=function(a,b){return this.for_each_cell_occupied(a,function(a,c){return this.gridmap[a]?void(this.gridmap[a][c]=b):this}),this},h.update_widget_dimensions=function(a,b,c){return a.data("coords").update({width:b,height:c}),this},h.update_widgets_dimensions=function(){return a.each(this.$widgets,a.proxy(function(b,c){var d=a(c).coords().grid,e=d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],f=d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1];this.update_widget_dimensions(a(c),e,f)},this)),this},h.remove_from_gridmap=function(a){return this.update_widget_position(a,!1)},h.add_to_gridmap=function(a,b){this.update_widget_position(a,b||a.el)},h.draggable=function(){var b=this,c=a.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0],limit:!0,start:function(c,d){b.$widgets.filter(".player-revert").removeClass("player-revert"),b.$player=a(this),b.$helper=a(d.$helper),b.helper=!b.$helper.is(b.$player),b.on_start_drag.call(b,c,d),b.$el.trigger("gridster:dragstart")},stop:function(a,c){b.on_stop_drag.call(b,a,c),b.$el.trigger("gridster:dragstop")},drag:throttle(function(a,c){b.on_drag.call(b,a,c),b.$el.trigger("gridster:drag")},60)});this.drag_api=this.$el.dragg(c).data("drag")},h.resizable=function(){return this.resize_api=this.$el.gridDraggable({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,scroll_container:this.options.scroll_container,start:a.proxy(this.on_start_resize,this),stop:a.proxy(function(b,c){delay(a.proxy(function(){this.on_stop_resize(b,c)},this),120)},this),drag:throttle(a.proxy(this.on_resize,this),60)}),this},h.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var b=this.options.resize.axes,c=' ';return this.resize_handle_tpl=a.map(b,function(a){return c.replace("{type}",a)}).join(""),a.isArray(this.options.draggable.ignore_dragging)&&this.options.draggable.ignore_dragging.push("."+this.resize_handle_class),this},h.on_start_drag=function(b,c){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=a.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var d=this.player_grid_data.size_x,e=this.cols-this.highest_col;this.options.autogrow_cols&&d>=e&&this.add_faux_cols(Math.min(d-e,1));var f=this.faux_grid,g=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(f,this.options.collision),this.$preview_holder=a("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:g.width,height:g.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},h.on_drag=function(a,b){if(null===this.$player)return!1;var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};if(this.options.autogrow_cols){var d=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;d>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(c),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},h.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.w_queue={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])},h.on_start_resize=function(b,c){this.$resized_widget=c.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:c.$player.is("."+this.resize_handle_class+"-x"),bottom:c.$player.is("."+this.resize_handle_class+"-y")},this.is_responsive()||this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var d=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=a("<"+d+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,b,c,this.$resized_widget),
-this.$el.trigger("gridster:resizestart")},h.on_stop_resize=function(b,c){this.$resized_widget.removeClass("resizing").css({width:"",height:"","min-width":"","min-height":""}),delay(a.proxy(function(){this.$resize_preview_holder.remove().css({"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},h.on_resize=function(a,b){var c,d=b.pointer.diff_left,e=b.pointer.diff_top,f=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0],g=this.options.widget_base_dimensions[1],h=this.options.widget_margins[0],i=this.options.widget_margins[1],j=this.resize_max_size_x,k=this.resize_min_size_x,l=this.resize_max_size_y,m=this.resize_min_size_y,n=this.options.autogrow_cols,o=Math.ceil(d/(f+2*h)-.2),p=Math.ceil(e/(g+2*i)-.2),q=Math.max(1,this.resize_initial_sizex+o),r=Math.max(1,this.resize_initial_sizey+p),s=Math.floor(this.container_width/this.min_widget_width-this.resize_initial_col+1),t=s*this.min_widget_width+(s-1)*h;if(q=Math.max(Math.min(q,j),k),q=Math.min(s,q),c=j*f+(q-1)*h,max_width=Math.min(c,t),min_width=k*f+(q-1)*h,r=Math.max(Math.min(r,l),m),max_height=l*g+(r-1)*i,min_height=m*g+(r-1)*i,this.resize_dir.right?r=this.resize_initial_sizey:this.resize_dir.bottom&&(q=this.resize_initial_sizex),n){var u=this.resize_initial_col+q-1;n&&this.resize_initial_last_col<=u&&(this.set_dom_grid_width(Math.max(u+1,this.cols)),this.colsd;d++)-1===a.inArray(e[d],this.last_cols)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_cols[d],e)&&(c||a.noop).call(this,this.last_cols[d]);return this.last_cols=e,this},h.on_overlapped_row_change=function(b,c){if(!this.colliders_data.length)return this;var d,e=this.get_targeted_rows(this.colliders_data[0].el.data.row),f=this.last_rows.length,g=e.length;for(d=0;g>d;d++)-1===a.inArray(e[d],this.last_rows)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_rows[d],e)&&(c||a.noop).call(this,this.last_rows[d]);this.last_rows=e},h.set_player=function(b,c,d){var e=this,f=!1;d||this.empty_cells_player_occupies();var g=d?{col:b}:e.colliders_data[0].el.data,h=g.col,i=g.row||c;this.player_grid_data={col:h,row:i,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data);var j=this.get_widgets_overlapped(this.player_grid_data),k=this.player_grid_data.size_y,l=this.player_grid_data.size_x,m=this.cells_occupied_by_placeholder,n=this;if(j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,g=m.cols[0]+l-1,o=m.rows[0]+k-1;if(d.hasClass(n.options.static_class))return!0;if(e.size_x<=l&&e.size_y<=k)if(n.is_swap_occupied(m.cols[0],e.row,e.size_x,e.size_y)||n.is_player_in(m.cols[0],e.row)||n.is_in_queue(m.cols[0],e.row,d))if(n.is_swap_occupied(g,e.row,e.size_x,e.size_y)||n.is_player_in(g,e.row)||n.is_in_queue(g,e.row,d))if(n.is_swap_occupied(e.col,m.rows[0],e.size_x,e.size_y)||n.is_player_in(e.col,m.rows[0])||n.is_in_queue(e.col,m.rows[0],d))if(n.is_swap_occupied(e.col,o,e.size_x,e.size_y)||n.is_player_in(e.col,o)||n.is_in_queue(e.col,o,d))if(n.is_swap_occupied(m.cols[0],m.rows[0],e.size_x,e.size_y)||n.is_player_in(m.cols[0],m.rows[0])||n.is_in_queue(m.cols[0],m.rows[0],d))for(var p=0;l>p;p++)for(var q=0;k>q;q++){var r=m.cols[0]+p,s=m.rows[0]+q;if(!n.is_swap_occupied(r,s,e.size_x,e.size_y)&&!n.is_player_in(r,s)&&!n.is_in_queue(r,s,d)){f=n.queue_widget(r,s,d),p=l;break}}else f=n.queue_widget(m.cols[0],m.rows[0],d);else f=n.queue_widget(e.col,o,d);else f=n.queue_widget(e.col,m.rows[0],d);else f=n.queue_widget(g,e.row,d);else f=n.queue_widget(m.cols[0],e.row,d);else n.options.shift_larger_widgets_down&&!f&&j.each(a.proxy(function(b,c){{var d=a(c);d.coords().grid}n.can_go_down(d)&&(n.move_widget_down(d,n.player_grid_data.size_y),n.set_placeholder(h,i))}));n.clean_up_changed()})),f&&this.can_placeholder_be_set(h,i,l,k)){for(var o in this.w_queue){var b=parseInt(o.split("_")[0]),c=parseInt(o.split("_")[1]);"full"!=this.w_queue[o]&&this.new_move_widget_to(this.w_queue[o],b,c)}this.set_placeholder(h,i)}if(!j.length){var p=this.can_go_player_up(this.player_grid_data);p!==!1&&(i=p),this.can_placeholder_be_set(h,i,l,k)&&this.set_placeholder(h,i)}return this.w_queue={},{col:h,row:i}},h.is_swap_occupied=function(a,b,c,d){for(var e=!1,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=h+"_"+i;if(this.is_occupied(h,i))e=!0;else if(j in this.w_queue){if("full"==this.w_queue[j]){e=!0;continue}$tw=this.w_queue[j],tgd=$tw.coords().grid,this.is_widget_under_player(tgd.col,tgd.row)||delete this.w_queue[j]}i>parseInt(this.options.max_rows)&&(e=!0),h>parseInt(this.options.max_cols)&&(e=!0),this.is_player_in(h,i)&&(e=!0)}return e},h.can_placeholder_be_set=function(a,b,c,d){for(var e=!0,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=this.is_widget(h,i);i>parseInt(this.options.max_rows)&&(e=!1),h>parseInt(this.options.max_cols)&&(e=!1),this.is_occupied(h,i)&&!this.is_widget_queued_and_can_move(j)&&(e=!1)}return e},h.queue_widget=function(a,b,c){var d=c,e=d.coords().grid,f=a+"_"+b;if(f in this.w_queue)return!1;this.w_queue[f]=d;for(var g=0;g=0&&a.inArray(c,d.rows)>=0},h.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},h.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},h.is_empty=function(a,b){return"undefined"!=typeof this.gridmap[a]?"undefined"!=typeof this.gridmap[a][b]&&this.gridmap[a][b]===!1?!0:!1:!0},h.is_occupied=function(a,b){return this.gridmap[a]&&this.gridmap[a][b]?!0:!1},h.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},h.is_static=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c&&c.hasClass(this.options.static_class)?!0:!1):!1},h.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},h.get_widgets_under_player=function(b){b||(b=this.cells_occupied_by_player||{cols:[],rows:[]});var c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},h.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b-=f-b);var g=this.placeholder_grid_data.row0&&(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f));)d[a].push(h),e=e>h?h:e;return 0===d[a].length?(c=!1,!0):void d[a].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.can_go_widget_up=function(a){var b=a.row+a.size_y-1,c=!0,d=[],e=1e4;return this.for_each_column_occupied(a,function(f){var g=this.gridmap[f];d[f]=[];for(var h=b+1;--h>0&&(!this.is_widget(f,h)||this.is_player_in(f,h)||g[h].is(a.el));)this.is_player(f,h)||this.is_placeholder_in(f,h)||this.is_player_in(f,h)||d[f].push(h),e>h&&(e=h);return 0===d[f].length?(c=!1,!0):void d[f].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.get_valid_rows=function(b,c,d){for(var e=b.row,f=b.row+b.size_y-1,g=b.size_y,h=d-1,i=[];++h<=f;){var j=!0;if(a.each(c,function(b,c){a.isArray(c)&&-1===a.inArray(h,c)&&(j=!1)}),j===!0&&(i.push(h),i.length===g))break}var k=!1;return 1===g?i[0]!==e&&(k=i[0]||!1):i[0]!==e&&(k=this.get_consecutive_numbers_index(i,g)),k},h.get_consecutive_numbers_index=function(a,b){for(var c=a.length,d=[],e=!0,f=-1,g=0;c>g;g++){if(e||a[g]===f+1){if(d.push(g),d.length===b)break;e=!1}else d=[],e=!0;f=a[g]}return d.length>=b?a[d[0]]:!1},h.get_widgets_overlapped=function(){var b=a([]),c=[],d=this.cells_occupied_by_player.rows.slice(0);return d.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(e,f){a.each(d,a.proxy(function(d,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&-1===a.inArray(g,c)&&(b=b.add(g),c.push(g))},this))},this)),b},h.on_start_overlapping_column=function(a){this.set_player(a,!1)},h.on_start_overlapping_row=function(a){this.set_player(!1,a)},h.on_stop_overlapping_column=function(a){var b=this;this.options.shift_larger_widgets_down&&this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},h.on_stop_overlapping_row=function(a){var b=this,c=this.cells_occupied_by_player.cols;if(this.options.shift_larger_widgets_down)for(var d=0,e=c.length;e>d;d++)this.for_each_widget_below(c[d],a,function(a,c){console.log("from_on_stop_overlapping_row"),b.move_widget_up(this,b.player_grid_data.size_y)})},h.new_move_widget_to=function(a,b,c){var d=a.coords().grid;return this.remove_from_gridmap(d),d.row=c,d.col=b,this.add_to_gridmap(d),a.attr("data-row",c),a.attr("data-col",b),this.update_widget_position(d,a),this.$changed=this.$changed.add(a),this},h.move_widget=function(a,b,c,d){var e=a.coords().grid,f={col:b,row:c,size_x:e.size_x,size_y:e.size_y};return this.mutate_widget_in_gridmap(a,e,f),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,f.col,f.row),a},h.move_widget_to=function(b,c){var d=this,e=b.coords().grid,f=(c-e.row,this.widgets_below(b)),g=this.can_move_to(e,e.col,c,b);return g===!1?!1:(this.remove_from_gridmap(e),e.row=c,this.add_to_gridmap(e),b.attr("data-row",c),this.$changed=this.$changed.add(b),f.each(function(b,c){var e=a(c),f=e.coords().grid,g=d.can_go_widget_up(f);g&&g!==f.row&&d.move_widget_to(e,g)}),this)},h.move_widget_up=function(b,c){var d=b.coords().grid,e=d.row,f=[];return c||(c=1),this.can_go_up(b)?void this.for_each_column_occupied(d,function(d){if(-1===a.inArray(b,f)){var g=b.coords().grid,h=e-c;if(h=this.can_go_up_to_row(g,d,h),!h)return!0;{this.widgets_below(b)}this.remove_from_gridmap(g),g.row=h,this.add_to_gridmap(g),b.attr("data-row",g.row),this.$changed=this.$changed.add(b),f.push(b)}}):!1},h.move_widget_down=function(b,c){var d,e,f,g;if(0>=c)return!1;if(d=b.coords().grid,e=d.row,f=[],g=c,!b)return!1;if(-1===a.inArray(b,f)){var h=b.coords().grid,i=e+c,j=this.widgets_below(b);this.remove_from_gridmap(h),j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,f=this.displacement_diff(e,h,g);f>0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},h.can_go_up_to_row=function(b,c,d){var e,f=this.gridmap,g=!0,h=[],i=b.row;if(this.for_each_column_occupied(b,function(a){f[a];for(h[a]=[],e=i;e--&&this.is_empty(a,e)&&!this.is_placeholder_in(a,e);)h[a].push(e);return h[a].length?void 0:(g=!1,!0)}),!g)return!1;for(e=d,e=1;i>e;e++){for(var j=!0,k=0,l=h.length;l>k;k++)h[k]&&-1===a.inArray(e,h[k])&&(j=!1);if(j===!0){g=e;break}}return g},h.displacement_diff=function(a,b,c){var d=a.row,e=[],f=b.row+b.size_y;this.for_each_column_occupied(a,function(a){for(var b=0,c=f;d>c;c++)this.is_empty(a,c)&&(b+=1);e.push(b)});var g=Math.max.apply(Math,e);return c-=g,c>0?c:0},h.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,e=this,f=(this.gridmap,c.row+c.size_y-1),g=a([]);return this.for_each_column_occupied(c,function(b){e.for_each_widget_below(b,f,function(b,c){return e.is_player(this)||-1!==a.inArray(this,g)?void 0:(g=g.add(this),!0)})}),d.sort_by_row_asc(g)},h.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},h.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},h.can_go_down=function(b){var c=!0,d=this;return b.hasClass(this.options.static_class)&&(c=!1),this.widgets_below(b).each(function(){a(this).hasClass(d.options.static_class)&&(c=!1)}),c},h.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=(this.gridmap,!0);return 1===c?!1:(this.for_each_column_occupied(b,function(a){this.is_widget(a,d);return this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d)||this.is_player_in(a,d)?(e=!1,!0):void 0}),e)},h.can_move_to=function(a,b,c,d){var e=(this.gridmap,a.el),f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:d&&d=d;d++)c.push(d);return c},h.get_targeted_rows=function(a){for(var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[],d=a;b>=d;d++)c.push(d);return c},h.get_cells_occupied=function(b){var c,d={cols:[],rows:[]};for(arguments[1]instanceof a&&(b=arguments[1].coords().grid),c=0;c0&&this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]),h)););},"for_each/below":function(){for(m=e+1,i=g[d].length;i>m;m++)this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]))}};n[j]&&n[j].call(this)}},h.for_each_widget_above=function(a,b,c){return this._traversing_widgets("for_each","above",a,b,c),this},h.for_each_widget_below=function(a,b,c){return this._traversing_widgets("for_each","below",a,b,c),this},h.get_highest_occupied_cell=function(){for(var a,b=this.gridmap,c=b[1].length,d=[],e=[],f=b.length-1;f>=1;f--)for(a=c-1;a>=1;a--)if(this.is_widget(f,a)){d.push(a),e.push(f);break}return{col:Math.max.apply(Math,e),row:Math.max.apply(Math,d)}},h.get_widgets_from=function(b,c){var d=(this.gridmap,a());return b&&(d=d.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c===b||c>b}))),c&&(d=d.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b===c||b>c}))),d},h.set_dom_grid_height=function(a){if("undefined"==typeof a){var b=this.get_highest_occupied_cell().row;a=(b+1)*this.options.widget_margins[1]+b*this.min_widget_height}return this.container_height=a,this.$el.css("height",this.container_height),this},h.set_dom_grid_width=function(a){"undefined"==typeof a&&(a=this.get_highest_occupied_cell().col);var b=this.options.autogrow_cols?this.options.max_cols:this.cols;return a=Math.min(b,Math.max(a,this.options.min_cols)),this.container_width=(a+1)*this.options.widget_margins[0]+a*this.min_widget_width,this.is_responsive()?(this.$el.css({"min-width":"100vw","max-width":"100vw"}),this):(this.$el.css("width",this.container_width),this)},h.is_responsive=function(){return this.options.autogenerate_stylesheet&&"auto"===this.options.widget_base_dimensions[0]&&this.options.max_cols!==1/0},h.get_responsive_col_width=function(){var a=this.cols||this.options.max_cols;return(this.$el.width()-(a+1)*this.options.widget_margins[0])/a},h.resize_responsive_layout=function(){return this.min_widget_width=this.get_responsive_col_width(),this.generate_stylesheet(),this.update_widgets_dimensions(),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0]),this},h.toggle_collapsed_grid=function(a,b){return a?(this.$widgets.css({"margin-top":b.widget_margins[0],"margin-bottom":b.widget_margins[0],"min-height":b.widget_base_dimensions[1]}),this.$el.addClass("collapsed"),this.resize_api&&this.disable_resize(),this.drag_api&&this.disable()):(this.$widgets.css({"margin-top":"auto","margin-bottom":"auto","min-height":"auto"}),this.$el.removeClass("collapsed"),this.resize_api&&this.enable_resize(),this.drag_api&&this.enable()),this},h.generate_stylesheet=function(b){var c,e="",f=this.options.max_size_x||this.cols,g=this.is_responsive()&&this.options.responsive_breakpoint&&a(window).width()=0)return!1;for(this.generated_stylesheets.push(h),d.generated_stylesheets.push(h),c=1;c<=b.cols+1;c++)e+=b.namespace+' [data-col="'+c+'"] { left:'+(g?this.options.widget_margins[0]:c*b.widget_margins[0]+(c-1)*b.widget_base_dimensions[0])+"px; }\n";for(c=1;c<=b.rows+1;c++)e+=b.namespace+' [data-row="'+c+'"] { top:'+(c*b.widget_margins[1]+(c-1)*b.widget_base_dimensions[1])+"px; }\n";for(var i=1;i<=b.rows;i++)e+=b.namespace+' [data-sizey="'+i+'"] { height:'+(g?"auto":i*b.widget_base_dimensions[1]+(i-1)*b.widget_margins[1])+"px; }\n";for(var j=1;f>=j;j++)e+=b.namespace+' [data-sizex="'+j+'"] { width:'+(g?a(window).width()-2*this.options.widget_margins[0]:j*b.widget_base_dimensions[0]+(j-1)*b.widget_margins[0])+"px; }\n";return this.remove_style_tags(),this.add_style_tag(e)},h.add_style_tag=function(a){var b=document;if(!document.getElementById("gridster-stylesheet")){var c=b.createElement("style");c.id="gridster-stylesheet",b.getElementsByTagName("head")[0].appendChild(c),c.setAttribute("type","text/css"),c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a)),this.remove_style_tags(),this.$style_tags=this.$style_tags.add(c)}return this},h.remove_style_tags=function(){var b=d.generated_stylesheets,c=this.generated_stylesheets;this.$style_tags.remove(),d.generated_stylesheets=a.map(b,function(b){return-1===a.inArray(b,c)?b:void 0})},h.generate_faux_grid=function(a,b){this.faux_grid=[],this.gridmap=[];var c,d;for(c=b;c>0;c--)for(this.gridmap[c]=[],d=a;d>0;d--)this.add_faux_cell(d,c);return this},h.add_faux_cell=function(b,c){var d=a({left:this.baseX+(c-1)*this.min_widget_width,top:this.baseY+(b-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:c,row:b,original_col:c,original_row:b}).coords();return a.isArray(this.gridmap[c])||(this.gridmap[c]=[]),"undefined"==typeof this.gridmap[c][b]&&(this.gridmap[c][b]=!1),this.faux_grid.push(d),this},h.add_faux_rows=function(a){a=window.parseInt(a,10);for(var b=this.rows,c=b+parseInt(a||1),d=c;d>b;d--)for(var e=this.cols;e>=1;e--)this.add_faux_cell(d,e);return this.rows=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.add_faux_cols=function(a){a=window.parseInt(a,10);var b=this.cols,c=b+parseInt(a||1);c=Math.min(c,this.options.max_cols);for(var d=b+1;c>=d;d++)for(var e=this.rows;e>=1;e--)this.add_faux_cell(e,d);return this.cols=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.recalculate_faux_grid=function(){var b=this.$wrapper.width();return this.baseX=(f.width()-b)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this.is_responsive()&&this.resize_responsive_layout(),this.options.center_widgets&&this.center_widgets(),this},h.resize_widget_dimensions=function(b){return b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this},h.get_widgets_from_DOM=function(){var b=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));b=d.sort_by_row_and_col_asc(b);var c=a(b).map(a.proxy(function(a,b){return this.register_widget(b)||null},this));return c.length&&this.$el.trigger("gridster:positionschanged"),this},h.set_num_columns=function(b){var c=this.options.max_cols,d=Math.floor(b/(this.min_widget_width+this.options.widget_margins[0]))+this.options.extra_cols,e=this.$widgets.map(function(){return a(this).attr("data-col")}).get();e.length||(e=[0]);var f=Math.max.apply(Math,e);this.cols=Math.max(f,d,this.options.min_cols),c!==1/0&&c>=f&&c=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)&&(c=!0),(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)&&(d=!0),c&&d},e.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2f;f++)-1===a.inArray(e[f],b)&&c.call(this,e[f]);for(var h=0,i=b.length;i>h;h++)-1===a.inArray(b[h],e)&&d.call(this,b[h])},e.find_collisions=function(b){for(var c=this,d=this.options.overlapping_region,e=[],f=[],g=this.colliders||this.$colliders,h=g.length,i=c.$element.coords().update(b||!1).get();h--;){var j=c.$colliders?a(g[h]):g[h],k=j.isCoords?j:j.coords(),l=k.get(),m=c.overlaps(i,l);if(m){var n=c.detect_overlapping_region(i,l);if(n===d||"all"===d){var o=c.calculate_overlapped_area_coords(i,l),p=c.calculate_overlapped_area(o);if(0!==p){var q={area:p,area_coords:o,region:n,coords:l,player_coords:i,el:j};c.options.on_overlap&&c.options.on_overlap.call(this,q),e.push(k),f.push(q)}}}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(e,c.options.on_overlap_start,c.options.on_overlap_stop),this.last_colliders_coords=e,f},e.get_closest_colliders=function(a){var b=this.find_collisions(a);return b.sort(function(a,b){return"C"===a.region&&"C"===b.region?a.coords.y1this.player_max_left?e=this.player_max_left:e=q&&(l=n+h,t>l&&(this.$scroll_container[i](l),this["scroll_offset_"+a]+=h)),r>=s&&(l=n-h,l>0&&(this.$scroll_container[i](l),this["scroll_offset_"+a]-=h)),this},j.manage_scroll=function(a){this.scroll_in("x",a),this.scroll_in("y",a)},j.calculate_dimensions=function(){this.scroller_height=this.$scroll_container.height(),this.scroller_width=this.$scroll_container.width()},j.drag_handler=function(b){if(!this.disabled&&(1===b.which||f)&&!this.ignore_drag(b)){var c=this,d=!0;return this.$player=a(b.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(b),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$document.on(this.pointer_events.move,function(a){var b=c.get_mouse_pos(a),e=Math.abs(b.left-c.mouse_init_pos.left),f=Math.abs(b.top-c.mouse_init_pos.top);return e>c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging===!0&&c.on_dragmove.call(c,a),!1):!1}),f?void 0:!1}},j.on_dragstart=function(a){if(a.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var b=this.$container.offset();return this.baseX=Math.round(b.left),this.baseY=Math.round(b.top),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_container_offset_y=this.$scroll_container.scrollTop(),this.scroll_container_offset_x=this.$scroll_container.scrollLeft(),this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,a,this.get_drag_data(a)),!1},j.on_dragmove=function(a){var b=this.get_drag_data(a);this.options.autoscroll&&this.manage_scroll(b),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:b.position.left,top:b.position.top});var c=this.last_position||b.position;return b.prev_position=c,this.options.drag&&this.options.drag.call(this.$player,a,b),this.last_position=b.position,!1},j.on_dragstop=function(a){var b=this.get_drag_data(a);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,a,b),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},j.on_select_start=function(a){return this.disabled||this.ignore_drag(a)?void 0:!1},j.enable=function(){this.disabled=!1},j.disable=function(){this.disabled=!0},j.destroy=function(){this.disable(),this.$container.off(this.ns),this.$document.off(this.ns),d.off(this.ns),a.removeData(this.$container,"drag")},j.ignore_drag=function(b){return this.options.handle?!a(b.target).is(this.options.handle):a.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(b):a(b.target).is(this.options.ignore_dragging.join(", "))},a.fn.gridDraggable=function(a){return new b(this,a)},a.fn.dragg=function(c){return this.each(function(){a.data(this,"drag")||a.data(this,"drag",new b(this,c))})},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery"),require("./jquery.draggable.js"),require("./jquery.collision.js"),require("./jquery.coords.js"),require("./utils.js")):"function"==typeof define&&define.amd?define(["jquery","gridster-draggable","gridster-collision"],b):a.Gridster=b(a.$||a.jQuery,a.GridsterDraggable,a.GridsterCollision)}(this,function(a,b,c){function d(b,c){this.options=a.extend(!0,{},g,c),this.options.draggable=this.options.draggable||{},this.options.draggable=a.extend(!0,{},this.options.draggable,{scroll_container:this.options.scroll_container}),this.$el=a(b),this.$scroll_container=this.options.scroll_container===window?a(window):this.$el.closest(this.options.scroll_container),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=a([]),this.w_queue={},this.min_widget_width=this.options.widget_base_dimensions[0],this.min_widget_height=this.options.widget_base_dimensions[1],this.min_col_count=this.options.min_cols,this.prev_col_count=this.min_col_count,this.is_responsive()&&(this.min_widget_width=this.get_responsive_col_width()),this.generated_stylesheets=[],this.$style_tags=a([]),this.options.auto_init&&this.init()}function e(a){for(var b=["col","row","size_x","size_y"],c={},d=0,e=b.length;e>d;d++){var f=b[d];if(!(f in a))throw new Error("Not exists property `"+f+"`");var g=a[f];if(!g||isNaN(g))throw new Error("Invalid value of `"+f+"` property");c[f]=+g}return c}var f=a(window),g={namespace:"",widget_selector:"li",static_class:"static",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,max_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,auto_init:!0,center_widgets:!1,responsive_breakpoint:!1,scroll_container:window,shift_larger_widgets_down:!0,serialize_params:function(a,b){return{col:b.col,row:b.row,size_x:b.size_x,size_y:b.size_y}},collision:{},draggable:{items:".gs-w:not(.static)",distance:4,ignore_dragging:b.defaults.ignore_dragging.slice(0)},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};d.defaults=g,d.generated_stylesheets=[],d.sort_by_row_asc=function(b){return b=b.sort(function(b,c){return b.row||(b=a(b).coords().grid,c=a(c).coords().grid),b=e(b),c=e(c),b.row>c.row?1:-1})},d.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row>b.row||a.row===b.row&&a.col>b.col?1:-1})},d.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.col>b.col?1:-1})},d.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row+a.size_ythis.cols){var k=i+(b-1)-this.cols,l=i-k;j=Math.max(1,l)}c>h&&this.add_faux_rows(Math.max(c-h,0));var m=g+b-1;m>this.cols&&this.add_faux_cols(m-this.cols);var n={col:j,row:f.row,size_x:b,size_y:c};return this.mutate_widget_in_gridmap(a,f,n),this.set_dom_grid_height(),this.set_dom_grid_width(),e&&e.call(this,n.size_x,n.size_y),a},h.expand_widget=function(b,c,d,e,f){var g=b.coords().grid,h=Math.floor((a(window).width()-2*this.options.widget_margins[0])/this.min_widget_width);c=c||Math.min(h,this.cols),d||(d=g.size_y);var i=g.size_y;b.attr("pre_expand_col",g.col),b.attr("pre_expand_sizex",g.size_x),b.attr("pre_expand_sizey",g.size_y);var j=e||1;d>i&&this.add_faux_rows(Math.max(d-i,0));var k={col:j,row:g.row,size_x:c,size_y:d};return this.mutate_widget_in_gridmap(b,g,k),this.set_dom_grid_height(),this.set_dom_grid_width(),f&&f.call(this,k.size_x,k.size_y),b},h.collapse_widget=function(a,b){var c=a.coords().grid,d=parseInt(a.attr("pre_expand_sizex")),e=parseInt(a.attr("pre_expand_sizey")),f=parseInt(a.attr("pre_expand_col")),g={col:f,row:c.row,size_x:d,size_y:e};return this.mutate_widget_in_gridmap(a,c,g),this.set_dom_grid_height(),this.set_dom_grid_width(),b&&b.call(this,g.size_x,g.size_y),a},h.fit_to_content=function(a,b,c,d){var e=a.coords().grid,f=this.$wrapper.width(),g=this.$wrapper.height(),h=this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0],i=this.options.widget_base_dimensions[1]+2*this.options.widget_margins[1],j=Math.ceil((f+2*this.options.widget_margins[0])/h),k=Math.ceil((g+2*this.options.widget_margins[1])/i),l={col:e.col,row:e.row,size_x:Math.min(b,j),size_y:Math.min(c,k)};return this.mutate_widget_in_gridmap(a,e,l),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,l.size_x,l.size_y),a},h.center_widgets=debounce(function(){var b,c=this.$wrapper.width();b=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0];var d=2*Math.floor(Math.max(Math.floor(c/b),this.min_col_count)/2);this.options.min_cols=d,this.options.max_cols=d,this.options.extra_cols=0,this.options.max_size_x=d,this.set_dom_grid_width(d),this.cols=d;var e=(d-this.prev_col_count)/2;return 0>e?(this.get_min_col()>-1*e?this.shift_cols(e):this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)):e>0?(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.shift_cols(e)},this),0)):(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)),this.prev_col_count=d,this},200),h.get_min_col=function(){return Math.min.apply(Math,this.$widgets.map(a.proxy(function(b,c){return this.get_cells_occupied(a(c).coords().grid).cols},this)).get())},h.shift_cols=function(b){var c=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));c=d.sort_by_row_and_col_asc(c),c.each(a.proxy(function(c,d){var e=a(d.el),f=e.coords().grid,g=parseInt(e.attr("data-col")),h={col:Math.max(Math.round(g+b),1),row:f.row,size_x:f.size_x,size_y:f.size_y};setTimeout(a.proxy(function(){this.mutate_widget_in_gridmap(e,f,h)},this),0)},this))},h.resize_widget_dimensions=function(b){b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1];this.serialize();return this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this},h.mutate_widget_in_gridmap=function(b,c,d){var e=c.size_y,f=this.get_cells_occupied(c),g=this.get_cells_occupied(d),h=[];a.each(f.cols,function(b,c){-1===a.inArray(c,g.cols)&&h.push(c)});var i=[];a.each(g.cols,function(b,c){-1===a.inArray(c,f.cols)&&i.push(c)});var j=[];a.each(f.rows,function(b,c){-1===a.inArray(c,g.rows)&&j.push(c)});var k=[];if(a.each(g.rows,function(b,c){-1===a.inArray(c,f.rows)&&k.push(c)}),this.remove_from_gridmap(c),i.length){var l=[d.col,d.row,d.size_x,Math.min(e,d.size_y),b];this.empty_cells.apply(this,l)}if(k.length){var m=[d.col,d.row,d.size_x,d.size_y,b];this.empty_cells.apply(this,m)}if(c.col=d.col,c.row=d.row,c.size_x=d.size_x,c.size_y=d.size_y,this.add_to_gridmap(d,b),b.removeClass("player-revert"),b.data("coords").update({width:d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],height:d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1]}),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),h.length){var n=[h[0],d.row,h[h.length-1]-h[0]+1,Math.min(e,d.size_y),b];this.remove_empty_cells.apply(this,n)}if(j.length){var o=[d.col,d.row,d.size_x,d.size_y,b];this.remove_empty_cells.apply(this,o)}return this.move_widget_up(b),this},h.empty_cells=function(b,c,d,e,f){var g=this.widgets_below({col:b,row:c-e,size_x:d,size_y:e});return g.not(f).each(a.proxy(function(b,d){var f=a(d),g=f.coords().grid;if(g.row<=c+e-1){var h=c+e-g.row;this.move_widget_down(f,h)}},this)),this.set_dom_grid_height(),this},h.remove_empty_cells=function(a,b,c,d,e){this.widgets_below({col:a,row:b,size_x:c,size_y:d});return this.set_dom_grid_height(),this},h.next_position=function(a,b){a||(a=1),b||(b=1);for(var c,e=this.gridmap,f=e.length,g=[],h=1;f>h;h++){c=e[h].length;for(var i=1;c>=i;i++){var j=this.can_move_to({size_x:a,size_y:b},h,i);j&&g.push({col:h,row:i,size_y:b,size_x:a})}}return g.length?d.sort_by_row_and_col_asc(g)[0]:!1},h.remove_by_grid=function(a,b){var c=this.is_widget(a,b);c&&this.remove_widget(c)},h.remove_widget=function(b,c,d){var e=b instanceof a?b:a(b),f=e.coords().grid;a.isFunction(c)&&(d=c,c=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(e);var g=this.widgets_below(e);return this.remove_from_gridmap(f),e.fadeOut(a.proxy(function(){e.remove(),c||g.each(a.proxy(function(b,c){this.move_widget_up(a(c),f.size_y)},this)),this.set_dom_grid_height(),d&&d.call(this,b)},this)),this},h.remove_all_widgets=function(b){return this.$widgets.each(a.proxy(function(a,c){this.remove_widget(c,!0,b)},this)),this},h.serialize=function(b){b||(b=this.$widgets);var c=[];b.each(a.proxy(function(b,d){var e=a(d);"undefined"!=typeof e.coords().grid&&c.push(this.options.serialize_params(e,e.coords().grid))},this))},h.serialize_changed=function(){return this.serialize(this.$changed)},h.dom_to_coords=function(a){return{col:parseInt(a.attr("data-col"),10),row:parseInt(a.attr("data-row"),10),size_x:parseInt(a.attr("data-sizex"),10)||1,size_y:parseInt(a.attr("data-sizey"),10)||1,max_size_x:parseInt(a.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(a.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(a.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(a.attr("data-min-sizey"),10)||!1,el:a}},h.register_widget=function(b){var c=b instanceof a,d=c?this.dom_to_coords(b):b,e=!1;c||(b=d.el);var f=this.can_go_widget_up(d);if(f&&(d.row=f,b.attr("data-row",f),this.$el.trigger("gridster:positionchanged",[d]),e=!0),this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:d.size_x,size_y:d.size_y},d.col,d.row)){if(!b.hasClass(".disp_ad"))return b.remove(),!1;a.extend(d,this.next_position(d.size_x,d.size_y)),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),e=!0}return b.data("coords",b.coords()),b.data("coords").grid=d,this.add_to_gridmap(d,b),this.options.resize.enabled&&this.add_resize_handle(b),e},h.update_widget_position=function(a,b){return this.for_each_cell_occupied(a,function(a,c){return this.gridmap[a]?void(this.gridmap[a][c]=b):this}),this},h.update_widget_dimensions=function(a,b,c){return a.data("coords").update({width:b,height:c}),this},h.update_widgets_dimensions=function(){return a.each(this.$widgets,a.proxy(function(b,c){var d=a(c).coords().grid,e=d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],f=d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1];this.update_widget_dimensions(a(c),e,f)},this)),this},h.remove_from_gridmap=function(a){return this.update_widget_position(a,!1)},h.add_to_gridmap=function(a,b){this.update_widget_position(a,b||a.el)},h.draggable=function(){var b=this,c=a.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0],limit:!0,start:function(c,d){b.$widgets.filter(".player-revert").removeClass("player-revert"),b.$player=a(this),b.$helper=a(d.$helper),b.helper=!b.$helper.is(b.$player),b.on_start_drag.call(b,c,d),b.$el.trigger("gridster:dragstart")},stop:function(a,c){b.on_stop_drag.call(b,a,c),b.$el.trigger("gridster:dragstop")},drag:throttle(function(a,c){b.on_drag.call(b,a,c),b.$el.trigger("gridster:drag")},60)});this.drag_api=this.$el.dragg(c).data("drag")},h.resizable=function(){return this.resize_api=this.$el.gridDraggable({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,scroll_container:this.options.scroll_container,start:a.proxy(this.on_start_resize,this),stop:a.proxy(function(b,c){delay(a.proxy(function(){this.on_stop_resize(b,c)},this),120)},this),drag:throttle(a.proxy(this.on_resize,this),60)}),this},h.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var b=this.options.resize.axes,c=' ';return this.resize_handle_tpl=a.map(b,function(a){return c.replace("{type}",a)}).join(""),a.isArray(this.options.draggable.ignore_dragging)&&this.options.draggable.ignore_dragging.push("."+this.resize_handle_class),this},h.on_start_drag=function(b,c){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=a.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var d=this.player_grid_data.size_x,e=this.cols-this.highest_col;this.options.autogrow_cols&&d>=e&&this.add_faux_cols(Math.min(d-e,1));var f=this.faux_grid,g=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(f,this.options.collision),this.$preview_holder=a("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:g.width,height:g.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},h.on_drag=function(a,b){if(null===this.$player)return!1;var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};if(this.options.autogrow_cols){var d=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;d>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(c),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},h.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.w_queue={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])},h.on_start_resize=function(b,c){this.$resized_widget=c.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:c.$player.is("."+this.resize_handle_class+"-x"),bottom:c.$player.is("."+this.resize_handle_class+"-y")},this.is_responsive()||this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var d=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=a("<"+d+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestart")},h.on_stop_resize=function(b,c){this.$resized_widget.removeClass("resizing").css({width:"",height:"","min-width":"","min-height":""}),delay(a.proxy(function(){this.$resize_preview_holder.remove().css({
+"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},h.on_resize=function(a,b){var c,d=b.pointer.diff_left,e=b.pointer.diff_top,f=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0],g=this.options.widget_base_dimensions[1],h=this.options.widget_margins[0],i=this.options.widget_margins[1],j=this.resize_max_size_x,k=this.resize_min_size_x,l=this.resize_max_size_y,m=this.resize_min_size_y,n=this.options.autogrow_cols,o=Math.ceil(d/(f+2*h)-.2),p=Math.ceil(e/(g+2*i)-.2),q=Math.max(1,this.resize_initial_sizex+o),r=Math.max(1,this.resize_initial_sizey+p),s=Math.floor(this.container_width/this.min_widget_width-this.resize_initial_col+1),t=s*this.min_widget_width+(s-1)*h;q=Math.max(Math.min(q,j),k),q=Math.min(s,q),c=j*f+(q-1)*h;var u=Math.min(c,t),v=k*f+(q-1)*h;r=Math.max(Math.min(r,l),m);var w=l*g+(r-1)*i,x=m*g+(r-1)*i;if(this.resize_dir.right?r=this.resize_initial_sizey:this.resize_dir.bottom&&(q=this.resize_initial_sizex),n){var y=this.resize_initial_col+q-1;n&&this.resize_initial_last_col<=y&&(this.set_dom_grid_width(Math.max(y+1,this.cols)),this.colsd;d++)-1===a.inArray(e[d],this.last_cols)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_cols[d],e)&&(c||a.noop).call(this,this.last_cols[d]);return this.last_cols=e,this},h.on_overlapped_row_change=function(b,c){if(!this.colliders_data.length)return this;var d,e=this.get_targeted_rows(this.colliders_data[0].el.data.row),f=this.last_rows.length,g=e.length;for(d=0;g>d;d++)-1===a.inArray(e[d],this.last_rows)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_rows[d],e)&&(c||a.noop).call(this,this.last_rows[d]);this.last_rows=e},h.set_player=function(b,c,d){var e=this,f=!1;d||this.empty_cells_player_occupies();var g=d?{col:b}:e.colliders_data[0].el.data,h=g.col,i=g.row||c;this.player_grid_data={col:h,row:i,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data);var j=this.get_widgets_overlapped(this.player_grid_data),k=this.player_grid_data.size_y,l=this.player_grid_data.size_x,m=this.cells_occupied_by_placeholder,n=this;if(j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,g=m.cols[0]+l-1,o=m.rows[0]+k-1;if(d.hasClass(n.options.static_class))return!0;if(e.size_x<=l&&e.size_y<=k)if(n.is_swap_occupied(m.cols[0],e.row,e.size_x,e.size_y)||n.is_player_in(m.cols[0],e.row)||n.is_in_queue(m.cols[0],e.row,d))if(n.is_swap_occupied(g,e.row,e.size_x,e.size_y)||n.is_player_in(g,e.row)||n.is_in_queue(g,e.row,d))if(n.is_swap_occupied(e.col,m.rows[0],e.size_x,e.size_y)||n.is_player_in(e.col,m.rows[0])||n.is_in_queue(e.col,m.rows[0],d))if(n.is_swap_occupied(e.col,o,e.size_x,e.size_y)||n.is_player_in(e.col,o)||n.is_in_queue(e.col,o,d))if(n.is_swap_occupied(m.cols[0],m.rows[0],e.size_x,e.size_y)||n.is_player_in(m.cols[0],m.rows[0])||n.is_in_queue(m.cols[0],m.rows[0],d))for(var p=0;l>p;p++)for(var q=0;k>q;q++){var r=m.cols[0]+p,s=m.rows[0]+q;if(!n.is_swap_occupied(r,s,e.size_x,e.size_y)&&!n.is_player_in(r,s)&&!n.is_in_queue(r,s,d)){f=n.queue_widget(r,s,d),p=l;break}}else f=n.queue_widget(m.cols[0],m.rows[0],d);else f=n.queue_widget(e.col,o,d);else f=n.queue_widget(e.col,m.rows[0],d);else f=n.queue_widget(g,e.row,d);else f=n.queue_widget(m.cols[0],e.row,d);else n.options.shift_larger_widgets_down&&!f&&j.each(a.proxy(function(b,c){{var d=a(c);d.coords().grid}n.can_go_down(d)&&(n.move_widget_down(d,n.player_grid_data.size_y),n.set_placeholder(h,i))}));n.clean_up_changed()})),f&&this.can_placeholder_be_set(h,i,l,k)){for(var o in this.w_queue){var p=parseInt(o.split("_")[0]),q=parseInt(o.split("_")[1]);"full"!==this.w_queue[o]&&this.new_move_widget_to(this.w_queue[o],p,q)}this.set_placeholder(h,i)}if(!j.length){var r=this.can_go_player_up(this.player_grid_data);r!==!1&&(i=r),this.can_placeholder_be_set(h,i,l,k)&&this.set_placeholder(h,i)}return this.w_queue={},{col:h,row:i}},h.is_swap_occupied=function(a,b,c,d){for(var e=!1,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=h+"_"+i;if(this.is_occupied(h,i))e=!0;else if(j in this.w_queue){if("full"===this.w_queue[j]){e=!0;continue}var k=this.w_queue[j],l=k.coords().grid;this.is_widget_under_player(l.col,l.row)||delete this.w_queue[j]}i>parseInt(this.options.max_rows)&&(e=!0),h>parseInt(this.options.max_cols)&&(e=!0),this.is_player_in(h,i)&&(e=!0)}return e},h.can_placeholder_be_set=function(a,b,c,d){for(var e=!0,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=this.is_widget(h,i);i>parseInt(this.options.max_rows)&&(e=!1),h>parseInt(this.options.max_cols)&&(e=!1),this.is_occupied(h,i)&&!this.is_widget_queued_and_can_move(j)&&(e=!1)}return e},h.queue_widget=function(a,b,c){var d=c,e=d.coords().grid,f=a+"_"+b;if(f in this.w_queue)return!1;this.w_queue[f]=d;for(var g=0;g=0&&a.inArray(c,d.rows)>=0},h.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},h.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},h.is_empty=function(a,b){return"undefined"!=typeof this.gridmap[a]?"undefined"!=typeof this.gridmap[a][b]&&this.gridmap[a][b]===!1?!0:!1:!0},h.is_occupied=function(a,b){return this.gridmap[a]&&this.gridmap[a][b]?!0:!1},h.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},h.is_static=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c&&c.hasClass(this.options.static_class)?!0:!1):!1},h.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},h.get_widgets_under_player=function(b){b||(b=this.cells_occupied_by_player||{cols:[],rows:[]});var c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},h.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b-=f-b);var g=this.placeholder_grid_data.row0&&(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f));)d[a].push(h),e=e>h?h:e;return 0===d[a].length?(c=!1,!0):void d[a].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.can_go_widget_up=function(a){var b=a.row+a.size_y-1,c=!0,d=[],e=1e4;return this.for_each_column_occupied(a,function(f){var g=this.gridmap[f];d[f]=[];for(var h=b+1;--h>0&&(!this.is_widget(f,h)||this.is_player_in(f,h)||g[h].is(a.el));)this.is_player(f,h)||this.is_placeholder_in(f,h)||this.is_player_in(f,h)||d[f].push(h),e>h&&(e=h);return 0===d[f].length?(c=!1,!0):void d[f].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.get_valid_rows=function(b,c,d){for(var e=b.row,f=b.row+b.size_y-1,g=b.size_y,h=d-1,i=[];++h<=f;){var j=!0;if(a.each(c,function(b,c){a.isArray(c)&&-1===a.inArray(h,c)&&(j=!1)}),j===!0&&(i.push(h),i.length===g))break}var k=!1;return 1===g?i[0]!==e&&(k=i[0]||!1):i[0]!==e&&(k=this.get_consecutive_numbers_index(i,g)),k},h.get_consecutive_numbers_index=function(a,b){for(var c=a.length,d=[],e=!0,f=-1,g=0;c>g;g++){if(e||a[g]===f+1){if(d.push(g),d.length===b)break;e=!1}else d=[],e=!0;f=a[g]}return d.length>=b?a[d[0]]:!1},h.get_widgets_overlapped=function(){var b=a([]),c=[],d=this.cells_occupied_by_player.rows.slice(0);return d.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(e,f){a.each(d,a.proxy(function(d,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&-1===a.inArray(g,c)&&(b=b.add(g),c.push(g))},this))},this)),b},h.on_start_overlapping_column=function(a){this.set_player(a,!1)},h.on_start_overlapping_row=function(a){this.set_player(!1,a)},h.on_stop_overlapping_column=function(a){var b=this;this.options.shift_larger_widgets_down&&this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},h.on_stop_overlapping_row=function(a){var b=this,c=this.cells_occupied_by_player.cols;if(this.options.shift_larger_widgets_down)for(var d=0,e=c.length;e>d;d++)this.for_each_widget_below(c[d],a,function(a,c){console.log("from_on_stop_overlapping_row"),b.move_widget_up(this,b.player_grid_data.size_y)})},h.new_move_widget_to=function(a,b,c){var d=a.coords().grid;return this.remove_from_gridmap(d),d.row=c,d.col=b,this.add_to_gridmap(d),a.attr("data-row",c),a.attr("data-col",b),this.update_widget_position(d,a),this.$changed=this.$changed.add(a),this},h.move_widget=function(a,b,c,d){var e=a.coords().grid,f={col:b,row:c,size_x:e.size_x,size_y:e.size_y};return this.mutate_widget_in_gridmap(a,e,f),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,f.col,f.row),a},h.move_widget_to=function(b,c){var d=this,e=b.coords().grid,f=(c-e.row,this.widgets_below(b)),g=this.can_move_to(e,e.col,c,b);return g===!1?!1:(this.remove_from_gridmap(e),e.row=c,this.add_to_gridmap(e),b.attr("data-row",c),this.$changed=this.$changed.add(b),f.each(function(b,c){var e=a(c),f=e.coords().grid,g=d.can_go_widget_up(f);g&&g!==f.row&&d.move_widget_to(e,g)}),this)},h.move_widget_up=function(b,c){var d=b.coords().grid,e=d.row,f=[];return c||(c=1),this.can_go_up(b)?void this.for_each_column_occupied(d,function(d){if(-1===a.inArray(b,f)){var g=b.coords().grid,h=e-c;if(h=this.can_go_up_to_row(g,d,h),!h)return!0;{this.widgets_below(b)}this.remove_from_gridmap(g),g.row=h,this.add_to_gridmap(g),b.attr("data-row",g.row),this.$changed=this.$changed.add(b),f.push(b)}}):!1},h.move_widget_down=function(b,c){var d,e,f,g;if(0>=c)return!1;if(d=b.coords().grid,e=d.row,f=[],g=c,!b)return!1;if(-1===a.inArray(b,f)){var h=b.coords().grid,i=e+c,j=this.widgets_below(b);this.remove_from_gridmap(h),j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,f=this.displacement_diff(e,h,g);f>0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},h.can_go_up_to_row=function(b,c,d){var e,f=this.gridmap,g=!0,h=[],i=b.row;if(this.for_each_column_occupied(b,function(a){f[a];for(h[a]=[],e=i;e--&&this.is_empty(a,e)&&!this.is_placeholder_in(a,e);)h[a].push(e);return h[a].length?void 0:(g=!1,!0)}),!g)return!1;for(e=d,e=1;i>e;e++){for(var j=!0,k=0,l=h.length;l>k;k++)h[k]&&-1===a.inArray(e,h[k])&&(j=!1);if(j===!0){g=e;break}}return g},h.displacement_diff=function(a,b,c){var d=a.row,e=[],f=b.row+b.size_y;this.for_each_column_occupied(a,function(a){for(var b=0,c=f;d>c;c++)this.is_empty(a,c)&&(b+=1);e.push(b)});var g=Math.max.apply(Math,e);return c-=g,c>0?c:0},h.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,e=this,f=(this.gridmap,c.row+c.size_y-1),g=a([]);return this.for_each_column_occupied(c,function(b){e.for_each_widget_below(b,f,function(b,c){return e.is_player(this)||-1!==a.inArray(this,g)?void 0:(g=g.add(this),!0)})}),d.sort_by_row_asc(g)},h.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},h.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},h.can_go_down=function(b){var c=!0,d=this;return b.hasClass(this.options.static_class)&&(c=!1),this.widgets_below(b).each(function(){a(this).hasClass(d.options.static_class)&&(c=!1)}),c},h.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=(this.gridmap,!0);return 1===c?!1:(this.for_each_column_occupied(b,function(a){this.is_widget(a,d);return this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d)||this.is_player_in(a,d)?(e=!1,!0):void 0}),e)},h.can_move_to=function(a,b,c,d){var e=(this.gridmap,a.el),f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:d&&d=d;d++)c.push(d);return c},h.get_targeted_rows=function(a){for(var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[],d=a;b>=d;d++)c.push(d);return c},h.get_cells_occupied=function(b){var c,d={cols:[],rows:[]};for(arguments[1]instanceof a&&(b=arguments[1].coords().grid),c=0;c0&&this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]),h)););},"for_each/below":function(){for(m=e+1,i=g[d].length;i>m;m++)this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]))}};n[j]&&n[j].call(this)}},h.for_each_widget_above=function(a,b,c){return this._traversing_widgets("for_each","above",a,b,c),this},h.for_each_widget_below=function(a,b,c){return this._traversing_widgets("for_each","below",a,b,c),this},h.get_highest_occupied_cell=function(){for(var a,b=this.gridmap,c=b[1].length,d=[],e=[],f=b.length-1;f>=1;f--)for(a=c-1;a>=1;a--)if(this.is_widget(f,a)){d.push(a),e.push(f);break}return{col:Math.max.apply(Math,e),row:Math.max.apply(Math,d)}},h.get_widgets_from=function(b,c){var d=(this.gridmap,a());return b&&(d=d.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c===b||c>b}))),c&&(d=d.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b===c||b>c}))),d},h.set_dom_grid_height=function(a){if("undefined"==typeof a){var b=this.get_highest_occupied_cell().row;a=(b+1)*this.options.widget_margins[1]+b*this.min_widget_height}return this.container_height=a,this.$el.css("height",this.container_height),this},h.set_dom_grid_width=function(a){"undefined"==typeof a&&(a=this.get_highest_occupied_cell().col);var b=this.options.autogrow_cols?this.options.max_cols:this.cols;return a=Math.min(b,Math.max(a,this.options.min_cols)),this.container_width=(a+1)*this.options.widget_margins[0]+a*this.min_widget_width,this.is_responsive()?(this.$el.css({"min-width":"100vw","max-width":"100vw"}),this):(this.$el.css("width",this.container_width),this)},h.is_responsive=function(){return this.options.autogenerate_stylesheet&&"auto"===this.options.widget_base_dimensions[0]&&this.options.max_cols!==1/0},h.get_responsive_col_width=function(){var a=this.cols||this.options.max_cols;return(this.$el.width()-(a+1)*this.options.widget_margins[0])/a},h.resize_responsive_layout=function(){return this.min_widget_width=this.get_responsive_col_width(),this.generate_stylesheet(),this.update_widgets_dimensions(),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0]),this},h.toggle_collapsed_grid=function(a,b){return a?(this.$widgets.css({"margin-top":b.widget_margins[0],"margin-bottom":b.widget_margins[0],"min-height":b.widget_base_dimensions[1]}),this.$el.addClass("collapsed"),this.resize_api&&this.disable_resize(),this.drag_api&&this.disable()):(this.$widgets.css({"margin-top":"auto","margin-bottom":"auto","min-height":"auto"}),this.$el.removeClass("collapsed"),this.resize_api&&this.enable_resize(),this.drag_api&&this.enable()),this},h.generate_stylesheet=function(b){var c,e="",f=this.options.max_size_x||this.cols,g=this.is_responsive()&&this.options.responsive_breakpoint&&a(window).width()=0)return!1;for(this.generated_stylesheets.push(h),d.generated_stylesheets.push(h),c=1;c<=b.cols+1;c++)e+=b.namespace+' [data-col="'+c+'"] { left:'+(g?this.options.widget_margins[0]:c*b.widget_margins[0]+(c-1)*b.widget_base_dimensions[0])+"px; }\n";for(c=1;c<=b.rows+1;c++)e+=b.namespace+' [data-row="'+c+'"] { top:'+(c*b.widget_margins[1]+(c-1)*b.widget_base_dimensions[1])+"px; }\n";for(var i=1;i<=b.rows;i++)e+=b.namespace+' [data-sizey="'+i+'"] { height:'+(g?"auto":i*b.widget_base_dimensions[1]+(i-1)*b.widget_margins[1])+"px; }\n";for(var j=1;f>=j;j++)e+=b.namespace+' [data-sizex="'+j+'"] { width:'+(g?a(window).width()-2*this.options.widget_margins[0]:j*b.widget_base_dimensions[0]+(j-1)*b.widget_margins[0])+"px; }\n";return this.remove_style_tags(),this.add_style_tag(e)},h.add_style_tag=function(a){var b=document;if(!document.getElementById("gridster-stylesheet")){var c=b.createElement("style");c.id="gridster-stylesheet",b.getElementsByTagName("head")[0].appendChild(c),c.setAttribute("type","text/css"),c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a)),this.remove_style_tags(),this.$style_tags=this.$style_tags.add(c)}return this},h.remove_style_tags=function(){var b=d.generated_stylesheets,c=this.generated_stylesheets;this.$style_tags.remove(),d.generated_stylesheets=a.map(b,function(b){return-1===a.inArray(b,c)?b:void 0})},h.generate_faux_grid=function(a,b){this.faux_grid=[],this.gridmap=[];var c,d;for(c=b;c>0;c--)for(this.gridmap[c]=[],d=a;d>0;d--)this.add_faux_cell(d,c);return this},h.add_faux_cell=function(b,c){var d=a({left:this.baseX+(c-1)*this.min_widget_width,top:this.baseY+(b-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:c,row:b,original_col:c,original_row:b}).coords();return a.isArray(this.gridmap[c])||(this.gridmap[c]=[]),"undefined"==typeof this.gridmap[c][b]&&(this.gridmap[c][b]=!1),this.faux_grid.push(d),this},h.add_faux_rows=function(a){a=window.parseInt(a,10);for(var b=this.rows,c=b+parseInt(a||1),d=c;d>b;d--)for(var e=this.cols;e>=1;e--)this.add_faux_cell(d,e);return this.rows=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.add_faux_cols=function(a){a=window.parseInt(a,10);var b=this.cols,c=b+parseInt(a||1);c=Math.min(c,this.options.max_cols);for(var d=b+1;c>=d;d++)for(var e=this.rows;e>=1;e--)this.add_faux_cell(e,d);return this.cols=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.recalculate_faux_grid=function(){var b=this.$wrapper.width();return this.baseX=(f.width()-b)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this.is_responsive()&&this.resize_responsive_layout(),this.options.center_widgets&&this.center_widgets(),this},h.resize_widget_dimensions=function(b){return b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this},h.get_widgets_from_DOM=function(){var b=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));b=d.sort_by_row_and_col_asc(b);var c=a(b).map(a.proxy(function(a,b){return this.register_widget(b)||null},this));return c.length&&this.$el.trigger("gridster:positionschanged"),this},h.set_num_columns=function(b){var c=this.options.max_cols,d=Math.floor(b/(this.min_widget_width+this.options.widget_margins[0]))+this.options.extra_cols,e=this.$widgets.map(function(){return a(this).attr("data-col")}).get();e.length||(e=[0]);var f=Math.max.apply(Math,e);this.cols=Math.max(f,d,this.options.min_cols),c!==1/0&&c>=f&&c=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)&&(c=!0),(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)&&(d=!0),c&&d},e.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2f;f++)-1===a.inArray(e[f],b)&&c.call(this,e[f]);for(var h=0,i=b.length;i>h;h++)-1===a.inArray(b[h],e)&&d.call(this,b[h])},e.find_collisions=function(b){for(var c=this,d=this.options.overlapping_region,e=[],f=[],g=this.colliders||this.$colliders,h=g.length,i=c.$element.coords().update(b||!1).get();h--;){var j=c.$colliders?a(g[h]):g[h],k=j.isCoords?j:j.coords(),l=k.get(),m=c.overlaps(i,l);if(m){var n=c.detect_overlapping_region(i,l);if(n===d||"all"===d){var o=c.calculate_overlapped_area_coords(i,l),p=c.calculate_overlapped_area(o);if(0!==p){var q={area:p,area_coords:o,region:n,coords:l,player_coords:i,el:j};c.options.on_overlap&&c.options.on_overlap.call(this,q),e.push(k),f.push(q)}}}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(e,c.options.on_overlap_start,c.options.on_overlap_stop),this.last_colliders_coords=e,f},e.get_closest_colliders=function(a){var b=this.find_collisions(a);return b.sort(function(a,b){return"C"===a.region&&"C"===b.region?a.coords.y1this.player_max_left?e=this.player_max_left:e=q&&(l=n+h,t>l&&(this.$scroll_container[i](l),this["scroll_offset_"+a]+=h)),r>=s&&(l=n-h,l>0&&(this.$scroll_container[i](l),this["scroll_offset_"+a]-=h)),this},j.manage_scroll=function(a){this.scroll_in("x",a),this.scroll_in("y",a)},j.calculate_dimensions=function(a){this.scroller_height=this.$scroll_container.height(),this.scroller_width=this.$scroll_container.width()},j.drag_handler=function(b){b.target.nodeName;if(!this.disabled&&(1===b.which||f)&&!this.ignore_drag(b)){var c=this,d=!0;return this.$player=a(b.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(b),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$document.on(this.pointer_events.move,function(a){var b=c.get_mouse_pos(a),e=Math.abs(b.left-c.mouse_init_pos.left),f=Math.abs(b.top-c.mouse_init_pos.top);return e>c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging===!0&&c.on_dragmove.call(c,a),!1):!1}),f?void 0:!1}},j.on_dragstart=function(a){if(a.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var b=this.$container.offset();return this.baseX=Math.round(b.left),this.baseY=Math.round(b.top),this.initial_container_width=this.options.container_width||this.$container.width(),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_container_offset_y=this.$scroll_container.scrollTop(),this.scroll_container_offset_x=this.$scroll_container.scrollLeft(),this.scroll_offset_y=0,this.scroll_offset_x=0,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_height=this.$player.height(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,a,this.get_drag_data(a)),!1},j.on_dragmove=function(a){var b=this.get_drag_data(a);this.options.autoscroll&&this.manage_scroll(b),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:b.position.left,top:b.position.top});var c=this.last_position||b.position;return b.prev_position=c,this.options.drag&&this.options.drag.call(this.$player,a,b),this.last_position=b.position,!1},j.on_dragstop=function(a){var b=this.get_drag_data(a);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,a,b),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},j.on_select_start=function(a){return this.disabled||this.ignore_drag(a)?void 0:!1},j.enable=function(){this.disabled=!1},j.disable=function(){this.disabled=!0},j.destroy=function(){this.disable(),this.$container.off(this.ns),this.$document.off(this.ns),d.off(this.ns),a.removeData(this.$container,"drag")},j.ignore_drag=function(b){return this.options.handle?!a(b.target).is(this.options.handle):a.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(b):a(b.target).is(this.options.ignore_dragging.join(", "))},a.fn.gridDraggable=function(a){return new b(this,a)},a.fn.dragg=function(c){return this.each(function(){a.data(this,"drag")||a.data(this,"drag",new b(this,c))})},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery"),require("./jquery.draggable.js"),require("./jquery.collision.js"),require("./jquery.coords.js"),require("./utils.js")):"function"==typeof define&&define.amd?define(["jquery","gridster-draggable","gridster-collision"],b):a.Gridster=b(a.$||a.jQuery,a.GridsterDraggable,a.GridsterCollision)}(this,function(a,b,c){function d(b,c){this.options=a.extend(!0,{},g,c),this.options.draggable=this.options.draggable||{},this.options.draggable=a.extend(!0,{},this.options.draggable,{scroll_container:this.options.scroll_container}),this.$el=a(b),this.$scroll_container=this.options.scroll_container==window?a(window):this.$el.closest(this.options.scroll_container),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=a([]),this.w_queue={},this.min_widget_width=this.options.widget_base_dimensions[0],this.min_widget_height=this.options.widget_base_dimensions[1],this.min_col_count=this.options.min_cols,this.prev_col_count=this.min_col_count,this.is_responsive()&&(this.min_widget_width=this.get_responsive_col_width()),this.generated_stylesheets=[],this.$style_tags=a([]),this.options.auto_init&&this.init()}function e(a){for(var b=["col","row","size_x","size_y"],c={},d=0,e=b.length;e>d;d++){var f=b[d];if(!(f in a))throw new Error("Not exists property `"+f+"`");var g=a[f];if(!g||isNaN(g))throw new Error("Invalid value of `"+f+"` property");c[f]=+g}return c}var f=a(window),g={namespace:"",widget_selector:"li",static_class:"static",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,max_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,auto_init:!0,center_widgets:!1,responsive_breakpoint:!1,scroll_container:window,shift_larger_widgets_down:!0,serialize_params:function(a,b){return{col:b.col,row:b.row,size_x:b.size_x,size_y:b.size_y}},collision:{},draggable:{items:".gs-w:not(.static)",distance:4,ignore_dragging:b.defaults.ignore_dragging.slice(0)},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};d.defaults=g,d.generated_stylesheets=[],d.sort_by_row_asc=function(b){return b=b.sort(function(b,c){return b.row||(b=a(b).coords().grid,c=a(c).coords().grid),b=e(b),c=e(c),b.row>c.row?1:-1})},d.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row>b.row||a.row===b.row&&a.col>b.col?1:-1})},d.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.col>b.col?1:-1})},d.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row+a.size_ythis.cols){var k=i+(b-1)-this.cols,l=i-k;j=Math.max(1,l)}c>h&&this.add_faux_rows(Math.max(c-h,0));var m=g+b-1;m>this.cols&&this.add_faux_cols(m-this.cols);var n={col:j,row:f.row,size_x:b,size_y:c};return this.mutate_widget_in_gridmap(a,f,n),this.set_dom_grid_height(),this.set_dom_grid_width(),e&&e.call(this,n.size_x,n.size_y),a},h.expand_widget=function(b,c,d,e,f){var g=b.coords().grid,h=Math.floor((a(window).width()-2*this.options.widget_margins[0])/this.min_widget_width);c=c||Math.min(h,this.cols),d||(d=g.size_y);var i=g.size_y;b.attr("pre_expand_col",g.col),b.attr("pre_expand_sizex",g.size_x),b.attr("pre_expand_sizey",g.size_y);var j=e||1;d>i&&this.add_faux_rows(Math.max(d-i,0));var k={col:j,row:g.row,size_x:c,size_y:d};return this.mutate_widget_in_gridmap(b,g,k),this.set_dom_grid_height(),this.set_dom_grid_width(),f&&f.call(this,k.size_x,k.size_y),b},h.collapse_widget=function(a,b){var c=a.coords().grid,d=parseInt(a.attr("pre_expand_sizex")),e=parseInt(a.attr("pre_expand_sizey")),f=parseInt(a.attr("pre_expand_col")),g={col:f,row:c.row,size_x:d,size_y:e};return this.mutate_widget_in_gridmap(a,c,g),this.set_dom_grid_height(),this.set_dom_grid_width(),b&&b.call(this,g.size_x,g.size_y),a},h.fit_to_content=function(a,b,c,d){var e=a.coords().grid,f=this.$wrapper.width(),g=this.$wrapper.height(),h=this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0],i=this.options.widget_base_dimensions[1]+2*this.options.widget_margins[1],j=Math.ceil((f+2*this.options.widget_margins[0])/h),k=Math.ceil((g+2*this.options.widget_margins[1])/i),l={col:e.col,row:e.row,size_x:Math.min(b,j),size_y:Math.min(c,k)};return this.mutate_widget_in_gridmap(a,e,l),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,l.size_x,l.size_y),a},h.center_widgets=debounce(function(){var b,c=this.$wrapper.width();b=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0];var d=2*Math.floor(Math.max(Math.floor(c/b),this.min_col_count)/2);this.options.min_cols=d,this.options.max_cols=d,this.options.extra_cols=0,this.options.max_size_x=d,this.set_dom_grid_width(d),this.cols=d;var e=(d-this.prev_col_count)/2;return 0>e?(this.get_min_col()>-1*e?this.shift_cols(e):this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)):e>0?(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.shift_cols(e)},this),0)):(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)),this.prev_col_count=d,this},200),h.get_min_col=function(){return Math.min.apply(Math,this.$widgets.map(a.proxy(function(b,c){return this.get_cells_occupied(a(c).coords().grid).cols},this)).get())},h.shift_cols=function(b){var c=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));c=d.sort_by_row_and_col_asc(c),c.each(a.proxy(function(c,d){var e=a(d.el),f=e.coords().grid,g=parseInt(e.attr("data-col")),h={col:Math.max(Math.round(g+b),1),row:f.row,size_x:f.size_x,size_y:f.size_y};setTimeout(a.proxy(function(){this.mutate_widget_in_gridmap(e,f,h)},this),0)},this))},h.resize_widget_dimensions=function(b){b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1];this.serialize();return this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this},h.mutate_widget_in_gridmap=function(b,c,d){var e=c.size_y,f=this.get_cells_occupied(c),g=this.get_cells_occupied(d),h=[];a.each(f.cols,function(b,c){-1===a.inArray(c,g.cols)&&h.push(c)});var i=[];a.each(g.cols,function(b,c){-1===a.inArray(c,f.cols)&&i.push(c)});var j=[];a.each(f.rows,function(b,c){-1===a.inArray(c,g.rows)&&j.push(c)});var k=[];if(a.each(g.rows,function(b,c){-1===a.inArray(c,f.rows)&&k.push(c)}),this.remove_from_gridmap(c),i.length){var l=[d.col,d.row,d.size_x,Math.min(e,d.size_y),b];this.empty_cells.apply(this,l)}if(k.length){var m=[d.col,d.row,d.size_x,d.size_y,b];this.empty_cells.apply(this,m)}if(c.col=d.col,c.row=d.row,c.size_x=d.size_x,c.size_y=d.size_y,this.add_to_gridmap(d,b),b.removeClass("player-revert"),b.data("coords").update({width:d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],height:d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1]}),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),h.length){var n=[h[0],d.row,h[h.length-1]-h[0]+1,Math.min(e,d.size_y),b];this.remove_empty_cells.apply(this,n)}if(j.length){var o=[d.col,d.row,d.size_x,d.size_y,b];this.remove_empty_cells.apply(this,o)}return this.move_widget_up(b),this},h.empty_cells=function(b,c,d,e,f){var g=this.widgets_below({col:b,row:c-e,size_x:d,size_y:e});return g.not(f).each(a.proxy(function(b,d){var f=a(d),g=f.coords().grid;if(g.row<=c+e-1){var h=c+e-g.row;this.move_widget_down(f,h)}},this)),this.set_dom_grid_height(),this},h.remove_empty_cells=function(a,b,c,d,e){this.widgets_below({col:a,row:b,size_x:c,size_y:d});return this.set_dom_grid_height(),this},h.next_position=function(a,b){a||(a=1),b||(b=1);for(var c,e=this.gridmap,f=e.length,g=[],h=1;f>h;h++){c=e[h].length;for(var i=1;c>=i;i++){var j=this.can_move_to({size_x:a,size_y:b},h,i);j&&g.push({col:h,row:i,size_y:b,size_x:a})}}return g.length?d.sort_by_row_and_col_asc(g)[0]:!1},h.remove_by_grid=function(a,b){var c=this.is_widget(a,b);c&&this.remove_widget(c)},h.remove_widget=function(b,c,d){var e=b instanceof a?b:a(b),f=e.coords().grid;a.isFunction(c)&&(d=c,c=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(e);var g=this.widgets_below(e);return this.remove_from_gridmap(f),e.fadeOut(a.proxy(function(){e.remove(),c||g.each(a.proxy(function(b,c){this.move_widget_up(a(c),f.size_y)},this)),this.set_dom_grid_height(),d&&d.call(this,b)},this)),this},h.remove_all_widgets=function(b){return this.$widgets.each(a.proxy(function(a,c){this.remove_widget(c,!0,b)},this)),this},h.serialize=function(b){b||(b=this.$widgets);var c=[];b.each(a.proxy(function(b,d){"undefined"!=typeof a(d).coords().grid&&c.push(this.options.serialize_params($w,$w.coords().grid))},this))},h.serialize_changed=function(){return this.serialize(this.$changed)},h.dom_to_coords=function(a){return{col:parseInt(a.attr("data-col"),10),row:parseInt(a.attr("data-row"),10),size_x:parseInt(a.attr("data-sizex"),10)||1,size_y:parseInt(a.attr("data-sizey"),10)||1,max_size_x:parseInt(a.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(a.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(a.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(a.attr("data-min-sizey"),10)||!1,el:a}},h.register_widget=function(b){var c=b instanceof a,d=c?this.dom_to_coords(b):b,e=!1;c||(b=d.el);var f=this.can_go_widget_up(d);if(f&&(d.row=f,b.attr("data-row",f),this.$el.trigger("gridster:positionchanged",[d]),e=!0),this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:d.size_x,size_y:d.size_y},d.col,d.row)){if(!b.hasClass(".disp_ad"))return b.remove(),!1;a.extend(d,this.next_position(d.size_x,d.size_y)),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),e=!0}return b.data("coords",b.coords()),b.data("coords").grid=d,this.add_to_gridmap(d,b),this.options.resize.enabled&&this.add_resize_handle(b),e},h.update_widget_position=function(a,b){return this.for_each_cell_occupied(a,function(a,c){return this.gridmap[a]?void(this.gridmap[a][c]=b):this}),this},h.update_widget_dimensions=function(a,b,c){return a.data("coords").update({width:b,height:c}),this},h.update_widgets_dimensions=function(){return a.each(this.$widgets,a.proxy(function(b,c){var d=a(c).coords().grid,e=d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],f=d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1];this.update_widget_dimensions(a(c),e,f)},this)),this},h.remove_from_gridmap=function(a){return this.update_widget_position(a,!1)},h.add_to_gridmap=function(a,b){this.update_widget_position(a,b||a.el)},h.draggable=function(){var b=this,c=a.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0],limit:!0,start:function(c,d){b.$widgets.filter(".player-revert").removeClass("player-revert"),b.$player=a(this),b.$helper=a(d.$helper),b.helper=!b.$helper.is(b.$player),b.on_start_drag.call(b,c,d),b.$el.trigger("gridster:dragstart")},stop:function(a,c){b.on_stop_drag.call(b,a,c),b.$el.trigger("gridster:dragstop")},drag:throttle(function(a,c){b.on_drag.call(b,a,c),b.$el.trigger("gridster:drag")},60)});this.drag_api=this.$el.dragg(c).data("drag")},h.resizable=function(){return this.resize_api=this.$el.gridDraggable({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,scroll_container:this.options.scroll_container,start:a.proxy(this.on_start_resize,this),stop:a.proxy(function(b,c){delay(a.proxy(function(){this.on_stop_resize(b,c)},this),120)},this),drag:throttle(a.proxy(this.on_resize,this),60)}),this},h.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var b=this.options.resize.axes,c=' ';return this.resize_handle_tpl=a.map(b,function(a){return c.replace("{type}",a)}).join(""),a.isArray(this.options.draggable.ignore_dragging)&&this.options.draggable.ignore_dragging.push("."+this.resize_handle_class),this},h.on_start_drag=function(b,c){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=a.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var d=this.player_grid_data.size_x,e=this.cols-this.highest_col;this.options.autogrow_cols&&d>=e&&this.add_faux_cols(Math.min(d-e,1));var f=this.faux_grid,g=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(f,this.options.collision),this.$preview_holder=a("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:g.width,height:g.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},h.on_drag=function(a,b){if(null===this.$player)return!1;var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};if(this.options.autogrow_cols){var d=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;d>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(c),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},h.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.w_queue={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])},h.on_start_resize=function(b,c){this.$resized_widget=c.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:c.$player.is("."+this.resize_handle_class+"-x"),bottom:c.$player.is("."+this.resize_handle_class+"-y")},this.is_responsive()||this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var d=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=a("<"+d+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,b,c,this.$resized_widget),
-this.$el.trigger("gridster:resizestart")},h.on_stop_resize=function(b,c){this.$resized_widget.removeClass("resizing").css({width:"",height:"","min-width":"","min-height":""}),delay(a.proxy(function(){this.$resize_preview_holder.remove().css({"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},h.on_resize=function(a,b){var c,d=b.pointer.diff_left,e=b.pointer.diff_top,f=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0],g=this.options.widget_base_dimensions[1],h=this.options.widget_margins[0],i=this.options.widget_margins[1],j=this.resize_max_size_x,k=this.resize_min_size_x,l=this.resize_max_size_y,m=this.resize_min_size_y,n=this.options.autogrow_cols,o=Math.ceil(d/(f+2*h)-.2),p=Math.ceil(e/(g+2*i)-.2),q=Math.max(1,this.resize_initial_sizex+o),r=Math.max(1,this.resize_initial_sizey+p),s=Math.floor(this.container_width/this.min_widget_width-this.resize_initial_col+1),t=s*this.min_widget_width+(s-1)*h;if(q=Math.max(Math.min(q,j),k),q=Math.min(s,q),c=j*f+(q-1)*h,max_width=Math.min(c,t),min_width=k*f+(q-1)*h,r=Math.max(Math.min(r,l),m),max_height=l*g+(r-1)*i,min_height=m*g+(r-1)*i,this.resize_dir.right?r=this.resize_initial_sizey:this.resize_dir.bottom&&(q=this.resize_initial_sizex),n){var u=this.resize_initial_col+q-1;n&&this.resize_initial_last_col<=u&&(this.set_dom_grid_width(Math.max(u+1,this.cols)),this.colsd;d++)-1===a.inArray(e[d],this.last_cols)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_cols[d],e)&&(c||a.noop).call(this,this.last_cols[d]);return this.last_cols=e,this},h.on_overlapped_row_change=function(b,c){if(!this.colliders_data.length)return this;var d,e=this.get_targeted_rows(this.colliders_data[0].el.data.row),f=this.last_rows.length,g=e.length;for(d=0;g>d;d++)-1===a.inArray(e[d],this.last_rows)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_rows[d],e)&&(c||a.noop).call(this,this.last_rows[d]);this.last_rows=e},h.set_player=function(b,c,d){var e=this,f=!1;d||this.empty_cells_player_occupies();var g=d?{col:b}:e.colliders_data[0].el.data,h=g.col,i=g.row||c;this.player_grid_data={col:h,row:i,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data);var j=this.get_widgets_overlapped(this.player_grid_data),k=this.player_grid_data.size_y,l=this.player_grid_data.size_x,m=this.cells_occupied_by_placeholder,n=this;if(j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,g=m.cols[0]+l-1,o=m.rows[0]+k-1;if(d.hasClass(n.options.static_class))return!0;if(e.size_x<=l&&e.size_y<=k)if(n.is_swap_occupied(m.cols[0],e.row,e.size_x,e.size_y)||n.is_player_in(m.cols[0],e.row)||n.is_in_queue(m.cols[0],e.row,d))if(n.is_swap_occupied(g,e.row,e.size_x,e.size_y)||n.is_player_in(g,e.row)||n.is_in_queue(g,e.row,d))if(n.is_swap_occupied(e.col,m.rows[0],e.size_x,e.size_y)||n.is_player_in(e.col,m.rows[0])||n.is_in_queue(e.col,m.rows[0],d))if(n.is_swap_occupied(e.col,o,e.size_x,e.size_y)||n.is_player_in(e.col,o)||n.is_in_queue(e.col,o,d))if(n.is_swap_occupied(m.cols[0],m.rows[0],e.size_x,e.size_y)||n.is_player_in(m.cols[0],m.rows[0])||n.is_in_queue(m.cols[0],m.rows[0],d))for(var p=0;l>p;p++)for(var q=0;k>q;q++){var r=m.cols[0]+p,s=m.rows[0]+q;if(!n.is_swap_occupied(r,s,e.size_x,e.size_y)&&!n.is_player_in(r,s)&&!n.is_in_queue(r,s,d)){f=n.queue_widget(r,s,d),p=l;break}}else f=n.queue_widget(m.cols[0],m.rows[0],d);else f=n.queue_widget(e.col,o,d);else f=n.queue_widget(e.col,m.rows[0],d);else f=n.queue_widget(g,e.row,d);else f=n.queue_widget(m.cols[0],e.row,d);else n.options.shift_larger_widgets_down&&!f&&j.each(a.proxy(function(b,c){{var d=a(c);d.coords().grid}n.can_go_down(d)&&(n.move_widget_down(d,n.player_grid_data.size_y),n.set_placeholder(h,i))}));n.clean_up_changed()})),f&&this.can_placeholder_be_set(h,i,l,k)){for(var o in this.w_queue){var b=parseInt(o.split("_")[0]),c=parseInt(o.split("_")[1]);"full"!=this.w_queue[o]&&this.new_move_widget_to(this.w_queue[o],b,c)}this.set_placeholder(h,i)}if(!j.length){var p=this.can_go_player_up(this.player_grid_data);p!==!1&&(i=p),this.can_placeholder_be_set(h,i,l,k)&&this.set_placeholder(h,i)}return this.w_queue={},{col:h,row:i}},h.is_swap_occupied=function(a,b,c,d){for(var e=!1,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=h+"_"+i;if(this.is_occupied(h,i))e=!0;else if(j in this.w_queue){if("full"==this.w_queue[j]){e=!0;continue}$tw=this.w_queue[j],tgd=$tw.coords().grid,this.is_widget_under_player(tgd.col,tgd.row)||delete this.w_queue[j]}i>parseInt(this.options.max_rows)&&(e=!0),h>parseInt(this.options.max_cols)&&(e=!0),this.is_player_in(h,i)&&(e=!0)}return e},h.can_placeholder_be_set=function(a,b,c,d){for(var e=!0,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=this.is_widget(h,i);i>parseInt(this.options.max_rows)&&(e=!1),h>parseInt(this.options.max_cols)&&(e=!1),this.is_occupied(h,i)&&!this.is_widget_queued_and_can_move(j)&&(e=!1)}return e},h.queue_widget=function(a,b,c){var d=c,e=d.coords().grid,f=a+"_"+b;if(f in this.w_queue)return!1;this.w_queue[f]=d;for(var g=0;g=0&&a.inArray(c,d.rows)>=0},h.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},h.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},h.is_empty=function(a,b){return"undefined"!=typeof this.gridmap[a]?"undefined"!=typeof this.gridmap[a][b]&&this.gridmap[a][b]===!1?!0:!1:!0},h.is_occupied=function(a,b){return this.gridmap[a]&&this.gridmap[a][b]?!0:!1},h.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},h.is_static=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c&&c.hasClass(this.options.static_class)?!0:!1):!1},h.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},h.get_widgets_under_player=function(b){b||(b=this.cells_occupied_by_player||{cols:[],rows:[]});var c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},h.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b-=f-b);var g=this.placeholder_grid_data.row0&&(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f));)d[a].push(h),e=e>h?h:e;return 0===d[a].length?(c=!1,!0):void d[a].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.can_go_widget_up=function(a){var b=a.row+a.size_y-1,c=!0,d=[],e=1e4;return this.for_each_column_occupied(a,function(f){var g=this.gridmap[f];d[f]=[];for(var h=b+1;--h>0&&(!this.is_widget(f,h)||this.is_player_in(f,h)||g[h].is(a.el));)this.is_player(f,h)||this.is_placeholder_in(f,h)||this.is_player_in(f,h)||d[f].push(h),e>h&&(e=h);return 0===d[f].length?(c=!1,!0):void d[f].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.get_valid_rows=function(b,c,d){for(var e=b.row,f=b.row+b.size_y-1,g=b.size_y,h=d-1,i=[];++h<=f;){var j=!0;if(a.each(c,function(b,c){a.isArray(c)&&-1===a.inArray(h,c)&&(j=!1)}),j===!0&&(i.push(h),i.length===g))break}var k=!1;return 1===g?i[0]!==e&&(k=i[0]||!1):i[0]!==e&&(k=this.get_consecutive_numbers_index(i,g)),k},h.get_consecutive_numbers_index=function(a,b){for(var c=a.length,d=[],e=!0,f=-1,g=0;c>g;g++){if(e||a[g]===f+1){if(d.push(g),d.length===b)break;e=!1}else d=[],e=!0;f=a[g]}return d.length>=b?a[d[0]]:!1},h.get_widgets_overlapped=function(){var b=a([]),c=[],d=this.cells_occupied_by_player.rows.slice(0);return d.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(e,f){a.each(d,a.proxy(function(d,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&-1===a.inArray(g,c)&&(b=b.add(g),c.push(g))},this))},this)),b},h.on_start_overlapping_column=function(a){this.set_player(a,!1)},h.on_start_overlapping_row=function(a){this.set_player(!1,a)},h.on_stop_overlapping_column=function(a){var b=this;this.options.shift_larger_widgets_down&&this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},h.on_stop_overlapping_row=function(a){var b=this,c=this.cells_occupied_by_player.cols;if(this.options.shift_larger_widgets_down)for(var d=0,e=c.length;e>d;d++)this.for_each_widget_below(c[d],a,function(a,c){console.log("from_on_stop_overlapping_row"),b.move_widget_up(this,b.player_grid_data.size_y)})},h.new_move_widget_to=function(a,b,c){var d=a.coords().grid;return this.remove_from_gridmap(d),d.row=c,d.col=b,this.add_to_gridmap(d),a.attr("data-row",c),a.attr("data-col",b),this.update_widget_position(d,a),this.$changed=this.$changed.add(a),this},h.move_widget=function(a,b,c,d){var e=a.coords().grid,f={col:b,row:c,size_x:e.size_x,size_y:e.size_y};return this.mutate_widget_in_gridmap(a,e,f),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,f.col,f.row),a},h.move_widget_to=function(b,c){var d=this,e=b.coords().grid,f=(c-e.row,this.widgets_below(b)),g=this.can_move_to(e,e.col,c,b);return g===!1?!1:(this.remove_from_gridmap(e),e.row=c,this.add_to_gridmap(e),b.attr("data-row",c),this.$changed=this.$changed.add(b),f.each(function(b,c){var e=a(c),f=e.coords().grid,g=d.can_go_widget_up(f);g&&g!==f.row&&d.move_widget_to(e,g)}),this)},h.move_widget_up=function(b,c){var d=b.coords().grid,e=d.row,f=[];return c||(c=1),this.can_go_up(b)?void this.for_each_column_occupied(d,function(d){if(-1===a.inArray(b,f)){var g=b.coords().grid,h=e-c;if(h=this.can_go_up_to_row(g,d,h),!h)return!0;{this.widgets_below(b)}this.remove_from_gridmap(g),g.row=h,this.add_to_gridmap(g),b.attr("data-row",g.row),this.$changed=this.$changed.add(b),f.push(b)}}):!1},h.move_widget_down=function(b,c){var d,e,f,g;if(0>=c)return!1;if(d=b.coords().grid,e=d.row,f=[],g=c,!b)return!1;if(-1===a.inArray(b,f)){var h=b.coords().grid,i=e+c,j=this.widgets_below(b);this.remove_from_gridmap(h),j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,f=this.displacement_diff(e,h,g);f>0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},h.can_go_up_to_row=function(b,c,d){var e,f=this.gridmap,g=!0,h=[],i=b.row;if(this.for_each_column_occupied(b,function(a){f[a];for(h[a]=[],e=i;e--&&this.is_empty(a,e)&&!this.is_placeholder_in(a,e);)h[a].push(e);return h[a].length?void 0:(g=!1,!0)}),!g)return!1;for(e=d,e=1;i>e;e++){for(var j=!0,k=0,l=h.length;l>k;k++)h[k]&&-1===a.inArray(e,h[k])&&(j=!1);if(j===!0){g=e;break}}return g},h.displacement_diff=function(a,b,c){var d=a.row,e=[],f=b.row+b.size_y;this.for_each_column_occupied(a,function(a){for(var b=0,c=f;d>c;c++)this.is_empty(a,c)&&(b+=1);e.push(b)});var g=Math.max.apply(Math,e);return c-=g,c>0?c:0},h.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,e=this,f=(this.gridmap,c.row+c.size_y-1),g=a([]);return this.for_each_column_occupied(c,function(b){e.for_each_widget_below(b,f,function(b,c){return e.is_player(this)||-1!==a.inArray(this,g)?void 0:(g=g.add(this),!0)})}),d.sort_by_row_asc(g)},h.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},h.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},h.can_go_down=function(b){var c=!0,d=this;return b.hasClass(this.options.static_class)&&(c=!1),this.widgets_below(b).each(function(){a(this).hasClass(d.options.static_class)&&(c=!1)}),c},h.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=(this.gridmap,!0);return 1===c?!1:(this.for_each_column_occupied(b,function(a){this.is_widget(a,d);return this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d)||this.is_player_in(a,d)?(e=!1,!0):void 0}),e)},h.can_move_to=function(a,b,c,d){var e=(this.gridmap,a.el),f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:d&&d=d;d++)c.push(d);return c},h.get_targeted_rows=function(a){for(var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[],d=a;b>=d;d++)c.push(d);return c},h.get_cells_occupied=function(b){var c,d={cols:[],rows:[]};for(arguments[1]instanceof a&&(b=arguments[1].coords().grid),c=0;c0&&this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]),h)););},"for_each/below":function(){for(m=e+1,i=g[d].length;i>m;m++)this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]))}};n[j]&&n[j].call(this)}},h.for_each_widget_above=function(a,b,c){return this._traversing_widgets("for_each","above",a,b,c),this},h.for_each_widget_below=function(a,b,c){return this._traversing_widgets("for_each","below",a,b,c),this},h.get_highest_occupied_cell=function(){for(var a,b=this.gridmap,c=b[1].length,d=[],e=[],f=b.length-1;f>=1;f--)for(a=c-1;a>=1;a--)if(this.is_widget(f,a)){d.push(a),e.push(f);break}return{col:Math.max.apply(Math,e),row:Math.max.apply(Math,d)}},h.get_widgets_from=function(b,c){var d=(this.gridmap,a());return b&&(d=d.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c===b||c>b}))),c&&(d=d.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b===c||b>c}))),d},h.set_dom_grid_height=function(a){if("undefined"==typeof a){var b=this.get_highest_occupied_cell().row;a=(b+1)*this.options.widget_margins[1]+b*this.min_widget_height}return this.container_height=a,this.$el.css("height",this.container_height),this},h.set_dom_grid_width=function(a){"undefined"==typeof a&&(a=this.get_highest_occupied_cell().col);var b=this.options.autogrow_cols?this.options.max_cols:this.cols;return a=Math.min(b,Math.max(a,this.options.min_cols)),this.container_width=(a+1)*this.options.widget_margins[0]+a*this.min_widget_width,this.is_responsive()?(this.$el.css({"min-width":"100vw","max-width":"100vw"}),this):(this.$el.css("width",this.container_width),this)},h.is_responsive=function(){return this.options.autogenerate_stylesheet&&"auto"===this.options.widget_base_dimensions[0]&&this.options.max_cols!==1/0},h.get_responsive_col_width=function(){var a=this.cols||this.options.max_cols;return(this.$el.width()-(a+1)*this.options.widget_margins[0])/a},h.resize_responsive_layout=function(){return this.min_widget_width=this.get_responsive_col_width(),this.generate_stylesheet(),this.update_widgets_dimensions(),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0]),this},h.toggle_collapsed_grid=function(a,b){return a?(this.$widgets.css({"margin-top":b.widget_margins[0],"margin-bottom":b.widget_margins[0],"min-height":b.widget_base_dimensions[1]}),this.$el.addClass("collapsed"),this.resize_api&&this.disable_resize(),this.drag_api&&this.disable()):(this.$widgets.css({"margin-top":"auto","margin-bottom":"auto","min-height":"auto"}),this.$el.removeClass("collapsed"),this.resize_api&&this.enable_resize(),this.drag_api&&this.enable()),this},h.generate_stylesheet=function(b){var c,e="",f=this.options.max_size_x||this.cols,g=this.is_responsive()&&this.options.responsive_breakpoint&&a(window).width()=0)return!1;for(this.generated_stylesheets.push(h),d.generated_stylesheets.push(h),c=1;c<=b.cols+1;c++)e+=b.namespace+' [data-col="'+c+'"] { left:'+(g?this.options.widget_margins[0]:c*b.widget_margins[0]+(c-1)*b.widget_base_dimensions[0])+"px; }\n";for(c=1;c<=b.rows+1;c++)e+=b.namespace+' [data-row="'+c+'"] { top:'+(c*b.widget_margins[1]+(c-1)*b.widget_base_dimensions[1])+"px; }\n";for(var i=1;i<=b.rows;i++)e+=b.namespace+' [data-sizey="'+i+'"] { height:'+(g?"auto":i*b.widget_base_dimensions[1]+(i-1)*b.widget_margins[1])+"px; }\n";for(var j=1;f>=j;j++)e+=b.namespace+' [data-sizex="'+j+'"] { width:'+(g?a(window).width()-2*this.options.widget_margins[0]:j*b.widget_base_dimensions[0]+(j-1)*b.widget_margins[0])+"px; }\n";return this.remove_style_tags(),this.add_style_tag(e)},h.add_style_tag=function(a){var b=document;if(!document.getElementById("gridster-stylesheet")){var c=b.createElement("style");c.id="gridster-stylesheet",b.getElementsByTagName("head")[0].appendChild(c),c.setAttribute("type","text/css"),c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a)),this.remove_style_tags(),this.$style_tags=this.$style_tags.add(c)}return this},h.remove_style_tags=function(){var b=d.generated_stylesheets,c=this.generated_stylesheets;this.$style_tags.remove(),d.generated_stylesheets=a.map(b,function(b){return-1===a.inArray(b,c)?b:void 0})},h.generate_faux_grid=function(a,b){this.faux_grid=[],this.gridmap=[];var c,d;for(c=b;c>0;c--)for(this.gridmap[c]=[],d=a;d>0;d--)this.add_faux_cell(d,c);return this},h.add_faux_cell=function(b,c){var d=a({left:this.baseX+(c-1)*this.min_widget_width,top:this.baseY+(b-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:c,row:b,original_col:c,original_row:b}).coords();return a.isArray(this.gridmap[c])||(this.gridmap[c]=[]),"undefined"==typeof this.gridmap[c][b]&&(this.gridmap[c][b]=!1),this.faux_grid.push(d),this},h.add_faux_rows=function(a){a=window.parseInt(a,10);for(var b=this.rows,c=b+parseInt(a||1),d=c;d>b;d--)for(var e=this.cols;e>=1;e--)this.add_faux_cell(d,e);return this.rows=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.add_faux_cols=function(a){a=window.parseInt(a,10);var b=this.cols,c=b+parseInt(a||1);c=Math.min(c,this.options.max_cols);for(var d=b+1;c>=d;d++)for(var e=this.rows;e>=1;e--)this.add_faux_cell(e,d);return this.cols=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.recalculate_faux_grid=function(){var b=this.$wrapper.width();return this.baseX=(f.width()-b)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this.is_responsive()&&this.resize_responsive_layout(),this.options.center_widgets&&this.center_widgets(),this},h.resize_widget_dimensions=function(b){return b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this},h.get_widgets_from_DOM=function(){var b=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));b=d.sort_by_row_and_col_asc(b);var c=a(b).map(a.proxy(function(a,b){return this.register_widget(b)||null},this));return c.length&&this.$el.trigger("gridster:positionschanged"),this},h.set_num_columns=function(b){var c=this.options.max_cols,d=Math.floor(b/(this.min_widget_width+this.options.widget_margins[0]))+this.options.extra_cols,e=this.$widgets.map(function(){return a(this).attr("data-col")}).get();e.length||(e=[0]);var f=Math.max.apply(Math,e);this.cols=Math.max(f,d,this.options.min_cols),c!==1/0&&c>=f&&c=0;b--)if(this.is_widget(a,b)!==!1)return!0;return!1},c.widgets_in_row=function(a){for(var b=this.gridmap.length;b>=1;b--)if(this.is_widget(b,a)!==!1)return!0;return!1},c.widgets_in_range=function(b,c,d,e){var f,g,h,i,j=a([]);for(f=d;f>=b;f--)for(g=e;g>=c;g--)h=this.is_widget(f,g),h!==!1&&(i=h.data("coords").grid,i.col>=b&&i.col<=d&&i.row>=c&&i.row<=e&&(j=j.add(h)));return j},c.get_bottom_most_occupied_cell=function(){var a=0,b=0;return this.for_each_cell(function(c,d,e){c&&e>a&&(a=e,b=d)}),{col:b,row:a}},c.get_right_most_occupied_cell=function(){var a=0,b=0;return this.for_each_cell(function(c,d,e){return c?(a=e,b=d,!1):void 0}),{col:b,row:a}},c.for_each_cell=function(a,b){b||(b=this.gridmap);var c=b.length,d=b[1].length;a:for(var e=c-1;e>=1;e--)for(var f=d-1;f>=1;f--){var g=b[e]&&b[e][f];if(a){if(a.call(this,g,e,f)===!1)break a}else;}},c.next_position_in_range=function(a,c,d){a||(a=1),c||(c=1);for(var e,f=this.gridmap,g=f.length,h=[],i=1;g>i;i++){e=d||f[i].length;for(var j=1;e>=j;j++){var k=this.can_move_to({size_x:a,size_y:c},i,j,d);k&&h.push({col:i,row:j,size_y:c,size_x:a})}}return h.length>=1?b.sort_by_col_asc(h)[0]:!1},c.closest_to_right=function(a,b){if(!this.gridmap[a])return!1;for(var c=this.gridmap.length-1,d=a;c>=d;d++)if(this.gridmap[d][b])return{col:d,row:b};return!1},c.closest_to_left=function(a,b){this.gridmap.length-1;if(!this.gridmap[a])return!1;for(var c=a;c>=1;c--)if(this.gridmap[c][b])return{col:c,row:b};return!1},b});
\ No newline at end of file
+/*! gridster.js - v0.6.6 - 2015-04-10 - * http://gridster.net/ - Copyright (c) 2015 ducksboard; Licensed MIT */ !function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-coords",["jquery"],b):a.GridsterCoords=b(a.$||a.jQuery)}(this,function(a){function b(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var c=b.prototype;return c.init=function(){this.set(),this.original_coords=this.get()},c.set=function(a,b){var c=this.el;if(c&&!a&&(this.data=c.offset(),this.data.width=c.width(),this.data.height=c.height()),c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return void 0===e.left&&(e.left=e.x1),void 0===e.top&&(e.top=e.y1),this.coords.x1=e.left,this.coords.y1=e.top,this.coords.x2=e.left+e.width,this.coords.y2=e.top+e.height,this.coords.cx=e.left+e.width/2,this.coords.cy=e.top+e.height/2,this.coords.width=e.width,this.coords.height=e.height,this.coords.el=c||!1,this},c.update=function(b){if(!b&&!this.el)return this;if(b){var c=a.extend({},this.data,b);return this.data=c,this.set(!0,!0)}return this.set(!0),this},c.get=function(){return this.coords},c.destroy=function(){this.el.removeData("coords"),delete this.el},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new b(this,arguments[0]);return this.data("coords",a),a},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-collision",["jquery","gridster-coords"],b):a.GridsterCollision=b(a.$||a.jQuery,a.GridsterCoords)}(this,function(a,b){function c(b,c,e){this.options=a.extend(d,e),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],this.set_colliders(c),this.init()}var d={colliders_context:document.body,overlapping_region:"C"};c.defaults=d;var e=c.prototype;return e.init=function(){this.find_collisions()},e.overlaps=function(a,b){var c=!1,d=!1;return(b.x1>=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)&&(c=!0),(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)&&(d=!0),c&&d},e.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2f;f++)-1===a.inArray(e[f],b)&&c.call(this,e[f]);for(var h=0,i=b.length;i>h;h++)-1===a.inArray(b[h],e)&&d.call(this,b[h])},e.find_collisions=function(b){for(var c=this,d=this.options.overlapping_region,e=[],f=[],g=this.colliders||this.$colliders,h=g.length,i=c.$element.coords().update(b||!1).get();h--;){var j=c.$colliders?a(g[h]):g[h],k=j.isCoords?j:j.coords(),l=k.get(),m=c.overlaps(i,l);if(m){var n=c.detect_overlapping_region(i,l);if(n===d||"all"===d){var o=c.calculate_overlapped_area_coords(i,l),p=c.calculate_overlapped_area(o);if(0!==p){var q={area:p,area_coords:o,region:n,coords:l,player_coords:i,el:j};c.options.on_overlap&&c.options.on_overlap.call(this,q),e.push(k),f.push(q)}}}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(e,c.options.on_overlap_start,c.options.on_overlap_stop),this.last_colliders_coords=e,f},e.get_closest_colliders=function(a){var b=this.find_collisions(a);return b.sort(function(a,b){return"C"===a.region&&"C"===b.region?a.coords.y1this.player_max_left?e=this.player_max_left:e=q&&(l=n+h,t>l&&(this.$scroll_container[i](l),this["scroll_offset_"+a]+=h)),r>=s&&(l=n-h,l>0&&(this.$scroll_container[i](l),this["scroll_offset_"+a]-=h)),this},j.manage_scroll=function(a){this.scroll_in("x",a),this.scroll_in("y",a)},j.calculate_dimensions=function(){this.scroller_height=this.$scroll_container.height(),this.scroller_width=this.$scroll_container.width()},j.drag_handler=function(b){if(!this.disabled&&(1===b.which||f)&&!this.ignore_drag(b)){var c=this,d=!0;return this.$player=a(b.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(b),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$document.on(this.pointer_events.move,function(a){var b=c.get_mouse_pos(a),e=Math.abs(b.left-c.mouse_init_pos.left),f=Math.abs(b.top-c.mouse_init_pos.top);return e>c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging===!0&&c.on_dragmove.call(c,a),!1):!1}),f?void 0:!1}},j.on_dragstart=function(a){if(a.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var b=this.$container.offset();return this.baseX=Math.round(b.left),this.baseY=Math.round(b.top),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_container_offset_y=this.$scroll_container.scrollTop(),this.scroll_container_offset_x=this.$scroll_container.scrollLeft(),this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,a,this.get_drag_data(a)),!1},j.on_dragmove=function(a){var b=this.get_drag_data(a);this.options.autoscroll&&this.manage_scroll(b),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:b.position.left,top:b.position.top});var c=this.last_position||b.position;return b.prev_position=c,this.options.drag&&this.options.drag.call(this.$player,a,b),this.last_position=b.position,!1},j.on_dragstop=function(a){var b=this.get_drag_data(a);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,a,b),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},j.on_select_start=function(a){return this.disabled||this.ignore_drag(a)?void 0:!1},j.enable=function(){this.disabled=!1},j.disable=function(){this.disabled=!0},j.destroy=function(){this.disable(),this.$container.off(this.ns),this.$document.off(this.ns),d.off(this.ns),a.removeData(this.$container,"drag")},j.ignore_drag=function(b){return this.options.handle?!a(b.target).is(this.options.handle):a.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(b):a(b.target).is(this.options.ignore_dragging.join(", "))},a.fn.gridDraggable=function(a){return new b(this,a)},a.fn.dragg=function(c){return this.each(function(){a.data(this,"drag")||a.data(this,"drag",new b(this,c))})},b}),function(a,b){"object"==typeof exports?module.exports=b(require("jquery"),require("./jquery.draggable.js"),require("./jquery.collision.js"),require("./jquery.coords.js"),require("./utils.js")):"function"==typeof define&&define.amd?define(["jquery","gridster-draggable","gridster-collision"],b):a.Gridster=b(a.$||a.jQuery,a.GridsterDraggable,a.GridsterCollision)}(this,function(a,b,c){function d(b,c){this.options=a.extend(!0,{},g,c),this.options.draggable=this.options.draggable||{},this.options.draggable=a.extend(!0,{},this.options.draggable,{scroll_container:this.options.scroll_container}),this.$el=a(b),this.$scroll_container=this.options.scroll_container===window?a(window):this.$el.closest(this.options.scroll_container),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=a([]),this.w_queue={},this.min_widget_width=this.options.widget_base_dimensions[0],this.min_widget_height=this.options.widget_base_dimensions[1],this.min_col_count=this.options.min_cols,this.prev_col_count=this.min_col_count,this.is_responsive()&&(this.min_widget_width=this.get_responsive_col_width()),this.generated_stylesheets=[],this.$style_tags=a([]),this.options.auto_init&&this.init()}function e(a){for(var b=["col","row","size_x","size_y"],c={},d=0,e=b.length;e>d;d++){var f=b[d];if(!(f in a))throw new Error("Not exists property `"+f+"`");var g=a[f];if(!g||isNaN(g))throw new Error("Invalid value of `"+f+"` property");c[f]=+g}return c}var f=a(window),g={namespace:"",widget_selector:"li",static_class:"static",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,max_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,auto_init:!0,center_widgets:!1,responsive_breakpoint:!1,scroll_container:window,shift_larger_widgets_down:!0,serialize_params:function(a,b){return{col:b.col,row:b.row,size_x:b.size_x,size_y:b.size_y}},collision:{},draggable:{items:".gs-w:not(.static)",distance:4,ignore_dragging:b.defaults.ignore_dragging.slice(0)},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};d.defaults=g,d.generated_stylesheets=[],d.sort_by_row_asc=function(b){return b=b.sort(function(b,c){return b.row||(b=a(b).coords().grid,c=a(c).coords().grid),b=e(b),c=e(c),b.row>c.row?1:-1})},d.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row>b.row||a.row===b.row&&a.col>b.col?1:-1})},d.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.col>b.col?1:-1})},d.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a=e(a),b=e(b),a.row+a.size_ythis.cols){var k=i+(b-1)-this.cols,l=i-k;j=Math.max(1,l)}c>h&&this.add_faux_rows(Math.max(c-h,0));var m=g+b-1;m>this.cols&&this.add_faux_cols(m-this.cols);var n={col:j,row:f.row,size_x:b,size_y:c};return this.mutate_widget_in_gridmap(a,f,n),this.set_dom_grid_height(),this.set_dom_grid_width(),e&&e.call(this,n.size_x,n.size_y),a},h.expand_widget=function(b,c,d,e,f){var g=b.coords().grid,h=Math.floor((a(window).width()-2*this.options.widget_margins[0])/this.min_widget_width);c=c||Math.min(h,this.cols),d||(d=g.size_y);var i=g.size_y;b.attr("pre_expand_col",g.col),b.attr("pre_expand_sizex",g.size_x),b.attr("pre_expand_sizey",g.size_y);var j=e||1;d>i&&this.add_faux_rows(Math.max(d-i,0));var k={col:j,row:g.row,size_x:c,size_y:d};return this.mutate_widget_in_gridmap(b,g,k),this.set_dom_grid_height(),this.set_dom_grid_width(),f&&f.call(this,k.size_x,k.size_y),b},h.collapse_widget=function(a,b){var c=a.coords().grid,d=parseInt(a.attr("pre_expand_sizex")),e=parseInt(a.attr("pre_expand_sizey")),f=parseInt(a.attr("pre_expand_col")),g={col:f,row:c.row,size_x:d,size_y:e};return this.mutate_widget_in_gridmap(a,c,g),this.set_dom_grid_height(),this.set_dom_grid_width(),b&&b.call(this,g.size_x,g.size_y),a},h.fit_to_content=function(a,b,c,d){var e=a.coords().grid,f=this.$wrapper.width(),g=this.$wrapper.height(),h=this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0],i=this.options.widget_base_dimensions[1]+2*this.options.widget_margins[1],j=Math.ceil((f+2*this.options.widget_margins[0])/h),k=Math.ceil((g+2*this.options.widget_margins[1])/i),l={col:e.col,row:e.row,size_x:Math.min(b,j),size_y:Math.min(c,k)};return this.mutate_widget_in_gridmap(a,e,l),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,l.size_x,l.size_y),a},h.center_widgets=debounce(function(){var b,c=this.$wrapper.width();b=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0]+2*this.options.widget_margins[0];var d=2*Math.floor(Math.max(Math.floor(c/b),this.min_col_count)/2);this.options.min_cols=d,this.options.max_cols=d,this.options.extra_cols=0,this.options.max_size_x=d,this.set_dom_grid_width(d),this.cols=d;var e=(d-this.prev_col_count)/2;return 0>e?(this.get_min_col()>-1*e?this.shift_cols(e):this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)):e>0?(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.shift_cols(e)},this),0)):(this.resize_widget_dimensions(this.options),setTimeout(a.proxy(function(){this.resize_widget_dimensions(this.options)},this),0)),this.prev_col_count=d,this},200),h.get_min_col=function(){return Math.min.apply(Math,this.$widgets.map(a.proxy(function(b,c){return this.get_cells_occupied(a(c).coords().grid).cols},this)).get())},h.shift_cols=function(b){var c=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));c=d.sort_by_row_and_col_asc(c),c.each(a.proxy(function(c,d){var e=a(d.el),f=e.coords().grid,g=parseInt(e.attr("data-col")),h={col:Math.max(Math.round(g+b),1),row:f.row,size_x:f.size_x,size_y:f.size_y};setTimeout(a.proxy(function(){this.mutate_widget_in_gridmap(e,f,h)},this),0)},this))},h.resize_widget_dimensions=function(b){b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1];this.serialize();return this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this},h.mutate_widget_in_gridmap=function(b,c,d){var e=c.size_y,f=this.get_cells_occupied(c),g=this.get_cells_occupied(d),h=[];a.each(f.cols,function(b,c){-1===a.inArray(c,g.cols)&&h.push(c)});var i=[];a.each(g.cols,function(b,c){-1===a.inArray(c,f.cols)&&i.push(c)});var j=[];a.each(f.rows,function(b,c){-1===a.inArray(c,g.rows)&&j.push(c)});var k=[];if(a.each(g.rows,function(b,c){-1===a.inArray(c,f.rows)&&k.push(c)}),this.remove_from_gridmap(c),i.length){var l=[d.col,d.row,d.size_x,Math.min(e,d.size_y),b];this.empty_cells.apply(this,l)}if(k.length){var m=[d.col,d.row,d.size_x,d.size_y,b];this.empty_cells.apply(this,m)}if(c.col=d.col,c.row=d.row,c.size_x=d.size_x,c.size_y=d.size_y,this.add_to_gridmap(d,b),b.removeClass("player-revert"),b.data("coords").update({width:d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],height:d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1]}),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),h.length){var n=[h[0],d.row,h[h.length-1]-h[0]+1,Math.min(e,d.size_y),b];this.remove_empty_cells.apply(this,n)}if(j.length){var o=[d.col,d.row,d.size_x,d.size_y,b];this.remove_empty_cells.apply(this,o)}return this.move_widget_up(b),this},h.empty_cells=function(b,c,d,e,f){var g=this.widgets_below({col:b,row:c-e,size_x:d,size_y:e});return g.not(f).each(a.proxy(function(b,d){var f=a(d),g=f.coords().grid;if(g.row<=c+e-1){var h=c+e-g.row;this.move_widget_down(f,h)}},this)),this.set_dom_grid_height(),this},h.remove_empty_cells=function(a,b,c,d,e){this.widgets_below({col:a,row:b,size_x:c,size_y:d});return this.set_dom_grid_height(),this},h.next_position=function(a,b){a||(a=1),b||(b=1);for(var c,e=this.gridmap,f=e.length,g=[],h=1;f>h;h++){c=e[h].length;for(var i=1;c>=i;i++){var j=this.can_move_to({size_x:a,size_y:b},h,i);j&&g.push({col:h,row:i,size_y:b,size_x:a})}}return g.length?d.sort_by_row_and_col_asc(g)[0]:!1},h.remove_by_grid=function(a,b){var c=this.is_widget(a,b);c&&this.remove_widget(c)},h.remove_widget=function(b,c,d){var e=b instanceof a?b:a(b),f=e.coords().grid;a.isFunction(c)&&(d=c,c=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(e);var g=this.widgets_below(e);return this.remove_from_gridmap(f),e.fadeOut(a.proxy(function(){e.remove(),c||g.each(a.proxy(function(b,c){this.move_widget_up(a(c),f.size_y)},this)),this.set_dom_grid_height(),d&&d.call(this,b)},this)),this},h.remove_all_widgets=function(b){return this.$widgets.each(a.proxy(function(a,c){this.remove_widget(c,!0,b)},this)),this},h.serialize=function(b){b||(b=this.$widgets);var c=[];b.each(a.proxy(function(b,d){var e=a(d);"undefined"!=typeof e.coords().grid&&c.push(this.options.serialize_params(e,e.coords().grid))},this))},h.serialize_changed=function(){return this.serialize(this.$changed)},h.dom_to_coords=function(a){return{col:parseInt(a.attr("data-col"),10),row:parseInt(a.attr("data-row"),10),size_x:parseInt(a.attr("data-sizex"),10)||1,size_y:parseInt(a.attr("data-sizey"),10)||1,max_size_x:parseInt(a.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(a.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(a.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(a.attr("data-min-sizey"),10)||!1,el:a}},h.register_widget=function(b){var c=b instanceof a,d=c?this.dom_to_coords(b):b,e=!1;c||(b=d.el);var f=this.can_go_widget_up(d);if(f&&(d.row=f,b.attr("data-row",f),this.$el.trigger("gridster:positionchanged",[d]),e=!0),this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:d.size_x,size_y:d.size_y},d.col,d.row)){if(!b.hasClass(".disp_ad"))return b.remove(),!1;a.extend(d,this.next_position(d.size_x,d.size_y)),b.attr({"data-col":d.col,"data-row":d.row,"data-sizex":d.size_x,"data-sizey":d.size_y}),e=!0}return b.data("coords",b.coords()),b.data("coords").grid=d,this.add_to_gridmap(d,b),this.options.resize.enabled&&this.add_resize_handle(b),e},h.update_widget_position=function(a,b){return this.for_each_cell_occupied(a,function(a,c){return this.gridmap[a]?void(this.gridmap[a][c]=b):this}),this},h.update_widget_dimensions=function(a,b,c){return a.data("coords").update({width:b,height:c}),this},h.update_widgets_dimensions=function(){return a.each(this.$widgets,a.proxy(function(b,c){var d=a(c).coords().grid,e=d.size_x*(this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0])+(d.size_x-1)*this.options.widget_margins[0],f=d.size_y*this.options.widget_base_dimensions[1]+(d.size_y-1)*this.options.widget_margins[1];this.update_widget_dimensions(a(c),e,f)},this)),this},h.remove_from_gridmap=function(a){return this.update_widget_position(a,!1)},h.add_to_gridmap=function(a,b){this.update_widget_position(a,b||a.el)},h.draggable=function(){var b=this,c=a.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0],limit:!0,start:function(c,d){b.$widgets.filter(".player-revert").removeClass("player-revert"),b.$player=a(this),b.$helper=a(d.$helper),b.helper=!b.$helper.is(b.$player),b.on_start_drag.call(b,c,d),b.$el.trigger("gridster:dragstart")},stop:function(a,c){b.on_stop_drag.call(b,a,c),b.$el.trigger("gridster:dragstop")},drag:throttle(function(a,c){b.on_drag.call(b,a,c),b.$el.trigger("gridster:drag")},60)});this.drag_api=this.$el.dragg(c).data("drag")},h.resizable=function(){return this.resize_api=this.$el.gridDraggable({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,scroll_container:this.options.scroll_container,start:a.proxy(this.on_start_resize,this),stop:a.proxy(function(b,c){delay(a.proxy(function(){this.on_stop_resize(b,c)},this),120)},this),drag:throttle(a.proxy(this.on_resize,this),60)}),this},h.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var b=this.options.resize.axes,c=' ';return this.resize_handle_tpl=a.map(b,function(a){return c.replace("{type}",a)}).join(""),a.isArray(this.options.draggable.ignore_dragging)&&this.options.draggable.ignore_dragging.push("."+this.resize_handle_class),this},h.on_start_drag=function(b,c){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=a.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var d=this.player_grid_data.size_x,e=this.cols-this.highest_col;this.options.autogrow_cols&&d>=e&&this.add_faux_cols(Math.min(d-e,1));var f=this.faux_grid,g=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(f,this.options.collision),this.$preview_holder=a("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:g.width,height:g.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},h.on_drag=function(a,b){if(null===this.$player)return!1;var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};if(this.options.autogrow_cols){var d=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;d>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(c),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},h.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.w_queue={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0])},h.on_start_resize=function(b,c){this.$resized_widget=c.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:c.$player.is("."+this.resize_handle_class+"-x"),bottom:c.$player.is("."+this.resize_handle_class+"-y")},this.is_responsive()||this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var d=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=a("<"+d+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestart")},h.on_stop_resize=function(b,c){this.$resized_widget.removeClass("resizing").css({width:"",height:"","min-width":"","min-height":""}),delay(a.proxy(function(){this.$resize_preview_holder.remove().css({
+"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,b,c,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},h.on_resize=function(a,b){var c,d=b.pointer.diff_left,e=b.pointer.diff_top,f=this.is_responsive()?this.get_responsive_col_width():this.options.widget_base_dimensions[0],g=this.options.widget_base_dimensions[1],h=this.options.widget_margins[0],i=this.options.widget_margins[1],j=this.resize_max_size_x,k=this.resize_min_size_x,l=this.resize_max_size_y,m=this.resize_min_size_y,n=this.options.autogrow_cols,o=Math.ceil(d/(f+2*h)-.2),p=Math.ceil(e/(g+2*i)-.2),q=Math.max(1,this.resize_initial_sizex+o),r=Math.max(1,this.resize_initial_sizey+p),s=Math.floor(this.container_width/this.min_widget_width-this.resize_initial_col+1),t=s*this.min_widget_width+(s-1)*h;q=Math.max(Math.min(q,j),k),q=Math.min(s,q),c=j*f+(q-1)*h;var u=Math.min(c,t),v=k*f+(q-1)*h;r=Math.max(Math.min(r,l),m);var w=l*g+(r-1)*i,x=m*g+(r-1)*i;if(this.resize_dir.right?r=this.resize_initial_sizey:this.resize_dir.bottom&&(q=this.resize_initial_sizex),n){var y=this.resize_initial_col+q-1;n&&this.resize_initial_last_col<=y&&(this.set_dom_grid_width(Math.max(y+1,this.cols)),this.colsd;d++)-1===a.inArray(e[d],this.last_cols)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_cols[d],e)&&(c||a.noop).call(this,this.last_cols[d]);return this.last_cols=e,this},h.on_overlapped_row_change=function(b,c){if(!this.colliders_data.length)return this;var d,e=this.get_targeted_rows(this.colliders_data[0].el.data.row),f=this.last_rows.length,g=e.length;for(d=0;g>d;d++)-1===a.inArray(e[d],this.last_rows)&&(b||a.noop).call(this,e[d]);for(d=0;f>d;d++)-1===a.inArray(this.last_rows[d],e)&&(c||a.noop).call(this,this.last_rows[d]);this.last_rows=e},h.set_player=function(b,c,d){var e=this,f=!1;d||this.empty_cells_player_occupies();var g=d?{col:b}:e.colliders_data[0].el.data,h=g.col,i=g.row||c;this.player_grid_data={col:h,row:i,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data);var j=this.get_widgets_overlapped(this.player_grid_data),k=this.player_grid_data.size_y,l=this.player_grid_data.size_x,m=this.cells_occupied_by_placeholder,n=this;if(j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,g=m.cols[0]+l-1,o=m.rows[0]+k-1;if(d.hasClass(n.options.static_class))return!0;if(e.size_x<=l&&e.size_y<=k)if(n.is_swap_occupied(m.cols[0],e.row,e.size_x,e.size_y)||n.is_player_in(m.cols[0],e.row)||n.is_in_queue(m.cols[0],e.row,d))if(n.is_swap_occupied(g,e.row,e.size_x,e.size_y)||n.is_player_in(g,e.row)||n.is_in_queue(g,e.row,d))if(n.is_swap_occupied(e.col,m.rows[0],e.size_x,e.size_y)||n.is_player_in(e.col,m.rows[0])||n.is_in_queue(e.col,m.rows[0],d))if(n.is_swap_occupied(e.col,o,e.size_x,e.size_y)||n.is_player_in(e.col,o)||n.is_in_queue(e.col,o,d))if(n.is_swap_occupied(m.cols[0],m.rows[0],e.size_x,e.size_y)||n.is_player_in(m.cols[0],m.rows[0])||n.is_in_queue(m.cols[0],m.rows[0],d))for(var p=0;l>p;p++)for(var q=0;k>q;q++){var r=m.cols[0]+p,s=m.rows[0]+q;if(!n.is_swap_occupied(r,s,e.size_x,e.size_y)&&!n.is_player_in(r,s)&&!n.is_in_queue(r,s,d)){f=n.queue_widget(r,s,d),p=l;break}}else f=n.queue_widget(m.cols[0],m.rows[0],d);else f=n.queue_widget(e.col,o,d);else f=n.queue_widget(e.col,m.rows[0],d);else f=n.queue_widget(g,e.row,d);else f=n.queue_widget(m.cols[0],e.row,d);else n.options.shift_larger_widgets_down&&!f&&j.each(a.proxy(function(b,c){{var d=a(c);d.coords().grid}n.can_go_down(d)&&(n.move_widget_down(d,n.player_grid_data.size_y),n.set_placeholder(h,i))}));n.clean_up_changed()})),f&&this.can_placeholder_be_set(h,i,l,k)){for(var o in this.w_queue){var p=parseInt(o.split("_")[0]),q=parseInt(o.split("_")[1]);"full"!==this.w_queue[o]&&this.new_move_widget_to(this.w_queue[o],p,q)}this.set_placeholder(h,i)}if(!j.length){var r=this.can_go_player_up(this.player_grid_data);r!==!1&&(i=r),this.can_placeholder_be_set(h,i,l,k)&&this.set_placeholder(h,i)}return this.w_queue={},{col:h,row:i}},h.is_swap_occupied=function(a,b,c,d){for(var e=!1,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=h+"_"+i;if(this.is_occupied(h,i))e=!0;else if(j in this.w_queue){if("full"===this.w_queue[j]){e=!0;continue}var k=this.w_queue[j],l=k.coords().grid;this.is_widget_under_player(l.col,l.row)||delete this.w_queue[j]}i>parseInt(this.options.max_rows)&&(e=!0),h>parseInt(this.options.max_cols)&&(e=!0),this.is_player_in(h,i)&&(e=!0)}return e},h.can_placeholder_be_set=function(a,b,c,d){for(var e=!0,f=0;c>f;f++)for(var g=0;d>g;g++){var h=a+f,i=b+g,j=this.is_widget(h,i);i>parseInt(this.options.max_rows)&&(e=!1),h>parseInt(this.options.max_cols)&&(e=!1),this.is_occupied(h,i)&&!this.is_widget_queued_and_can_move(j)&&(e=!1)}return e},h.queue_widget=function(a,b,c){var d=c,e=d.coords().grid,f=a+"_"+b;if(f in this.w_queue)return!1;this.w_queue[f]=d;for(var g=0;g=0&&a.inArray(c,d.rows)>=0},h.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},h.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},h.is_empty=function(a,b){return"undefined"!=typeof this.gridmap[a]?"undefined"!=typeof this.gridmap[a][b]&&this.gridmap[a][b]===!1?!0:!1:!0},h.is_occupied=function(a,b){return this.gridmap[a]&&this.gridmap[a][b]?!0:!1},h.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},h.is_static=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c&&c.hasClass(this.options.static_class)?!0:!1):!1},h.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},h.get_widgets_under_player=function(b){b||(b=this.cells_occupied_by_player||{cols:[],rows:[]});var c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},h.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b-=f-b);var g=this.placeholder_grid_data.row0&&(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f));)d[a].push(h),e=e>h?h:e;return 0===d[a].length?(c=!1,!0):void d[a].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.can_go_widget_up=function(a){var b=a.row+a.size_y-1,c=!0,d=[],e=1e4;return this.for_each_column_occupied(a,function(f){var g=this.gridmap[f];d[f]=[];for(var h=b+1;--h>0&&(!this.is_widget(f,h)||this.is_player_in(f,h)||g[h].is(a.el));)this.is_player(f,h)||this.is_placeholder_in(f,h)||this.is_player_in(f,h)||d[f].push(h),e>h&&(e=h);return 0===d[f].length?(c=!1,!0):void d[f].sort(function(a,b){return a-b})}),c?this.get_valid_rows(a,d,e):!1},h.get_valid_rows=function(b,c,d){for(var e=b.row,f=b.row+b.size_y-1,g=b.size_y,h=d-1,i=[];++h<=f;){var j=!0;if(a.each(c,function(b,c){a.isArray(c)&&-1===a.inArray(h,c)&&(j=!1)}),j===!0&&(i.push(h),i.length===g))break}var k=!1;return 1===g?i[0]!==e&&(k=i[0]||!1):i[0]!==e&&(k=this.get_consecutive_numbers_index(i,g)),k},h.get_consecutive_numbers_index=function(a,b){for(var c=a.length,d=[],e=!0,f=-1,g=0;c>g;g++){if(e||a[g]===f+1){if(d.push(g),d.length===b)break;e=!1}else d=[],e=!0;f=a[g]}return d.length>=b?a[d[0]]:!1},h.get_widgets_overlapped=function(){var b=a([]),c=[],d=this.cells_occupied_by_player.rows.slice(0);return d.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(e,f){a.each(d,a.proxy(function(d,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&-1===a.inArray(g,c)&&(b=b.add(g),c.push(g))},this))},this)),b},h.on_start_overlapping_column=function(a){this.set_player(a,!1)},h.on_start_overlapping_row=function(a){this.set_player(!1,a)},h.on_stop_overlapping_column=function(a){var b=this;this.options.shift_larger_widgets_down&&this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},h.on_stop_overlapping_row=function(a){var b=this,c=this.cells_occupied_by_player.cols;if(this.options.shift_larger_widgets_down)for(var d=0,e=c.length;e>d;d++)this.for_each_widget_below(c[d],a,function(a,c){console.log("from_on_stop_overlapping_row"),b.move_widget_up(this,b.player_grid_data.size_y)})},h.new_move_widget_to=function(a,b,c){var d=a.coords().grid;return this.remove_from_gridmap(d),d.row=c,d.col=b,this.add_to_gridmap(d),a.attr("data-row",c),a.attr("data-col",b),this.update_widget_position(d,a),this.$changed=this.$changed.add(a),this},h.move_widget=function(a,b,c,d){var e=a.coords().grid,f={col:b,row:c,size_x:e.size_x,size_y:e.size_y};return this.mutate_widget_in_gridmap(a,e,f),this.set_dom_grid_height(),this.set_dom_grid_width(),d&&d.call(this,f.col,f.row),a},h.move_widget_to=function(b,c){var d=this,e=b.coords().grid,f=(c-e.row,this.widgets_below(b)),g=this.can_move_to(e,e.col,c,b);return g===!1?!1:(this.remove_from_gridmap(e),e.row=c,this.add_to_gridmap(e),b.attr("data-row",c),this.$changed=this.$changed.add(b),f.each(function(b,c){var e=a(c),f=e.coords().grid,g=d.can_go_widget_up(f);g&&g!==f.row&&d.move_widget_to(e,g)}),this)},h.move_widget_up=function(b,c){var d=b.coords().grid,e=d.row,f=[];return c||(c=1),this.can_go_up(b)?void this.for_each_column_occupied(d,function(d){if(-1===a.inArray(b,f)){var g=b.coords().grid,h=e-c;if(h=this.can_go_up_to_row(g,d,h),!h)return!0;{this.widgets_below(b)}this.remove_from_gridmap(g),g.row=h,this.add_to_gridmap(g),b.attr("data-row",g.row),this.$changed=this.$changed.add(b),f.push(b)}}):!1},h.move_widget_down=function(b,c){var d,e,f,g;if(0>=c)return!1;if(d=b.coords().grid,e=d.row,f=[],g=c,!b)return!1;if(-1===a.inArray(b,f)){var h=b.coords().grid,i=e+c,j=this.widgets_below(b);this.remove_from_gridmap(h),j.each(a.proxy(function(b,c){var d=a(c),e=d.coords().grid,f=this.displacement_diff(e,h,g);f>0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},h.can_go_up_to_row=function(b,c,d){var e,f=this.gridmap,g=!0,h=[],i=b.row;if(this.for_each_column_occupied(b,function(a){f[a];for(h[a]=[],e=i;e--&&this.is_empty(a,e)&&!this.is_placeholder_in(a,e);)h[a].push(e);return h[a].length?void 0:(g=!1,!0)}),!g)return!1;for(e=d,e=1;i>e;e++){for(var j=!0,k=0,l=h.length;l>k;k++)h[k]&&-1===a.inArray(e,h[k])&&(j=!1);if(j===!0){g=e;break}}return g},h.displacement_diff=function(a,b,c){var d=a.row,e=[],f=b.row+b.size_y;this.for_each_column_occupied(a,function(a){for(var b=0,c=f;d>c;c++)this.is_empty(a,c)&&(b+=1);e.push(b)});var g=Math.max.apply(Math,e);return c-=g,c>0?c:0},h.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,e=this,f=(this.gridmap,c.row+c.size_y-1),g=a([]);return this.for_each_column_occupied(c,function(b){e.for_each_widget_below(b,f,function(b,c){return e.is_player(this)||-1!==a.inArray(this,g)?void 0:(g=g.add(this),!0)})}),d.sort_by_row_asc(g)},h.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},h.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},h.can_go_down=function(b){var c=!0,d=this;return b.hasClass(this.options.static_class)&&(c=!1),this.widgets_below(b).each(function(){a(this).hasClass(d.options.static_class)&&(c=!1)}),c},h.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=(this.gridmap,!0);return 1===c?!1:(this.for_each_column_occupied(b,function(a){this.is_widget(a,d);return this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d)||this.is_player_in(a,d)?(e=!1,!0):void 0}),e)},h.can_move_to=function(a,b,c,d){var e=(this.gridmap,a.el),f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:d&&d=d;d++)c.push(d);return c},h.get_targeted_rows=function(a){for(var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[],d=a;b>=d;d++)c.push(d);return c},h.get_cells_occupied=function(b){var c,d={cols:[],rows:[]};for(arguments[1]instanceof a&&(b=arguments[1].coords().grid),c=0;c0&&this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]),h)););},"for_each/below":function(){for(m=e+1,i=g[d].length;i>m;m++)this.is_widget(d,m)&&-1===a.inArray(g[d][m],l)&&(h=f.call(g[d][m],d,m),l.push(g[d][m]))}};n[j]&&n[j].call(this)}},h.for_each_widget_above=function(a,b,c){return this._traversing_widgets("for_each","above",a,b,c),this},h.for_each_widget_below=function(a,b,c){return this._traversing_widgets("for_each","below",a,b,c),this},h.get_highest_occupied_cell=function(){for(var a,b=this.gridmap,c=b[1].length,d=[],e=[],f=b.length-1;f>=1;f--)for(a=c-1;a>=1;a--)if(this.is_widget(f,a)){d.push(a),e.push(f);break}return{col:Math.max.apply(Math,e),row:Math.max.apply(Math,d)}},h.get_widgets_from=function(b,c){var d=(this.gridmap,a());return b&&(d=d.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c===b||c>b}))),c&&(d=d.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b===c||b>c}))),d},h.set_dom_grid_height=function(a){if("undefined"==typeof a){var b=this.get_highest_occupied_cell().row;a=(b+1)*this.options.widget_margins[1]+b*this.min_widget_height}return this.container_height=a,this.$el.css("height",this.container_height),this},h.set_dom_grid_width=function(a){"undefined"==typeof a&&(a=this.get_highest_occupied_cell().col);var b=this.options.autogrow_cols?this.options.max_cols:this.cols;return a=Math.min(b,Math.max(a,this.options.min_cols)),this.container_width=(a+1)*this.options.widget_margins[0]+a*this.min_widget_width,this.is_responsive()?(this.$el.css({"min-width":"100vw","max-width":"100vw"}),this):(this.$el.css("width",this.container_width),this)},h.is_responsive=function(){return this.options.autogenerate_stylesheet&&"auto"===this.options.widget_base_dimensions[0]&&this.options.max_cols!==1/0},h.get_responsive_col_width=function(){var a=this.cols||this.options.max_cols;return(this.$el.width()-(a+1)*this.options.widget_margins[0])/a},h.resize_responsive_layout=function(){return this.min_widget_width=this.get_responsive_col_width(),this.generate_stylesheet(),this.update_widgets_dimensions(),this.drag_api.set_limits(this.cols*this.min_widget_width+(this.cols+1)*this.options.widget_margins[0]),this},h.toggle_collapsed_grid=function(a,b){return a?(this.$widgets.css({"margin-top":b.widget_margins[0],"margin-bottom":b.widget_margins[0],"min-height":b.widget_base_dimensions[1]}),this.$el.addClass("collapsed"),this.resize_api&&this.disable_resize(),this.drag_api&&this.disable()):(this.$widgets.css({"margin-top":"auto","margin-bottom":"auto","min-height":"auto"}),this.$el.removeClass("collapsed"),this.resize_api&&this.enable_resize(),this.drag_api&&this.enable()),this},h.generate_stylesheet=function(b){var c,e="",f=this.options.max_size_x||this.cols,g=this.is_responsive()&&this.options.responsive_breakpoint&&a(window).width()=0)return!1;for(this.generated_stylesheets.push(h),d.generated_stylesheets.push(h),c=1;c<=b.cols+1;c++)e+=b.namespace+' [data-col="'+c+'"] { left:'+(g?this.options.widget_margins[0]:c*b.widget_margins[0]+(c-1)*b.widget_base_dimensions[0])+"px; }\n";for(c=1;c<=b.rows+1;c++)e+=b.namespace+' [data-row="'+c+'"] { top:'+(c*b.widget_margins[1]+(c-1)*b.widget_base_dimensions[1])+"px; }\n";for(var i=1;i<=b.rows;i++)e+=b.namespace+' [data-sizey="'+i+'"] { height:'+(g?"auto":i*b.widget_base_dimensions[1]+(i-1)*b.widget_margins[1])+"px; }\n";for(var j=1;f>=j;j++)e+=b.namespace+' [data-sizex="'+j+'"] { width:'+(g?a(window).width()-2*this.options.widget_margins[0]:j*b.widget_base_dimensions[0]+(j-1)*b.widget_margins[0])+"px; }\n";return this.remove_style_tags(),this.add_style_tag(e)},h.add_style_tag=function(a){var b=document;if(!document.getElementById("gridster-stylesheet")){var c=b.createElement("style");c.id="gridster-stylesheet",b.getElementsByTagName("head")[0].appendChild(c),c.setAttribute("type","text/css"),c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a)),this.remove_style_tags(),this.$style_tags=this.$style_tags.add(c)}return this},h.remove_style_tags=function(){var b=d.generated_stylesheets,c=this.generated_stylesheets;this.$style_tags.remove(),d.generated_stylesheets=a.map(b,function(b){return-1===a.inArray(b,c)?b:void 0})},h.generate_faux_grid=function(a,b){this.faux_grid=[],this.gridmap=[];var c,d;for(c=b;c>0;c--)for(this.gridmap[c]=[],d=a;d>0;d--)this.add_faux_cell(d,c);return this},h.add_faux_cell=function(b,c){var d=a({left:this.baseX+(c-1)*this.min_widget_width,top:this.baseY+(b-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:c,row:b,original_col:c,original_row:b}).coords();return a.isArray(this.gridmap[c])||(this.gridmap[c]=[]),"undefined"==typeof this.gridmap[c][b]&&(this.gridmap[c][b]=!1),this.faux_grid.push(d),this},h.add_faux_rows=function(a){a=window.parseInt(a,10);for(var b=this.rows,c=b+parseInt(a||1),d=c;d>b;d--)for(var e=this.cols;e>=1;e--)this.add_faux_cell(d,e);return this.rows=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.add_faux_cols=function(a){a=window.parseInt(a,10);var b=this.cols,c=b+parseInt(a||1);c=Math.min(c,this.options.max_cols);for(var d=b+1;c>=d;d++)for(var e=this.rows;e>=1;e--)this.add_faux_cell(e,d);return this.cols=c,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},h.recalculate_faux_grid=function(){var b=this.$wrapper.width();return this.baseX=(f.width()-b)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this.is_responsive()&&this.resize_responsive_layout(),this.options.center_widgets&&this.center_widgets(),this},h.resize_widget_dimensions=function(b){return b.widget_margins&&(this.options.widget_margins=b.widget_margins),b.widget_base_dimensions&&(this.options.widget_base_dimensions=b.widget_base_dimensions),this.$widgets.each(a.proxy(function(b,c){var d=a(c);this.resize_widget(d)},this)),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this},h.get_widgets_from_DOM=function(){var b=this.$widgets.map(a.proxy(function(b,c){var d=a(c);return this.dom_to_coords(d)},this));b=d.sort_by_row_and_col_asc(b);var c=a(b).map(a.proxy(function(a,b){return this.register_widget(b)||null},this));return c.length&&this.$el.trigger("gridster:positionschanged"),this},h.set_num_columns=function(b){var c=this.options.max_cols,d=Math.floor(b/(this.min_widget_width+this.options.widget_margins[0]))+this.options.extra_cols,e=this.$widgets.map(function(){return a(this).attr("data-col")}).get();e.length||(e=[0]);var f=Math.max.apply(Math,e);this.cols=Math.max(f,d,this.options.min_cols),c!==1/0&&c>=f&&c=0;b--)if(this.is_widget(a,b)!==!1)return!0;return!1},c.widgets_in_row=function(a){for(var b=this.gridmap.length;b>=1;b--)if(this.is_widget(b,a)!==!1)return!0;return!1},c.widgets_in_range=function(b,c,d,e){var f,g,h,i,j=a([]);for(f=d;f>=b;f--)for(g=e;g>=c;g--)h=this.is_widget(f,g),h!==!1&&(i=h.data("coords").grid,i.col>=b&&i.col<=d&&i.row>=c&&i.row<=e&&(j=j.add(h)));return j},c.get_bottom_most_occupied_cell=function(){var a=0,b=0;return this.for_each_cell(function(c,d,e){c&&e>a&&(a=e,b=d)}),{col:b,row:a}},c.get_right_most_occupied_cell=function(){var a=0,b=0;return this.for_each_cell(function(c,d,e){return c?(a=e,b=d,!1):void 0}),{col:b,row:a}},c.for_each_cell=function(a,b){b||(b=this.gridmap);var c=b.length,d=b[1].length;a:for(var e=c-1;e>=1;e--)for(var f=d-1;f>=1;f--){var g=b[e]&&b[e][f];if(a){if(a.call(this,g,e,f)===!1)break a}else;}},c.next_position_in_range=function(a,c,d){a||(a=1),c||(c=1);for(var e,f=this.gridmap,g=f.length,h=[],i=1;g>i;i++){e=d||f[i].length;for(var j=1;e>=j;j++){var k=this.can_move_to({size_x:a,size_y:c},i,j,d);k&&h.push({col:i,row:j,size_y:c,size_x:a})}}return h.length>=1?b.sort_by_col_asc(h)[0]:!1},c.closest_to_right=function(a,b){if(!this.gridmap[a])return!1;for(var c=this.gridmap.length-1,d=a;c>=d;d++)if(this.gridmap[d][b])return{col:d,row:b};return!1},c.closest_to_left=function(a,b){this.gridmap.length-1;if(!this.gridmap[a])return!1;for(var c=a;c>=1;c--)if(this.gridmap[c][b])return{col:c,row:b};return!1},b});
\ No newline at end of file
diff --git a/package.json b/package.json
index b2ab4a24ae..97063874a5 100644
--- a/package.json
+++ b/package.json
@@ -5,8 +5,7 @@
"version": "0.6.6",
"homepage": "http://gridster.net/",
"author": {
- "name": "decksterteam",
- "email": "deckster@42six.com"
+ "name": "ducksboard"
},
"repository": {
"type": "git",
@@ -24,14 +23,18 @@
"keywords": [],
"devDependencies": {
"bower": "~0.9.2",
- "grunt": "~0.4.1",
+ "grunt": "~0.4.5",
"grunt-bump": "0.0.11",
- "grunt-contrib-concat": "~0.1.3",
- "grunt-contrib-cssmin": "~0.5.0",
- "grunt-contrib-jshint": "~0.3.0",
- "grunt-contrib-uglify": "~0.2.0",
- "grunt-contrib-watch": "~0.3.1",
- "grunt-contrib-yuidoc": "~0.4.0",
- "grunt-conventional-changelog": "~1.0.0"
+ "grunt-contrib-clean": "^0.6.0",
+ "grunt-contrib-concat": "^0.5.0",
+ "grunt-contrib-copy": "^0.8.0",
+ "grunt-contrib-cssmin": "~0.10.0",
+ "grunt-contrib-jshint": "~0.10.0",
+ "grunt-contrib-uglify": "~0.6.0",
+ "grunt-contrib-watch": "~0.6.1",
+ "grunt-contrib-yuidoc": "~0.7.0",
+ "grunt-conventional-changelog": "~1.0.0",
+ "grunt-gh-pages": "^0.10.0",
+ "jshint-stylish": "^1.0.1"
}
}
diff --git a/sample/css/main.css b/sample/css/main.css
deleted file mode 100755
index 8777993ddb..0000000000
--- a/sample/css/main.css
+++ /dev/null
@@ -1,68 +0,0 @@
-body {
- background: #004756;
-}
-
-/* Gridster styles */
-.demo {
- margin: 3em 0;
- padding: 7.5em 0 5.5em;
- background: #004756;
-}
-
-.demo:hover .gridster {
- opacity: 1;
-}
-
-.gridster, .content, .gridster2 {
-/*
- width: 940px;
- margin: 0 auto;
-*/
- opacity: .8;
- -webkit-transition: opacity .6s;
- -moz-transition: opacity .6s;
- -o-transition: opacity .6s;
- -ms-transition: opacity .6s;
- transition: opacity .6s;
-}
-
-.content {
- color: white;
-}
-
-.gridster .gs-w, .gridster2 .gs-w {
- background: #FFFFFF;
- cursor: pointer;
- -webkit-box-shadow: 0 0 5px rgba(0,0,0,0.3);
- box-shadow: 0 0 5px rgba(0,0,0,0.3);
-}
-
-.gridster .player, .gridster2 .player {
- -webkit-box-shadow: 3px 3px 5px rgba(0,0,0,0.3);
- box-shadow: 3px 3px 5px rgba(0,0,0,0.3);
-}
-
-
-.gridster .gs-w.try, .gridster2 .gs-w.try {
- background-image: url(../img/sprite.png);
- background-repeat: no-repeat;
- background-position: 37px -169px;
-
-}
-
-.gridster .preview-holder, .gridster2 .preview-holder {
- border: none!important;
- border-radius: 0!important;
- background: rgba(255,255,255,.2)!important;
-}
-
-li {
- list-style: none;
- font-weight: bold
-}
-
-.gridster-box {
- position: relative;
- width: 100%;
- height: 100%;
-}
diff --git a/sample/css/normalize.css b/sample/css/normalize.css
deleted file mode 100755
index 4d4d01d158..0000000000
--- a/sample/css/normalize.css
+++ /dev/null
@@ -1,527 +0,0 @@
-/*! normalize.css v1.1.0 | MIT License | git.io/normalize */
-
-/* ==========================================================================
- HTML5 display definitions
- ========================================================================== */
-
-/**
- * Correct `block` display not defined in IE 6/7/8/9 and Firefox 3.
- */
-
-article,
-aside,
-details,
-figcaption,
-figure,
-footer,
-header,
-hgroup,
-main,
-nav,
-section,
-summary {
- display: block;
-}
-
-/**
- * Correct `inline-block` display not defined in IE 6/7/8/9 and Firefox 3.
- */
-
-audio,
-canvas,
-video {
- display: inline-block;
- *display: inline;
- *zoom: 1;
-}
-
-/**
- * Prevent modern browsers from displaying `audio` without controls.
- * Remove excess height in iOS 5 devices.
- */
-
-audio:not([controls]) {
- display: none;
- height: 0;
-}
-
-/**
- * Address styling not present in IE 7/8/9, Firefox 3, and Safari 4.
- * Known issue: no IE 6 support.
- */
-
-[hidden] {
- display: none;
-}
-
-/* ==========================================================================
- Base
- ========================================================================== */
-
-/**
- * 1. Correct text resizing oddly in IE 6/7 when body `font-size` is set using
- * `em` units.
- * 2. Prevent iOS text size adjust after orientation change, without disabling
- * user zoom.
- */
-
-html {
- font-size: 100%; /* 1 */
- -webkit-text-size-adjust: 100%; /* 2 */
- -ms-text-size-adjust: 100%; /* 2 */
-}
-
-/**
- * Address `font-family` inconsistency between `textarea` and other form
- * elements.
- */
-
-html,
-button,
-input,
-select,
-textarea {
- font-family: sans-serif;
-}
-
-/**
- * Address margins handled incorrectly in IE 6/7.
- */
-
-body {
- margin: 0;
-}
-
-/* ==========================================================================
- Links
- ========================================================================== */
-
-/**
- * Address `outline` inconsistency between Chrome and other browsers.
- */
-
-a:focus {
- outline: thin dotted;
-}
-
-/**
- * Improve readability when focused and also mouse hovered in all browsers.
- */
-
-a:active,
-a:hover {
- outline: 0;
-}
-
-/* ==========================================================================
- Typography
- ========================================================================== */
-
-/**
- * Address font sizes and margins set differently in IE 6/7.
- * Address font sizes within `section` and `article` in Firefox 4+, Safari 5,
- * and Chrome.
- */
-
-h1 {
- font-size: 2em;
- margin: 0.67em 0;
-}
-
-h2 {
- font-size: 1.5em;
- margin: 0.83em 0;
-}
-
-h3 {
- font-size: 1.17em;
- margin: 1em 0;
-}
-
-h4 {
- font-size: 1em;
- margin: 1.33em 0;
-}
-
-h5 {
- font-size: 0.83em;
- margin: 1.67em 0;
-}
-
-h6 {
- font-size: 0.67em;
- margin: 2.33em 0;
-}
-
-/**
- * Address styling not present in IE 7/8/9, Safari 5, and Chrome.
- */
-
-abbr[title] {
- border-bottom: 1px dotted;
-}
-
-/**
- * Address style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome.
- */
-
-b,
-strong {
- font-weight: bold;
-}
-
-blockquote {
- margin: 1em 40px;
-}
-
-/**
- * Address styling not present in Safari 5 and Chrome.
- */
-
-dfn {
- font-style: italic;
-}
-
-/**
- * Address differences between Firefox and other browsers.
- * Known issue: no IE 6/7 normalization.
- */
-
-hr {
- -moz-box-sizing: content-box;
- box-sizing: content-box;
- height: 0;
-}
-
-/**
- * Address styling not present in IE 6/7/8/9.
- */
-
-mark {
- background: #ff0;
- color: #000;
-}
-
-/**
- * Address margins set differently in IE 6/7.
- */
-
-p,
-pre {
- margin: 1em 0;
-}
-
-/**
- * Correct font family set oddly in IE 6, Safari 4/5, and Chrome.
- */
-
-code,
-kbd,
-pre,
-samp {
- font-family: monospace, serif;
- _font-family: 'courier new', monospace;
- font-size: 1em;
-}
-
-/**
- * Improve readability of pre-formatted text in all browsers.
- */
-
-pre {
- white-space: pre;
- white-space: pre-wrap;
- word-wrap: break-word;
-}
-
-/**
- * Address CSS quotes not supported in IE 6/7.
- */
-
-q {
- quotes: none;
-}
-
-/**
- * Address `quotes` property not supported in Safari 4.
- */
-
-q:before,
-q:after {
- content: '';
- content: none;
-}
-
-/**
- * Address inconsistent and variable font size in all browsers.
- */
-
-small {
- font-size: 80%;
-}
-
-/**
- * Prevent `sub` and `sup` affecting `line-height` in all browsers.
- */
-
-sub,
-sup {
- font-size: 75%;
- line-height: 0;
- position: relative;
- vertical-align: baseline;
-}
-
-sup {
- top: -0.5em;
-}
-
-sub {
- bottom: -0.25em;
-}
-
-/* ==========================================================================
- Lists
- ========================================================================== */
-
-/**
- * Address margins set differently in IE 6/7.
- */
-
-dl,
-menu,
-ol,
-ul {
- margin: 1em 0;
-}
-
-dd {
- margin: 0 0 0 40px;
-}
-
-/**
- * Address paddings set differently in IE 6/7.
- */
-
-menu,
-ol,
-ul {
- padding: 0 0 0 40px;
-}
-
-/**
- * Correct list images handled incorrectly in IE 7.
- */
-
-nav ul,
-nav ol {
- list-style: none;
- list-style-image: none;
-}
-
-/* ==========================================================================
- Embedded content
- ========================================================================== */
-
-/**
- * 1. Remove border when inside `a` element in IE 6/7/8/9 and Firefox 3.
- * 2. Improve image quality when scaled in IE 7.
- */
-
-img {
- border: 0; /* 1 */
- -ms-interpolation-mode: bicubic; /* 2 */
-}
-
-/**
- * Correct overflow displayed oddly in IE 9.
- */
-
-svg:not(:root) {
- overflow: hidden;
-}
-
-/* ==========================================================================
- Figures
- ========================================================================== */
-
-/**
- * Address margin not present in IE 6/7/8/9, Safari 5, and Opera 11.
- */
-
-figure {
- margin: 0;
-}
-
-/* ==========================================================================
- Forms
- ========================================================================== */
-
-/**
- * Correct margin displayed oddly in IE 6/7.
- */
-
-form {
- margin: 0;
-}
-
-/**
- * Define consistent border, margin, and padding.
- */
-
-fieldset {
- border: 1px solid #c0c0c0;
- margin: 0 2px;
- padding: 0.35em 0.625em 0.75em;
-}
-
-/**
- * 1. Correct color not being inherited in IE 6/7/8/9.
- * 2. Correct text not wrapping in Firefox 3.
- * 3. Correct alignment displayed oddly in IE 6/7.
- */
-
-legend {
- border: 0; /* 1 */
- padding: 0;
- white-space: normal; /* 2 */
- *margin-left: -7px; /* 3 */
-}
-
-/**
- * 1. Correct font size not being inherited in all browsers.
- * 2. Address margins set differently in IE 6/7, Firefox 3+, Safari 5,
- * and Chrome.
- * 3. Improve appearance and consistency in all browsers.
- */
-
-button,
-input,
-select,
-textarea {
- font-size: 100%; /* 1 */
- margin: 0; /* 2 */
- vertical-align: baseline; /* 3 */
- *vertical-align: middle; /* 3 */
-}
-
-/**
- * Address Firefox 3+ setting `line-height` on `input` using `!important` in
- * the UA stylesheet.
- */
-
-button,
-input {
- line-height: normal;
-}
-
-/**
- * Address inconsistent `text-transform` inheritance for `button` and `select`.
- * All other form control elements do not inherit `text-transform` values.
- * Correct `button` style inheritance in Chrome, Safari 5+, and IE 6+.
- * Correct `select` style inheritance in Firefox 4+ and Opera.
- */
-
-button,
-select {
- text-transform: none;
-}
-
-/**
- * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
- * and `video` controls.
- * 2. Correct inability to style clickable `input` types in iOS.
- * 3. Improve usability and consistency of cursor style between image-type
- * `input` and others.
- * 4. Remove inner spacing in IE 7 without affecting normal text inputs.
- * Known issue: inner spacing remains in IE 6.
- */
-
-button,
-html input[type="button"], /* 1 */
-input[type="reset"],
-input[type="submit"] {
- -webkit-appearance: button; /* 2 */
- cursor: pointer; /* 3 */
- *overflow: visible; /* 4 */
-}
-
-/**
- * Re-set default cursor for disabled elements.
- */
-
-button[disabled],
-html input[disabled] {
- cursor: default;
-}
-
-/**
- * 1. Address box sizing set to content-box in IE 8/9.
- * 2. Remove excess padding in IE 8/9.
- * 3. Remove excess padding in IE 7.
- * Known issue: excess padding remains in IE 6.
- */
-
-input[type="checkbox"],
-input[type="radio"] {
- box-sizing: border-box; /* 1 */
- padding: 0; /* 2 */
- *height: 13px; /* 3 */
- *width: 13px; /* 3 */
-}
-
-/**
- * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome.
- * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome
- * (include `-moz` to future-proof).
- */
-
-input[type="search"] {
- -webkit-appearance: textfield; /* 1 */
- -moz-box-sizing: content-box;
- -webkit-box-sizing: content-box; /* 2 */
- box-sizing: content-box;
-}
-
-/**
- * Remove inner padding and search cancel button in Safari 5 and Chrome
- * on OS X.
- */
-
-input[type="search"]::-webkit-search-cancel-button,
-input[type="search"]::-webkit-search-decoration {
- -webkit-appearance: none;
-}
-
-/**
- * Remove inner padding and border in Firefox 3+.
- */
-
-button::-moz-focus-inner,
-input::-moz-focus-inner {
- border: 0;
- padding: 0;
-}
-
-/**
- * 1. Remove default vertical scrollbar in IE 6/7/8/9.
- * 2. Improve readability and alignment in all browsers.
- */
-
-textarea {
- overflow: auto; /* 1 */
- vertical-align: top; /* 2 */
-}
-
-/* ==========================================================================
- Tables
- ========================================================================== */
-
-/**
- * Remove most spacing between table cells.
- */
-
-table {
- border-collapse: collapse;
- border-spacing: 0;
-}
diff --git a/sample/index.html b/sample/index.html
deleted file mode 100644
index 4ff9fd4838..0000000000
--- a/sample/index.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
- Gridster Demos
-
-
-
-
-
-
-
-
-
Samples
-
-
-
-
-
-
diff --git a/sample/js/plugins.js b/sample/js/plugins.js
deleted file mode 100755
index 728680b08d..0000000000
--- a/sample/js/plugins.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Avoid `console` errors in browsers that lack a console.
-(function() {
- var method;
- var noop = function () {};
- var methods = [
- 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
- 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
- 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
- 'timeStamp', 'trace', 'warn'
- ];
- var length = methods.length;
- var console = (window.console = window.console || {});
-
- while (length--) {
- method = methods[length];
-
- // Only stub undefined methods.
- if (!console[method]) {
- console[method] = noop;
- }
- }
-}());
-
-// Place any jQuery/helper plugins in here.
diff --git a/src/jquery.draggable.js b/src/jquery.draggable.js
index ec859c1a48..94d7ac9c92 100644
--- a/src/jquery.draggable.js
+++ b/src/jquery.draggable.js
@@ -82,9 +82,8 @@
this.options = $.extend({}, defaults, options);
this.$document = $(document);
this.$container = $(el);
- this.$scroll_container = this.options.scroll_container == window ?
+ this.$scroll_container = this.options.scroll_container === window ?
$(window) : this.$container.closest(this.options.scroll_container);
- this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
this.player_min_left = 0 + this.options.offset_left;
this.id = uniqId();
@@ -104,7 +103,7 @@
this.events();
$window.bind(this.nsEvent('resize'),
- throttle($.proxy(this.calculate_dimensions, this), 200));
+ throttle($.proxy(this.calculate_dimensions, this), 200));
};
fn.nsEvent = function(ev) {
@@ -135,8 +134,7 @@
};
fn.get_actual_pos = function($el) {
- var pos = $el.position();
- return pos;
+ return $el.position();
};
@@ -271,14 +269,13 @@
};
- fn.calculate_dimensions = function(e) {
+ fn.calculate_dimensions = function() {
this.scroller_height = this.$scroll_container.height();
this.scroller_width = this.$scroll_container.width();
};
fn.drag_handler = function(e) {
- var node = e.target.nodeName;
// skip if drag is disabled, or click was not done with the mouse primary button
if (this.disabled || e.which !== 1 && !isTouch) {
return;
@@ -334,7 +331,6 @@
var offset = this.$container.offset();
this.baseX = Math.round(offset.left);
this.baseY = Math.round(offset.top);
- this.initial_container_width = this.options.container_width || this.$container.width();
if (this.options.helper === 'clone') {
this.$helper = this.$player.clone()
@@ -346,11 +342,8 @@
this.scroll_container_offset_y = this.$scroll_container.scrollTop();
this.scroll_container_offset_x = this.$scroll_container.scrollLeft();
- this.scroll_offset_y = 0;
- this.scroll_offset_x = 0;
this.el_init_offset = this.$player.offset();
this.player_width = this.$player.width();
- this.player_height = this.$player.height();
this.set_limits(this.options.container_width);
diff --git a/src/jquery.gridster.css b/src/jquery.gridster.css
index c98cb2a3cc..51fbc713c0 100644
--- a/src/jquery.gridster.css
+++ b/src/jquery.gridster.css
@@ -3,7 +3,6 @@
}
.gridster > * {
- margin: 0 auto;
-webkit-transition: height .4s, width .4s;
-moz-transition: height .4s, width .4s;
-o-transition: height .4s, width .4s;
diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js
index f1f1e0df66..5af16f0e4a 100755
--- a/src/jquery.gridster.js
+++ b/src/jquery.gridster.js
@@ -145,7 +145,7 @@
this.options.draggable = $.extend(true, {}, this.options.draggable,
{scroll_container: this.options.scroll_container});
this.$el = $(el);
- this.$scroll_container = this.options.scroll_container == window ?
+ this.$scroll_container = this.options.scroll_container === window ?
$(window) : this.$el.closest(this.options.scroll_container);
this.$wrapper = this.$el.parent();
this.$widgets = this.$el.children(
@@ -431,7 +431,7 @@
}, this), 0);
}
- return $w.fadeIn({complete: function () { if(callback) callback.call(this); }});
+ return $w.fadeIn({complete: function () { if(callback) {callback.call(this);} }});
};
@@ -493,7 +493,7 @@
fn.add_resize_handle = function($w) {
var $append_to = this.options.resize.handle_append_to ? $(this.options.resize.handle_append_to, $w) : $w;
- if ( ($append_to.children("span[class~='" + this.resize_handle_class + "']")).length == 0 ) {
+ if ( ($append_to.children("span[class~='" + this.resize_handle_class + "']")).length === 0 ) {
$(this.resize_handle_tpl).appendTo( $append_to );
}
@@ -947,7 +947,9 @@
$nexts.not($exclude).each($.proxy(function(i, w) {
var $w = $( w ),
wgd = $w.coords().grid;
+ /*jshint -W018 */
if ( !(wgd.row <= (row + size_y - 1))) { return; }
+ /*jshint +W018 */
var diff = (row + size_y) - wgd.row;
this.move_widget_down($w, diff);
}, this));
@@ -1040,7 +1042,7 @@
if($w){
this.remove_widget($w);
}
- }
+ };
/**
@@ -1120,7 +1122,8 @@
$widgets || ($widgets = this.$widgets);
var result = [];
$widgets.each($.proxy(function(i, widget) {
- if(typeof($(widget).coords().grid) != "undefined"){
+ var $w = $(widget);
+ if(typeof($w.coords().grid) !== 'undefined'){
result.push(this.options.serialize_params($w, $w.coords().grid) );
}
}, this));
@@ -1730,12 +1733,12 @@
size_x = Math.max(Math.min(size_x, max_size_x), min_size_x);
size_x = Math.min(max_cols, size_x);
width = (max_size_x * wbd_x) + ((size_x - 1) * margin_x );
- max_width = Math.min(width, limit_width);
- min_width = (min_size_x * wbd_x) + ((size_x - 1) * margin_x);
+ var max_width = Math.min(width, limit_width);
+ var min_width = (min_size_x * wbd_x) + ((size_x - 1) * margin_x);
size_y = Math.max(Math.min(size_y, max_size_y), min_size_y);
- max_height = (max_size_y * wbd_y) + ((size_y - 1) * margin_y);
- min_height = (min_size_y * wbd_y) + ((size_y - 1) * margin_y);
+ var max_height = (max_size_y * wbd_y) + ((size_y - 1) * margin_y);
+ var min_height = (min_size_y * wbd_y) + ((size_y - 1) * margin_y);
if (this.resize_dir.right) {
size_y = this.resize_initial_sizey;
@@ -1973,10 +1976,10 @@
//Move queued widgets
if(swap && this.can_placeholder_be_set(to_col, to_row, player_size_x, player_size_y)){
for(var key in this.w_queue){
- var col = parseInt(key.split("_")[0]);
- var row = parseInt(key.split("_")[1]);
- if (this.w_queue[key] != "full"){
- this.new_move_widget_to(this.w_queue[key], col, row);
+ var _col = parseInt(key.split("_")[0]);
+ var _row = parseInt(key.split("_")[1]);
+ if (this.w_queue[key] !== "full"){
+ this.new_move_widget_to(this.w_queue[key], _col, _row);
}
}
this.set_placeholder(to_col, to_row);
@@ -2013,12 +2016,12 @@
if(this.is_occupied(colc,rowc)){
occupied = true;
} else if(key in this.w_queue){
- if(this.w_queue[key] == "full"){
+ if(this.w_queue[key] === 'full'){
occupied = true;
continue;
}
- $tw = this.w_queue[key];
- tgd = $tw.coords().grid;
+ var $tw = this.w_queue[key];
+ var tgd = $tw.coords().grid;
//remove queued items if no longer under player.
if(!this.is_widget_under_player(tgd.col,tgd.row)){
delete this.w_queue[key];
@@ -2037,7 +2040,7 @@
}
return occupied;
- }
+ };
fn.can_placeholder_be_set = function(col, row, player_size_x, player_size_y){
var can_set = true;
@@ -2060,10 +2063,10 @@
}
}
return can_set;
- }
+ };
fn.queue_widget = function(col, row, $widget){
- var $w = $widget
+ var $w = $widget;
var wgd = $w.coords().grid;
var primary_key = col+"_"+row;
if (primary_key in this.w_queue){
@@ -2077,7 +2080,7 @@
var colc = col + c;
var rowc = row + r;
var key = colc+"_"+rowc;
- if (key == primary_key){
+ if (key === primary_key){
continue;
}
this.w_queue[key] = "full";
@@ -2085,7 +2088,7 @@
}
return true;
- }
+ };
fn.is_widget_queued_and_can_move = function($widget){
var queued = false;
@@ -2094,10 +2097,10 @@
}
for(var key in this.w_queue){
- if(this.w_queue[key] == "full"){
+ if(this.w_queue[key] === "full"){
continue;
}
- if(this.w_queue[key].attr("data-col") == $widget.attr("data-col") && this.w_queue[key].attr("data-row") == $widget.attr("data-row")){
+ if(this.w_queue[key].attr("data-col") === $widget.attr("data-col") && this.w_queue[key].attr("data-row") === $widget.attr("data-row")){
queued = true;
//test whole space
var $w = this.w_queue[key];
@@ -2119,24 +2122,24 @@
}
}
- return queued
- }
+ return queued;
+ };
fn.is_in_queue = function(col,row, $widget){
var queued = false;
var key = col+"_"+row;
if ((key in this.w_queue)){
- if (this.w_queue[key] == "full"){
+ if (this.w_queue[key] === "full"){
queued = true;
} else {
- $tw = this.w_queue[key];
- tgd = $tw.coords().grid;
+ var $tw = this.w_queue[key];
+ var tgd = $tw.coords().grid;
if(!this.is_widget_under_player(tgd.col,tgd.row)){
- delete this.w_queue[key]
+ delete this.w_queue[key];
queued = false;
- } else if(this.w_queue[key].attr("data-col") == $widget.attr("data-col") && this.w_queue[key].attr("data-row") == $widget.attr("data-row")) {
- delete this.w_queue[key]
+ } else if(this.w_queue[key].attr("data-col") === $widget.attr("data-col") && this.w_queue[key].attr("data-row") === $widget.attr("data-row")) {
+ delete this.w_queue[key];
queued = false;
} else {
queued = true;
@@ -2145,7 +2148,7 @@
}
return queued;
- }
+ };
/**
@@ -2222,7 +2225,7 @@
// overlaps player
var y = (to_row + this.player_grid_data.size_y) - wgd.row;
if (this.can_go_down($w)){
- console.log("In Move Down!")
+ console.log("In Move Down!");
this.move_widget_down($w, y);
this.set_placeholder(to_col, to_row);
}
@@ -2466,8 +2469,8 @@
if (moved_down || changed_column) {
$nexts.each($.proxy(function(i, widget) {
//Make sure widget is at it's topmost position
- $w = $(widget);
- wgd = $w.coords().grid;
+ var $w = $(widget);
+ var wgd = $w.coords().grid;
var can_go_widget_up = this.can_go_widget_up(wgd);
@@ -2622,12 +2625,13 @@
while (++r <= p_bottom_row ) {
var common = true;
+ /*jshint -W083 */
$.each(upper_rows, function(col, rows) {
if ($.isArray(rows) && $.inArray(r, rows) === -1) {
common = false;
}
});
-
+ /*jshint +W083 */
if (common === true) {
valid_rows.push(r);
if (valid_rows.length === size_y) {
@@ -2764,12 +2768,14 @@
var self = this;
var cols = this.cells_occupied_by_player.cols;
if(this.options.shift_larger_widgets_down){
+ /*jshint -W083 */
for (var c = 0, cl = cols.length; c < cl; c++) {
this.for_each_widget_below(cols[c], row, function(tcol, trow) {
console.log("from_on_stop_overlapping_row");
self.move_widget_up(this, self.player_grid_data.size_y);
});
}
+ /*jshint +W083 */
}
};
@@ -2789,7 +2795,7 @@
this.$changed = this.$changed.add($widget);
return this;
- }
+ };
/**
@@ -3127,10 +3133,10 @@
if ($(this).hasClass($gr.options.static_class)){
can_go_down = false;
}
- })
+ });
return can_go_down;
- }
+ };
fn.can_go_up = function($el) {
@@ -3328,13 +3334,13 @@
};
fn.clean_up_changed = function(){
- $gr = this;
+ var $gr = this;
$gr.$changed.each(function(){
if($gr.options.shift_larger_widgets_down){
$gr.move_widget_up($(this));
}
});
- }
+ };
@@ -3629,8 +3635,8 @@
/* generate CSS styles for cols */
for(i = 1; i <= opts.cols + 1; i++) {
styles += (opts.namespace + ' [data-col="' + i + '"] { left:' +
- (full_width ? this.options.widget_margins[0] : ((i * opts.widget_margins[0]) + ((i - 1) * opts.widget_base_dimensions[0])))
- + 'px; }\n');
+ (full_width ? this.options.widget_margins[0] :
+ ((i * opts.widget_margins[0]) + ((i - 1) * opts.widget_base_dimensions[0]))) + 'px; }\n');
}
/* generate CSS styles for rows */
@@ -3646,7 +3652,8 @@
for (var x = 1; x <= max_size_x; x++) {
styles += (opts.namespace + ' [data-sizex="' + x + '"] { width:' +
- (full_width ? ($(window).width() - this.options.widget_margins[0] * 2) : ((x * opts.widget_base_dimensions[0]) + ((x - 1) * opts.widget_margins[0]))) + 'px; }\n');
+ (full_width ? ($(window).width() - this.options.widget_margins[0] * 2) :
+ ((x * opts.widget_base_dimensions[0]) + ((x - 1) * opts.widget_margins[0]))) + 'px; }\n');
}
this.remove_style_tags();
diff --git a/src/utils.js b/src/utils.js
index f66910d78d..c25d6dbf06 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -1,72 +1,85 @@
-;(function(window, undefined) {
+(function (window, undefined) {
- /* Delay, debounce and throttle functions taken from underscore.js
- *
- * Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
- * Investigative Reporters & Editors
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
+ /* Delay, debounce and throttle functions taken from underscore.js
+ *
+ * Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
+ * Investigative Reporters & Editors
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
- window.delay = function(func, wait) {
- var args = Array.prototype.slice.call(arguments, 2);
- return setTimeout(function(){ return func.apply(null, args); }, wait);
- };
+ window.delay = function (func, wait) {
+ var args = Array.prototype.slice.call(arguments, 2);
+ return setTimeout(function () {
+ return func.apply(null, args);
+ }, wait);
+ };
- window.debounce = function(func, wait, immediate) {
- var timeout;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) func.apply(context, args);
- };
- if (immediate && !timeout) func.apply(context, args);
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- };
- };
+ window.debounce = function (func, wait, immediate) {
+ var timeout;
+ return function () {
+ var context = this, args = arguments;
+ var later = function () {
+ timeout = null;
+ if (!immediate) {
+ func.apply(context, args);
+ }
+ };
+ if (immediate && !timeout) {
+ func.apply(context, args);
+ }
+ clearTimeout(timeout);
+ timeout = setTimeout(later, wait);
+ };
+ };
- window.throttle = function(func, wait) {
- var context, args, timeout, throttling, more, result;
- var whenDone = debounce(
- function(){ more = throttling = false; }, wait);
- return function() {
- context = this; args = arguments;
- var later = function() {
- timeout = null;
- if (more) func.apply(context, args);
- whenDone();
- };
- if (!timeout) timeout = setTimeout(later, wait);
- if (throttling) {
- more = true;
- } else {
- result = func.apply(context, args);
- }
- whenDone();
- throttling = true;
- return result;
- };
- };
+ window.throttle = function (func, wait) {
+ var context, args, timeout, throttling, more, result;
+ var whenDone = debounce(
+ function () {
+ more = throttling = false;
+ }, wait);
+ return function () {
+ context = this;
+ args = arguments;
+ var later = function () {
+ timeout = null;
+ if (more) {
+ func.apply(context, args);
+ }
+ whenDone();
+ };
+ if (!timeout) {
+ timeout = setTimeout(later, wait);
+ }
+ if (throttling) {
+ more = true;
+ } else {
+ result = func.apply(context, args);
+ }
+ whenDone();
+ throttling = true;
+ return result;
+ };
+ };
})(window);