~alexharrington/xibo/pyclient-1.1.0a22

« back to all changes in this revision

Viewing changes to server/lib/js/layout.js

  • Committer: Alex Harrington
  • Date: 2009-12-31 11:38:50 UTC
  • Revision ID: alex@longhill.org.uk-20091231113850-bz5flhqq2gsw0qxf
Converted to 2.0 repo format and fixed lineendings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Xibo - Digitial Signage - http://www.xibo.org.uk
3
 
 * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
4
 
 *
5
 
 * This file is part of Xibo.
6
 
 *
7
 
 * Xibo is free software: you can redistribute it and/or modify
8
 
 * it under the terms of the GNU Affero General Public License as published by
9
 
 * the Free Software Foundation, either version 3 of the License, or
10
 
 * any later version. 
11
 
 *
12
 
 * Xibo is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU Affero General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Affero General Public License
18
 
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
19
 
 */
20
 
 
21
 
var region_options_callback = function(outputDiv)
22
 
{       
23
 
        //Get all the tooltip_hidden
24
 
        $(".tooltip_hidden").parent().hover(function() {
25
 
                var html = $(".tooltip_hidden",this).html();
26
 
                var left = this.offsetLeft - this.offsetParent.scrollLeft;;
27
 
                
28
 
                //Change the hidden div's content
29
 
                $('#tooltip_hover')     .html(html)
30
 
                                                        .css("left",left)
31
 
                                                        .show();
32
 
        }, function() {
33
 
                $('#tooltip_hover').hide();
34
 
        });
35
 
        
36
 
        // Make the elements draggable
37
 
        $(".timebar_ctl").draggable({
38
 
                containment: document.getElementById("timeline_ctl")
39
 
        });
40
 
        
41
 
        $(".mediabreak").droppable({
42
 
                accept: ".timebar_ctl",
43
 
                tolerance: "pointer",
44
 
                drop: function(ev, ui) {
45
 
                        orderRegion(ui.draggable, this);
46
 
                }
47
 
        });
48
 
}
49
 
 
50
 
var background_button_callback = function()
51
 
{
52
 
        //Want to attach an onchange event to the drop down for the bg-image
53
 
        var fileUrl = $('#bg_image').val();
54
 
        
55
 
        $('#bg_image_image').attr("src", "index.php?p=module&q=GetImage&file="+"tn_" + fileUrl);
56
 
}
57
 
 
58
 
var text_callback = function()
59
 
{       
60
 
        //Create the FCK editor
61
 
        var oFCKeditor = new FCKeditor( 'ta_text' ) ;
62
 
        oFCKeditor.BasePath = "3rdparty/fckeditor/" ;
63
 
        oFCKeditor.ReplaceTextarea();
64
 
 
65
 
        var regionid = $("#iRegionId").val();
66
 
        var width = $("#region_"+regionid).width();
67
 
        var height = $("#region_"+regionid).height();
68
 
        
69
 
        //Min width
70
 
        if (width < 800) width = 800;
71
 
        height = height + 75 //the width of the toolbar
72
 
        
73
 
        $('#ta_text___Frame').attr("width",width+"px");
74
 
        $('#ta_text___Frame').attr("height",height+"px");
75
 
 
76
 
        
77
 
        width = width + 50;
78
 
        height = height + 220;  
79
 
        
80
 
        $('#div_dialog').height(height+"px");
81
 
        $('#div_dialog').dialog('option', 'width', width);
82
 
        $('#div_dialog').dialog('option', 'height', height);
83
 
        $('#div_dialog').dialog('option', 'position', 'center');
84
 
        
85
 
        return false; //prevent submit
86
 
}
87
 
 
88
 
