From 9102c9aff4738bc46e92a3cb60c7f0f07f6e2deb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Jun 2012 18:10:29 +0200 Subject: [PATCH] fixed Notes widget --- .../applications/Notes.wgt/js/ubw-main.js | 16 +- .../applications/Notes.wgt/ubw-main.js | 211 ------------------ 2 files changed, 14 insertions(+), 213 deletions(-) delete mode 100644 resources/library/applications/Notes.wgt/ubw-main.js diff --git a/resources/library/applications/Notes.wgt/js/ubw-main.js b/resources/library/applications/Notes.wgt/js/ubw-main.js index 3009fa9b..4d799fc2 100644 --- a/resources/library/applications/Notes.wgt/js/ubw-main.js +++ b/resources/library/applications/Notes.wgt/js/ubw-main.js @@ -77,10 +77,13 @@ function init(){ if(window.sankore){ window.sankore.setPreference("fontSize", newFontSize); - }; + } if(!checkMinimize) textField.focus(); + + var sel = window.getSelection(); + sel.removeAllRanges(); }); fontUp.click( @@ -95,10 +98,12 @@ function init(){ if(window.sankore){ window.sankore.setPreference("fontSize", newFontSize); - }; + } if(!checkMinimize) textField.focus(); + var sel = window.getSelection(); + sel.removeAllRanges(); }); minimize.click( @@ -229,4 +234,11 @@ function init(){ controlTextField(); } + + if (window.widget) { + window.widget.onleave = function(){ + window.sankore.setPreference("noteText", textField.html()); + window.sankore.setPreference("fontSize", newFontSize); + } + } } diff --git a/resources/library/applications/Notes.wgt/ubw-main.js b/resources/library/applications/Notes.wgt/ubw-main.js deleted file mode 100644 index 1e86c2a5..00000000 --- a/resources/library/applications/Notes.wgt/ubw-main.js +++ /dev/null @@ -1,211 +0,0 @@ -function init(){ - - var ubwidget = $("#ubwidget").ubwidget({ - width:300, - height:240 - }); - - var text = ""; - var winwidth; - var minimizedHeight; - var winheight; - var scroll = false; - var defaultFontSize = 35; - var currentFontSize = defaultFontSize; - var header = $(''); - var fontUp = $(''); - var fontDown = $(''); - var minimize = $(''); - var maximize = $(''); - var title = $(''); - var textField = $('
'); - var shadow = $("
 
") - .appendTo("body"); - var shadowleft = $("") - .appendTo($("#sl")); - var shadowright = $("") - .appendTo($("#sr")); - - $("#ubwidget") - .append(header) - .append(textField); - - fontUp.addClass('menuElement'); - fontDown.addClass('menuElement'); - minimize.addClass('menuElement'); - maximize.addClass('menuElement') - .hide(); - - header.append(maximize) - .append(minimize) - .append(fontUp) - .append(fontDown); - var titletext = header.find('textarea'); - - titletext.click( - function(){ - - titletext.focus(); - - }); - - fontDown.click( - function(){ - - var newFontSize = parseInt(currentFontSize) - 3; - - textField.css({ - fontSize : newFontSize - }) - - controlTextField(); - - if(window.sankore){ - window.sankore.setPreference("fontSize", newFontSize); - }; - - //textField.focus(); - }); - - fontUp.click( - function(){ - - var newFontSize = parseInt(currentFontSize) + 3; - - textField.css({ - fontSize : newFontSize - }) - - controlTextField(); - - if(window.sankore){ - window.sankore.setPreference("fontSize", newFontSize); - }; - - //textField.focus(); - }); - - minimize.click( - function(){ - $('.ubw-container').animate({height:"26px"},100); - minimizedHeight = $('.ubw-container').height() ; - minimize.hide(); - maximize.show(); - $('#headtitle').show(); - window.resizeTo($('.ubw-container').width(),0); - - if(window.sankore){ - window.sankore.setPreference("minimized", "true"); - }; - }); - - maximize.click( - function(){ - var lastHeight = String(minimizedHeight)+'px'; - $('.ubw-container').animate({height: lastHeight},100); - - maximize.hide(); - minimize.show(); - $('#headtitle').hide(); - - window.resizeTo($('.ubw-container').width()+15,minimizedHeight+20); - - if(window.sankore){ - window.sankore.setPreference("minimized", "false"); - }; - }); - - header - .append(title); - title - .addClass('menu'); - header - .addClass('head'); - textField - .addClass("textField") - .css("fontSize",currentFontSize) - .attr('contentEditable','true') - .keyup(function(){ - if(window.sankore){ - window.sankore.setPreference("text", textField.html()); - } - controlTextField(); - $('#headtitle').hide(); - }); - if(textField.html().length === 0){ - textField.focus(); - } - titletext - .attr('rows','1'); - - function controlTextField(){ - if(textField.text().length < 25){ - var titleStr = textField.text() + '...'; - $('#headtitle').val(titleStr); - } - - textField.css({ - height : $('.ubw-container').height()-28, - }) - - if(textField.text().length == 0){ - textField.css({ - fontSize: defaultFontSize, - }); - } - - currentFontSize = textField.css('fontSize').replace('px',''); - - } - - textField.bind('paste', function(e) { - controlTextField(); - }); - $('#headtitle').hide(); - if(window.sankore){ - text = window.sankore.preference('text', text); - currentFontSize = window.sankore.preference('fontSize', defaultFontSize); - - $('.ubw-container').css({ - width:parseInt(window.sankore.preference('width', "300")), - height:parseInt(window.sankore.preference('height', "240")) - }); - - if(window.sankore.preference('minimized', "false") == "true"){ - minimize.trigger("click"); - }; - - textField.css({ - fontSize : parseInt(currentFontSize) - }) - textField.html(text); - } - - window.onresize = function(){ - winwidth = window.innerWidth; - winheight = window.innerHeight; - - if(winwidth <= 290) - { - window.resizeTo(290,winheight); - } - if(winheight <= 100) - { - window.resizeTo(winwidth,100); - } - if(winheight > 600) - { - window.resizeTo(winwidth,600); - } - - $('.ubw-container').width(winwidth-2) ; - $('.ubw-container').height(winheight-20) ; - - if(window.sankore){ - window.sankore.setPreference("width", winwidth-2); - window.sankore.setPreference("height", winheight-20); - } - - controlTextField(); - } -} \ No newline at end of file