diff options
author | supriya <supriya@dragbox.(none)> | 2012-06-15 17:20:25 +0530 |
---|---|---|
committer | supriya <supriya@dragbox.(none)> | 2012-06-15 17:20:25 +0530 |
commit | 3cdc89682bc24634ae672acf090aa83a4ee2fd89 (patch) | |
tree | 2b459073283f704a644e636d3006a21bcf961ded /objectapp/static/objectapp | |
parent | 1f9318d1d158bd31e75469386cb03f5ae5208464 (diff) | |
download | gnowsys-3cdc89682bc24634ae672acf090aa83a4ee2fd89.tar.gz |
wrap added to gnowmacs & save button is working
Diffstat (limited to 'objectapp/static/objectapp')
-rw-r--r-- | objectapp/static/objectapp/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js | 98 | ||||
-rw-r--r-- | objectapp/static/objectapp/js/Gnowmacs/src/js/ymacs-commands.js | 164 |
2 files changed, 68 insertions, 194 deletions
diff --git a/objectapp/static/objectapp/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js b/objectapp/static/objectapp/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js index 88caa1f..e8e781d 100644 --- a/objectapp/static/objectapp/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js +++ b/objectapp/static/objectapp/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js @@ -171,45 +171,33 @@ var org_data = org.getCode(); document.getElementById("orgcontent").value = org_data; var encode_data = encodeURIComponent(org_data); - - - url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/ajaxcreatefile/?id=" +id+ "&content_org=" +encode_data; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/ajaxcreatehtml/"; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - - - alert("Data Saved"); - window.location.reload(); - }); - + url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; + $.get(url, + function(data){ + + url1 = "/nodetypes/ajax/ajaxcreatefile/?id=" +id+ "&content_org=" +encode_data; + $.get(url1, + function(data){ + url2 = "/nodetypes/ajax/ajaxcreatehtml/"; + $.get(url2, + function(data){ + url3 = "/nodetypes/ajax/contentadd/?id=" + id; + $.get(url3, + function(data){ + alert("Data Saved"); + window.location.reload(); + + }) + + + }) + }) + + }) + + + }); + var item = new DlMenuItem({ parent: menu, label: "Toggle line numbers".makeLabel() @@ -217,30 +205,14 @@ item.addEventListener("onSelect", function () { ymacs.getActiveBuffer().cmd("toggle_line_numbers"); }); - - /*------[ Wrap ]-------- - flag is a variable to store the current status of wrap.wrap itself switches On n Off depending on previous status. - so it is necessary to keep record of previous status*/ - - // var item = new DlMenuItem({ - // parent: menu, - // label: "Wrap".makeLabel() - // }); - // var flag = "False"; - // item.addEventListener("onSelect", function () { - // if (flag == "False") { - // flag = "True"; - // alert("Wrapping is ON"); - // ymacs.getActiveBuffer().cmd("wrap_text"); - // } else { - // flag = "False"; - // alert("Wrapping is OFF"); - // ymacs.getActiveBuffer().cmd("wrap_text"); - // } - - // }); - - + + var item = new DlMenuItem({ + parent: menu, + label: "Wrap".makeLabel() + }); + item.addEventListener("onSelect", function () { + ymacs.getActiveBuffer().cmd("wrap"); + }); /* -----[ insert - just a try] ----- */ diff --git a/objectapp/static/objectapp/js/Gnowmacs/src/js/ymacs-commands.js b/objectapp/static/objectapp/js/Gnowmacs/src/js/ymacs-commands.js index a44e1ff..21091d9 100644 --- a/objectapp/static/objectapp/js/Gnowmacs/src/js/ymacs-commands.js +++ b/objectapp/static/objectapp/js/Gnowmacs/src/js/ymacs-commands.js @@ -102,139 +102,41 @@ Ymacs_Buffer.newCommands({ var rc = this._rowcol; return this.cmd("goto_char", this._rowColToPosition(rc.row, this.code[rc.row].length)); }), - wrap : Ymacs_Interactive(function() { - var i = 0; - this.cmd("end_of_buffer"); - var st1 = this.caretMarker.getPosition(); - this.cmd("beginning_of_buffer"); - if(st1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line", i); - i= i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var line_size = line.length; - if(line_size > 112) - { - this.cmd("move_to_column", 111); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - - } - - }), - - - wrap_at_edge : Ymacs_Interactive(function() { - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > 112) - { - this.cmd("insert", "\n"); - } - }), - - wrap_status:Ymacs_Interactive(function() { - var one = flag; - //alert("inside wrap_status"); - return one; - }), - - word_wrap : Ymacs_Interactive(function() { - - var one1 = this.cmd("wrap_status"); - if(one1 == "Word Wrap") - { - var x = 112; - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > x) - { - var str2 = line.slice(0,str1-2); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("end_of_line"); - this.cmd("insert", " "); - } - else - { - this.cmd("insert", " "); - } - } - else - { - - this.cmd("insert", " "); - } - + wrap : Ymacs_Interactive(function() { + + this.cmd("beginning_of_buffer"); + this.cmd("goto_line" ,1); + var i = 0,y = 0, x = 50; + while(i < 100) + { + i = i+1; + + + this.cmd("end_of_line"); + var ipos = this._positionToRowCol(this.point()); + var charpos = this.caretMarker.getPosition(); // It gives total number of character upto this position. + + + if(ipos.col > x ) //ipos.col gives the column number at this point. + { + y = ipos.col-50; + var z = charpos-y; + this.cmd("goto_char", z); + this.cmd("insert", "\n"); + } + else + { + this.cmd("forward_line"); + + } + + } + }), - }), - - - wrap1:Ymacs_Interactive(function() { - var i = 1; - this.cmd("end_of_buffer"); - var str1 = this.caretMarker.getPosition(); - //this.cmd("beginning_of_buffer"); - if(str1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line" ,i); - i=i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var str2 = line.lastIndexOf(" "); - if(str2 > 112) - { - var str2 = line.slice(0,115); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - } - - }), - - beginning_of_buffer: Ymacs_Interactive(function() { return this.cmd("goto_char", 0); }), - export_as_html: Ymacs_Interactive(function() { - //jQuery.get('/ymacs/test.py', function(data) { - //alert("jquery"); - //window.location= "/home/supriya/ymacs/test.py" - //alert("test1"); - - //do stuff with the data - - - //var oShell = new AactiveXObject("WScript.Shell"); - //shell.Run("/h", 1, true); - // $.ajax({ - // type: "GET", - // url: "test.py", - // success: function() { alert("ajax"); } - //} ); - //} ); - //url = "~/test.py" - //$.get(url, - //function(data){ - //alert("ajax"); - //}); - - }), - end_of_buffer: Ymacs_Interactive(function() { return this.cmd("goto_char", this.getCodeSize()); @@ -340,9 +242,9 @@ Ymacs_Buffer.newCommands({ this.cmd("indent_line"); } }), - + -// tab is not working on the 1st position of the buffer + // tab is not working on the 1st position of the buffer // user should create table from 1st position only indent_line: Ymacs_Interactive("P", function(noEmpty) { @@ -496,7 +398,7 @@ Ymacs_Buffer.newCommands({ } this.cmd("insert", " ".x(this.getq("indent_line"))); }), - indent_region: Ymacs_Interactive("r", function(begin, end) { + indent_region: Ymacs_Interactive("r", function(begin, end) { if (end < begin) { var tmp = begin; begin = end; end = tmp; } this.cmd("save_excursion", function() { var m = this.createMarker(end); |