1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
/* RTP.Slider.js - experimental release https://github.com/mgreter/slider*/;/* Copyright (c) Marcel Greter 2010/2012 - rtp.ch - RTP jQuery Slider 0.12.3 This is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt), either version 3 of the License, or (at your option) any later version.*/;/* Copyright (c) Marcel Greter 2010 - rtp.ch - RTP Multi Event Dispatcher v0.8.2 This is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt), either version 3 of the License, or (at your option) any later version. Example: var xml_doc, xsl_doc; var mevent = new RTP.Multievent(function() { // do something with xml_doc and xsl_doc }) // mevent is satisfied when all have been called var xml_complete = mevent.prerequisite(); var xsl_complete = mevent.prerequisite(); // load url and call mevent prerequisites / store doc when completed _ajax.load(xml_url, function (doc) { xml_doc = doc; xml_complete(); }); _ajax.load(xsl_url, function (doc) { xsl_doc = doc; xsl_complete(); });*/if (!window.RTP) window.RTP = {}; // ns/* @@@@@@@@@@ CONSTRUCTOR @@@@@@@@@@ */// constructor (variables/settings and init)RTP.Multievent = function (cb){ this.cb = cb; // callback when satisifed this.ids = 0; // registered prerequisites this.args = {}; // save callback arguments this.required = 0; // registered prerequisites this.listeners = []; // some additional listeners this.satisfied = []; // satisfied prerequisites};/* @@@@@@@@@@ RTP CLASS @@@@@@@@@@ */// extend class prototype(function (prototype){ // get function checker var isFn = jQuery.isFunction; // @@@ request a new prerequisite that must be satisfied @@@ prototype.prerequisite = function(arg) { var cb = isFn(arg) ? arg : null; var name = isFn(arg) ? null : arg; var self = this; this.required ++; var id = this.ids ++; this.satisfied[id] = false; // return function to be called to signal satisfaction return function () { if (!self.satisfied[id]) { if (cb) cb(); self.required --; self.satisfied[id] = true; if (name) self.args[name] = arguments; if (self.required == 0 & self.cb) { self._cb = self.cb; self.cb = false; for(var i = 0; i < self.listeners.length; i++) { self.listeners[i]() } return self._cb(); } } } }; // @@@ finish this multievent @@@ prototype.finish = function() { /* call this method when you add prerequisites dynamically */ /* this will fire the callback immediately if no prerequisites */ /* were registered, otherwise we will wait till they are satisfied */ // execute the callback on no prerequisites if (this.ids == 0 & this.cb) { this._cb = this.cb; this.cb = false; for(var i = 0; i < this.listeners.length; i++) { this.listeners[i]() } return this._cb(); } };// EO extend class prototype})(RTP.Multievent.prototype);;/* Copyright (c) Marcel Greter 2012 - OCBNET Layouter 1.0.0 This plugin available for use in all personal or commercial projects under both MIT and GPL licenses. The Layouter takes care of widgets that have aspect ratios. These Widgets can run into problem when the scrollbar appears. This lib does the same as any (tested) browser does when displaying images with an aspect ratio and a flexible width. When the vertical scrollbar appears due to the widget/image beeing to tall, the width of the widget would be decreased which in turn decreases the height. This then can make the scrollbar to disapear again, which in turn would increase the width and height of the widget again. To solve this endless loop, we force a vertical scrollbar to be shown. This fixes layout and scrollbar problems like these: http://stackoverflow.com/questions/6818096*//* @@@@@@@@@@ STATIC CLASS @@@@@@@@@@ */// create private scope(function (jQuery){ // jquery win and body object // body will be set when the first // widget is added to the collection var win = jQuery(window), body = null; // frames per second to layout // only needed when not in vsync mode var fps = 60; // store scheduled timeout var scheduled; // widgets without parent var roots = jQuery(); // widgets to be layouted var widgets = jQuery(); // old body overflow style var overflow_x, overflow_y; // get the user agent string in lowercase // copy feature from jquery migrate plugin // this was included in jquery before v1.9 var ua = navigator.userAgent.toLowerCase(); // only match for ie and mozilla so far var match = // /(chrome)[ \/]([\w.]+)/.exec( ua ) || // /(webkit)[ \/]([\w.]+)/.exec( ua ) || // /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || /(msie) ([\w.]+)/.exec( ua ) || ua.indexOf("compatible") < 0 & /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || []; // get splitted information about the user agent var browser = match[ 1 ] || '', version = match[ 2 ] || '0'; // defer the resize event and filter multiple calls // this is a bugfix for ie 8 where the resize event may is // triggered multiple times when scrollbars appear/disappear var vsync = ! browser == 'msie' || parseInt(version, 10) != 8; // get firefox mode on startup / initialization // firefox will show both scrollbars when the layout // does not 'fit' perfectly. All other browsers will // only show the scrollbar in the direction needed. var firefox_overflow = browser == 'mozilla'; // use requestAnimationFrame to defer functions // this seems to work quite well, so include it var setDefered = window.requestAnimationFrame, clearDefered = window.cancelAnimationFrame || window.cancelRequestAnimationFrame; // search for requestAnimationFrame by vendor var vendors = ['ms', 'moz', 'webkit', 'o']; // loop vendors until the request animation frame function is found for(var x = 0; x < vendors.length & !setDefered; ++x) { setDefered = window[vendors[x]+'RequestAnimationFrame']; clearDefered = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } // create function to take out delay argument (returns identifier) if (setDefered) var callDefered = function (cb) { return setDefered(cb); }; // use timeouts as a fallback if (!callDefered) callDefered = window.setTimeout; if (!clearDefered) clearDefered = window.clearTimeout; // remember default functions var defCallDefered = callDefered; var defClearDefered = clearDefered; // static local function // call function on all widgets function exec(fn, data, widgets) { // loop all widgets in order of registration for(var i = 0, l = widgets.length; i < l; i++) { // call method in widget context if (jQuery.isFunction(widgets[i][fn])) { widgets[i][fn].call(widgets[i], data); } } } // EO exec // static local function // call function on all widgets function layout(data, widgets) { // first call pre on all widgets [call]exec('preLayout', data, widgets); // loop all widgets in order of registration for(var i = 0, l = widgets.length; i < l; i++) { // get childrens for widget from options var children = widgets[i].layout.children; // call layout for all childrens if (children & children.length) { [call]layout(data, children); } } // then call update on all widgets [call]exec('postLayout', data, widgets); } // EO layout // static local function // call function on all widgets function finalize(data, widgets) { // first call post on all widgets [call]exec('updateLayout', data, widgets); // loop all widgets in order of registration for(var i = 0, l = widgets.length; i < l; i++) { // get childrens for widget from options var children = widgets[i].layout.children; // call finalize for all childrens if (children & children.length) { [call]finalize(data, children); } } } // EO finalize // static global function // do the layout on all widgets function Manager (force, widgets) { // shared data (assign flag) var data = { force: force }; // get nodes to manage in this run var nodes = widgets ? jQuery(widgets) : roots; // restore the previous overflow style on the document body // needed so our layout can trigger the scrollbar to appear/disapear if (overflow_y) { body.css('overflow-y', overflow_y); overflow_y = null; } if (overflow_x) { body.css('overflow-x', overflow_x); overflow_x = null; } // get the initial dimensions var body_1st_x = win.innerWidth(); var body_1st_y = win.innerHeight(); // reflow layout [call]layout(data, nodes); // get the dimensions afterwards var body_2nd_x = win.innerWidth(); var body_2nd_y = win.innerHeight(); if (body_1st_x != body_2nd_x || body_1st_y != body_2nd_y) // if (body_1st_x > body_2nd_x || body_1st_y > body_2nd_y) { // reflow layout [call]layout(data, nodes); // get the dimensions afterwards var body_3rd_x = win.innerWidth(); var body_3rd_y = win.innerHeight(); if (body_2nd_x != body_3rd_x || body_2nd_y != body_3rd_y) // if (body_2nd_x < body_3rd_x || body_2nd_y < body_3rd_y) { // check if we should force the horizontal scrollbar if (firefox_overflow || body_2nd_y != body_3rd_y) { // store previous scollbar setting overflow_x = body.css('overflow-x'); // reset to scroll if not hidden if (overflow_x != 'hidden') { body.css('overflow-x', 'scroll'); } } // check if we should force the vertical scrollbar if (firefox_overflow || body_2nd_x != body_3rd_x) { // store previous scollbar setting overflow_y = body.css('overflow-y'); // reset to scroll if not hidden if (overflow_y != 'hidden') { body.css('overflow-y', 'scroll'); } } // reflow layout [call]layout(data, nodes); } // EO if 2nd changed } // EO if 1st changed // execute last (only once) [call]finalize(data, nodes); }; // EO Manager // static global function Manager.config = function (key, value) { // assign config option switch (key) { case 'fps': fps = value; break; case 'vsync': vsync = value; break; case 'default': callDefered = defCallDefered; clearDefered = defClearDefered; break; case 'fallback': callDefered = window.setTimeout; clearDefered = window.clearTimeout; break; } // reassign the resizer function resizer = vsync ? function () { [call]Manager(); } : deferer; }; // EO config // static global function // schedule a layout call in delay ms // normally we keep the current waiting timeout // set reset if you want to reschedule the repaint Manager.schedule = function (delay, reset) { // do not re-schedule, execute the first timeout. // we want it to be called from time to time if (!reset & scheduled) return; // we should reset the scheduled callback // this will enforce the delay to stay if (scheduled) clearDefered(scheduled); // schedule a layout execution scheduled = callDefered(function() { // call layout [call]Manager(); // reset timer status // we are ready for more scheduled = null; }, delay || 0); } // EO Manager.schedule // EO Manager.defer Manager.defer = function (fn, delay) { // delay is optional if (typeof delay == 'undefined') { delay = 1000 / fps; } // add scheduled function return callDefered(fn, delay); } // EO Manager.defer // EO Manager.undefer Manager.undefer = function (scheduled) { // clear scheduled function return clearDefered(scheduled); } // EO Manager.undefer // static global function // add a widget under our control Manager.add = function (widget) { // assign the body object only once if (!body) body = jQuery('BODY:first'); // extend/initialize layout options property widget.layout = jQuery.extend({ children: [] }, widget.layout) // check if widget has a parent with children // add ourself to our parent's children array if (widget.layout & widget.layout.parent) { if (!widget.layout.parent.layout.children) { widget.layout.parent.layout.children = []; } widget.layout.parent.layout.children.push(widget); } // otherwise it's a root widget without parent else { roots = roots.add(jQuery(widget)); } // call start layout hook on widget if (jQuery.isFunction(widget.startLayout)) { widget.startLayout.call(widget); } // jQueryfy input argument widget = jQuery(widget); // attach resize event to call resizer if (widgets.length == 0 & widget.length > 0) { jQuery(window).bind('resize', resizer); } // push instances to static array widgets = widgets.add(widget) // make static array a global // Manager.widgets = widgets; // Manager.roots = roots; }; // EO Manager.add // static global function // add a widget under our control Manager.del = function (widget) { // call stop layout hook on widget if (jQuery.isFunction(widget.stopLayout)) { widget.stopLayout.call(widget); } // jQueryfy input argument widget = jQuery(widget); // remove from static arrays widgets = widgets.not(widget) roots = roots.not(widget); // remove the resize handler when there are no widgets left if (widgets.length == 0) jQuery(window).unbind('resize', resizer); // make static array a global // Manager.widgets = widgets; // Manager.roots = roots; }; // EO Manager.del // make static array a global // Manager.widgets = widgets; // Maybe we should defer the resize event. // This is needed to avoid a possible endless // loop in internet explorer 8. This Browser // can trigger resize events after scrollbars // appear/disapear or on reflow of some element. // IE 7 and below always show a scrollbar, so this // problem does not seem to exist, otherwise we // should also set those browsers to defer the resize. // only enqueue one var resizing = false; // @@@ function: deferer @@@ var deferer = function () { // only register one callback if (resizing) return false; // register a callback for next idle loop resizing = callDefered(function() { // call layouter [call]Manager(); // reset the lock resizing = false; }, 1000 / fps) } // @@@ EO function: deferer @@@ // Set resizer to the desired function to execute. // Set this on initialization as the decision is always // based on information that must not change during runtime. // Will be bound to resize event when first widget is added. var resizer = vsync ? function () { [call]Manager(); } : deferer; // make sure our global namespace exists // but do not reset it if already present if (typeof OCBNET == 'undefined') OCBNET = {}; // assign class to global namespace OCBNET.Layout = Manager;})(jQuery);// EO private scope;// taken from http://api.jquery.com/jQuery.cssHooks/(function($) { if ( !$.cssHooks ) { throw("jQuery 1.4.3+ is needed for this plugin to work"); return; } var css3 = [ 'boxSizing', 'transform', 'perspective', 'transformStyle', 'backfaceVisibility' ]; function styleSupport( prop ) { var vendorProp, supportedProp, capProp = prop.charAt(0).toUpperCase() + prop.slice(1), prefixes = [ "Moz", "Webkit", "O", "ms" ], div = document.createElement( "div" ); if ( prop in div.style ) { supportedProp = prop; } else { for ( var i = 0; i < prefixes.length; i++ ) { vendorProp = prefixes[i] + capProp; if ( vendorProp in div.style ) { supportedProp = vendorProp; break; } } } div = null; $.support[ prop ] = supportedProp return supportedProp; } var i = css3.length; while (i--) { (function() { var attr = css3[i], support = [call]styleSupport( attr ); // Set cssHooks only for browsers that // supports a vendor-prefixed style only if ( support & support !== attr ) { $.cssHooks[attr] = { get: function( elem, computed, extra ) { return $.css( elem, support ); }, set: function( elem, value) { elem.style[ support ] = value; } }; } })() }})(jQuery);;/* Copyright (c) Marcel Greter 2011/2013 - OCBNET Gestures 0.0.0 This is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt), either version 3 of the License, or (at your option) any later version.*/;// @@@ private scope @@@(function(){ // @@@ private fn: trap @@@ function trap (handleObj) { // get current handler for event var handler = handleObj.handler; // @@@ closure fn: trapped @@@ var trapped = function (evt) { // call the original handler first var rv = handler.call(this, evt); // check if event propagation was disabled if (rv == false || evt.isPropagationStopped()) { // store some event attributes var type = evt.type, isTrigger = evt.isTrigger, isPropagationStopped = evt.isPropagationStopped, isImmediatePropagationStopped = evt.isImmediatePropagationStopped; // add trap prefix to event // for custom event on target evt.type = 'trap' + evt.type; // force custom event propagating evt.isPropagationStopped = function () { return false; }; evt.isImmediatePropagationStopped = function () { return false; } // this will bubble up so you can // handle that trapped event anyway // XXX: Maybe call on parent instead jQuery(evt.currentTarget).parent().trigger(evt); // restore some event attributes evt.type = type; evt.isTrigger = isTrigger; if (isPropagationStopped) evt.stopPropagation(); if (isImmediatePropagationStopped) evt.stopImmediatePropagation(); // return the same as original handler if (typeof rv != 'undefined') return rv; } // EO if not propagating } // @@@ EO closure fn: trapped @@@ // reset given handler handleObj.handler = trapped; } // @@@ EO private fn: trap @@@ // special event callback var special = { add : trap }; // check for mouse interface if ( 'onmousedown' in window ) { // register common event types to trap jQuery.event.special['mouseup'] = special; jQuery.event.special['mouseout'] = special; jQuery.event.special['mouseover'] = special; jQuery.event.special['mousemove'] = special; jQuery.event.special['mousedown'] = special; } // check for touch interface if ( 'ontouchstart' in window ) { // register common event types to trap jQuery.event.special['touchend'] = special; jQuery.event.special['touchmove'] = special; jQuery.event.special['touchstart'] = special; jQuery.event.special['touchcancel'] = special; } // check if we have a pointer interface (ie11) if ( window.navigator['pointerEnabled'] & window.navigator["maxTouchPoints"] > 0 ) { // register common event types to trap jQuery.event.special['pointerup'] = special; jQuery.event.special['pointermove'] = special; jQuery.event.special['pointerdown'] = special; jQuery.event.special['pointercancel'] = special; } // check if we have a pointer interface (ie10) else if ( window.navigator['msPointerEnabled'] & window.navigator["msMaxTouchPoints"] > 0 ) { // register common event types to trap jQuery.event.special['MSPointerUp'] = special; jQuery.event.special['MSPointerMove'] = special; jQuery.event.special['MSPointerDown'] = special; jQuery.event.special['MSPointerCancel'] = special; }})()// @@@ EO private scope @@@;/* Copyright (c) Marcel Greter 2012 - OCBNET gesture 0.0.0 This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.*/// make sure our global namespace exists// but do not reset it if already presentif (typeof OCBNET == 'undefined') var OCBNET = {};// detect chrome for special implementationvar isChromium = window.chrome, vendorName = window.navigator.vendor;// decide if we are going to scroll or pan on first touch move event// this seems to be the correct implementation for google chrome, altough// it also seems to work without this and a proper setup for swipeMinDistancevar decideScrollOrPanOnFirst = isChromium !== null & vendorName === "Google Inc.";/* @@@@@@@@@@ STATIC CLASS @@@@@@@@@@ */// create private scope(function (jQuery){ // static array var fingers = {}; var gestures = []; // static counter var count = 0; // store all fingers down at any time // used to store some static information // each finger can be involved in multiple // gesture and it makes it possible to get // the associated finger data only with the id var surface = {}; // @@@ Object Constructor @@@ OCBNET.Gestures = function (el, config) { // dom element this.el = el; // create initial configuration this.config = jQuery.extend({ // native features // mostly for pan-y native: {}, // in how many angle sectors // should swipes be distributed swipeSectors: 2, // minimum distance to find // the appropriate swipe sector swipeMinDistance: 15, // decide on first touch move handler // if we should pan ourself or leave it // to the user agent to do the scrolling decideOnFirst: decideScrollOrPanOnFirst }, config, true); // assign a static id this.id = count ++; // add our instance gestures.push(this); // count fingers this.fingers = 0; // maximum fingers this.maximum = 0; // attached fingers this.finger = {}; // finger ids in order this.ordered = []; // link to static arrays this.surface = surface; // bind ... jQuery(el) // do not allow dragging of any gesture elements .bind('dragstart', function () { return false; }) // call all further initializers (mouse/touch) for (var i = 0, l = this.init.length; i < l; i++) { // binds specific event handlers this.init[i].apply(this, arguments); } }; // @@@ EO Object Constructor @@@ // @@@ finger got up somewhere on surface @@@ OCBNET.Gestures.fingerup = function (evt) { // process all registered gestures var g = gestures.length; while (g--) { // does nothing for unknown finger gestures[g].fingerUp(evt); } // finger may be deleted if (fingers[evt.id]) { // update shared finger fingers[evt.id].x = evt.x; fingers[evt.id].y = evt.y; } }; // @@@ EO: fingerup @@@ // @@@ move all fingers on surface @@@ // emulate event chain for all gestures OCBNET.Gestures.fingermove = function (evt) { // get all gestures for finger var gestures = surface[evt.id]; // check if we have some gestures if (typeof gestures != 'undefined') { // process all registered gestures for(var g = 0, l = gestures.length; g < l; g++) { // call move for this finger gestures[g].fingerMove(evt); // exit loop if propagation stopped if (evt.isPropagationStopped()) break; } // update shared finger fingers[evt.id].x = evt.x; fingers[evt.id].y = evt.y; } }; // @@@ move all fingers on surface @@@ OCBNET.Gestures.fingersmove = function (evt) { // now process all finger ids for (var id in surface) { // create new fingermove event object var event = jQuery.Event('fingermove', { id : id, x : evt.x, y : evt.y, originalEvent: evt }); // call move for each finger OCBNET.Gestures.fingermove(event); } }; // @@@ EO move all fingers on surface @@@ // @@@ remove all fingers on surface @@@ OCBNET.Gestures.fingersup = function (evt) { // process all registered gestures var g = gestures.length; while (g--) { // now process all finger ids for (var id in gestures[g].finger) { // create new fingermove event object var event = jQuery.Event('fingerup', { id : id, x : evt.x, y : evt.y, originalEvent: evt }); // call move for each finger gestures[g].fingerUp(event); } } }; // @@@ EO remove all fingers on surface @@@ // @@@ Object Constructor @@@ OCBNET.Gestures.Finger = function (opt) { this.id = opt.id; this.x = opt.x; this.y = opt.y; }; // @@@ EO Object Constructor @@@ // @@@ Class declaration @@@ (function (prototype) { // create objects on prototype prototype.init = []; // @@@ method: fingerDown @@@ prototype.fingerDown = function (evt) { // for optimizer var gesture = this; // create a local finger for this gesture // you decide when to update properties var finger = new OCBNET.Gestures.Finger(evt); // create a new finger shared across all instances if (typeof fingers[evt.id] == 'undefined') { fingers[evt.id] = new OCBNET.Gestures.Finger(evt); } // create a new finger down event var event = new jQuery.Event('handstart', { dx: 0, dy: 0, finger: finger, gesture: gesture, originalEvent: evt }); // only call event on the given element // this means the event will not bubble jQuery(gesture.el).triggerHandler(event); // abort this hand gesture right now if (event.isDefaultPrevented()) return; // finger not yet known if (![call]this.hasFinger(finger.id)) { // increase counter gesture.fingers ++; // remember maximum fingers on gesture if (gesture.maximum < gesture.fingers) { gesture.maximum = gesture.fingers; } // add finger to ordered list gesture.ordered.push(finger.id); // attach finger to gesture gesture.finger[finger.id] = finger; // calculations gesture.start = { center : [call]gesture.getCenter(), rotation : [call]gesture.getRotation(), distance : [call]gesture.getDistance() } // offset position gesture.offset = { x : 0, y : 0 } // get the center from last move gesture.center = gesture.start.center; // offset rotation and distance gesture.rotation = 0; gesture.distance = 0; // create surface array if (!surface[finger.id]) { surface[finger.id] = []; } // push finger to surface surface[finger.id].push(gesture); // create and init a copy for move gesture.move = jQuery.extend({}, gesture.start); } // EO if not used } // @@@ EO method: fingerDown @@@ // @@@ private fn: fingerMove @@@ prototype.fingerMove = function(evt) { // init variables var id = evt.id, gesture = this; // check that finger is known if ([call]gesture.hasFinger(id)) { // get the actual finger instance var finger = [call]gesture.getFinger(id); // update position finger.x = evt.x; finger.y = evt.y; // calculate shared delta move var dx = fingers[id].x - evt.x, dy = fingers[id].y - evt.y; // calculations gesture.move = { center : [call]gesture.getCenter(), rotation : [call]gesture.getRotation(), distance : [call]gesture.getDistance() } // offset position gesture.offset = { x : gesture.move.center.x - gesture.start.center.x, y : gesture.move.center.y - gesture.start.center.y } // get the center from last move gesture.center = gesture.move.center; // offset rotation and distance gesture.rotation = gesture.move.rotation - gesture.start.rotation; gesture.distance = gesture.move.distance - gesture.start.distance; // detect swipes to dispatch by offsets var deltaX = Math.abs(gesture.offset.x), deltaY = Math.abs(gesture.offset.y); // handler options var options = { dx: dx, dy: dy, finger: finger, gesture: gesture, originalEvent: evt } // trigger hand move event // event does not bubbles up jQuery(gesture.el).triggerHandler ( new jQuery.Event('handmove', options) ); // check if there is a swipe movement if (typeof gesture.swipeSector == 'undefined') { // check if we have the minimum move/slop distance reached for a swipe if (this.config.decideOnFirst || Math.pow(this.config.swipeMinDistance, 2) < deltaX*deltaX + deltaY*deltaY) { // determine in which sector the swipe was // get the rotation of the swipe to match to sector var angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI; gesture.swipeSector = parseInt(angle / 90 * this.config.swipeSectors, 10); gesture.swipeSector = Math.min(gesture.swipeSector, this.config.swipeSectors - 1); } } // EO if no swipe yet // check if swipe has been started // always keep swipe in same sector if (typeof gesture.swipeSector != 'undefined') { // trigger hand swipe event // event does not bubbles up jQuery(gesture.el).triggerHandler ( new jQuery.Event('handswipe', options) ); } // EO if swiping // check multifinger gesture if (gesture.fingers > 1) { // trigger hand transform event // event does not bubbles up jQuery(gesture.el).triggerHandler ( new jQuery.Event('handtransform', options) ); } // EO if multifinger gesture } // EO if finger is known } // @@@ EO method: fingerMove @@@ // @@@ method: fingerUp @@@ prototype.fingerUp = function (evt) { // init variables var id = evt.id, gesture = this; // finger was used if ([call]gesture.hasFinger(id)) { // get the actual finger instance var finger = [call]gesture.getFinger(id); // update position finger.x = evt.x; finger.y = evt.y; // calculate shared delta move var dx = fingers[id].x - evt.x, dy = fingers[id].y - evt.y; // calculations gesture.stop = { center : [call]gesture.getCenter(), rotation : [call]gesture.getRotation(), distance : [call]gesture.getDistance() } // offset position gesture.offset = { x : gesture.stop.center.x - gesture.start.center.x, y : gesture.stop.center.y - gesture.start.center.y } // get the center from last move gesture.center = gesture.stop.center; // offset rotation and distance gesture.rotation = gesture.stop.rotation - gesture.start.rotation; gesture.distance = gesture.stop.distance - gesture.start.distance; // create a new finger down event var event = new jQuery.Event('handstop', { dx: dx, dy: dy, finger: finger, gesture: gesture }); // only call event on the given element // this means the event will not bubble jQuery(gesture.el).triggerHandler(event); // abort this hand gesture right now // if (finger.isDefaultPrevented()) return; // decrease fingers gesture.fingers --; // stop swipe movement delete gesture.offset; delete gesture.rotation; delete gesture.distance; delete gesture.swipeSector; // get index of finger in current gesture var idx = jQuery.inArray(finger.id, gesture.ordered) // remove finger from order array gesture.ordered.splice(idx, 1); // remove the finger from the gesture delete gesture.finger[id]; // remove from surface (find index and remove via splice) var idx = jQuery.inArray(gesture, surface[id]); if (idx != -1) surface[id].splice( idx, 1 ); // remove statucs if array is empty if (surface[id].length == 0) { delete fingers[id]; delete surface[id]; } } // EO if used }; // @@@ EO method: fingerUp @@@ // @@@ method: getCenter @@@ prototype.getCenter = function () { // create center object var center = { x : 0, y : 0 }; // sum up all attributes for (var id in this.finger) { // get finger from this gesture var finger = this.finger[id]; // sum up all finger positions center.x += finger.x; center.y += finger.y; } // EO each finger // normalize x/y value if (this.fingers) { center.x /= this.fingers; center.y /= this.fingers; } // return center return center; }; // @@@ EO method: getCenter @@@ // @@@ method: getRotation @@@ prototype.getRotation = function () { // need at least 2 fingers if (this.fingers < 2) return 0; // declare variables var x = 0, y = 0, c = 0; // process all fingers down for this gesture for (var i = 0, l = this.ordered.length; i < l; i++) { // get the first finger var i_id = this.ordered[i], i_finger = this.finger[i_id]; // process all other fingers for (var n = i + 1; n < l; n++) { // increase counter c ++; // get the second finger var n_id = this.ordered[n], n_finger = this.finger[n_id]; // get the distance on each axis x += (n_finger.x - i_finger.x); y += (n_finger.y - i_finger.y); } // EO process other fingers } // EO process all fingers // normalize values x /= c; y /= c; // return the calulcated rotation angle return Math.atan2(y, x) * 180 / Math.PI; }; // @@@ EO method: getRotation @@@ // @@@ method: getDistance @@@ prototype.getDistance = function () { // need at least 2 fingers if (this.fingers < 2) return 0; // declare variables var x = 0, y = 0, c = 0; // process all fingers down for this gesture for (var i = 0, l = this.ordered.length; i < l; i++) { // get the first finger var i_id = this.ordered[i], i_finger = this.finger[i_id]; // process all other fingers for (var n = i + 1; n < l; n++) { // increase counter c ++; // get the second finger var n_id = this.ordered[n], n_finger = this.finger[n_id]; // get the absolute distance on each axis x += Math.abs(n_finger.x - i_finger.x); y += Math.abs(n_finger.y - i_finger.y); } // EO process other fingers } // EO process all fingers // normalize values x /= c; y /= c; // calculate distance return Math.sqrt(x*x + y*y); }; // @@@ EO method: getDistance @@@ // @@@ method: hasFinger @@@ prototype.hasFinger = function (id) { // return if id is known return id in this.finger; } // @@@ EO method: hasFinger @@@ // @@@ method: hasFinger @@@ prototype.getFinger = function (id) { // return finger instance return this.finger[id]; } // @@@ EO method: hasFinger @@@ })(OCBNET.Gestures.prototype); // @@@ EO Class declaration @@@ // @@@ jQuery fn: gesture @@@ jQuery.fn.gesture = function (config) { // process all elements in collection jQuery(this).each(function (i, el) { // get the gesture data from element // only one gesture for each element var gesture = jQuery(el).data('gesture'); // check if element is not initialised if (typeof gesture == 'undefined') { // create a new gesture object // also binds start events to el gesture = new OCBNET.Gestures(el, config); // store the object on the element jQuery(el).data('gesture', gesture); } // EO if gesture not initialised // if gesture is initialised else { // assertion for config change if (gesture.fingers > 0) { // only allow initial config changes throw('fatal: live config change'); } // extend the gesture config object jQuery.extend(gesture.config, config, true); } // EO if gesture is initialised }); // EO each element // chainable return this; } // @@@ EO jQuery fn: gesture @@@})(jQuery);// EO private scope;/* Copyright (c) Marcel Greter 2012 - OCBNET Gestures 0.0.0 This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.*//* @@@@@@@@@@ STATIC CLASS @@@@@@@@@@ */// create private scope(function (jQuery){ // check for touch features if ( 'ontouchstart' in window ) return; // proper detection for ie10 on desktop (https://github.com/CreateJS/EaselJS/issues/273) if ( window.navigator['msPointerEnabled'] & window.navigator["msMaxTouchPoints"] > 0 ) return; // extend class (function(prototype) { // bind additional events for gestures prototype.init.push(function (el) { // create a closure var closure = this; // trap mousedown locally on each element jQuery(el).bind('mousedown', function (evt) { // get variables from event var el = evt.currentTarget, org = evt.originalEvent; // get the gesture for current element // it should be here, otherwise I don't know // why I would be registered on this element var gesture = jQuery(el).data('gesture'); // assertion for same object (play safe - dev) if (gesture !== closure) eval("alert('assertion')"); // create new finger down event object // you may use it to cancel event bubbeling var finger = new jQuery.Event('fingerdown', { type : 'mouse', id : evt.which, x : evt.screenX, y : evt.screenY, originalEvent : evt }); // pass on to gesture handler gesture.fingerDown(finger) }) }); // EO bind additional events for gestures })(OCBNET.Gestures.prototype); // EO extend class // trap mouseup globally, "trap" for all cases jQuery(document).bind('mouseup trapmouseup', function (evt) { // mouseup outside of viewport? // this is known to be very buggy! if ( evt.clientX < 0 || evt.clientY < 0 || evt.clientX > jQuery(window).width() || evt.clientY > jQuery(window).height() ) { // create new finger object var event = new jQuery.Event('fingersup', { type : 'mouse', x : evt.screenX, y : evt.screenY, originalEvent: evt }); // release all buttons at once OCBNET.Gestures.fingersup(event); } else { // create new finger object var event = new jQuery.Event('fingerup', { type : 'mouse', id : evt.which, x : evt.screenX, y : evt.screenY, originalEvent: evt }) // only release the specific button OCBNET.Gestures.fingerup(event); } }) // EO mouseup // trap mousemove globally, "trap" for all cases jQuery(document).bind('mousemove', function (evt) { // create new fingersmove event object var event = jQuery.Event('fingersmove', { type : 'mouse', x : evt.screenX, y : evt.screenY, originalEvent: evt }); // always move all fingers at once OCBNET.Gestures.fingersmove(event); }) // EO mousemove})(jQuery);// EO private scope;/* Copyright (c) Marcel Greter 2012 - OCBNET Gestures 0.0.0 This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.*//* @@@@@@@@@@ STATIC CLASS @@@@@@@@@@ */// create private scope(function (jQuery){ // check for touch features if ( ! ('ontouchstart' in window) ) return; // proper detection for ie10 on desktop (https://github.com/CreateJS/EaselJS/issues/273) if ( window.navigator['msPointerEnabled'] & window.navigator["msMaxTouchPoints"] > 0 ) return; // extend class (function(prototype) { // bind additional events for gestures prototype.init.push(function (el) { // create a closure var closure = this; // trap mousedown locally on each element jQuery(el).bind('touchstart', function (evt) { // get variables from event var el = evt.currentTarget, org = evt.originalEvent, touches = org.changedTouches || []; // get the gesture for current element // it should be here, otherwise I don't know // why I would be registered on this element var gesture = jQuery(el).data('gesture'); // assertion for same object (play safe - dev) if (gesture !== closure) eval("alert('assertion')"); // process all newly added fingers jQuery(touches).each(function (i, touch) { // create new finger down event object // you may use it to cancel event bubbeling var event = new jQuery.Event('fingerdown', { type : 'touch', x : touch.clientX || touch.screenX, y : touch.clientY || touch.screenY, id : touch.identifier, originalEvent : evt }); // pass on to gesture handler gesture.fingerDown(event) }); }) // trap mousedown locally on each element jQuery(el).bind('handswipe', function (evt) { // only support default configuration option if (evt.gesture.config.swipeSectors == 2) { // tested only on android so far (from experience this should work on ipad too) // chrome change the bevahior recently (only firing one touch move after it decided) if (evt.gesture.swipeSector === 0 & evt.gesture.config.native.panY) evt.preventDefault(); if (evt.gesture.swipeSector === 1 & evt.gesture.config.native.panX) evt.preventDefault(); } }); }); // EO bind additional events for gestures })(OCBNET.Gestures.prototype); // EO extend class // trap touchend globally, "trap" for all cases jQuery(document).bind('touchend touchcancel', function (evt) { // get variables from the event object var org = evt.originalEvent, touches = org.changedTouches || []; // process all newly added fingers jQuery(touches).each(function (i, touch) { // create new finger object var event = jQuery.Event('fingerup', { type : 'touch', x : touch.clientX || touch.screenX, y : touch.clientY || touch.screenY, id : touch.identifier, originalEvent: evt }); // only release the specific button OCBNET.Gestures.fingerup(event); }); }) // EO touchend // trap mousemove globally, "trap" for all cases // this will be called for every pointer that moved jQuery(document).bind('touchmove', function (evt) { // get variables from the event object var org = evt.originalEvent, touches = org.changedTouches || []; // process all newly added fingers jQuery(touches).each(function (i, touch) { // create new fingermove event object var event = jQuery.Event('fingermove', { type : 'touch', x : touch.clientX || touch.screenX, y : touch.clientY || touch.screenY, id : touch.identifier, originalEvent: evt }); // always move all fingers at once OCBNET.Gestures.fingermove(event); }); }) // EO MSPointerMove})(jQuery);// EO private scope;/* Copyright (c) Marcel Greter 2012 - OCBNET Gestures 0.0.0 This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.*//* @@@@@@@@@@ STATIC CLASS @@@@@@@@@@ */// create private scope(function (jQuery){ // proper detection for ie10 on desktop (https://github.com/CreateJS/EaselJS/issues/273) // this will also be true for ie11 and hopefully for all future IE generations (I dare you MS) if ( ! (window.navigator['msPointerEnabled'] & window.navigator["msMaxTouchPoints"] > 0) ) return; // event names may vary // ie 10 uses vendor prefix // keep the legacy code here var evt_name = { 'up' : 'MSPointerUp', 'move' : 'MSPointerMove', 'down' : 'MSPointerDown', 'cancel' : 'MSPointerCancel', // name for css attributes 'action' : 'ms-touch-action' }; // https://coderwall.com/p/mfreca // so feature detection is the way to go, the internet says // thank you IE for once again keeping things "interesting" if ( window.navigator['pointerEnabled'] & window.navigator["maxTouchPoints"] > 0 ) { // use new names evt_name = { 'up' : 'pointerup', 'move' : 'pointermove', 'down' : 'pointerdown', 'cancel' : 'pointercancel', // name for css attributes 'action' : 'touch-action' }; } // extend class (function(prototype) { // bind additional events for gestures prototype.init.push(function (el) { // create a closure var closure = this; // native actions var actions = []; // get object with info about which // actions should be handled by UA var action = this.config.native || {}; // push native features to array if (action.panY) actions.push('pan-y'); if (action.panX) actions.push('pan-x'); // add default value if we have no option yet if (actions.length == 0) actions.push('none'); // trap pointerdown locally on each element jQuery(el).bind(evt_name['down'], function (evt) { // get variables from event var el = evt.currentTarget, org = evt.originalEvent; // get the gesture for current element // it should be here, otherwise I don't know // why I would be registered on this element var gesture = jQuery(el).data('gesture'); // assertion for same object (play safe - dev) if (gesture !== closure) eval("alert('assertion')"); // create new finger down event object // you may use it to cancel event bubbeling var finger = new jQuery.Event('fingerdown', { type : 'pointer', x : org.pageX, y : org.pageY, id : org.pointerId, originalEvent : evt }); // pass on to gesture handler gesture.fingerDown(finger) }) // this can ie. cancel pointers on scroll // mostly we will only see pan-x/pan-y here .css(evt_name['action'], actions.join(' ')) }); // EO bind additional events for gestures })(OCBNET.Gestures.prototype); // EO extend class // use same handler for pointerup and pointercancel var evt_up = [evt_name['up'], evt_name['cancel']].join(' '); // trap pointerup globally, "trap" for all cases // canceled ie. if user decided to scroll not swipe jQuery(document).bind(evt_up, function (evt) { // get variables from the event object var org = evt.originalEvent; // create new finger object var event = new jQuery.Event('fingerup', { type : 'pointer', x : org.pageX, y : org.pageY, id : org.pointerId, originalEvent: evt }); // only release the specific button OCBNET.Gestures.fingerup(event); }) // EO MSPointerUp // trap pointermove globally, "trap" for all cases // this will be called for every pointer that moved jQuery(document).bind(evt_name['move'], function (evt) { // get variables from the event object var org = evt.originalEvent; // create new finger object var event = jQuery.Event('fingermove', { type : 'pointer', x : org.pageX, y : org.pageY, id : org.pointerId, originalEvent: evt }); // move just one finger at once OCBNET.Gestures.fingermove(event); }) // EO MSPointerMove})(jQuery);// EO private scope;/* Copyright (c) Marcel Greter 2010/2012 - rtp.ch - RTP jQuery Slider This is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt), either version 3 of the License, or (at your option) any later version.*/// START anonymous scope(function(jQuery){ 'use strict'; // declare our namespace if (!window.RTP) window.RTP = {}; /* @@@@@@@@@@ CONSTRUCTOR @@@@@@@@@@ */ RTP.Slider = function (el, options) { // create closure for // resize event handler var slider = this; // only init once if (slider.inited) { return; } else { slider.inited = true; } // create new config by extending with data array // data options take priority over instance options var conf = jQuery.extend(true, {}, options, jQuery(el).data()); // connect parent layout widget slider.layout = { parent: options.parent }; // @@@ private fn: extend @@@ function defaults (config) { // create new config slider.conf = {}; // add more (default) configuration options (deep extend) // preserves the already set configuration (just set default) return conf = jQuery.extend(true, slider.conf, config, conf); } // @@@ EO private fn: extend @@@ // add defaults [call]defaults({ // the panel alignment to the position align: 'center', // inherits from align alignPanelDim: false, alignPanelOpp: false, alignViewport: false, // vertical sliding is also supported vertical: false, // set float parameter for panels // will not be set if vertical is true setFloat: true, // enable endless carousel carousel: false, // the first slide to load after init // this can also be a callback function slideFirst: 0, // how many panels should be visible // mainly used for the layout sizers, but // also defines how many panels are cloned panelsVisible: 1, // frames per second to draw // defer all position updates // leave the UA some idle loops fps: 25, // synchronise with monitor // draw as soon as requested vsync: false, // we often want to have margin between // the slides, but still want to fill the // while viewport. Computation of this is // tricky, so I've added this static option. margin: 0, // how many panels should be cloned // if this is set to true, we will use // the panelsVisible option for this // set to false to disable cloning clonePanels: true, // in which direction should we clone // adds cloned panels before or after cloneAfter: true, cloneBefore: true, // define which axis of the panel is fixed // the other axis can be fluid by some ratio // this is possible by having an image inside // which spans to 100% in both directions // may gets overwritten by panelsByViewport sizer panelFixedAxis: conf.vertical ? 'opp' : 'dim', // initialize some structures // they can be used by plugins // localized texts text: {}, // templates fragments tmpl: { wrapper : '<div/>', viewport : '<div/>', container : '<div/>' }, // classes to assign klass: { next: 'rtp-slider-next', current: 'rtp-slider-current', previous: 'rtp-slider-previous', vertical: 'rtp-slider-vertical', horizontal: 'rtp-slider-horizontal', panel : 'rtp-slider-panel', wrapper: 'rtp-slider-wrapper', viewport : 'rtp-slider-viewport', container : 'rtp-slider-container' } }); // EO extend config // execute all config hooks // this will add more defaults slider.trigger('config', defaults); // assign shortcuts to access nested config jQuery(['text', 'tmpl', 'klass', 'selector']) .each(function() { slider[this] = conf[this]; }) // optimize for compiler var tmpl = slider.tmpl, klass = slider.klass, selector = slider.selector; // assertion for some options if (isNaN(conf.align)) { conf.align = 0.5; } if (isNaN(conf.panelsVisible)) { conf.panelsVisible = 1.0; } // current element is used as our container var container = slider.container = jQuery(el); // get all intial panels (slides) once at startup (after config) var slides = slider.slides = container.find('>.' + klass.panel); // don't init further if there is only a single slide if (conf.dontInitSingle & slides.length < 2) return; // put viewport around container var viewport = slider.viewport = container .wrapAll(tmpl.viewport).parent(); // put wrapper around viewport var wrapper = slider.wrapper = viewport .wrapAll(tmpl.wrapper).parent(); // move all attributes from container to viewport var attrs = el.attributes, idx = attrs.length; // process all attributes while (idx--) { // copy the attribute from container to viewport viewport.attr(attrs[idx].name, attrs[idx].value); // remove the attribute on the container container.removeAttr(attrs[idx].name); } // force the container to have no margin and padding container.css({ 'margin' : '0', 'padding' : '0' }); // add default class to all elements wrapper.addClass(klass.wrapper); viewport.addClass(klass.viewport); container.addClass(klass.container); // min and max index for slides slider.smin = slider.smax = 0; // mark wrapper indicating vertical/horizontal mode if (conf.vertical & klass.vertical) { slider.wrapper.addClass(klass.vertical); } if (!conf.vertical & klass.horizontal) { slider.wrapper.addClass(klass.horizontal); } // first slide to load may be a function slider.position = jQuery.isFunction(conf.slideFirst) ? conf.slideFirst.call(slider) : conf.slideFirst || 0; // @@@ private fn: resolve_align @@@ // this can be a number between -INF and +INF // or you can use "left", "center" or "right" function resolve_align (key, preset) { // get configured option var align = conf[key]; // check if align matches any of our strings if (new RegExp(/^[lt]/i).test(align)) align = 0.0; if (new RegExp(/^[cm]/i).test(align)) align = 0.5; if (new RegExp(/^[rb]/i).test(align)) align = 1.0; // now check if it's valid or use given preset if (isNaN(parseInt(align, 10))) align = preset; // maybe there was no preset given, check again if (isNaN(parseInt(align, 10))) align = 0.5; // assign and return the number return conf[key] = align; } // EO @@@ private fn: resolve_align @@@ // first resolve the shared value to inherit from var preset = [call]resolve_align('align', 0.5); // then resolve the specific align options [call]resolve_align('alignPanelDim', preset); [call]resolve_align('alignPanelOpp', preset); [call]resolve_align('alignViewport', preset); // fix the panel size from initial read var i = this.slides.length; while (i--) { // get jQuery object of this slide var slide = jQuery(this.slides[i]); // fix the size of the panel // TODO: make axis configurable if (conf.panelFixedAxis == 'dim') { slide.width(slide.width()); } else if (conf.panelFixedAxis == 'opp') { slide.height(slide.height()); } } // EO each slide // init array always // avoid checks in code slider.cloned = jQuery(); // create cloned panels if (conf.carousel & slides.length) { // get variables (resolve afterwards) var cloneAfter = conf.cloneAfter, cloneBefore = conf.cloneBefore, clonePanels = conf.clonePanels, // Clone as many panels needed to fill the viewport. // If sizer is false you can use this config option // to adjust how many panels you want to have cloned // In this mode the viewport might be much wider than // all panels inside. Todo: Maybe support this better. clonePanels = clonePanels === true ? Math.ceil(conf.panelsVisible) : clonePanels === false ? 0 : parseInt(clonePanels + 0.5); // distribute cloned panels after (right/bottom) cloneAfter = cloneAfter === true ? Math.ceil(clonePanels * (1 - conf.alignViewport)) : cloneAfter === false ? 0 : isNaN(cloneAfter) ? 0 : cloneAfter; // distribute cloned panels before (left/top) cloneBefore = cloneBefore === true ? Math.ceil(clonePanels * (0 + conf.alignViewport)) : cloneBefore === false ? 0 : isNaN(cloneBefore) ? 0 : cloneBefore; // accumulate all cloned panels // we may clone each slide more than once var after = jQuery([]), before = jQuery([]); // I will clone as many as you wish while (cloneBefore > slides.length) { // remove a full set of slides cloneBefore -= slides.length; // clone and add another full set jQuery.merge(before, slides.clone()); } // clone panels before if (cloneBefore > 0) { // clone panels from end to extend the container before = jQuery.merge(slides.slice(- cloneBefore).clone(), before); } // I will clone as many as you wish while (cloneAfter > slides.length) { // remove a full set of slides cloneAfter -= slides.length; // clone and add another full set jQuery.merge(after, slides.clone()); } // clone panels after if (cloneAfter > 0) { // clone panels from begining to extend the container jQuery.merge(after, slides.slice(0, cloneAfter).clone()); } // append the cloned panels to the container and set class after.appendTo(slider.container).addClass('cloned'); before.prependTo(slider.container).addClass('cloned'); // increase min and max slide index slider.smax += after.length; slider.smax += before.length; slider.smin += before.length; // merge all cloned panels jQuery.merge(slider.cloned, before); jQuery.merge(slider.cloned, after) // store the cloned panels slider.before = before; slider.after = after; } // EO if conf.carousel // execute all init hooks slider.trigger('init'); // lookup panels - equals slides if carousel == false slider.panels = container.find('>.' + klass.panel); // to which side should we float the panels / container // we normally always need to float the panels, also // for vertical stacking (just clear the float again) var floating = conf.offsetReverse ? 'right' : 'left'; // for experimental carousel 3d module var overflow = conf.carousel3d ? 'visible' : 'hidden'; // setup css for every panel var css = slider.conf.setFloat ? { 'float' : floating } : {}; // set some css to fix some issues // if you do not want this you have // to remove these styles on ready event slider.panels.css(css) // add viewport to collection .add(slider.viewport) // set on viewport and panels .css({ 'overflow' : overflow }) // add container to collection .add(slider.container) // set on container, viewport and panels .css({ 'position' : 'relative', 'zoom' : 1 }) // setup floats for the container if (!conf.vertical) { // get the tagname for panels var tag = slider.panels[0].tagName; // define html code for float clearer var clearer_div = jQuery('<DIV/>'); var clearer_tag = jQuery('<' + tag + '/>'); // define the css styles for the clearer tags var clearer_styles = { width: 0, height: 0, clear: 'both' }; // we either float the container right or left slider.container.css('float', floating) // insert a float clearing div after the container .append(clearer_tag.css(clearer_styles)) .after(clearer_div.css(clearer_styles)); } // trigger loading hook slider.trigger('loading'); // defer until all images are loaded // otherwise we will not get valid info // about resource dimensions like images jQuery('IMG', viewport) // wait loading images .imagesLoaded() // execute when ready .done(function() { // trigger ready hook slider.trigger('ready'); }); }; /* @@@@@@@@@@ CONSTRUCTOR @@@@@@@@@@ */ /* @@@@@@@@@@ RTP CLASS @@@@@@@@@@ */ (function (prototype, jQuery) { // @@@ method: panel2panel @@@ prototype.panel2panel = function(panel) { // adjust for carousel if (this.conf.carousel) { // get number of slides var count = this.slides.length; // protect from endless loop if (count <= 0) return 0; // adjust panels into the valid range while (panel > this.smax) panel -= count; while (panel < this.smin) panel += count; } else { // adjust panels to outer ranges if (panel > this.smax) panel = this.smax; if (panel < this.smin) panel = this.smin; } // return the in range panel return panel; } // @@@ EO method: panel2panel @@@ // @@@ method: slide2panel @@@ prototype.slide2panel = function(slide) { return [call]this.panel2panel(slide + this.smin); } // @@@ EO method: slide2panel @@@ // @@@ method: panel2slide @@@ prototype.panel2slide = function (panel) { return [call]this.panel2panel(panel) - this.smin; } // @@@ EO method: panel2slide @@@ // @@@ method: panel2slide @@@ prototype.slide2slide = function (slide) { return [call]this.panel2slide([call]this.slide2panel(slide)); } // @@@ EO method: panel2slide @@@ // @@@ method: update @@@ prototype.update = function (option) { // trigger updating event // use to adjust stuff if needed // ie. used by nav dots to adjust this.trigger('updating', option); // extend our config with new options jQuery.extend(true, this.conf, option); // trigger position change event this.trigger('layout'); // call global layout OCBNET.Layout(true); } // @@@ EO method: update @@@ // EO extend class prototype })(RTP.Slider.prototype, jQuery); /* @@@@@@@@@@ RTP CLASS @@@@@@@@@@ */ /* @@@@@@@@@@ JQUERY CONNECTOR @@@@@@@@@@ */ jQuery.fn.rtpSlider = function(conf) { return this.each(function(){ // check if already initialized if (typeof jQuery(this).data('rtp-slider') == 'undefined') { jQuery(this).data('rtp-slider', new RTP.Slider(this, conf)); } // else { throw('you tried to init rtp-slider twice') } }); } /* @@@@@@@@@@ JQUERY CONNECTOR @@@@@@@@@@ */// END anonymous scope})(jQuery);;/* Copyright (c) Marcel Greter 2012 - rtp.ch - RTP jQuery Slider Core Hook Functions This is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt), either version 3 of the License, or (at your option) any later version.*/// extend class prototype(function (prototype, jQuery){ 'use strict'; // create the hooks hash on prototype // this is shared across all instances prototype.hooks = {}; // @@@ method: trigger @@@ // execute both custom and static // hooks for this slider instance prototype.trigger = function() { // get a copy of all arguments and shift off type var args = [].slice.call(arguments), type = args.shift(); // first call our method by that name if it seems to be a function if (this[type] & this[type].apply) this[type].apply(this, args); // declare an array with all hooks in order var hooks = [this.hooks, this.conf.hooks]; // process each hooks array (object/config) for (var i = 0; i < hooks.length; i++) { // check if hook type is available if (hooks[i] & hooks[i][type]) { // get into local variable var hook = hooks[i][type]; // process single hooks function if (jQuery.isFunction(hook)) { return hook.apply(this, args); } // process all hooks in the array for(var n = 0; n < hook.length; n++) { hook[n].apply(this, args); } } // EO if hook type exists } // EO each hook array } // @@@ EO method: trigger @@@ // @@@ private fn: ordersort @@@ function ordersort(a, b) { // sort numerical by order return a.order - b.order; } // @@@ EO private fn: ordersort @@@ // @@@ private fn: addHook @@@ function addHook (hooks, type, cb, order) { // default order for callback if (isNaN(cb.order)) cb.order = 0; // check if given order is valid if (!isNaN(order)) cb.order = order; // make sure the hook type is available // we allow any type of hook to be registered if (!hooks[type]) hooks[type] = []; // register plugin callback hooks[type].push(cb); // now sort the hooks by their orders hooks[type] = hooks[type].sort(ordersort) } // @@@ EO private fn: addHook @@@ // @@@ method: plugin @@@ // insert callback into static hooks // these callbacks are shared accross all instances // we only allow this fuction to be called statically // for this we check if the conf object is not defined yet // example: RTP.Slider.plugin('type', function() {}); prototype.plugin = function(type, cb, order) { // declare local variable var hooks = this.hooks; // if this happens you propably wanted to // register a custom and not a static hook if (typeof this.conf != 'undefined') { // throw an error message to the console // this is a coding error an not a config error throw('plugin can only be called on object prototype'); } // add through addHook [call]addHook (hooks, type, cb, order); } // @@@ EO method: plugin @@@ // @@@ method: listen @@@ // insert callback into our hooks (on config) // these callbacks are local to a slider instance prototype.listen = function (type, cb, order) { // declare local variable var ready = this.isReady, hooks = this.conf.hooks; // if this happens you propably wanted to // register a static and not a custom hook if (typeof this.conf == 'undefined') { // throw an error message to the console // this is a coding error an not a config error throw('listen can only be called on real instance'); } // check some status variables to dispatch to late event bindings if (ready !== null & type == 'init') return cb.call(this); if (ready === true & type == 'ready') return cb.call(this); // add through addHook [call]addHook (hooks, type, cb, order); } // @@@ EO method: listen @@@ // @@@ plugin: config @@@ prototype.plugin('config', function() { // init ready state this.isReady = null; // create defered object // remember timeout ids this.defered = {}; // create hook object if (!this.conf.hooks) { this.conf.hooks = {}; } }, - 999999); // @@@ EO plugin: config @@@ // @@@ plugin: init @@@ prototype.plugin('init', function() { // prepare ready state this.isReady = false; }, + 999999); // @@@ EO plugin: init @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function() { // now set ready state this.isReady = true; }, - 999999); // @@@ EO plugin: ready @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function() { // call start hook defered this.trigger('start'); }, + 999999); // @@@ EO plugin: ready @@@ // @@@ method: defer @@@ // execute both custom and static // hooks for this slider instance prototype.defer = function() { // create closure var self = this; // get a copy of all arguments and get the type var args = [].slice.call(arguments), // get the type from first argument // both options may be overwritten below type = args[0], delay = 0; // implement option to pass delay // you have to pass it as the first argument if (!isNaN(args[0])) { // shift away delay from arguments // get type from now first argument delay = args.shift(); type = args[0]; } // EO if delay is given // this type is already registered // to be called on next idle loop if (this.defered[type]) return; // create callback function var fn = function() { // reset first so we can register // this type again to be called self.defered[type] = false; // now trigger the event type [call]self.trigger.apply(self, args) } // create the defered call via timeout with given delay this.defered[type] = [call]OCBNET.Layout.defer(fn, delay); } // @@@ EO method: defer @@@ // @@@ method: undefer @@@ // reset waiting defered event prototype.undefer = function(type) { // clear the registered timeout [call]OCBNET.Layout.undefer(this.defered[type]); // reset so we can register again this.defered[type] = false; } // @@@ EO method: undefer @@@// EO extend class prototype; 'use strict'; // these method are not available to panels as // we have to make sure that cloned panels have // exactly the same size as the original panel // set the outer dimension of the slide panel // @@@ method: setSlideDim @@@ prototype.setSlideDim = function (slide, outerdim) { [call]this.setSlideSize(slide, outerdim, 0); } // @@@ EO method: setSlideDim @@@ // @@@ method: setSlideOpp @@@ prototype.setSlideOpp = function (slide, outerdim) { [call]this.setSlideSize(slide, outerdim, 1); } // @@@ EO method: setSlideOpp @@@ // @@@ method: setSlideSize @@@ prototype.setSlideSize = function (slide, outerdim, invert) { // declare loop variables var outer = this.pd[invert], inner = this.ps[invert], layout = this.pl[invert], border = this.pb[invert], margin = this.pm[invert], padding = this.pp[invert]; // normalize the input variable slide = this.slide2slide(slide); // get array with all panels for slide // contains only indexes and not objects var panels = this.slidepanels[slide]; // process original and cloned panels for slide var i = panels.length; while (i--) { // get the index from slidepanels and panel var p = panels[i], panel = this.panels[p]; // get sizing difference (is normalized to content box) var boxdiff = margin[p][2] + border[p][2] + padding[p][2]; // we cannot have a negative outer size if (outerdim < boxdiff) outerdim = boxdiff; // update inner dimension of panel var innerdim = outerdim - boxdiff; // update outer dimension of panel this.pd[invert][p] = outerdim; // update inner dimension of panel this.ps[invert][p] = innerdim; // adjust for box sizing layout // if (layout[i] == 'content-box') // { innerdim += padding[i][2]; } // else if (layout[i] == 'border-box') // { innerdim += padding[i][2] + border[i][2]; } // update the panel size in dom if (this.conf.vertical ^ invert) { jQuery(panel).height(innerdim); } else { jQuery(panel).width(innerdim); } } // EO each panel } // @@@ EO method: setSlideSize @@@ // @@@ method: getPanelsBySlide @@@ // slidepanel does only store indexes // return the actual panel jquery nodes prototype.getPanelsBySlide = function (slide) { // parse into integer slide = parseInt(slide + 0.5, 10); // normalize the input variable slide = this.slide2slide(slide); // get array copy with all panels for slide var panels = this.slidepanels[slide].slice(); // get the actual panel dom nodes var i = panels.length; while (i--) { panels[i] = this.panels[panels[i]]; } // return collection return jQuery(panels); } // @@@ EO method: getPanelsBySlide @@@ // @@@ plugin: ready @@@ prototype.plugin('loading', function () { // initialize slidepanels this.slidepanels = []; // get slides length this.slen = this.slides.length; // max index for real slider panels (not cloned ones) this.smax = this.smin + this.slen - 1; // process all panels to create slide index for(var i = 0; i < this.panels.length; i ++) { // normalize from panel to slide var slide = this.panel2slide(i); // generate slidepanels array if (!this.slidepanels[slide]) { this.slidepanels[slide] = [i]; } else { this.slidepanels[slide].push(i); } } // EO foreach panel }, - 99999); // @@@ EO plugin: ready @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ // attach and create status arrays // store all panels style definitions prototype.plugin('config', function () { // sizes this.ps = [[], []]; // margins this.pm = [[], []]; // borders this.pb = [[], []]; // paddings this.pp = [[], []]; // dimensions this.pd = [[], []]; // layout this.pl = []; }) // @@@ EO plugin: config @@@ // @@@ private fn: getBoxSizeCssStr @@@ function getBoxSizeCssStr (invert) { // get the reverse option from config var reverse = this.conf.offsetReverse; // return the strings according to options return this.conf.vertical ^ invert ? (reverse ? ['Bottom', 'Top'] : ['Top', 'Bottom']) : (reverse ? ['Right', 'Left'] : ['Left', 'Right']); } // @@@ EO private fn: getBoxSizeCssStr @@@ // @@@ privat fn: getPanelBoxCss @@@ function getPanelBoxCss (panel, prefix, suffix, invert) { // get the box size strings (ie left/right) var css = [call]getBoxSizeCssStr.call(this, invert); // get the left/top and right/bottom value for this css box var lt = parseFloat([call]panel.css(prefix + css[0] + suffix), 10); var rb = parseFloat([call]panel.css(prefix + css[1] + suffix), 10); // some browser may return auto when the actual value is zero (ie8) if(isNaN(lt)) lt = 0; if(isNaN(rb)) rb = 0; // return an array with values and sum return [lt, rb, lt + rb]; } // @@@ EO privat fn: getPanelBoxCss @@@ // @@@ privat fn: getPanelMargin @@@ function getPanelMargin (panel, invert) { // call through getPanelCss function return [call]getPanelBoxCss.call(this, panel, 'margin', '', invert); } // @@@ EO privat fn: getPanelMargin @@@ // @@@ privat fn: getPanelBorder @@@ function getPanelBorder (panel, invert) { // call through getPanelCss function return [call]getPanelBoxCss.call(this, panel, 'border', 'Width', invert); } // @@@ EO privat fn: getPanelBorder @@@ // @@@ privat fn: getPanelPadding @@@ function getPanelPadding (panel, invert) { // call through getPanelCss function return [call]getPanelBoxCss.call(this, panel, 'padding', '', invert); } // @@@ EO privat fn: getPanelPadding @@@ // @@@ method: getPanelSize @@@ prototype.getPanelSize = function (panel, invert) { // access panel only once (get id into range) panel = this.panels.eq(this.panel2panel(panel)); // return the panel axis size return this.conf.vertical ^ invert ? panel.height() : panel.width(); // return the accurate panel size // return this.conf.vertical ^ invert // ? panel.get(0).clientHeight ? panel.get(0).clientHeight : panel.height() // : panel.get(0).clientWidth ? panel.get(0).clientWidth : panel.width(); } // @@@ EO method: getPanelSize @@@ // @@@ method: setPanelSize @@@ prototype.setPanelSize = function (panel, value, invert) { // access panel only once (get id into range) panel = this.panels.eq(this.panel2panel(panel)); // return the panel axis size return this.conf.vertical ^ invert ? panel.height(value) : panel.width(value); } // @@@ EO method: setPanelSize @@@ // @@@ private fn: readPanelsSize @@@ function readPanelsSize (invert) { // declare loop variables var size, outer = this.pd[invert], inner = this.ps[invert], layout = this.pl[invert], border = this.pb[invert], margin = this.pm[invert], padding = this.pp[invert]; // reset size and dim array inner.length = outer.length = 0; // collect size and margin for all panels var i = this.panels.length; while (i--) { // get actual panel size on drag axis inner[i] = size = [call]this.getPanelSize(i, invert); // add padding, border and margin to size for final dimension outer[i] = size + padding[i][2] + border[i][2] + margin[i][2]; // adjust for panel box sizing // this may not work with all jquery versions // once jquery starts to fully support this itself // if (layout[i] == 'padding-box') // { inner[i] += padding[i][2]; } // else if (layout[i] == 'border-box') // { inner[i] += padding[i][2] + border[i][2]; } } // EO foreach panel } // @@@ EO private fn: readPanelsSize @@@ // @@@ private fn: readPanelsStyles @@@ function readPanelsStyles (invert) { // store box-sizing this.pl[invert] = []; // store margin this.pm[invert] = []; // store border this.pb[invert] = []; // store padding this.pp[invert] = []; // collect size and margin for all panels var i = this.panels.length; while (i--) { // access panel only once (get id into range) var panel = this.panels.eq(this.panel2panel(i)); // get box sizing to adjust some stuff later this.pl[invert][i] = [call]panel.css('box-sizing'); // get panel margin for both sides (and a sum of them) this.pm[invert][i] = [call]getPanelMargin.call(this, panel, invert); this.pb[invert][i] = [call]getPanelBorder.call(this, panel, invert); this.pp[invert][i] = [call]getPanelPadding.call(this, panel, invert); } // EO foreach panel } // @@@ EO private fn: readPanelsStyles @@@ // @@@ method: updatePanelsDim @@@ prototype.updatePanelsDim = function() { // get sizes for drag axis [call]readPanelsSize.call(this, 0); // trigger hook for updated panels this.trigger('updatedPanelsDim'); }; // @@@ EO method: updatePanelsDim @@@ // @@@ method: updatePanelsDim @@@ prototype.updatePanelsOpp = function() { // get sizes for scroll axis [call]readPanelsSize.call(this, 1); // trigger hook for updated panels this.trigger('updatedPanelsOpp'); }; // @@@ EO method: updatePanelsOpp @@@ // @@@ plugin: updatedPanelsDim @@@ // the pd (panel dimension) has been updated // recalculate the complete panel offset array prototype.plugin('updatedPanelsDim', function() { // experimental feature if (this.conf.carousel3d) { // get local variable var dimensions = this.pd[0]; // calculate offset for each panel var offset = 0; this.offset = [0]; // collect size and margin for all panels for(var i = 0; i < dimensions.length; i++) { // sum up and store current offset this.offset.push(offset += dimensions[i]); } // EO foreach panel } // hardcore calculation by getting the real offsets // this should lead to perfect offset positions else { // get local variable var dimensions = this.pd[0]; // get the vertical indicator for arrays var vertical = this.conf.vertical ? 1 : 0; // calculate offset for each panel var offset = 0; this.offset = []; // start with the first panel's offset var offset = this.panels.eq(0).offset(); // get the start offset for the correct direction var start = vertical ? offset.top : offset.left; // adjust start offset for the margin start -= this.pm[vertical][0][0]; // collect size and margin for all panels for(var i = 0; i < dimensions.length; i++) { // get the offset value for this panel offset = this.panels.eq(i).offset(); // get the offset for the correct direction offset = vertical ? offset.top : offset.left; // calculate the precise offset for this panel offset = parseFloat(offset) - start - this.pm[vertical][i][0]; // sum up and store current offset this.offset.push(offset); } // EO foreach panel // have at least one panel if (this.panels.length) { // add last dimension to indicate the whole length this.offset.push(parseFloat(offset) + this.pd[0][i-1]) } } }, + 99); // @@@ plugin: updatedPanelsDim @@@ // @@@ plugin: loading @@@ prototype.plugin('loading', function () { // read styles for both axes [call]readPanelsStyles.call(this, 0); [call]readPanelsStyles.call(this, 1); }, - 99); // @@@ EO plugin: loading @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function () { // read the dimensions // once before on ready [call]this.updatePanelsDim(); [call]this.updatePanelsOpp(); }, - 99); // @@@ EO plugin: ready @@@ // @@@ method: readPanelsDim @@@ prototype.readPanelsDim = function () { // check if we are allowed to read from ua if (this.conf.sizerDim == 'panelsByViewport') eval('debugger'); // get sizes for drag axis [call]readPanelsSize.call(this, 0); } // @@@ EO method: readPanelsDim @@@ // @@@ method: readPanelsOpp @@@ prototype.readPanelsOpp = function () { // check if we are allowed to read from ua if (this.conf.sizerOpp == 'panelsByViewport') eval('debugger'); // get sizes for scroll axis [call]readPanelsSize.call(this, 1); } // @@@ EO method: readPanelsOpp @@@ // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // read viewport so we can use it to layout panels if (this.conf.sizerDim == 'viewportByPanels') [call]this.readPanelsDim(); if (this.conf.sizerOpp == 'viewportByPanels') [call]this.readPanelsOpp(); }, -9999); // @@@ EO plugin: changedViewport @@@ // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // read viewport opp after adjustment if (this.conf.sizerDim == 'none') [call]this.readPanelsDim(); if (this.conf.sizerOpp == 'none') [call]this.readPanelsOpp(); }, 9999); // @@@ EO plugin: changedViewport @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // link wrapper dimension to viewport linkWrapperToViewportDim: true, // link wrapper opposition to viewport linkWrapperToViewportOpp: false }); }); // @@@ EO plugin: config @@@ // @@@ plugin: init @@@ prototype.plugin('init', function () { // closure object var slider = this; // create closure function function changedViewport (evt, widget) { // trigger adjust viewport hook // integrates ocbnet layout manager slider.trigger('adjustViewport'); // do not propagate any further // we may emit another event if needed evt.stopPropagation(); } // event is emmited on wrapper, not on viewport // otherwise we would handle our own event again slider.viewport.bind('changedViewport', changedViewport) }); // @@@ EO plugin: init @@@ // @@@ method: getViewportOffset @@@ prototype.getViewportOffset = function () { // get the viewport offset var offset = this.viewport.offset(); // normalize drag and scroll axis return this.conf.vertical ? { x : offset.top, y : offset.left } : { x : offset.left, y : offset.top }; } // @@@ EO method: getViewportOffset @@@ // @@@ private fn: setViewportSize @@@ // this may not work as other css might overrule us // the implementer has to make sure this does not happen function setViewportSize (value, invert) { // get local variable var conf = this.conf, wrapper = this.wrapper, viewport = this.viewport; // set the height if (conf.vertical ^ invert) { viewport.height(value); if (conf.linkWrapperToViewportOpp) { wrapper.height(viewport.outerHeight(true)); } } // set the width else { viewport.width(value); if (conf.linkWrapperToViewportDim) { wrapper.width(viewport.outerWidth(true)); } } } // @@@ EO private fn: setViewportSize @@@ // @@@ method: updateViewportDim @@@ prototype.updateViewportDim = function (value) { // development assertion if (isNaN(value)) eval('debugger'); // check if we are allowed to read from ua // this should not happen, remove when use case emerges if (this.conf.sizerDim != 'viewportByPanels') eval('debugger'); // does the value really change if (this.vp_x == value) return; // assign given viewport dimension [call]setViewportSize.call(this, value, 0); // remember old value to pass to hook var before = this.vp_x; this.vp_x = value; // now trigger the updatedViewportDim hook this.trigger('updatedViewportDim', value, before); // issue an event for any outside listeners this.wrapper.trigger('changedViewport', this); } // @@@ EO method: updateViewportDim @@@ // @@@ method: updateViewportOpp @@@ prototype.updateViewportOpp = function (value) { // development assertion if (isNaN(value)) eval('debugger'); // check if we are allowed to read from ua // this should not happen, remove when use case emerges if (this.conf.sizerOpp != 'viewportByPanels') eval('debugger'); // does the value really change if (this.vp_y == value) return; // assign given viewport dimension [call]setViewportSize.call(this, value, 1); // remember old value to pass to hook var before = this.vp_y; this.vp_y = value; // now trigger the updatedViewportOpp hook this.trigger('updatedViewportOpp', value, before); // issue an event for any outside listeners this.wrapper.trigger('changedViewport', this); } // @@@ EO method: updateViewportOpp @@@ // @@@ private fn: getViewportSize @@@ function getViewportSize (invert) { // get local variable var viewport = this.viewport; // return the viewport axis size return this.conf.vertical ^ invert ? viewport.height() : viewport.width(); } // @@@ EO private fn: getViewportSize @@@ // @@@ method: getViewportDim @@@ prototype.getViewportDim = function () { return [call]getViewportSize.call(this, 0); } // @@@ EO method: getViewportDim @@@ // @@@ method: getViewportOpp @@@ prototype.getViewportOpp = function () { return [call]getViewportSize.call(this, 1); } // @@@ EO method: getViewportOpp @@@ // @@@ method: readViewportDim @@@ prototype.readViewportDim = function () { // check if we are allowed to read from ua if (this.conf.sizerDim == 'viewportByPanels') eval('debugger'); // store the current viewport dimension this.vp_x = [call]getViewportSize.call(this, 0); } // @@@ EO method: readViewportDim @@@ // @@@ method: readViewportOpp @@@ prototype.readViewportOpp = function () { // check if we are allowed to read from ua if (this.conf.sizerOpp == 'viewportByPanels') eval('debugger'); // store the current viewport opposition this.vp_y = [call]getViewportSize.call(this, 1); } // @@@ EO method: readViewportOpp @@@ // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // read viewport so we can use it to layout panels if (this.conf.sizerDim == 'panelsByViewport') [call]this.readViewportDim(); if (this.conf.sizerOpp == 'panelsByViewport') [call]this.readViewportOpp(); }, -9999); // @@@ EO plugin: changedViewport @@@ // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // read viewport after everything else is done if (this.conf.sizerDim == 'none') [call]this.readViewportDim(); if (this.conf.sizerOpp == 'none') [call]this.readViewportOpp(); }, 9999); // @@@ EO plugin: changedViewport @@@ // @@@ plugin: updatedPanelsOpp @@@ prototype.plugin('updatedPanelsOpp', function () { // read viewport after panels have changed if (this.conf.sizerOpp == 'none') [call]this.readViewportOpp(); }) // @@@ EO plugin: updatedPanelsOpp @@@ // @@@ plugin: updatedPanelsDim @@@ prototype.plugin('updatedPanelsDim', function () { // read viewport after panels have changed if (this.conf.sizerDim == 'none') [call]this.readViewportDim(); }) // @@@ EO plugin: updatedPanelsDim @@@// EO extend class prototype; 'use strict'; // @@@ private fn: getSizeCssStr @@@ function getSizeCssStr (invert) { return this.conf.vertical ^ invert ? 'height' : 'width'; } // @@@ EO private fn: getSizeCssStr @@@ // @@@ private fn: getOffsetCssStr @@@ function getOffsetCssStr (invert) { // get the reverse option from config var reverse = this.conf.offsetReverse; // return the string according to options return this.conf.vertical ^ invert ? (reverse ? 'marginBottom' : 'marginTop') : (reverse ? 'marginRight' : 'marginLeft'); } // @@@ EO private fn: getOffsetCssStr @@@ // @@@ method: getContainerOffset @@@ prototype.getContainerOffset = function(invert) { // return a float number from the container offset return - (parseFloat([call]this.container.css([call]getOffsetCssStr.call(this, invert)), 10) || 0) } // @@@ EO method: getContainerOffset @@@ // @@@ method: setContainerOffset @@@ prototype.setContainerOffset = function(offset, invert) { /* Tests have shown that the clamping is not needed here! So this has been disabled on purpose for performance! Keep the code anyway, as it might become needed again! // get the left and right position // also calculate size of all slides var conf = this.conf align = conf.align * conf.vp_x, left = this.offset[this.smin] + align, right = this.offset[this.smax + 1] + align, size = right - left; // shift into range when in carousel // protect from endless loop condition if (conf.carousel & size > 0) { // shift into prefered and best visible area // this may go wrong if floated to the right? while (offset < left) { offset += size; } while (right <= offset) { offset -= size; } } // EO if conf.carousel // allow offsets outside the valid range // if (offset < left) { offset = left; } // if (right < offset) { offset = right; } */ // only set offset to full integers // avoids some strange visual bugs offset = parseInt(offset + 0.5); // set the offset position of the container to the viewport [call]this.container.css([call]getOffsetCssStr.call(this, invert), - offset); // update internal variable // needed to calc visibilities this.ct_off = offset; } // @@@ EO method: setContainerOffset @@@ // @@@ method: readContainerOffset @@@ prototype.readContainerOffset = function () { // update the container offset this.ct_off = [call]this.getContainerOffset(0); }; // @@@ EO method: readContainerOffset @@@ // @@@ method: checkContainerOffset @@@ // get container offset from browser // check if offset value has changed // trigger changedContainerOffset hook prototype.checkContainerOffset = function() { // get the current container offset var current = [call]this.getContainerOffset(0); // check if dimension change if (this.ct_off !== current) { // store previous value and assign new value var previous = this.ct_off; this.ct_off = current; // now trigger the changedContainerOffset hook this.trigger('changedContainerOffset', current, previous); } // EO if value changed } // @@@ EO method: checkContainerOffset @@@ // @@@ plugin: updatedPanelsDim @@@ prototype.plugin('updatedPanelsDim', function () { // in vertical mode the container always // has the panels correctly layed out if (this.conf.carousel3d) return; if (this.conf.vertical) return; // sum up the dimensions for the container // calculate it so we can later get the accurate // pixel offset for the positioning from the ua // the panels hook for updatedPanelsDim runs later var dim = 0, i = this.panels.length; while (i--) { dim += this.pd[0][i]; } // set the container width/height to the calculated value to contain all panels // there is no getter or setter method for this particular container attribute // we really only need to adjust this dimension if the panel dimensions have changed [call]this.container.css([call]getSizeCssStr.call(this), Math.ceil(dim) + 'px') }, - 9999); // @@@ EO plugin: updatedPanelsDim @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function() { // check container offset [call]this.checkContainerOffset(); }, - 99); // @@@ EO plugin: ready @@@// EO extend class prototype; 'use strict'; // @@@ private fn: updateSlideExposure @@@ function updateSlideExposure() { // get values from the current internal status var position = this.slide2slide(this.position), visible = this.conf.panelsVisible || 1; // declare local variables var conf = this.conf, alignPanelDim = conf.alignPanelDim, alignViewport = conf.alignViewport, panelsVisible = conf.panelsVisible; // only in non-carousel mode if (!conf.carousel) { // try to show as many panels possible if (conf.fillViewport) { // calculate the left and right space to be filled var fill_left = panelsVisible * alignViewport - alignPanelDim, fill_right = -1 * fill_left + panelsVisible - 1; // adjust panel position to make those // panels "virtually" visible / exposed if (position < this.smin + fill_left) { position = this.smin + fill_left; } if (position > this.smax - fill_right) { position = this.smax - fill_right; } } // EO if conf.fillViewport // shrink the viewport on both ends else if (conf.shrinkViewport) { // make sure we only show one slide at the end if (position > this.smax + 1 - this.smin - panelsVisible) { panelsVisible = this.smax + 1 - position; } // make sure we only show one slide at the start else if (position < this.smin - 1 + panelsVisible) { panelsVisible = this.smin + 1 + position; } } // EO if conf.shrinkViewport } // EO if not conf.carousel // adjust the panel position for the viewport and panel alignment position += alignPanelDim - alignViewport * panelsVisible; // declare local variables var exposure = [], left = position, i_left = Math.floor(left), right = position + panelsVisible, i_right = Math.ceil(right); // initialize exposure array var i = this.slides.length; while (i--) { exposure[i] = 0; } // process panels in visible range for (i = i_left; i < i_right; i++) { // declare local variables var out_left = left - i, in_right = right - i, slide = this.slide2slide(i); // add visibility if (in_right < 1) { exposure[slide] += in_right; } else { exposure[slide] += 1; } // remove visibility if (out_left > 0) { exposure[slide] -= out_left; } } // store state before calling the changed hock // reset the status first, but pass before status var se = this.se; this.se = exposure; // execute the changedExposure hook for slides this.trigger('changedExposure', exposure, se); } // @@@ EO private fn: updateSlideExposure @@@ // @@@ fn: updateSlideVisibility @@@ function updateSlideVisibility () { // protect beeing called too early if (this.isReady !== true) return; // get values from the current internal status var panel = this.ct_off; // development assertion if (isNaN(this.vp_x)) { eval('debugger'); } // development assertion if (isNaN(this.ct_off)) { eval('debugger'); } // declare local variables var visible, panel_left = 0, visibility = [], smin = this.smin, widths = this.pd[0], i = this.slides.length, view_left = this.ct_off, view_right = view_left + this.vp_x; // initialize visibility array while (i--) { visibility[i] = 0; } // test how much viewable each panel is right now for(i = 0; panel_left < view_right; i ++) { // normalize from panel to slide var slide = this.panel2slide(i); // calculate the right panel edge var panel_right = panel_left + widths[slide + smin]; // the panel is out on the left or out on the right if (panel_right < view_left || panel_left > view_right) { visible = 0; } // the panel is completely inside the viewport else if (panel_left >= view_left & panel_right <= view_right) { visible = 1; } // the panel does not fit into the viewport completely else if (panel_left < view_left & panel_right > view_right) { visible = (view_right - view_left) / (panel_right - panel_left) } // the panel is partially on the left else if (panel_left < view_left) { visible = ( panel_right - view_left ) / ( panel_right - panel_left ); } // the panel is partially on the right else if (panel_right > view_right) { visible = ( view_right - panel_left ) / ( panel_right - panel_left ); } // this should not happen else { throw('updateVisibility has invalid state') } // sum up for slides visibility[slide] += visible; // move to next panel offset panel_left = panel_right; } // EO each panel // store state before calling the changed hock // reset the status first, but pass before status var sv = this.sv; this.sv = visibility; // execute the changedVisibility hook for slides this.trigger('changedVisibility', visibility, sv); } // @@@ EO fn: updateSlideVisibility @@@ // calculate the exposure array very early [call]prototype.plugin('layout', updateSlideExposure, -99); [call]prototype.plugin('loading', updateSlideExposure, -99); [call]prototype.plugin('changedPosition', updateSlideExposure, -99); // calculate the visibility array very late [call]prototype.plugin('layout', updateSlideVisibility, 99); [call]prototype.plugin('changedPosition', updateSlideVisibility, 99);// EO extend class prototype; 'use strict'; // @@@ method: setPosition @@@ prototype.setPosition = function (position) { // normalize the slide index position = this.slide2slide(position); // check if the position really changed if (this.position == position) return; // get previous position to pass var previous = this.position; // store normalized position this.position = position; // sync to monitor? if (this.conf.vsync) { // synchronize action with monitor this.trigger('changedPosition', previous); } else { // defer draw to achieve the wished frame rate (approx) [call]this.defer(1000 / this.conf.fps, 'changedPosition', previous); } } // @@@ EO method: setPosition @@@ // @@@ plugin: layout @@@ prototype.plugin('changedPosition', function () { // just reset the current position [call]this.setOffsetByPosition(this.position); }); // @@@ EO plugin: layout @@@ // @@@ method: setOffsetByPosition @@@ prototype.setOffsetByPosition = function (position) { // protect beeing called too early if (this.isReady !== true) return; // store current normalized position this.position = this.slide2slide(position); // declare local variables var conf = this.conf, alignPanelDim = conf.alignPanelDim, alignViewport = conf.alignViewport, panelsVisible = conf.panelsVisible; // only in non-carousel mode if (!conf.carousel) { // try to show as many panels possible if (conf.fillViewport) { // calculate the left and right space to be filled var fill_left = panelsVisible * alignViewport - alignPanelDim, fill_right = -1 * fill_left + panelsVisible - 1; // adjust panel position to make those // panels "virtually" visible / exposed if (position < this.smin + fill_left) { position = this.smin + fill_left; } if (position > this.smax - fill_right) { position = this.smax - fill_right; } } // EO if conf.fillViewport } // EO if not conf.carousel // maybe do not update the actual container offset if (this.animation & this.animation.fader) return; // get the pixel offset for the given relative index var px = [call]this.getOffsetByPosition(position); // adjust the offset on the viewport px -= this.vp_x * alignViewport; // adjust the container offset [call]this.setContainerOffset(px); } // @@@ EO method: setOffsetByPosition @@@ // @@@ method: getOffsetByPosition @@@ prototype.getOffsetByPosition = function (index, real) { // index is meant as slide, get into panels index += this.smin + this.conf.alignPanelDim; // count full revolvings // to adjust virtual offset var turns = 0; // normalize/sanitize the input if (this.conf.carousel) { // adjust index into the valid panel range while (index > this.smax) { turns++; index -= this.slides.length; } while (index < this.smin) { turns--; index += this.slides.length; } } else { // adjust index into the valid panel range if (index <= this.smin + 0) return this.offset[this.smin]; if (index >= this.smax + 1) return this.offset[this.smax + 1]; } // get the panel on the left side var panel = Math.floor(index); // get the floating part var fpart = index - panel; // solve by distributing in the panel var px = this.pd[0][panel] * fpart; // add the offset of the panels px += this.offset[panel]; // adjust end result for real result // can return "out of bound" position if (real) px += this.offset[this.smax + 1] * turns; // return px return px; } // @@@ EO method: getOffsetByPosition @@@ // @@@ method: getPositionByOffset @@@ prototype.getPositionByOffset = function (px, real) { // ensure pixel as integer px = parseInt(px + 0.5, 10); // get the left and right position // also calculate size of all slides var left = this.offset[this.smin], right = this.offset[this.smax + 1], align = this.conf.alignPanelDim + this.smin; // count full revolvings // to adjust real position var turns = 0, adjust = 0; // normalize/sanitize the input if (this.conf.carousel & right > left) { // shift into prefered and best visible area while (px < left) { turns--; px += right - left; } while (right <= px) { turns++; px -= right - left; } } else { if (px <= left) { return this.smin; } if (px >= right) { return this.smax + 1; } } // process all panels from right until we find // a panel that is currently moving out of view var i = this.panels.length; while (i--) { // assign to local variables var panel_left = this.offset[i+0]; var panel_right = this.offset[i+1]; // make test for equality first // this is the most common case so // avoid the unnecessary calculation if (panel_left == px) return i - align; // test if pixel offset lies in this panel if (panel_right > px & px > panel_left) { // adjust end result for real result // can return "out of bound" position if (real) var adjust = turns * (this.smax + 1); // return the calculated position (intoPanel / panelSize + i - offset) return (px - panel_left) / (panel_right - panel_left) + i - align + adjust; } // EO if position in panel } // EO each panel // this should not ever happen, debug!! throw('getPositionByOffset has invalid state'); } // @@@ EO method: getPositionByOffset @@@ // @@@ plugin: layout @@@ prototype.plugin('layout', function () { // normalized the position before layouting this.position = this.slide2slide(this.position); }, - 999); // @@@ EO plugin: layout @@@ // @@@ plugin: layout @@@ prototype.plugin('layout', function () { // just reset the current position [call]this.setOffsetByPosition(this.position); }, + 999); // @@@ EO plugin: layout @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // store jquery animation this.animating = false; // animation queue this.queue = []; // add defaults extend({ // easing duration per slide easeDuration: 1200, // easing function per step easeFunction: 'linear' }); }); // @@@ EO plugin: config @@@ // @@@ method: lock @@@ // lock the slider for custom animation // returns a function you have to call // when your own animation is complete prototype.lock = function() { // create closure var slider = this; // check if slider is locked if (slider.locked) { // return another prerequisite to satisfy return slider.locked.prerequisite(); } // when swiping the custom animation // should run freely without lock if (slider.swiping) return; // create resume function / closure var resume = jQuery.proxy(slider.resume, slider); // reset the resume callback // I did already consume it slider.resume = false; // return lexical function slider.locked = new RTP.Multievent(function () { // check if we are already animating // this should not happend, safety first if (slider.animating) return; // unlock the slider slider.locked = false; // only call once if (!resume) return; // execute resume resume.call(slider) // reset callback resume = null; }); // EO multievent cb // create a new prerequisite to satisfy return slider.locked.prerequisite(); }; // @@@ EO method: lock @@@ // @@@ private fn: enqueue @@@ var enqueue = function (action, duration, easing, cb, keep) { // create closure var slider = this; // enqueue action slider.queue.push({ keep: keep, action: action, easing: easing || this.conf.easeFunction, duration: isNaN(duration) ? this.conf.easeDuration : duration, step: function () { step.call(slider, this, arguments); }, complete: function () { if(cb) cb.call(slider, this); complete.call(slider, this); } }); } // @@@ EO private fn: enqueue @@@ // @@@ private fn: actionToPosition @@@ function actionToPosition (action) { // local variable var pos; // convert to next/prev action if (action.toString().match(/^([\+\-])/)) { // add parsed number to current position pos = this.position + parseFloat(action); } // absolute position else if (typeof action != 'undefined') { // remove equal sign if there is one // this is the recommended way to tell // us that you want to animate absolute action = action.toString().replace(/^=/, ''); // return parsed number pos = parseFloat(action); } else { debugger } // return normalized value if not in carousel mode return this.conf.carousel ? pos : this.panel2panel(pos); } // @@@ EO private fn: actionToPosition @@@ // @@@ private fn: dequeue @@@ var dequeue = function (animation) { // get animation lock this.animating = true; // get the enqueued animation var action = animation.action, position = this.position, from = { pos: position }; // get the absolute position for this action var pos = [call]actionToPosition.call(this, action); // check if we are already on position if (pos == position) { // execute complete callback and return return animation.complete.call({ pos : pos }); } // search for shortest path if (this.conf.carousel & ! animation.keep) { var diff = Math.abs(position - pos), left_pos = pos - this.slides.length, right_pos = pos + this.slides.length; if (diff > Math.abs(left_pos - position)) pos = left_pos; if (diff > Math.abs(right_pos - position)) pos = right_pos; } this.animation = animation; // start the jQuery animation that drives our animation this.animating = jQuery(from).animate({ pos : pos }, animation); }; // @@@ EO private fn: dequeue @@@ // @@@ private fn: abort @@@ prototype.abortAnimation = function () { // reset queued animations this.queue.length = 0; // stop all queued custom jquery animations if (this.animating & this.animating !== true) { // this.trigger('stopAnimation'); this.animating.stop(true, false); } // release all animation locks this.animating = this.locked = false; } // @@@ EO private fn: abort @@@ // @@@ private fn: start @@@ var start = function () { // check if some animation is running if (this.animating || this.locked) return; // check if there is anything queued if (this.queue.length == 0) return; // shift next animation step to do var animation = this.queue.shift(); // handle special fader animation if (animation.action.toString().match(/^f(\d+)/i)) { animation.action = RegExp.$1; animation.fader = this.conf.tiles & this.conf.fader; } // get the absolute position for this action var pos = [call]actionToPosition.call(this, animation.action); // register resume function for lockers // the lock method will take care to attach // this function to the right context object this.resume = function () { // now trigger the startAnimation hook this.trigger('startAnimation'); // start dequeuing next action // preAnimation hook has completed dequeue.call(this, animation); if (animation.fader) { this.trigger('changedPosition', this.position); jQuery('.rtp-slider-fader', this.el) .css({ 'opacity' : '1', 'display' : 'block' }) } // reset our resumer this.resume = null; } // EO fn resume // now trigger the preAnimation hook // this might lock the animation which if (pos != this.position) this.trigger('preAnimation'); // call resume now if not locked and still defined if (this.resume & !this.locked) this.resume.call(this); }; // @@@ EO private fn: start @@@ // @@@ private fn: complete @@@ var complete = function (to) { // release animation lock this.animating = false; // move slider to final position [call]this.setPosition(to.pos); if (this.animation & this.animation.fader) { this.animation.fader = false; this.trigger('changedPosition'); } this.animation = {}; // register resume function for lockers // the lock method will take care // to attach this function to the right context this.resume = function () { // now trigger the endAnimation hook this.trigger('stopAnimation'); // re-start the queue, do next // postAnimation hook has completed start.call(this); // reset our resumer this.resume = null; }; // EO fn resume // if (animation.fader) {} var fader = jQuery('.rtp-slider-fader', this.el); [call]fader.css('display', 'none').css('opacity', ''); // just reset the current position [call]this.setOffsetByPosition(this.position); if (this.queue.length == 0) { // now trigger the postAnimation hook // this might lock the animation which this.trigger('postAnimation'); } // call resume now if not locked and still defined if (this.resume & !this.locked) this.resume.call(this); }; // @@@ EO private fn: complete @@@ // @@@ private fn: step @@@ var step = function (cur, animation) { var foo = this.animation; // move slider to position // this.setPosition(cur.pos); if (!foo.fader) { [call]this.setPosition(cur.pos); } if (foo.fader) { var end = animation[1].end, start = animation[1].start; if (end == start) return; var progress = (cur.pos - start) / (end - start); var fader = jQuery('.rtp-slider-fader', this.el); fader.show().find('.tile').css('opacity', progress); var visibility = []; for (var i = 0; i < this.slides.length; i++) { visibility[i] = i == this.slide2slide(end) ? progress : i == this.slide2slide(start) ? 1 - progress : 0; } this.sv = visibility; this.se = visibility;// this.trigger('changedVisibility', visibility); this.trigger('foobarVisibility', visibility); } }; // @@@ EO private fn: step @@@ // @@@ method: animate @@@ prototype.animate = function (action, duration, easing, cb, keep) { // if config option is a function, execute to get action if (jQuery.isFunction(action)) action = action.call(this); // trigger interaction hook this.trigger('interaction', action); // add action to the queue enqueue.apply(this, arguments); // start the queue start.call(this); }; // @@@ EO method: animate @@@ // @@@ method: animate @@@ prototype.goTo = function (action, duration, easing, cb, keep) { // if config option is a function, execute to get action if (jQuery.isFunction(action)) action = action.call(this); // add action to the queue enqueue.apply(this, arguments); // start the queue start.call(this); }; // @@@ EO method: animate @@@ // shortcut methods for common animations prototype.goNext = function (delay, easing) { [call]this.animate('+1', delay, easing); } prototype.goPrev = function (delay, easing) { [call]this.animate('-1', delay, easing); } prototype.goFirst = function (delay, easing) { [call]this.animate('0', delay, easing); } prototype.goLast = function (delay, easing) { [call]this.animate(this.slen - 1, delay, easing); }// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // which viewport dimension should be fluid // those values are read from the user agent // and the code must not try to set that itself // valid: panelsByViewport or viewportByPanels sizerDim: 'panelsByViewport', sizerOpp: 'viewportByPanels' }); }); // @@@ EO plugin: config @@@ // @@@ method: preLayout @@@ // called by OCBNET.Layout library prototype.preLayout = function(data) { // read viewport dimensions first // use only these values to adjust ui if (this.conf.sizerDim != 'viewportByPanels') [event]this.trigger('readViewportDim', data); if (this.conf.sizerOpp != 'viewportByPanels') [event]this.trigger('readViewportOpp', data); // check if viewport has changed // otherwise do nothing to safe cpu // if ( // Math.abs(this.vp_x_lck - this.vp_x) > 0.0001 || // Math.abs(this.vp_y_lck - this.vp_y) > 0.0001 || // data.force // ) // { // } // EO if dimension changed // update and adjust all ui elements this.trigger('changedViewport', data); } // @@@ EO method: preLayout @@@ // @@@ method: postLayout @@@ // called by OCBNET.Layout library prototype.postLayout = function(data) { if ( Math.abs(this.vp_x_lck - this.vp_x) > 0.0001 || Math.abs(this.vp_y_lck - this.vp_y) > 0.0001 || data.force ) { // adjust outer ui elements (viewport) this.trigger('adjustViewport', data); } } // @@@ EO method: postLayout @@@ // @@@ method: updateLayout @@@ // called by OCBNET.Layout library prototype.updateLayout = function(data) { // check if viewport has changed // otherwise do nothing to safe cpu if ( this.vp_x_lck != this.vp_x || this.vp_y_lck != this.vp_y || data.force ) { // update the lock variable // tells us when layout was run this.vp_x_lck = this.vp_x; this.vp_y_lck = this.vp_y; // redo all layouts [event]this.trigger('layout', data); } // EO if dimension changed } // @@@ EO method: updateLayout @@@ // @@@ plugin: ready @@@ prototype.plugin('start', function() { // add widget to layout manager OCBNET.Layout.add(this); // trigger changed viewport once this.trigger('changedViewport'); // layout user interface OCBNET.Layout(true); }, 999999); // @@@ EO plugin: ready @@@ // @@@ plugin: changedPosition @@@ // A position change may change the opposition // which could trigger a scrollbar, so check for // this condition here on the corresponding event prototype.plugin('changedPosition', function() { // current viewport dimensions var vp_x = [call]this.getViewportDim(); var vp_y = [call]this.getViewportOpp(); // check against the stored viewport dimensions for changes // if they differ, chances are we need to update all layouts if (vp_x != this.vp_x || vp_y != this.vp_y) OCBNET.Layout(true); }, 999999); // @@@ EO plugin: changedPosition @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // center in viewport alignPanelOpp: 0.5 }); }); // @@@ EO plugin: config @@@ // @@@ private fn: alignOppInViewport @@@ function alignOppInViewport () { // get the css attribute to set var css = this.conf.vertical ? 'left' : 'top', // get the alignment number (between 0 and 1) align = parseFloat(this.conf.alignPanelOpp, 10); // check for valid number if (isNaN(align)) return; // loop all slides to set their offset var i = this.panels.length; while (i--) { // calculate the difference and multiply to align var offset = (this.vp_y - this.pd[1][i]) * align; // set this panel offset for given direction jQuery(this.panels[i]).css(css, offset + 'px'); } // EO each panel } // @@@ EO private fn: alignOppInViewport @@@ // run late after the viewport opposition has been changed/updated [call]prototype.plugin('adjustViewport', alignOppInViewport, 99999); [call]prototype.plugin('changedPosition', alignOppInViewport, 99999);// EO extend class prototype; 'use strict'; // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // distribute viewport dim to slides if (this.conf.sizerDim == 'panelsByViewport') { // process all slides to set dimension var i = this.slides.length; while (i--) { // set size to the calculated value [call]this.setSlideDim(i, [call]this.getSlideDimFromVp(i)); } } }) // @@@ EO plugin: changedViewport @@@ // @@@ plugin: adjustViewport @@@ prototype.plugin('adjustViewport', function () { // distribute viewport dim to slides if (this.conf.sizerDim == 'panelsByViewport') { // trigger the changed panels dim hook this.trigger('updatedPanelsDim'); // now update the panel opposition // read in the new dimensions and // dispatch updatedPanelsOpp event [call]this.updatePanelsOpp(); } }); // @@@ EO plugin: adjustViewport @@@ // @@@ method: getSlideDimFromVp @@@ // get the dimension for the given slide prototype.getSlideDimFromVp = function (slide) { // correct virtual viewport to get rid of the margin var virtual = this.vp_x + (this.conf.margin || 0); // we currently distribute everything evenly to all slides // todo: implement a more complex sizer with distribution factors return parseFloat(virtual / this.conf.panelsVisible, 10) } // @@@ EO method: getSlideDimFromVp @@@// EO extend class prototype; 'use strict'; // @@@ plugin: changedViewport @@@ prototype.plugin('changedViewport', function () { // abort if this feature is not enabled if (this.conf.sizerOpp == 'panelsByViewport') { // process all slides to set opposition var i = this.slides.length; while (i--) { // set size to full viewport opp [call]this.setSlideOpp(i, [call]this.getSlideOppFromVp(i)); } } }); // @@@ EO plugin: changedViewport @@@ // @@@ plugin: adjustViewport @@@ prototype.plugin('adjustViewport', function () { // distribute viewport dim to slides if (this.conf.sizerOpp == 'panelsByViewport') { // trigger the changed panels dim hook this.trigger('updatedPanelsOpp'); // now update the panel opposition // read in the new dimensions and // dispatch updatedPanelsOpp event [call]this.updatePanelsDim(); } }); // @@@ EO plugin: adjustViewport @@@ // @@@ method: getSlideOppFromVp @@@ // get the opposition for the given slide prototype.getSlideOppFromVp = function (slide) { // extend to the full opposition // todo: implement a more complex method return parseFloat(this.vp_y, 10) } // @@@ EO method: getSlideOppFromVp @@@// EO extend class prototype; 'use strict'; // @@@ private fn: viewportDimByPanels @@@ function viewportDimByPanels () { // protect beeing called too early if (this.isReady !== true) return; // abort if feature is not enabled if (this.conf.sizerDim != 'viewportByPanels') return; // calculate dimension from exposure var dim = 0, exposure = this.se; // development assertions if (exposure.length == 0) eval('debugger'); if (this.pd[0].length == 0) eval('debugger'); // process all panel visibilites for(var i = 0; i < exposure.length; i++) { // skip if panel is not visible if (exposure[i] == 0) continue; // sum up dimensions of all panels dim += this.pd[0][i] * exposure[i]; } // set viewport dimension [call]this.updateViewportDim(dim); } // @@@ EO private fn: viewportDimByPanels @@@ // hook into various change events to adjust viewport [call]prototype.plugin('adjustViewport', viewportDimByPanels, 9999); [call]prototype.plugin('changedPosition', viewportDimByPanels, 9999);// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // when is a panel not visible autoVpOppDeadZone: 0.2, // when is a panel fully visible autoVpOppLifeZone: 0.8 }); }); // @@@ EO plugin: config @@@ // @@@ private fn: viewportOppByPanels @@@ function viewportOppByPanels () { // protect beeing called too early if (this.isReady !== true) return; // abort if feature is not enabled if (this.conf.sizerOpp != 'viewportByPanels') return; // declare local variables for loop var min = 1E+100, opps = [], exposure = this.se, // dead zone for out of view panel dead_zone = parseFloat(this.conf.autoVpOppDeadZone, 10), // life zone for out of view panel life_zone = parseFloat(this.conf.autoVpOppLifeZone, 10); // assertion for numeric value if (isNaN(dead_zone)) dead_zone = 0.2; if (isNaN(life_zone)) life_zone = 0.8; // switch arguments if they seem to be // defined in the opposite way (play safe) if (dead_zone > life_zone) { var foobar = dead_zone; dead_zone = life_zone; life_zone = foobar; } // development assertions if (exposure.length == 0) eval('debugger'); if (this.pd[1].length == 0) eval('debugger'); // process all panel visibilites var i = exposure.length; while (i --) { // panel access index var n = this.smin + i; // check if current panel is visible and smaller than min if (exposure[i] > 0 & this.pd[1][n] < min) min = this.pd[1][n]; } // process all panel visibilites var i = exposure.length; while (i --) { // panel access index var n = this.smin + i; // skip if panel is not visible if (exposure[i] === 0) continue; // check if panel is fully visible if (exposure[i] > life_zone) { // use full panel size difference opps.push((this.pd[1][n] - min)); } // panel only partial visible else if (exposure[i] > dead_zone) { // use a partial panel size diff (distribute from 0 to 1 between dead_zone and life_zone) opps.push((this.pd[1][n] - min) * (exposure[i] - dead_zone) / (life_zone - dead_zone)); } } // EO foreach panel visiblity // get the biggest value from array var offset = Math.max.apply(Math, opps); // update opposite viewport size // take minimum size and add offset [call]this.updateViewportOpp(min + offset); } // @@@ EO private fn: viewportOppByPanels @@@ // hook into various change events to adjust viewport [call]prototype.plugin('adjustViewport', viewportOppByPanels, 9999); [call]prototype.plugin('changedPosition', viewportOppByPanels, 9999); [call]prototype.plugin('foobarVisibility', viewportOppByPanels, 9999);// EO extend class prototype; 'use strict'; // get function checker var isFn = jQuery.isFunction; // declare here for compiler var prefix = 'rtp-nav-dot'; // @@@ private fn: formatTitle @@@ // default title format function function formatTitle (nr) { return (nr + 1) + "/" + this.slides.length; } // @@@ EO private fn: formatTitle @@@ // @@@ private fn: updateNavDotUI @@@ // call to setup the styles of a nav dot node function updateNavDotUI (slide, progress) { // classes for selectors var class_hidden = this.klass.panelHidden; var class_partial = this.klass.panelPartial; var class_visible = this.klass.panelVisible; // panel if completely visible if (progress >= 1) { this.navDot.eq(slide) .addClass(class_visible) .removeClass(class_hidden) .removeClass(class_partial) } // panel is not shown at all else if (progress <= 0) { this.navDot.eq(slide) .addClass(class_hidden) .removeClass(class_partial) .removeClass(class_visible) } // panel is partially visible else { this.navDot.eq(slide) .addClass(class_partial) .removeClass(class_hidden) .removeClass(class_visible) } // call configured function for styling var fn = this.conf.navDotStepFunction; // assert that the configured option is a function if (jQuery.isFunction(fn)) fn.call(this, slide, progress) } // @@@ EO private fn: updateNavDotUI @@@ // @@@ private fn: updateVisibility @@@ function updateVisibility (visibility) { // is plugin enabled if (this.conf.navDots) { if (this.conf.groupPanels) { // should always to be an integer var vis = this.conf.panelsVisible; // group visibilities together is distribute for(var i = 0, l = visibility.length; i < l; i += vis) { // declare variables var sum = 0, count = 0; // process all dots in this panels group for(var n = 0; n < vis & i + n < l; n ++) { sum += visibility[i + n]; count ++; } // calculate the (adjusted) average var average = Math.pow(sum / count, vis); // update all dots in group with average for(var n = 0; n < vis & i + n < l; n ++) { [call]updateNavDotUI.call(this, i, average) } } } else { // call update for each slide nav dot for(var i = 0; i < visibility.length; i++) { [call]updateNavDotUI.call(this, i, visibility[i]) } } } // EO if is enabled } // @@@ EO private fn: updateVisibility @@@ // @@@ private fn: updateUI @@@ function updateUI (config) { if (!this.navDot) return; // fall back to instance config if (!config) config = this.conf; // get the new configuration var vis = config.panelsVisible; // calculate how many nav dots are visible var count = Math.ceil(this.navDot.length/vis); // check for old count class if (this.navDotCountClass) { // remove the indicator class from the wrapper this.navDotWrapper.removeClass(this.navDotCountClass); // reset the storage variable this.navDotCountClass = null; } // check of config option if (this.conf.navDotCountClass) { // create class indicating how many nav dots are ... this.navDotCountClass = this.klass.navDotCount + count; // ... currently shown (use to hide single nav dots) this.navDotWrapper.addClass(this.navDotCountClass); } // process all nav dots to show/hide them for(var i = 0; i < this.slides.length; i++) { // check if the current nav dot is shown or not var display = i % vis == 0 ? '' : 'none'; // update inline styles of the dom node this.navDot.eq(i).css('display', display); } } // @@@ EO private fn: updateUI @@@ // @@@ plugin: updating @@@ prototype.plugin('updating', function (config) { // check if we should group the panels (otherwise just return) // option may be overruled by new config (therefore we use a proper check) if (!(('groupPanels' in config & config.groupPanels) || this.conf.groupPanels )) return; // only proceed if the visible panels have changed (pass new config to function) if (config.panelsVisible != this.conf.panelsVisible) [call]updateUI.call(this, config); }); // @@@ EO plugin: updating @@@ // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable plugin navDots: false, // enable wrappers navDotWrappers: false, // function name to add dom node // ex: prepend, append, after or before navDotPosition: 'append', // add class indicating how many // now dots are currently shown // use this to hide single dots navDotCountClass: true, // format for alt and title tag navDotAltFormat: formatTitle, navDotTitleFormat: formatTitle, // this function is responsible to change styles // progress will be in the range of 0 to 1 (100%) navDotStepFunction: function(slide, progress) { // the default method is to change the opacity this.navDotImg.eq(slide).css('opacity', progress); }, klass : { navDot: prefix, navDotCount: prefix + '-count-', panelHidden: prefix + '-hidden', panelPartial: prefix + '-partial', panelVisible: prefix + '-visible' }, tmpl : { navDotWrapper: ['<span><a href="javascript:void(0);">', '</a></span>'], navDotElement: '<img src="img/rtp-nav-dot-clear.gif" width="12" height="12" alt=""/>' }, selector : { navDotImage: 'IMG' } }); }); // @@@ EO plugin: config @@@ // @@@ plugin: init @@@ prototype.plugin('init', function() { // create closure var self = this, tmpl = self.tmpl, conf = self.conf; // activate autoslide if (conf.navDots) { // only if more than one slide if (self.slides.length > 1) { // store nav dots and nav dot images self.navDot = jQuery(), self.navDotImg = jQuery(); // create the wrapper around all nav dots self.navDotWrapper = jQuery('<div class="' + prefix + 's">'); // create a representation for each slide self.slides.each(function (i) { // create a new jquery dom object var navDot = jQuery( tmpl.navDotWrapper[0] + tmpl.navDotElement + tmpl.navDotWrapper[1] ) // add generic class to the item .addClass(self.klass.navDot) // add specific class to the item (with nr) .addClass([self.klass.navDot, i].join('-')) // attach click handler to the nav dot // use experimental fade mode if configured // TODO: refactor animate to avoid these nonsense arguments .click(function () { [call]self.animate(self.conf.fader ? 'f' + i : '=' + i, null, null, null, true); }) // append object to wrapper .appendTo(self.navDotWrapper); // get the nav dot image node var navDotImg = jQuery(conf.selector.navDotImage, navDot); // set some attributes for the image (overwrite format functions to personalize) if (isFn(conf.navDotAltFormat)) navDotImg.attr('alt', conf.navDotAltFormat.call(self, i)); if (isFn(conf.navDotTitleFormat)) navDotImg.attr('title', conf.navDotTitleFormat.call(self, i)); // collect all real dom nodes self.navDot.push(navDot.get(0)); self.navDotImg.push(navDotImg.get(0)); // setup the styles of this dot [call]updateNavDotUI.call(self, i, 0); }); // get configured function from node var fn = self.wrapper[conf.navDotPosition]; // call to add wrapper to the main slider wrapper if (fn) fn.call(self.wrapper, self.navDotWrapper); // enable additional wrappers if (conf.navDotWrappers) { // these can be usefull to center them in all browsers self.navDotWrapper.wrap('<div class="rtp-nav-dots-outer">'); self.navDotWrapper.wrap('<div class="rtp-nav-dots-wrapper">'); } } // EO if slides > 1 } // EO if conf.autoslide // call updateUI [call]updateUI.call(this); }); // @@@ plugin: init @@@ // execute when slide visibility is changed (actual visibility) [call]prototype.plugin('changedVisibility', updateVisibility); [call]prototype.plugin('foobarVisibility', updateVisibility);// EO extend class prototype; 'use strict'; // @@@ updateUI @@@ var updateUI = function() { // get the prev/next nodes var prev = this.arrows.prev; var next = this.arrows.next; // is carousel mode? if (this.conf.carousel) { // prev/next links are always shown in carousel mode if(!prev.is(':visible')) prev.stop(true, true).show(); if(!next.is(':visible')) next.stop(true, true).show(); } else { // set opacity according to current position (fade out at edges) [call]prev.css('opacity', Math.max(0, Math.min(1, this.position - this.smin))); [call]next.css('opacity', Math.max(0, Math.min(1, this.smax - this.position))); } } // @@@ EO updateUI @@@ // hook into rtp slider class [call]prototype.plugin('layout', updateUI); [call]prototype.plugin('changedPosition', updateUI); // hook into rtp slider class prototype.plugin('config', function(extend) { // add defaults extend({ navArrows: false, // should we generate navigation arrows navArrowAttach: 'wrapper', // wrapper or panels navArrowPosition: 'default', // prepend, reverse, append navArrowPrevText: '« left', // text/html for the previous link navArrowNextText: 'right »', // text/html for the next link tmpl : { 'arrow-prev' : ['<div class="rtp-nav-prev"><a href="javascript:void(0)">', '</a></div>'], 'arrow-next' : ['<div class="rtp-nav-next"><a href="javascript:void(0)">', '</a></div>'] }, selector : { 'nav-prev' : '.rtp-nav-prev A', 'nav-next' : '.rtp-nav-next A' } }); }); // hook into rtp slider class prototype.plugin('init', function(extend) { // declare and init navigation arrows this.arrows = { prev : jQuery(), next : jQuery() }; // initialize navigation arrows if (this.conf.navArrows) { // get default methods for the insert var navPositionNext = this.viewport.append; var navPositionPrev = this.viewport.prepend; // switch positions by given configuration switch(this.conf.navArrowPosition.substr(0,1)) { case 'r': // reverse navPositionPrev = this.viewport.append; navPositionNext = this.viewport.prepend; break; case 'p': // prepend navPositionNext = this.viewport.prepend; break; case 'a': // append navPositionPrev = this.viewport.append; break; } // where should the arrows be attached to (inside each panel or once for all within wrapper) var el = this.conf.navArrowAttach.substring(0,1) == 'p' ? this.panels : this.wrapper; // add prev/next navigation items (will be shown or hidden by other application settings) var txt_prev = this.conf.navArrowPrevText, txt_next = this.conf.navArrowNextText; if (txt_prev) navPositionPrev.call(el, this.tmpl['arrow-prev'][0] + txt_prev + this.tmpl['arrow-prev'][1]); if (txt_next) navPositionNext.call(el, this.tmpl['arrow-next'][0] + txt_next + this.tmpl['arrow-next'][1]); // get the actual dom nodes by selecting them from the wrapper this.arrows.prev = this.wrapper.find(this.selector['nav-prev']); this.arrows.next = this.wrapper.find(this.selector['nav-next']); // attach prev/next arrow click (prevent event bubbeling) if (this.arrows.prev) this.arrows.prev.click(jQuery.proxy(function() { [call]this.goPrev(); return false; }, this)); if (this.arrows.next) this.arrows.next.click(jQuery.proxy(function() { [call]this.goNext(); return false; }, this)); // update ui immediately [call]updateUI.call(this, 0); }; // EO if conf.navArrows }); // EO init hook// EO extend class prototype; 'use strict'; // @@@ plugin: init @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // should we enable keyboard navigation navKeyboard : false, // jquery keycode for prev action navKeyboardPrev : this.conf.vertical ? 38 : 37, // jquery keycode for next action navKeyboardNext : this.conf.vertical ? 40 : 39 }); }); // @@@ EO plugin: init @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function() { // initialize keyboard navigation if (this.conf.navKeyboard) { // bind to keyboard event on document scope jQuery(document).keydown(jQuery.proxy(function (evt) { // only capture without any modifier combination (ie. for opera tabbing) if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return true; // map key to slider function switch (evt.which) { case this.conf.navKeyboardPrev: [call]this.goPrev(); break; case this.conf.navKeyboardNext: [call]this.goNext(); break; } }, this)); } }); // @@@ EO plugin: ready @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // class for current panel curClass: false, // panel dead zone curClassDeadZone: 0.25 }); // marked elements store this.curEls = jQuery(); }); // @@@ EO plugin: config @@@ // @@@ private fn: updateClasses @@@ function updateClasses () { // check if feature is enabled if (!this.conf.curClass) return; // get the current position var conf = this.conf, curEls = jQuery(), position = this.position, curClass = conf.curClass, deadZone = conf.curClassDeadZone; // get the nearest slide to be selected as current var nearest = (parseInt(this.position + 0.5, 10)); // mark current class if within dead zone if (Math.abs(nearest - position) < deadZone) { // get jQuery collection of current panels curEls = [call]this.getPanelsBySlide(nearest); // have nav dots? if (this.navDot) { // bring value into valid range nearest = this.slide2slide(nearest); // add dom element of current nav dot curEls = curEls.add(this.navDot[nearest]); } // EO if navDot } // EO if in dead zone // add class to newly current elements curEls.not(this.curEls).addClass(curClass); // remove class from no longer current elements this.curEls.not(curEls).removeClass(curClass); // store current elements this.curEls = curEls; }; // @@@ EO private fn: updateClasses @@@ // reset the classes on position changes [call]prototype.plugin('layout', updateClasses) [call]prototype.plugin('changedPosition', updateClasses)// EO extend class prototype; 'use strict'; // @@@ plugin: init @@@ prototype.plugin('config', function (extend) { // store autoslide timer // if autosliding is set to true it is paused and can // be restartet. if autosliding is false no auto slider // should be running, when running the timeout is stored this.autosliding = null; // add defaults extend({ // start auto slide on load autoslide: false, // direction for autoslide autoslideAction: +1, // delay for next slide autoslideDelay: 3500, // overwrite first slide delay autoslideFirstDelay : 1000, // overwrite resume slide delay autoslideResumeDelay : false, // stop autoslide on mouse over autoslideStopOnHover: false, // pause autoslide on mouse over // will resume on mouse out event autoslidePauseOnHover: true, // stop autoslide on manual interaction autoslideStopOnAction: false }); }); // @@@ EO plugin: init @@@ // @@@ plugin: interaction @@@ prototype.plugin('interaction', function() { // stop the autoslider if configured to do so if (this.conf.autoslideStopOnAction) [call]this.stopAutoSlide(false); }); // @@@ EO plugin: interaction @@@ // @@@ plugin: stopAnimation @@@ prototype.plugin('stopAnimation', function() { // return if autoslider is inactive if (!this.autosliding) return // only restart autoslider when // there are no more animation queued if (this.queue.length > 0) return; // restart autoslider with the default deay [call]this.startAutoSlide(this.conf.autoslideDelay); }); // @@@ EO plugin: stopAnimation @@@ // @@@ method: startAutoSlide @@@ prototype.startAutoSlide = function (delay, action) { // get default action from given config if (isNaN(action)) action = parseFloat(this.conf.autoslideAction || 1); // abort if autoslider timeout is waiting if (this.autosliding & this.autosliding !== true) return; this.autosliding = true; this.trigger('autoslideStart'); if (this.queue.length > 0 || this.animating || this.locked) return; // stop the autoslide if end is reached (either on the begining or the end) if (!this.conf.carousel & ((this.position <= this.smin & action < 0) || (this.position >= this.smax & action > 0))) { return [call]this.stopAutoSlide(); } // wait for next slide action this.trigger('autoslideWaitStart', delay); // setup and create new function to start autoslider this.autosliding = window.setTimeout(jQuery.proxy(function () { if (this.queue.length > 0 || this.animating || this.locked) return; // if config option is a function, execute to get action if (jQuery.isFunction(action)) action = action.call(this); // we are now executing slide action this.trigger('autoslideWaitStop'); // get default action from given config if (isNaN(action)) action = this.conf.autoslideAction || 1; // add action and start animation [call]this.goTo(action > 0 ? '+' + action : action); // autosliding has been activated this.autosliding = true; }, this), isNaN(delay) ? 0 : delay); } // @@@ EO method: startAutoSlide @@@ // @@@ method: stopAutoSlide @@@ prototype.stopAutoSlide = function (pause) { // abort if autoslider is not running // if (!this.autosliding) return; // a timeout has been stored if (this.autosliding !== true) { // we are aborting slide waiter this.trigger('autoslideWaitStop', true); // clear the next autoslide timeout window.clearTimeout(this.autosliding) } // autosliding has been disabled this.autosliding = pause ? false : null; if (pause) this.trigger('autoslidePause'); else this.trigger('autoslideStop'); } // @@@ EO method: stopAutoSlide @@@ // @@@ control autoslider [on/off, first timeout, action] @@@ // prototype.autoslide = function () // { // dispatch to start and stop functions // if (arguments.length > 0 & !arguments[0]) this.stopAutoSlide(false); // else this.startAutoSlide(arguments[1], arguments[2]); // } // @@@ EO autoslide @@@ // @@@ plugin: start @@@ prototype.plugin('start', function() { // abort if feature is not enabled if (!this.conf.autoslide) return; // maybe use special timeout for first auto slide var timeout = isNaN(this.conf.autoslideFirstDelay) ? this.conf.autoslideDelay : this.conf.autoslideFirstDelay; // call first autoslide with setting [call]this.startAutoSlide(timeout); }); // @@@ EO plugin: start @@@ // @@@ plugin: ready @@@ // start is defered after ready prototype.plugin('ready', function() { // pause auto slide if mouse is over the element // this option can only be enabled before ready event // if you intend to disable it on runtime, you must enable // it before this event, but you can then disable it on runtime this.wrapper.hover( // @@@ event: mouse in @@@ jQuery.proxy(function () { // check if autoslider is set to be running if (this.autosliding === null) return; // check options on runtime if autoslider should be stopped if(this.conf.autoslideStopOnHover) [call]this.stopAutoSlide(false); else if(this.conf.autoslidePauseOnHover) [call]this.stopAutoSlide(true); }, this), // @@@ EO event: mouse in @@@ // @@@ event: mouse out @@@ jQuery.proxy(function () { // only do something if slider is paused if (this.autosliding !== false) return; // maybe use special timeout for resume auto slide var timeout = this.conf.autoslideResumeDelay != false ? this.conf.autoslideResumeDelay : this.conf.autoslideDelay; // restart autoslide on mouse out with optional timeout if(this.conf.autoslidePauseOnHover) [call]this.startAutoSlide(timeout); }, this) // @@@ EO event: mouse out @@@ ); // EO hover }); // @@@ EO plugin: ready @@@ // start is defered after ready prototype.plugin('swipeStart', function() { // XXX - implement this properly this.backup = this.autosliding; if (this.autosliding) { [call]this.stopAutoSlide(true); } }); prototype.plugin('swipeStop', function() { if (this.backup) { [call]this.startAutoSlide(); } }); // @@@ EO _init @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable plugin panelInfoBox: true }); // EO extend config }); // @@@ EO plugin: config @@@ // @@@ private fn: toggleInfoBox @@@ function toggleInfoBox (opacity, duration, position) { // create closure var slider = this; // check if feature is enabled if (!this.conf.panelInfoBox) return; // check if queue is empty // if (slider.queue.length == 0) // { // get all panels for the current slide var panels = [call]slider.getPanelsBySlide(position); // animate infoboxes of all panels by position jQuery('DIV.info', panels).each(function () { // get local jQuery object var infobox= jQuery(this); // only animate if opacity is about to change if ([call]infobox.css('opacity') != opacity) { // animate info box [call]infobox.animate({ // animate opacity opacity: opacity }, { // animation duration duration: duration, // unlock on complete complete: [call]slider.lock() }) // EO animate } // EO if opacity changes }); // EO each panel // } // EO if empty queue } // @@@ EO private fn: toggleInfoBox @@@ // @@@ plugin: swipeMove @@@ prototype.plugin('swipeMove', function(x, y, data) { // check if feature is enabled if (!this.conf.panelInfoBox) return; // check if the position actually has changed if (this.position == data.swipeStartPosition) return; // hide the box very fast // we will be swiping around [call]toggleInfoBox.call(this, 0, 300, data.swipeStartPosition); }); // @@@ EO plugin: swipeMove @@@ // @@@ plugin: abortAnimation @@@ prototype.plugin('abortAnimation', function() { // check if feature is enabled if (!this.conf.panelInfoBox) return; // abort the info box animations (if running) jQuery('DIV.info', this.panels).stop(true, true); }); // @@@ EO plugin: abortAnimation @@@ // show info boxes after the main animation ended (aquire locks) prototype.plugin('postAnimation', function() { [call]toggleInfoBox.call(this, 1, 700, this.position) }) // hide info boxes before the main animation started (aquire locks) prototype.plugin('preAnimation', function() { [call]toggleInfoBox.call(this, 0, 700, this.position) }) // @@@ plugin: ready @@@ prototype.plugin('ready', function() { // check if feature is enabled if (!this.conf.panelInfoBox) return; // first hide all infoboxes in all panels jQuery('DIV.info', this.panels).css({ 'opacity' : 0 // , 'zoom': 1 }); // get all panels for the current slide var panels = [call]this.getPanelsBySlide(this.position); // init the current panel infoboxes to be shown jQuery('DIV.info', panels).css({ 'opacity' : 1 // , 'zoom': 1 }); }, - 9); // @@@ EO plugin: ready @@@// EO extend class prototype; 'use strict'; /* This function is used to calculate the speed when the user releases the mouse or swipe gesture. We record the positions of the points and the timestamp, then this function calculates the average speed. http://en.wikipedia.org/wiki/Least_squares http://pcbheaven.com/wikipages/The_Least_Squares_Fitting/ */ var LeastSquaresFitting = function (points, scale) { // no result if less than 2 points given if (points.length < 2) return [0, 0]; // get a timestamp from current time var timestamp = points[0][2]; // declare variables to calculate the sums var sum_x = 0, sum_y = 0, sum_xy = 0, sum_xx = 0; for (var i = 0, l = points.length; i < l; i++) { var y = points[i][0] / scale, x = points[i][2] - timestamp; sum_x += x; sum_xx += x * x; sum_y += y; sum_xy += x * y; } var m = (l * sum_xy - sum_x * sum_y) / (l * sum_xx - sum_x * sum_x); var n = (sum_y * sum_xx - sum_x * sum_xy) / (l * sum_xx - sum_x * sum_x); if (isNaN(m)) console.log(sum_x, sum_xx, sum_y, sum_xy, points); return [m, n]; }; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // status variable this.swipe = false; // add defaults extend({ // pixel offset before fixing direction // from then on we either scroll or swipe swipeThreshold : 5 }); }); // @@@ EO plugin: config @@@ // @@@ plugin: swipeStart @@@ prototype.plugin('swipeStart', function (x, y, data) { // pause autoslider if it's active at the moment if (this.autoSlidePause) this.autoSlidePause(); // assert that, when swiping is given, animation lock is set // if (this.locked & !this.animation) alert('invalid status'); // lock the animations this.animation = true; // store last moves data.swipeMoves = []; // store swiped position data.swipePosOff = 0; // init direction status variables data.swipeDrag = data.swipeScroll = false; // store the start positions for this swipe data.swipeStartDrag = data.swipeX = x; data.swipeStartScroll = data.swipeY = y; data.dragOff = 0; // remember start position data.swipeStartPosition = this.position; // get viewport offset var vp_off = [call]this.getViewportOffset(); var offset = this.ct_off + x - vp_off.x; data.vp_off = vp_off.x; // get the position where the drag has been started / initiated (point of interest) data.swipeStartDragPos = [call]this.getPositionByOffset(offset); data.swipeStartPositionOff = [call]this.getOffsetByPosition(this.position) - offset; // we are now going to swipe this.locked = true; // abort all other animations [event]this.trigger('abortAnimation'); }); // @@@ EO plugin: swipeStart @@@ // @@@ plugin: swipeDraw @@@ prototype.plugin('swipeDraw', function (data) { // get the real offset for the given position (might be "out of bound") var offset = [call]this.getOffsetByPosition(this.position, true) + data.dragOff; // calculate real position by real offset var position = [call]this.getPositionByOffset(offset, true); // keep track of real position dragging data.swipePosOff += position - this.position; // now set to new position // position will be normalized [call]this.setPosition(position); // reset pixel offset data.dragOff = 0; }) // @@@ EO plugin: swipeDraw @@@ // @@@ plugin: swipeMove @@@ prototype.plugin('swipeMove', function (x, y, data, dx, dy) { this.swiping = true; // get from data into local variable // usefull for performance and minimizing var moves = data.swipeMoves; // store current swipe position data.swipeX = x; data.swipeY = y; data.dragOff += dx; // try to determine the prominent axis for this swipe movement if (data.swipeDrag == false & data.swipeScroll == false) { // threshold to determine/fix direction var threshold = this.conf.swipeThreshold; // check if there was an initial minimum amount of movement in some direction if (Math.abs(data.swipeStartDrag - x) > threshold) { data.swipeDrag = true; } else if (Math.abs(data.swipeStartScroll - y) > threshold) { data.swipeScroll = true; } } // check if this move is going into another direction then before // ToDo: Could also add a threshold that a small back move will be tolerated var length = moves.length; if (length > 2) { if (moves[length-2][0] < moves[length-1][0] & moves[length-1][0] > x) { moves.length = 0; } else if (moves[length-2][0] > moves[length-1][0] & moves[length-1][0] < x) { moves.length = 0; } } // do not record to many steps (memory usage) if (moves.length > 50) moves.shift(); // push the coordinates with timestamp to our data array moves.push([x, y, (new Date()).getTime()]); // abort this event if not dragging if (!data.swipeDrag) return true; this.trigger('swipeDraw', data); // return false if dragging return ! data.swipeDrag; }); // @@@ EO plugin: swipeMove @@@ // @@@ private fn: snap @@@ function snap(val, grid, base) { // assertion for optional values grid = grid || 1; base = base || 0; // snap the value to the grid, regarding to its base return grid * Math.round((val - base) / grid) + base; } // @@@ EO private fn: snap @@@ // @@@ private fn: getFinalOffset @@@ function getFinalOffset (start, off, inertia) { // get number of panels visible at once var vis = Math.floor(this.conf.panelsVisible); // config value if we are grouping panels // this means we treat them as one panel if (!this.conf.groupPanels) vis = 1; // create the main position anchor // all motions are aligned to this var anchor = [call]snap(start, 1); // get the end position without any snapping // this is where the swipe plus inertia would go var real_position = start + off + inertia; // snap the final position to the anchor by a grid // defined by the number of visible panels. This may // should only be done if we are grouping panels! var final_position = [call]snap(real_position, vis, anchor); // calculate offset from current position // start and off are already in that value var offset = final_position - off - start; // return result return offset; } // @@@ EO private fn: getFinalOffset @@@ // @@@ plugin: swipeStop @@@ prototype.plugin('swipeStop', function (x, y, data) { // abort all other animations [event]this.trigger('abortAnimation'); // get from data into local variable // usefull for performance and minimizing var moves = data.swipeMoves; // first call swipe move to do some work this.trigger('swipeMove', x, y, data, 0, 0); // clear swipe draw timer [call]this.undefer('swipeDraw'); // get a timestamp from current time var timestamp = (new Date()).getTime(); // get the limiting timestamp for moves var limit = timestamp - 500; // get number of panels visible at once var vis = Math.floor(this.conf.panelsVisible); // remove all moves that happend before our limit while (moves.length & moves[0][2] < limit) moves.shift(); // get fitted linear function parameters var least = LeastSquaresFitting(moves, this.vp_x / 2); // linear fn -> y = m*x + n var m = least[0] * this.vp_x / 2, n = least[1]; // get absolute speed var speed = Math.abs(m); // direction of the movement var direction = m < 0 ? - 1 : 1; // get the inertia of the swipe movement (maybe improve this more) var inertia = Math.pow(speed * 0.5 * vis, 0.5) * - direction; // call private function to calculate the actual real offset for final animation var offset = [call]getFinalOffset.call(this, data.swipeStartPosition, data.swipePosOff, inertia) // unlock slider this.locked = false; // abort all other animations [event]this.trigger('abortAnimation'); // first call swipe move to do some work this.trigger('swipeFinish', x, y, data); var duration = 0, easing = 'linear', delta = Math.abs(offset); if (delta > 0.5) { easing = speed < 0.375 ? 'easeOutBounce' : 'easeOutExpo'; duration = Math.max(Math.min(100 / Math.pow(1/speed, 1.5), 9000), 1200); } else if (delta > 0) { easing = speed < 0.375 ? 'easeOutBounce' : 'easeOutExpo'; duration = Math.max(Math.min(100 / Math.pow(1/speed, 1.5), 2000), 600); } // account for the distance left to go (shorten duration if not much to do) // if (speed > 0.375) duration *= Math.abs(this.position - this.slide2slide(to)); var swipeDrag = data.swipeDrag; // data.dragOff = 0; // data.scrollOff = 0; delete data.swipeDrag; delete data.swipeScroll; data.swipeMoves = []; // make offset value explicitly relative offset = offset < 0 ? offset : '+' + offset [call]this.animate(offset, duration, easing, function () { this.foobar = false; this.swiping = false; }, true); // return false if dragging return ! swipeDrag; }); // @@@ EO plugin: swipeStop @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable touch swipes gestureSwipe : false }); }); // @@@ EO plugin: config @@@ // @@@ private fn: stop_handler @@@ var stop_handler = function (data, evt) { // return without aborting the event if (!this.conf.gestureSwipe) return true; // retrieve from event var finger = evt.finger, gesture = evt.gesture; // normalize drag/scroll variable var vertical = this.conf.vertical, swipe = vertical ? finger.y : finger.x, scroll = vertical ? finger.x : finger.y; // call swipe start handler with coordinates this.trigger('swipeStop', swipe, scroll, data); } // @@@ EO private fn: stop_handler @@@ // @@@ private fn: move_handler @@@ var move_handler = function (data, evt) { // return without aborting the event if (!this.conf.gestureSwipe) return true; // retrieve from event var finger = evt.finger, gesture = evt.gesture; // normalize drag/scroll variable var vertical = this.conf.vertical, swipe = vertical ? finger.y : finger.x, scroll = vertical ? finger.x : finger.y, swipeOff = vertical ? evt.dy : evt.dx, scrollOff = vertical ? evt.dx : evt.dy; // call swipe start handler with coordinates this.trigger('swipeMove', swipe, scroll, data, swipeOff, scrollOff); if(!data.swipeDrag) { evt.stopPropagation(); return; } if(!this.conf.carousel) { // console.log(this.viewport.get(0).id, swipe, data.position, this.position); if (data.position === this.position & (this.position == 0 || this.position == this.smax)) { // data.swipeStartDrag = swipe; // data.swipeStartScroll = scroll; // delete data.swipeFirstDrag; } else { // console.log('stop'); evt.stopPropagation(); } } else { evt.stopPropagation(); } // remember last position data.position = this.position; } // @@@ EO private fn: move_handler @@@ // @@@ private fn: start_handler @@@ var start_handler = function (data, evt) { // return without aborting the event if (!this.conf.gestureSwipe) return true; // retrieve from event var finger = evt.finger, gesture = evt.gesture; // normalize drag/scroll variable var vertical = this.conf.vertical, swipe = vertical ? finger.y : finger.x, scroll = vertical ? finger.x : finger.y; // call swipe start handler with coordinates this.trigger('swipeStart', swipe, scroll, data); } // @@@ EO private fn: start_handler @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function () { // shared data var data = {}; // setup viewport this.viewport // enable gestures .gesture({ native: { panY : ! this.conf.vertical, panX : !! this.conf.vertical } }) .bind('handmove', function (evt) { // evt.stopPropagation(); // evt.preventDefault(); }) // bind event listeners and create instance closures .bind('handstop', jQuery.proxy(stop_handler, this, data)) .bind('handmove', jQuery.proxy(move_handler, this, data)) .bind('handstart', jQuery.proxy(start_handler, this, data)) .bind('handstart', function (evt) { if (evt.gesture.fingers == 0) { // evt.stopPropagation(); } if (evt.gesture.fingers == 1) { evt.preventDefault(); } }) }); // @@@ EO plugin: ready @@@// EO extend class prototype; 'use strict'; // declare here for compiler var prefix = 'rtp-toolbar'; // define all toggle buttons var toggler = { // define function to define if state is on stop : function () { return this.autosliding === null; }, pause : function () { return ! this.autosliding; } }; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable feature navToolbar: false, // toolbar: 'first, rewind, pause, stop, play, toggle-stop, toggle-pause, forward, last' navToolbarButtons: this.conf.carousel ? 'rewind, toggle-stop, toggle-pause, forward' : 'first, rewind, toggle-stop, toggle-pause, forward, last', // add templates tmpl : { navButtonWrapper: ['<a href="javascript:void(0);">', '</a>'], navButton: '<img src="img/rtp-toolbar-{type}.gif" width="12" height="12" alt="{title}"/>' } }); }); // @@@ EO plugin: config @@@ // @@@ plugin: init @@@ prototype.plugin('init', function () { // create closure var self = this; // store the buttons self.buttons = {}; // function for the button actions function action (command) { switch (command) { // navigation commands case 'last': [call]this.goLast(); break; case 'first': [call]this.goFirst(); break; case 'rewind': [call]this.goPrev(); break; case 'forward': [call]this.goNext(); break; // auto slide show commands case 'play': [call]this.startAutoSlide(); break; case 'stop': [call]this.stopAutoSlide(false); break; case 'pause': [call]this.stopAutoSlide(true); break; // toggle pause/play case 'toggle-pause': if (!toggler.pause.call(this)) { [call]this.stopAutoSlide(true); } else { [call]this.startAutoSlide(); } break; // toggle stop/play case 'toggle-stop': if (!toggler.stop.call(this)) { [call]this.stopAutoSlide(false); } else { [call]this.startAutoSlide(); } break; } } // EO fn action // check if the feature is activated and configured if (self.conf.navToolbar & self.conf.navToolbarButtons) { // get all buttons for the toolbar var buttons = self.conf.navToolbarButtons.split(/\s*,\s*/), nodes = []; // create the wrapper around all toolbar buttons var wrapper = jQuery('<div class="' + prefix + '">'); // now create all configured buttons for (var i = 0, l = buttons.length; i < l; i++) { // create the button node var button = jQuery( '<span class="' + prefix + '-' + buttons[i] + '">' + self.tmpl.navButtonWrapper[0] + self.tmpl.navButton .replace(/{title}/g, buttons[i]) .replace(/{type}/g, buttons[i].replace('toggle-', '')) + self.tmpl.navButtonWrapper[1] + '</span>' ) // attach click handler to the button .click(jQuery.proxy(action, self, buttons[i])); // add button to the outer wrapper node wrapper.append(self.buttons[buttons[i]] = button); // find and store all button images button.imgs = button.find('IMG'); } // store the toolbar wrapper self.toolbarWrapper = wrapper; // append wrapper to the main slider wrapper self.toolbarWrapper.appendTo(self.wrapper); } // EO if conf.navToolbar }); // @@@ EO plugin: init @@@ // @@@ private fn: updateToggleButtons @@@ function updateToggleButtons () { // check if the feature is activated and configured if (this.conf.navToolbar & this.conf.navToolbarButtons) { // process all toggle buttons for(var type in toggler) { // get value if feature is enabled var enabled = toggler[type].call(this); // get the images previousely stored var imgs = this.buttons['toggle-' + type].imgs; // process all button images var i = imgs.length; while (i--) { // get the current image src var src = imgs[i].src.replace( enabled ? type : 'play', enabled ? 'play' : type ); // check if src has changed if (src != imgs[i].src) { imgs[i].src = src; } } // EO each image } // EO each toggler } // EO if conf.navToolbar } // @@@ EO private fn: updateToggleButtons @@@ // plug into various events to update buttons [call]prototype.plugin('ready', updateToggleButtons); [call]prototype.plugin('autoslideStop', updateToggleButtons); [call]prototype.plugin('autoslideStart', updateToggleButtons); [call]prototype.plugin('autoslidePause', updateToggleButtons);// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable plugin adjustTabIndex: true }); // EO extend config }); // @@@ EO plugin: config @@@ // @@@ plugin: ready @@@ prototype.plugin('ready', function () { // check if feature is enabled if (!this.conf.adjustTabIndex) return; // fetch all links within the slides var i = this.slides.length; while (i --) { var slide = jQuery(this.slides[i]); slide.data('links', jQuery('A', slide)) } // first disable all links in all panels // links in cloned panels are never selectable jQuery('A', this.panels).attr('tabindex', '-1'); }); // @@@ EO plugin: ready @@@ // @@@ plugin: changedSlideVisibility @@@ prototype.plugin('changedSlideVisibility', function (slide, visible) { // check if feature is enabled if (!this.conf.adjustTabIndex) return; // reset the tabindex for all links in this slide jQuery(slide).data('links').attr('tabindex', visible ? '' : '-1'); }); // @@@ EO plugin: changedSlideVisibility @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // when is a slide visible // how visible has it to be withinThreshold : 0.995 }); // store per slide this.within = []; }); // @@@ EO plugin: config @@@ // @@@ plugin: changedVisibility @@@ prototype.plugin('changedVisibility', function (visibility, sv) { // process all slides, array must have // same length as all registered slides var i = visibility.length; while (i--) { // get the previous value var prev = this.within[i]; // get status if slide is visible (int for array access) var vis = visibility[i] > this.conf.withinThreshold ? 1 : 0; // check is status has changed if (vis != prev) { // store new status this.within[i] = vis; // emit an event to inform that this slide visibility has changed this.trigger('changedSlideVisibility', this.slides[i], vis, prev); } // EO if state changed } // EO each slide }); // @@@ EO plugin: changedVisibility @@@// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable plugin progressBar: false, // position of the dom nodes // we only need the first char // valid: prepend, append, both progressBarPosition: 'append', // templates fragments tmpl : { 'progress-bar-append' : '<div class="rtp-progress-bar-append"></div>', 'progress-bar-prepend' : '<div class="rtp-progress-bar-prepend"></div>' }, // classes to assign klass : { 'progress-bar' : 'rtp-progress-bar' } }); // EO extend config }); // @@@ EO plugin: config @@@ // @@@ css @@@ function css(value) { if (this.conf.vertical) { return { height : value }; } else { return { width : value }; } } // @@@ EO css @@@ // @@@ stopProgressBar @@@ function stopProgressBar () { // prevent early calls if (!this.progressbar) return; // stop previous animation this.progressbar .stop(true) .css( [call]css.call(this, '0%') ); } // @@@ EO stopProgressBar @@@ // @@@ startProgressBar @@@ function startProgressBar (delay) { // prevent animation if (!delay) return; // prevent early calls if (!this.progressbar) return; // stop previous animation [call]stopProgressBar.call(this); // animate progressbar this.progressbar .stop(true) .css( [call]css.call(this, '0%') ) .animate( [call]css.call(this, '100%'), delay ) } // @@@ EO startProgressBar @@@ // @@@ plugin: init @@@ prototype.plugin('init', function() { // create closure var self = this; // activate autoslide if (self.conf.progressBar) { // create the progress bar jQuery collection var progressbar = jQuery(); // get the configured position for progress bar (first char lowercase) var position = this.conf.progressBarPosition.substr(0,1).toLowerCase(); // check if we should prepend the progress bar if (position == 'p' || position == 'b') { // create the progress bar dom node var node = jQuery( this.tmpl['progress-bar-prepend'], this.tmpl['progress-bar'] ); // add this node the jQuery collection progressbar = progressbar.add(node); // prepend node to the wrapper this.wrapper.prepend(node); } // EO if prepend // check if we should prepend the progress bar if (position == 'a' || position == 'b') { // create the progress bar dom node var node = jQuery( this.tmpl['progress-bar-append'] || this.tmpl['progress-bar'] ); // add this node the jQuery collection progressbar = progressbar.add(node); // append node to the wrapper this.wrapper.append(node); } // EO if append // store object to slide instance this.progressbar = progressbar; // add our standard class name to dom nodes progressbar.addClass(this.conf.klass['progress-bar']) // call the stop function [call]stopProgressBar.call(this); } // EO if conf.progressBar }); // @@@ plugin: init @@@ // hook into various change events to adjust progress bars [call]prototype.plugin('autoslideWaitStop', stopProgressBar); [call]prototype.plugin('autoslideWaitStart', startProgressBar);// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable plugin tiles: false, // how many tiles for animations tileRows: 1, tileCols: 1, // how many tiles should animate at once tileRowsAtOnce: 1, tileColsAtOnce: 1, // from where should tile animation start tileDimOrigin: 0.5, tileOppOrigin: 0.5 }); // EO extend config }); // @@@ EO plugin: config @@@ // @@@ plugin: config @@@ prototype.plugin('ready', function (extend) { if (!this.conf.tiles) return; this.rows = []; this.cols = []; this.tiles = []; // @@@ private fn: getOffsetCssStr @@@ function getOffsetCssStr (invert) { // get the reverse option from config var reverse = this.conf.offsetReverse; // return the string according to options return this.conf.vertical ^ invert ? (reverse ? 'marginBottom' : 'marginTop') : (reverse ? 'marginRight' : 'marginLeft'); } // @@@ EO private fn: getOffsetCssStr @@@ // seems like __proto__ does not always work? // first found in mobile IE and fader example! var oldSetPosition = this.setPosition; this.setPosition = function(value) { if (!this.conf.tiles) return oldSetPosition.apply(this, arguments) if (!this.animation || !this.animation.fader) return oldSetPosition.apply(this, arguments); if (Math.floor(value) === parseInt(value)) { if (this.animation.fader) { this.animation.restore(); } return oldSetPosition.call(this, parseInt(value)); } } var oldGetContainerOffset = this.getContainerOffset; // @@@ overload method: getContainerOffset @@@ this.getContainerOffset = function(invert) { if (!this.conf.tiles) return oldGetContainerOffset.apply(this, arguments) if (typeof this.ct_off != "undefined") return this.ct_off; // return a float number from the container offset return - (parseFloat([call]this.container.css([call]getOffsetCssStr.call(this, invert)), 10) || 0) } // @@@ EO overload method: getContainerOffset @@@ var oldSetContainerOffset = this.getContainerOffset; // @@@ overload method: setContainerOffset @@@ this.setContainerOffset = function(offset, invert) { if (!this.conf.tiles) return oldSetContainerOffset.apply(this, arguments) // search position to clamp container to var i = this.offset.length; while(i--) { if (this.offset[i] <= offset) break; } // set the offset position of the container to the viewport [call]this.container.css([call]getOffsetCssStr.call(this, invert), - this.offset[i]); var visibility = [], value = this.position; // fake the visibility for nav dots etc if (Math.floor(value) === parseInt(value) & !this.swiping) { for (var i = 0; i < this.slides.length; i++) { visibility[i] = i == value ? 1 : 0; } this.sv = visibility; this.trigger('foobarVisibility', visibility); } // update internal variable // needed to calc visibilities this.ct_off = offset; } // @@@ EO overload method: setContainerOffset @@@ var oldGetOffsetByPosition = this.getContainerOffset; // @@@ overload method: getOffsetByPosition @@@ this.getOffsetByPosition = function (index) { if (!this.conf.tiles) return oldGetOffsetByPosition.apply(this, arguments) return [call]prototype.getOffsetByPosition.call(this, index) } // @@@ EO overload method: getOffsetByPosition @@@ for(var i = 0; i < this.slides.length; i++) { jQuery(this.slides[i]).addClass('rtp-slider-slide-' + i); } var fader = jQuery('<div class="rtp-slider-fader">'); for(var i = 0; i < this.conf.tileRows; i++) { var cols = [], tiles = [], row = jQuery('<div class="row row-' + i + '">'); for(var n = 0; n < this.conf.tileCols; n++) { var col = jQuery('<div class="col col-' + n + '">'); var tile = jQuery('<div class="tile tile-' + i + '-' + n + '">'); row.append(col) col.append(tile); cols.push(col); tiles.push(tile); } fader.append(row) this.rows.push(row); this.cols.push(cols); this.tiles.push(tiles); } jQuery(this.viewport).append(fader); this.fader = fader; [call]fader.css({ 'top' : '0px', 'left' : '0px', 'right' : '0px', 'bottom' : '0px', 'position' : 'absolute' }); }, -9999); // @@@ EO plugin: config @@@ function layout() { if (!this.conf.tiles) return; var off_y = 0, conf = this.conf, rows = this.rows, cols = this.cols, tiles = this.tiles, y = this.vp_y / conf.tileRows, x = this.vp_x / conf.tileCols; for (var i = 0; i < conf.tileRows; i ++) { var off_x = 0; var width = x + 'px'; var height = y + 'px'; if (conf.tileCols == 1) width = '100%'; if (conf.tileRows == 1) height = '100%'; rows[i].css({ 'left' : '0px', 'right' : '0px', 'width' : 'auto', 'height' : height, 'top' : off_y + 'px', 'overflow' : 'hidden', 'position' : 'absolute' }); for (var n = 0; n < conf.tileCols; n ++) { cols[i][n].css({ 'left' : off_x + 'px', // 'width' : x + 'px', 'height' : 'auto', 'top' : '0px', 'bottom' : '0px', 'overflow' : 'hidden', 'position' : 'absolute' }) if (this.position == Math.floor(this.position)) { } tiles[i][n].css({ 'width' : this.vp_x * 2, 'height' : this.vp_y * 2, 'marginTop' : - off_y, 'marginLeft' : - off_x }) jQuery('.rtp-slider-panel', tiles[i][n]).css({ 'float' : 'none', // 'width' : '100%', // 'height' : '100%', 'opacity' : '1' }); off_x += x; } off_y += y; } } function change(position, part) { if (!this.conf.tiles) return; var width = this.vp_x / this.conf.tileCols; var height = this.vp_y / this.conf.tileRows; var off_y = 0, y = this.vp_y / this.conf.tileRows, x = this.vp_x / this.conf.tileCols; for (var i = 0; i < this.conf.tileRows; i ++) { var off_x = 0; for (var n = 0; n < this.conf.tileCols; n ++) { // the simples swipe through // one start when other ends // var d_w = 1 / this.conf.tileCols, s_w = d_w * n; // distribute it from the left/top var d_w = 1 / this.conf.tileCols * this.conf.tileColsAtOnce, s_w = this.conf.tileCols == 1 ? 0 : (1 - d_w) / (this.conf.tileCols - 1) * n; var d_h = 1 / this.conf.tileRows * this.conf.tileRowsAtOnce, s_h = this.conf.tileRows == 1 ? 0 : (1 - d_h) / (this.conf.tileRows - 1) * i; var prog_w = (part - s_w) / (d_w); prog_w = Math.max(0, Math.min(1, prog_w)); var prog_h = (part - s_h) / (d_h); prog_h = Math.max(0, Math.min(1, prog_h)); var align_h = this.conf.tileOppOrigin || 0, align_w = this.conf.tileDimOrigin || 0; this.cols[i][n].css({ // 'opacity' : part, 'width' : width * prog_w + 'px', 'height' : height * prog_h + 'px', 'marginTop' : align_h * height * (1 - prog_h) + 'px', 'marginLeft' : align_w * width * (1 - prog_w) + 'px' }); this.tiles[i][n].css({ 'opacity' : part, 'marginTop' : (-1 * align_h * height * (1 - prog_h) - off_y) + 'px', 'marginLeft' : (-1 * align_w * width * (1 - prog_w) - off_x) + 'px' }); off_x += x; } off_y += y; } } var first = true; // @@@ plugin: changedPosition @@@ prototype.plugin('changedPosition', function (previous) { if (!this.conf.tiles) return; var position = this.position; // get the integer via method var int_pos = parseInt(position, 10), int_prv = parseInt(previous, 10), ceil_pos = Math.ceil(position), ceil_prv = Math.ceil(previous), floor_pos = Math.floor(position), floor_prv = Math.floor(previous); if (this.animation & this.animation.fader) { if (this.animation.tiles) return; this.animation.tiles = true; floor_pos = this.animation.action - 1; floor_prv = this.animation.action - 2; } if (first || floor_pos != floor_prv) { first = false; var slide_left = Math.min(floor_pos), panel_left = this.slide2panel(slide_left), panel_right = this.slide2panel(slide_left + 1); var panel = this.panels.get(panel_right), panel = jQuery(panel); this.fader.hide(); for(var i = 0; i < this.conf.tileRows; i++) { for(var n = 0; n < this.conf.tileCols; n++) { this.tiles[i][n].empty().append(panel.clone().css({ 'margin': '0' })); } } // jQuery('IMG').fixFirefox795072(); }; this.animation.restore = function() {};/* if (this.animation.fader) { var img = jQuery('IMG', this.slides[this.animation.action]); var placeholder = jQuery('<SPAN>'); this.animation.restore = function() {}; this.animation.restore = function() { placeholder.replaceWith(img) } img.replaceWith(placeholder); console.warn(img) }*/ if (Math.floor(position) != position) this.fader.show(); else this.fader.hide(); var part_pos = position - Math.floor(position); [call]change.call(this, position, part_pos) }, - 999); // @@@ EO plugin: changedPosition @@@ // @@@ plugin: layout @@@ prototype.plugin('layout', function () { [call]layout.call(this); var position = this.position; var part_pos = position - Math.floor(position); [call]change.call(this, position, part_pos); }, 0); // @@@ EO plugin: layout @@@ // @@@ private fn: alignOppInViewport @@@ function alignOppInViewport () { if (!this.conf.tiles) return; // declare local variables var align = this.conf.alignPanelOpp, // get the css attribute to set css = this.conf.vertical ? 'left' : 'top'; // check for valid number if (isNaN(align)) return; // loop all slides to setup their 3d transformation var i = this.slides.length; while (i--) { var p = this.slide2panel(i); // calculate the possible margin and multiply var margin = (this.vp_y - this.pd[1][p]) * align; // set this panel margin for direction jQuery('.rtp-slider-slide-' + i).css(css, margin + 'px'); // jQuery(this.panels[i]).css(css, margin + 'px'); } // EO all panels } // @@@ EO private fn: alignOppInViewport @@@ function changedPanelsSize() { if (!this.conf.tiles) return; // loop all slides to setup their 3d transformation var i = this.slides.length; while (i--) { var p = this.slide2panel(i); // calculate the possible margin and multiply var dim = this.pd[0][p], opp = this.pd[1][p] // set this panel margin for direction jQuery('.rtp-slider-slide-' + i, this.fader) .css({ 'width': dim + 'px', 'height': opp + 'px' }); } } // run late after the viewport opposition has been changed/updated [call]prototype.plugin('updatedViewportOpp', alignOppInViewport, 99999); [call]prototype.plugin('updatedPanelsDim', changedPanelsSize, 99999); [call]prototype.plugin('updatedPanelsOpp', changedPanelsSize, 99999); // prototype.plugin('foobarVisibility', alignOppInViewport, 99999); [call]prototype.plugin('foobarVisibility', changedPanelsSize, 9999);// EO extend class prototype; 'use strict'; // @@@ plugin: config @@@ prototype.plugin('config', function (extend) { // add defaults extend({ // enable feature carousel3d: false }); }); // @@@ EO plugin: config @@@ // conversion constants // var deg2rad = Math.PI/180; // var rad2deg = 180/Math.PI; // @@@ plugin: init @@@ prototype.plugin('init', function () { // create closures for functions // only calculate on layout update var angle, paneldim, distance; // save and store to old method (to be restored later) var oldSetOffsetByPosition = this.setOffsetByPosition; // @@@ private fn: setOffsetByPosition @@@ function setOffsetByPosition (position) { // check if feature is enabled if (!this.conf.carousel3d) { // call original method if feature is disabled return oldSetOffsetByPosition.apply(this, arguments); } // EO if feature not enabled // now calulate the rotation for this position var rotate = 360 / this.slides.length * position; var dir = this.conf.vertical ? 'X' : 'Y'; // set 3d container styles [call]this.container.css({ // rotate the 3d panel and move it aways from the 3d center // transform: 'translateZ(-' + distance + 'px) rotate' + dir + '(-' + rotate + 'deg)' transform: 'translateZ(-' + distance + 'px) rotate' + dir + '(-' + rotate + 'deg)' }); } // @@@ EO private fn: setOffsetByPosition @@@ // @@@ private fn: layout @@@ function layout () { // check if feature is enabled if (!this.conf.carousel3d) return; // declare local variables var conf = this.conf, alignPanelDim = conf.alignPanelDim, alignViewport = conf.alignViewport, panelsVisible = conf.panelsVisible; // get segment angle at center (in radians) var angle = Math.PI / this.slides.length; // calculate maxium panel dimension and take half var paneldim = Math.max.apply( Math, this.pd[0] ) / 2; // calculate the panel distances (3d) from the center distance = parseFloat(paneldim / Math.tan(angle), 10); // calculate the alignment / offset position (use panelsVisible to assume viewport) var align = panelsVisible * (alignViewport - 0.5) - alignPanelDim + 0.5 // setup 3d panels [call]this.panels.css({ // use absolute position position : 'absolute', left : '0px', right : '0px', // force anti aliasing in firefox outline: '1px solid transparent' }); // hide cloned panels this.cloned.hide(); var dir = this.conf.vertical ? 'X' : 'Y'; // loop all slides to setup their 3d transformation var l = this.slides.length, i = l; while (i--) { // get rotation for this panel var rotate = 360 / l * i + align; // set all 3d panel styles jQuery(this.slides[i]).css({ // rotate the 3d panel and move it aways from the 3d center transform: 'rotate' + dir + '(' + rotate + 'deg) translateZ( ' + distance + 'px )' }); } // EO all slides // setup 3d viewport styles [call]this.viewport.css({ // 'overflow': 'hidden', 'perspective': distance * panelsVisible / 2 }); // setup 3d container styles [call]this.container.css({ 'width': '100%', 'overflow': 'visible', 'transform-style': 'preserve-3d' }); } // @@@ EO private fn: layout @@@ // overwrite setOffsetByPosition method // do this on each instance not on prototype this.setOffsetByPosition = setOffsetByPosition; // setup the 3d carousel on layout event [call]prototype.plugin('adjustViewport', layout, - 99); }); // @@@ EO plugin: init @@@// EO extend class prototype})(RTP.Slider.prototype, jQuery);