this.tableDnDConfig = jQuery.extend({
onDragStyle: null,
onDropStyle: null,
- // Add in the default class for whileDragging
- onDragClass: "tDnD_whileDrag",
+ // Add in the default class for whileDragging
+ onDragClass: "tDnD_whileDrag",
onDrop: null,
onDragStart: null,
scrollAmount: 5,
- serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
- serializeParamName: null, // If you want to specify another parameter name instead of the table ID
+ serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
+ serializeParamName: null, // If you want to specify another parameter name instead of the table ID
dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
}, options || {});
// Now make the rows draggable
/** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
makeDraggable: function(table) {
var config = table.tableDnDConfig;
- if (table.tableDnDConfig.dragHandle) {
- // We only need to add the event to the specified cells
- var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
- cells.each(function() {
- // The cell is bound to "this"
+ if (table.tableDnDConfig.dragHandle) {
+ // We only need to add the event to the specified cells
+ var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
+ cells.each(function() {
+ // The cell is bound to "this"
jQuery(this).mousedown(function(ev) {
jQuery.tableDnD.dragObject = this.parentNode;
jQuery.tableDnD.currentTable = table;
}
return false;
});
- })
- } else {
- // For backwards compatibility, we add the event to the whole row
- var rows = jQuery("tr", table); // get all the rows as a wrapped set
- rows.each(function() {
- // Iterate through each row, the row is bound to "this"
- var row = jQuery(this);
- if (! row.hasClass("nodrag")) {
- row.mousedown(function(ev) {
- if (ev.target.tagName == "TD") {
- jQuery.tableDnD.dragObject = this;
- jQuery.tableDnD.currentTable = table;
- jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
- if (config.onDragStart) {
- // Call the onDrop method if there is one
- config.onDragStart(table, this);
- }
- return false;
- }
- }).css("cursor", "move"); // Store the tableDnD object
- }
- });
- }
- },
+ })
+ } else {
+ // For backwards compatibility, we add the event to the whole row
+ var rows = jQuery("tr", table); // get all the rows as a wrapped set
+ rows.each(function() {
+ // Iterate through each row, the row is bound to "this"
+ var row = jQuery(this);
+ if (! row.hasClass("nodrag")) {
+ row.mousedown(function(ev) {
+ if (ev.target.tagName == "TD") {
+ jQuery.tableDnD.dragObject = this;
+ jQuery.tableDnD.currentTable = table;
+ jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
+ if (config.onDragStart) {
+ // Call the onDrop method if there is one
+ config.onDragStart(table, this);
+ }
+ return false;
+ }
+ }).css("cursor", "move"); // Store the tableDnD object
+ }
+ });
+ }
+ },
- updateTables: function() {
- this.each(function() {
- // this is now bound to each matching table
- if (this.tableDnDConfig) {
- jQuery.tableDnD.makeDraggable(this);
- }
- })
- },
+ updateTables: function() {
+ this.each(function() {
+ // this is now bound to each matching table
+ if (this.tableDnDConfig) {
+ jQuery.tableDnD.makeDraggable(this);
+ }
+ })
+ },
/** Get the mouse coordinates from the event (allowing for browser differences) */
mouseCoords: function(ev){
var mousePos = jQuery.tableDnD.mouseCoords(ev);
var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
//auto scroll the window
- var yOffset = window.pageYOffset;
- if (document.all) {
- // Windows version
- //yOffset=document.body.scrollTop;
- if (typeof document.compatMode != 'undefined' &&
- document.compatMode != 'BackCompat') {
- yOffset = document.documentElement.scrollTop;
- }
- else if (typeof document.body != 'undefined') {
- yOffset=document.body.scrollTop;
- }
+ var yOffset = window.pageYOffset;
+ if (document.all) {
+ // Windows version
+ //yOffset=document.body.scrollTop;
+ if (typeof document.compatMode != 'undefined' &&
+ document.compatMode != 'BackCompat') {
+ yOffset = document.documentElement.scrollTop;
+ }
+ else if (typeof document.body != 'undefined') {
+ yOffset=document.body.scrollTop;
+ }
- }
-
- if (mousePos.y-yOffset < config.scrollAmount) {
- window.scrollBy(0, -config.scrollAmount);
- } else {
+ }
+
+ if (mousePos.y-yOffset < config.scrollAmount) {
+ window.scrollBy(0, -config.scrollAmount);
+ } else {
var windowHeight = window.innerHeight ? window.innerHeight
: document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
// update the old value
jQuery.tableDnD.oldY = y;
// update the style to show we're dragging
- if (config.onDragClass) {
- dragObj.addClass(config.onDragClass);
- } else {
- dragObj.css(config.onDragStyle);
- }
+ if (config.onDragClass) {
+ dragObj.addClass(config.onDragClass);
+ } else {
+ dragObj.css(config.onDragStyle);
+ }
// If we're over a row then move the dragged row to there so that the user sees the
// effect dynamically
var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
// Because we always have to insert before, we need to offset the height a bit
if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
// that's the row we're over
- // If it's the same as the current row, ignore it
- if (row == draggedRow) {return null;}
+ // If it's the same as the current row, ignore it
+ if (row == draggedRow) {return null;}
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
if (config.onAllowDrop) {
if (config.onAllowDrop(draggedRow, row)) {
return null;
}
} else {
- // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
+ // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
var nodrop = jQuery(row).hasClass("nodrop");
if (! nodrop) {
return row;
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
// If we have a dragObject, then we need to release it,
// The row will already have been moved to the right place so we just reset stuff
- if (config.onDragClass) {
- jQuery(droppedRow).removeClass(config.onDragClass);
- } else {
- jQuery(droppedRow).css(config.onDropStyle);
- }
+ if (config.onDragClass) {
+ jQuery(droppedRow).removeClass(config.onDragClass);
+ } else {
+ jQuery(droppedRow).css(config.onDropStyle);
+ }
jQuery.tableDnD.dragObject = null;
if (config.onDrop) {
// Call the onDrop method if there is one
}
},
- serializeTable: function(table) {
+ serializeTable: function(table) {
var result = "";
var tableId = table.id;
var rows = table.rows;
result += rowId;
}
return result;
- },
+ },
- serializeTables: function() {
+ serializeTables: function() {
var result = "";
this.each(function() {
- // this is now bound to each matching table
- result += jQuery.tableDnD.serializeTable(this);
- });
+ // this is now bound to each matching table
+ result += jQuery.tableDnD.serializeTable(this);
+ });
return result;
}
}
jQuery.fn.extend(
- {
- tableDnD : jQuery.tableDnD.build,
- tableDnDUpdate : jQuery.tableDnD.updateTables,
- tableDnDSerialize: jQuery.tableDnD.serializeTables
- }
+ {
+ tableDnD : jQuery.tableDnD.build,
+ tableDnDUpdate : jQuery.tableDnD.updateTables,
+ tableDnDSerialize: jQuery.tableDnD.serializeTables
+ }
);
\ No newline at end of file
<div id="content" class="flex">
<h1>{$page_title}</h1>
- <div id="content-main">
+ <div id="content-main">
<ul class="object-tools">{if array_search('add',$perms)!==false}<li><a href="add/" class="addlink">Add {$classname}</a></li>{/if}<li><a href="javascript:print();">Print</a></li></ul>
<div id="changelist" class="module {if $filters} filtered{/if}">
{if $is_search}
<div id="toolbar">
- <form id="changelist-search" method="get" action="">
- <div>
- <label for="searchbar">
- <img alt="Search" src="{$ADMIN_MEDIA_URL}img/icon_searchbox.png" />
- </label>
- <input id="searchbar" type="text" value="{$search_value}" name="q" size="40"/>
- <input type="submit" value="Go"/>
- {if $search_value}
- <span class="small quiet">{$pager->getPager()->getNumResults()} results (<a href="{url 'IPF_Admin_Views_ListItems', array($lapp, $lmodel)}">reset</a>)</span>
- {/if}
- </div>
- </form>
+ <form id="changelist-search" method="get" action="">
+ <div>
+ <label for="searchbar">
+ <img alt="Search" src="{$ADMIN_MEDIA_URL}img/icon_searchbox.png" />
+ </label>
+ <input id="searchbar" type="text" value="{$search_value}" name="q" size="40"/>
+ <input type="submit" value="Go"/>
+ {if $search_value}
+ <span class="small quiet">{$pager->getPager()->getNumResults()} results (<a href="{url 'IPF_Admin_Views_ListItems', array($lapp, $lmodel)}">reset</a>)</span>
+ {/if}
+ </div>
+ </form>
</div>
- {/if}
+ {/if}
- {if $filters}
- <div id="changelist-filter">
- <h2>Filter</h2>
- {foreach $filters as $f}
- <h3>{$f->title}</h3>
- <ul>
- {foreach $f->choices as $ch}
- <li{if $ch['selected']} class="selected"{/if}><a href="?{$ch['param']}">{$ch['name']}</a></li>
- {/foreach}
- </ul>
- {/foreach}
- </div>
- {/if}
- <table id="items-grid">
- <thead>
- <tr>
- {foreach $header as $h}
- <th>{$h.title}</th>
- {/foreach}
- </tr>
- </thead>
- <tbody>
- {foreach $objects as $o}
- <tr class="trsort" id="{$o.pk()}">
- {foreach $o.ModelAdmin().ListRow($o) as $v}
- <td>{$v|safe}</td>
- {/foreach}
- </tr>
- {/foreach}
- </tbody>
- </table>
- <p class="paginator">
- {$pager->display()|safe}{$pager->getPager()->getNumResults()} record(s) of {$classname}
- </p>
+ {if $filters}
+ <div id="changelist-filter">
+ <h2>Filter</h2>
+ {foreach $filters as $f}
+ <h3>{$f->title}</h3>
+ <ul>
+ {foreach $f->choices as $ch}
+ <li{if $ch['selected']} class="selected"{/if}><a href="?{$ch['param']}">{$ch['name']}</a></li>
+ {/foreach}
+ </ul>
+ {/foreach}
+ </div>
+ {/if}
+ <table id="items-grid">
+ <thead>
+ <tr class="nodrop">
+ {foreach $header as $h}
+ <th>{$h.title}</th>
+ {/foreach}
+ </tr>
+ </thead>
+ <tbody>
+ {foreach $objects as $o}
+ <tr class="trsort" id="{$o.pk()}">
+ {foreach $o.ModelAdmin().ListRow($o) as $v}
+ <td>{$v|safe}</td>
+ {/foreach}
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+ <p class="paginator">
+ {$pager->display()|safe}{$pager->getPager()->getNumResults()} record(s) of {$classname}
+ </p>
</div>
- </div>
- <br class="clear" />
+ </div>
+ <br class="clear" />
</div>