~daker/ubuntu-html5-theme/fix.1232533

« back to all changes in this revision

Viewing changes to 0.1/ambiance/js/option-selector.js

  • Committer: daker
  • Date: 2013-12-03 00:37:28 UTC
  • Revision ID: adnane002@gmail.com-20131203003728-btrakrizy45dbc2o
Added a guard for an invalid 'optionselector' DOM node

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
    function OptionSelector (id, expanded, multiSelection) {
54
54
        this.currentlyExpanded = false;
55
 
        this.expanded = typeof expanded !== 'undefined' ? expanded : true;
56
 
        this.multiSelection = typeof multiSelection !== 'undefined' ? multiSelection : true;
 
55
        this.expanded = typeof expanded !== 'undefined' ? expanded : false;
 
56
        this.multiSelection = typeof multiSelection !== 'undefined' ? multiSelection : false;
 
57
 
 
58
        if (this.multiSelection)
 
59
            this.expanded = true;
57
60
 
58
61
        this.optionselector = document.getElementById(id);
 
62
 
 
63
        if (this.optionselector === null) {
 
64
            console.error('The OptionSelector with the ID #' + this.id + ' doesn\'t exist');
 
65
            return;
 
66
        }
 
67
 
59
68
        this.optionselector_ul = this.optionselector.querySelectorAll('ul')[0];
60
69
        this.optionselector_ul_li = this.optionselector.querySelectorAll('li');
61
70
 
68
77
        }
69
78
        else {
70
79
            if (this.currentlyExpanded) {
71
 
                console.log('messoud');
72
80
                this.__open();
73
81
                this.optionselector_ul_li[0].classList.add('active');
74
82
            } else {
75
 
                console.log('mahloul');
76
83
                this.__close(__currentIndex);
77
84
                this.optionselector_ul_li[0].classList.add('closed');
78
85
            }