$(document).ready(function() {
89
 
        
90
 
        var container = document.getElementById('layout');
91
 
        
92
 
        $('.region').draggable({containment:container, stop:function(e, ui){
93
 
                //Called when draggable is finished
94
 
                submitBackground(this);
95
 
        }}).resizable({containment:container, minWidth:25, minHeight:25, stop:function(e, ui){
96
 
                //Called when resizable is finished
97
 
                submitBackground(this);
98
 
        }}).contextMenu('regionMenu', {
99
 
            bindings: {
100
 
                'options': function(t) {
101
 
                                XiboFormRender($(t).attr("href"));
102
 
                },
103
 
                        'deleteRegion': function(t) {
104
 
                    deleteRegion(t);
105
 
                }
106
 
                        ,
107
 
                        'setAsHomepage': function(t) {
108
 
                                var layoutid = $(t).attr("layoutid");
109
 
                                var regionid = $(t).attr("regionid");
110
 
                                
111
 
                    XiboFormRender("index.php?p=user&q=SetUserHomepageForm&layoutid="+layoutid+"&regionid="+regionid);
112
 
                }
113
 
        }
114
 
        });
115
 
        
116
 
        $('#layout').contextMenu('layoutMenu', {
117
 
                bindings: {
118
 
                        'addRegion': function(t){
119
 
                                addRegion(t);
120
 
                        },
121
 
                        'editBackground': function(t) {
122
 
                                XiboFormRender($('#background_button').attr("href"));
123
 
                        },
124
 
                        'layoutProperties': function(t) {
125
 
                                XiboFormRender($('#edit_button').attr("href"));
126
 
                        },
127
 
                        'templateSave': function(t) {
128
 
                                var layoutid = $(t).attr("layoutid");
129
 
                        
130
 
                                XiboFormRender("index.php?p=template&q=TemplateForm&layoutid="+layoutid);
131
 
                        }
132
 
                }
133
 
        });
134
 
        
135
 
        
136
 
        // Preview
137
 
        $('.region').each(function(){
138
 
        var preview = new Preview(this);
139
 
        });
140
 
 
141
 
});
142
 
 
143
 
/**
144
 
 * Adds a region to the specified layout
145
 
 * @param {Object} layout
146
 
 */
147
 
function addRegion(layout)
148
 
{
149
 
        var layoutid = $(layout).attr("layoutid");
150
 
        
151
 
        $.ajax({type:"post", url:"index.php?p=layout&q=AddRegion&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json",success: XiboSubmitResponse});
152
 
}
153
 
 
154
 
/**
155
 
 * Submits the background changes from draggable / resizable
156
 
 * @param {Object} region
157
 
 */
158
 
function submitBackground(region)
159
 
{
160
 
        var width       = $(region).css("width");
161
 
        var height      = $(region).css("height");
162
 
        var top         = $(region).css("top");
163
 
        var left        = $(region).css("left");
164
 
        var regionid = $(region).attr("regionid");
165
 
        var layoutid = $(region).attr("layoutid");
166
 
        
167
 
        $.ajax({type:"post", url:"index.php?p=layout&q=RegionChange&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json", 
168
 
                data:{"width":width,"height":height,"top":top,"left":left,"regionid":regionid},success: XiboSubmitResponse});
169
 
}
170
 
 
171
 
/**
172
 
 * Deletes a region
173
 
 */
174
 
function deleteRegion(region) {
175
 
        var regionid = $(region).attr("regionid");
176
 
        var layoutid = $(region).attr("layoutid");
177
 
 
178
 
        XiboFormRender("index.php?p=layout&q=DeleteRegionForm&layoutid="+layoutid+"&regionid="+regionid);
179
 
}
180
 
 
181
 
/**
182
 
 * Reorders the Region specified by the timebar and its position
183
 
 * @param {Object} timeBar
184
 
 * @param {Object} mediaBreak
185
 
 */
186
 
function orderRegion(timeBar, mediaBreak) {
187
 
        var timeLine = $(timeBar).parent().parent();
188
 
        
189
 
        var layoutid = timeLine.attr("layoutid");
190
 
        var regionid = timeLine.attr("regionid");
191
 
        var mediaid = $(timeBar).attr("mediaid");
192
 
        var sequence = $(mediaBreak).attr("breakid");
193
 
        
194
 
        $.ajax({type:"post", url:"index.php?p=layout&q=RegionOrder&layoutid="+layoutid+"&callingpage=layout&ajax=true", cache:false, dataType:"json", 
195
 
                data:{"mediaid":mediaid,"sequence":sequence,"regionid":regionid},success: XiboSubmitResponse});
196
 
}
197
 
 
198
 
/**
199
 
 * Handles the tRegionOptions trigger
200
 
 */
201
 
function tRegionOptions() {
202
 
        var regionid = gup("regionid");
203
 
        var layoutid = gup("layoutid");
204
 
        
205
 
        XiboFormRender('index.php?p=layout&layoutid='+layoutid+'&regionid='+regionid+'&q=RegionOptions');
206
 
}
207
 
 
208
 
 
209
 
