Subversion Repositories Integrator Subversion

Rev

Rev 207 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 espaco 1
/**
2
 * PrimeFaces Poseidon Layout
3
 */
4
PrimeFaces.widget.Poseidon = PrimeFaces.widget.BaseWidget.extend({
5
 
6
    init: function(cfg) {
7
        this._super(cfg);
8
        this.wrapper = $(document.body).children('.layout-wrapper');
9
        var $this = this;
10
 
11
        $(function() {
12
            $this._init();
13
 
14
            if (!$this.wrapper.hasClass('layout-horizontal')) {
15
                $this.restoreMenuState();
16
            }
17
        });
18
    },
19
 
20
    _init: function() {
21
        this.contentWrapper = this.wrapper.children('.layout-main');
22
        this.topbar = this.wrapper.find('.layout-topbar');
23
        this.topbarItems = this.topbar.find('.layout-topbar-actions > li.topbar-item');
24
        this.topbarLinks = this.topbarItems.children('a');
25
        this.topbarSearchItemMenu = this.topbar.find('.search-item');
26
 
27
        this.menuWrapper = this.wrapper.find('.menu-wrapper');
28
        this.menuContainer = this.menuWrapper.find('.layout-menu-container');
29
        this.menu = this.menuWrapper.find('.layout-menu');
30
        this.menuButton = this.topbar.find('.menu-button');
31
        this.menulinks = this.menu.find('a');
32
 
33
        this.profileContainer = $('.layout-profile');
34
        this.profileButton = this.profileContainer.children('.layout-profile-button');
35
        this.profileMenu = this.profileContainer.children('.layout-profile-menu');
36
 
37
        this.rightpanel = this.wrapper.find('.layout-rightpanel');
38
        this.rightpanelButton = this.topbar.find('.layout-rightpanel-button');
39
        this.rightpanelExitButton = this.rightpanel.find('.rightpanel-exit-button');
40
 
41
        this.configButton = $('#layout-config-button');
42
        this.configMenu = $('#layout-config');
43
        this.configMenuClose = this.configMenu.find('> .layout-config-content > .layout-config-close');
44
 
45
        this.bindEvents();
46
    },
47
 
48
    toggleClass: function(el, className) {
49
        if (el.hasClass(className)) {
50
            el.removeClass(className);
51
        }
52
        else {
53
            el.addClass(className);
54
        }
55
    },
56
 
57
    bindEvents: function() {
58
        var $this = this;
59
 
60
        this.bindTopbarEvents();
61
        this.bindMenuEvents();
62
        this.bindRightPanelEvents();
63
        this.bindConfigEvents();
64
 
65
        $(document.body).off('click.layoutBody').on('click.layoutBody', function() {
66
            if (!$this.menuClick) {
67
                $this.wrapper.removeClass('layout-overlay-active layout-mobile-active');
68
                $(document.body).removeClass('blocked-scroll');
69
 
70
                if ($this.isHorizontal() ) {
71
                    $this.menu.find('.active-menuitem').removeClass('active-menuitem');
72
                    $this.menuActive = false;
73
                }
74
            }
75
 
76
            if (!$this.profileMenuClick && ($this.isHorizontal())) {
77
                $this.profileContainer.removeClass('layout-profile-active');
78
            }
79
 
80
            if (!$this.topbarItemClicked) {
81
                $this.removeTopbarClassFromAllItems(null, 'active-topmenuitem', $this.topbarItems.filter('.active-topmenuitem'));
82
            }
83
 
84
            if (!$this.rightpanelClicked) {
85
                $this.wrapper.removeClass('layout-rightpanel-active');
86
            }
87
 
88
            if (!$this.configMenuClicked && $this.configMenu.hasClass('layout-config-active')) {
89
                if (!$this.wrapper.hasClass('layout-mobile-active') && !$this.wrapper.hasClass('layout-overlay-active')) {
90
                    $(document.body).removeClass('blocked-scroll');
91
                }
92
                $this.configMenu.removeClass('layout-config-active');
93
            }
94
 
95
            $this.topbarItemClicked = false;
96
            $this.rightpanelClicked = false;
97
            $this.menuClick = false;
98
            $this.profileMenuClick = false;
99
            $this.configMenuClicked = false;
100
        });
101
    },
102
 
103
    bindConfigEvents: function() {
104
        var $this = this;
105
 
106
        this.configButton.off('click.config').on('click.config', function(e) {
107
            $this.configMenuClicked = true;
108
 
109
            if ($this.configMenu.hasClass('layout-config-active')) {
110
                $this.configMenu.removeClass('layout-config-active');
111
                $(document.body).removeClass('blocked-scroll');
112
            }
113
            else {
114
                $this.configMenu.addClass('layout-config-active');
115
                $(document.body).addClass('blocked-scroll');
116
            }
117
 
118
            e.preventDefault();
119
        });
120
 
121
        this.configMenuClose.off('click.config').on('click.config', function(e) {
122
            $this.configMenu.removeClass('layout-config-active');
123
            $this.configMenuClicked = true;
124
            $(document.body).removeClass('blocked-scroll');
125
            e.preventDefault();
126
        });
127
 
128
        this.configMenu.off('click.configMenu').on('click.configMenu', function() {
129
            $this.configMenuClicked = true;
130
        });
131
    },
132
 
133
    bindMenuEvents: function() {
134
        var $this = this;
135
 
136
        this.menuWrapper.off('click.menu').on('click.menu', function() {
137
            if (!$this.profileMenuClick) {
138
                $this.menuClick = true;
139
            }
140
        });
141
 
142
        this.menuButton.off('click.menu').on('click.menu', function(e) {
143
            $this.menuClick = true;
144
 
145
            if ($this.isMobile()) {
146
                if ($this.wrapper.hasClass('layout-mobile-active')) {
147
                    $this.wrapper.removeClass('layout-mobile-active');
148
                    $(document.body).removeClass('blocked-scroll');
149
                }
150
                else {
151
                    $this.wrapper.addClass('layout-mobile-active');
152
                    $(document.body).addClass('blocked-scroll');
153
                }
154
            }
155
            else {
156
                if ($this.isStatic()) {
157
                    $this.wrapper.toggleClass('layout-static-active');
158
                    $this.saveStaticMenuState();
159
                }
160
                else {
161
                    $this.wrapper.toggleClass('layout-overlay-active');
162
                }
163
            }
164
 
165
            e.preventDefault();
166
        });
167
 
168
        this.menulinks.off('click.menu').on('click.menu', function(e) {
169
            var link = $(this),
170
            item = link.parent(),
171
            submenu = item.children('ul');
172
            horizontal = $this.isHorizontal();
173
            $this.menuClick = true;
174
 
175
            if ($this.isHorizontal() ) {
176
                submenu.css('display','');
177
 
178
                if (item.hasClass('active-menuitem')) {
179
                    if (submenu.length) {
180
                        item.removeClass('active-menuitem');
181
                        e.preventDefault();
182
                    }
183
 
184
                    if (item.parent().is($this.jq)) {
185
                        $this.menuActive = false;
186
                    }
187
                }
188
                else {
189
                    if (submenu.length > 0) {
190
                        e.preventDefault();
191
                    }
192
 
193
                    item.siblings('.active-menuitem').removeClass('active-menuitem');
194
                    item.addClass('active-menuitem');
195
 
196
                    if (item.parent().is($this.jq)) {
197
                        $this.menuActive = true;
198
                    }
199
                }
200
            }
201
            else {
202
                if(item.hasClass('active-menuitem')) {
203
                    if(submenu.length) {
204
                        item.removeClass('active-menuitem');
205
 
206
                        if(horizontal) {
207
                            if(item.parent().is($this.jq)) {
208
                                $this.menuActive = false;
209
                            }
210
                            item.removeClass('active-menuitem');
211
                        }
212
                        else {
213
                            submenu.slideUp(function() {
214
                                item.removeClass('active-menuitem');
215
                            });
216
                        }
217
                    }
218
                }
219
                else {
220
                    if (horizontal) {
221
                        $this.deactivateItems(item.siblings());
222
                        item.addClass('active-menuitem');
223
                        $this.menuActive = true;
224
                    }
225
                    else {
226
                        $this.deactivateItems(item.siblings(), true);
227
                        var groupedItems = item.parent().closest('li');
228
                        if (groupedItems && groupedItems.length > 0) {
229
                            $this.deactivateItems(groupedItems.siblings(), true);
230
                        }
231
                        $this.activate(item);
232
                        $.cookie('poseidon_menu_scroll_state', link.attr('href') + ',' + $this.menuContainer.scrollTop(), { path: '/' });
233
                    }
234
                }
235
            }
236
 
237
            if(submenu.length) {
238
                e.preventDefault();
239
            }
240
        });
241
 
242
        this.menu.find('ul').off('click.menu').on('click.menu', function() {
243
            if ($this.isHorizontal()) {
244
                $this.horizontalMenuClick = true;
245
            }
246
        });
247
 
248
        this.profileButton.off('click.profile').on('click.profile', function (e) {
249
            if (!$this.isHorizontal() ) {
250
                $this.profileContainer.toggleClass('layout-profile-active');
251
                $this.profileMenu.slideToggle();
252
            }
253
            else {
254
                $this.profileMenuClick = true;
255
 
256
                if ($this.profileContainer.hasClass('layout-profile-active')) {
257
                    $this.profileMenu.addClass('fadeOutUp');
258
 
259
                    setTimeout(function () {
260
                        $this.profileContainer.removeClass('layout-profile-active');
261
                        $this.profileMenu.removeClass('fadeOutUp');
262
                    }, 150);
263
                }
264
                else {
265
                    $this.profileContainer.addClass('layout-profile-active');
266
                    $this.profileMenu.addClass('fadeInDown');
267
                }
268
            }
269
 
270
            e.preventDefault();
271
        });
272
 
273
        this.menu.find('> li').on('mouseenter', function(e) {    
274
            if($this.isHorizontal() && $this.menuActive) {
275
                var item = $(this);
276
 
277
                if(!item.hasClass('active-menuitem')) {
278
                    $this.menu.find('.active-menuitem').removeClass('active-menuitem');
279
 
280
                    if($this.menuActive) {
281
                        item.addClass('active-menuitem');
282
                    }
283
                }
284
            }
285
        });
286
    },
287
 
288
    bindTopbarEvents: function() {
289
        var $this = this;
290
 
291
        this.topbarLinks.off('click.topbar').on('click.topbar', function(e) {
292
            var link = $(this),
293
            item = link.parent(),
294
            submenu = item.children('ul');
295
 
296
            if ($this.isMobile()) {
297
                $this.removeTopbarClassFromAllItems(null, 'active-topmenuitem', $this.topbarItems.filter('.active-topmenuitem').not(item));
298
            }
299
            else {
300
                $this.removeTopbarClassFromAllItems(item, 'active-topmenuitem');
301
            }
302
            $this.addTopbarClass(item, 'active-topmenuitem');
303
 
304
            $this.topbarItemClicked = true;
305
 
306
            if (submenu.length) {
307
                e.preventDefault();
308
            }
309
        });
310
 
311
        this.topbarSearchItemMenu.off('click.topbar').on('click.topbar', function(e) {
312
            $this.topbarItemClicked = true;
313
        });
314
    },
315
 
316
    bindRightPanelEvents: function() {
317
        var $this = this;
318
        var changeRightpanelState = function(e) {
319
            this.toggleClass(this.wrapper, 'layout-rightpanel-active');
320
 
321
            this.rightpanelClicked = true;
322
            e.preventDefault();
323
        };
324
 
325
        this.rightpanelButton.off('click.rightpanel').on('click.rightpanel', changeRightpanelState.bind(this));
326
        this.rightpanelExitButton.off('click.rightpanel').on('click.rightpanel', changeRightpanelState.bind(this));
327
 
328
        this.rightpanel.off('click.rightpanel').on('click.rightpanel', function() {
329
            $this.rightpanelClicked = true;
330
        });
331
    },
332
 
333
    activate: function(item) {
334
        var submenu = item.children('ul');
335
        item.addClass('active-menuitem');
336
 
337
        if(submenu.length) {
338
            submenu.slideDown();
339
        }
340
    },
341
 
342
    deactivate: function(item) {
343
        var submenu = item.children('ul');
344
        item.removeClass('active-menuitem');
345
 
346
        if(submenu.length) {
347
            submenu.hide();
348
        }
349
    },
350
 
351
    deactivateItems: function(items, animate) {
352
        var $this = this;
353
 
354
        for(var i = 0; i < items.length; i++) {
355
            var item = items.eq(i),
356
            submenu = item.children('ul');
357
 
358
            if(submenu.length) {
359
                if(item.hasClass('active-menuitem')) {
360
                    var activeSubItems = item.find('.active-menuitem');
361
                    item.removeClass('active-menuitem');
362
 
363
                    if(animate) {
364
                        submenu.slideUp('normal', function() {
365
                            $(this).parent().find('.active-menuitem').each(function() {
366
                                $this.deactivate($(this));
367
                            });
368
                        });
369
                    }
370
                    else {
371
                        item.find('.active-menuitem').each(function() {
372
                            $this.deactivate($(this));
373
                        });
374
                    }
375
                }
376
                else {
377
                    item.find('.active-menuitem').each(function() {
378
                        var subItem = $(this);
379
                        $this.deactivate(subItem);
380
                    });
381
                }
382
            }
383
            else if(item.hasClass('active-menuitem')) {
384
                $this.deactivate(item);
385
            }
386
        }
387
    },
388
 
389
    saveStaticMenuState: function() {
390
        if(this.isHorizontal()) {
391
            return;
392
        }
393
 
394
        if (!this.wrapper.hasClass('layout-static-active'))
395
            $.cookie('poseidon_menu_static', 'poseidon_menu_static', {path: '/'});
396
        else
397
            $.removeCookie('poseidon_menu_static', {path: '/'});
398
    },
399
 
400
    clearMenuState: function() {
401
        $.removeCookie('poseidon_menu_static', {path: '/'});
402
    },
403
 
404
    clearActiveItems: function() {
405
        var activeItems = this.jq.find('li.active-menuitem'),
406
        subContainers = activeItems.children('ul');
407
 
408
        activeItems.removeClass('active-menuitem');
409
        if(subContainers && subContainers.length) {
410
            subContainers.hide();
411
        }
412
    },
413
 
414
    clearLayoutState: function() {
415
        this.clearMenuState();
416
        this.clearActiveItems();
417
    },
418
 
419
    restoreMenuState: function () {
420
        var link = $('a[href^="' + this.cfg.pathname + '"]');
421
        var $this = this;
422
        if (link.length) {
423
            var menuitem = link.closest('li');
424
            var parentMenu = menuitem.closest('ul');
425
 
426
            menuitem.addClass('active-menuitem');
427
            if (parentMenu.length) {
428
                var parentMenuItem = parentMenu.closest('li');
429
                while (!parentMenuItem.hasClass('layout-root-menuitem')) {
224 espaco 430
// MODIFICAÇÃO PARA NÃO DEIXAR O PANEL ABERTO AO IDENTIFICAR O HREF DA PÁGINA                       
431
//                    parentMenuItem.addClass('active-menuitem');
432
//                    parentMenu.show();
207 espaco 433
 
434
                    parentMenu = parentMenuItem.closest('ul');
435
                    if (!parentMenu.length) {
436
                        break;
437
                    }
438
 
439
                    parentMenuItem = parentMenu.closest('li');
440
                }
441
 
442
                if (parentMenuItem.hasClass('layout-root-menuitem') && !parentMenuItem.closest('ul').hasClass('layout-menu')) {
443
                    parentMenuItem.addClass('active-menuitem');
444
                    parentMenu.show();
445
                }
446
            }
447
 
448
            setTimeout(function() {
449
                $this.restoreScrollState(menuitem);
450
            }, 100)
451
        }
452
 
453
        var sidebarCookie = $.cookie('poseidon_menu_static');
454
        if (sidebarCookie) {
455
            this.wrapper.removeClass('layout-static-active');
456
        }
457
    },
458
 
459
    restoreScrollState: function(menuitem) {
460
        var scrollState = $.cookie('poseidon_menu_scroll_state');
461
        if (scrollState) {
462
            var state = scrollState.split(',');
463
            if (state[0].startsWith(this.cfg.pathname) || this.isScrolledIntoView(menuitem, state[1])) {
464
                this.menuContainer.scrollTop(parseInt(state[1], 10));
465
            }
466
            else {
467
                this.scrollIntoView(menuitem.get(0));
468
                $.removeCookie('poseidon_menu_scroll_state', { path: '/' });
469
            }
470
        }
471
        else if (!this.isScrolledIntoView(menuitem, menuitem.scrollTop())){
472
            this.scrollIntoView(menuitem.get(0));
473
        }
474
    },
475
 
476
    scrollIntoView: function(elem) {
477
        if (document.documentElement.scrollIntoView) {
478
            elem.scrollIntoView();
479
        }
480
    },
481
 
482
    isScrolledIntoView: function(elem, scrollTop) {
483
        var viewBottom = parseInt(scrollTop, 10) + this.menuContainer.height();
484
 
485
        var elemTop = elem.position().top;
486
        var elemBottom = elemTop + elem.height();
487
 
488
        return ((elemBottom <= viewBottom) && (elemTop >= scrollTop));
489
    },
490
 
491
    removeTopbarClassFromAllItems: function(item, className, items) {
492
        var activeItems = item != null ? item.siblings('.' + className) : items;
493
 
494
        activeItems.removeClass(className);
495
        activeItems.children('ul').removeClass('fadeInDown');
496
    },
497
 
498
    addTopbarClass: function(item, className) {
499
        var submenu = item.children('ul');
500
 
501
        if (submenu.length) {
502
            if (item.hasClass(className)) {
503
                submenu.removeClass('fadeInDown').addClass('fadeOutUp');
504
 
505
                setTimeout(function() {
506
                    item.removeClass(className);
507
                    submenu.removeClass('fadeOutUp');
508
                }, 100);
509
            }
510
            else {
511
                item.addClass(className);
512
                submenu.addClass('fadeInDown');
513
            }
514
        }
515
    },
516
 
517
    hideTopBar: function() {
518
        var $this = this;
519
        this.topbarMenu.addClass('fadeOutUp');
520
 
521
        setTimeout(function() {
522
            $this.topbarMenu.removeClass('fadeOutUp topbar-menu-visible');
523
        },500);
524
    },
525
 
526
    isMobile: function() {
527
        return window.innerWidth <= 992;
528
    },
529
 
530
    isHorizontal: function() {
531
        return this.wrapper.hasClass('layout-horizontal') && !this.isMobile();
532
    },
533
    isStatic: function() {
534
        return this.wrapper.hasClass('layout-static') && !this.isMobile();
535
    }
536
});
537
 
