|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="fa" dir="rtl"> |
| 3 | + |
| 4 | + <head> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css"> |
| 7 | + <link rel="stylesheet" href="../dist/jquery.scrolling-tabs.css"> |
| 8 | + |
| 9 | + <style> |
| 10 | + .left-side { |
| 11 | + width: 50%; |
| 12 | + } |
| 13 | + |
| 14 | + .right-side { |
| 15 | + width: 50%; |
| 16 | + } |
| 17 | + |
| 18 | + .st-demo-header { |
| 19 | + background-color: #666666; |
| 20 | + color: white; |
| 21 | + font-size: 24px; |
| 22 | + padding: 8px 24px; |
| 23 | + } |
| 24 | + |
| 25 | + .st-demo-header button { |
| 26 | + color: black; |
| 27 | + font-size: 12px; |
| 28 | + } |
| 29 | + |
| 30 | + .st-demo-subheader { |
| 31 | + background-color: #f0f0f0; |
| 32 | + color: #333; |
| 33 | + font-size: 16px; |
| 34 | + height: 65px; |
| 35 | + margin-top: 50px; |
| 36 | + padding: 8px 24px; |
| 37 | + } |
| 38 | + |
| 39 | + .st-demo-subheader:first-child { |
| 40 | + margin-top: 0; |
| 41 | + } |
| 42 | + </style> |
| 43 | + </head> |
| 44 | + |
| 45 | + <body> |
| 46 | + |
| 47 | + <div class="st-demo-header"> |
| 48 | + <div>jquery-bootstrap-scrolling-tabs Demo - Data Driven</div> |
| 49 | + <div>Using Tabs Array</div> |
| 50 | + <div> |
| 51 | + <button type="button" class="btn-add-tab">Add Tab</button> |
| 52 | + <button type="button" class="btn-remove-tab">Remove Tab</button> |
| 53 | + <button type="button" class="btn-update-tab">Update Tab</button> |
| 54 | + <button type="button" class="btn-move-tab">Move Tabs</button> |
| 55 | + <button type="button" class="btn-destroy">Destroy</button> |
| 56 | + </div> |
| 57 | + |
| 58 | + </div> |
| 59 | + |
| 60 | + <!-- build .nav-tabs and .tab-content in here --> |
| 61 | + <div class="tabs-inside-here"></div> |
| 62 | + |
| 63 | + |
| 64 | + <script src="../node_modules/jquery/dist/jquery.min.js"></script> |
| 65 | + <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
| 66 | + |
| 67 | + <script src="../dist/jquery.scrolling-tabs.js"></script> |
| 68 | + |
| 69 | + <script> |
| 70 | + ;(function() { |
| 71 | + 'use strict'; |
| 72 | + |
| 73 | + |
| 74 | + var tabs = [ |
| 75 | + { paneId: 'tab00', title: 'Tab Index 0', content: 'Tab Index 0 Content', active: true, disabled: false }, |
| 76 | + { paneId: 'tab01', title: 'Tab Index 1', content: 'Tab Index 1 Content', active: false, disabled: false }, |
| 77 | + { paneId: 'tab02', title: 'Tab Index 2', content: 'Tab Index 2 Content', active: false, disabled: false }, |
| 78 | + { paneId: 'tab03', title: 'Tab Index 3', content: 'Tab Index 3 Content', active: false, disabled: false }, |
| 79 | + { paneId: 'tab04', title: 'Tab Index 4', content: 'Tab Index 4 Content', active: false, disabled: true }, |
| 80 | + { paneId: 'tab05', title: 'Tab Index 5', content: 'Tab Index 5 Content', active: false, disabled: false }, |
| 81 | + { paneId: 'tab06', title: 'Tab Index 6', content: 'Tab Index 6 Content', active: false, disabled: false }, |
| 82 | + { paneId: 'tab07', title: 'Tab Index 7', content: 'Tab Index 7 Content', active: false, disabled: false }, |
| 83 | + { paneId: 'tab08', title: 'Tab Index 8', content: 'Tab Index 8 Content', active: false, disabled: false }, |
| 84 | + { paneId: 'tab09', title: 'Tab Index 9', content: 'Tab Index 9 Content', active: false, disabled: false }, |
| 85 | + { paneId: 'tab10', title: 'Tab Index 10', content: 'Tab Index 10 Content', active: false, disabled: false }, |
| 86 | + { paneId: 'tab11', title: 'Tab Index 11', content: 'Tab Index 11 Content', active: false, disabled: false } |
| 87 | + ], |
| 88 | + lastTabId = 11; |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + $(activate); |
| 93 | + |
| 94 | + |
| 95 | + function activate() { |
| 96 | + |
| 97 | + $('.tabs-inside-here').scrollingTabs({ |
| 98 | + tabs: tabs, // required, |
| 99 | + propPaneId: 'paneId', // optional - pass in default value for demo purposes |
| 100 | + propTitle: 'title', // optional - pass in default value for demo purposes |
| 101 | + propActive: 'active', // optional - pass in default value for demo purposes |
| 102 | + propDisabled: 'disabled', // optional - pass in default value for demo purposes |
| 103 | + propContent: 'content', // optional - pass in default value for demo purposes |
| 104 | + scrollToTabEdge: false, // optional - pass in default value for demo purposes |
| 105 | + disableScrollArrowsOnFullyScrolled: true, |
| 106 | + enableSwiping: true, |
| 107 | + rtl: true, |
| 108 | + //widthMultiplier: 0.7, |
| 109 | + tabClickHandler: function () { |
| 110 | + console.log("click!! ", Date.now()); |
| 111 | + } |
| 112 | + }); |
| 113 | + |
| 114 | + $('.btn-add-tab').click(addTab); |
| 115 | + $('.btn-remove-tab').click(removeTab); |
| 116 | + $('.btn-update-tab').click(updateTab); |
| 117 | + $('.btn-move-tab').click(moveTab); |
| 118 | + $('.btn-destroy').click(destroy); |
| 119 | + } |
| 120 | + |
| 121 | + function destroy() { |
| 122 | + $('.tabs-inside-here').scrollingTabs('destroy'); |
| 123 | + } |
| 124 | + |
| 125 | + function updateTab() { |
| 126 | + console.log("update " + tabs[1].title); |
| 127 | + |
| 128 | + tabs[1].title = 'UPDATED ' + tabs[1].title; |
| 129 | + tabs[1].content = 'UPDATED ' + tabs[1].content; |
| 130 | + |
| 131 | + $('.tabs-inside-here').scrollingTabs('refresh'); |
| 132 | + } |
| 133 | + |
| 134 | + function moveTab() { |
| 135 | + console.log("move " + tabs[1].title + " to after " + tabs[4].title + |
| 136 | + ", move " + tabs[9].title + " to before " + tabs[6].title); |
| 137 | + |
| 138 | + tabs.splice(4, 0, tabs.splice(1, 1)[0]); // move 1 to right after 4 |
| 139 | + tabs.splice(6, 0, tabs.splice(9, 1)[0]); // move 9 to right before 6 |
| 140 | + |
| 141 | + $('.tabs-inside-here').scrollingTabs('refresh'); |
| 142 | + } |
| 143 | + |
| 144 | + function addTab() { |
| 145 | + var newTab = { |
| 146 | + paneId: 'tab' + (++lastTabId), |
| 147 | + title: 'Tab Index ' + lastTabId, |
| 148 | + content: 'Tab Index ' + lastTabId + ' Content', |
| 149 | + active: true, |
| 150 | + disabled: false |
| 151 | + }; |
| 152 | + |
| 153 | + console.log("append new tab ", newTab.title); |
| 154 | + |
| 155 | + // deactivate currently active tab |
| 156 | + tabs.some(function (tab) { |
| 157 | + if (tab.active) { |
| 158 | + tab.active = false; |
| 159 | + return true; // exit loop |
| 160 | + } |
| 161 | + }); |
| 162 | + |
| 163 | + tabs.push(newTab); |
| 164 | + |
| 165 | + $('.tabs-inside-here').scrollingTabs('refresh', { |
| 166 | + forceActiveTab: true // make our new tab active |
| 167 | + }); |
| 168 | + } |
| 169 | + |
| 170 | + function removeTab() { |
| 171 | + console.log("remove tab ", tabs[2].title); |
| 172 | + |
| 173 | + tabs.splice(2, 1); |
| 174 | + |
| 175 | + $('.tabs-inside-here').scrollingTabs('refresh'); |
| 176 | + } |
| 177 | + |
| 178 | + }()); |
| 179 | + |
| 180 | + </script> |
| 181 | + </body> |
| 182 | + |
| 183 | +</html> |
0 commit comments