From patchwork Fri Sep 11 15:54:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0E3B914012C for ; Sat, 12 Sep 2015 01:59:08 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id E8B651A2BC8 for ; Sat, 12 Sep 2015 01:59:07 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id B1A101A2BC0 for ; Sat, 12 Sep 2015 01:55:55 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Sep 2015 08:55:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559867107" Received: from jeffzhua-mobl.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.88.85]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2015 08:55:51 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 23/51] dynatable: Allow the user to have a pre-defined per-page element Date: Fri, 11 Sep 2015 16:54:56 +0100 Message-Id: <1441986924-26689-24-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> References: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Sometimes users of dynatable don't want the library to generate its own elements, but use the ones already present in the page. This patch adds support to do just that for the per-page element. Signed-off-by: Damien Lespiau --- lib/packages/jquery/jquery.dynatable.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/packages/jquery/jquery.dynatable.js b/lib/packages/jquery/jquery.dynatable.js index 9285e1e..eb8065d 100644 --- a/lib/packages/jquery/jquery.dynatable.js +++ b/lib/packages/jquery/jquery.dynatable.js @@ -1300,7 +1300,8 @@ }; function PaginationPerPage(obj, settings) { - var _this = this; + var _this = this, + fromUser = true; this.initOnLoad = function() { return settings.features.paginate; @@ -1326,10 +1327,15 @@ }; this.create = function() { - var $select = $('', { id: 'dynatable-per-page-' + obj.element.id, 'class': 'dynatable-per-page-select' - }); + }); + } for (var i = 0, len = settings.dataset.perPageOptions.length; i < len; i++) { var number = settings.dataset.perPageOptions[i], @@ -1342,14 +1348,22 @@ obj.process(); }); + if (fromUser) + return $select; + return $('', { 'class': 'dynatable-per-page' }).append("" + settings.inputs.perPageText + "").append($select); }; this.attach = function() { + var element = this.create(); + + if (fromUser) + return; + var $target = settings.inputs.perPageTarget ? $(settings.inputs.perPageTarget) : obj.$element; - $target[settings.inputs.perPagePlacement](this.create()); + $target[settings.inputs.perPagePlacement](element); }; this.set = function(number, skipResetPage) {