538
PrimeFaces.PoseidonConfigurator = {
539
 
540
    changeLayout: function( componentTheme, darkMode ) {
541
        this.changeLayoutsTheme(darkMode);
542
        this.changeDemo(darkMode);
543
        this.changeComponentsTheme(componentTheme, darkMode);
544
        this.changeSectionTheme( darkMode, 'layout-menu');
545
        this.changeSectionTheme( darkMode , 'layout-topbar');
546
    },
547
 
548
    changeLayoutsTheme: function(darkMode) {
549
        newLayout = '-' + darkMode;
550
        var linkElement = $('link[href*="layout-"]');
551
        var href = linkElement.attr('href');
552
        var startIndexOf = href.indexOf('layout-') + 6;
553
        var endIndexOf = href.indexOf('.css');
554
        var currentColor = href.substring(startIndexOf, endIndexOf);
555
        this.replaceLink(linkElement, href.replace(currentColor, newLayout));
556
    },
557
 
558
    changeComponentsTheme: function(theme, darkMode) {
559
        theme = this.getColor(theme, darkMode);
560
        var library = 'primefaces-poseidon';
561
        var linkElement = $('link[href*="theme.css"]');
562
        var href = linkElement.attr('href');
563
        var index = href.indexOf(library) + 1;
564
        var currentTheme = href.substring(index + library.length);
565
 
566
        this.replaceLink(linkElement, href.replace(currentTheme, theme));
567
    },
568
 
569
    changeDemo: function(darkMode) {
570
        newLayout = '-' + darkMode;
571
        var linkElement = $('link[href*="demo-"]');
572
        var href = linkElement.attr('href');
573
        var startIndexOf = href.indexOf('demo-') + 4;
574
        var endIndexOf = href.indexOf('.css');
575
        var currentColor = href.substring(startIndexOf, endIndexOf);
576
 
577
        this.replaceLink(linkElement, href.replace(currentColor, newLayout));
578
    },
579
 
580
    changeMenuMode: function(menuMode) {
581
        var wrapper = $(document.body).children('.layout-wrapper');
582
        switch (menuMode) {
583
            case 'layout-static layout-static-active':
584
                wrapper.addClass('layout-static layout-static-active').removeClass('layout-overlay layout-slim layout-horizontal layout-slim-plus');
585
                this.clearLayoutState();
586
            break;
587
 
588
            case 'layout-overlay':
589
                wrapper.addClass('layout-overlay').removeClass('layout-static layout-slim layout-horizontal layout-slim-plus layout-static-active');
590
                this.clearLayoutState();
591
            break;
592
 
593
            case 'layout-horizontal':
594
                wrapper.addClass('layout-horizontal').removeClass('layout-static layout-overlay  layout-slim layout-slim-plus layout-static-active');
595
                this.clearLayoutState();
596
            break;
597
 
598
            default:
599
                wrapper.addClass('layout-static').removeClass('layout-overlay layout-slim layout-horizontal layout-slim-plus ');
600
                this.clearLayoutState();
601
            break;
602
        }
603
    },
604
 
605
    changeSectionTheme: function(theme, section) {
606
        var wrapperElement = $('.layout-wrapper');
607
        var styleClass = wrapperElement.attr('class');
608
        var tokens = styleClass.split(' ');
609
        var sectionClass;
610
        for (var i = 0; i < tokens.length; i++) {
611
            if (tokens[i].indexOf(section + '-') > -1) {
612
                sectionClass = tokens[i];
613
                break;
614
            }
615
        }
616
 
617
        wrapperElement.attr('class', styleClass.replace(sectionClass, section + '-' + theme));
618
    },
619
 
620
    beforeResourceChange: function() {
621
        PrimeFaces.ajax.RESOURCE = null;    //prevent resource append
622
    },
623
 
624
    replaceLink: function(linkElement, href) {
625
        PrimeFaces.ajax.RESOURCE = 'javax.faces.Resource';
626
 
627
        var isIE = this.isIE();
628
 
629
        if (isIE) {
630
            linkElement.attr('href', href);
631
        }
632
        else {
633
            var cloneLinkElement = linkElement.clone(false);
634
 
635
            cloneLinkElement.attr('href', href);
636
            linkElement.after(cloneLinkElement);
637
 
638
            cloneLinkElement.off('load').on('load', function() {
639
                linkElement.remove();
640
 
641
                // for dashboard
642
                setTimeout(function() {
643
                    if (window['redrawDoughnut']) {
644
                        window.redrawDoughnut();
645
                    }
646
                }, 1);
647
            });
648
        }
649
    },
650
 
651
    getColor: function(name, darkMode) {
652
        return name + '-' + darkMode;
653
    },
654
 
655
    isIE: function() {
656
        return /(MSIE|Trident\/|Edge\/)/i.test(navigator.userAgent);
657
    },
658
 
659
    changeMenuToRTL: function() {
660
        $('.layout-wrapper').toggleClass('layout-rtl');
661
    },
662
 
663
    clearLayoutState: function() {
664
        var menu = PF('PoseidonMenuWidget');
665
 
666
        if (menu) {
667
            menu.clearLayoutState();
668
        }
669
    },
670
 
671
    updateInputStyle: function(value) {
672
        if (value === 'filled')
673
            $(document.body).addClass('ui-input-filled');
674
        else
675
            $(document.body).removeClass('ui-input-filled');
676
    }
677
};
678
 