function Preview(regionElement)
210
 
{
211
 
                
212
 
        // Load the preview - sequence 1
213
 
        this.seq = 1;
214
 
        this.layoutid = $(regionElement).attr("layoutid");
215
 
        this.regionid = $(regionElement).attr("regionid");
216
 
        this.regionElement      = regionElement;
217
 
        this.width      = $(regionElement).width();
218
 
        this.height = $(regionElement).height();
219
 
        
220
 
        var regionHeight = $(regionElement).height();
221
 
        var arrowsTop = regionHeight / 2 - 28;
222
 
        var regionid = this.regionid;
223
 
        
224
 
        this.previewElement = $('.preview',regionElement);
225
 
        this.previewContent = $('.previewContent', this.previewElement);
226
 
 
227
 
        // Setup global control tracking
228
 
        Preview.instances[this.regionid] = this;
229
 
        
230
 
        // Create the Nav Buttons
231
 
        $('.previewNav',this.previewElement)    
232
 
                .append("<div class='prevSeq' style='position:absolute; left:1px; top:"+ arrowsTop +"px'><img src='img/arrow_left.gif' /></div>")
233
 
                .append("<div class='nextSeq' style='position:absolute; right:1px; top:"+ arrowsTop +"px'><img src='img/arrow_right.gif' /></div>");
234
 
        
235
 
        // Bind the events to the Nav Buttons
236
 
        $(regionElement).hover(function(){
237
 
                //In
238
 
                $('.previewNav, .info', regionElement).fadeIn("slow");
239
 
        }, function(){
240
 
                //Out
241
 
                $('.previewNav, .info', regionElement).fadeOut("slow");
242
 
        });
243
 
        
244
 
        $('.prevSeq', $(this.previewElement)).click(function() {
245
 
                var preview = Preview.instances[regionid];
246
 
                var maxSeq      = $('#maxSeq', preview.previewContent[0]).val();
247
 
                                
248
 
                var currentSeq = preview.seq;
249
 
                currentSeq--;
250
 
                
251
 
                if (currentSeq <= 0)
252
 
                {
253
 
                        currentSeq = maxSeq;
254
 
                }
255
 
                
256
 
                preview.SetSequence(currentSeq);
257
 
        });
258
 
        
259
 
        $('.nextSeq', $(this.previewElement)).click(function() {
260
 
                var preview = Preview.instances[regionid];
261
 
                var maxSeq      = $('#maxSeq', preview.previewContent[0]).val();
262
 
                
263
 
                var currentSeq = preview.seq;
264
 
                currentSeq++;
265
 
                
266
 
                if (currentSeq > maxSeq)
267
 
                {
268
 
                        currentSeq = 1;
269
 
                }
270
 
                
271
 
                preview.SetSequence(currentSeq);
272
 
        });     
273
 
        
274
 
        this.SetSequence(1);
275
 
}
276
 
 
277
 
Preview.instances = {};
278
 
 
279
 
Preview.prototype.SetSequence = function(seq)
280
 
