1 | $(function(){ |
---|
2 | |
---|
3 | function createStep(uid,title) { |
---|
4 | return $('<div class="displayStep"><div class="displayStepIcon"><img src="images/icons/survey.png"></img></div><p>'+title+'</p></div>') |
---|
5 | .attr("id",uid); |
---|
6 | } |
---|
7 | |
---|
8 | function createDivider() { |
---|
9 | return $('<div class="divider horizontal"></div>'); |
---|
10 | } |
---|
11 | |
---|
12 | $.widget("rft.sequencer",{ |
---|
13 | _create: function(){ |
---|
14 | this._selected = null; |
---|
15 | this._sequence = []; |
---|
16 | this._dividers = []; |
---|
17 | var el = this.element; |
---|
18 | $.get("widgets/sequencer/sequencer.html") |
---|
19 | .done(function(html){ |
---|
20 | el.html(html); |
---|
21 | }); |
---|
22 | this._wrapper = $("#seqContentWrapper"); |
---|
23 | }, |
---|
24 | addStep: function() { |
---|
25 | var self = this; |
---|
26 | var seq = this._sequence; |
---|
27 | var divs = this._dividers; |
---|
28 | var idx = seq.length; |
---|
29 | var step = createStep(idx,"Survey "+idx); |
---|
30 | step.click(function(){ |
---|
31 | self._stepClicked(step); |
---|
32 | }); |
---|
33 | if ( seq.length > 0 ) { |
---|
34 | var div = createDivider(); |
---|
35 | divs.push(div); |
---|
36 | $("#seqContentWrapper").append(div); |
---|
37 | } |
---|
38 | seq.push(step); |
---|
39 | step.appendTo($("#seqContentWrapper")); |
---|
40 | }, |
---|
41 | _stepClicked: function(step) { |
---|
42 | if ( !$.isEmptyObject(step) ) { |
---|
43 | if ( step == this._selected ) { |
---|
44 | this._selected.removeClass("selected"); |
---|
45 | this._selected = null; |
---|
46 | this._trigger("select", 0, null); |
---|
47 | } else { |
---|
48 | if ( !$.isEmptyObject(this._selected) ) { |
---|
49 | this._selected.removeClass("selected"); |
---|
50 | this._selected = null; |
---|
51 | this._trigger("select", 0, null); |
---|
52 | } |
---|
53 | step.addClass("selected"); |
---|
54 | this._selected = step; |
---|
55 | this._trigger("select", 0, step); |
---|
56 | } |
---|
57 | } |
---|
58 | }, |
---|
59 | removeStep: function(step) { |
---|
60 | |
---|
61 | }, |
---|
62 | moveLeft: function() { |
---|
63 | |
---|
64 | }, |
---|
65 | moveRight: function() { |
---|
66 | |
---|
67 | } |
---|
68 | }); |
---|
69 | |
---|
70 | }); |
---|