Dotclear

source: plugins/widgets/dragdrop.js @ 2980:aef1340d89e3

Revision 2980:aef1340d89e3, 2.2 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Usual oops. Incorrect javascript comment

RevLine 
[1659]1/*
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[2973]6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear
[1659]7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12*/
13
[1648]14$(function() {
[2566]15
[1648]16     // clean
[1657]17     $('.remove-if-drag').remove();
18     $('.hidden-if-drag').hide();
19     $('.widgets, .sortable-delete').addClass('if-drag');
[2566]20
[1648]21     // move
[1649]22     $( ".connected, .sortable-delete" ).sortable({
23          tolerance: "move",
24          cursor: "move",
[1648]25          axis: "y",
[1649]26          dropOnEmpty: true,
27          handle: ".widget-name",
28          placeholder: "ui-sortable-placeholder",
[2395]29          items: "li:not(.sortable-delete-placeholder,.empty-widgets)",
[1649]30          connectWith: ".connected, .sortable-delete",
31          start: function( event, ui ) {
[1766]32               // petit décalage esthétique
[1650]33               ui.item.css('left', ui.item.position().left + 20);
[1649]34          },
35          update: function(event, ui) {
[1650]36               ul = $(this);
37               widget = ui.item;
38               field = ul.parents('.widgets');
[2566]39
[1650]40               // met a zéro le décalage
[1649]41               ui.item.css('left', 'auto');
[2980]42               // Fixes issue #2080
[2973]43               ui.item.css('width', 'auto');
44               ui.item.css('height', 'auto');
[2566]45
[1766]46               // signale les zones vides
[2395]47               if( ul.find('li:not(.empty-widgets)').length == 0 ) {
48                    ul.find('li.empty-widgets').show();
49                    field.find('ul.sortable-delete').hide();
50               } else {
51                    ul.find('li.empty-widgets').hide();
52                    field.find('ul.sortable-delete').show();
53               }
[2566]54
[1650]55               // remove
56               if( widget.parents('ul').is('.sortable-delete') ) {
57                    widget.hide('slow', function() {
58                         $(this).remove();
59                    });
[1649]60               }
[2566]61
[1649]62               // réordonne
[2401]63               reorder(ul);
[2566]64
[1650]65               // expand
66               if(widget.find('img.expand').length == 0) {
67                    dotclear.postExpander(widget);
68                    dotclear.viewPostContent(widget, 'close');
[1649]69               }
[1650]70          }
[1648]71     });
[2566]72
[1648]73     // add
[1659]74     $( "#widgets-ref > li" ).draggable({
[1649]75          tolerance: "move",
76          cursor: "move",
[1648]77          connectToSortable: ".connected",
78          helper: "clone",
79          revert: "invalid",
80          start: function( event, ui ) {
[1659]81               ui.helper.css({'width': $('#widgets-ref > li').css('width')});
[1649]82          }
[1648]83     });
[2566]84
[2395]85     $("li.ui-draggable, ul.ui-sortable li")
86          .not('ul.sortable-delete li, li.empty-widgets')
87          .css({'cursor':'move'});
[2566]88});
Note: See TracBrowser for help on using the repository browser.

Sites map