12fc2651226baac27029e38c9d6ef883fa32084dbSteve Block/* 22fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * Copyright (C) 2011 Google Inc. All rights reserved. 32fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 42fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * Redistribution and use in source and binary forms, with or without 52fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * modification, are permitted provided that the following conditions are 62fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * met: 72fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 82fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * * Redistributions of source code must retain the above copyright 92fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * notice, this list of conditions and the following disclaimer. 102fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * * Redistributions in binary form must reproduce the above 112fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * copyright notice, this list of conditions and the following disclaimer 122fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * in the documentation and/or other materials provided with the 132fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * distribution. 142fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * * Neither the name of Google Inc. nor the names of its 152fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * contributors may be used to endorse or promote products derived from 162fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * this software without specific prior written permission. 172fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 182fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 192fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 202fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 212fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 222fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 232fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 242fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 252fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 262fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 272fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 282fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 292fc2651226baac27029e38c9d6ef883fa32084dbSteve Block */ 302fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 312fc2651226baac27029e38c9d6ef883fa32084dbSteve BlockWebInspector.ShowMoreDataGridNode = function(callback, nextCount, allCount) 322fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 332fc2651226baac27029e38c9d6ef883fa32084dbSteve Block function populate(count) 342fc2651226baac27029e38c9d6ef883fa32084dbSteve Block { 352fc2651226baac27029e38c9d6ef883fa32084dbSteve Block var index = this.parent.children.indexOf(this); 362fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.parent.removeChild(this); 372fc2651226baac27029e38c9d6ef883fa32084dbSteve Block callback(count, index); 382fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } 392fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 402fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showNext = document.createElement("button"); 412fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showNext.setAttribute("type", "button"); 422fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showNext.textContent = WebInspector.UIString("Show next %d", nextCount); 432fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showNext.addEventListener("click", populate.bind(this, nextCount), false); 442fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 452fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (allCount) { 462fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showAll = document.createElement("button"); 472fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showAll.setAttribute("type", "button"); 482fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showAll.textContent = WebInspector.UIString("Show all %d", allCount); 492fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.showAll.addEventListener("click", populate.bind(this, allCount), false); 502fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } 512fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 522fc2651226baac27029e38c9d6ef883fa32084dbSteve Block WebInspector.DataGridNode.call(this, {summaryRow:true}, false); 532fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this.selectable = false; 542fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 552fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 562fc2651226baac27029e38c9d6ef883fa32084dbSteve BlockWebInspector.ShowMoreDataGridNode.prototype = { 572fc2651226baac27029e38c9d6ef883fa32084dbSteve Block createCells: function() 582fc2651226baac27029e38c9d6ef883fa32084dbSteve Block { 592fc2651226baac27029e38c9d6ef883fa32084dbSteve Block var cell = document.createElement("td"); 602fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (this.depth) 612fc2651226baac27029e38c9d6ef883fa32084dbSteve Block cell.style.setProperty("padding-left", (this.depth * this.dataGrid.indentWidth) + "px"); 622fc2651226baac27029e38c9d6ef883fa32084dbSteve Block cell.appendChild(this.showNext); 632fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (this.showAll) 642fc2651226baac27029e38c9d6ef883fa32084dbSteve Block cell.appendChild(this.showAll); 652fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this._element.appendChild(cell); 662fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 672fc2651226baac27029e38c9d6ef883fa32084dbSteve Block var columns = this.dataGrid.columns; 682fc2651226baac27029e38c9d6ef883fa32084dbSteve Block var count = 0; 692fc2651226baac27029e38c9d6ef883fa32084dbSteve Block for (var c in columns) 702fc2651226baac27029e38c9d6ef883fa32084dbSteve Block ++count; 712fc2651226baac27029e38c9d6ef883fa32084dbSteve Block while (--count > 0) { 722fc2651226baac27029e38c9d6ef883fa32084dbSteve Block cell = document.createElement("td"); 732fc2651226baac27029e38c9d6ef883fa32084dbSteve Block this._element.appendChild(cell); 742fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } 752fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } 762fc2651226baac27029e38c9d6ef883fa32084dbSteve Block}; 772fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 782fc2651226baac27029e38c9d6ef883fa32084dbSteve BlockWebInspector.ShowMoreDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype; 79