679
/*!
680
 * jQuery Cookie Plugin v1.4.1
681
 * https://github.com/carhartl/jquery-cookie
682
 *
683
 * Copyright 2006, 2014 Klaus Hartl
684
 * Released under the MIT license
685
 */
686
(function (factory) {
687
    if (typeof define === 'function' && define.amd) {
688
        // AMD (Register as an anonymous module)
689
        define(['jquery'], factory);
690
    } else if (typeof exports === 'object') {
691
        // Node/CommonJS
692
        module.exports = factory(require('jquery'));
693
    } else {
694
        // Browser globals
695
        factory(jQuery);
696
    }
697
}(function ($) {
698
 
699
    var pluses = /\+/g;
700
 
701
    function encode(s) {
702
        return config.raw ? s : encodeURIComponent(s);
703
    }
704
 
705
    function decode(s) {
706
        return config.raw ? s : decodeURIComponent(s);
707
    }
708
 
709
    function stringifyCookieValue(value) {
710
        return encode(config.json ? JSON.stringify(value) : String(value));
711
    }
712
 
713
    function parseCookieValue(s) {
714
        if (s.indexOf('"') === 0) {
715
            // This is a quoted cookie as according to RFC2068, unescape...
716
            s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
717
        }
718
 
719
        try {
720
            // Replace server-side written pluses with spaces.
721
            // If we can't decode the cookie, ignore it, it's unusable.
722
            // If we can't parse the cookie, ignore it, it's unusable.
723
            s = decodeURIComponent(s.replace(pluses, ' '));
724
            return config.json ? JSON.parse(s) : s;
725
        } catch (e) { }
726
    }
727
 
728
    function read(s, converter) {
729
        var value = config.raw ? s : parseCookieValue(s);
730
        return $.isFunction(converter) ? converter(value) : value;
731
    }
732
 
733
    var config = $.cookie = function (key, value, options) {
734
 
735
        // Write
736
 
737
        if (arguments.length > 1 && !$.isFunction(value)) {
738
            options = $.extend({}, config.defaults, options);
739
 
740
            if (typeof options.expires === 'number') {
741
                var days = options.expires, t = options.expires = new Date();
742
                t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
743
            }
744
 
745
            return (document.cookie = [
746
                encode(key), '=', stringifyCookieValue(value),
747
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
748
                options.path ? '; path=' + options.path : '',
749
                options.domain ? '; domain=' + options.domain : '',
750
                options.secure ? '; secure' : ''
751
            ].join(''));
752
        }
753
 
754
        // Read
755
 
756
        var result = key ? undefined : {},
757
            // To prevent the for loop in the first place assign an empty array
758
            // in case there are no cookies at all. Also prevents odd result when
759
            // calling $.cookie().
760
            cookies = document.cookie ? document.cookie.split('; ') : [],
761
            i = 0,
762
            l = cookies.length;
763
 
764
        for (; i < l; i++) {
765
            var parts = cookies[i].split('='),
766
                name = decode(parts.shift()),
767
                cookie = parts.join('=');
768
 
769
            if (key === name) {
770
                // If second argument (value) is a function it's a converter...
771
                result = read(cookie, value);
772
                break;
773
            }
774
 
775
            // Prevent storing a cookie that we couldn't decode.
776
            if (!key && (cookie = read(cookie)) !== undefined) {
777
                result[name] = cookie;
778
            }
779
        }
780
 
781
        return result;
782
    };
783
 
784
    config.defaults = {};
785
 
786
    $.removeCookie = function (key, options) {
787
        // Must not alter options, thus extending a fresh object...
788
        $.cookie(key, '', $.extend({}, options, { expires: -1 }));
789
        return !$.cookie(key);
790
    };
791
 
792
}));
793
 
