pattern-reader-view.js
1.8 KB
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
/* global $dj, getBusyOverlay, common */
var default_root;
var edit = {
reader: true,
changed: false,
get_id: function() {
"use strict";
return edit.active_id;
},
load_content: function(id, is_created, check_callback) {
"use strict";
$.ajaxJSON({
url: $dj.ajax_get_name,
method: 'get',
data: {
pattern_id: id
},
callback: function(data) {
common.update_hash('' + id + '/' + data.name);
}
});
$.ajaxJSON({
method: 'get',
url: $dj.ajax_pattern_preview,
dest: $('#preview'),
data: {id: id},
check_callback: check_callback,
callback: function() {
edit.busy_off();
default_root = $('.root').first().text();
}
});
edit.active_id = id;
},
// busy
busy_ctrl: null,
busy_on: function() {
"use strict";
if (!edit.busy_ctrl) {
edit.busy_ctrl = getBusyOverlay(
$('#right')[0],
{color: 'black', opacity: 0.2},
{size: 30});
}
},
busy_off: function() {
"use strict";
if (edit.busy_ctrl) edit.busy_ctrl.remove();
edit.busy_ctrl = null;
}
};
$(function() {
"use strict";
$(document).on('click', '.switch-example', function () {
var $t = $(this);
var root = $t.attr('data-example');
var active = $t.hasClass('active-example');
$('.active-example').removeClass('active-example checked');
if (active) {
$('.root').text(default_root);
} else {
$t.addClass('checked active-example');
$('.root').text(root);
}
});
});