summaryrefslogtreecommitdiffstats
path: root/doc/views/demo-callbacks.htm
blob: ade9ac181625fe254a1f022745b67284e21a442c (plain)
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
<div class="row">
    <div class="col-sm-12">

        <h3 class="pageHeading">Demo > Callbacks</h3>        

        <p>
            The directive provides 8 (eight) callbacks. Open your browser's console to see the output.
        </p>
        
        <br />

        <div 
            isteven-multi-select 
            input-model="modernBrowsers"
            output-model="outputBrowsers"
            button-label="icon name"         
            item-label="icon name maker" 
            tick-property="ticked"     
            on-open="fOpen()"                
            on-close="fClose()"
            on-item-click="fClick( data )"
            on-select-all="fSelectAll()"
            on-select-none="fSelectNone()"
            on-reset="fReset()"
            on-clear="fClear()"
            on-search-change="fSearchChange( data )"
        ></div>


        <p>&nbsp;</p>

        <div role="tabpanel">

          <!-- Nav tabs -->
          <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a data-target="#view" aria-controls="home" role="tab" data-toggle="tab">View</a></li>
            <li role="presentation"><a data-target="#controller" aria-controls="profile" role="tab" data-toggle="tab">Controller</a></li>
          </ul>

          <!-- Tab panes -->
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="view">
                <p>Define your directive:</p>
                <pre><code>&lt;div
    isteven-multi-select 
    input-model="modernBrowsers"
    output-model="outputBrowsers"
    button-label="icon name"         
    item-label="icon name maker" 
    tick-property="ticked"     
    ...
    on-open="fOpen()"                
    on-close="fClose()"
    on-item-click="fClick( data )"
    on-select-all="fSelectAll()"
    on-select-none="fSelectNone()"
    on-reset="fReset()"
    on-clear="fClear()"
    on-search-change="fSearchChange( data )"
&gt;
&lt;/div&gt;</code></pre>
            </div>
            <div role="tabpanel" class="tab-pane" id="controller">
                <p>Define your input-model:</p>
        <div class="fauxCode hljs xml">
            $scope.modernBrowsers = [
            <table>
                <tr class="hljs-tag" ng-repeat="row in modernBrowsers" >
                    <td>&nbsp;</td>
                    <td>{</td>
                    <td><span class="hljs-attribute">icon</span>: <span class="hljs-value">{{removeHost(row.icon)}}</span>,</td>
                    <td><span class="hljs-attribute">name</span>: <span class="hljs-value">{{row.name}}</span>,</td>
                    <td><span class="hljs-attribute">maker</span>: <span class="hljs-value">{{row.maker}}</span>,</td>
                    <td><span class="hljs-attribute">ticked</span>: <span class="hljs-value">{{row.ticked}}</span></td>
                    <td>}<span ng-if="$index < modernWebBrowsers.length - 1">,</span></td>
                </tr>
            </table>
            ];
        </div>  

        <p>Define your callback functions:</p>
        <pre><code>$scope.fOpen = function() {
    console.log( 'On-open' );
}

$scope.fClose = function() {
    console.log( 'On-close' );
}    

$scope.fClick = function( data ) {           
    console.log( 'On-item-click' );        
    console.log( 'On-item-click - data:' );        
    console.log( data );
}    

$scope.fSelectAll = function() {
    console.log( 'On-select-all' );
}

$scope.fSelectNone = function() {
    console.log( 'On-select-none' );
}

$scope.fReset = function() {
    console.log( 'On-reset' );
}        

$scope.fClear = function() {
    console.log( 'On-clear' );
}

$scope.fSearchChange = function( data ) {
    console.log( 'On-search-change' );
    console.log( 'On-search-change - keyword: ' + data.keyword );
    console.log( 'On-search-change - result: ' );
    console.log( data.result );
}</code></pre>            
    </div>
          </div>

        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">              
        <h5>Output model</h5>
        <p>
            Look at the <code>output-model</code> below to see the values getting updated 
            as you select / deselect an item in the directive. Icons in the objects are actually full HTML <code>img</code> tag, shortened for simplicity. 
        </p>
        <div class="fauxCode hljs xml">
            $scope.outputBrowsers = [
            <table>
                <tr class="hljs-tag" ng-repeat="row in outputBrowsers" >
                    <td>&nbsp;</td>
                    <td>{</td>
                    <td><span class="hljs-attribute">icon</span>: <span class="hljs-value">{{removeHost(row.icon)}}</span>,</td>
                    <td><span class="hljs-attribute">name</span>: <span class="hljs-value">{{row.name}}</span>,</td>
                    <td><span class="hljs-attribute">maker</span>: <span class="hljs-value">{{row.maker}}</span>,</td>
                    <td><span class="hljs-attribute">ticked</span>: <span class="hljs-value">{{row.ticked}}</span></td>
                    <td>}<span ng-if="$index < outputBrowsers.length - 1">,</span></td>
                </tr>
            </table>
            ];
        </div>                

        <h5>Learn more</h5>
        </p>
            Open the <code>/docs/js/controllers/demo-callbacks.js</code>, as well as this view 
            <code>docs/views/demo-callbacks.htm</code>to learn the code directly.
        </p>

    </div>        
</div>

<script>    
    $(document).ready(function() {
      $('pre code').each(function(i, block) {
        hljs.highlightBlock(block);
      });
    });
</script>