{
281
 
        this.seq = seq;
282
 
        
283
 
        var layoutid            = this.layoutid;
284
 
        var regionid            = this.regionid;
285
 
        var previewContent      = this.previewContent;
286
 
        var previewElement      = this.previewElement;
287
 
        var maxSeq                      = $('#maxSeq', previewContent[0]).val();
288
 
        
289
 
        this.width      = $(this.regionElement).width();
290
 
        this.height = $(this.regionElement).height();
291
 
        
292
 
        //Get the sequence via AJAX
293
 
        $.ajax({type:"post", 
294
 
                url:"index.php?p=layout&q=RegionPreview&ajax=true", 
295
 
                cache:false, 
296
 
                dataType:"json", 
297
 
                data:{"layoutid":layoutid,"seq":seq,"regionid":regionid,"width":this.width, "height":this.height},
298
 
                success:function(response) {
299
 
                
300
 
                        if (response.success) {
301
 
                                // Success - what do we do now?
302
 
                                $(previewContent).html(response.html);
303
 
                        }
304
 
                        else {
305
 
                                // Why did we fail? 
306
 
                                if (response.login) {
307
 
                                        // We were logged out
308
 
                            LoginBox(response.message);
309
 
                            return false;
310
 
                        }
311
 
                        else {
312
 
                            // Likely just an error that we want to report on
313
 
                            $(previewContent).html(response.html);
314
 
                        }
315
 
                        }
316
 
                        return false;
317
 
                }
318
 
        });
 
1
/*
 
2
 * Xibo - Digitial Signage - http://www.xibo.org.uk
 
3
 * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
 
4
 *
 
5
 * This file is part of Xibo.
 
6
 *
 
7
 * Xibo is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU Affero General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * any later version. 
 
11
 *
 
12
 * Xibo is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU Affero General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Affero General Public License
 
18
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
var region_options_callback = function(outputDiv)
 
22
{       
 
23
        //Get all the tooltip_hidden
 
24
        $(".tooltip_hidden").parent().hover(function() {
 
25
                var html = $(".tooltip_hidden",this).html();
 
26
                var left = this.offsetLeft - this.offsetParent.scrollLeft;;
 
27
                
 
28
                //Change the hidden div's content
 
29
                $('#tooltip_hover')     .html(html)
 
30
                                                        .css("left",left)
 
31
                                                        .show();
 
32
        }, function() {
 
33
                $('#tooltip_hover').hide();
 
34
        });
 
35
        
 
36
        // Make the elements draggable
 
37
        $(".timebar_ctl").draggable({
 
38
                containment: document.getElementById("timeline_ctl")
 
39
        });
 
40
        
 
41
        $(".mediabreak").droppable({
 
42
                accept: ".timebar_ctl",
 
43
                tolerance: "pointer",
 
44
                drop: function(ev, ui) {
 
45
                        orderRegion(ui.draggable, this);
 
46
                }
 
47
        });
 
48
}
 
49
 
 
50
var background_button_callback = function()
 
51
{
 
52
        //Want to attach an onchange event to the drop down for the bg-image
 
53
        var fileUrl = $('#bg_image').val();
 
54
        
 
55
        $('#bg_image_image').attr("src", "index.php?p=module&q=GetImage&file="+"tn_" + fileUrl);
 
56
}
 
57
 
 
58
var text_callback = function()
 
59
{       
 
60
        //Create the FCK editor
 
61
        var oFCKeditor = new FCKeditor( 'ta_text' ) ;
 
62
        oFCKeditor.BasePath = "3rdparty/fckeditor/" ;
 
63
        oFCKeditor.ReplaceTextarea();
 
64
 
 
65
        var regionid = $("#iRegionId").val();
 
66
        var width = $("#region_"+regionid).width();
 
67
        var height = $("#region_"+regionid).height();
 
68
        
 
69
        //Min width
 
70
        if (width < 800) width = 800;
 
71
        height = height + 75 //the width of the toolbar
 
72
        
 
73
        $('#ta_text___Frame').attr("width",width+"px");
 
74
        $('#ta_text___Frame').attr("height",height+"px");
 
75
 
 
76
        
 
77
        width = width + 50;
 
78
        height = height + 220;  
 
79
        
 
80
        $('#div_dialog').height(height+"px");
 
81
        $('#div_dialog').dialog('option', 'width', width);
 
82
        $('#div_dialog').dialog('option', 'height', height);
 
83
        $('#div_dialog').dialog('option', 'position', 'center');
 
84
        
 
85
        return false; //prevent submit
 
86
}
 
87
 
 
88
$(document).ready(function() {
 
89
        
 
90
        var container = document.getElementById('layout');
 
91
        
 
92
        $('.region').draggable({containment:container, stop:function(e, ui){
 
93
                //Called when draggable is finished
 
94
                submitBackground(this);
 
95
        }}).resizable({containment:container, minWidth:25, minHeight:25, stop:function(e, ui){
 
96
                //Called when resizable is finished
 
97
                submitBackground(this);
 
98
        }}).contextMenu('regionMenu', {
 
99
            bindings: {
 
100
                'options': function(t) {
 
101
                                XiboFormRender($(t).attr("href"));
 
102
                },
 
103
                        'deleteRegion': function(t) {
 
104
                    deleteRegion(t);
 
105
                }
 
106
                        ,
 
107
                        'setAsHomepage': function(t) {
 
108
                                var layoutid = $(t).attr("layoutid");
 
109
                                var regionid = $(t).attr("regionid");
 
110
                                
 
111
                    XiboFormRender("index.php?p=user&q=SetUserHomepageForm&layoutid="+layoutid+"&regionid="+regionid);
 
112
                }
 
113
        }
 
114
        });
 
115
        
 
116
        $('#layout').contextMenu('layoutMenu', {
 
117
                bindings: {
 
118
                        'addRegion': function(t){
 
119
                                addRegion(t);
 
120
                        },
 
121
                        'editBackground': function(t) {
 
122
                                XiboFormRender($('#background_button').attr("href"));
 
123
                        },
 
124
                        'layoutProperties': function(t) {
 
125
                                XiboFormRender($('#edit_button').attr("href"));
 
126
                        },
 
127
                        'templateSave': function(t) {
 
128
                                var layoutid = $(t).attr("layoutid");
 
129
                        
 
130
                                XiboFormRender("index.php?p=template&q=TemplateForm&layoutid="+layoutid);
 
131
                        }
 
132
                }
 
133
        });
 
134
        
 
135
        
 
136
        // Preview
 
137
        $('.region').each(function(){
 
138
        var preview = new Preview(this);
 
139
        });
 
140
 
 
141
});
 
142
 
 
143
/**
 
144
 * Adds a region to the specified layout
 
145
 * @param {Object} layout
 
146
 */
 
147
function addRegion(layout)
 
148
{
 
149
        var layoutid = $(layout).attr("layoutid");
 
150
        
 
151
        $.ajax({type:"post", url:"index.php?p=layout&q=AddRegion&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json",success: XiboSubmitResponse});
 
152
}
 
153
 
 
154
/**
 
155
 * Submits the background changes from draggable / resizable
 
156
 * @param {Object} region
 
157
 */
 
158
function submitBackground(region)
 
159
{
 
160
        var width       = $(region).css("width");
 
161
        var height      = $(region).css("height");
 
162
        var top         = $(region).css("top");
 
163
        var left        = $(region).css("left");
 
164
        var regionid = $(region).attr("regionid");
 
165
        var layoutid = $(region).attr("layoutid");
 
166
        
 
167
        $.ajax({type:"post", url:"index.php?p=layout&q=RegionChange&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json", 
 
168
                data:{"width":width,"height":height,"top":top,"left":left,"regionid":regionid},success: XiboSubmitResponse});
 
169
}
 
170
 
 
171
/**
 
172
 * Deletes a region
 
173
 */
 
174
function deleteRegion(region) {
 
175
        var regionid = $(region).attr("regionid");
 
176
        var layoutid = $(region).attr("layoutid");
 
177
 
 
178
        XiboFormRender("index.php?p=layout&q=DeleteRegionForm&layoutid="+layoutid+"&regionid="+regionid);
 
179
}
 
180
 
 
181
/**
 
182
 * Reorders the Region specified by the timebar and its position
 
183
 * @param {Object} timeBar
 
184
 * @param {Object} mediaBreak
 
185
 */
 
186
function orderRegion(timeBar, mediaBreak) {
 
187
        var timeLine = $(timeBar).parent().parent();
 
188
        
 
189
        var layoutid = timeLine.attr("layoutid");
 
190
        var regionid = timeLine.attr("regionid");
 
191
        var mediaid = $(timeBar).attr("mediaid");
 
192
        var sequence = $(mediaBreak).attr("breakid");
 
193
        
 
194
        $.ajax({type:"post", url:"index.php?p=layout&q=RegionOrder&layoutid="+layoutid+"&callingpage=layout&ajax=true", cache:false, dataType:"json", 
 
195
                data:{"mediaid":mediaid,"sequence":sequence,"regionid":regionid},success: XiboSubmitResponse});
 
196
}
 
197
 
 
198
/**
 
199
 * Handles the tRegionOptions trigger
 
200
 */
 
201
function tRegionOptions() {
 
202
        var regionid = gup("regionid");
 
203
        var layoutid = gup("layoutid");
 
204
        
 
205
        XiboFormRender('index.php?p=layout&layoutid='+layoutid+'&regionid='+regionid+'&q=RegionOptions');
 
206
}
 
207
 
 
208
 
 
209
function Preview(regionElement)
 
210
{
 
211
                
 
212
        // Load the preview - sequence 1
 
213
        this.seq = 1;
 
214
        this.layoutid = $(regionElement).attr("layoutid");
 
215
        this.regionid = $(regionElement).attr("regionid");
 
216
        this.regionElement      = regionElement;
 
217
        this.width      = $(regionElement).width();
 
218
        this.height = $(regionElement).height();
 
219
        
 
220
        var regionHeight = $(regionElement).height();
 
221
        var arrowsTop = regionHeight / 2 - 28;
 
222
        var regionid = this.regionid;
 
223
        
 
224
        this.previewElement = $('.preview',regionElement);
 
225
        this.previewContent = $('.previewContent', this.previewElement);
 
226
 
 
227
        // Setup global control tracking
 
228
        Preview.instances[this.regionid] = this;
 
229
        
 
230
        // Create the Nav Buttons
 
231
        $('.previewNav',this.previewElement)    
 
232
                .append("<div class='prevSeq' style='position:absolute; left:1px; top:"+ arrowsTop +"px'><img src='img/arrow_left.gif' /></div>")
 
233
                .append("<div class='nextSeq' style='position:absolute; right:1px; top:"+ arrowsTop +"px'><img src='img/arrow_right.gif' /></div>");
 
234
        
 
235
        // Bind the events to the Nav Buttons
 
236
        $(regionElement).hover(function(){
 
237
                //In
 
238
                $('.previewNav, .info', regionElement).fadeIn("slow");
 
239
        }, function(){
 
240
                //Out
 
241
                $('.previewNav, .info', regionElement).fadeOut("slow");
 
242
        });
 
243
        
 
244
        $('.prevSeq', $(this.previewElement)).click(function() {
 
245
                var preview = Preview.instances[regionid];
 
246
                var maxSeq      = $('#maxSeq', preview.previewContent[0]).val();
 
247
                                
 
248
                var currentSeq = preview.seq;
 
249
                currentSeq--;
 
250
                
 
251
                if (currentSeq <= 0)
 
252
                {
 
253
                        currentSeq = maxSeq;
 
254
                }
 
255
                
 
256
                preview.SetSequence(currentSeq);
 
257
        });
 
258
        
 
259
        $('.nextSeq', $(this.previewElement)).click(function() {
 
260
                var preview = Preview.instances[regionid];
 
261
                var maxSeq      = $('#maxSeq', preview.previewContent[0]).val();
 
262
                
 
263
                var currentSeq = preview.seq;
 
264
                currentSeq++;
 
265
                
 
266
                if (currentSeq > maxSeq)
 
267
                {
 
268
                        currentSeq = 1;
 
269
                }
 
270
                
 
271
                preview.SetSequence(currentSeq);
 
272
        });     
 
273
        
 
274
        this.SetSequence(1);
 
275
}
 
276
 
 
277
Preview.instances = {};
 
278
 
 
279
Preview.prototype.SetSequence = function(seq)
 
280
{
 
281
        this.seq = seq;
 
282
        
 
283
        var layoutid            = this.layoutid;
 
284
        var regionid            = this.regionid;
 
285
        var previewContent      = this.previewContent;
 
286
        var previewElement      = this.previewElement;
 
287
        var maxSeq                      = $('#maxSeq', previewContent[0]).val();
 
288
        
 
289
        this.width      = $(this.regionElement).width();
 
290
        this.height = $(this.regionElement).height();
 
291
        
 
292
        //Get the sequence via AJAX
 
293
        $.ajax({type:"post", 
 
294
                url:"index.php?p=layout&q=RegionPreview&ajax=true", 
 
295
                cache:false, 
 
296
                dataType:"json", 
 
297
                data:{"layoutid":layoutid,"seq":seq,"regionid":regionid,"width":this.width, "height":this.height},
 
298
                success:function(response) {
 
299
                
 
300
                        if (response.success) {
 
301
                                // Success - what do we do now?
 
302
                                $(previewContent).html(response.html);
 
303
                        }
 
304
                        else {
 
305
                                // Why did we fail? 
 
306
                                if (response.login) {
 
307
                                        // We were logged out
 
308
                            LoginBox(response.message);
 
309
                            return false;
 
310
                        }
 
311
                        else {
 
312
                            // Likely just an error that we want to report on
 
313
                            $(previewContent).html(response.html);
 
314
                        }
 
315
                        }
 
316
                        return false;
 
317
                }
 
318
        });
319
319
}
 
 
b'\\ No newline at end of file'