Commit 94920135b40375cf12d21b6b5f2345a0b94dd199
- Diff rendering mode:
- inline
- side by side
server/ui.js
(42 / 12)
  | |||
371 | 371 | '<input id="see-narration" type="submit" onclick="a11ypi." value="Undo">'+ | |
372 | 372 | '<input id="see-links" type="submit" onclick="a11ypi.publish();" value="Publish">'; | |
373 | 373 | ||
374 | var element_edit_overlay_template = '<div id="element_edit_overlay" class="ui-widget-header ui-corner-all">'+ | ||
375 | '<input id="edit-text" type="submit" onclick="a11ypi.displayEditor();" value="Edit Text" disabled=true>'+ | ||
376 | '<input id="add-audio" type="submit" onclick="a11ypi.help_window();" value="Add Audio" disabled=true>'+ | ||
377 | '<input id="add-link" type="submit" onclick="a11ypi.showBox();" value="Add Link" disabled=true>'+ | ||
378 | '<input id="replace-image" type="submit" onclick="a11ypi.imageReplacer();" value="Replace Image" disabled=true>'; | ||
374 | var element_edit_overlay_template = '<div id="element_edit_overlay" class="alipi ui-widget-header ui-corner-all">'+ | ||
375 | '<input id="edit-text" class="alipi" type="submit" onclick="a11ypi.displayEditor();" value="Edit Text" disabled=true>'+ | ||
376 | '<input id="add-audio" type="submit" onclick="a11ypi.help_window();" class="alipi" value="Add Audio" disabled=true>'+ | ||
377 | '<input id="add-link" type="submit" onclick="a11ypi.showBox();" class="alipi" value="Add Link" disabled=true>'+ | ||
378 | '<input id="replace-image" type="submit" onclick="a11ypi.imageReplacer();" class="alipi" value="Replace Image" disabled=true>'; | ||
379 | |||
380 | var imageInputTemplate = '<div id="imageInputElement" title="Enter url" class="alipi ui-widget-header ui-corner-all">'+ | ||
381 | '<input type="text" id="imageInput" placeholder="http://foo.com/baz.jpg" class="alipi" value=""/>'+ | ||
382 | '</div>'; | ||
379 | 383 | ||
380 | 384 | $('body').append(icon_template); | |
381 | 385 | $('body').append(overlay_template); | |
382 | 386 | $('body').append(pub_overlay_template); | |
383 | 387 | $('body').append(element_edit_overlay_template); | |
388 | $('body').append(imageInputTemplate); | ||
384 | 389 | a11ypi.ajax(); | |
385 | 390 | a11ypi.ajaxLinks1(); | |
386 | 391 | go.disabled = true; | |
… | … | ||
632 | 632 | $('#icon_on_overlay').show(); | |
633 | 633 | $('#pub_overlay').show(); | |
634 | 634 | $('#element_edit_overlay').show(); | |
635 | // document.addEventListener('click',pageEditor.startEdit, false); | ||
636 | $(document).click(pageEditor.startEdit); | ||
637 | //page_edit('4seiz', '4l85060vb9', '336e2nootv6nxjsvyjov', 'VISUAL', 'false', ''); | ||
638 | // document.getElementById("renarrated_overlay").style.display = "none"; | ||
635 | $('body *').contents().filter(function(){ | ||
636 | { | ||
637 | try{ | ||
638 | if(!($(this).hasClass('alipi'))) | ||
639 | return this; | ||
640 | } | ||
641 | catch(err) | ||
642 | { | ||
643 | //pass | ||
644 | }}}).click(pageEditor.startEdit); | ||
639 | 645 | }, | |
640 | 646 | ||
641 | 647 | displayEditor: function() { | |
… | … | ||
691 | 691 | }, | |
692 | 692 | ||
693 | 693 | imageReplacer: function() { | |
694 | var src = prompt("Enter the url"); | ||
695 | $(event.target).attr('src',src); | ||
696 | console.log(DOM.getXpath(event.target)); | ||
694 | $( "#imageInputElement" ).dialog({ | ||
695 | width:300, | ||
696 | height:200, | ||
697 | modal: true, | ||
698 | buttons: { | ||
699 | OK: function() { | ||
700 | |||
701 | var formValue = $('#imageInput').val(); | ||
702 | if(formValue != '\/S/') | ||
703 | { | ||
704 | pageEditor.cleanUp(pageEditor.event.target); | ||
705 | console.log(formValue); | ||
706 | manager.updateImage(pageEditor.event.target, formValue); | ||
707 | $( "#imageInputElement" ).remove(); | ||
708 | } | ||
709 | } | ||
710 | }, | ||
711 | close: function() { | ||
712 | pageEditor.cleanUp(pageEditor.event.target); | ||
713 | $("#imageInputElement" ).remove(); | ||
714 | } | ||
715 | }); | ||
697 | 716 | ||
698 | 717 | }, | |
699 | 718 |
server/wsgi/pageEditor.js
(46 / 7)
  | |||
