mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
update dependencies and jshint
This commit is contained in:
@@ -1,26 +1,103 @@
|
||||
{
|
||||
"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,
|
||||
// http://www.jshint.com/docs/
|
||||
// Based on node-jshint@2.x.x
|
||||
|
||||
"globals": {
|
||||
"jQuery": true,
|
||||
"define": false,
|
||||
"require": false,
|
||||
"delay": false,
|
||||
"debounce": false,
|
||||
"throttle": false,
|
||||
"Gridster": false
|
||||
}
|
||||
// ENFORCING OPTIONS
|
||||
// These options tell JSHint to be more strict towards your code. Use them if
|
||||
// you want to allow only a safe subset of JavaScript—very useful when your
|
||||
// codebase is shared with a big number of developers with different skill
|
||||
// levels.
|
||||
|
||||
"bitwise": true, //prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others
|
||||
"camelcase": false, //force all variable names to use either camelCase style or UPPER_CASE with underscores
|
||||
"curly": true, //requires you to always put curly braces around blocks in loops and conditionals
|
||||
"eqeqeq": true, //prohibits the use of == and != in favor of === and !==
|
||||
"es3": false, //tells JSHint that your code needs to adhere to ECMAScript 3 specification
|
||||
"forin": false, //requires all `for in` loops to filter object's items with `hasOwnProperty()`
|
||||
"immed": true, //prohibits the use of immediate function invocations without wrapping them in parentheses
|
||||
"indent": 2, //enforces specific tab width
|
||||
"latedef": true, //prohibits the use of a variable before it was defined
|
||||
"newcap": true, //requires you to capitalize names of constructor functions
|
||||
"noarg": true, //prohibits the use of `arguments.caller` and `arguments.callee`
|
||||
"noempty": true, //warns when you have an empty block in your code
|
||||
"nonew": true, //prohibits the use of constructor functions for side-effects
|
||||
"plusplus": false, //prohibits the use of unary increment and decrement operators
|
||||
"quotmark": true, //enforces the consistency of quotation marks used throughout your code
|
||||
"undef": true, //prohibits the use of explicitly undeclared variables
|
||||
"unused": "vars", //warns when you define and never use your variables
|
||||
"strict": true, //requires all functions to run in ECMAScript 5's strict mode
|
||||
"trailing": true, //makes it an error to leave a trailing whitespace in your code
|
||||
"maxparams": false, //set the max number of formal parameters allowed per function
|
||||
"maxdepth": 6, //control how nested do you want your blocks to be
|
||||
"maxstatements": false, //set the max number of statements allowed per function
|
||||
"maxcomplexity": false, //control cyclomatic complexity throughout your code
|
||||
|
||||
// RELAXING OPTIONS
|
||||
// These options allow you to suppress certain types of warnings. Use them
|
||||
// only if you are absolutely positive that you know what you are doing.
|
||||
|
||||
"asi": false, //suppresses warnings about missing semicolons
|
||||
"boss": false, //suppresses warnings about the use of assignments in cases where comparisons are expected
|
||||
"debug": false, //suppresses warnings about the debugger statements in your code
|
||||
"eqnull": false, //suppresses warnings about == null comparisons
|
||||
"esnext": false, //your code uses ES.next specific features such as const
|
||||
"evil": false, //suppresses warnings about the use of eval
|
||||
"expr": true, //suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls
|
||||
"funcscope": false, //suppresses warnings about declaring variables inside of control structures while accessing them later from the outside
|
||||
"globalstrict": false, //suppresses warnings about the use of global strict mode
|
||||
"iterator": false, //suppresses warnings about the `__iterator__` property
|
||||
"lastsemic": false, //suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block
|
||||
"laxbreak": false, //suppresses most of the warnings about possibly unsafe line breakings in your code
|
||||
"laxcomma": false, //suppresses warnings about comma-first coding style
|
||||
"loopfunc": false, //suppresses warnings about functions inside of loops
|
||||
"moz": false, //tells JSHint that your code uses Mozilla JavaScript extensions
|
||||
"multistr": false, //suppresses warnings about multi-line strings
|
||||
"proto": false, //suppresses warnings about the `__proto__` property
|
||||
"scripturl": false, //suppresses warnings about the use of script-targeted URLs—such as `javascript:...`
|
||||
"smarttabs": false, //suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only
|
||||
"shadow": false, //suppresses warnings about variable shadowing
|
||||
"sub": false, //suppresses warnings about using `[]` notation when it can be expressed in dot notation
|
||||
"supernew": false, //suppresses warnings about "weird" constructions like `new function () { ... }` and `new Object;`
|
||||
"validthis": false, //suppresses warnings about possible strict violations when the code is running in strict mode and you use `this` in a non-constructor function
|
||||
|
||||
// ENVIRONMENTS
|
||||
// These options pre-define global variables that are exposed by popular
|
||||
// JavaScript libraries and runtime environments—such as browser or node.js.
|
||||
// Essentially they are shortcuts for explicit declarations like
|
||||
// /*global $:false, jQuery:false */
|
||||
|
||||
"browser": true, //defines globals exposed by modern browsers
|
||||
"couch": false, //defines globals exposed by CouchDB
|
||||
"devel": true, //defines globals that are usually used for logging poor-man's debugging: `console`, `alert`, etc.
|
||||
"dojo": false, //defines globals exposed by the Dojo Toolkit
|
||||
"jquery": true, //defines globals exposed by the jQuery JavaScript library
|
||||
"mootools": false, //defines globals exposed by the MooTools JavaScript framework
|
||||
"node": true, //defines globals available when your code is running inside of the Node runtime environment
|
||||
"nonstandard": false, //defines non-standard but widely adopted globals such as `escape` and `unescape`
|
||||
"phantom": false, //defines globals available when your core is running inside of the PhantomJS runtime environment
|
||||
"qunit": true, //defines globals available when your core is running inside of the Qqunit runtime environment
|
||||
"prototypejs": false, //defines globals exposed by the Prototype JavaScript framework
|
||||
"rhino": false, //defines globals available when your code is running inside of the Rhino runtime environment
|
||||
"worker": true, //defines globals available when your code is running inside of a Web Worker
|
||||
"wsh": false, //defines globals available when your code is running as a script for the Windows Script Host
|
||||
"yui": false, //defines globals exposed by the YUI JavaScript framework
|
||||
|
||||
"globals": {
|
||||
"define": false,
|
||||
"throttle": false,
|
||||
"delay": false,
|
||||
"debounce": false,
|
||||
"jQuery": true,
|
||||
"require": false,
|
||||
"Gridster": false
|
||||
},
|
||||
|
||||
// LEGACY
|
||||
// These options are legacy from JSLint. Aside from bug fixes they will not
|
||||
// be improved in any way and might be removed at any point.
|
||||
|
||||
"nomen": false, //disallows the use of dangling `_` in variables
|
||||
"onevar": false, //allows only one `var` statement per function
|
||||
"passfail": false, //makes JSHint stop on the first error or warning
|
||||
"white": false //make JSHint check your source code against Douglas Crockford's JavaScript coding style
|
||||
}
|
||||
|
||||
+10
-9
@@ -1,6 +1,7 @@
|
||||
/*global module:false*/
|
||||
module.exports = function (grunt) {
|
||||
module.exports = function(grunt) {
|
||||
|
||||
'use strict';
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
@@ -60,7 +61,7 @@ module.exports = function (grunt) {
|
||||
banner: '<%= meta.minibanner %>'
|
||||
},
|
||||
files: {
|
||||
"dist/jquery.<%= pkg.name %>.min.css": ["dist/jquery.<%= pkg.name %>.css"]
|
||||
'dist/jquery.<%= pkg.name %>.min.css': ['dist/jquery.<%= pkg.name %>.css']
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -74,14 +75,14 @@ module.exports = function (grunt) {
|
||||
},
|
||||
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',
|
||||
'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/"
|
||||
paths: 'src/',
|
||||
outdir: 'gh-pages/docs/'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+3
-1
@@ -3,7 +3,9 @@
|
||||
"homepage": "https://github.com/DecksterTeam/gridster.js",
|
||||
"version": "0.6.7",
|
||||
"dependencies": {
|
||||
"jquery": "^2.1.3",
|
||||
"jquery": "^2.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"requirejs": "^2.1.17",
|
||||
"qunit": "~1.18.0"
|
||||
},
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
/*! gridster.js - v0.6.7 - 2015-04-16
|
||||
/*! gridster.js - v0.6.7 - 2015-04-28
|
||||
* http://gridster.net/
|
||||
* Copyright (c) 2015 ducksboard; Licensed MIT */
|
||||
|
||||
|
||||
Vendored
+30
-46
@@ -1,8 +1,9 @@
|
||||
/*! gridster.js - v0.6.7 - 2015-04-16
|
||||
/*! gridster.js - v0.6.7 - 2015-04-28
|
||||
* http://gridster.net/
|
||||
* Copyright (c) 2015 ducksboard; Licensed MIT */
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -13,6 +14,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
'use strict';
|
||||
/**
|
||||
* Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height)
|
||||
* to simulate DOM elements on the screen.
|
||||
@@ -128,6 +130,7 @@
|
||||
}));
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -139,7 +142,7 @@
|
||||
}
|
||||
|
||||
}(this, function($, Coords) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
colliders_context: document.body,
|
||||
overlapping_region: 'C'
|
||||
@@ -367,7 +370,7 @@
|
||||
}));
|
||||
|
||||
(function (window, undefined) {
|
||||
|
||||
'use strict';
|
||||
/* Delay, debounce and throttle functions taken from underscore.js
|
||||
*
|
||||
* Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
|
||||
@@ -464,7 +467,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
items: 'li',
|
||||
distance: 1,
|
||||
@@ -898,6 +901,7 @@
|
||||
}));
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if (typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'), require('./jquery.draggable.js'), require('./jquery.collision.js'), require('./jquery.coords.js'), require('./utils.js'));
|
||||
}
|
||||
@@ -909,7 +913,7 @@
|
||||
}
|
||||
|
||||
}(this, function ($, Draggable, Collision) {
|
||||
|
||||
'use strict';
|
||||
var $window = $(window),
|
||||
defaults = {
|
||||
namespace: '',
|
||||
@@ -1269,7 +1273,7 @@
|
||||
size_x || (size_x = 1);
|
||||
size_y || (size_y = 1);
|
||||
|
||||
if (!col & !row) {
|
||||
if (!col && !row) {
|
||||
pos = this.next_position(size_x, size_y);
|
||||
} else {
|
||||
pos = {
|
||||
@@ -1390,7 +1394,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);
|
||||
}
|
||||
|
||||
@@ -1416,7 +1420,6 @@
|
||||
fn.resize_widget = function ($widget, size_x, size_y, reposition, callback) {
|
||||
var wgd = $widget.coords().grid;
|
||||
var col = wgd.col;
|
||||
var max_cols = this.options.max_cols;
|
||||
reposition !== false && (reposition = true);
|
||||
var old_size_y = wgd.size_y;
|
||||
var old_col = wgd.col;
|
||||
@@ -1698,7 +1701,6 @@
|
||||
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
|
||||
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
|
||||
|
||||
var serializedGrid = this.serialize();
|
||||
this.$widgets.each($.proxy(function (i, widget) {
|
||||
var $widget = $(widget);
|
||||
this.resize_widget($widget);
|
||||
@@ -1874,14 +1876,14 @@
|
||||
* @return {Class} Returns the instance of the Gridster Class.
|
||||
*/
|
||||
fn.remove_empty_cells = function (col, row, size_x, size_y, exclude) {
|
||||
var $nexts = this.widgets_below({
|
||||
/*var $nexts = this.widgets_below({
|
||||
col: col,
|
||||
row: row,
|
||||
size_x: size_x,
|
||||
size_y: size_y
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
$nexts.not(exclude).each($.proxy(function(i, widget) {
|
||||
console.log("from_remove")
|
||||
this.move_widget_up( $(widget), size_y );
|
||||
@@ -2851,7 +2853,6 @@
|
||||
} else if ($gr.options.shift_larger_widgets_down && !swap) {
|
||||
$overlapped_widgets.each($.proxy(function (i, w) {
|
||||
var $w = $(w);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
if ($gr.can_go_down($w)) {
|
||||
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
|
||||
@@ -2874,9 +2875,9 @@
|
||||
//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") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -2910,7 +2911,7 @@
|
||||
for (var r = 0; r < w_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (this.is_occupied(colc, rowc)) {
|
||||
occupied = true;
|
||||
} else if (key in this.w_queue) {
|
||||
@@ -2946,7 +2947,6 @@
|
||||
for (var r = 0; r < player_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var $tw = this.is_widget(colc, rowc);
|
||||
//if this space is occupied and not queued for move.
|
||||
if (rowc > parseInt(this.options.max_rows)) {
|
||||
@@ -2966,7 +2966,7 @@
|
||||
fn.queue_widget = function (col, row, $widget) {
|
||||
var $w = $widget;
|
||||
var wgd = $w.coords().grid;
|
||||
var primary_key = col + "_" + row;
|
||||
var primary_key = col + '_' + row;
|
||||
if (primary_key in this.w_queue) {
|
||||
return false;
|
||||
}
|
||||
@@ -2977,11 +2977,11 @@
|
||||
for (var r = 0; r < wgd.size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (key === primary_key) {
|
||||
continue;
|
||||
}
|
||||
this.w_queue[key] = "full";
|
||||
this.w_queue[key] = 'full';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2995,15 +2995,15 @@
|
||||
}
|
||||
|
||||
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];
|
||||
var dcol = parseInt(key.split("_")[0]);
|
||||
var drow = parseInt(key.split("_")[1]);
|
||||
var dcol = parseInt(key.split('_')[0]);
|
||||
var drow = parseInt(key.split('_')[1]);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
for (var c = 0; c < wgd.size_x; c++) {
|
||||
@@ -3025,10 +3025,10 @@
|
||||
|
||||
fn.is_in_queue = function (col, row, $widget) {
|
||||
var queued = false;
|
||||
var key = col + "_" + row;
|
||||
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 {
|
||||
var $tw = this.w_queue[key];
|
||||
@@ -3036,7 +3036,7 @@
|
||||
if (!this.is_widget_under_player(tgd.col, tgd.row)) {
|
||||
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")) {
|
||||
} 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 {
|
||||
@@ -3123,7 +3123,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);
|
||||
}
|
||||
@@ -3593,7 +3593,6 @@
|
||||
* @return {jQuery} Returns a jQuery collection of HTMLElements.
|
||||
*/
|
||||
fn.get_widgets_overlapped = function () {
|
||||
var $w;
|
||||
var $widgets = $([]);
|
||||
var used = [];
|
||||
var rows_from_bottom = this.cells_occupied_by_player.rows.slice(0);
|
||||
@@ -3678,7 +3677,7 @@
|
||||
/*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");
|
||||
console.log('from_on_stop_overlapping_row');
|
||||
self.move_widget_up(this, self.player_grid_data.size_y);
|
||||
});
|
||||
}
|
||||
@@ -3688,7 +3687,6 @@
|
||||
|
||||
//Not yet part of api - DM.
|
||||
fn.new_move_widget_to = function ($widget, col, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
@@ -3754,7 +3752,6 @@
|
||||
fn.move_widget_to = function ($widget, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
var diff = row - widget_grid_data.row;
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
var can_move_to_new_cell = this.can_move_to(
|
||||
@@ -3796,7 +3793,6 @@
|
||||
var el_grid_data = $widget.coords().grid;
|
||||
var actual_row = el_grid_data.row;
|
||||
var moved = [];
|
||||
var can_go_up = true;
|
||||
y_units || (y_units = 1);
|
||||
|
||||
if (!this.can_go_up($widget)) {
|
||||
@@ -3815,8 +3811,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
widget_grid_data.row = next_row;
|
||||
this.add_to_gridmap(widget_grid_data);
|
||||
@@ -3826,7 +3820,7 @@
|
||||
moved.push($widget);
|
||||
|
||||
/* $next_widgets.each($.proxy(function(i, widget) {
|
||||
console.log("from_within_move_widget_up");
|
||||
console.log('from_within_move_widget_up');
|
||||
this.move_widget_up($(widget), y_units);
|
||||
}, this)); */
|
||||
}
|
||||
@@ -3902,7 +3896,6 @@
|
||||
* to the target position, else returns false.
|
||||
*/
|
||||
fn.can_go_up_to_row = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var result = true;
|
||||
var urc = []; // upper_rows_in_columns
|
||||
var actual_row = widget_grid_data.row;
|
||||
@@ -3911,7 +3904,6 @@
|
||||
/* generate an array with columns as index and array with
|
||||
* upper rows empty in the column */
|
||||
this.for_each_column_occupied(widget_grid_data, function (tcol) {
|
||||
var grid_col = ga[tcol];
|
||||
urc[tcol] = [];
|
||||
|
||||
r = actual_row;
|
||||
@@ -3996,7 +3988,6 @@
|
||||
return $nexts;
|
||||
}
|
||||
var self = this;
|
||||
var ga = this.gridmap;
|
||||
var next_row = el_grid_data.row + el_grid_data.size_y - 1;
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
@@ -4063,8 +4054,6 @@
|
||||
var el_grid_data = $el.coords().grid;
|
||||
var initial_row = el_grid_data.row;
|
||||
var prev_row = initial_row - 1;
|
||||
var ga = this.gridmap;
|
||||
var upper_rows_by_column = [];
|
||||
|
||||
var result = true;
|
||||
if (initial_row === 1) {
|
||||
@@ -4072,8 +4061,6 @@
|
||||
}
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
var $w = this.is_widget(col, prev_row);
|
||||
|
||||
if (this.is_occupied(col, prev_row) ||
|
||||
this.is_player(col, prev_row) ||
|
||||
this.is_placeholder_in(col, prev_row) ||
|
||||
@@ -4101,7 +4088,6 @@
|
||||
* @return {Boolean} Returns true if all cells are empty, else return false.
|
||||
*/
|
||||
fn.can_move_to = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var $w = widget_grid_data.el;
|
||||
var future_wd = {
|
||||
size_y: widget_grid_data.size_y,
|
||||
@@ -4399,8 +4385,6 @@
|
||||
* @returns {*|jQuery|HTMLElement} - a collection of the cells within the range
|
||||
*/
|
||||
fn.get_widgets_in_range = function (col1, row1, col2, row2) {
|
||||
var valid_cols = [];
|
||||
var valid_rows = [];
|
||||
var $widgets = $([]);
|
||||
var c, r, $w, wgd;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! gridster.js - v0.6.7 - 2015-04-16 - * http://gridster.net/ - Copyright (c) 2015 ducksboard; Licensed MIT */
|
||||
/*! gridster.js - v0.6.7 - 2015-04-28 - * 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}
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+33
-49
@@ -1,8 +1,9 @@
|
||||
/*! gridster.js - v0.6.7 - 2015-04-16
|
||||
/*! gridster.js - v0.6.7 - 2015-04-28
|
||||
* http://gridster.net/
|
||||
* Copyright (c) 2015 ducksboard; Licensed MIT */
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -13,6 +14,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
'use strict';
|
||||
/**
|
||||
* Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height)
|
||||
* to simulate DOM elements on the screen.
|
||||
@@ -128,6 +130,7 @@
|
||||
}));
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -139,7 +142,7 @@
|
||||
}
|
||||
|
||||
}(this, function($, Coords) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
colliders_context: document.body,
|
||||
overlapping_region: 'C'
|
||||
@@ -367,7 +370,7 @@
|
||||
}));
|
||||
|
||||
(function (window, undefined) {
|
||||
|
||||
'use strict';
|
||||
/* Delay, debounce and throttle functions taken from underscore.js
|
||||
*
|
||||
* Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
|
||||
@@ -464,7 +467,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
items: 'li',
|
||||
distance: 1,
|
||||
@@ -898,6 +901,7 @@
|
||||
}));
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if (typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'), require('./jquery.draggable.js'), require('./jquery.collision.js'), require('./jquery.coords.js'), require('./utils.js'));
|
||||
}
|
||||
@@ -909,7 +913,7 @@
|
||||
}
|
||||
|
||||
}(this, function ($, Draggable, Collision) {
|
||||
|
||||
'use strict';
|
||||
var $window = $(window),
|
||||
defaults = {
|
||||
namespace: '',
|
||||
@@ -1269,7 +1273,7 @@
|
||||
size_x || (size_x = 1);
|
||||
size_y || (size_y = 1);
|
||||
|
||||
if (!col & !row) {
|
||||
if (!col && !row) {
|
||||
pos = this.next_position(size_x, size_y);
|
||||
} else {
|
||||
pos = {
|
||||
@@ -1390,7 +1394,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);
|
||||
}
|
||||
|
||||
@@ -1416,7 +1420,6 @@
|
||||
fn.resize_widget = function ($widget, size_x, size_y, reposition, callback) {
|
||||
var wgd = $widget.coords().grid;
|
||||
var col = wgd.col;
|
||||
var max_cols = this.options.max_cols;
|
||||
reposition !== false && (reposition = true);
|
||||
var old_size_y = wgd.size_y;
|
||||
var old_col = wgd.col;
|
||||
@@ -1698,7 +1701,6 @@
|
||||
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
|
||||
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
|
||||
|
||||
var serializedGrid = this.serialize();
|
||||
this.$widgets.each($.proxy(function (i, widget) {
|
||||
var $widget = $(widget);
|
||||
this.resize_widget($widget);
|
||||
@@ -1874,14 +1876,14 @@
|
||||
* @return {Class} Returns the instance of the Gridster Class.
|
||||
*/
|
||||
fn.remove_empty_cells = function (col, row, size_x, size_y, exclude) {
|
||||
var $nexts = this.widgets_below({
|
||||
/*var $nexts = this.widgets_below({
|
||||
col: col,
|
||||
row: row,
|
||||
size_x: size_x,
|
||||
size_y: size_y
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
$nexts.not(exclude).each($.proxy(function(i, widget) {
|
||||
console.log("from_remove")
|
||||
this.move_widget_up( $(widget), size_y );
|
||||
@@ -2851,7 +2853,6 @@
|
||||
} else if ($gr.options.shift_larger_widgets_down && !swap) {
|
||||
$overlapped_widgets.each($.proxy(function (i, w) {
|
||||
var $w = $(w);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
if ($gr.can_go_down($w)) {
|
||||
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
|
||||
@@ -2874,9 +2875,9 @@
|
||||
//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") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -2910,7 +2911,7 @@
|
||||
for (var r = 0; r < w_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (this.is_occupied(colc, rowc)) {
|
||||
occupied = true;
|
||||
} else if (key in this.w_queue) {
|
||||
@@ -2946,7 +2947,6 @@
|
||||
for (var r = 0; r < player_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var $tw = this.is_widget(colc, rowc);
|
||||
//if this space is occupied and not queued for move.
|
||||
if (rowc > parseInt(this.options.max_rows)) {
|
||||
@@ -2966,7 +2966,7 @@
|
||||
fn.queue_widget = function (col, row, $widget) {
|
||||
var $w = $widget;
|
||||
var wgd = $w.coords().grid;
|
||||
var primary_key = col + "_" + row;
|
||||
var primary_key = col + '_' + row;
|
||||
if (primary_key in this.w_queue) {
|
||||
return false;
|
||||
}
|
||||
@@ -2977,11 +2977,11 @@
|
||||
for (var r = 0; r < wgd.size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (key === primary_key) {
|
||||
continue;
|
||||
}
|
||||
this.w_queue[key] = "full";
|
||||
this.w_queue[key] = 'full';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2995,15 +2995,15 @@
|
||||
}
|
||||
|
||||
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];
|
||||
var dcol = parseInt(key.split("_")[0]);
|
||||
var drow = parseInt(key.split("_")[1]);
|
||||
var dcol = parseInt(key.split('_')[0]);
|
||||
var drow = parseInt(key.split('_')[1]);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
for (var c = 0; c < wgd.size_x; c++) {
|
||||
@@ -3025,10 +3025,10 @@
|
||||
|
||||
fn.is_in_queue = function (col, row, $widget) {
|
||||
var queued = false;
|
||||
var key = col + "_" + row;
|
||||
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 {
|
||||
var $tw = this.w_queue[key];
|
||||
@@ -3036,7 +3036,7 @@
|
||||
if (!this.is_widget_under_player(tgd.col, tgd.row)) {
|
||||
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")) {
|
||||
} 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 {
|
||||
@@ -3123,7 +3123,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);
|
||||
}
|
||||
@@ -3593,7 +3593,6 @@
|
||||
* @return {jQuery} Returns a jQuery collection of HTMLElements.
|
||||
*/
|
||||
fn.get_widgets_overlapped = function () {
|
||||
var $w;
|
||||
var $widgets = $([]);
|
||||
var used = [];
|
||||
var rows_from_bottom = this.cells_occupied_by_player.rows.slice(0);
|
||||
@@ -3678,7 +3677,7 @@
|
||||
/*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");
|
||||
console.log('from_on_stop_overlapping_row');
|
||||
self.move_widget_up(this, self.player_grid_data.size_y);
|
||||
});
|
||||
}
|
||||
@@ -3688,7 +3687,6 @@
|
||||
|
||||
//Not yet part of api - DM.
|
||||
fn.new_move_widget_to = function ($widget, col, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
@@ -3754,7 +3752,6 @@
|
||||
fn.move_widget_to = function ($widget, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
var diff = row - widget_grid_data.row;
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
var can_move_to_new_cell = this.can_move_to(
|
||||
@@ -3796,7 +3793,6 @@
|
||||
var el_grid_data = $widget.coords().grid;
|
||||
var actual_row = el_grid_data.row;
|
||||
var moved = [];
|
||||
var can_go_up = true;
|
||||
y_units || (y_units = 1);
|
||||
|
||||
if (!this.can_go_up($widget)) {
|
||||
@@ -3815,8 +3811,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
widget_grid_data.row = next_row;
|
||||
this.add_to_gridmap(widget_grid_data);
|
||||
@@ -3826,7 +3820,7 @@
|
||||
moved.push($widget);
|
||||
|
||||
/* $next_widgets.each($.proxy(function(i, widget) {
|
||||
console.log("from_within_move_widget_up");
|
||||
console.log('from_within_move_widget_up');
|
||||
this.move_widget_up($(widget), y_units);
|
||||
}, this)); */
|
||||
}
|
||||
@@ -3902,7 +3896,6 @@
|
||||
* to the target position, else returns false.
|
||||
*/
|
||||
fn.can_go_up_to_row = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var result = true;
|
||||
var urc = []; // upper_rows_in_columns
|
||||
var actual_row = widget_grid_data.row;
|
||||
@@ -3911,7 +3904,6 @@
|
||||
/* generate an array with columns as index and array with
|
||||
* upper rows empty in the column */
|
||||
this.for_each_column_occupied(widget_grid_data, function (tcol) {
|
||||
var grid_col = ga[tcol];
|
||||
urc[tcol] = [];
|
||||
|
||||
r = actual_row;
|
||||
@@ -3996,7 +3988,6 @@
|
||||
return $nexts;
|
||||
}
|
||||
var self = this;
|
||||
var ga = this.gridmap;
|
||||
var next_row = el_grid_data.row + el_grid_data.size_y - 1;
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
@@ -4063,8 +4054,6 @@
|
||||
var el_grid_data = $el.coords().grid;
|
||||
var initial_row = el_grid_data.row;
|
||||
var prev_row = initial_row - 1;
|
||||
var ga = this.gridmap;
|
||||
var upper_rows_by_column = [];
|
||||
|
||||
var result = true;
|
||||
if (initial_row === 1) {
|
||||
@@ -4072,8 +4061,6 @@
|
||||
}
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
var $w = this.is_widget(col, prev_row);
|
||||
|
||||
if (this.is_occupied(col, prev_row) ||
|
||||
this.is_player(col, prev_row) ||
|
||||
this.is_placeholder_in(col, prev_row) ||
|
||||
@@ -4101,7 +4088,6 @@
|
||||
* @return {Boolean} Returns true if all cells are empty, else return false.
|
||||
*/
|
||||
fn.can_move_to = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var $w = widget_grid_data.el;
|
||||
var future_wd = {
|
||||
size_y: widget_grid_data.size_y,
|
||||
@@ -4399,8 +4385,6 @@
|
||||
* @returns {*|jQuery|HTMLElement} - a collection of the cells within the range
|
||||
*/
|
||||
fn.get_widgets_in_range = function (col1, row1, col2, row2) {
|
||||
var valid_cols = [];
|
||||
var valid_rows = [];
|
||||
var $widgets = $([]);
|
||||
var c, r, $w, wgd;
|
||||
|
||||
@@ -5028,7 +5012,8 @@
|
||||
}));
|
||||
|
||||
;(function(root, factory) {
|
||||
if(typeof exports === 'object') {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'), require('./jquery-gridster.js'));
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
@@ -5038,7 +5023,7 @@
|
||||
}
|
||||
|
||||
}(this, function($, Gridster) {
|
||||
|
||||
'use strict';
|
||||
var fn = Gridster.prototype;
|
||||
|
||||
fn.widgets_in_col = function(col) {
|
||||
@@ -5163,7 +5148,6 @@
|
||||
|
||||
|
||||
fn.closest_to_left = function(col, row) {
|
||||
var cols_l = this.gridmap.length - 1;
|
||||
if (!this.gridmap[col]) { return false; }
|
||||
|
||||
for (var c = col; c >= 1; c--) {
|
||||
|
||||
+2
-2
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -18,7 +19,7 @@
|
||||
}
|
||||
|
||||
}(this, function($, Coords) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
colliders_context: document.body,
|
||||
overlapping_region: 'C'
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
;(function(root, factory) {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
@@ -17,6 +18,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
'use strict';
|
||||
/**
|
||||
* Creates objects with coordinates (x1, y1, x2, y2, cx, cy, width, height)
|
||||
* to simulate DOM elements on the screen.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
}
|
||||
|
||||
}(this, function($) {
|
||||
|
||||
'use strict';
|
||||
var defaults = {
|
||||
items: 'li',
|
||||
distance: 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
;(function(root, factory) {
|
||||
if(typeof exports === 'object') {
|
||||
'use strict';
|
||||
if(typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'), require('./jquery-gridster.js'));
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
@@ -9,7 +10,7 @@
|
||||
}
|
||||
|
||||
}(this, function($, Gridster) {
|
||||
|
||||
'use strict';
|
||||
var fn = Gridster.prototype;
|
||||
|
||||
fn.widgets_in_col = function(col) {
|
||||
@@ -134,7 +135,6 @@
|
||||
|
||||
|
||||
fn.closest_to_left = function(col, row) {
|
||||
var cols_l = this.gridmap.length - 1;
|
||||
if (!this.gridmap[col]) { return false; }
|
||||
|
||||
for (var c = col; c >= 1; c--) {
|
||||
|
||||
+23
-42
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if (typeof exports === 'object') {
|
||||
module.exports = factory(require('jquery'), require('./jquery.draggable.js'), require('./jquery.collision.js'), require('./jquery.coords.js'), require('./utils.js'));
|
||||
}
|
||||
@@ -18,7 +19,7 @@
|
||||
}
|
||||
|
||||
}(this, function ($, Draggable, Collision) {
|
||||
|
||||
'use strict';
|
||||
var $window = $(window),
|
||||
defaults = {
|
||||
namespace: '',
|
||||
@@ -378,7 +379,7 @@
|
||||
size_x || (size_x = 1);
|
||||
size_y || (size_y = 1);
|
||||
|
||||
if (!col & !row) {
|
||||
if (!col && !row) {
|
||||
pos = this.next_position(size_x, size_y);
|
||||
} else {
|
||||
pos = {
|
||||
@@ -499,7 +500,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);
|
||||
}
|
||||
|
||||
@@ -525,7 +526,6 @@
|
||||
fn.resize_widget = function ($widget, size_x, size_y, reposition, callback) {
|
||||
var wgd = $widget.coords().grid;
|
||||
var col = wgd.col;
|
||||
var max_cols = this.options.max_cols;
|
||||
reposition !== false && (reposition = true);
|
||||
var old_size_y = wgd.size_y;
|
||||
var old_col = wgd.col;
|
||||
@@ -807,7 +807,6 @@
|
||||
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
|
||||
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
|
||||
|
||||
var serializedGrid = this.serialize();
|
||||
this.$widgets.each($.proxy(function (i, widget) {
|
||||
var $widget = $(widget);
|
||||
this.resize_widget($widget);
|
||||
@@ -983,14 +982,14 @@
|
||||
* @return {Class} Returns the instance of the Gridster Class.
|
||||
*/
|
||||
fn.remove_empty_cells = function (col, row, size_x, size_y, exclude) {
|
||||
var $nexts = this.widgets_below({
|
||||
/*var $nexts = this.widgets_below({
|
||||
col: col,
|
||||
row: row,
|
||||
size_x: size_x,
|
||||
size_y: size_y
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
$nexts.not(exclude).each($.proxy(function(i, widget) {
|
||||
console.log("from_remove")
|
||||
this.move_widget_up( $(widget), size_y );
|
||||
@@ -1960,7 +1959,6 @@
|
||||
} else if ($gr.options.shift_larger_widgets_down && !swap) {
|
||||
$overlapped_widgets.each($.proxy(function (i, w) {
|
||||
var $w = $(w);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
if ($gr.can_go_down($w)) {
|
||||
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
|
||||
@@ -1983,9 +1981,9 @@
|
||||
//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") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -2019,7 +2017,7 @@
|
||||
for (var r = 0; r < w_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (this.is_occupied(colc, rowc)) {
|
||||
occupied = true;
|
||||
} else if (key in this.w_queue) {
|
||||
@@ -2055,7 +2053,6 @@
|
||||
for (var r = 0; r < player_size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var $tw = this.is_widget(colc, rowc);
|
||||
//if this space is occupied and not queued for move.
|
||||
if (rowc > parseInt(this.options.max_rows)) {
|
||||
@@ -2075,7 +2072,7 @@
|
||||
fn.queue_widget = function (col, row, $widget) {
|
||||
var $w = $widget;
|
||||
var wgd = $w.coords().grid;
|
||||
var primary_key = col + "_" + row;
|
||||
var primary_key = col + '_' + row;
|
||||
if (primary_key in this.w_queue) {
|
||||
return false;
|
||||
}
|
||||
@@ -2086,11 +2083,11 @@
|
||||
for (var r = 0; r < wgd.size_y; r++) {
|
||||
var colc = col + c;
|
||||
var rowc = row + r;
|
||||
var key = colc + "_" + rowc;
|
||||
var key = colc + '_' + rowc;
|
||||
if (key === primary_key) {
|
||||
continue;
|
||||
}
|
||||
this.w_queue[key] = "full";
|
||||
this.w_queue[key] = 'full';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2104,15 +2101,15 @@
|
||||
}
|
||||
|
||||
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];
|
||||
var dcol = parseInt(key.split("_")[0]);
|
||||
var drow = parseInt(key.split("_")[1]);
|
||||
var dcol = parseInt(key.split('_')[0]);
|
||||
var drow = parseInt(key.split('_')[1]);
|
||||
var wgd = $w.coords().grid;
|
||||
|
||||
for (var c = 0; c < wgd.size_x; c++) {
|
||||
@@ -2134,10 +2131,10 @@
|
||||
|
||||
fn.is_in_queue = function (col, row, $widget) {
|
||||
var queued = false;
|
||||
var key = col + "_" + row;
|
||||
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 {
|
||||
var $tw = this.w_queue[key];
|
||||
@@ -2145,7 +2142,7 @@
|
||||
if (!this.is_widget_under_player(tgd.col, tgd.row)) {
|
||||
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")) {
|
||||
} 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 {
|
||||
@@ -2232,7 +2229,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);
|
||||
}
|
||||
@@ -2702,7 +2699,6 @@
|
||||
* @return {jQuery} Returns a jQuery collection of HTMLElements.
|
||||
*/
|
||||
fn.get_widgets_overlapped = function () {
|
||||
var $w;
|
||||
var $widgets = $([]);
|
||||
var used = [];
|
||||
var rows_from_bottom = this.cells_occupied_by_player.rows.slice(0);
|
||||
@@ -2787,7 +2783,7 @@
|
||||
/*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");
|
||||
console.log('from_on_stop_overlapping_row');
|
||||
self.move_widget_up(this, self.player_grid_data.size_y);
|
||||
});
|
||||
}
|
||||
@@ -2797,7 +2793,6 @@
|
||||
|
||||
//Not yet part of api - DM.
|
||||
fn.new_move_widget_to = function ($widget, col, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
@@ -2863,7 +2858,6 @@
|
||||
fn.move_widget_to = function ($widget, row) {
|
||||
var self = this;
|
||||
var widget_grid_data = $widget.coords().grid;
|
||||
var diff = row - widget_grid_data.row;
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
var can_move_to_new_cell = this.can_move_to(
|
||||
@@ -2905,7 +2899,6 @@
|
||||
var el_grid_data = $widget.coords().grid;
|
||||
var actual_row = el_grid_data.row;
|
||||
var moved = [];
|
||||
var can_go_up = true;
|
||||
y_units || (y_units = 1);
|
||||
|
||||
if (!this.can_go_up($widget)) {
|
||||
@@ -2924,8 +2917,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
var $next_widgets = this.widgets_below($widget);
|
||||
|
||||
this.remove_from_gridmap(widget_grid_data);
|
||||
widget_grid_data.row = next_row;
|
||||
this.add_to_gridmap(widget_grid_data);
|
||||
@@ -2935,7 +2926,7 @@
|
||||
moved.push($widget);
|
||||
|
||||
/* $next_widgets.each($.proxy(function(i, widget) {
|
||||
console.log("from_within_move_widget_up");
|
||||
console.log('from_within_move_widget_up');
|
||||
this.move_widget_up($(widget), y_units);
|
||||
}, this)); */
|
||||
}
|
||||
@@ -3011,7 +3002,6 @@
|
||||
* to the target position, else returns false.
|
||||
*/
|
||||
fn.can_go_up_to_row = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var result = true;
|
||||
var urc = []; // upper_rows_in_columns
|
||||
var actual_row = widget_grid_data.row;
|
||||
@@ -3020,7 +3010,6 @@
|
||||
/* generate an array with columns as index and array with
|
||||
* upper rows empty in the column */
|
||||
this.for_each_column_occupied(widget_grid_data, function (tcol) {
|
||||
var grid_col = ga[tcol];
|
||||
urc[tcol] = [];
|
||||
|
||||
r = actual_row;
|
||||
@@ -3105,7 +3094,6 @@
|
||||
return $nexts;
|
||||
}
|
||||
var self = this;
|
||||
var ga = this.gridmap;
|
||||
var next_row = el_grid_data.row + el_grid_data.size_y - 1;
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
@@ -3172,8 +3160,6 @@
|
||||
var el_grid_data = $el.coords().grid;
|
||||
var initial_row = el_grid_data.row;
|
||||
var prev_row = initial_row - 1;
|
||||
var ga = this.gridmap;
|
||||
var upper_rows_by_column = [];
|
||||
|
||||
var result = true;
|
||||
if (initial_row === 1) {
|
||||
@@ -3181,8 +3167,6 @@
|
||||
}
|
||||
|
||||
this.for_each_column_occupied(el_grid_data, function (col) {
|
||||
var $w = this.is_widget(col, prev_row);
|
||||
|
||||
if (this.is_occupied(col, prev_row) ||
|
||||
this.is_player(col, prev_row) ||
|
||||
this.is_placeholder_in(col, prev_row) ||
|
||||
@@ -3210,7 +3194,6 @@
|
||||
* @return {Boolean} Returns true if all cells are empty, else return false.
|
||||
*/
|
||||
fn.can_move_to = function (widget_grid_data, col, row) {
|
||||
var ga = this.gridmap;
|
||||
var $w = widget_grid_data.el;
|
||||
var future_wd = {
|
||||
size_y: widget_grid_data.size_y,
|
||||
@@ -3508,8 +3491,6 @@
|
||||
* @returns {*|jQuery|HTMLElement} - a collection of the cells within the range
|
||||
*/
|
||||
fn.get_widgets_in_range = function (col1, row1, col2, row2) {
|
||||
var valid_cols = [];
|
||||
var valid_rows = [];
|
||||
var $widgets = $([]);
|
||||
var c, r, $w, wgd;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
(function (window, undefined) {
|
||||
|
||||
'use strict';
|
||||
/* Delay, debounce and throttle functions taken from underscore.js
|
||||
*
|
||||
* Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
//Based on https://github.com/jonnyreeves/qunit-require
|
||||
/* global require */
|
||||
"use strict";
|
||||
/* global require, QUnit*/
|
||||
'use strict';
|
||||
require.config({
|
||||
//set the baseUrl to the src dir so that gridster
|
||||
//AMD modules can be found.
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
define(['jquery'], function (jq) {
|
||||
'use strict';
|
||||
return jq.noConflict( true );
|
||||
});
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false*/
|
||||
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
|
||||
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
|
||||
//jshint quotmark:false
|
||||
/*global module:false, test:false */
|
||||
/*global ok:false, equal:false, notEqual:false, deepEqual:false*/
|
||||
/*global notDeepEqual:false */
|
||||
(function ($) {
|
||||
|
||||
'use strict';
|
||||
/*
|
||||
======== A Handy Little QUnit Reference ========
|
||||
http://docs.jquery.com/QUnit
|
||||
@@ -117,13 +118,11 @@
|
||||
});
|
||||
|
||||
test('get_highest_occupied_cell', 1, function () {
|
||||
var input = {col: 2, row: 3, size_x: 3, size_y: 1};
|
||||
var grid = this.el.gridster().data('gridster');
|
||||
deepEqual(grid.get_min_col(), 1);
|
||||
});
|
||||
|
||||
test('get_highest_occupied_cell', 1, function () {
|
||||
var input = {col: 2, row: 3, size_x: 3, size_y: 1};
|
||||
var grid = this.el.gridster().data('gridster');
|
||||
deepEqual(grid.get_highest_occupied_cell(), {col: 3, row: 2});
|
||||
});
|
||||
@@ -172,7 +171,7 @@
|
||||
grid.add_widget('<li />', this.size_x, this.size_y, this.col, this.row);
|
||||
});
|
||||
equal(grid.get_num_widgets(), numBefore + this.resizeGrid.length, 'Loading the widgets to prepare for tests');
|
||||
var row, col;
|
||||
|
||||
//check for widgets in the space it will occupy
|
||||
var widgets = grid.get_widgets_in_range(1,1,2,2);
|
||||
var numberInSpaceBefore = widgets.length;
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/* global u, SPEED*/
|
||||
|
||||
'use strict';
|
||||
|
||||
window.serialization = {
|
||||
'default': function() {
|
||||
return [
|
||||
{name: 'A', col: 1, row: 1, size_x: 1, size_y: 2},
|
||||
{name: 'B', col: 2, row: 1, size_x: 3, size_y: 2},
|
||||
{name: 'C', col: 5, row: 1, size_x: 3, size_y: 2},
|
||||
{name: 'D', col: 8, row: 1, size_x: 2, size_y: 1},
|
||||
{name: 'E', col: 1, row: 3, size_x: 4, size_y: 1},
|
||||
{name: 'F', col: 10, row: 1, size_x: 1, size_y: 2},
|
||||
{name: 'G', col: 8, row: 2, size_x: 2, size_y: 1},
|
||||
{name: 'H', col: 5, row: 3, size_x: 3, size_y: 2},
|
||||
{name: 'I', col: 8, row: 3, size_x: 1, size_y: 1},
|
||||
{name: 'J', col: 9, row: 3, size_x: 2, size_y: 2},
|
||||
{name: 'K', col: 1, row: 4, size_x: 1, size_y: 3}
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
window.u = {
|
||||
pick: function(data, prop) {
|
||||
return data.map(function(elm) {
|
||||
return elm[prop];
|
||||
});
|
||||
},
|
||||
|
||||
getRandomColor: function() {
|
||||
var letters = '0123456789ABCDEF'.split('');
|
||||
var color = '#';
|
||||
for (var i = 0; i < 6; i++) {
|
||||
color += letters[Math.round(Math.random() * 10)];
|
||||
}
|
||||
return color;
|
||||
},
|
||||
|
||||
createGridster: function(config, serialize, fromDom) {
|
||||
var defaults = {
|
||||
widget_margins: [5, 5],
|
||||
widget_base_dimensions: [100, 55],
|
||||
min_cols: 10,
|
||||
max_cols: 10
|
||||
};
|
||||
|
||||
serialize || (serialize = window.serialization.default());
|
||||
|
||||
var widgets = [];
|
||||
$.each(serialize, function(i, w) {
|
||||
widgets.push(['<li>' + w.name + '</li>', w.size_x, w.size_y, w.col, w.row]);
|
||||
});
|
||||
|
||||
this.$fixture = $('#fixture');
|
||||
this.$fixture.html('<div class="gridster"><ul></ul></div>');
|
||||
this.$el = $('.gridster > ul');
|
||||
|
||||
if (fromDom) {
|
||||
var html = [];
|
||||
$.each(serialize, function(i, w) {
|
||||
html.push('<li data-col="' + w.col + '" data-row="' + w.row + '" data-sizex="' + w.size_x + '" data-sizey="' + w.size_y + '">' + w.name + '</li>');
|
||||
});
|
||||
this.$el.html(html.join('\n'));
|
||||
}
|
||||
|
||||
this.gridster = this.$el.gridster(
|
||||
$.extend({}, defaults, config)).data('gridster');
|
||||
|
||||
if (!fromDom) {
|
||||
$.each(widgets, function(i, widget) {
|
||||
this.gridster.add_widget.apply(this.gridster, widget);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
this.drag_from_to = u._dragFromTo;
|
||||
|
||||
return this.gridster;
|
||||
},
|
||||
|
||||
createEvent: function(type, offset) {
|
||||
var event = document.createEvent('MouseEvents');
|
||||
event.initMouseEvent(type, true, true, window, 0, 0, 0,
|
||||
offset.left, offset.top, false, false, false, false, 0, null);
|
||||
|
||||
return event;
|
||||
},
|
||||
|
||||
dispatchEvent: function(elem, type, event) {
|
||||
if (elem.dispatchEvent) {
|
||||
elem.dispatchEvent(event);
|
||||
} else if (elem.fireEvent) {
|
||||
elem.fireEvent('on' + type, event);
|
||||
}
|
||||
},
|
||||
|
||||
_dragFromTo: function(fromCoords, toCoords) {
|
||||
var d = $.Deferred();
|
||||
var gridster = this.gridster;
|
||||
var $el;
|
||||
|
||||
function getMousePos(coords) {
|
||||
var size = gridster.options.widget_base_dimensions;
|
||||
var margin = gridster.options.widget_margins;
|
||||
|
||||
var left = ((coords[0] - 1) * size[0]) + (margin[0] * ((coords[0] * 2) - 1));
|
||||
var top = ((coords[1] - 1) * size[1]) + (margin[1] * ((coords[1] * 2) - 1));
|
||||
|
||||
var parentOffset = gridster.$wrapper.offset();
|
||||
|
||||
return {
|
||||
left: parentOffset.left + left + 20,
|
||||
top: parentOffset.top + top + 20
|
||||
};
|
||||
}
|
||||
|
||||
function addPoint(offset) {
|
||||
$('<span/>').css({
|
||||
left: offset.left + 'px',
|
||||
top: offset.top + 'px',
|
||||
width: '2px',
|
||||
height: '2px',
|
||||
background: 'red',
|
||||
display: 'inline-block',
|
||||
position: 'absolute',
|
||||
zIndex: '9999'
|
||||
}).appendTo('body');
|
||||
}
|
||||
|
||||
var from_offset;
|
||||
|
||||
if (fromCoords instanceof $) {
|
||||
$el = fromCoords;
|
||||
var offset = $el.offset();
|
||||
from_offset = {
|
||||
left: offset.left + ($el.width() / 2),
|
||||
top: offset.top + ($el.height() / 2)
|
||||
};
|
||||
} else {
|
||||
$el = this.gridster.gridmap[fromCoords[0]][fromCoords[1]];
|
||||
from_offset = getMousePos(fromCoords);
|
||||
}
|
||||
|
||||
if (! $el) {
|
||||
return;
|
||||
}
|
||||
|
||||
var to_offset = getMousePos(toCoords);
|
||||
var el = $el.get(0);
|
||||
|
||||
addPoint(from_offset);
|
||||
addPoint(to_offset);
|
||||
|
||||
// Simulating drag start
|
||||
var type = 'mousedown';
|
||||
var event = u.createEvent(type, from_offset);
|
||||
u.dispatchEvent(el, type, event);
|
||||
|
||||
// Simulating drop
|
||||
type = 'mousemove';
|
||||
u.dispatchEvent(el, type, u.createEvent(type, {
|
||||
top: from_offset.top + 2,
|
||||
left: from_offset.left + 2
|
||||
}));
|
||||
|
||||
this.gridster.$el.on('gridster:dragstop gridster:resizestop', function() {
|
||||
setTimeout(function() {
|
||||
d.resolveWith(this);
|
||||
}.bind(this), SPEED);
|
||||
}.bind(this));
|
||||
|
||||
var diff_x = to_offset.left - from_offset.left;
|
||||
var diff_y = to_offset.top - from_offset.top;
|
||||
var steps = 10;
|
||||
var step_x = diff_x / steps;
|
||||
var step_y = diff_y / steps;
|
||||
|
||||
var tmp_offset = {
|
||||
left: from_offset.left,
|
||||
top: from_offset.top
|
||||
};
|
||||
|
||||
for (var i = 0; i < steps; i++) {
|
||||
tmp_offset.left += step_x;
|
||||
tmp_offset.top += step_y;
|
||||
addPoint(tmp_offset);
|
||||
u.dispatchEvent(el, type, u.createEvent(type, tmp_offset));
|
||||
}
|
||||
|
||||
u.dispatchEvent(el, type, u.createEvent(type, to_offset));
|
||||
addPoint(to_offset);
|
||||
|
||||
// Simulating drag end
|
||||
type = 'mouseup';
|
||||
var dragEndEvent = u.createEvent(type, to_offset);
|
||||
u.dispatchEvent(el, type, dragEndEvent);
|
||||
|
||||
return d.promise();
|
||||
}
|
||||
};
|
||||
+4
-5
@@ -1,12 +1,11 @@
|
||||
/* global require */
|
||||
"use strict";
|
||||
'use strict';
|
||||
define([
|
||||
'QUnit',
|
||||
'jquery',
|
||||
'gridster'
|
||||
], function(QUnit, $, gridster) {
|
||||
|
||||
QUnit.module("Gridster AMD", {
|
||||
QUnit.module('Gridster AMD', {
|
||||
setup: function () {
|
||||
},
|
||||
teardown: function () {
|
||||
@@ -21,8 +20,8 @@ define([
|
||||
|
||||
QUnit.test('gridster should be initialized.', function() {
|
||||
$('.wrapper ul').gridster();
|
||||
equal($(".wrapper").hasClass('ready'), true, 'Gridster should initialized wrapper.');
|
||||
equal($(".wrapper ul li").length, $(".gs-w").length, 'grid elements get a .gs-w class');
|
||||
equal($('.wrapper').hasClass('ready'), true, 'Gridster should initialized wrapper.');
|
||||
equal($('.wrapper ul li').length, $('.gs-w').length, 'grid elements get a .gs-w class');
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user