Commits

Dis Shishkov committed e17307a

- removed unnecessary options
- fixed typos

Comments (0)

Files changed (6)

 * `Widgetster` uses `PascalCase` notation for methods and options.
 * Removed option `avoid_overlapped_widgets`. For `Widgetster` it's alwasy `true`.
 * Removed option `autogenerate_stylesheet`. For `Widgetster` it's alwasy `false`. Because `Gridster` has a performance issues, which are related CSS `Widgetster` uses inline styles.
-* Added method `ResizeWidgetDimensions`
-* Added `callback` parameter to `AddWidget` method (former `add_widget`)
-* Added `row` parameter to `ResizeWidget` method (former `resize_widget`)
+* Removed option `max_size_x`.
+* Removed option `namespace`.
+* Added method `ResizeWidgetDimensions`.
+* Added `row` parameter to `ResizeWidget` method (former `resize_widget`).
 
 
 ## License
     },
 
     "name": "Widgetster",
-    "version": "0.2.0",
+    "version": "0.2.1",
     "description": "a drag-and-drop jquery plugin to build dashboard with widgets.",
     "site": "https://bitbucket.org/DuC/widgetster",
     "pluginName": "jquery.widgetster",
     {
         private _defaultOptions: ICollisionOptions =
         {
-            CollidersContext: document.body,
             OnOverlapStart: null,
             OnOverlapStop: null,
             OnOverlap: null
         };
         private _options: ICollisionOptions;
         private _el: JQuery;
-        private _colliders: JQuery;
+        private _colliders: Coords[] = [];
         private _lastCollidersCoords: Coords[] = [];
-        private _isInContext: boolean = false;
 
         public Area: number;
         public AreaCoords: Coords;
          * Initialize the Collision object.
          * 
          * @param {JQuery} [el] The JQuery object.
-         * @param {any} [colliders] Can be a jQuery collection of HTMLElements or an Array of Coords instances.
+         * @param {Coords[]} [colliders] Array of Coords instances.
          * @param {ICollisionOptions} [options] An object of options (see ICollisionOptions).
          */ 
-        constructor(el?: JQuery, colliders?: any, options?: ICollisionOptions)
+        constructor(el?: JQuery, colliders?: Coords[], options?: ICollisionOptions)
         {
-            //NOTE: follow colliders seems it should not be any
             if (!el && !colliders && !options)
             {
                 return;
 
             this._options = $.extend(this._defaultOptions, options);
             this._el = el;
-            if (typeof colliders == "string" || colliders instanceof jQuery)
-            {
-                this._colliders = $(colliders, this._options.CollidersContext).not(this._el);
-                this._isInContext = true;
-            }
-            else
-            {
-                this._colliders = $(colliders);
-            }
+            this._colliders = colliders;
 
             this.FindCollisions(null);
         }
 
             while(count--)
             {
-                //NOTE: think how to remove any.
-                var collider: JQuery = this._isInContext ? $(this._colliders[count]) : $((<any>this._colliders[count]).Data);
+                var collider: JQuery = $(this._colliders[count].Data);
                 var colliderCoords = new Coords(collider);
 
                 if (!this.IsOverlaped(playerCoords, colliderCoords))

ts/ICollisionOptions.ts

 {
     export interface ICollisionOptions
     {
-        CollidersContext: HTMLElement;
         OnOverlapStart: Function;
         OnOverlapStop: Function;
         OnOverlap: Function;

ts/IWidgetsterOptions.ts

 {
     export interface IWidgetsterOptions extends IDimensions
     {
-        Namespace: string;
         Selector: string;
         ExtraRows: number;
         ExtraCols: number;
         MinCols: number;
         MaxCols: number;
         MinRows: number;
-        MaxSizeX: number;
         SerializeParams: Function;
         Collision: ICollisionOptions;
         Draggable: IDraggableOptions;
     {
         private _defaultOptions: IWidgetsterOptions =
         {
-            Namespace: "",
             Selector: "li",
             Margins: [10, 10],
-            BaseDimensions: [400, 225],
+            BaseDimensions: [140, 140],
             ExtraRows: 0,
             ExtraCols: 0,
             MinCols: 1,
             MaxCols: null,
             MinRows: 15,
-            MaxSizeX: null,
             SerializeParams: (widgetElement: JQuery, widget: IWidget) => { return widget; },
             Collision: <ICollisionOptions>{},
             Draggable: <IDraggableOptions>{},
         }
         
         /**
-        * Add a new widget to the grid.
+        * Adds a new widget to the grid.
         *
         * @method AddWidget
         * @param {JQuery} [widget] The jQuery wrapped HTMLElement representing the widget.
         * @param {Number} [column] The column the widget should start in.
         * @param {Number} [row] The row the widget should start in.
         * @param {Number[]} [maxSize] Maximun size (in units) for width and height.
-        * @param {Function} [callback] Function executed when the widget is added.
         * @return {JQuery} Returns widget.
         */
-        public AddWidget(widget: JQuery, sizeX?: number, sizeY?: number, column?: number, row?: number, maxSize?: number[], callback?: Function): JQuery
+        public AddWidget(widget: JQuery, sizeX?: number, sizeY?: number, column?: number, row?: number, maxSize?: number[]): JQuery
         {
             sizeX || (sizeX = 1);
             sizeY || (sizeY = 1);
             
             this.SetDomGridHeight();
             
-            if (callback)
-            {
-                callback.call(this, addedWidget);
-            }
-            
             return addedWidget.fadeIn();
         }
         
         /**
-        * Remove a widget from the grid.
+        * Removes a widget from the grid.
         *
         * @method RemoveWidget
         * @param {JQuery} [widget] The jQuery wrapped HTMLElement representing the widget.
         }
         
         /**
-        * Remove all widgets from the grid.
+        * Removes all widgets from the grid.
         *
         * @method RemoveAllWidgets
         * @param {Function} [callback] Function executed for each widget removed.
         }
         
         /**
-        * Change the size of a widget. Width is limited to the current grid width.
+        * Changes the size of a widget. Width is limited to the current grid width.
         *
         * @method ResizeWidget
         * @param {JQuery} [widget] The jQuery wrapped HTMLElement representing the widget.
         }
         
         /**
-         * Resizes widget dimensions, such as Margins and BaseDimensions
+         * Resizes widget dimensions, such as Margins and BaseDimensions.
          * 
-         * @method ResizeWidgetDimensionss
+         * @method ResizeWidgetDimensions
          * @param {IDimensions} [dimensions] The new dimensions.
          * @param {Boolean} [isIgnoreEquals] Set to true to apply changing dimensiosn even
-         * old and new dimensions are equals.s
+         * old and new dimensions are equals.
          */ 
         public ResizeWidgetDimensions(dimensions: IDimensions, isIgnoreEquals: boolean): void
         {