| | | | 1 | //-*-coding: utf-8 -*- | 1 | //-*-coding: utf-8 -*- |
---|
2 | var a11ypi = { | | var a11ypi = { |
---|
3 | auth : " ", | | auth : " ", |
---|
4 | loc:" ", | | loc:" ", |
---|
5 | elementTagName: " ", | | elementTagName: " ", |
---|
6 | elementId: " ", | | elementId: " ", |
---|
7 | flag : 0, | | flag : 0, |
---|
8 | fflag : 0, | | fflag : 0, |
---|
9 | showbox : 0, | | showbox : 0, |
---|
10 | showlinks : 0, | | showlinks : 0, |
---|
11 | blog_flag: false, | | blog_flag: false, |
---|
12 | target : false, | | target : false, |
---|
13 | pageHtml:'', | | pageHtml:'', |
---|
14 | d: {}, | | d: {}, |
---|
15 | responseJSON:'', | | responseJSON:'', |
---|
16 | testContext : function() | | testContext : function() |
---|
17 | { | | { |
---|
18 | if(document.getElementById('social_overlay') != null) | | if(document.getElementById('social_overlay') != null) |
---|
19 | document.body.removeChild(document.getElementById('social_overlay')); | | document.body.removeChild(document.getElementById('social_overlay')); |
---|
20 | $(document).ready(function(){ | | $(document).ready(function(){ |
---|
21 | try{ | | try{ |
---|
22 | $('body *').not('iframe').contents().filter(function(){ | | $('body *').not('iframe').contents().filter(function(){ |
---|
23 | try{ | | try{ |
---|
| | 2 | //window.jQuery = window.jQuery || {}; | | | 3 | window.onload = function() { |
---|
| | 4 | yepnope([{ |
---|
| | 5 | test: window.jQuery, |
---|
| | 6 | nope:['//code.jquery.com/jquery-1.10.2.min.js'], |
---|
| | 7 | load:['//code.jquery.com/ui/1.10.3/jquery-ui.js'], |
---|
| | 8 | complete:function(){ |
---|
| | 9 | jQuery.noConflict(); |
---|
| | 10 | (function($) { |
---|
24 | | 11 | |
---|
25 | if(this.nodeType == 3 && !($(this).hasClass('alipi'))){ | | if(this.nodeType == 3 && !($(this).hasClass('alipi'))){ |
---|
26 | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} | | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} |
---|
27 | catch(err){ | | catch(err){ |
---|
28 | console.log(err); | | console.log(err); |
---|
29 | } | | } |
---|
30 | }).parent().attr('m4pageedittype','text'); | | }).parent().attr('m4pageedittype','text'); |
---|
31 | } | | } |
---|
32 | catch(e){ | | catch(e){ |
---|
33 | console.log(this); | | console.log(this); |
---|
34 | } | | } |
---|
35 | }); | | }); |
---|
| | 12 | $(function() { | | | 13 | var a11ypi = { |
---|
| | 14 | auth : " ", |
---|
| | 15 | loc:" ", |
---|
| | 16 | elementTagName: " ", |
---|
| | 17 | elementId: " ", |
---|
| | 18 | flag : 0, |
---|
| | 19 | fflag : 0, |
---|
| | 20 | showbox : 0, |
---|
| | 21 | showlinks : 0, |
---|
| | 22 | blog_flag: false, |
---|
| | 23 | target : false, |
---|
| | 24 | pageHtml:'', |
---|
| | 25 | d: {}, |
---|
| | 26 | responseJSON:'', |
---|
| | 27 | testContext : function() |
---|
| | 28 | { |
---|
| | 29 | if(document.getElementById('social_overlay') != null) |
---|
| | 30 | document.body.removeChild(document.getElementById('social_overlay')); |
---|
| | 31 | $(document).ready(function(){ |
---|
| | 32 | try{ |
---|
| | 33 | $('body *').not('iframe').contents().filter(function(){ |
---|
| | 34 | try{ |
---|
36 | | 35 | |
---|
37 | vimg = document.getElementsByTagName('img'); | | vimg = document.getElementsByTagName('img'); |
---|
38 | for(i=0; i<vimg.length; i++) | | for(i=0; i<vimg.length; i++) |
---|
39 | { | | { |
---|
40 | vimg[i].setAttribute('m4pageedittype','image'); | | vimg[i].setAttribute('m4pageedittype','image'); |
---|
41 | } | | } |
---|
42 | }, | | }, |
---|
| | 36 | if(this.nodeType == 3 && !($(this).hasClass('alipi'))){ | | | 37 | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} |
---|
| | 38 | catch(err){ |
---|
| | 39 | console.log(err); |
---|
| | 40 | } |
---|
| | 41 | }).parent().attr('m4pageedittype','text'); |
---|
| | 42 | } |
---|
| | 43 | catch(e){ |
---|
| | 44 | console.log(this); |
---|
| | 45 | } |
---|
| | 46 | }); |
---|
43 | | 47 | |
---|
44 | createMenu: function(type) { | | createMenu: function(type) { |
---|
45 | var xyz = ''; | | var xyz = ''; |
---|
46 | if(type === 're-narration') | | if(type === 're-narration') |
---|
47 | xyz = document.getElementById("show-box"); | | xyz = document.getElementById("show-box"); |
---|
48 | else | | else |
---|
49 | xyz = document.getElementById("show-comment"); | | xyz = document.getElementById("show-comment"); |
---|
50 | xyz.innerHTML = ''; | | xyz.innerHTML = ''; |
---|
51 | a = a11ypi.getParams(); | | a = a11ypi.getParams(); |
---|
52 | for(var i in a11ypi.showbox) | | for(var i in a11ypi.showbox) |
---|
53 | { | | { |
---|
54 | if(a11ypi.showbox[i]['type'] == type) | | if(a11ypi.showbox[i]['type'] == type) |
---|
55 | { | | { |
---|
56 | var para = document.createElement("p"); | | var para = document.createElement("p"); |
---|
57 | var newel = document.createElement("a"); | | var newel = document.createElement("a"); |
---|
58 | newel.textContent = a11ypi.showbox[i]['lang']; | | newel.textContent = a11ypi.showbox[i]['lang']; |
---|
59 | if(type === 're-narration') | | if(type === 're-narration') |
---|
60 | $(newel).attr("href",config.deploy+"/?foruri="+encodeURIComponent(a['foruri'])+"&lang="+a11ypi.showbox[i]['lang']+"&interactive=1"+"&type="+type); | | $(newel).attr("href",config.deploy+"/?foruri="+encodeURIComponent(a['foruri'])+"&lang="+a11ypi.showbox[i]['lang']+"&interactive=1"+"&type="+type); |
---|
61 | else | | else |
---|
62 | $(newel).attr("href",config.deploy+"/?foruri="+a['foruri']+"&tags="+a11ypi.showbox[i]['lang']+"&interactive=0"+"&type="+type); | | $(newel).attr("href",config.deploy+"/?foruri="+a['foruri']+"&tags="+a11ypi.showbox[i]['lang']+"&interactive=0"+"&type="+type); |
---|
63 | para.appendChild(newel); | | para.appendChild(newel); |
---|
64 | xyz.appendChild(para); | | xyz.appendChild(para); |
---|
65 | } | | } |
---|
66 | } | | } |
---|
67 | }, | | }, |
---|
| | 48 | vimg = document.getElementsByTagName('img'); | | | 49 | for(i=0; i<vimg.length; i++) |
---|
| | 50 | { |
---|
| | 51 | vimg[i].setAttribute('m4pageedittype','image'); |
---|
| | 52 | } |
---|
| | 53 | }, |
---|
68 | | 54 | |
---|
69 | ajax: function() { | | ajax: function() { |
---|
70 | if(a11ypi.flag == '0') | | if(a11ypi.flag == '0') |
---|
71 | { | | { |
---|
72 | a11ypi.flag = 1; | | a11ypi.flag = 1; |
---|
73 | a = a11ypi.getParams(); | | a = a11ypi.getParams(); |
---|
74 | $.getJSON(config.deploy+'/menu?', {"url":a['foruri']}, function(data) | | $.getJSON(config.deploy+'/menu?', {"url":a['foruri']}, function(data) |
---|
75 | { | | { |
---|
76 | a11ypi.showbox = data; | | a11ypi.showbox = data; |
---|
77 | $('#see-narration').show(); | | $('#see-narration').show(); |
---|
78 | // $("#blog-filter").show(); a11ypi.blogFilter(); | | // $("#blog-filter").show(); a11ypi.blogFilter(); |
---|
79 | //$("#go").show(); | | //$("#go").show(); |
---|
80 | }); | | }); |
---|
| | 55 | createMenu: function(type) { | | | 56 | var xyz = ''; |
---|
| | 57 | if(type === 're-narration') |
---|
| | 58 | xyz = document.getElementById("show-box"); |
---|
| | 59 | else |
---|
| | 60 | xyz = document.getElementById("show-comment"); |
---|
| | 61 | xyz.innerHTML = ''; |
---|
| | 62 | a = a11ypi.getParams(); |
---|
| | 63 | for(var i in a11ypi.showbox) |
---|
| | 64 | { |
---|
| | 65 | if(a11ypi.showbox[i]['type'] == type) |
---|
| | 66 | { |
---|
| | 67 | var para = document.createElement("p"); |
---|
| | 68 | var newel = document.createElement("a"); |
---|
| | 69 | newel.textContent = a11ypi.showbox[i]['lang']; |
---|
| | 70 | if(type === 're-narration') |
---|
| | 71 | $(newel).attr("href",config.deploy+"/?foruri="+encodeURIComponent(a['foruri'])+"&lang="+a11ypi.showbox[i]['lang']+"&interactive=1"+"&type="+type); |
---|
| | 72 | else |
---|
| | 73 | $(newel).attr("href",config.deploy+"/?foruri="+a['foruri']+"&tags="+a11ypi.showbox[i]['lang']+"&interactive=0"+"&type="+type); |
---|
| | 74 | para.appendChild(newel); |
---|
| | 75 | xyz.appendChild(para); |
---|
| | 76 | } |
---|
| | 77 | } |
---|
| | 78 | }, |
---|
81 | | 79 | |
---|
82 | if(a['lang']) | | if(a['lang']) |
---|
83 | {req = {"about":decodeURIComponent(a['foruri']), "lang":a['lang']}; | | {req = {"about":decodeURIComponent(a['foruri']), "lang":a['lang']}; |
---|
84 | $.getJSON(config.deploy+'/info?', req, function(data) | | $.getJSON(config.deploy+'/info?', req, function(data) |
---|
85 | { | | { |
---|
86 | a11ypi.responseJSON = data; | | a11ypi.responseJSON = data; |
---|
87 | }); | | }); |
---|
88 | } | | } |
---|
89 | } | | } |
---|
90 | }, | | }, |
---|
91 | ajax1: function() { | | ajax1: function() { |
---|
92 | if(a11ypi.fflag == '0') | | if(a11ypi.fflag == '0') |
---|
93 | { | | { |
---|
94 | a11ypi.fflag = 1; | | a11ypi.fflag = 1; |
---|
95 | // var xhr = new XMLHttpRequest(); | | // var xhr = new XMLHttpRequest(); |
---|
96 | // xhr.onreadystatechange = function() | | // xhr.onreadystatechange = function() |
---|
97 | // { | | // { |
---|
98 | // if(xhr.readyState == 4) | | // if(xhr.readyState == 4) |
---|
99 | // { | | // { |
---|
100 | // if(xhr.responseText == "empty") | | // if(xhr.responseText == "empty") |
---|
101 | // { | | // { |
---|
102 | // // a11ypi.clearMenu(); | | // // a11ypi.clearMenu(); |
---|
103 | // } | | // } |
---|
104 | // else | | // else |
---|
105 | // { | | // { |
---|
106 | // a11ypi.createMenuFilter(JSON.parse(xhr.responseText)); | | // a11ypi.createMenuFilter(JSON.parse(xhr.responseText)); |
---|
107 | // } | | // } |
---|
108 | // } | | // } |
---|
109 | // } | | // } |
---|
110 | // xhr.open("POST",config.deploy+"/menu",true); | | // xhr.open("POST",config.deploy+"/menu",true); |
---|
111 | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
112 | // a = a11ypi.getParams(); | | // a = a11ypi.getParams(); |
---|
113 | // data = 'url='+a['foruri']+'&option='+a['blog']; | | // data = 'url='+a['foruri']+'&option='+a['blog']; |
---|
114 | // xhr.send(data) ; | | // xhr.send(data) ; |
---|
115 | // } | | // } |
---|
116 | var request = {}; | | var request = {}; |
---|
117 | request['url'] = a['foruri']; | | request['url'] = a['foruri']; |
---|
118 | request['option'] = a['blog']; | | request['option'] = a['blog']; |
---|
119 | $.get(config.deploy+"/menu", {"url":a["foruri"], "option":a['blog']}, function(data){ | | $.get(config.deploy+"/menu", {"url":a["foruri"], "option":a['blog']}, function(data){ |
---|
120 | a11ypi.createMenuFilter(JSON.parse(data)); | | a11ypi.createMenuFilter(JSON.parse(data)); |
---|
| | 80 | ajax: function() { | | | 81 | if(a11ypi.flag == '0') |
---|
| | 82 | { |
---|
| | 83 | a11ypi.flag = 1; |
---|
| | 84 | a = a11ypi.getParams(); |
---|
| | 85 | $.getJSON(config.deploy+'/menu?', {"url":a['foruri']}, function(data) |
---|
| | 86 | { |
---|
| | 87 | a11ypi.showbox = data; |
---|
| | 88 | //$('#see-narration').show(); |
---|
| | 89 | // $("#blog-filter").show(); a11ypi.blogFilter(); |
---|
| | 90 | //$("#go").show(); |
---|
| | 91 | }); |
---|
121 | | 92 | |
---|
122 | }); | | }); |
---|
123 | } | | } |
---|
124 | }, | | }, |
---|
| | 93 | if(a['lang']) | | | 94 | {req = {"about":decodeURIComponent(a['foruri']), "lang":a['lang']}; |
---|
| | 95 | $.getJSON(config.deploy+'/info?', req, function(data) |
---|
| | 96 | { |
---|
| | 97 | a11ypi.responseJSON = data; |
---|
| | 98 | }); |
---|
| | 99 | } |
---|
| | 100 | } |
---|
| | 101 | }, |
---|
| | 102 | ajax1: function() { |
---|
| | 103 | if(a11ypi.fflag == '0') |
---|
| | 104 | { |
---|
| | 105 | a11ypi.fflag = 1; |
---|
| | 106 | // var xhr = new XMLHttpRequest(); |
---|
| | 107 | // xhr.onreadystatechange = function() |
---|
| | 108 | // { |
---|
| | 109 | // if(xhr.readyState == 4) |
---|
| | 110 | // { |
---|
| | 111 | // if(xhr.responseText == "empty") |
---|
| | 112 | // { |
---|
| | 113 | // // a11ypi.clearMenu(); |
---|
| | 114 | // } |
---|
| | 115 | // else |
---|
| | 116 | // { |
---|
| | 117 | // a11ypi.createMenuFilter(JSON.parse(xhr.responseText)); |
---|
| | 118 | // } |
---|
| | 119 | // } |
---|
| | 120 | // } |
---|
| | 121 | // xhr.open("POST",config.deploy+"/menu",true); |
---|
| | 122 | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
| | 123 | // a = a11ypi.getParams(); |
---|
| | 124 | // data = 'url='+a['foruri']+'&option='+a['blog']; |
---|
| | 125 | // xhr.send(data) ; |
---|
| | 126 | // } |
---|
| | 127 | var request = {}; |
---|
| | 128 | request['url'] = a['foruri']; |
---|
| | 129 | request['option'] = a['blog']; |
---|
| | 130 | $.get(config.deploy+"/menu", {"url":a["foruri"], "option":a['blog']}, function(data){ |
---|
| | 131 | a11ypi.createMenuFilter(JSON.parse(data)); |
---|
125 | | 132 | |
---|
126 | getURL: function(e) { | | getURL: function(e) { |
---|
127 | window.location = window.location.href + "&lang=" + e.value; | | window.location = window.location.href + "&lang=" + e.value; |
---|
128 | window.reload(); | | window.reload(); |
---|
129 | }, | | }, |
---|
130 | ren: function() | | ren: function() |
---|
131 | { | | { |
---|
132 | a = a11ypi.getParams(); | | a = a11ypi.getParams(); |
---|
133 | var url = a['foruri']; | | var url = a['foruri']; |
---|
134 | // var url = decodeURIComponent(a['foruri']); | | // var url = decodeURIComponent(a['foruri']); |
---|
135 | var type; | | var type; |
---|
136 | if(a['type']) | | if(a['type']) |
---|
137 | type = a['type']; | | type = a['type']; |
---|
138 | else | | else |
---|
139 | type = 're-narration' | | type = 're-narration' |
---|
140 | var lang = ''; | | var lang = ''; |
---|
| | 133 | }); | | | 134 | } |
---|
| | 135 | }, |
---|
141 | | 136 | |
---|
142 | if( type != 're-narration') | | if( type != 're-narration') |
---|
143 | lang = a['tags']; | | lang = a['tags']; |
---|
144 | else | | else |
---|
145 | lang = a['lang']; | | lang = a['lang']; |
---|
| | 137 | getURL: function(e) { | | | 138 | window.location = window.location.href + "&lang=" + e.value; |
---|
| | 139 | window.reload(); |
---|
| | 140 | }, |
---|
| | 141 | ren: function() |
---|
| | 142 | { |
---|
| | 143 | a = a11ypi.getParams(); |
---|
| | 144 | var url = a['foruri']; |
---|
| | 145 | // var url = decodeURIComponent(a['foruri']); |
---|
| | 146 | var type; |
---|
| | 147 | if(a['type']) |
---|
| | 148 | type = a['type']; |
---|
| | 149 | else |
---|
| | 150 | type = 're-narration' |
---|
| | 151 | var lang = ''; |
---|
146 | | 152 | |
---|
147 | $.getJSON(config.deploy+"/replace?",{"url":url,"lang":lang,"type":type},function(data) | | $.getJSON(config.deploy+"/replace?",{"url":url,"lang":lang,"type":type},function(data) |
---|
148 | { | | { |
---|
149 | for(var i=0;i<data['r'].length;i++) | | for(var i=0;i<data['r'].length;i++) |
---|
150 | { | | { |
---|
151 | for(var x in data['r'][i]['narration']) | | for(var x in data['r'][i]['narration']) |
---|
152 | { | | { |
---|
153 | // path = data['r'][i]['narration'][x]['xpath']; | | // path = data['r'][i]['narration'][x]['xpath']; |
---|
154 | // newContent = data['r'][i]['narration'][x]['data']; | | // newContent = data['r'][i]['narration'][x]['data']; |
---|
155 | // elementType = data['r'][i]['narration'][x]['elementtype']; | | // elementType = data['r'][i]['narration'][x]['elementtype']; |
---|
| | 153 | if( type != 're-narration') | | | 154 | lang = a['tags']; |
---|
| | 155 | else |
---|
| | 156 | lang = a['lang']; |
---|
156 | | 157 | |
---|
157 | a11ypi.evaluate(data['r'][i]['narration'][x]); | | a11ypi.evaluate(data['r'][i]['narration'][x]); |
---|
158 | } | | } |
---|
159 | } | | } |
---|
160 | }); | | }); |
---|
161 | }, | | }, |
---|
162 | evaluate: function(a) | | evaluate: function(a) |
---|
163 | { | | { |
---|
164 | try{ | | try{ |
---|
165 | var nodes = document.evaluate(a['xpath'], document, null, XPathResult.ANY_TYPE,null); | | var nodes = document.evaluate(a['xpath'], document, null, XPathResult.ANY_TYPE,null); |
---|
| | 158 | $.getJSON(config.deploy+"/replace?",{"url":url,"lang":lang,"type":type},function(data) | | | 159 | { |
---|
| | 160 | for(var i=0;i<data['r'].length;i++) |
---|
| | 161 | { |
---|
| | 162 | for(var x in data['r'][i]['narration']) |
---|
| | 163 | { |
---|
| | 164 | // path = data['r'][i]['narration'][x]['xpath']; |
---|
| | 165 | // newContent = data['r'][i]['narration'][x]['data']; |
---|
| | 166 | // elementType = data['r'][i]['narration'][x]['elementtype']; |
---|
166 | | 167 | |
---|
167 | } | | } |
---|
168 | catch(e) | | catch(e) |
---|
169 | { | | { |
---|
170 | console.log(e); | | console.log(e); |
---|
171 | } | | } |
---|
172 | if(a['type'] == 're-narration') | | if(a['type'] == 're-narration') |
---|
173 | { | | { |
---|
174 | try{ | | try{ |
---|
175 | var result = nodes.iterateNext(); | | var result = nodes.iterateNext(); |
---|
176 | while (result) | | while (result) |
---|
177 | { | | { |
---|
178 | if (a['elementtype'] == 'image') | | if (a['elementtype'] == 'image') |
---|
179 | { | | { |
---|
180 | if(a['data'] != '') | | if(a['data'] != '') |
---|
181 | { | | { |
---|
182 | result.setAttribute('src',a['data'].split(',')[1]); //A hack to display images properly, the size has been saved in the database. | | result.setAttribute('src',a['data'].split(',')[1]); //A hack to display images properly, the size has been saved in the database. |
---|
183 | width = a['data'].split(',')[0].split('x')[0]; | | width = a['data'].split(',')[0].split('x')[0]; |
---|
184 | height = a['data'].split(',')[0].split('x')[1]; | | height = a['data'].split(',')[0].split('x')[1]; |
---|
185 | result.setAttribute('width',width); | | result.setAttribute('width',width); |
---|
186 | result.setAttribute('height', height); | | result.setAttribute('height', height); |
---|
187 | result.setAttribute('class','blink'); | | result.setAttribute('class','blink'); |
---|
188 | } | | } |
---|
189 | else | | else |
---|
190 | $(result).hide(); | | $(result).hide(); |
---|
191 | } | | } |
---|
192 | else if(a['elementtype'] == 'audio/ogg') | | else if(a['elementtype'] == 'audio/ogg') |
---|
193 | { | | { |
---|
194 | a['data'] = decodeURIComponent(a['data']); | | a['data'] = decodeURIComponent(a['data']); |
---|
195 | audio = '<audio controls="controls" src="'+a['data']+'" style="display:table;"></audio>'; | | audio = '<audio controls="controls" src="'+a['data']+'" style="display:table;"></audio>'; |
---|
196 | $(result).before(audio); | | $(result).before(audio); |
---|
197 | result.setAttribute('class','blink'); | | result.setAttribute('class','blink'); |
---|
198 | } | | } |
---|
199 | else{ | | else{ |
---|
200 | result.innerHTML = a['data']; | | result.innerHTML = a['data']; |
---|
201 | result.setAttribute('class','blink'); | | result.setAttribute('class','blink'); |
---|
202 | } | | } |
---|
203 | result=nodes.iterateNext(); | | result=nodes.iterateNext(); |
---|
204 | } | | } |
---|
205 | } | | } |
---|
206 | catch (e) | | catch (e) |
---|
207 | { | | { |
---|
208 | // dump( 'error: Document tree modified during iteration ' + e ); | | // dump( 'error: Document tree modified during iteration ' + e ); |
---|
209 | } | | } |
---|
210 | } | | } |
---|
211 | else if(a['type']=='5el') | | else if(a['type']=='5el') |
---|
212 | { | | { |
---|
| | 168 | a11ypi.evaluate(data['r'][i]['narration'][x]); | | | 169 | } |
---|
| | 170 | } |
---|
| | 171 | }); |
---|
| | 172 | }, |
---|
| | 173 | evaluate: function(a) |
---|
| | 174 | { |
---|
| | 175 | try{ |
---|
| | 176 | var nodes = document.evaluate(a['xpath'], document, null, XPathResult.ANY_TYPE,null); |
---|
213 | | 177 | |
---|
214 | try{ | | try{ |
---|
215 | var result = nodes.iterateNext(); | | var result = nodes.iterateNext(); |
---|
216 | while (result) | | while (result) |
---|
217 | { | | { |
---|
218 | $(result).html($(result).html()+a['data']); | | $(result).html($(result).html()+a['data']); |
---|
219 | $(result).get(0).scrollIntoView(); | | $(result).get(0).scrollIntoView(); |
---|
220 | result=nodes.iterateNext(); | | result=nodes.iterateNext(); |
---|
221 | } | | } |
---|
222 | } | | } |
---|
223 | catch (e) | | catch (e) |
---|
224 | { | | { |
---|
225 | //dump( 'error: Document tree modified during iteration ' + e ); | | //dump( 'error: Document tree modified during iteration ' + e ); |
---|
226 | } | | } |
---|
227 | } | | } |
---|
228 | }, | | }, |
---|
229 | filter: function() | | filter: function() |
---|
230 | { | | { |
---|
231 | var xhr = new XMLHttpRequest(); | | var xhr = new XMLHttpRequest(); |
---|
232 | xhr.onreadystatechange = function() | | xhr.onreadystatechange = function() |
---|
233 | { | | { |
---|
234 | if(xhr.readyState == 4) | | if(xhr.readyState == 4) |
---|
235 | { | | { |
---|
236 | if(xhr.responseText =='empty') | | if(xhr.responseText =='empty') |
---|
237 | { | | { |
---|
238 | // a11ypi.clearMenu(); | | // a11ypi.clearMenu(); |
---|
239 | // alert("An internal server error occured, please try later."); | | // alert("An internal server error occured, please try later."); |
---|
240 | } | | } |
---|
241 | else | | else |
---|
242 | { | | { |
---|
| | 178 | } | | | 179 | catch(e) |
---|
| | 180 | { |
---|
| | 181 | console.log(e); |
---|
| | 182 | } |
---|
| | 183 | if(a['type'] == 're-narration') |
---|
| | 184 | { |
---|
| | 185 | try{ |
---|
| | 186 | var result = nodes.iterateNext(); |
---|
| | 187 | while (result) |
---|
| | 188 | { |
---|
| | 189 | if (a['elementtype'] == 'image') |
---|
| | 190 | { |
---|
| | 191 | if(a['data'] != '') |
---|
| | 192 | { |
---|
| | 193 | result.setAttribute('src',a['data'].split(',')[1]); //A hack to display images properly, the size has been saved in the database. |
---|
| | 194 | width = a['data'].split(',')[0].split('x')[0]; |
---|
| | 195 | height = a['data'].split(',')[0].split('x')[1]; |
---|
| | 196 | result.setAttribute('width',width); |
---|
| | 197 | result.setAttribute('height', height); |
---|
| | 198 | result.setAttribute('class','blink'); |
---|
| | 199 | } |
---|
| | 200 | else |
---|
| | 201 | $(result).hide(); |
---|
| | 202 | } |
---|
| | 203 | else if(a['elementtype'] == 'audio/ogg') |
---|
| | 204 | { |
---|
| | 205 | a['data'] = decodeURIComponent(a['data']); |
---|
| | 206 | audio = '<audio controls="controls" src="'+a['data']+'" style="display:table;"></audio>'; |
---|
| | 207 | $(result).before(audio); |
---|
| | 208 | result.setAttribute('class','blink'); |
---|
| | 209 | } |
---|
| | 210 | else{ |
---|
| | 211 | result.innerHTML = a['data']; |
---|
| | 212 | result.setAttribute('class','blink'); |
---|
| | 213 | } |
---|
| | 214 | result=nodes.iterateNext(); |
---|
| | 215 | } |
---|
| | 216 | } |
---|
| | 217 | catch (e) |
---|
| | 218 | { |
---|
| | 219 | // dump( 'error: Document tree modified during iteration ' + e ); |
---|
| | 220 | } |
---|
| | 221 | } |
---|
| | 222 | else if(a['type']=='5el') |
---|
| | 223 | { |
---|
243 | | 224 | |
---|
244 | d ={}; | | d ={}; |
---|
245 | var response=xhr.responseText.substring(3).split('###'); | | var response=xhr.responseText.substring(3).split('###'); |
---|
246 | for (var j= 0; j< response.length ; j++){ | | for (var j= 0; j< response.length ; j++){ |
---|
247 | chunk = response[j].substring(1).split('&'); | | chunk = response[j].substring(1).split('&'); |
---|
| | 225 | try{ | | | 226 | var result = nodes.iterateNext(); |
---|
| | 227 | while (result) |
---|
| | 228 | { |
---|
| | 229 | $(result).html($(result).html()+a['data']); |
---|
| | 230 | $(result).get(0).scrollIntoView(); |
---|
| | 231 | result=nodes.iterateNext(); |
---|
| | 232 | } |
---|
| | 233 | } |
---|
| | 234 | catch (e) |
---|
| | 235 | { |
---|
| | 236 | //dump( 'error: Document tree modified during iteration ' + e ); |
---|
| | 237 | } |
---|
| | 238 | } |
---|
| | 239 | }, |
---|
| | 240 | filter: function() |
---|
| | 241 | { |
---|
| | 242 | var xhr = new XMLHttpRequest(); |
---|
| | 243 | xhr.onreadystatechange = function() |
---|
| | 244 | { |
---|
| | 245 | if(xhr.readyState == 4) |
---|
| | 246 | { |
---|
| | 247 | if(xhr.responseText =='empty') |
---|
| | 248 | { |
---|
| | 249 | // a11ypi.clearMenu(); |
---|
| | 250 | // alert("An internal server error occured, please try later."); |
---|
| | 251 | } |
---|
| | 252 | else |
---|
| | 253 | { |
---|
248 | | 254 | |
---|
249 | for (var i= 0; i< chunk.length ; i++){ | | for (var i= 0; i< chunk.length ; i++){ |
---|
250 | pair =chunk[i].split("::"); | | pair =chunk[i].split("::"); |
---|
251 | key = pair[0]; | | key = pair[0]; |
---|
252 | value = pair[1]; | | value = pair[1]; |
---|
253 | d[key] = value; | | d[key] = value; |
---|
254 | } | | } |
---|
255 | path = d['xpath']; | | path = d['xpath']; |
---|
256 | newContent = d['data']; | | newContent = d['data']; |
---|
257 | elementType = d['elementtype']; | | elementType = d['elementtype']; |
---|
258 | a11ypi.evaluate(path,newContent,elementType); | | a11ypi.evaluate(path,newContent,elementType); |
---|
259 | } | | } |
---|
260 | } | | } |
---|
261 | } | | } |
---|
262 | } | | } |
---|
263 | a = a11ypi.getParams(); | | a = a11ypi.getParams(); |
---|
264 | var url = a['foruri']; | | var url = a['foruri']; |
---|
265 | var lang= a['lang']; | | var lang= a['lang']; |
---|
266 | var blog= a['blog']; | | var blog= a['blog']; |
---|
267 | var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog); | | var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog); |
---|
| | 255 | d ={}; | | | 256 | var response=xhr.responseText.substring(3).split('###'); |
---|
| | 257 | for (var j= 0; j< response.length ; j++){ |
---|
| | 258 | chunk = response[j].substring(1).split('&'); |
---|
268 | | 259 | |
---|
269 | xhr.open("POST",config.root+"/filter",true); | | xhr.open("POST",config.root+"/filter",true); |
---|
270 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
271 | xhr.send(data);// | | xhr.send(data);// |
---|
272 | }, | | }, |
---|
273 | createMenuFilter: function(menu_list) { | | createMenuFilter: function(menu_list) { |
---|
274 | var xyz = document.getElementById("show-box"); | | var xyz = document.getElementById("show-box"); |
---|
275 | xyz.innerHTML = ''; | | xyz.innerHTML = ''; |
---|
276 | d = window.location.search.split('?')[1]; | | d = window.location.search.split('?')[1]; |
---|
277 | a = a11ypi.getParams(); | | a = a11ypi.getParams(); |
---|
278 | var page = a['foruri']; | | var page = a['foruri']; |
---|
279 | var blog = a['blog']; | | var blog = a['blog']; |
---|
280 | for(var i=0;i<menu_list.length;i++) | | for(var i=0;i<menu_list.length;i++) |
---|
281 | { | | { |
---|
282 | var para = document.createElement("p"); | | var para = document.createElement("p"); |
---|
283 | var newel = document.createElement("a"); | | var newel = document.createElement("a"); |
---|
284 | newel.textContent = menu_list[i]; | | newel.textContent = menu_list[i]; |
---|
285 | $(newel).attr("href",config.deploy+"/?foruri="+page+"&blog="+blog+"&lang="+menu_list[i]+"&interactive=1"); | | $(newel).attr("href",config.deploy+"/?foruri="+page+"&blog="+blog+"&lang="+menu_list[i]+"&interactive=1"); |
---|
286 | para.appendChild(newel); | | para.appendChild(newel); |
---|
287 | xyz.appendChild(para); | | xyz.appendChild(para); |
---|
288 | } | | } |
---|
289 | }, | | }, |
---|
290 | clearMenuFilter: function() { | | clearMenuFilter: function() { |
---|
291 | var xyz = document.getElementById("menu-button"); | | var xyz = document.getElementById("menu-button"); |
---|
292 | while(null!= xyz.firstChild) | | while(null!= xyz.firstChild) |
---|
293 | { | | { |
---|
294 | xyz.removeChild(xyz.firstChild); | | xyz.removeChild(xyz.firstChild); |
---|
295 | } | | } |
---|
296 | }, | | }, |
---|
297 | getURLFilter: function(e) { | | getURLFilter: function(e) { |
---|
298 | a= a11ypi.getParams(); | | a= a11ypi.getParams(); |
---|
299 | window.location = config.deploy+"/?foruri="+a['foruri']+"&blog="+a['blog'] + "&lang=" + e.value+"&interactive=1"; | | window.location = config.deploy+"/?foruri="+a['foruri']+"&blog="+a['blog'] + "&lang=" + e.value+"&interactive=1"; |
---|
300 | window.reload(); | | window.reload(); |
---|
301 | }, | | }, |
---|
302 | showOriginal: function(){ | | showOriginal: function(){ |
---|
303 | var url=decodeURIComponent(window.location.search.split("=")[1].split("&")[0]); | | var url=decodeURIComponent(window.location.search.split("=")[1].split("&")[0]); |
---|
304 | window.open(url); | | window.open(url); |
---|
305 | }, | | }, |
---|
306 | tweet:function(){ | | tweet:function(){ |
---|
307 | !function(d,s,id){ | | !function(d,s,id){ |
---|
308 | var js,fjs=d.getElementsByTagName(s)[0]; | | var js,fjs=d.getElementsByTagName(s)[0]; |
---|
309 | if(!d.getElementById(id)){ | | if(!d.getElementById(id)){ |
---|
310 | js=d.createElement(s); | | js=d.createElement(s); |
---|
311 | js.id=id;js.src="//platform.twitter.com/widgets.js"; | | js.id=id;js.src="//platform.twitter.com/widgets.js"; |
---|
312 | fjs.parentNode.insertBefore(js,fjs); | | fjs.parentNode.insertBefore(js,fjs); |
---|
313 | } | | } |
---|
314 | } | | } |
---|
315 | (document,"script","twitter-wjs"); | | (document,"script","twitter-wjs"); |
---|
316 | }, | | }, |
---|
317 | facebook: function() { | | facebook: function() { |
---|
318 | (function(d, s, id) { | | (function(d, s, id) { |
---|
319 | var js, fjs = d.getElementsByTagName(s)[0]; | | var js, fjs = d.getElementsByTagName(s)[0]; |
---|
320 | if (d.getElementById(id)) return; | | if (d.getElementById(id)) return; |
---|
321 | js = d.createElement(s); js.id = id; | | js = d.createElement(s); js.id = id; |
---|
322 | js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; | | js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; |
---|
323 | fjs.parentNode.insertBefore(js, fjs); | | fjs.parentNode.insertBefore(js, fjs); |
---|
324 | } | | } |
---|
325 | (document, 'script', 'facebook-jssdk')); | | (document, 'script', 'facebook-jssdk')); |
---|
326 | }, | | }, |
---|
327 | loadOverlay: function() | | loadOverlay: function() |
---|
328 | { | | { |
---|
329 | yepnope([{ | | yepnope([{ |
---|
330 | test: window.jQuery, | | test: window.jQuery, |
---|
331 | nope:['//code.jquery.com/jquery-1.10.2.min.js'], | | nope:['//code.jquery.com/jquery-1.10.2.min.js'], |
---|
332 | load:['//code.jquery.com/ui/1.10.3/jquery-ui.js'], | | load:['//code.jquery.com/ui/1.10.3/jquery-ui.js'], |
---|
333 | complete:function(){ | | complete:function(){ |
---|
334 | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ | | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ |
---|
335 | '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+ | | '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+ |
---|
336 | '<button id="outter-up-button" class="alipi" onclick="a11ypi.outterToggle();" title="Move this bar to bottom">Move</button> '+ | | '<button id="outter-up-button" class="alipi" onclick="a11ypi.outterToggle();" title="Move this bar to bottom">Move</button> '+ |
---|
337 | '<button id="edit-current" class="alipi" title="Allow to edit this page">Re-narrate</button> '+ | | '<button id="edit-current" class="alipi" title="Allow to edit this page">Re-narrate</button> '+ |
---|
338 | '<button id="see-narration" class="alipi" onclick="a11ypi.showBox();" title="See other renarrations, which are in same or other languages"> '+ | | '<button id="see-narration" class="alipi" onclick="a11ypi.showBox();" title="See other renarrations, which are in same or other languages"> '+ |
---|
339 | 'Re-narrations</button>'+ | | 'Re-narrations</button>'+ |
---|
340 | // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+ | | // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+ |
---|
341 | // '5el</button>'+ | | // '5el</button>'+ |
---|
342 | '<button id="see-links" class="alipi" onclick="a11ypi.showBox1();" title="See other re-narrated pages of this domain">Re-narrated Pages '+ | | '<button id="see-links" class="alipi" onclick="a11ypi.showBox1();" title="See other re-narrated pages of this domain">Re-narrated Pages '+ |
---|
343 | '</button>'+ | | '</button>'+ |
---|
344 | // '<select id="blog-filter" class="alipi" onChange="a11ypi.checkSelect();" title="Select one of the blog name"></select>'+ | | // '<select id="blog-filter" class="alipi" onChange="a11ypi.checkSelect();" title="Select one of the blog name"></select>'+ |
---|
345 | '<button id="go" class="alipi ui-icon-circle-arrow-e" onclick="a11ypi.go();" title="Filter by blog" >|Y|</button>'+ | | '<button id="go" class="alipi ui-icon-circle-arrow-e" onclick="a11ypi.go();" title="Filter by blog" >|Y|</button>'+ |
---|
346 | '<div id="show-box" title="Choose a narration"></div> '+ | | '<div id="show-box" title="Choose a narration"></div> '+ |
---|
347 | '<div id="show-comment" title="Comments for"></div> '+ | | '<div id="show-comment" title="Comments for"></div> '+ |
---|
348 | '<div id="show-links" title="List of pages narrated in this domain" class="alipi"></div> '+ | | '<div id="show-links" title="List of pages narrated in this domain" class="alipi"></div> '+ |
---|
349 | '<div id="share-box" class="alipi" title="Share this page in any following social network"></div>'; | | '<div id="share-box" class="alipi" title="Share this page in any following social network"></div>'; |
---|
| | 260 | for (var i= 0; i< chunk.length ; i++){ | | | 261 | pair =chunk[i].split("::"); |
---|
| | 262 | key = pair[0]; |
---|
| | 263 | value = pair[1]; |
---|
| | 264 | d[key] = value; |
---|
| | 265 | } |
---|
| | 266 | path = d['xpath']; |
---|
| | 267 | newContent = d['data']; |
---|
| | 268 | elementType = d['elementtype']; |
---|
| | 269 | a11ypi.evaluate(path,newContent,elementType); |
---|
| | 270 | } |
---|
| | 271 | } |
---|
| | 272 | } |
---|
| | 273 | } |
---|
| | 274 | a = a11ypi.getParams(); |
---|
| | 275 | var url = a['foruri']; |
---|
| | 276 | var lang= a['lang']; |
---|
| | 277 | var blog= a['blog']; |
---|
| | 278 | var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog); |
---|
350 | | 279 | |
---|
351 | var pub_overlay_template = '<div id="pub_overlay" class="alipi ui-widget-header ui-corner-all">'+ | | var pub_overlay_template = '<div id="pub_overlay" class="alipi ui-widget-header ui-corner-all">'+ |
---|
352 | '<button id="icon-up" class="alipi" down="true" onClick="a11ypi.hide_overlays();" title="Move this bar to top">Move</button>'+ //▲ | | '<button id="icon-up" class="alipi" down="true" onClick="a11ypi.hide_overlays();" title="Move this bar to top">Move</button>'+ //▲ |
---|
353 | '<button id="icon-down" class="alipi" onClick="a11ypi.hide_overlays();" title="Move this bar to bottom">Move</button>'+ //▼ | | '<button id="icon-down" class="alipi" onClick="a11ypi.hide_overlays();" title="Move this bar to bottom">Move</button>'+ //▼ |
---|
354 | '<button id="exit-mode" class="alipi" onclick="a11ypi.exitMode();" title="Do not want to save any changes, just take me out of this editing"> '+ | | '<button id="exit-mode" class="alipi" onclick="a11ypi.exitMode();" title="Do not want to save any changes, just take me out of this editing"> '+ |
---|
355 | 'Exit</button>'+ | | 'Exit</button>'+ |
---|
356 | '<button id="help-window" class="alipi" onclick="a11ypi.help_window();" title="How may I help you in editing this page?">Help</button>'+ | | '<button id="help-window" class="alipi" onclick="a11ypi.help_window();" title="How may I help you in editing this page?">Help</button>'+ |
---|
357 | '<button id="undo-button" class="alipi" onclick="util.undoChanges();"title="Undo previous change, one by one">Undo changes</button>'+ | | '<button id="undo-button" class="alipi" onclick="util.undoChanges();"title="Undo previous change, one by one">Undo changes</button>'+ |
---|
358 | '<button id="publish-button" class="alipi" onclick="a11ypi.loginToSwtStore();"title="Publish your changes to blog">Publish</button></div>'; | | '<button id="publish-button" class="alipi" onclick="a11ypi.loginToSwtStore();"title="Publish your changes to blog">Publish</button></div>'; |
---|
| | 280 | xhr.open("POST",config.root+"/filter",true); | | | 281 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
| | 282 | xhr.send(data);// |
---|
| | 283 | }, |
---|
| | 284 | createMenuFilter: function(menu_list) { |
---|
| | 285 | var xyz = document.getElementById("show-box"); |
---|
| | 286 | xyz.innerHTML = ''; |
---|
| | 287 | d = window.location.search.split('?')[1]; |
---|
| | 288 | a = a11ypi.getParams(); |
---|
| | 289 | var page = a['foruri']; |
---|
| | 290 | var blog = a['blog']; |
---|
| | 291 | for(var i=0;i<menu_list.length;i++) |
---|
| | 292 | { |
---|
| | 293 | var para = document.createElement("p"); |
---|
| | 294 | var newel = document.createElement("a"); |
---|
| | 295 | newel.textContent = menu_list[i]; |
---|
| | 296 | $(newel).attr("href",config.deploy+"/?foruri="+page+"&blog="+blog+"&lang="+menu_list[i]+"&interactive=1"); |
---|
| | 297 | para.appendChild(newel); |
---|
| | 298 | xyz.appendChild(para); |
---|
| | 299 | } |
---|
| | 300 | }, |
---|
| | 301 | clearMenuFilter: function() { |
---|
| | 302 | var xyz = document.getElementById("menu-button"); |
---|
| | 303 | while(null!= xyz.firstChild) |
---|
| | 304 | { |
---|
| | 305 | xyz.removeChild(xyz.firstChild); |
---|
| | 306 | } |
---|
| | 307 | }, |
---|
| | 308 | getURLFilter: function(e) { |
---|
| | 309 | a= a11ypi.getParams(); |
---|
| | 310 | window.location = config.deploy+"/?foruri="+a['foruri']+"&blog="+a['blog'] + "&lang=" + e.value+"&interactive=1"; |
---|
| | 311 | window.reload(); |
---|
| | 312 | }, |
---|
| | 313 | showOriginal: function(){ |
---|
| | 314 | var url=decodeURIComponent(window.location.search.split("=")[1].split("&")[0]); |
---|
| | 315 | window.open(url); |
---|
| | 316 | }, |
---|
| | 317 | tweet:function(){ |
---|
| | 318 | !function(d,s,id){ |
---|
| | 319 | var js,fjs=d.getElementsByTagName(s)[0]; |
---|
| | 320 | if(!d.getElementById(id)){ |
---|
| | 321 | js=d.createElement(s); |
---|
| | 322 | js.id=id;js.src="//platform.twitter.com/widgets.js"; |
---|
| | 323 | fjs.parentNode.insertBefore(js,fjs); |
---|
| | 324 | } |
---|
| | 325 | } |
---|
| | 326 | (document,"script","twitter-wjs"); |
---|
| | 327 | }, |
---|
| | 328 | facebook: function() { |
---|
| | 329 | (function(d, s, id) { |
---|
| | 330 | var js, fjs = d.getElementsByTagName(s)[0]; |
---|
| | 331 | if (d.getElementById(id)) return; |
---|
| | 332 | js = d.createElement(s); js.id = id; |
---|
| | 333 | js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; |
---|
| | 334 | fjs.parentNode.insertBefore(js, fjs); |
---|
| | 335 | } |
---|
| | 336 | (document, 'script', 'facebook-jssdk')); |
---|
| | 337 | }, |
---|
| | 338 | loadOverlay: function() |
---|
| | 339 | { |
---|
| | 340 | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 341 | '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+ |
---|
| | 342 | '<button id="outter-up-button" class="alipi" onclick="a11ypi.outterToggle();" title="Move this bar to bottom">Move</button> '+ |
---|
| | 343 | '<button id="edit-current" class="alipi" title="Allow to edit this page">Re-narrate</button> '+ |
---|
| | 344 | '<button id="see-narration" class="alipi" title="See other renarrations, which are in same or other languages"> '+ |
---|
| | 345 | 'Re-narrations</button>'+ |
---|
| | 346 | // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+ |
---|
| | 347 | // '5el</button>'+ |
---|
| | 348 | '<button id="see-links" class="alipi" title="See other re-narrated pages of this domain">Re-narrated Pages '+ |
---|
| | 349 | '</button>'+ |
---|
| | 350 | // '<select id="blog-filter" class="alipi" onChange="a11ypi.checkSelect();" title="Select one of the blog name"></select>'+ |
---|
| | 351 | '<button id="go" class="alipi ui-icon-circle-arrow-e" onclick="a11ypi.go();" title="Filter by blog" >|Y|</button>'+ |
---|
| | 352 | '<div id="show-box" title="Choose a narration"></div> '+ |
---|
| | 353 | '<div id="show-comment" title="Comments for"></div> '+ |
---|
| | 354 | '<div id="show-links" title="List of pages narrated in this domain" class="alipi"></div> '+ |
---|
| | 355 | '<div id="share-box" class="alipi" title="Share this page in any following social network"></div>'; |
---|
359 | | 356 | |
---|
360 | var element_edit_overlay_template = '<div id="element_edit_overlay" class="alipi ui-widget-header ui-corner-all" >'+ | | var element_edit_overlay_template = '<div id="element_edit_overlay" class="alipi ui-widget-header ui-corner-all" >'+ |
---|
361 | '<button id="edit-text" class="alipi" onclick="a11ypi.displayEditor();" title="Help you to edit this element by providing an editor on right'+ | | '<button id="edit-text" class="alipi" onclick="a11ypi.displayEditor();" title="Help you to edit this element by providing an editor on right'+ |
---|
362 | ' & reference on left.">Edit Text</button>'+ | | ' & reference on left.">Edit Text</button>'+ |
---|
363 | '<button id="add-audio" class="alipi" onclick="a11ypi.addAudio();" title="Allow you to give an audio file(.ogg) link to add your audio '+ | | '<button id="add-audio" class="alipi" onclick="a11ypi.addAudio();" title="Allow you to give an audio file(.ogg) link to add your audio '+ |
---|
364 | 'to this element ">Add Audio</button>'+ | | 'to this element ">Add Audio</button>'+ |
---|
365 | '<button id="replace-image" class="alipi" onclick="a11ypi.imageReplacer();" title="Allow you to give an image file(jpeg/jpg/gif/png) '+ | | '<button id="replace-image" class="alipi" onclick="a11ypi.imageReplacer();" title="Allow you to give an image file(jpeg/jpg/gif/png) '+ |
---|
366 | 'link to replace with this image">Replace Image</button>'+ | | 'link to replace with this image">Replace Image</button>'+ |
---|
367 | '<button id="delete-image" class="alipi" onclick="pageEditor.deleteImage();" title="Remove this image from page">Delete Image</button>'+ | | '<button id="delete-image" class="alipi" onclick="pageEditor.deleteImage();" title="Remove this image from page">Delete Image</button>'+ |
---|
368 | '<button id="close-element" class="alipi" onclick="pageEditor.cleanUp();" title="Close" ></button>'+ | | '<button id="close-element" class="alipi" onclick="pageEditor.cleanUp();" title="Close" ></button>'+ |
---|
369 | '<label id="cant-edit" class="alipi">No selection / Too large selection </label> '+ | | '<label id="cant-edit" class="alipi">No selection / Too large selection </label> '+ |
---|
370 | '</div>'; | | '</div>'; |
---|
| | 357 | var pub_overlay_template = '<div id="pub_overlay" class="alipi ui-widget-header ui-corner-all">'+ | | | 358 | '<button id="icon-up" class="alipi" down="true" onClick="a11ypi.hide_overlays();" title="Move this bar to top">Move</button>'+ //▲ |
---|
| | 359 | '<button id="icon-down" class="alipi" onClick="a11ypi.hide_overlays();" title="Move this bar to bottom">Move</button>'+ //▼ |
---|
| | 360 | '<button id="exit-mode" class="alipi" onclick="a11ypi.exitMode();" title="Do not want to save any changes, just take me out of this editing"> '+ |
---|
| | 361 | 'Exit</button>'+ |
---|
| | 362 | '<button id="help-window" class="alipi" onclick="a11ypi.help_window();" title="How may I help you in editing this page?">Help</button>'+ |
---|
| | 363 | '<button id="undo-button" class="alipi" onclick="util.undoChanges();"title="Undo previous change, one by one">Undo changes</button>'+ |
---|
| | 364 | '<button id="publish-button" class="alipi" onclick="a11ypi.loginToSwtStore();"title="Publish your changes to blog">Publish</button></div>'; |
---|
371 | | 365 | |
---|
372 | $('body').append(overlay_template); | | $('body').append(overlay_template); |
---|
373 | $('body').append(pub_overlay_template); | | $('body').append(pub_overlay_template); |
---|
374 | $('body').append(element_edit_overlay_template); | | $('body').append(element_edit_overlay_template); |
---|
| | 366 | var element_edit_overlay_template = '<div id="element_edit_overlay" class="alipi ui-widget-header ui-corner-all" >'+ | | | 367 | '<button id="edit-text" class="alipi" onclick="a11ypi.displayEditor();" title="Help you to edit this element by providing an editor on right'+ |
---|
| | 368 | ' & reference on left.">Edit Text</button>'+ |
---|
| | 369 | '<button id="add-audio" class="alipi" onclick="a11ypi.addAudio();" title="Allow you to give an audio file(.ogg) link to add your audio '+ |
---|
| | 370 | 'to this element ">Add Audio</button>'+ |
---|
| | 371 | '<button id="replace-image" class="alipi" onclick="a11ypi.imageReplacer();" title="Allow you to give an image file(jpeg/jpg/gif/png) '+ |
---|
| | 372 | 'link to replace with this image">Replace Image</button>'+ |
---|
| | 373 | '<button id="delete-image" class="alipi" onclick="pageEditor.deleteImage();" title="Remove this image from page">Delete Image</button>'+ |
---|
| | 374 | '<button id="close-element" class="alipi" onclick="pageEditor.cleanUp();" title="Close" ></button>'+ |
---|
| | 375 | '<label id="cant-edit" class="alipi">No selection / Too large selection </label> '+ |
---|
| | 376 | '</div>'; |
---|
375 | | 377 | |
---|
376 | $('#outter-up-button').show(); | | $('#outter-up-button').show(); |
---|
377 | $('#go').button({disabled : true}); | | $('#go').button({disabled : true}); |
---|
378 | $('#undo-button').button({ disabled: true}); | | $('#undo-button').button({ disabled: true}); |
---|
379 | $('#publish-button').button({ disabled: true}); | | $('#publish-button').button({ disabled: true}); |
---|
380 | $('input[class="alipi"], select[class="alipi"]').button(); | | $('input[class="alipi"], select[class="alipi"]').button(); |
---|
| | 378 | $('body').append(overlay_template); | | | 379 | $('body').append(pub_overlay_template); |
---|
| | 380 | $('body').append(element_edit_overlay_template); |
---|
381 | | 381 | |
---|
382 | $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); | | $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); |
---|
383 | $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); | | $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); |
---|
384 | $("#edit-current").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-current').children().addClass('alipi'); | | $("#edit-current").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-current').children().addClass('alipi'); |
---|
385 | $("#see-narration").button({icons:{primary:"ui-icon-document-b"}}); $('#see-narration').children().addClass('alipi'); | | $("#see-narration").button({icons:{primary:"ui-icon-document-b"}}); $('#see-narration').children().addClass('alipi'); |
---|
386 | $("#see-comment").button({icons:{primary:"ui-icon-document-b"}}); $('#see-comment').children().addClass('alipi'); | | $("#see-comment").button({icons:{primary:"ui-icon-document-b"}}); $('#see-comment').children().addClass('alipi'); |
---|
387 | $("#see-links").button({icons:{primary:"ui-icon-link"}}); $('#see-links').children().addClass('alipi'); | | $("#see-links").button({icons:{primary:"ui-icon-link"}}); $('#see-links').children().addClass('alipi'); |
---|
388 | /*$("#blog-filter").button({icons:{secondary:"ui-icon-triangle-1-s"}}); */ $('#blog-filter').children().addClass('alipi'); | | /*$("#blog-filter").button({icons:{secondary:"ui-icon-triangle-1-s"}}); */ $('#blog-filter').children().addClass('alipi'); |
---|
389 | $("#go").button({icons:{primary:"ui-icon-arrowthick-1-e"},text:false}); $('#go').children().addClass('alipi'); | | $("#go").button({icons:{primary:"ui-icon-arrowthick-1-e"},text:false}); $('#go').children().addClass('alipi'); |
---|
390 | $("#share").button({icons:{primary:"ui-icon-signal-diag"}}); $('#share').children().addClass('alipi'); | | $("#share").button({icons:{primary:"ui-icon-signal-diag"}}); $('#share').children().addClass('alipi'); |
---|
391 | $("#orig-button").button({icons:{primary:"ui-icon-extlink"}}); $('#orig-button').children().addClass('alipi'); | | $("#orig-button").button({icons:{primary:"ui-icon-extlink"}}); $('#orig-button').children().addClass('alipi'); |
---|
392 | $("#info").button({icons:{primary:"ui-icon-info"}}); $('#info').children().addClass('alipi'); | | $("#info").button({icons:{primary:"ui-icon-info"}}); $('#info').children().addClass('alipi'); |
---|
| | 382 | $('#outter-up-button').show(); | | | 383 | $('#go').button({disabled : true}); |
---|
| | 384 | $('#undo-button').button({ disabled: true}); |
---|
| | 385 | $('#publish-button').button({ disabled: true}); |
---|
393 | | 386 | |
---|
394 | $("#icon-up").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#icon-up').children().addClass('alipi'); | | $("#icon-up").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#icon-up').children().addClass('alipi'); |
---|
395 | $("#icon-down").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#icon-down').children().addClass('alipi'); | | $("#icon-down").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#icon-down').children().addClass('alipi'); |
---|
396 | $("#exit-mode").button({icons:{primary:"ui-icon-power"}}); $('#exit-mode').children().addClass('alipi'); | | $("#exit-mode").button({icons:{primary:"ui-icon-power"}}); $('#exit-mode').children().addClass('alipi'); |
---|
397 | $("#help-window").button({icons:{primary:"ui-icon-help"}}); $('#help-window').children().addClass('alipi'); | | $("#help-window").button({icons:{primary:"ui-icon-help"}}); $('#help-window').children().addClass('alipi'); |
---|
398 | $("#undo-button").button({icons:{primary:"ui-icon-arrowreturnthick-1-w"}}); $('#undo-button').children().addClass('alipi'); | | $("#undo-button").button({icons:{primary:"ui-icon-arrowreturnthick-1-w"}}); $('#undo-button').children().addClass('alipi'); |
---|
399 | $("#publish-button").button({icons:{primary:"ui-icon-circle-check"}}); $('#publish-button').children().addClass('alipi'); | | $("#publish-button").button({icons:{primary:"ui-icon-circle-check"}}); $('#publish-button').children().addClass('alipi'); |
---|
400 | | 387 | |
---|
401 | $("#edit-text").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-text').children().addClass('alipi'); | | $("#edit-text").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-text').children().addClass('alipi'); |
---|
402 | $("#add-audio").button({icons:{primary:"ui-icon-circle-plus"}}); $('#add-audio').children().addClass('alipi'); | | $("#add-audio").button({icons:{primary:"ui-icon-circle-plus"}}); $('#add-audio').children().addClass('alipi'); |
---|
403 | $("#replace-image").button({icons:{primary:"ui-icon-transferthick-e-w"}}); $('#replace-image').children().addClass('alipi'); | | $("#replace-image").button({icons:{primary:"ui-icon-transferthick-e-w"}}); $('#replace-image').children().addClass('alipi'); |
---|
404 | $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); | | $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); |
---|
405 | $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); | | $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); |
---|
| | 388 | $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); | | | 389 | $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); |
---|
| | 390 | $("#edit-current").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-current').children().addClass('alipi'); |
---|
| | 391 | $("#see-narration").button({icons:{primary:"ui-icon-document-b"}}); $('#see-narration').children().addClass('alipi'); |
---|
| | 392 | $("#see-comment").button({icons:{primary:"ui-icon-document-b"}}); $('#see-comment').children().addClass('alipi'); |
---|
| | 393 | $("#see-links").button({icons:{primary:"ui-icon-link"}}); $('#see-links').children().addClass('alipi'); |
---|
| | 394 | /*$("#blog-filter").button({icons:{secondary:"ui-icon-triangle-1-s"}}); */ $('#blog-filter').children().addClass('alipi'); |
---|
| | 395 | $("#go").button({icons:{primary:"ui-icon-arrowthick-1-e"},text:false}); $('#go').children().addClass('alipi'); |
---|
| | 396 | $("#share").button({icons:{primary:"ui-icon-signal-diag"}}); $('#share').children().addClass('alipi'); |
---|
| | 397 | $("#orig-button").button({icons:{primary:"ui-icon-extlink"}}); $('#orig-button').children().addClass('alipi'); |
---|
| | 398 | $("#info").button({icons:{primary:"ui-icon-info"}}); $('#info').children().addClass('alipi'); |
---|
406 | | 399 | |
---|
407 | $("#edit-current").button(); | | $("#edit-current").button(); |
---|
408 | $("#edit-current").on("click", a11ypi.editPage); | | $("#edit-current").on("click", a11ypi.editPage); |
---|
| | 400 | $("#icon-up").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#icon-up').children().addClass('alipi'); | | | 401 | $("#icon-down").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#icon-down').children().addClass('alipi'); |
---|
| | 402 | $("#exit-mode").button({icons:{primary:"ui-icon-power"}}); $('#exit-mode').children().addClass('alipi'); |
---|
| | 403 | $("#help-window").button({icons:{primary:"ui-icon-help"}}); $('#help-window').children().addClass('alipi'); |
---|
| | 404 | $("#undo-button").button({icons:{primary:"ui-icon-arrowreturnthick-1-w"}}); $('#undo-button').children().addClass('alipi'); |
---|
| | 405 | $("#publish-button").button({icons:{primary:"ui-icon-circle-check"}}); $('#publish-button').children().addClass('alipi'); |
---|
409 | | 406 | |
---|
410 | $('#renarrated_overlay').addClass('barOnTop'); | | $('#renarrated_overlay').addClass('barOnTop'); |
---|
411 | a11ypi.ajax(); | | a11ypi.ajax(); |
---|
412 | a11ypi.ajaxLinks1(); | | a11ypi.ajaxLinks1(); |
---|
413 | $('#edit-current').show(); | | $('#edit-current').show(); |
---|
| | 407 | $("#edit-text").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-text').children().addClass('alipi'); | | | 408 | $("#add-audio").button({icons:{primary:"ui-icon-circle-plus"}}); $('#add-audio').children().addClass('alipi'); |
---|
| | 409 | $("#replace-image").button({icons:{primary:"ui-icon-transferthick-e-w"}}); $('#replace-image').children().addClass('alipi'); |
---|
| | 410 | $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); |
---|
| | 411 | $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); |
---|
414 | | 412 | |
---|
415 | d = window.location.search.split('?')[1]; | | d = window.location.search.split('?')[1]; |
---|
416 | var a =[]; | | var a =[]; |
---|
417 | for (var i = 0;i<d.split('&').length;i++){ | | for (var i = 0;i<d.split('&').length;i++){ |
---|
418 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; |
---|
419 | } | | } |
---|
420 | if(a['blog'] != undefined ) { | | if(a['blog'] != undefined ) { |
---|
421 | $('#go').hide(); | | $('#go').hide(); |
---|
422 | $('#blog-filter').hide(); | | $('#blog-filter').hide(); |
---|
423 | } else { | | } else { |
---|
424 | } | | } |
---|
| | 413 | $("#edit-current").button(); | | | 414 | $("#see-narration").button(); |
---|
| | 415 | $("#see-links").button(); |
---|
425 | | 416 | |
---|
426 | if($('#orig-button').text() == 'Original Page') { | | if($('#orig-button').text() == 'Original Page') { |
---|
427 | $('#share').insertAfter($('#go')); $('#share').show(); | | $('#share').insertAfter($('#go')); $('#share').show(); |
---|
428 | $('#info').insertAfter($('#go')); $('#info').show(); | | $('#info').insertAfter($('#go')); $('#info').show(); |
---|
429 | $('#orig-button').insertAfter($('#go')); $('#orig-button').show(); | | $('#orig-button').insertAfter($('#go')); $('#orig-button').show(); |
---|
430 | $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root')); | | $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root')); |
---|
431 | } | | } |
---|
432 | }}]); | | }}]); |
---|
433 | }, | | }, |
---|
434 | checkSelect: function() | | checkSelect: function() |
---|
435 | { | | { |
---|
436 | if($('#blog-filter').val() != "Choose a blog") { | | if($('#blog-filter').val() != "Choose a blog") { |
---|
437 | $('#go').button({disabled : false}); | | $('#go').button({disabled : false}); |
---|
438 | } else { | | } else { |
---|
439 | $('#go').button({disabled : true}); | | $('#go').button({disabled : true}); |
---|
440 | } | | } |
---|
441 | }, | | }, |
---|
| | 417 | // $('input[class="alipi"], select[class="alipi"]').button(); | | | 418 | $("#edit-current").on("click", a11ypi.editPage); |
---|
| | 419 | $("#see-narration").on("click",a11ypi.showBox); |
---|
| | 420 | $("#see-links").on("click",a11ypi.showBox1); |
---|
442 | | 421 | |
---|
443 | help_window: function() { | | help_window: function() { |
---|
444 | var help_template = '<div id="helpwindow" class="alipi ui-widget-header ui-corner-all">'+ | | var help_template = '<div id="helpwindow" class="alipi ui-widget-header ui-corner-all">'+ |
---|
445 | '<label id="txtlab" class="alipi" style="color:#aaa;font-size:100%;">TEXT :- It will popup a '+ | | '<label id="txtlab" class="alipi" style="color:#aaa;font-size:100%;">TEXT :- It will popup a '+ |
---|
446 | 'window and allow you to modify/replace text of select element on editor(right) box.'+ | | 'window and allow you to modify/replace text of select element on editor(right) box.'+ |
---|
447 | '<p class="alipi">To delete - Empty the editor(right) box and press "Save changes".'+ | | '<p class="alipi">To delete - Empty the editor(right) box and press "Save changes".'+ |
---|
448 | '</p><p class="alipi" style="margin-left:50px";>Add Audio - It allows you to '+ | | '</p><p class="alipi" style="margin-left:50px";>Add Audio - It allows you to '+ |
---|
449 | 'enter audio URL.</p>IMAGE:- <p class="alipi" style="margin-left:50px";> Replace - It allows you to enter '+ | | 'enter audio URL.</p>IMAGE:- <p class="alipi" style="margin-left:50px";> Replace - It allows you to enter '+ |
---|
450 | 'image URL.</p> UNDO:- Use it when you want to revert back to '+ | | 'image URL.</p> UNDO:- Use it when you want to revert back to '+ |
---|
451 | 'previous change.'+ | | 'previous change.'+ |
---|
452 | 'PUBLISH:- To publish your crafted changes to database and blog (Alipi/Personal).'+ | | 'PUBLISH:- To publish your crafted changes to database and blog (Alipi/Personal).'+ |
---|
453 | '<p class="alipi" style="margin-left:50px";>States - The place you are targetting to.</p><p class="alipi" '+ | | '<p class="alipi" style="margin-left:50px";>States - The place you are targetting to.</p><p class="alipi" '+ |
---|
454 | 'style="margin-left:50px";>Languages - In language you publishing.</p><p class="alipi" style= '+ | | 'style="margin-left:50px";>Languages - In language you publishing.</p><p class="alipi" style= '+ |
---|
455 | '"margin-left:50px";>Style - In what style you crafted?</p><p class="alipi" style="margin-left:50px";> '+ | | '"margin-left:50px";>Style - In what style you crafted?</p><p class="alipi" style="margin-left:50px";> '+ |
---|
456 | 'Author - Who is a crafter?</p><p class="alipi" style="margin-left:50px";>'+ | | 'Author - Who is a crafter?</p><p class="alipi" style="margin-left:50px";>'+ |
---|
457 | 'Alipi blog - If you don\'t have blogspot ID then check this to post it to our blog.</p></div>'; | | 'Alipi blog - If you don\'t have blogspot ID then check this to post it to our blog.</p></div>'; |
---|
| | 422 | $('#renarrated_overlay').addClass('barOnTop'); | | | 423 | a11ypi.ajax(); |
---|
| | 424 | a11ypi.ajaxLinks1(); |
---|
| | 425 | $('#edit-current').show(); |
---|
| | 426 | $("#see-narration").show(); |
---|
| | 427 | d = window.location.search.split('?')[1]; |
---|
| | 428 | var a =[]; |
---|
| | 429 | for (var i = 0;i<d.split('&').length;i++){ |
---|
| | 430 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; |
---|
| | 431 | } |
---|
| | 432 | if(a['blog'] != undefined ) { |
---|
| | 433 | $('#go').hide(); |
---|
| | 434 | $('#blog-filter').hide(); |
---|
| | 435 | } else { |
---|
| | 436 | } |
---|
458 | | 437 | |
---|
459 | $('body').append(help_template); | | $('body').append(help_template); |
---|
460 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
461 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 438 | if($('#orig-button').text() == 'Original Page') { | | | 439 | $('#share').insertAfter($('#go')); $('#share').show(); |
---|
| | 440 | $('#info').insertAfter($('#go')); $('#info').show(); |
---|
| | 441 | $('#orig-button').insertAfter($('#go')); $('#orig-button').show(); |
---|
| | 442 | $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root')); |
---|
| | 443 | } |
---|
462 | | 444 | |
---|
463 | $(function() { | | $(function() { |
---|
464 | $( "#helpwindow" ).dialog({ | | $( "#helpwindow" ).dialog({ |
---|
465 | width:800, | | width:800, |
---|
466 | height:550, | | height:550, |
---|
467 | modal: true, | | modal: true, |
---|
468 | close: function() { | | close: function() { |
---|
469 | $("#helpwindow").remove(); | | $("#helpwindow").remove(); |
---|
470 | } | | } |
---|
471 | }); | | }); |
---|
472 | }); | | }); |
---|
473 | }, | | }, |
---|
| | 445 | }, | | | 446 | checkSelect: function() |
---|
| | 447 | { |
---|
| | 448 | if($('#blog-filter').val() != "Choose a blog") { |
---|
| | 449 | $('#go').button({disabled : false}); |
---|
| | 450 | } else { |
---|
| | 451 | $('#go').button({disabled : true}); |
---|
| | 452 | } |
---|
| | 453 | }, |
---|
474 | | 454 | |
---|
475 | exitMode: function() { | | exitMode: function() { |
---|
476 | var exit = window.confirm("Do you really want to exit from edit mode?"); | | var exit = window.confirm("Do you really want to exit from edit mode?"); |
---|
477 | if (exit == true) { | | if (exit == true) { |
---|
478 | window.location.reload(); | | window.location.reload(); |
---|
479 | } | | } |
---|
480 | }, | | }, |
---|
| | 455 | help_window: function() { | | | 456 | var help_template = '<div id="helpwindow" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 457 | '<label id="txtlab" class="alipi" style="color:#aaa;font-size:100%;">TEXT :- It will popup a '+ |
---|
| | 458 | 'window and allow you to modify/replace text of select element on editor(right) box.'+ |
---|
| | 459 | '<p class="alipi">To delete - Empty the editor(right) box and press "Save changes".'+ |
---|
| | 460 | '</p><p class="alipi" style="margin-left:50px";>Add Audio - It allows you to '+ |
---|
| | 461 | 'enter audio URL.</p>IMAGE:- <p class="alipi" style="margin-left:50px";> Replace - It allows you to enter '+ |
---|
| | 462 | 'image URL.</p> UNDO:- Use it when you want to revert back to '+ |
---|
| | 463 | 'previous change.'+ |
---|
| | 464 | 'PUBLISH:- To publish your crafted changes to database and blog (Alipi/Personal).'+ |
---|
| | 465 | '<p class="alipi" style="margin-left:50px";>States - The place you are targetting to.</p><p class="alipi" '+ |
---|
| | 466 | 'style="margin-left:50px";>Languages - In language you publishing.</p><p class="alipi" style= '+ |
---|
| | 467 | '"margin-left:50px";>Style - In what style you crafted?</p><p class="alipi" style="margin-left:50px";> '+ |
---|
| | 468 | 'Author - Who is a crafter?</p><p class="alipi" style="margin-left:50px";>'+ |
---|
| | 469 | 'Alipi blog - If you don\'t have blogspot ID then check this to post it to our blog.</p></div>'; |
---|
481 | | 470 | |
---|
482 | hide_overlays: function() { | | hide_overlays: function() { |
---|
483 | if($('#icon-up').attr('down') == 'true') { | | if($('#icon-up').attr('down') == 'true') { |
---|
484 | $('#icon-up').attr('down', 'false'); | | $('#icon-up').attr('down', 'false'); |
---|
485 | $('#icon-up').show(); $('#icon-down').hide(); | | $('#icon-up').show(); $('#icon-down').hide(); |
---|
486 | $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop'); | | $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop'); |
---|
487 | } else { | | } else { |
---|
488 | $('#icon-up').attr('down', 'true'); | | $('#icon-up').attr('down', 'true'); |
---|
489 | $('#icon-down').show(); $('#icon-up').hide(); | | $('#icon-down').show(); $('#icon-up').hide(); |
---|
490 | $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom'); | | $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom'); |
---|
| | 471 | $('body').append(help_template); | | | 472 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 473 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
491 | | 474 | |
---|
492 | } | | } |
---|
493 | }, | | }, |
---|
| | 475 | $(function() { | | | 476 | $( "#helpwindow" ).dialog({ |
---|
| | 477 | width:800, |
---|
| | 478 | height:550, |
---|
| | 479 | modal: true, |
---|
| | 480 | close: function() { |
---|
| | 481 | $("#helpwindow").remove(); |
---|
| | 482 | } |
---|
| | 483 | }); |
---|
| | 484 | }); |
---|
| | 485 | }, |
---|
494 | | 486 | |
---|
495 | outterToggle: function() { | | outterToggle: function() { |
---|
496 | if($('#outter-down-button').attr('up') == 'true' ) { | | if($('#outter-down-button').attr('up') == 'true' ) { |
---|
497 | $('#outter-down-button').attr('up', 'false'); | | $('#outter-down-button').attr('up', 'false'); |
---|
498 | $('#outter-up-button').hide(); $('#outter-down-button').show(); | | $('#outter-up-button').hide(); $('#outter-down-button').show(); |
---|
499 | $('#renarrated_overlay').addClass('barOnBottom'); $('#renarrated_overlay').removeClass('barOnTop'); | | $('#renarrated_overlay').addClass('barOnBottom'); $('#renarrated_overlay').removeClass('barOnTop'); |
---|
500 | } else { | | } else { |
---|
501 | $('#outter-down-button').attr('up', 'true'); | | $('#outter-down-button').attr('up', 'true'); |
---|
502 | $('#outter-up-button').show(); $('#outter-down-button').hide(); | | $('#outter-up-button').show(); $('#outter-down-button').hide(); |
---|
503 | $('#renarrated_overlay').addClass('barOnTop'); $('#renarrated_overlay').removeClass('barOnBottom'); | | $('#renarrated_overlay').addClass('barOnTop'); $('#renarrated_overlay').removeClass('barOnBottom'); |
---|
504 | } | | } |
---|
505 | }, | | }, |
---|
| | 487 | exitMode: function() { | | | 488 | var exit = window.confirm("Do you really want to exit from edit mode?"); |
---|
| | 489 | if (exit == true) { |
---|
| | 490 | window.location.reload(); |
---|
| | 491 | } |
---|
| | 492 | }, |
---|
506 | | 493 | |
---|
| | 494 | hide_overlays: function() { |
---|
| | 495 | if($('#icon-up').attr('down') == 'true') { |
---|
| | 496 | $('#icon-up').attr('down', 'false'); |
---|
| | 497 | $('#icon-up').show(); $('#icon-down').hide(); |
---|
| | 498 | $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop'); |
---|
| | 499 | } else { |
---|
| | 500 | $('#icon-up').attr('down', 'true'); |
---|
| | 501 | $('#icon-down').show(); $('#icon-up').hide(); |
---|
| | 502 | $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom'); |
---|
507 | | 503 | |
---|
508 | getLoc: function() { | | getLoc: function() { |
---|
| | 504 | } | | | 505 | }, |
---|
509 | | 506 | |
---|
510 | $( "#loc-select" ).autocomplete({ | | $( "#loc-select" ).autocomplete({ |
---|
511 | source: function(req, add){ | | source: function(req, add){ |
---|
| | 507 | outterToggle: function() { | | | 508 | if($('#outter-down-button').attr('up') == 'true' ) { |
---|
| | 509 | $('#outter-down-button').attr('up', 'false'); |
---|
| | 510 | $('#outter-up-button').hide(); $('#outter-down-button').show(); |
---|
| | 511 | $('#renarrated_overlay').addClass('barOnBottom'); $('#renarrated_overlay').removeClass('barOnTop'); |
---|
| | 512 | } else { |
---|
| | 513 | $('#outter-down-button').attr('up', 'true'); |
---|
| | 514 | $('#outter-up-button').show(); $('#outter-down-button').hide(); |
---|
| | 515 | $('#renarrated_overlay').addClass('barOnTop'); $('#renarrated_overlay').removeClass('barOnBottom'); |
---|
| | 516 | } |
---|
| | 517 | }, |
---|
512 | | 518 | |
---|
513 | //pass request to server | | //pass request to server |
---|
514 | $.getJSON(config.deploy+"/getLoc?", req, function(data) { | | $.getJSON(config.deploy+"/getLoc?", req, function(data) { |
---|
515 | $('#loc-img').hide(); | | $('#loc-img').hide(); |
---|
516 | | 519 | |
---|
517 | //create array for response objects | | //create array for response objects |
---|
518 | var suggestions = []; | | var suggestions = []; |
---|
| | 520 | getLoc: function() { | 519 | | 521 | |
---|
520 | //process response | | //process response |
---|
521 | $.each(data['return'], function(i,val){ | | $.each(data['return'], function(i,val){ |
---|
522 | suggestions.push(val['name']+', '+val['country_name']); | | suggestions.push(val['name']+', '+val['country_name']); |
---|
523 | }); | | }); |
---|
524 | //pass array to callback | | //pass array to callback |
---|
525 | add(suggestions); | | add(suggestions); |
---|
526 | }); | | }); |
---|
527 | $('#loc-img').show(); | | $('#loc-img').show(); |
---|
528 | }, | | }, |
---|
529 | }); | | }); |
---|
530 | }, | | }, |
---|
| | 522 | $( "#loc-select" ).autocomplete({ | | | 523 | source: function(req, add){ |
---|
531 | | 524 | |
---|
532 | getLang: function() { | | getLang: function() { |
---|
533 | $( "#lang-select" ).autocomplete({ | | $( "#lang-select" ).autocomplete({ |
---|
534 | source: function(req, add){ | | source: function(req, add){ |
---|
| | 525 | //pass request to server | | | 526 | $.getJSON(config.deploy+"/getLoc?", req, function(data) { |
---|
| | 527 | $('#loc-img').hide(); |
---|
535 | | 528 | |
---|
536 | //pass request to server | | //pass request to server |
---|
537 | $.getJSON(config.deploy+"/getLang?", req, function(data) { | | $.getJSON(config.deploy+"/getLang?", req, function(data) { |
---|
538 | $('#lang-img').hide(); | | $('#lang-img').hide(); |
---|
| | 529 | //create array for response objects | | | 530 | var suggestions = []; |
---|
539 | | 531 | |
---|
540 | //create array for response objects | | //create array for response objects |
---|
541 | var suggestions = []; | | var suggestions = []; |
---|
| | 532 | //process response | | | 533 | $.each(data['return'], function(i,val){ |
---|
| | 534 | suggestions.push(val['name']+', '+val['country_name']); |
---|
| | 535 | }); |
---|
| | 536 | //pass array to callback |
---|
| | 537 | add(suggestions); |
---|
| | 538 | }); |
---|
| | 539 | $('#loc-img').show(); |
---|
| | 540 | }, |
---|
| | 541 | }); |
---|
| | 542 | }, |
---|
542 | | 543 | |
---|
543 | //process response | | //process response |
---|
544 | $.each(data['return'], function(i, val){ | | $.each(data['return'], function(i, val){ |
---|
545 | //suggestions.push(val.country); | | //suggestions.push(val.country); |
---|
546 | suggestions.push(val['name']); | | suggestions.push(val['name']); |
---|
547 | }); | | }); |
---|
548 | //pass array to callback | | //pass array to callback |
---|
549 | add(suggestions); | | add(suggestions); |
---|
550 | }); | | }); |
---|
551 | $('#lang-img').show(); | | $('#lang-img').show(); |
---|
552 | }, | | }, |
---|
553 | }); | | }); |
---|
| | 544 | getLang: function() { | | | 545 | $( "#lang-select" ).autocomplete({ |
---|
| | 546 | source: function(req, add){ |
---|
554 | | 547 | |
---|
| | 548 | //pass request to server |
---|
| | 549 | $.getJSON(config.deploy+"/getLang?", req, function(data) { |
---|
| | 550 | $('#lang-img').hide(); |
---|
555 | | 551 | |
---|
556 | }, | | }, |
---|
| | 552 | //create array for response objects | | | 553 | var suggestions = []; |
---|
557 | | 554 | |
---|
558 | loginToSwtStore: function() { | | loginToSwtStore: function() { |
---|
559 | var login_template = '<div id="login-template" style="display: none;" title="Please login" class="alipi ui-widget-header ui-corner-all">' + | | var login_template = '<div id="login-template" style="display: none;" title="Please login" class="alipi ui-widget-header ui-corner-all">' + |
---|
560 | '<div>' + | | '<div>' + |
---|
561 | '<h3> Registered Users:</h3>' + | | '<h3> Registered Users:</h3>' + |
---|
562 | '<div style="text-align: left;">Please enter your username and password </div>' + | | '<div style="text-align: left;">Please enter your username and password </div>' + |
---|
563 | '<input id="tar-uname" type="text" placeholder=" username" size="30">'+ | | '<input id="tar-uname" type="text" placeholder=" username" size="30">'+ |
---|
564 | '<input id="tar-pass" class="" type="password" placeholder=" password" size="30">'+ | | '<input id="tar-pass" class="" type="password" placeholder=" password" size="30">'+ |
---|
565 | '<h3 class="">Guest Users:</h3>' + | | '<h3 class="">Guest Users:</h3>' + |
---|
566 | '<div>Please enter your name </div>' + | | '<div>Please enter your name </div>' + |
---|
567 | '<input id="tar-name" class="" type="text" placeholder=" Your name" /> '+ | | '<input id="tar-name" class="" type="text" placeholder=" Your name" /> '+ |
---|
568 | '</div>' + | | '</div>' + |
---|
569 | '</div>'; | | '</div>'; |
---|
| | 555 | //process response | | | 556 | $.each(data['return'], function(i, val){ |
---|
| | 557 | //suggestions.push(val.country); |
---|
| | 558 | suggestions.push(val['name']); |
---|
| | 559 | }); |
---|
| | 560 | //pass array to callback |
---|
| | 561 | add(suggestions); |
---|
| | 562 | }); |
---|
| | 563 | $('#lang-img').show(); |
---|
| | 564 | }, |
---|
| | 565 | }); |
---|
570 | | 566 | |
---|
571 | if($('#login-template').length == 0) { | | if($('#login-template').length == 0) { |
---|
572 | $('body').append(login_template); | | $('body').append(login_template); |
---|
573 | } | | } |
---|
574 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
575 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
576 | | 567 | |
---|
577 | $('#login-template').dialog({ | | $('#login-template').dialog({ |
---|
578 | height: 400, | | height: 400, |
---|
579 | width: 400, | | width: 400, |
---|
580 | position: 'center', | | position: 'center', |
---|
581 | modal: true, | | modal: true, |
---|
582 | buttons: [ | | buttons: [ |
---|
583 | { | | { |
---|
584 | text: 'Login', | | text: 'Login', |
---|
585 | click: function() { | | click: function() { |
---|
586 | console.log('login'); | | console.log('login'); |
---|
587 | var uname = $('#tar-uname').val(); | | var uname = $('#tar-uname').val(); |
---|
588 | var pass = $('#tar-pass').val(); | | var pass = $('#tar-pass').val(); |
---|
589 | if(uname && pass) { | | if(uname && pass) { |
---|
590 | $('.login-button > .ui-button-text').text('Please wait..'); | | $('.login-button > .ui-button-text').text('Please wait..'); |
---|
591 | sweet.authenticate(config.sweet + '/authenticate', uname, pass, a11ypi.publish, function() { | | sweet.authenticate(config.sweet + '/authenticate', uname, pass, a11ypi.publish, function() { |
---|
592 | $('.login-button > .ui-button-text').text('Login'); | | $('.login-button > .ui-button-text').text('Login'); |
---|
| | 568 | }, | | | 569 | |
---|
| | 570 | loginToSwtStore: function() { |
---|
| | 571 | var login_template = '<div id="login-template" style="display: none;" title="Please login" class="alipi ui-widget-header ui-corner-all">' + |
---|
| | 572 | '<div>' + |
---|
| | 573 | '<h3> Registered Users:</h3>' + |
---|
| | 574 | '<div style="text-align: left;">Please enter your username and password </div>' + |
---|
| | 575 | '<input id="tar-uname" type="text" placeholder=" username" size="30">'+ |
---|
| | 576 | '<input id="tar-pass" class="" type="password" placeholder=" password" size="30">'+ |
---|
| | 577 | '<h3 class="">Guest Users:</h3>' + |
---|
| | 578 | '<div>Please enter your name </div>' + |
---|
| | 579 | '<input id="tar-name" class="" type="text" placeholder=" Your name" /> '+ |
---|
| | 580 | '</div>' + |
---|
| | 581 | '</div>'; |
---|
| | 582 | |
---|
| | 583 | if($('#login-template').length == 0) { |
---|
| | 584 | $('body').append(login_template); |
---|
| | 585 | } |
---|
| | 586 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 587 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 588 | |
---|
| | 589 | $('#login-template').dialog({ |
---|
| | 590 | height: 400, |
---|
| | 591 | width: 400, |
---|
| | 592 | position: 'center', |
---|
| | 593 | modal: true, |
---|
| | 594 | buttons: [ |
---|
| | 595 | { |
---|
| | 596 | text: 'Login', |
---|
| | 597 | click: function() { |
---|
| | 598 | console.log('login'); |
---|
| | 599 | var uname = $('#tar-uname').val(); |
---|
| | 600 | var pass = $('#tar-pass').val(); |
---|
| | 601 | if(uname && pass) { |
---|
| | 602 | $('.login-button > .ui-button-text').text('Please wait..'); |
---|
| | 603 | sweet.authenticate(config.sweet + '/authenticate', uname, pass, a11ypi.publish, function() { |
---|
| | 604 | $('.login-button > .ui-button-text').text('Login'); |
---|
| | 605 | }); |
---|
| | 606 | } |
---|
| | 607 | else { |
---|
| | 608 | //console.log('no username and password'); |
---|
| | 609 | //$('#login-error').show(); |
---|
| | 610 | //TODO: have a proper UI |
---|
| | 611 | alert('No username or password provided! Please enter both and then click Login'); |
---|
| | 612 | } |
---|
| | 613 | }, |
---|
| | 614 | 'class': 'login-button' |
---|
| | 615 | }, |
---|
| | 616 | { |
---|
| | 617 | text: 'Guest Login', |
---|
| | 618 | click: function() { |
---|
| | 619 | console.log('guest login'); |
---|
| | 620 | var name = $('#tar-name').val(); |
---|
| | 621 | if(name) { |
---|
| | 622 | $(this).dialog('close'); |
---|
| | 623 | a11ypi.publish(); |
---|
| | 624 | } |
---|
| | 625 | else { |
---|
| | 626 | //console.log('no guest name'); |
---|
| | 627 | //$('#guest-error').show(); |
---|
| | 628 | alert('Please provide a name for Guest Login'); |
---|
| | 629 | } |
---|
| | 630 | } |
---|
| | 631 | } |
---|
| | 632 | ], |
---|
| | 633 | close: function() { |
---|
| | 634 | console.log('close'); |
---|
| | 635 | } |
---|
593 | }); | 636 | }); |
---|
| | 637 | }, |
---|
| | 638 | |
---|
| | 639 | publish: function() { |
---|
| | 640 | $('#login-template').dialog('close'); |
---|
| | 641 | if(util.hasChangesPending()) |
---|
| | 642 | { |
---|
| | 643 | $('#pub_overlay').slideUp(); |
---|
| | 644 | $('#element_edit_overlay').slideUp(); |
---|
| | 645 | $('#icon_on_overlay').slideUp(); |
---|
| | 646 | if (a11ypi.target == false ) { |
---|
| | 647 | var publish_template = '<div id="targetoverlay" title="Who are you narrating to?" class="alipi ui-widget-header ui-corner-all"> '+ |
---|
| | 648 | // '<div id="infovis" class="alipi"> </div>'+ |
---|
| | 649 | '<label id="tar-lab1" class="alipi" >Enter few attributes of the target community </label>'+ |
---|
| | 650 | '<label id="tar-lab2" class="alipi" >Location of the target community: </label> '+ |
---|
| | 651 | '<input id="loc-select" class="alipi" placeholder="Type city/town name"/> '+ |
---|
| | 652 | '<img id="loc-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif" /> '+ |
---|
| | 653 | '<label id="tar-lab3" class="alipi" >Language of re-narration: </label> '+ |
---|
| | 654 | '<input id="lang-select" class="alipi" placeholder="Type language name"/>'+ |
---|
| | 655 | '<img id="lang-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif"/> '+ |
---|
| | 656 | '<label id="tar-lab4" class="alipi" >Select a style of re-narration: </label> '+ |
---|
| | 657 | '<select id="style-select" class="alipi" > '+ |
---|
| | 658 | '<option>Translation</option><option>Technical</option><option>Fun</option><option>Simplification</option> '+ |
---|
| | 659 | '<option>Correction</option><option>Evolution</option><option>Other</option></select>'+ |
---|
| | 660 | '<div id="free-form"><label id="tar-lab8" class="alipi">Comments:</label><textarea id="tar-comment"></textarea></div>'+ |
---|
| | 661 | '<div id="blogset" > We are having issues with posting to a personal Google blog. Please use demo.swtr.us to publish.</div> '+ |
---|
| | 662 | '<p id="tar-p" ><input id="our-check" class="alipi" type="radio"name="blog" /> '+ |
---|
| | 663 | '<label id="tar-lab6" class="alipi" > demo.swtr.us </label><input id="your-check" class="alipi" type="radio" name="blog" /> '+ |
---|
| | 664 | '<label id="tar-lab7" class="alipi">Personal Blog</label></p></div>'; |
---|
| | 665 | |
---|
| | 666 | $('body').append(publish_template); |
---|
| | 667 | a11ypi.getLoc(); |
---|
| | 668 | a11ypi.getLang(); |
---|
| | 669 | a11ypi.target = true; |
---|
| | 670 | } |
---|
| | 671 | |
---|
| | 672 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 673 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 674 | |
---|
| | 675 | $('#pub_overlay').slideUp(); |
---|
| | 676 | $('#element_edit_overlay').slideUp(); |
---|
| | 677 | // $('#icon_on_overlay').slideUp(); |
---|
| | 678 | |
---|
| | 679 | $(function() { |
---|
| | 680 | $( "#targetoverlay" ).dialog({ |
---|
| | 681 | height:550, |
---|
| | 682 | width:700, |
---|
| | 683 | modal: true, |
---|
| | 684 | buttons: { |
---|
| | 685 | Publish: function() { |
---|
| | 686 | util.publish(); |
---|
| | 687 | }, |
---|
| | 688 | |
---|
| | 689 | }, |
---|
| | 690 | close: function() { |
---|
| | 691 | $('#pub_overlay').slideDown(); |
---|
| | 692 | // $('#element_edit_overlay').slideDown(); |
---|
| | 693 | // $('#icon_on_overlay').slideDown(); |
---|
| | 694 | $( "#targetoverlay" ).hide(); |
---|
| | 695 | } |
---|
| | 696 | }); |
---|
| | 697 | }); |
---|
| | 698 | } |
---|
| | 699 | }, |
---|
| | 700 | |
---|
| | 701 | hideAll: function() { |
---|
| | 702 | var boxes = '#show-links, #show-box, #show-comment'; |
---|
| | 703 | if($(boxes).dialog().dialog("isOpen")) |
---|
| | 704 | $(boxes).dialog().dialog('close'); |
---|
| | 705 | }, |
---|
| | 706 | |
---|
| | 707 | showBox: function() { |
---|
| | 708 | a11ypi.hideAll(); |
---|
| | 709 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 710 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 711 | |
---|
| | 712 | $(function() { |
---|
| | 713 | // $( "#show-box" ).dialog( "destroy" ); |
---|
| | 714 | |
---|
| | 715 | $( "#show-box" ).dialog({ |
---|
| | 716 | width: 300, |
---|
| | 717 | height: 300, |
---|
| | 718 | modal: true |
---|
| | 719 | }); |
---|
| | 720 | }); |
---|
| | 721 | d = window.location.search.split('?')[1]; |
---|
| | 722 | var a = a11ypi.getParams(); |
---|
| | 723 | if (a['blog'] === undefined ) { |
---|
| | 724 | a11ypi.createMenu('re-narration'); |
---|
| | 725 | } |
---|
| | 726 | else { |
---|
| | 727 | $('#show-box').attr('title', 'Choose a re-narration from the blog you specified.'); |
---|
| | 728 | a11ypi.ajax1(); |
---|
| | 729 | } |
---|
| | 730 | }, |
---|
| | 731 | showComment: function() { |
---|
| | 732 | a11ypi.hideAll(); |
---|
| | 733 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 734 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 735 | |
---|
| | 736 | $(function() { |
---|
| | 737 | $( "#show-comment" ).dialog( "destroy" ); |
---|
| | 738 | |
---|
| | 739 | $( "#show-comment" ).dialog({ |
---|
| | 740 | width: 300, |
---|
| | 741 | height: 300, |
---|
| | 742 | modal: true |
---|
| | 743 | }); |
---|
| | 744 | }); |
---|
| | 745 | a11ypi.createMenu('5el'); |
---|
| | 746 | }, |
---|
| | 747 | |
---|
| | 748 | ajaxLinks1: function() { |
---|
| | 749 | // var xhr = new XMLHttpRequest(); |
---|
| | 750 | // xhr.onreadystatechange = function() |
---|
| | 751 | // { |
---|
| | 752 | // if(xhr.readyState == 4) |
---|
| | 753 | // { |
---|
| | 754 | // if(xhr.responseText == "empty") |
---|
| | 755 | // { } |
---|
| | 756 | // else |
---|
| | 757 | // { |
---|
| | 758 | // $('#see-links').show(); |
---|
| | 759 | // a11ypi.showlinks = JSON.parse(xhr.responseText); |
---|
| | 760 | // } |
---|
| | 761 | // } |
---|
| | 762 | // } |
---|
| | 763 | // xhr.open("POST",config.deploy+"/domain",true); |
---|
| | 764 | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
| | 765 | // d = window.location.search.split('?')[1]; |
---|
| | 766 | // a = a11ypi.getParams(); |
---|
| | 767 | // xhr.send('url='+a['foruri']) |
---|
| | 768 | |
---|
| | 769 | $.get(config.deploy+"/domain", {"url":a['foruri']}, function(data){ |
---|
| | 770 | if(data[0] != 'empty') |
---|
| | 771 | { |
---|
| | 772 | a11ypi.showlinks = data; |
---|
| | 773 | $('#see-links').show(); |
---|
| | 774 | } |
---|
| | 775 | }); |
---|
| | 776 | }, |
---|
| | 777 | showBox1: function() { |
---|
| | 778 | a11ypi.hideAll(); |
---|
| | 779 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 780 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 781 | |
---|
| | 782 | $(function() { |
---|
| | 783 | // $( "#show-links" ).dialog( "destroy" ); |
---|
| | 784 | |
---|
| | 785 | $( "#show-links" ).dialog({ |
---|
| | 786 | width: 500, |
---|
| | 787 | height: 300, |
---|
| | 788 | modal: true |
---|
| | 789 | }); |
---|
| | 790 | }); |
---|
| | 791 | a11ypi.createDomainMenu(); |
---|
| | 792 | }, |
---|
| | 793 | createDomainMenu: function() { |
---|
| | 794 | var xyz = $("#show-links"); |
---|
| | 795 | xyz.html(''); |
---|
| | 796 | for(var i in a11ypi.showlinks) |
---|
| | 797 | { |
---|
| | 798 | var para = document.createElement("p"); |
---|
| | 799 | var newel = document.createElement("a"); |
---|
| | 800 | newel.textContent = a11ypi.showlinks[i]; |
---|
| | 801 | newel.setAttribute("href", config.deploy+"/?foruri="+encodeURIComponent(a11ypi.showlinks[i])); |
---|
| | 802 | newel.setAttribute("class","alipiShowLink"); |
---|
| | 803 | para.appendChild(newel); |
---|
| | 804 | xyz.append(para); |
---|
| | 805 | } |
---|
| | 806 | $('.alipiShowLink').hover( |
---|
| | 807 | function() { |
---|
| | 808 | var xhr = new XMLHttpRequest(); |
---|
| | 809 | xhr.onreadystatechange = function() |
---|
| | 810 | { |
---|
| | 811 | if(xhr.readyState == 4) |
---|
| | 812 | { |
---|
| | 813 | if(xhr.responseText == "empty") |
---|
| | 814 | { } |
---|
| | 815 | else |
---|
| | 816 | { |
---|
| | 817 | menu_list = JSON.parse(xhr.responseText); |
---|
| | 818 | x = ''; |
---|
| | 819 | for(i=0; i<menu_list.length; i++) { |
---|
| | 820 | if (i == menu_list.length-1) { |
---|
| | 821 | x += menu_list[i]; |
---|
| | 822 | } else { |
---|
| | 823 | x += menu_list[i] + ", "; |
---|
| | 824 | } |
---|
| | 825 | } |
---|
| | 826 | $('#show-links').title = x; |
---|
| | 827 | } |
---|
| | 828 | } |
---|
| | 829 | } |
---|
| | 830 | xhr.open("POST",config.root+"/menu",true); |
---|
| | 831 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
| | 832 | xhr.send('url='+encodeURIComponent($(this).attr('href'))) ; |
---|
| | 833 | }, |
---|
| | 834 | function () {$('#show-links').title= '';} |
---|
| | 835 | ); |
---|
| | 836 | }, |
---|
| | 837 | // blogFilter: function() { |
---|
| | 838 | // if (a11ypi.blog_flag == false) { |
---|
| | 839 | // a11ypi.blog_flag = true; |
---|
| | 840 | // // var xhr = new XMLHttpRequest(); |
---|
| | 841 | // // xhr.onreadystatechange = function() |
---|
| | 842 | // // { |
---|
| | 843 | // // if(xhr.readyState == 4) |
---|
| | 844 | // // { |
---|
| | 845 | // // if(xhr.responseText == "empty") |
---|
| | 846 | // // { } |
---|
| | 847 | // // else |
---|
| | 848 | // // { |
---|
| | 849 | // // var sel = $("#blog-filter"); |
---|
| | 850 | // // var menu_list = JSON.parse(xhr.responseText); |
---|
| | 851 | // // opt = document.createElement("option"); |
---|
| | 852 | // // opt.textContent = "Choose a blog"; |
---|
| | 853 | // // sel.append(opt); |
---|
| | 854 | // // for (var i=0; i < menu_list.length; i++) |
---|
| | 855 | // // { |
---|
| | 856 | // // opt = document.createElement("option"); |
---|
| | 857 | // // opt.textContent = menu_list[i]; |
---|
| | 858 | // // sel.append(opt); |
---|
| | 859 | // // } |
---|
| | 860 | // // } |
---|
| | 861 | // // } |
---|
| | 862 | // // } |
---|
| | 863 | // // xhr.open("POST",config.deploy+"/blog",true); |
---|
| | 864 | // // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
| | 865 | // // a = a11ypi.getParams(); |
---|
| | 866 | // // xhr.send('url='+a['foruri']); |
---|
| | 867 | // $.get(config.deploy+"/blog", {"url":a['foruri']}, function(data){ |
---|
| | 868 | // var sel = $("#blog-filter"); |
---|
| | 869 | // var menu_list = JSON.parse(data); |
---|
| | 870 | // opt = document.createElement("option"); |
---|
| | 871 | // opt.textContent = "Choose a blog"; |
---|
| | 872 | // sel.append(opt); |
---|
| | 873 | // for (var i=0; i < menu_list.length; i++) |
---|
| | 874 | // { |
---|
| | 875 | // opt = document.createElement("option"); |
---|
| | 876 | // opt.textContent = menu_list[i]; |
---|
| | 877 | // sel.append(opt); |
---|
| | 878 | // } |
---|
| | 879 | // }); |
---|
| | 880 | // } |
---|
| | 881 | // }, |
---|
| | 882 | go: function() { |
---|
| | 883 | var a =[]; |
---|
| | 884 | for (var i = 0;i<d.split('&').length;i++){ |
---|
| | 885 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; |
---|
| | 886 | } |
---|
| | 887 | if ($("#blog-filter").val() == null) |
---|
| | 888 | { } |
---|
| | 889 | else { |
---|
| | 890 | window.open(config.deploy+"/?foruri=" + a['foruri'] + "&blog=" + $("#blog-filter").val()); |
---|
| | 891 | } |
---|
| | 892 | }, |
---|
| | 893 | share: function() { |
---|
| | 894 | $('#fb-like').css('display', 'block'); |
---|
| | 895 | $('#tweet-root').css('display', 'block'); |
---|
| | 896 | $( "#share-box" ).dialog({ |
---|
| | 897 | position: 'center', |
---|
| | 898 | width:450, |
---|
| | 899 | height:180, |
---|
| | 900 | modal: true, |
---|
| | 901 | }); |
---|
| | 902 | }, |
---|
| | 903 | editPage: function() { |
---|
| | 904 | //this.hideAll(); |
---|
| | 905 | a11ypi.testContext(); |
---|
| | 906 | $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); |
---|
| | 907 | $('#icon-down').show(); |
---|
| | 908 | $('#renarrated_overlay').hide(); |
---|
| | 909 | $('body *').not('iframe').contents().filter(function(){ |
---|
| | 910 | { |
---|
| | 911 | try{ |
---|
| | 912 | if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') ) |
---|
| | 913 | return this; |
---|
| | 914 | } |
---|
| | 915 | catch(err) |
---|
| | 916 | { |
---|
| | 917 | //pass |
---|
| | 918 | } |
---|
| | 919 | } |
---|
| | 920 | }).click(pageEditor.startEdit); |
---|
| | 921 | |
---|
| | 922 | $('body *').not('iframe').contents().filter(function(){ |
---|
| | 923 | { |
---|
| | 924 | try{ |
---|
| | 925 | if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype')) |
---|
| | 926 | return this; |
---|
| | 927 | } |
---|
| | 928 | catch(err) |
---|
| | 929 | { |
---|
| | 930 | //pass |
---|
| | 931 | } |
---|
| | 932 | } |
---|
| | 933 | }).click(pageEditor.noEdit); |
---|
| | 934 | |
---|
| | 935 | $(document).mouseover(a11ypi.highlightOnHover); |
---|
| | 936 | $(document).mouseout(a11ypi.unhighlightOnMouseOut); |
---|
| | 937 | }, |
---|
| | 938 | |
---|
| | 939 | displayEditor: function() { |
---|
| | 940 | var template = '<div id="editoroverlay" title="Editor" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 941 | '<button id="close-adv" class="alipi" onclick="a11ypi.closeAdv();" title="Want to close View Source & display without HTML code?"> '+ |
---|
| | 942 | 'Render source</button> '+ |
---|
| | 943 | '<button id="adv-ref" class="alipi" onclick="a11ypi.showAdv();" title="Want to see HTML code? Then click me !!">View Source</button> '+ |
---|
| | 944 | '<label id="ref-lab" class="alipi" style="left:3%;">Here is original piece (Reference)</label>'+ |
---|
| | 945 | '<div id="reference" class="alipi" readonly="yes"></div>'+ |
---|
| | 946 | '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+ |
---|
| | 947 | '<label id="edit-lab" class="alipi" style="left:53%;">Where you should edit (Editor)</label>'+ |
---|
| | 948 | '<div id="editor" class="alipi" contenteditable="true" '+ |
---|
| | 949 | '</div>'; |
---|
| | 950 | $('body').append(template); |
---|
| | 951 | $('#pub_overlay').slideUp(); |
---|
| | 952 | $('#element_edit_overlay').hide(); |
---|
| | 953 | |
---|
| | 954 | var tag = pageEditor.event.target.nodeName; |
---|
| | 955 | $(pageEditor.event.target).removeAttr('m4pageedittype'); |
---|
| | 956 | $(pageEditor.event.target).children().removeAttr('m4pageedittype'); |
---|
| | 957 | |
---|
| | 958 | $('#adv-reference').text('<'+tag+'>'+$(pageEditor.event.target).html()+'</'+tag+'>'); |
---|
| | 959 | $('#reference').html($(pageEditor.event.target).html()); |
---|
| | 960 | $('#editor').html($(pageEditor.event.target).html()); |
---|
| | 961 | $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi'); |
---|
| | 962 | $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi'); |
---|
| | 963 | $('#close-adv').hide(); |
---|
| | 964 | $('#adv-ref').button(); |
---|
| | 965 | |
---|
| | 966 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 967 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 968 | |
---|
| | 969 | $( "#editoroverlay" ).dialog({ |
---|
| | 970 | position: 'center', |
---|
| | 971 | width:$(window).width()-10, |
---|
| | 972 | height:$(window).height()-50, |
---|
| | 973 | modal: true, |
---|
| | 974 | buttons: { |
---|
| | 975 | "+": function() { |
---|
| | 976 | if($('#editor').css('font-size') >= '30px') { |
---|
| | 977 | // passthrough |
---|
| | 978 | } |
---|
| | 979 | else { |
---|
| | 980 | var font = parseFloat($('#editor').css('font-size')) + 1; |
---|
| | 981 | $('#editor').css('font-size', font+'px'); |
---|
| | 982 | font = parseFloat($('#reference').css('font-size')) + 1; |
---|
| | 983 | $('#reference').css('font-size', font+'px'); |
---|
| | 984 | font = parseFloat($('#adv-reference').css('font-size')) + 1; |
---|
| | 985 | $('#adv-reference').css('font-size', font+'px'); |
---|
| | 986 | } |
---|
| | 987 | }, |
---|
| | 988 | "-": function() { |
---|
| | 989 | if($('#editor').css('font-size') <= '10px') { |
---|
| | 990 | //passthrough |
---|
| | 991 | } |
---|
| | 992 | else { |
---|
| | 993 | var font = parseFloat($('#editor').css('font-size')) - 1; |
---|
| | 994 | $('#editor').css('font-size', font+'px'); |
---|
| | 995 | font = parseFloat($('#reference').css('font-size')) - 1; |
---|
| | 996 | $('#reference').css('font-size', font+'px'); |
---|
| | 997 | font = parseFloat($('#adv-reference').css('font-size')) - 1; |
---|
| | 998 | $('#adv-reference').css('font-size', font+'px'); |
---|
| | 999 | } |
---|
| | 1000 | }, |
---|
| | 1001 | "Add Link": function() { |
---|
| | 1002 | pageEditor.handler(); |
---|
| | 1003 | }, |
---|
| | 1004 | "Save changes": function() { |
---|
| | 1005 | $('#pub_overlay').slideDown(); |
---|
| | 1006 | $('#element_edit_overlay').slideDown(); |
---|
| | 1007 | $('#icon_on_overlay').slideDown(); |
---|
| | 1008 | manager.recordText(pageEditor.event.target); |
---|
| | 1009 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1010 | $( "#editoroverlay" ).remove(); |
---|
| | 1011 | } |
---|
| | 1012 | }, |
---|
| | 1013 | close: function() { |
---|
| | 1014 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1015 | $("#editoroverlay" ).remove(); |
---|
| | 1016 | } |
---|
| | 1017 | }); |
---|
| | 1018 | |
---|
| | 1019 | $($($('<label>').insertAfter($('.ui-dialog-buttonset').children()[0])).html('Magnify or Demagnify')); // Element added externally with css |
---|
| | 1020 | $($('.ui-dialog-buttonset').children()[1]).attr('id','mag-demag'); |
---|
| | 1021 | $($('.ui-dialog-buttonset').children()[0]).attr('id','mag'); // '+' |
---|
| | 1022 | $($('.ui-dialog-buttonset').children()[2]).attr('id','demag'); // '-' |
---|
| | 1023 | $($('.ui-dialog-buttonset').children()[3]).attr('id','add-link'); // 'Link' |
---|
| | 1024 | $($('.ui-dialog-buttonset').children()[4]).attr('id','save-changes'); // 'Save Changes' |
---|
| | 1025 | |
---|
| | 1026 | $('#adv-reference').height($('#editor').height() + 40); |
---|
| | 1027 | $('#reference').height($('#editor').height()); |
---|
| | 1028 | $('#mag').attr('title', 'To magnify letters/Increase font size'); |
---|
| | 1029 | $('#demag').attr('title', 'To demagnify letters/Decrease font size'); |
---|
| | 1030 | $('#add-link').attr('title', 'Add link(href) to the selected text portion (Before clicking this button, select some portion of text in "Editor")'); |
---|
| | 1031 | $('#save-changes').attr('title', 'Save edited text onto the page') |
---|
| | 1032 | }, |
---|
| | 1033 | |
---|
| | 1034 | showAdv: function() { |
---|
| | 1035 | $('#reference').hide(); |
---|
| | 1036 | $('#adv-reference').show(); |
---|
| | 1037 | $('#adv-ref').hide(); |
---|
| | 1038 | $('#close-adv').show(); |
---|
| | 1039 | }, |
---|
| | 1040 | closeAdv: function() { |
---|
| | 1041 | $('#reference').show(); |
---|
| | 1042 | $('#adv-reference').hide(); |
---|
| | 1043 | $('#close-adv').hide(); |
---|
| | 1044 | $('#adv-ref').show(); |
---|
| | 1045 | }, |
---|
| | 1046 | |
---|
| | 1047 | reflectInReference: function() { |
---|
| | 1048 | var tag = pageEditor.event.target.nodeName; |
---|
| | 1049 | $("#reference").html() = $("#editor").html(); |
---|
| | 1050 | }, |
---|
| | 1051 | |
---|
| | 1052 | imageReplacer: function() { |
---|
| | 1053 | var imageInputTemplate = '<div id="imageInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 1054 | '<input type="text" id="imageInput" placeholder="http://foo.com/baz.jpg" class="alipi" value=""/></div>'; |
---|
| | 1055 | |
---|
| | 1056 | $('body').append(imageInputTemplate); |
---|
| | 1057 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 1058 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1059 | |
---|
| | 1060 | $('#pub_overlay').slideUp(); |
---|
| | 1061 | $('#element_edit_overlay').slideUp(); |
---|
| | 1062 | $('#icon_on_overlay').slideUp(); |
---|
| | 1063 | |
---|
| | 1064 | $( "#imageInputElement" ).dialog({ |
---|
| | 1065 | width:300, |
---|
| | 1066 | height:200, |
---|
| | 1067 | modal: true, |
---|
| | 1068 | buttons: { |
---|
| | 1069 | OK: function() { |
---|
| | 1070 | var formValue = $('#imageInput').val(); |
---|
| | 1071 | if(formValue != '\/S/') |
---|
| | 1072 | { |
---|
| | 1073 | manager.recordImage(pageEditor.event.target, formValue); |
---|
| | 1074 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1075 | $( "#imageInputElement" ).remove(); |
---|
| | 1076 | } |
---|
| | 1077 | } |
---|
| | 1078 | }, |
---|
| | 1079 | close: function() { |
---|
| | 1080 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1081 | $("#imageInputElement" ).remove(); |
---|
| | 1082 | } |
---|
| | 1083 | }); |
---|
| | 1084 | |
---|
| | 1085 | }, |
---|
| | 1086 | |
---|
| | 1087 | addAudio: function() { |
---|
| | 1088 | var audioInputTemplate = '<div id="audioInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 1089 | '<input type="text" id="audioInput" placeholder="http://foo.com/baz.ogg" class="alipi" value=""/></div>'; |
---|
| | 1090 | |
---|
| | 1091 | $('body').append(audioInputTemplate); |
---|
| | 1092 | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
| | 1093 | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1094 | |
---|
| | 1095 | $('#pub_overlay').slideUp(); |
---|
| | 1096 | $('#element_edit_overlay').slideUp(); |
---|
| | 1097 | $('#icon_on_overlay').slideUp(); |
---|
| | 1098 | |
---|
| | 1099 | $( "#audioInputElement" ).dialog({ |
---|
| | 1100 | width:300, |
---|
| | 1101 | height:200, |
---|
| | 1102 | modal: true, |
---|
| | 1103 | buttons: { |
---|
| | 1104 | OK: function() { |
---|
| | 1105 | pageEditor.addAudio(); |
---|
| | 1106 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1107 | $( "#audioInputElement" ).remove(); |
---|
| | 1108 | } |
---|
| | 1109 | }, |
---|
| | 1110 | close: function() { |
---|
| | 1111 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1112 | $("#audioInputElement" ).remove(); |
---|
| | 1113 | } |
---|
| | 1114 | }); |
---|
| | 1115 | }, |
---|
| | 1116 | |
---|
| | 1117 | highlightOnHover: function(event) { |
---|
| | 1118 | if( !($(event.target).hasClass('alipi')) ) { |
---|
| | 1119 | $(event.target).addClass('highlightElement'); |
---|
| | 1120 | } |
---|
| | 1121 | }, |
---|
| | 1122 | |
---|
| | 1123 | unhighlightOnMouseOut: function(event) { |
---|
| | 1124 | $(event.target).removeClass('highlightElement'); |
---|
| | 1125 | }, |
---|
| | 1126 | showInfo: function(data) { |
---|
| | 1127 | infoWindow = window.open(config.deploy+'/blank','Info page'); |
---|
| | 1128 | window.setTimeout(function(){a11ypi.pushInfo(infoWindow.document.getElementById('info_content'),infoWindow,data);},2500); |
---|
| | 1129 | }, |
---|
| | 1130 | pushInfo: function(ele, win, data) //ele contains the info_content element from blank.html |
---|
| | 1131 | { |
---|
| | 1132 | win.infoFullJSON = a11ypi.responseJSON; |
---|
| | 1133 | win.onLoad(); |
---|
| | 1134 | }, |
---|
| | 1135 | getParams: function() |
---|
| | 1136 | { |
---|
| | 1137 | var a = []; |
---|
| | 1138 | if(window.location.hostname == config.hostname || "localhost" ) |
---|
| | 1139 | { |
---|
| | 1140 | d = window.location.search.split('?')[1]; |
---|
| | 1141 | for (var i = 0;i<d.split('&').length;i++){ |
---|
| | 1142 | a[d.split('&')[i].split('=')[0]] = decodeURIComponent(d.split('&')[i].split('=')[1]); |
---|
| | 1143 | } |
---|
| | 1144 | return a; |
---|
| | 1145 | } |
---|
| | 1146 | else |
---|
| | 1147 | { |
---|
| | 1148 | a['foruri'] = window.location.href; |
---|
| | 1149 | return a; |
---|
| | 1150 | } |
---|
594 | } | 1151 | } |
---|
595 | else { | | else { |
---|
596 | //console.log('no username and password'); | | //console.log('no username and password'); |
---|
597 | //$('#login-error').show(); | | //$('#login-error').show(); |
---|
598 | //TODO: have a proper UI | | //TODO: have a proper UI |
---|
599 | alert('No username or password provided! Please enter both and then click Login'); | | alert('No username or password provided! Please enter both and then click Login'); |
---|
600 | } | | } |
---|
| | 1152 | }; | | | 1153 | window.a11ypi = a11ypi; |
---|
| | 1154 | |
---|
| | 1155 | |
---|
| | 1156 | }); |
---|
| | 1157 | window.a11ypi.loadOverlay(); |
---|
| | 1158 | var pageEditor = { |
---|
| | 1159 | event: 0 , //Use this var to store the event object, which will be passed for editor. |
---|
| | 1160 | m4pageedittype: '', |
---|
| | 1161 | savedHtml: '', |
---|
| | 1162 | url:'', |
---|
| | 1163 | selection:'', |
---|
| | 1164 | startEdit: function(event) |
---|
| | 1165 | { |
---|
| | 1166 | if(event.target.nodeName != 'AUDIO'){ |
---|
| | 1167 | event.stopPropagation(); |
---|
| | 1168 | event.preventDefault(); |
---|
| | 1169 | } |
---|
| | 1170 | pageEditor.event = event; |
---|
| | 1171 | pageEditor.m4pageedittype = $(event.target).attr('m4pageedittype'); |
---|
| | 1172 | $('*').removeClass('highlightOnSelect'); |
---|
| | 1173 | |
---|
| | 1174 | if (pageEditor.event) { |
---|
| | 1175 | xAxis = pageEditor.event.clientX; |
---|
| | 1176 | yAxis = pageEditor.event.clientY; |
---|
| | 1177 | $("#element_edit_overlay").css("top", yAxis); |
---|
| | 1178 | $("#element_edit_overlay").css("left", xAxis); |
---|
| | 1179 | } |
---|
| | 1180 | |
---|
| | 1181 | if($(event.target).attr('m4pageedittype') == 'text') { |
---|
| | 1182 | $(event.target).addClass('highlightOnSelect'); // To show selected element |
---|
| | 1183 | |
---|
| | 1184 | $('#edit-text').show(); |
---|
| | 1185 | $('#add-audio').show(); |
---|
| | 1186 | $('#close-element').show(); |
---|
| | 1187 | $('#replace-image').hide(); |
---|
| | 1188 | $('#delete-image').hide(); |
---|
| | 1189 | $('#cant-edit').hide(); |
---|
| | 1190 | $("body").css("overflow", "hidden"); |
---|
| | 1191 | $('#pub_overlay').slideDown(); |
---|
| | 1192 | $('#element_edit_overlay').slideDown(); |
---|
| | 1193 | // At this point 'displayEditor' function will be performed on click of 'Edit Text' button |
---|
| | 1194 | // displayEditor function is in ui.js file |
---|
| | 1195 | } |
---|
| | 1196 | else if($(event.target).attr('m4pageedittype') == 'image') { |
---|
| | 1197 | $(event.target).addClass('highlightOnSelect'); // To show selected element |
---|
| | 1198 | |
---|
| | 1199 | $('#replace-image').show(); |
---|
| | 1200 | $('#delete-image').show(); |
---|
| | 1201 | $('#close-element').show(); |
---|
| | 1202 | $('#add-audio').hide(); |
---|
| | 1203 | $('#edit-text').hide(); |
---|
| | 1204 | $('#cant-edit').hide(); |
---|
| | 1205 | $("body").css("overflow", "hidden"); |
---|
| | 1206 | $('#element_edit_overlay').slideDown(); |
---|
| | 1207 | $('#pub_overlay').slideDown(); |
---|
| | 1208 | // At this point 'imageReplacer' function will be performed on click of 'Replace Image' button |
---|
| | 1209 | // imageReplacer function is in ui.js |
---|
| | 1210 | } |
---|
601 | }, | 1211 | }, |
---|
602 | 'class': 'login-button' | | 'class': 'login-button' |
---|
603 | }, | | }, |
---|
604 | { | | { |
---|
605 | text: 'Guest Login', | | text: 'Guest Login', |
---|
606 | click: function() { | | click: function() { |
---|
607 | console.log('guest login'); | | console.log('guest login'); |
---|
608 | var name = $('#tar-name').val(); | | var name = $('#tar-name').val(); |
---|
609 | if(name) { | | if(name) { |
---|
610 | $(this).dialog('close'); | | $(this).dialog('close'); |
---|
611 | a11ypi.publish(); | | a11ypi.publish(); |
---|
612 | } | | } |
---|
613 | else { | | else { |
---|
614 | //console.log('no guest name'); | | //console.log('no guest name'); |
---|
615 | //$('#guest-error').show(); | | //$('#guest-error').show(); |
---|
616 | alert('Please provide a name for Guest Login'); | | alert('Please provide a name for Guest Login'); |
---|
617 | } | | } |
---|
618 | } | | } |
---|
619 | } | | } |
---|
620 | ], | | ], |
---|
621 | close: function() { | | close: function() { |
---|
622 | console.log('close'); | | console.log('close'); |
---|
623 | } | | } |
---|
624 | }); | | }); |
---|
625 | }, | | }, |
---|
626 | | 1212 | |
---|
627 | publish: function() { | | publish: function() { |
---|
628 | $('#login-template').dialog('close'); | | $('#login-template').dialog('close'); |
---|
629 | if(util.hasChangesPending()) | | if(util.hasChangesPending()) |
---|
630 | { | | { |
---|
631 | $('#pub_overlay').slideUp(); | | $('#pub_overlay').slideUp(); |
---|
632 | $('#element_edit_overlay').slideUp(); | | $('#element_edit_overlay').slideUp(); |
---|
633 | $('#icon_on_overlay').slideUp(); | | $('#icon_on_overlay').slideUp(); |
---|
634 | if (a11ypi.target == false ) { | | if (a11ypi.target == false ) { |
---|
635 | var publish_template = '<div id="targetoverlay" title="Who are you narrating to?" class="alipi ui-widget-header ui-corner-all"> '+ | | var publish_template = '<div id="targetoverlay" title="Who are you narrating to?" class="alipi ui-widget-header ui-corner-all"> '+ |
---|
636 | // '<div id="infovis" class="alipi"> </div>'+ | | // '<div id="infovis" class="alipi"> </div>'+ |
---|
637 | '<label id="tar-lab1" class="alipi" >Enter few attributes of the target community </label>'+ | | '<label id="tar-lab1" class="alipi" >Enter few attributes of the target community </label>'+ |
---|
638 | '<label id="tar-lab2" class="alipi" >Location of the target community: </label> '+ | | '<label id="tar-lab2" class="alipi" >Location of the target community: </label> '+ |
---|
639 | '<input id="loc-select" class="alipi" placeholder="Type city/town name"/> '+ | | '<input id="loc-select" class="alipi" placeholder="Type city/town name"/> '+ |
---|
640 | '<img id="loc-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif" /> '+ | | '<img id="loc-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif" /> '+ |
---|
641 | '<label id="tar-lab3" class="alipi" >Language of re-narration: </label> '+ | | '<label id="tar-lab3" class="alipi" >Language of re-narration: </label> '+ |
---|
642 | '<input id="lang-select" class="alipi" placeholder="Type language name"/>'+ | | '<input id="lang-select" class="alipi" placeholder="Type language name"/>'+ |
---|
643 | '<img id="lang-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif"/> '+ | | '<img id="lang-img" src="http://dev.a11y.in/wsgi/images/db_loading.gif"/> '+ |
---|
644 | '<label id="tar-lab4" class="alipi" >Select a style of re-narration: </label> '+ | | '<label id="tar-lab4" class="alipi" >Select a style of re-narration: </label> '+ |
---|
645 | '<select id="style-select" class="alipi" > '+ | | '<select id="style-select" class="alipi" > '+ |
---|
646 | '<option>Translation</option><option>Technical</option><option>Fun</option><option>Simplification</option> '+ | | '<option>Translation</option><option>Technical</option><option>Fun</option><option>Simplification</option> '+ |
---|
647 | '<option>Correction</option><option>Evolution</option><option>Other</option></select>'+ | | '<option>Correction</option><option>Evolution</option><option>Other</option></select>'+ |
---|
648 | '<div id="free-form"><label id="tar-lab8" class="alipi">Comments:</label><textarea id="tar-comment"></textarea></div>'+ | | '<div id="free-form"><label id="tar-lab8" class="alipi">Comments:</label><textarea id="tar-comment"></textarea></div>'+ |
---|
649 | '<div id="blogset" > We are having issues with posting to a personal Google blog. Please use demo.swtr.us to publish.</div> '+ | | '<div id="blogset" > We are having issues with posting to a personal Google blog. Please use demo.swtr.us to publish.</div> '+ |
---|
650 | '<p id="tar-p" ><input id="our-check" class="alipi" type="radio"name="blog" /> '+ | | '<p id="tar-p" ><input id="our-check" class="alipi" type="radio"name="blog" /> '+ |
---|
651 | '<label id="tar-lab6" class="alipi" > demo.swtr.us </label><input id="your-check" class="alipi" type="radio" name="blog" /> '+ | | '<label id="tar-lab6" class="alipi" > demo.swtr.us </label><input id="your-check" class="alipi" type="radio" name="blog" /> '+ |
---|
652 | '<label id="tar-lab7" class="alipi">Personal Blog</label></p></div>'; | | '<label id="tar-lab7" class="alipi">Personal Blog</label></p></div>'; |
---|
| | 1213 | noEdit: function(event) | | | 1214 | { |
---|
| | 1215 | if (event) { |
---|
| | 1216 | xAxis = event.clientX; |
---|
| | 1217 | yAxis = event.clientY; |
---|
| | 1218 | $("#element_edit_overlay").css("top", yAxis); |
---|
| | 1219 | $("#element_edit_overlay").css("left", xAxis); |
---|
| | 1220 | } |
---|
| | 1221 | $('*').removeClass('highlightOnSelect'); |
---|
| | 1222 | if(!($(event.target).attr('m4pageedittype'))) { |
---|
| | 1223 | $('#edit-text').hide(); |
---|
| | 1224 | $('#add-audio').hide(); |
---|
| | 1225 | $('#replace-image').hide(); |
---|
| | 1226 | $('#delete-image').hide(); |
---|
| | 1227 | $('#close-element').hide(); |
---|
| | 1228 | $('#cant-edit').show(); |
---|
| | 1229 | window.setTimeout("$('#cant-edit').hide();", 3000); |
---|
| | 1230 | $("body").css("overflow", "auto"); |
---|
| | 1231 | $('#pub_overlay').slideDown(); |
---|
| | 1232 | $('#element_edit_overlay').slideDown(); |
---|
| | 1233 | } |
---|
| | 1234 | }, |
---|
653 | | 1235 | |
---|
654 | $('body').append(publish_template); | | $('body').append(publish_template); |
---|
655 | a11ypi.getLoc(); | | a11ypi.getLoc(); |
---|
656 | a11ypi.getLang(); | | a11ypi.getLang(); |
---|
657 | a11ypi.target = true; | | a11ypi.target = true; |
---|
658 | } | | } |
---|
| | 1236 | handler: function() | | | 1237 | { |
---|
| | 1238 | var sel = window.getSelection(); |
---|
| | 1239 | y = sel.anchorOffset; |
---|
| | 1240 | z = sel.focusOffset; |
---|
| | 1241 | if(y != z) |
---|
| | 1242 | { |
---|
| | 1243 | pageEditor.savedHtml = $('#editor').html(); |
---|
| | 1244 | var url = prompt("Enter url"); |
---|
| | 1245 | if(url) |
---|
| | 1246 | { |
---|
| | 1247 | sel.anchorNode.textContent = sel.anchorNode.textContent.substr(0,y)+'<a href="'+url+'">'+sel.anchorNode.textContent.substr(y,z-y)+"</a>"+sel.anchorNode.textContent.substr(z); |
---|
| | 1248 | abc = $('#editor').html(); |
---|
| | 1249 | abc = abc.replace(/(<)/g,'<'); |
---|
| | 1250 | abc = abc.replace(/(>)/g,'>'); |
---|
| | 1251 | $('#editor').html(abc); |
---|
| | 1252 | } |
---|
| | 1253 | else |
---|
| | 1254 | { |
---|
| | 1255 | $('#dialog-message').html('<p>Please enter a valid url</p>'); |
---|
| | 1256 | $('#dialog-message').dialog({ |
---|
| | 1257 | modal: true, |
---|
| | 1258 | buttons:{ |
---|
| | 1259 | OK:function(){ |
---|
| | 1260 | $(this).dialog("close"); |
---|
| | 1261 | $(this).html(''); |
---|
| | 1262 | } |
---|
| | 1263 | }}); |
---|
| | 1264 | } |
---|
| | 1265 | } |
---|
| | 1266 | else{ |
---|
| | 1267 | $('#dialog-message').html('<p>Please choose a portion of text and then click <b>Add link</b>.</p>'); |
---|
| | 1268 | $('#dialog-message').dialog({ |
---|
| | 1269 | modal: true, |
---|
| | 1270 | buttons:{ |
---|
| | 1271 | OK:function(){ |
---|
| | 1272 | $(this).dialog("close"); |
---|
| | 1273 | $(this).html(''); |
---|
| | 1274 | } |
---|
| | 1275 | }}); |
---|
| | 1276 | } |
---|
| | 1277 | }, |
---|
659 | | 1278 | |
---|
660 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
661 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1279 | addAudio: function(){ | | | 1280 | url = $('#audioInput').val(); |
---|
| | 1281 | if(url.substr(-4) =='.ogg'){ |
---|
| | 1282 | manager.recordAudio(pageEditor.event.target); |
---|
| | 1283 | } |
---|
| | 1284 | // else{ |
---|
| | 1285 | // $('#dialog-message').html('<p>Please enter a valid url</p>'); |
---|
| | 1286 | // $('#dialog-message').dialog({ |
---|
| | 1287 | // modal: true, |
---|
| | 1288 | // buttons:{ |
---|
| | 1289 | // OK:function(){ |
---|
| | 1290 | // $(this).dialog("close"); |
---|
| | 1291 | // $(this).html(''); |
---|
| | 1292 | // } |
---|
| | 1293 | // }}); |
---|
| | 1294 | // } |
---|
| | 1295 | }, |
---|
662 | | 1296 | |
---|
663 | $('#pub_overlay').slideUp(); | | $('#pub_overlay').slideUp(); |
---|
664 | $('#element_edit_overlay').slideUp(); | | $('#element_edit_overlay').slideUp(); |
---|
665 | // $('#icon_on_overlay').slideUp(); | | // $('#icon_on_overlay').slideUp(); |
---|
| | 1297 | deleteImage: function(){ | | | 1298 | manager.deleteImage(pageEditor.event.target); |
---|
| | 1299 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1300 | }, |
---|
666 | | 1301 | |
---|
667 | $(function() { | | $(function() { |
---|
668 | $( "#targetoverlay" ).dialog({ | | $( "#targetoverlay" ).dialog({ |
---|
669 | height:550, | | height:550, |
---|
670 | width:700, | | width:700, |
---|
671 | modal: true, | | modal: true, |
---|
672 | buttons: { | | buttons: { |
---|
673 | Publish: function() { | | Publish: function() { |
---|
674 | util.publish(); | | util.publish(); |
---|
675 | }, | | }, |
---|
| | 1302 | cleanUp: function(element) | | | 1303 | { |
---|
| | 1304 | if(util.hasChangesPending()) { |
---|
| | 1305 | $('#undo-button').button('option', 'disabled', false); // Another way of enabling UI-JQUERY button |
---|
| | 1306 | $('#publish-button').button({ disabled: false}); // Enabling UI-JQUERY button |
---|
| | 1307 | } else { |
---|
| | 1308 | $('#undo-button').button({ disabled: true}); // Disabling button |
---|
| | 1309 | $('#publish-button').button({ disabled: true}); // Disabling button |
---|
| | 1310 | } |
---|
676 | | 1311 | |
---|
677 | }, | | }, |
---|
678 | close: function() { | | close: function() { |
---|
679 | $('#pub_overlay').slideDown(); | | $('#pub_overlay').slideDown(); |
---|
680 | // $('#element_edit_overlay').slideDown(); | | // $('#element_edit_overlay').slideDown(); |
---|
681 | // $('#icon_on_overlay').slideDown(); | | // $('#icon_on_overlay').slideDown(); |
---|
682 | $( "#targetoverlay" ).hide(); | | $( "#targetoverlay" ).hide(); |
---|
683 | } | | } |
---|
684 | }); | | }); |
---|
685 | }); | | }); |
---|
686 | } | | } |
---|
687 | }, | | }, |
---|
| | 1312 | $(element).attr('m4pageedittype', pageEditor.m4pageedittype); | | | 1313 | $(element).children().attr('m4pageedittype', pageEditor.m4pageedittype); |
---|
| | 1314 | // $('#icon_on_overlay').slideDown(); |
---|
| | 1315 | $('#pub_overlay').slideDown(); |
---|
| | 1316 | $('#element_edit_overlay').hide(); |
---|
| | 1317 | $("body").css("overflow", "auto"); |
---|
| | 1318 | $('*').removeClass('highlightOnSelect'); |
---|
| | 1319 | // $('#element_edit_overlay').slideDown(); |
---|
| | 1320 | $(document).mouseover(a11ypi.highlightOnHover); |
---|
| | 1321 | $(document).mouseout(a11ypi.unhighlightOnMouseOut); |
---|
| | 1322 | // $(pageEditor.event.target).removeClass('highlightOnSelect'); // Remove hightlight of selected element |
---|
| | 1323 | }, |
---|
| | 1324 | }; |
---|
688 | | 1325 | |
---|
689 | hideAll: function() { | | hideAll: function() { |
---|
690 | var boxes = '#show-links, #show-box, #show-comment'; | | var boxes = '#show-links, #show-box, #show-comment'; |
---|
691 | $(boxes).dialog('close'); | | $(boxes).dialog('close'); |
---|
692 | }, | | }, |
---|
| | 1326 | var DOM = { | | | 1327 | getXpath : function (element) |
---|
| | 1328 | { |
---|
| | 1329 | var str = ''; |
---|
| | 1330 | var currentNode = element; |
---|
| | 1331 | var path = ''; |
---|
| | 1332 | var index = -1; |
---|
693 | | 1333 | |
---|
694 | showBox: function() { | | showBox: function() { |
---|
695 | this.hideAll(); | | this.hideAll(); |
---|
696 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
697 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1334 | if (currentNode.nodeName != "#text") | | | 1335 | { |
---|
| | 1336 | path = DOM.makePath(currentNode); |
---|
| | 1337 | } |
---|
| | 1338 | else |
---|
| | 1339 | { |
---|
| | 1340 | path = DOM.makePath(currentNode.parentNode); |
---|
| | 1341 | } |
---|
698 | | 1342 | |
---|
699 | $(function() { | | $(function() { |
---|
700 | $( "#show-box" ).dialog( "destroy" ); | | $( "#show-box" ).dialog( "destroy" ); |
---|
701 | | 1343 | |
---|
702 | $( "#show-box" ).dialog({ | | $( "#show-box" ).dialog({ |
---|
703 | width: 300, | | width: 300, |
---|
704 | height: 300, | | height: 300, |
---|
705 | modal: true | | modal: true |
---|
706 | }); | | }); |
---|
707 | }); | | }); |
---|
708 | d = window.location.search.split('?')[1]; | | d = window.location.search.split('?')[1]; |
---|
709 | var a = a11ypi.getParams(); | | var a = a11ypi.getParams(); |
---|
710 | if (a['blog'] === undefined ) { | | if (a['blog'] === undefined ) { |
---|
711 | a11ypi.createMenu('re-narration'); | | a11ypi.createMenu('re-narration'); |
---|
712 | } | | } |
---|
713 | else { | | else { |
---|
714 | $('#show-box').attr('title', 'Choose a re-narration from the blog you specified.'); | | $('#show-box').attr('title', 'Choose a re-narration from the blog you specified.'); |
---|
715 | a11ypi.ajax1(); | | a11ypi.ajax1(); |
---|
716 | } | | } |
---|
717 | }, | | }, |
---|
718 | showComment: function() { | | showComment: function() { |
---|
719 | this.hideAll(); | | this.hideAll(); |
---|
720 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
721 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1344 | return path; | | | 1345 | }, |
---|
| | 1346 | getElementIdx : function getElementIdx(elt) |
---|
| | 1347 | { |
---|
| | 1348 | var count = 1; |
---|
| | 1349 | for (var sib = elt.previousSibling; sib ; sib = sib.previousSibling) |
---|
| | 1350 | { |
---|
| | 1351 | if(sib.nodeType == 1 && sib.tagName == elt.tagName)count++ |
---|
| | 1352 | } |
---|
722 | | 1353 | |
---|
723 | $(function() { | | $(function() { |
---|
724 | $( "#show-comment" ).dialog( "destroy" ); | | $( "#show-comment" ).dialog( "destroy" ); |
---|
| | 1354 | return count; | | | 1355 | }, |
---|
725 | | 1356 | |
---|
726 | $( "#show-comment" ).dialog({ | | $( "#show-comment" ).dialog({ |
---|
727 | width: 300, | | width: 300, |
---|
728 | height: 300, | | height: 300, |
---|
729 | modal: true | | modal: true |
---|
730 | }); | | }); |
---|
731 | }); | | }); |
---|
732 | a11ypi.createMenu('5el'); | | a11ypi.createMenu('5el'); |
---|
733 | }, | | }, |
---|
| | 1357 | makePath : function makePath(elt){ | | | 1358 | var path = ''; |
---|
| | 1359 | for (; elt && elt.nodeType == 1; elt = elt.parentNode) |
---|
| | 1360 | { |
---|
| | 1361 | if(elt.id == "") |
---|
| | 1362 | { |
---|
| | 1363 | idx = DOM.getElementIdx(elt); |
---|
| | 1364 | xname = elt.tagName; |
---|
| | 1365 | if (idx > 1) |
---|
| | 1366 | xname += "[" + idx + "]"; |
---|
| | 1367 | path = "/" + xname + path; |
---|
| | 1368 | } |
---|
| | 1369 | else |
---|
| | 1370 | { |
---|
| | 1371 | path = "//*[@id='"+elt.id+"']"+path; |
---|
| | 1372 | break; |
---|
| | 1373 | } |
---|
| | 1374 | } |
---|
| | 1375 | return path; |
---|
| | 1376 | }, |
---|
| | 1377 | settextContent : function(element, content){ |
---|
| | 1378 | $(element).html(content); |
---|
| | 1379 | }, |
---|
| | 1380 | gettextContent:function(element) |
---|
| | 1381 | { |
---|
| | 1382 | return $(element).html(); |
---|
| | 1383 | }, |
---|
| | 1384 | }; |
---|
734 | | 1385 | |
---|
735 | ajaxLinks1: function() { | | ajaxLinks1: function() { |
---|
736 | // var xhr = new XMLHttpRequest(); | | // var xhr = new XMLHttpRequest(); |
---|
737 | // xhr.onreadystatechange = function() | | // xhr.onreadystatechange = function() |
---|
738 | // { | | // { |
---|
739 | // if(xhr.readyState == 4) | | // if(xhr.readyState == 4) |
---|
740 | // { | | // { |
---|
741 | // if(xhr.responseText == "empty") | | // if(xhr.responseText == "empty") |
---|
742 | // { } | | // { } |
---|
743 | // else | | // else |
---|
744 | // { | | // { |
---|
745 | // $('#see-links').show(); | | // $('#see-links').show(); |
---|
746 | // a11ypi.showlinks = JSON.parse(xhr.responseText); | | // a11ypi.showlinks = JSON.parse(xhr.responseText); |
---|
747 | // } | | // } |
---|
748 | // } | | // } |
---|
749 | // } | | // } |
---|
750 | // xhr.open("POST",config.deploy+"/domain",true); | | // xhr.open("POST",config.deploy+"/domain",true); |
---|
751 | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | | // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
752 | // d = window.location.search.split('?')[1]; | | // d = window.location.search.split('?')[1]; |
---|
753 | // a = a11ypi.getParams(); | | // a = a11ypi.getParams(); |
---|
754 | // xhr.send('url='+a['foruri']) | | // xhr.send('url='+a['foruri']) |
---|
| | 1386 | var util = { | | | 1387 | history: [], |
---|
| | 1388 | command: [], |
---|
755 | | 1389 | |
---|
756 | $.get(config.deploy+"/domain", {"url":a['foruri']}, function(data){ | | $.get(config.deploy+"/domain", {"url":a['foruri']}, function(data){ |
---|
757 | if(data[0] != 'empty') | | if(data[0] != 'empty') |
---|
758 | { | | { |
---|
759 | a11ypi.showlinks = data; | | a11ypi.showlinks = data; |
---|
760 | $('#see-links').show(); | | $('#see-links').show(); |
---|
761 | } | | } |
---|
762 | }); | | }); |
---|
763 | }, | | }, |
---|
764 | showBox1: function() { | | showBox1: function() { |
---|
765 | this.hideAll(); | | this.hideAll(); |
---|
766 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
767 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1390 | forEach : function(array, callback) { | | | 1391 | var i = 0, length = array.length, value; |
---|
768 | | 1392 | |
---|
769 | $(function() { | | $(function() { |
---|
770 | $( "#show-links" ).dialog( "destroy" ); | | $( "#show-links" ).dialog( "destroy" ); |
---|
| | 1393 | if (length) { | | | 1394 | for (value = array[0]; i < length && callback.call(value, i, value) !== false; value = array[++i]) { |
---|
| | 1395 | } |
---|
| | 1396 | } |
---|
| | 1397 | }, |
---|
| | 1398 | hasChangesPending : function(){ |
---|
| | 1399 | return util.history.length > 0; |
---|
| | 1400 | }, |
---|
| | 1401 | formUncomplete : function formUnomplete(){ |
---|
| | 1402 | return (locName == '' && langName=='' && styleName == '' ); |
---|
| | 1403 | }, |
---|
771 | | 1404 | |
---|
772 | $( "#show-links" ).dialog({ | | $( "#show-links" ).dialog({ |
---|
773 | width: 500, | | width: 500, |
---|
774 | height: 300, | | height: 300, |
---|
775 | modal: true | | modal: true |
---|
776 | }); | | }); |
---|
777 | }); | | }); |
---|
778 | a11ypi.createDomainMenu(); | | a11ypi.createDomainMenu(); |
---|
779 | }, | | }, |
---|
780 | createDomainMenu: function() { | | createDomainMenu: function() { |
---|
781 | var xyz = $("#show-links"); | | var xyz = $("#show-links"); |
---|
782 | xyz.html(''); | | xyz.html(''); |
---|
783 | for(var i in a11ypi.showlinks) | | for(var i in a11ypi.showlinks) |
---|
784 | { | | { |
---|
785 | var para = document.createElement("p"); | | var para = document.createElement("p"); |
---|
786 | var newel = document.createElement("a"); | | var newel = document.createElement("a"); |
---|
787 | newel.textContent = a11ypi.showlinks[i]; | | newel.textContent = a11ypi.showlinks[i]; |
---|
788 | newel.setAttribute("href", config.deploy+"/?foruri="+encodeURIComponent(a11ypi.showlinks[i])); | | newel.setAttribute("href", config.deploy+"/?foruri="+encodeURIComponent(a11ypi.showlinks[i])); |
---|
789 | newel.setAttribute("class","alipiShowLink"); | | newel.setAttribute("class","alipiShowLink"); |
---|
790 | para.appendChild(newel); | | para.appendChild(newel); |
---|
791 | xyz.append(para); | | xyz.append(para); |
---|
792 | } | | } |
---|
793 | $('.alipiShowLink').hover( | | $('.alipiShowLink').hover( |
---|
794 | function() { | | function() { |
---|
795 | var xhr = new XMLHttpRequest(); | | var xhr = new XMLHttpRequest(); |
---|
796 | xhr.onreadystatechange = function() | | xhr.onreadystatechange = function() |
---|
797 | { | | { |
---|
798 | if(xhr.readyState == 4) | | if(xhr.readyState == 4) |
---|
799 | { | | { |
---|
800 | if(xhr.responseText == "empty") | | if(xhr.responseText == "empty") |
---|
801 | { } | | { } |
---|
802 | else | | else |
---|
803 | { | | { |
---|
804 | menu_list = JSON.parse(xhr.responseText); | | menu_list = JSON.parse(xhr.responseText); |
---|
805 | x = ''; | | x = ''; |
---|
806 | for(i=0; i<menu_list.length; i++) { | | for(i=0; i<menu_list.length; i++) { |
---|
807 | if (i == menu_list.length-1) { | | if (i == menu_list.length-1) { |
---|
808 | x += menu_list[i]; | | x += menu_list[i]; |
---|
809 | } else { | | } else { |
---|
810 | x += menu_list[i] + ", "; | | x += menu_list[i] + ", "; |
---|
811 | } | | } |
---|
812 | } | | } |
---|
813 | $('#show-links').title = x; | | $('#show-links').title = x; |
---|
814 | } | | } |
---|
815 | } | | } |
---|
816 | } | | } |
---|
817 | xhr.open("POST",config.root+"/menu",true); | | xhr.open("POST",config.root+"/menu",true); |
---|
818 | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | | xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
819 | xhr.send('url='+encodeURIComponent($(this).attr('href'))) ; | | xhr.send('url='+encodeURIComponent($(this).attr('href'))) ; |
---|
820 | }, | | }, |
---|
821 | function () {$('#show-links').title= '';} | | function () {$('#show-links').title= '';} |
---|
822 | ); | | ); |
---|
823 | }, | | }, |
---|
824 | // blogFilter: function() { | | // blogFilter: function() { |
---|
825 | // if (a11ypi.blog_flag == false) { | | // if (a11ypi.blog_flag == false) { |
---|
826 | // a11ypi.blog_flag = true; | | // a11ypi.blog_flag = true; |
---|
827 | // // var xhr = new XMLHttpRequest(); | | // // var xhr = new XMLHttpRequest(); |
---|
828 | // // xhr.onreadystatechange = function() | | // // xhr.onreadystatechange = function() |
---|
829 | // // { | | // // { |
---|
830 | // // if(xhr.readyState == 4) | | // // if(xhr.readyState == 4) |
---|
831 | // // { | | // // { |
---|
832 | // // if(xhr.responseText == "empty") | | // // if(xhr.responseText == "empty") |
---|
833 | // // { } | | // // { } |
---|
834 | // // else | | // // else |
---|
835 | // // { | | // // { |
---|
836 | // // var sel = $("#blog-filter"); | | // // var sel = $("#blog-filter"); |
---|
837 | // // var menu_list = JSON.parse(xhr.responseText); | | // // var menu_list = JSON.parse(xhr.responseText); |
---|
838 | // // opt = document.createElement("option"); | | // // opt = document.createElement("option"); |
---|
839 | // // opt.textContent = "Choose a blog"; | | // // opt.textContent = "Choose a blog"; |
---|
840 | // // sel.append(opt); | | // // sel.append(opt); |
---|
841 | // // for (var i=0; i < menu_list.length; i++) | | // // for (var i=0; i < menu_list.length; i++) |
---|
842 | // // { | | // // { |
---|
843 | // // opt = document.createElement("option"); | | // // opt = document.createElement("option"); |
---|
844 | // // opt.textContent = menu_list[i]; | | // // opt.textContent = menu_list[i]; |
---|
845 | // // sel.append(opt); | | // // sel.append(opt); |
---|
846 | // // } | | // // } |
---|
847 | // // } | | // // } |
---|
848 | // // } | | // // } |
---|
849 | // // } | | // // } |
---|
850 | // // xhr.open("POST",config.deploy+"/blog",true); | | // // xhr.open("POST",config.deploy+"/blog",true); |
---|
851 | // // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | | // // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); |
---|
852 | // // a = a11ypi.getParams(); | | // // a = a11ypi.getParams(); |
---|
853 | // // xhr.send('url='+a['foruri']); | | // // xhr.send('url='+a['foruri']); |
---|
854 | // $.get(config.deploy+"/blog", {"url":a['foruri']}, function(data){ | | // $.get(config.deploy+"/blog", {"url":a['foruri']}, function(data){ |
---|
855 | // var sel = $("#blog-filter"); | | // var sel = $("#blog-filter"); |
---|
856 | // var menu_list = JSON.parse(data); | | // var menu_list = JSON.parse(data); |
---|
857 | // opt = document.createElement("option"); | | // opt = document.createElement("option"); |
---|
858 | // opt.textContent = "Choose a blog"; | | // opt.textContent = "Choose a blog"; |
---|
859 | // sel.append(opt); | | // sel.append(opt); |
---|
860 | // for (var i=0; i < menu_list.length; i++) | | // for (var i=0; i < menu_list.length; i++) |
---|
861 | // { | | // { |
---|
862 | // opt = document.createElement("option"); | | // opt = document.createElement("option"); |
---|
863 | // opt.textContent = menu_list[i]; | | // opt.textContent = menu_list[i]; |
---|
864 | // sel.append(opt); | | // sel.append(opt); |
---|
865 | // } | | // } |
---|
866 | // }); | | // }); |
---|
867 | // } | | // } |
---|
868 | // }, | | // }, |
---|
869 | go: function() { | | go: function() { |
---|
870 | var a =[]; | | var a =[]; |
---|
871 | for (var i = 0;i<d.split('&').length;i++){ | | for (var i = 0;i<d.split('&').length;i++){ |
---|
872 | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; | | a[d.split('&')[i].split('=')[0]] = d.split('&')[i].split('=')[1]; |
---|
873 | } | | } |
---|
874 | if ($("#blog-filter").val() == null) | | if ($("#blog-filter").val() == null) |
---|
875 | { } | | { } |
---|
876 | else { | | else { |
---|
877 | window.open(config.deploy+"/?foruri=" + a['foruri'] + "&blog=" + $("#blog-filter").val()); | | window.open(config.deploy+"/?foruri=" + a['foruri'] + "&blog=" + $("#blog-filter").val()); |
---|
878 | } | | } |
---|
879 | }, | | }, |
---|
880 | share: function() { | | share: function() { |
---|
881 | $('#fb-like').css('display', 'block'); | | $('#fb-like').css('display', 'block'); |
---|
882 | $('#tweet-root').css('display', 'block'); | | $('#tweet-root').css('display', 'block'); |
---|
883 | $( "#share-box" ).dialog({ | | $( "#share-box" ).dialog({ |
---|
884 | position: 'center', | | position: 'center', |
---|
885 | width:450, | | width:450, |
---|
886 | height:180, | | height:180, |
---|
887 | modal: true, | | modal: true, |
---|
888 | }); | | }); |
---|
889 | }, | | }, |
---|
890 | editPage: function() { | | editPage: function() { |
---|
891 | //this.hideAll(); | | //this.hideAll(); |
---|
892 | a11ypi.testContext(); | | a11ypi.testContext(); |
---|
893 | $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); | | $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); |
---|
894 | $('#icon-down').show(); | | $('#icon-down').show(); |
---|
895 | $('#renarrated_overlay').hide(); | | $('#renarrated_overlay').hide(); |
---|
896 | $('body *').not('iframe').contents().filter(function(){ | | $('body *').not('iframe').contents().filter(function(){ |
---|
897 | { | | { |
---|
898 | try{ | | try{ |
---|
899 | if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') ) | | if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') ) |
---|
900 | return this; | | return this; |
---|
901 | } | | } |
---|
902 | catch(err) | | catch(err) |
---|
903 | { | | { |
---|
904 | //pass | | //pass |
---|
905 | } | | } |
---|
906 | } | | } |
---|
907 | }).click(pageEditor.startEdit); | | }).click(pageEditor.startEdit); |
---|
| | 1405 | makeChanges: function (command, selectedElement) { | | | 1406 | var poofPosition, poofDiv; |
---|
| | 1407 | util.command = command; |
---|
| | 1408 | switch (util.command.command) { |
---|
| | 1409 | case 'TEXT_UPDATE': |
---|
| | 1410 | DOM.settextContent(util.command.element, util.command.data); |
---|
| | 1411 | break; |
---|
| | 1412 | case 'IMAGE_DELETE': |
---|
| | 1413 | $(selectedElement).hide(); |
---|
| | 1414 | break; |
---|
| | 1415 | case 'IMAGE_SRC_UPDATE': |
---|
| | 1416 | imageMatcher = new RegExp("(\\d+)x(\\d+),(.+)").exec(util.command.data); |
---|
| | 1417 | imageWidth = imageMatcher[1]; |
---|
| | 1418 | imageHeight = imageMatcher[2]; |
---|
| | 1419 | imageSrc = imageMatcher[3]; |
---|
908 | | 1420 | |
---|
909 | $('body *').not('iframe').contents().filter(function(){ | | $('body *').not('iframe').contents().filter(function(){ |
---|
910 | { | | { |
---|
911 | try{ | | try{ |
---|
912 | if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype')) | | if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype')) |
---|
913 | return this; | | return this; |
---|
914 | } | | } |
---|
915 | catch(err) | | catch(err) |
---|
916 | { | | { |
---|
917 | //pass | | //pass |
---|
918 | } | | } |
---|
919 | } | | } |
---|
920 | }).click(pageEditor.noEdit); | | }).click(pageEditor.noEdit); |
---|
| | 1421 | if (imageSrc && util.command.element.src != imageSrc) { | | | 1422 | util.command.element.src = imageSrc; |
---|
| | 1423 | } |
---|
| | 1424 | if (imageWidth == 0) { |
---|
| | 1425 | util.command.element.removeAttribute('width'); |
---|
| | 1426 | } else { |
---|
| | 1427 | util.command.element.width = imageWidth; |
---|
| | 1428 | } |
---|
921 | | 1429 | |
---|
922 | $(document).mouseover(a11ypi.highlightOnHover); | | $(document).mouseover(a11ypi.highlightOnHover); |
---|
923 | $(document).mouseout(a11ypi.unhighlightOnMouseOut); | | $(document).mouseout(a11ypi.unhighlightOnMouseOut); |
---|
924 | }, | | }, |
---|
| | 1430 | if (imageHeight == 0) { | | | 1431 | util.command.element.removeAttribute('height'); |
---|
| | 1432 | } else { |
---|
| | 1433 | util.command.element.height = imageHeight; |
---|
| | 1434 | } |
---|
| | 1435 | break; |
---|
925 | | 1436 | |
---|
926 | displayEditor: function() { | | displayEditor: function() { |
---|
927 | var template = '<div id="editoroverlay" title="Editor" class="alipi ui-widget-header ui-corner-all">'+ | | var template = '<div id="editoroverlay" title="Editor" class="alipi ui-widget-header ui-corner-all">'+ |
---|
928 | '<button id="close-adv" class="alipi" onclick="a11ypi.closeAdv();" title="Want to close View Source & display without HTML code?"> '+ | | '<button id="close-adv" class="alipi" onclick="a11ypi.closeAdv();" title="Want to close View Source & display without HTML code?"> '+ |
---|
929 | 'Render source</button> '+ | | 'Render source</button> '+ |
---|
930 | '<button id="adv-ref" class="alipi" onclick="a11ypi.showAdv();" title="Want to see HTML code? Then click me !!">View Source</button> '+ | | '<button id="adv-ref" class="alipi" onclick="a11ypi.showAdv();" title="Want to see HTML code? Then click me !!">View Source</button> '+ |
---|
931 | '<label id="ref-lab" class="alipi" style="left:3%;">Here is original piece (Reference)</label>'+ | | '<label id="ref-lab" class="alipi" style="left:3%;">Here is original piece (Reference)</label>'+ |
---|
932 | '<div id="reference" class="alipi" readonly="yes"></div>'+ | | '<div id="reference" class="alipi" readonly="yes"></div>'+ |
---|
933 | '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+ | | '<textarea id="adv-reference" class="alipi" readonly="yes"></textarea> '+ |
---|
934 | '<label id="edit-lab" class="alipi" style="left:53%;">Where you should edit (Editor)</label>'+ | | '<label id="edit-lab" class="alipi" style="left:53%;">Where you should edit (Editor)</label>'+ |
---|
935 | '<div id="editor" class="alipi" contenteditable="true" '+ | | '<div id="editor" class="alipi" contenteditable="true" '+ |
---|
936 | '</div>'; | | '</div>'; |
---|
937 | $('body').append(template); | | $('body').append(template); |
---|
938 | $('#pub_overlay').slideUp(); | | $('#pub_overlay').slideUp(); |
---|
939 | $('#element_edit_overlay').hide(); | | $('#element_edit_overlay').hide(); |
---|
| | 1437 | case 'ANCHOR_UPDATE': | | | 1438 | $(util.command.element).attr('href', util.command.data); |
---|
| | 1439 | break; |
---|
940 | | 1440 | |
---|
941 | var tag = pageEditor.event.target.nodeName; | | var tag = pageEditor.event.target.nodeName; |
---|
942 | $(pageEditor.event.target).removeAttr('m4pageedittype'); | | $(pageEditor.event.target).removeAttr('m4pageedittype'); |
---|
943 | $(pageEditor.event.target).children().removeAttr('m4pageedittype'); | | $(pageEditor.event.target).children().removeAttr('m4pageedittype'); |
---|
| | 1441 | case 'ANCHOR_CREATE': | | | 1442 | anchorElement = DOM.BUILDER.A({ 'href' : util.command.data }); |
---|
| | 1443 | util.command.element.parentNode.replaceChild(anchorElement, util.command.element); |
---|
| | 1444 | anchorElement.appendChild(util.command.element); |
---|
| | 1445 | util.command.previousData = anchorElement; |
---|
| | 1446 | break; |
---|
944 | | 1447 | |
---|
945 | $('#adv-reference').text('<'+tag+'>'+$(pageEditor.event.target).html()+'</'+tag+'>'); | | $('#adv-reference').text('<'+tag+'>'+$(pageEditor.event.target).html()+'</'+tag+'>'); |
---|
946 | $('#reference').html($(pageEditor.event.target).html()); | | $('#reference').html($(pageEditor.event.target).html()); |
---|
947 | $('#editor').html($(pageEditor.event.target).html()); | | $('#editor').html($(pageEditor.event.target).html()); |
---|
948 | $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi'); | | $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi'); |
---|
949 | $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi'); | | $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi'); |
---|
950 | $('#close-adv').hide(); | | $('#close-adv').hide(); |
---|
951 | $('#adv-ref').button(); | | $('#adv-ref').button(); |
---|
| | 1448 | case 'AUDIO_UPDATE': | | | 1449 | util.command.element.setAttribute('src', util.command.data); |
---|
| | 1450 | //pageEditor.showMessage('Audio changed'); |
---|
| | 1451 | break; |
---|
952 | | 1452 | |
---|
953 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
954 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1453 | case 'AUDIO_CREATE': | | | 1454 | audioElement = document.createElement('audio'); |
---|
| | 1455 | audioElement.setAttribute("class", "alipi"); |
---|
| | 1456 | audioElement.setAttribute('src',util.command.data); |
---|
| | 1457 | audioElement.setAttribute('controls','controls'); |
---|
| | 1458 | audioElement.setAttribute('mime-type','audio/ogg'); |
---|
| | 1459 | $(audioElement).insertBefore($(selectedElement)); |
---|
| | 1460 | util.command.element = audioElement; |
---|
| | 1461 | break; |
---|
955 | | 1462 | |
---|
956 | $( "#editoroverlay" ).dialog({ | | $( "#editoroverlay" ).dialog({ |
---|
957 | position: 'center', | | position: 'center', |
---|
958 | width:$(window).width()-10, | | width:$(window).width()-10, |
---|
959 | height:$(window).height()-50, | | height:$(window).height()-50, |
---|
960 | modal: true, | | modal: true, |
---|
961 | buttons: { | | buttons: { |
---|
962 | "+": function() { | | "+": function() { |
---|
963 | if($('#editor').css('font-size') >= '30px') { | | if($('#editor').css('font-size') >= '30px') { |
---|
964 | // passthrough | | // passthrough |
---|
965 | } | | } |
---|
966 | else { | | else { |
---|
967 | var font = parseFloat($('#editor').css('font-size')) + 1; | | var font = parseFloat($('#editor').css('font-size')) + 1; |
---|
968 | $('#editor').css('font-size', font+'px'); | | $('#editor').css('font-size', font+'px'); |
---|
969 | font = parseFloat($('#reference').css('font-size')) + 1; | | font = parseFloat($('#reference').css('font-size')) + 1; |
---|
970 | $('#reference').css('font-size', font+'px'); | | $('#reference').css('font-size', font+'px'); |
---|
971 | font = parseFloat($('#adv-reference').css('font-size')) + 1; | | font = parseFloat($('#adv-reference').css('font-size')) + 1; |
---|
972 | $('#adv-reference').css('font-size', font+'px'); | | $('#adv-reference').css('font-size', font+'px'); |
---|
973 | } | | } |
---|
974 | }, | | }, |
---|
975 | "-": function() { | | "-": function() { |
---|
976 | if($('#editor').css('font-size') <= '10px') { | | if($('#editor').css('font-size') <= '10px') { |
---|
977 | //passthrough | | //passthrough |
---|
978 | } | | } |
---|
979 | else { | | else { |
---|
980 | var font = parseFloat($('#editor').css('font-size')) - 1; | | var font = parseFloat($('#editor').css('font-size')) - 1; |
---|
981 | $('#editor').css('font-size', font+'px'); | | $('#editor').css('font-size', font+'px'); |
---|
982 | font = parseFloat($('#reference').css('font-size')) - 1; | | font = parseFloat($('#reference').css('font-size')) - 1; |
---|
983 | $('#reference').css('font-size', font+'px'); | | $('#reference').css('font-size', font+'px'); |
---|
984 | font = parseFloat($('#adv-reference').css('font-size')) - 1; | | font = parseFloat($('#adv-reference').css('font-size')) - 1; |
---|
985 | $('#adv-reference').css('font-size', font+'px'); | | $('#adv-reference').css('font-size', font+'px'); |
---|
986 | } | | } |
---|
987 | }, | | }, |
---|
988 | "Add Link": function() { | | "Add Link": function() { |
---|
989 | pageEditor.handler(); | | pageEditor.handler(); |
---|
990 | }, | | }, |
---|
991 | "Save changes": function() { | | "Save changes": function() { |
---|
992 | $('#pub_overlay').slideDown(); | | $('#pub_overlay').slideDown(); |
---|
993 | $('#element_edit_overlay').slideDown(); | | $('#element_edit_overlay').slideDown(); |
---|
994 | $('#icon_on_overlay').slideDown(); | | $('#icon_on_overlay').slideDown(); |
---|
995 | manager.recordText(pageEditor.event.target); | | manager.recordText(pageEditor.event.target); |
---|
996 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
997 | $( "#editoroverlay" ).remove(); | | $( "#editoroverlay" ).remove(); |
---|
998 | } | | } |
---|
999 | }, | | }, |
---|
1000 | close: function() { | | close: function() { |
---|
1001 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
1002 | $("#editoroverlay" ).remove(); | | $("#editoroverlay" ).remove(); |
---|
1003 | } | | } |
---|
1004 | }); | | }); |
---|
| | 1463 | default: | | | 1464 | console.error('Unknown util.command:', util.command); |
---|
| | 1465 | } |
---|
1005 | | 1466 | |
---|
1006 | $($($('<label>').insertAfter($('.ui-dialog-buttonset').children()[0])).html('Magnify or Demagnify')); // Element added externally with css | | $($($('<label>').insertAfter($('.ui-dialog-buttonset').children()[0])).html('Magnify or Demagnify')); // Element added externally with css |
---|
1007 | $($('.ui-dialog-buttonset').children()[1]).attr('id','mag-demag'); | | $($('.ui-dialog-buttonset').children()[1]).attr('id','mag-demag'); |
---|
1008 | $($('.ui-dialog-buttonset').children()[0]).attr('id','mag'); // '+' | | $($('.ui-dialog-buttonset').children()[0]).attr('id','mag'); // '+' |
---|
1009 | $($('.ui-dialog-buttonset').children()[2]).attr('id','demag'); // '-' | | $($('.ui-dialog-buttonset').children()[2]).attr('id','demag'); // '-' |
---|
1010 | $($('.ui-dialog-buttonset').children()[3]).attr('id','add-link'); // 'Link' | | $($('.ui-dialog-buttonset').children()[3]).attr('id','add-link'); // 'Link' |
---|
1011 | $($('.ui-dialog-buttonset').children()[4]).attr('id','save-changes'); // 'Save Changes' | | $($('.ui-dialog-buttonset').children()[4]).attr('id','save-changes'); // 'Save Changes' |
---|
| | 1467 | util.history.push(util.command); | | | 1468 | }, |
---|
1012 | | 1469 | |
---|
1013 | $('#adv-reference').height($('#editor').height() + 40); | | $('#adv-reference').height($('#editor').height() + 40); |
---|
1014 | $('#reference').height($('#editor').height()); | | $('#reference').height($('#editor').height()); |
---|
1015 | $('#mag').attr('title', 'To magnify letters/Increase font size'); | | $('#mag').attr('title', 'To magnify letters/Increase font size'); |
---|
1016 | $('#demag').attr('title', 'To demagnify letters/Decrease font size'); | | $('#demag').attr('title', 'To demagnify letters/Decrease font size'); |
---|
1017 | $('#add-link').attr('title', 'Add link(href) to the selected text portion (Before clicking this button, select some portion of text in "Editor")'); | | $('#add-link').attr('title', 'Add link(href) to the selected text portion (Before clicking this button, select some portion of text in "Editor")'); |
---|
1018 | $('#save-changes').attr('title', 'Save edited text onto the page') | | $('#save-changes').attr('title', 'Save edited text onto the page') |
---|
1019 | }, | | }, |
---|
| | 1470 | undoChanges:function () { | | | 1471 | var imageElement, command=util.command; |
---|
1020 | | 1472 | |
---|
1021 | showAdv: function() { | | showAdv: function() { |
---|
1022 | $('#reference').hide(); | | $('#reference').hide(); |
---|
1023 | $('#adv-reference').show(); | | $('#adv-reference').show(); |
---|
1024 | $('#adv-ref').hide(); | | $('#adv-ref').hide(); |
---|
1025 | $('#close-adv').show(); | | $('#close-adv').show(); |
---|
1026 | }, | | }, |
---|
1027 | closeAdv: function() { | | closeAdv: function() { |
---|
1028 | $('#reference').show(); | | $('#reference').show(); |
---|
1029 | $('#adv-reference').hide(); | | $('#adv-reference').hide(); |
---|
1030 | $('#close-adv').hide(); | | $('#close-adv').hide(); |
---|
1031 | $('#adv-ref').show(); | | $('#adv-ref').show(); |
---|
1032 | }, | | }, |
---|
| | 1473 | if (util.hasChangesPending()) { | | | 1474 | command = util.history.pop(); |
---|
| | 1475 | switch (command.command) { |
---|
| | 1476 | case 'TEXT_UPDATE': |
---|
| | 1477 | command.element.innerHTML = command.previousData; |
---|
| | 1478 | break; |
---|
1033 | | 1479 | |
---|
1034 | reflectInReference: function() { | | reflectInReference: function() { |
---|
1035 | var tag = pageEditor.event.target.nodeName; | | var tag = pageEditor.event.target.nodeName; |
---|
1036 | $("#reference").html() = $("#editor").html(); | | $("#reference").html() = $("#editor").html(); |
---|
1037 | }, | | }, |
---|
| | 1480 | case 'DELETE': | | | 1481 | DOM.restoreStyleProperty(command.element, 'display', ''); |
---|
| | 1482 | break; |
---|
1038 | | 1483 | |
---|
1039 | imageReplacer: function() { | | imageReplacer: function() { |
---|
1040 | var imageInputTemplate = '<div id="imageInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ | | var imageInputTemplate = '<div id="imageInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ |
---|
1041 | '<input type="text" id="imageInput" placeholder="http://foo.com/baz.jpg" class="alipi" value=""/></div>'; | | '<input type="text" id="imageInput" placeholder="http://foo.com/baz.jpg" class="alipi" value=""/></div>'; |
---|
| | 1484 | case 'IMAGE_SRC_UPDATE': | | | 1485 | command.element.src = command.previousData.src; |
---|
| | 1486 | if (command.previousData.size.width) { |
---|
| | 1487 | command.element.width = command.previousData.size.width; |
---|
| | 1488 | } else { |
---|
| | 1489 | command.element.removeAttribute('width'); |
---|
| | 1490 | } |
---|
| | 1491 | if (command.previousData.size.height) { |
---|
| | 1492 | command.element.height = command.previousData.size.height; |
---|
| | 1493 | } else { |
---|
| | 1494 | command.element.removeAttribute('height'); |
---|
| | 1495 | } |
---|
| | 1496 | break; |
---|
1042 | | 1497 | |
---|
1043 | $('body').append(imageInputTemplate); | | $('body').append(imageInputTemplate); |
---|
1044 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
1045 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1498 | case 'AUDIO_CREATE': | | | 1499 | $(command.element).remove(); |
---|
| | 1500 | break; |
---|
| | 1501 | case 'ANCHOR_UPDATE': |
---|
| | 1502 | command.element.setAttribute('href', command.previousData); |
---|
| | 1503 | break; |
---|
1046 | | 1504 | |
---|
1047 | $('#pub_overlay').slideUp(); | | $('#pub_overlay').slideUp(); |
---|
1048 | $('#element_edit_overlay').slideUp(); | | $('#element_edit_overlay').slideUp(); |
---|
1049 | $('#icon_on_overlay').slideUp(); | | $('#icon_on_overlay').slideUp(); |
---|
| | 1505 | case 'ANCHOR_CREATE': | | | 1506 | command.previousData.parentNode.replaceChild(command.element, command.previousData); |
---|
| | 1507 | break; |
---|
| | 1508 | case 'IMAGE_DELETE': |
---|
| | 1509 | $(command.element).show(); |
---|
| | 1510 | break; |
---|
| | 1511 | default: |
---|
| | 1512 | console.error('Unknown command:', command); |
---|
| | 1513 | } |
---|
| | 1514 | pageEditor.cleanUp(pageEditor.event.target); |
---|
| | 1515 | } else { |
---|
| | 1516 | } |
---|
| | 1517 | }, |
---|
| | 1518 | checkHistoryChanges: function() |
---|
| | 1519 | { |
---|
| | 1520 | if(util.hasChangesPending()) |
---|
| | 1521 | { |
---|
| | 1522 | $('#undo-button').attr('disabled',false); |
---|
| | 1523 | $('#publish-button').attr('disabled',false); |
---|
| | 1524 | } |
---|
| | 1525 | else{ |
---|
| | 1526 | $('#undo-button').attr('disabled',true); |
---|
| | 1527 | $('#publish-button').attr('disabled',true); |
---|
| | 1528 | } |
---|
| | 1529 | }, |
---|
1050 | | 1530 | |
---|
1051 | $( "#imageInputElement" ).dialog({ | | $( "#imageInputElement" ).dialog({ |
---|
1052 | width:300, | | width:300, |
---|
1053 | height:200, | | height:200, |
---|
1054 | modal: true, | | modal: true, |
---|
1055 | buttons: { | | buttons: { |
---|
1056 | OK: function() { | | OK: function() { |
---|
1057 | var formValue = $('#imageInput').val(); | | var formValue = $('#imageInput').val(); |
---|
1058 | if(formValue != '\/S/') | | if(formValue != '\/S/') |
---|
1059 | { | | { |
---|
1060 | manager.recordImage(pageEditor.event.target, formValue); | | manager.recordImage(pageEditor.event.target, formValue); |
---|
1061 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
1062 | $( "#imageInputElement" ).remove(); | | $( "#imageInputElement" ).remove(); |
---|
1063 | } | | } |
---|
1064 | } | | } |
---|
1065 | }, | | }, |
---|
1066 | close: function() { | | close: function() { |
---|
1067 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
1068 | $("#imageInputElement" ).remove(); | | $("#imageInputElement" ).remove(); |
---|
1069 | } | | } |
---|
1070 | }); | | }); |
---|
| | 1531 | publish:function (){ | | | 1532 | var result; |
---|
| | 1533 | if ($('#loc-select').val() == '' || $('#lang-select').val() == '' || $('input:checked') == undefined) { |
---|
| | 1534 | alert("please furnish all the details"); |
---|
| | 1535 | } else { |
---|
| | 1536 | if($('input:checked') == $("#your-check")) |
---|
| | 1537 | { |
---|
| | 1538 | localStorage.myContent = util.buildDataString(); |
---|
| | 1539 | window.location.href = "http://dev.a11y.in/test.html"; |
---|
| | 1540 | } |
---|
| | 1541 | else{ |
---|
| | 1542 | $(function(){ |
---|
| | 1543 | $( "#targetoverlay" ).dialog('close'); |
---|
| | 1544 | $('#pub_overlay').slideUp(); |
---|
| | 1545 | $('#element_edit_overlay').hide(); |
---|
| | 1546 | // $('#icon_on_overlay').slideUp(); |
---|
| | 1547 | // $( "#success-dialog" ).dialog({ |
---|
| | 1548 | // modal: true, |
---|
| | 1549 | // }); |
---|
| | 1550 | var success_template = '<div id="success-dialog" title="Posting your changes" class="alipi ui-widget-header ui-corner-all" '+ |
---|
| | 1551 | '<p style="color:#aaa"><b>Please wait !!!</b></p><p style="color:#aaa">Your contribution is being posted</p></div>'; |
---|
| | 1552 | $('body').append(success_template); |
---|
| | 1553 | $(function() { |
---|
| | 1554 | $( "#success-dialog" ).dialog({ |
---|
| | 1555 | modal: true, |
---|
| | 1556 | }); |
---|
| | 1557 | }); |
---|
| | 1558 | }); |
---|
| | 1559 | $.post(config.deploy+'/publish', {"data" : JSON.stringify(util.buildDataString())}, |
---|
| | 1560 | function(data){ |
---|
| | 1561 | window.location.reload(); |
---|
| | 1562 | }); |
---|
1071 | | 1563 | |
---|
1072 | }, | | }, |
---|
| | 1564 | //+'&title='+encodeURIComponent(document.title) | | | 1565 | // }).done(function(){ |
---|
| | 1566 | // console.log("test"); |
---|
| | 1567 | //window.location.reload(); |
---|
| | 1568 | // }); |
---|
| | 1569 | } |
---|
| | 1570 | } |
---|
| | 1571 | }, |
---|
1073 | | 1572 | |
---|
1074 | addAudio: function() { | | addAudio: function() { |
---|
1075 | var audioInputTemplate = '<div id="audioInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ | | var audioInputTemplate = '<div id="audioInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ |
---|
1076 | '<input type="text" id="audioInput" placeholder="http://foo.com/baz.ogg" class="alipi" value=""/></div>'; | | '<input type="text" id="audioInput" placeholder="http://foo.com/baz.ogg" class="alipi" value=""/></div>'; |
---|
| | 1573 | buildDataString : function (){ | | | 1574 | var check_xpath = [], temp_history = [], index = []; |
---|
| | 1575 | for(x=0; x<util.history.length; x++) { |
---|
| | 1576 | check_xpath.push(util.history[x].xpath); |
---|
| | 1577 | } |
---|
| | 1578 | for(i=0; i<check_xpath.length-1; i++) { |
---|
| | 1579 | for(j=i+1; j<check_xpath.length; j++) { |
---|
| | 1580 | if ((check_xpath[i] == check_xpath[j]) && (util.history[i].elementType == util.history[j].elementType)) { |
---|
| | 1581 | index.push(i); |
---|
| | 1582 | } |
---|
| | 1583 | } |
---|
| | 1584 | } |
---|
| | 1585 | if (index.length > 0) { |
---|
| | 1586 | for (var z=0; z<index.length; z++) { |
---|
| | 1587 | delete util.history[index[z]]; |
---|
| | 1588 | } |
---|
| | 1589 | } |
---|
1077 | | 1590 | |
---|
1078 | $('body').append(audioInputTemplate); | | $('body').append(audioInputTemplate); |
---|
1079 | $(document).unbind('mouseover'); // Unbind the css on mouseover | | $(document).unbind('mouseover'); // Unbind the css on mouseover |
---|
1080 | $(document).unbind('mouseout'); // Unbind the css on mouseout | | $(document).unbind('mouseout'); // Unbind the css on mouseout |
---|
| | 1591 | for (var x=0; x<util.history.length; x++) { | | | 1592 | if (util.history[x] != undefined) { |
---|
| | 1593 | temp_history.push(util.history[x]); |
---|
| | 1594 | } |
---|
| | 1595 | } |
---|
1081 | | 1596 | |
---|
1082 | $('#pub_overlay').slideUp(); | | $('#pub_overlay').slideUp(); |
---|
1083 | $('#element_edit_overlay').slideUp(); | | $('#element_edit_overlay').slideUp(); |
---|
1084 | $('#icon_on_overlay').slideUp(); | | $('#icon_on_overlay').slideUp(); |
---|
| | 1597 | util.history = temp_history; | | | 1598 | var command = util.command, buffer; |
---|
| | 1599 | // buffer = new StringUtil.StringBuffer(); |
---|
1085 | | 1600 | |
---|
1086 | $( "#audioInputElement" ).dialog({ | | $( "#audioInputElement" ).dialog({ |
---|
1087 | width:300, | | width:300, |
---|
1088 | height:200, | | height:200, |
---|
1089 | modal: true, | | modal: true, |
---|
1090 | buttons: { | | buttons: { |
---|
1091 | OK: function() { | | OK: function() { |
---|
1092 | pageEditor.addAudio(); | | pageEditor.addAudio(); |
---|
1093 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
1094 | $( "#audioInputElement" ).remove(); | | $( "#audioInputElement" ).remove(); |
---|
1095 | } | | } |
---|
1096 | }, | | }, |
---|
1097 | close: function() { | | close: function() { |
---|
1098 | pageEditor.cleanUp(pageEditor.event.target); | | pageEditor.cleanUp(pageEditor.event.target); |
---|
1099 | $("#audioInputElement" ).remove(); | | $("#audioInputElement" ).remove(); |
---|
1100 | } | | } |
---|
1101 | }); | | }); |
---|
1102 | }, | | }, |
---|
| | 1601 | var buff = []; | | | 1602 | util.forEach(util.history, function(index, command) { |
---|
| | 1603 | var dict = {}; |
---|
| | 1604 | dict['type'] = "re-narration"; //TYPE |
---|
| | 1605 | dict['about'] = decodeURIComponent(window.location.search.split('=')[1]); |
---|
| | 1606 | dict['lang'] = $('#lang-select').val(); |
---|
| | 1607 | dict["location"] = $('#loc-select').val(); |
---|
| | 1608 | dict["style"] = $('#style-select').val(); |
---|
| | 1609 | dict["blog"] = config.sweet; |
---|
| | 1610 | dict["elementtype"] = command.elementType; |
---|
| | 1611 | dict["xpath"] = command.xpath; |
---|
| | 1612 | dict["data"] = command.data; |
---|
| | 1613 | /*if ($('#auth-select').val() == '' || $('#auth-select').val() == /\S/) { |
---|
| | 1614 | dict["author"] = "Anonymous"; |
---|
| | 1615 | } else { |
---|
| | 1616 | dict["author"] = $('#auth-select').val(); |
---|
| | 1617 | }*/ |
---|
| | 1618 | dict['author'] = $('#tar-uname').val() || $('#tar-name').val() || 'Anonymous'; |
---|
| | 1619 | buff.push(dict); |
---|
1103 | | 1620 | |
---|
1104 | highlightOnHover: function(event) { | | highlightOnHover: function(event) { |
---|
1105 | if( !($(event.target).hasClass('alipi')) ) { | | if( !($(event.target).hasClass('alipi')) ) { |
---|
1106 | $(event.target).addClass('highlightElement'); | | $(event.target).addClass('highlightElement'); |
---|
1107 | } | | } |
---|
1108 | }, | | }, |
---|
| | 1621 | // buffer.append('###'); //separates the commands | | | 1622 | // buffer.append('about='); //url=about //removed '&' on purpose |
---|
| | 1623 | // buffer.append(window.location.search.split('=')[1]); |
---|
| | 1624 | // buffer.append('&lang=');//lang |
---|
| | 1625 | // buffer.append(encodeURIComponent($('#lang-select').val())); |
---|
| | 1626 | // buffer.append('&location=');//location |
---|
| | 1627 | // buffer.append(encodeURIComponent($('#loc-select').val())); |
---|
| | 1628 | // buffer.append('&style=');//style |
---|
| | 1629 | // buffer.append(encodeURIComponent($('#style-select').val())); |
---|
| | 1630 | // buffer.append('&blog='); //blog where to post |
---|
| | 1631 | // buffer.append(encodeURIComponent("blog")); |
---|
| | 1632 | // buffer.append('&elementtype='); // text, audio, img |
---|
| | 1633 | // buffer.append(encodeURIComponent(command.elementType)); |
---|
| | 1634 | // buffer.append('&xpath=');//xpath |
---|
| | 1635 | // buffer.append(encodeURIComponent(command.xpath)); |
---|
| | 1636 | // buffer.append('&data='); //data |
---|
| | 1637 | // buffer.append(encodeURIComponent(command.data)); |
---|
| | 1638 | // buffer.append('&author='); //author |
---|
| | 1639 | // if ($('#auth-select').val() == '' || $('#auth-select').val() == /\S/) { |
---|
| | 1640 | // buffer.append(encodeURIComponent('Anonymous')); |
---|
| | 1641 | // } else { |
---|
| | 1642 | // buffer.append(encodeURIComponent($('#auth-select').val())); |
---|
| | 1643 | // } |
---|
| | 1644 | }); |
---|
| | 1645 | // return buffer.toString().substring(3); |
---|
| | 1646 | buff.push({'comments': $("#tar-comment").val()}); |
---|
| | 1647 | console.log(buff); |
---|
| | 1648 | return buff; |
---|
| | 1649 | }, |
---|
| | 1650 | }; |
---|
1109 | | 1651 | |
---|
1110 | unhighlightOnMouseOut: function(event) { | | unhighlightOnMouseOut: function(event) { |
---|
1111 | $(event.target).removeClass('highlightElement'); | | $(event.target).removeClass('highlightElement'); |
---|
1112 | }, | | }, |
---|
1113 | showInfo: function(data) { | | showInfo: function(data) { |
---|
1114 | infoWindow = window.open(config.deploy+'/blank','Info page'); | | infoWindow = window.open(config.deploy+'/blank','Info page'); |
---|
1115 | window.setTimeout(function(){a11ypi.pushInfo(infoWindow.document.getElementById('info_content'),infoWindow,data);},2500); | | window.setTimeout(function(){a11ypi.pushInfo(infoWindow.document.getElementById('info_content'),infoWindow,data);},2500); |
---|
1116 | }, | | }, |
---|
1117 | pushInfo: function(ele, win, data) //ele contains the info_content element from blank.html | | pushInfo: function(ele, win, data) //ele contains the info_content element from blank.html |
---|
1118 | { | | { |
---|
1119 | win.infoFullJSON = a11ypi.responseJSON; | | win.infoFullJSON = a11ypi.responseJSON; |
---|
1120 | win.onLoad(); | | win.onLoad(); |
---|
1121 | }, | | }, |
---|
1122 | getParams: function() | | getParams: function() |
---|
1123 | { | | { |
---|
1124 | var a = []; | | var a = []; |
---|
1125 | if(window.location.hostname == config.hostname || "localhost" ) | | if(window.location.hostname == config.hostname || "localhost" ) |
---|
1126 | { | | { |
---|
1127 | d = window.location.search.split('?')[1]; | | d = window.location.search.split('?')[1]; |
---|
1128 | for (var i = 0;i<d.split('&').length;i++){ | | for (var i = 0;i<d.split('&').length;i++){ |
---|
1129 | a[d.split('&')[i].split('=')[0]] = decodeURIComponent(d.split('&')[i].split('=')[1]); | | a[d.split('&')[i].split('=')[0]] = decodeURIComponent(d.split('&')[i].split('=')[1]); |
---|
1130 | } | | } |
---|
1131 | return a; | | return a; |
---|
1132 | } | | } |
---|
1133 | else | | else |
---|
1134 | { | | { |
---|
1135 | a['foruri'] = window.location.href; | | a['foruri'] = window.location.href; |
---|
1136 | return a; | | return a; |
---|
1137 | } | | } |
---|
1138 | } | | } |
---|
1139 | }; | | }; |
---|
| | 1652 | var manager = { | | | 1653 | recordText:function (selectedElement) { |
---|
| | 1654 | var prevData = $(selectedElement).html(); |
---|
| | 1655 | var command = { |
---|
| | 1656 | command : 'TEXT_UPDATE', |
---|
| | 1657 | element : selectedElement, |
---|
| | 1658 | url : window.location.href, |
---|
| | 1659 | xpath : DOM.getXpath(selectedElement), |
---|
| | 1660 | elementType : 'text', |
---|
| | 1661 | data : DOM.gettextContent($('#editor')), |
---|
| | 1662 | previousData : prevData |
---|
| | 1663 | }; |
---|
| | 1664 | util.makeChanges(command, selectedElement); |
---|
| | 1665 | }, |
---|
| | 1666 | recordAudio:function(selectedElement){ |
---|
| | 1667 | var command = { |
---|
| | 1668 | command : 'AUDIO_CREATE', |
---|
| | 1669 | element : selectedElement, |
---|
| | 1670 | url : window.location.href, |
---|
| | 1671 | xpath : DOM.getXpath(selectedElement), |
---|
| | 1672 | elementType: 'audio/ogg', |
---|
| | 1673 | data : url, |
---|
| | 1674 | previousData : '' |
---|
| | 1675 | |
---|
| | 1676 | }; |
---|
| | 1677 | util.makeChanges(command,selectedElement); |
---|
| | 1678 | }, |
---|
| | 1679 | deleteElement : function(selectedElement) { |
---|
| | 1680 | var command = { |
---|
| | 1681 | command : 'DELETE', |
---|
| | 1682 | element : selectedElement, |
---|
| | 1683 | url : '', |
---|
| | 1684 | elementType : 'text', |
---|
| | 1685 | data : '', |
---|
| | 1686 | xpath : '', |
---|
| | 1687 | data : '', |
---|
| | 1688 | previousData : '' |
---|
| | 1689 | }; |
---|
| | 1690 | util.makeChanges(command, selectedElement); |
---|
| | 1691 | }, |
---|
| | 1692 | recordImage: function(selectedElement, url) |
---|
| | 1693 | { |
---|
| | 1694 | var command = { |
---|
| | 1695 | command : 'IMAGE_SRC_UPDATE', |
---|
| | 1696 | element : selectedElement, |
---|
| | 1697 | elementType : 'image', |
---|
| | 1698 | xpath : DOM.getXpath(selectedElement), |
---|
| | 1699 | url : window.location.href, |
---|
| | 1700 | data : new StringUtil.StringBuffer().append(selectedElement.width).append('x').append(selectedElement.height).append(',').append(url).toString(), |
---|
| | 1701 | previousData : { |
---|
| | 1702 | 'src' : selectedElement.src, |
---|
| | 1703 | 'size' : { width: selectedElement.width, height: selectedElement.height } |
---|
| | 1704 | } |
---|
| | 1705 | }; |
---|
| | 1706 | util.makeChanges(command, selectedElement); |
---|
| | 1707 | }, |
---|
| | 1708 | deleteImage : function(selectedElement) { |
---|
| | 1709 | var command = { |
---|
| | 1710 | command : 'IMAGE_DELETE', |
---|
| | 1711 | element : selectedElement, |
---|
| | 1712 | url : window.location.href, |
---|
| | 1713 | elementType : 'image', |
---|
| | 1714 | data : '', |
---|
| | 1715 | xpath : '', |
---|
| | 1716 | data : '', |
---|
| | 1717 | previousData : { |
---|
| | 1718 | 'src' : selectedElement.src, |
---|
| | 1719 | 'size' : { width: selectedElement.width, height: selectedElement.height } |
---|
| | 1720 | } |
---|
| | 1721 | }; |
---|
| | 1722 | util.makeChanges(command, selectedElement); |
---|
| | 1723 | }, |
---|
| | 1724 | |
---|
| | 1725 | }; |
---|
| | 1726 | //Implementing the class for doing StringBuffer. |
---|
| | 1727 | var StringUtil = StringUtil || {}; |
---|
| | 1728 | (function(StringUtil){ |
---|
| | 1729 | StringUtil.StringBuffer = function StringBuffer() { |
---|
| | 1730 | var buffer = []; |
---|
| | 1731 | this.append = function append(string) { |
---|
| | 1732 | buffer.push(string); |
---|
| | 1733 | return this; |
---|
| | 1734 | }; |
---|
| | 1735 | |
---|
| | 1736 | this.toString = function toString() { |
---|
| | 1737 | return buffer.join(''); |
---|
| | 1738 | }; |
---|
| | 1739 | }; |
---|
| | 1740 | })(StringUtil); |
---|
| | 1741 | window.pageEditor = pageEditor; |
---|
| | 1742 | })(jQuery); |
---|
| | 1743 | }}]);}; |
---|