4 | 4 | '<div id="reference" readonly="yes"></div>'+ | |
5 | 5 | '<label style="left: 70%;">Editor</label>'+ | |
6 | 6 | '<div id="editor" alipielements="alipi" contenteditable="true"></div>'+ | |
7 | '<div id="forPrevData"></div>'+ | ||
7 | '<div id="forPrevData"></div>'+ | ||
8 | 8 | '</div>', | |
9 | 9 | event: 0 , //Use this var to store the event object, which will be passed for editor. | |
10 | m4pageedittype: '', | ||
10 | 11 | startEdit: function(event) | |
11 | 12 | { | |
13 | pageEditor.event = event; | ||
14 | pageEditor.m4pageedittype = $(event.target).attr('m4pageedittype'); | ||
12 | 15 | if($(event.target).attr('m4pageedittype') == 'text') | |
13 | 16 | { | |
14 | pageEditor.event = event; | ||
17 | |||
15 | 18 | $('#pub_overlay').slideDown(); | |
16 | 19 | $('#element_edit_overlay').slideDown(); | |
17 | 20 | ||
… | … | ||
36 | 36 | } | |
37 | 37 | else if($(event.target).attr('m4pageedittype') == 'image') | |
38 | 38 | { | |
39 | _this = pageEditor; | ||
39 | 40 | $('#replace-image').attr('disabled', false); | |
40 | $('#add-audio').attr('disabled', false); | ||
41 | $('#add-link').attr('disabled', false); | ||
41 | $('#add-audio').attr('disabled', true); | ||
42 | $('#add-link').attr('disabled', true); | ||
42 | 43 | $('#edit-text').attr('disabled', true); | |
44 | |||
43 | 45 | } | |
44 | 46 | ||
45 | 47 | }, | |
46 | 48 | cleanUp: function(element) | |
47 | 49 | { | |
48 | $(element).attr('m4pageedittype','text'); | ||
49 | $(element).children().attr('m4pageedittype','text'); | ||
50 | $(element).attr('m4pageedittype', pageEditor.m4pageedittype); | ||
51 | $(element).children().attr('m4pageedittype', pageEditor.m4pageedittype); | ||
50 | 52 | }, | |
51 | 53 | }; | |
52 | 54 | ||
… | … | ||
193 | 193 | // break; | |
194 | 194 | ||
195 | 195 | case 'IMAGE_SRC_UPDATE': | |
196 | console.log(command.data); | ||
196 | 197 | imageMatcher = new RegExp("(\\d+)x(\\d+),(.+)").exec(command.data); | |
197 | 198 | imageWidth = imageMatcher[1]; | |
198 | 199 | imageHeight = imageMatcher[2]; | |
… | … | ||
201 | 201 | ||
202 | 202 | if (imageSrc && command.element.src != imageSrc) { | |
203 | 203 | command.element.src = imageSrc; | |
204 | pageEditor.showMessage('Image changed'); | ||
204 | //pageEditor.showMessage('Image changed'); | ||
205 | 205 | } | |
206 | 206 | if (imageWidth == 0) { | |
207 | 207 | command.element.removeAttribute('width'); | |
… | … | ||
413 | 413 | }; | |
414 | 414 | util.recordHistory(command, selectedElement); | |
415 | 415 | }, | |
416 | updateImage: function(selectedElement, url) | ||
417 | { | ||
418 | console.log(url); | ||
419 | var command = { | ||
420 | command : 'IMAGE_SRC_UPDATE', | ||
421 | element : selectedElement, | ||
422 | elementType : 'image', | ||
423 | xpath : DOM.getXpath(selectedElement), | ||
424 | url : window.location.href, | ||
425 | data : new StringUtil.StringBuffer().append(selectedElement.width).append('x').append(selectedElement.height).append(',').append(url).toString(), | ||
426 | previousData : { | ||
427 | 'src' : selectedElement.src, | ||
428 | 'size' : { width: selectedElement.width, height: selectedElement.height } | ||
429 | //'rawImageSize' : image.getRawImageSize() | ||
430 | } | ||
431 | } | ||
432 | util.recordHistory(command, selectedElement); | ||
433 | }, | ||
416 | 434 | }; | |
435 | //Implementing the class for doing StringBuffer. | ||
436 | var StringUtil = StringUtil || {}; | ||
437 | (function(StringUtil){ | ||
438 | StringUtil.StringBuffer = function StringBuffer() { | ||
439 | var buffer = []; | ||
440 | this.append = function append(string) { | ||
441 | buffer.push(string); | ||
442 | return this; | ||
443 | }; | ||
444 | |||
445 | this.toString = function toString() { | ||
446 | return buffer.join(''); | ||
447 | }; | ||
448 | }; | ||
449 | })(StringUtil); |