794
if (PrimeFaces.widget.InputSwitch) {
795
    PrimeFaces.widget.InputSwitch = PrimeFaces.widget.InputSwitch.extend({
796
 
797
        init: function (cfg) {
798
            this._super(cfg);
799
 
800
            if (this.input.prop('checked')) {
801
                this.jq.addClass('ui-inputswitch-checked');
802
            }
803
        },
804
 
805
        check: function () {
806
            var $this = this;
807
 
808
            this.input.prop('checked', true).trigger('change');
809
            setTimeout(function () {
810
                $this.jq.addClass('ui-inputswitch-checked');
811
            }, 100);
812
        },
813
 
814
        uncheck: function () {
815
            var $this = this;
816
 
817
            this.input.prop('checked', false).trigger('change');
818
            setTimeout(function () {
819
                $this.jq.removeClass('ui-inputswitch-checked');
820
            }, 100);
821
        }
822
    });
823
}
824
 
825
if (PrimeFaces.widget.AccordionPanel) {
826
    PrimeFaces.widget.AccordionPanel = PrimeFaces.widget.AccordionPanel.extend({
827
 
828
        init: function (cfg) {
829
            this._super(cfg);
830
 
831
            this.headers.last().addClass('ui-accordion-header-last');
832
        }
833
    });
834
}