You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by pr...@apache.org on 2014/04/17 04:42:55 UTC
[15/52] [partial] forking carbon ui bundle in to stratos code base
and removing license incompatible JS and packing the new module to carbon
runtime, through dropins
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/autocompletion.js
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/autocompletion.js b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/autocompletion.js
new file mode 100644
index 0000000..c5d646a
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/autocompletion.js
@@ -0,0 +1,491 @@
+/**
+ * Autocompletion class
+ *
+ * An auto completion box appear while you're writing. It's possible to force it to appear with Ctrl+Space short cut
+ *
+ * Loaded as a plugin inside editArea (everything made here could have been made in the plugin directory)
+ * But is definitly linked to syntax selection (no need to do 2 different files for color and auto complete for each syntax language)
+ * and add a too important feature that many people would miss if included as a plugin
+ *
+ * - init param: autocompletion_start
+ * - Button name: "autocompletion"
+ */
+
+var EditArea_autocompletion= {
+
+ /**
+ * Get called once this file is loaded (editArea still not initialized)
+ *
+ * @return nothing
+ */
+ init: function(){
+ // alert("test init: "+ this._someInternalFunction(2, 3));
+
+ if(editArea.settings["autocompletion"])
+ this.enabled= true;
+ else
+ this.enabled= false;
+ this.current_word = false;
+ this.shown = false;
+ this.selectIndex = -1;
+ this.forceDisplay = false;
+ this.isInMiddleWord = false;
+ this.autoSelectIfOneResult = false;
+ this.delayBeforeDisplay = 100;
+ this.checkDelayTimer = false;
+ this.curr_syntax_str = '';
+
+ this.file_syntax_datas = {};
+ }
+ /**
+ * Returns the HTML code for a specific control string or false if this plugin doesn't have that control.
+ * A control can be a button, select list or any other HTML item to present in the EditArea user interface.
+ * Language variables such as {$lang_somekey} will also be replaced with contents from
+ * the language packs.
+ *
+ * @param {string} ctrl_name: the name of the control to add
+ * @return HTML code for a specific control or false.
+ * @type string or boolean
+ */
+ /*,get_control_html: function(ctrl_name){
+ switch( ctrl_name ){
+ case 'autocompletion':
+ // Control id, button img, command
+ return parent.editAreaLoader.get_button_html('autocompletion_but', 'autocompletion.gif', 'toggle_autocompletion', false, this.baseURL);
+ break;
+ }
+ return false;
+ }*/
+ /**
+ * Get called once EditArea is fully loaded and initialised
+ *
+ * @return nothing
+ */
+ ,onload: function(){
+ if(this.enabled)
+ {
+ var icon= document.getElementById("autocompletion");
+ if(icon)
+ editArea.switchClassSticky(icon, 'editAreaButtonSelected', true);
+ }
+
+ this.container = document.createElement('div');
+ this.container.id = "auto_completion_area";
+ editArea.container.insertBefore( this.container, editArea.container.firstChild );
+
+ // add event detection for hiding suggestion box
+ parent.editAreaLoader.add_event( document, "click", function(){ editArea.plugins['autocompletion']._hide();} );
+ parent.editAreaLoader.add_event( editArea.textarea, "blur", function(){ editArea.plugins['autocompletion']._hide();} );
+
+ }
+
+ /**
+ * Is called each time the user touch a keyboard key.
+ *
+ * @param (event) e: the keydown event
+ * @return true - pass to next handler in chain, false - stop chain execution
+ * @type boolean
+ */
+ ,onkeydown: function(e){
+ if(!this.enabled)
+ return true;
+
+ if (EA_keys[e.keyCode])
+ letter=EA_keys[e.keyCode];
+ else
+ letter=String.fromCharCode(e.keyCode);
+ // shown
+ if( this._isShown() )
+ {
+ // if escape, hide the box
+ if(letter=="Esc")
+ {
+ this._hide();
+ return false;
+ }
+ // Enter
+ else if( letter=="Entrer")
+ {
+ var as = this.container.getElementsByTagName('A');
+ // select a suggested entry
+ if( this.selectIndex >= 0 && this.selectIndex < as.length )
+ {
+ as[ this.selectIndex ].onmousedown();
+ return false
+ }
+ // simply add an enter in the code
+ else
+ {
+ this._hide();
+ return true;
+ }
+ }
+ else if( letter=="Tab" || letter=="Down")
+ {
+ this._selectNext();
+ return false;
+ }
+ else if( letter=="Up")
+ {
+ this._selectBefore();
+ return false;
+ }
+ }
+ // hidden
+ else
+ {
+
+ }
+
+ // show current suggestion list and do autoSelect if possible (no matter it's shown or hidden)
+ if( letter=="Space" && CtrlPressed(e) )
+ {
+ //parent.console.log('SHOW SUGGEST');
+ this.forceDisplay = true;
+ this.autoSelectIfOneResult = true;
+ this._checkLetter();
+ return false;
+ }
+
+ // wait a short period for check that the cursor isn't moving
+ setTimeout("editArea.plugins['autocompletion']._checkDelayAndCursorBeforeDisplay();", editArea.check_line_selection_timer +5 );
+ this.checkDelayTimer = false;
+ return true;
+ }
+ /**
+ * Executes a specific command, this function handles plugin commands.
+ *
+ * @param {string} cmd: the name of the command being executed
+ * @param {unknown} param: the parameter of the command
+ * @return true - pass to next handler in chain, false - stop chain execution
+ * @type boolean
+ */
+ ,execCommand: function(cmd, param){
+ switch( cmd ){
+ case 'toggle_autocompletion':
+ var icon= document.getElementById("autocompletion");
+ if(!this.enabled)
+ {
+ if(icon != null){
+ editArea.restoreClass(icon);
+ editArea.switchClassSticky(icon, 'editAreaButtonSelected', true);
+ }
+ this.enabled= true;
+ }
+ else
+ {
+ this.enabled= false;
+ if(icon != null)
+ editArea.switchClassSticky(icon, 'editAreaButtonNormal', false);
+ }
+ return true;
+ }
+ return true;
+ }
+ ,_checkDelayAndCursorBeforeDisplay: function()
+ {
+ this.checkDelayTimer = setTimeout("if(editArea.textarea.selectionStart == "+ editArea.textarea.selectionStart +") EditArea_autocompletion._checkLetter();", this.delayBeforeDisplay - editArea.check_line_selection_timer - 5 );
+ }
+ // hide the suggested box
+ ,_hide: function(){
+ this.container.style.display="none";
+ this.selectIndex = -1;
+ this.shown = false;
+ this.forceDisplay = false;
+ this.autoSelectIfOneResult = false;
+ }
+ // display the suggested box
+ ,_show: function(){
+ if( !this._isShown() )
+ {
+ this.container.style.display="block";
+ this.selectIndex = -1;
+ this.shown = true;
+ }
+ }
+ // is the suggested box displayed?
+ ,_isShown: function(){
+ return this.shown;
+ }
+ // setter and getter
+ ,_isInMiddleWord: function( new_value ){
+ if( typeof( new_value ) == "undefined" )
+ return this.isInMiddleWord;
+ else
+ this.isInMiddleWord = new_value;
+ }
+ // select the next element in the suggested box
+ ,_selectNext: function()
+ {
+ var as = this.container.getElementsByTagName('A');
+
+ // clean existing elements
+ for( var i=0; i<as.length; i++ )
+ {
+ if( as[i].className )
+ as[i].className = as[i].className.replace(/ focus/g, '');
+ }
+
+ this.selectIndex++;
+ this.selectIndex = ( this.selectIndex >= as.length || this.selectIndex < 0 ) ? 0 : this.selectIndex;
+ as[ this.selectIndex ].className += " focus";
+ }
+ // select the previous element in the suggested box
+ ,_selectBefore: function()
+ {
+ var as = this.container.getElementsByTagName('A');
+
+ // clean existing elements
+ for( var i=0; i<as.length; i++ )
+ {
+ if( as[i].className )
+ as[i].className = as[ i ].className.replace(/ focus/g, '');
+ }
+
+ this.selectIndex--;
+
+ this.selectIndex = ( this.selectIndex >= as.length || this.selectIndex < 0 ) ? as.length-1 : this.selectIndex;
+ as[ this.selectIndex ].className += " focus";
+ }
+ ,_select: function( content )
+ {
+ cursor_forced_position = content.indexOf( '{@}' );
+ content = content.replace(/{@}/g, '' );
+ editArea.getIESelection();
+
+ // retrive the number of matching characters
+ var start_index = Math.max( 0, editArea.textarea.selectionEnd - content.length );
+
+ line_string = editArea.textarea.value.substring( start_index, editArea.textarea.selectionEnd + 1);
+ limit = line_string.length -1;
+ nbMatch = 0;
+ for( i =0; i<limit ; i++ )
+ {
+ if( line_string.substring( limit - i - 1, limit ) == content.substring( 0, i + 1 ) )
+ nbMatch = i + 1;
+ }
+ // if characters match, we should include them in the selection that will be replaced
+ if( nbMatch > 0 )
+ parent.editAreaLoader.setSelectionRange(editArea.id, editArea.textarea.selectionStart - nbMatch , editArea.textarea.selectionEnd);
+
+ parent.editAreaLoader.setSelectedText(editArea.id, content );
+ range= parent.editAreaLoader.getSelectionRange(editArea.id);
+
+ if( cursor_forced_position != -1 )
+ new_pos = range["end"] - ( content.length-cursor_forced_position );
+ else
+ new_pos = range["end"];
+ parent.editAreaLoader.setSelectionRange(editArea.id, new_pos, new_pos);
+ this._hide();
+ }
+
+
+ /**
+ * Parse the AUTO_COMPLETION part of syntax definition files
+ */
+ ,_parseSyntaxAutoCompletionDatas: function(){
+ //foreach syntax loaded
+ for(var lang in parent.editAreaLoader.load_syntax)
+ {
+ if(!parent.editAreaLoader.syntax[lang]['autocompletion']) // init the regexp if not already initialized
+ {
+ parent.editAreaLoader.syntax[lang]['autocompletion']= {};
+ // the file has auto completion datas
+ if(parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION'])
+ {
+ // parse them
+ for(var i in parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION'])
+ {
+ datas = parent.editAreaLoader.load_syntax[lang]['AUTO_COMPLETION'][i];
+ tmp = {};
+ if(datas["CASE_SENSITIVE"]!="undefined" && datas["CASE_SENSITIVE"]==false)
+ tmp["modifiers"]="i";
+ else
+ tmp["modifiers"]="";
+ tmp["prefix_separator"]= datas["REGEXP"]["prefix_separator"];
+ tmp["match_prefix_separator"]= new RegExp( datas["REGEXP"]["prefix_separator"] +"$", tmp["modifiers"]);
+ tmp["match_word"]= new RegExp("(?:"+ datas["REGEXP"]["before_word"] +")("+ datas["REGEXP"]["possible_words_letters"] +")$", tmp["modifiers"]);
+ tmp["match_next_letter"]= new RegExp("^("+ datas["REGEXP"]["letter_after_word_must_match"] +")$", tmp["modifiers"]);
+ tmp["keywords"]= {};
+ //console.log( datas["KEYWORDS"] );
+ for( var prefix in datas["KEYWORDS"] )
+ {
+ tmp["keywords"][prefix]= {
+ prefix: prefix,
+ prefix_name: prefix,
+ prefix_reg: new RegExp("(?:"+ parent.editAreaLoader.get_escaped_regexp( prefix ) +")(?:"+ tmp["prefix_separator"] +")$", tmp["modifiers"] ),
+ datas: []
+ };
+ for( var j=0; j<datas["KEYWORDS"][prefix].length; j++ )
+ {
+ tmp["keywords"][prefix]['datas'][j]= {
+ is_typing: datas["KEYWORDS"][prefix][j][0],
+ // if replace with is empty, replace with the is_typing value
+ replace_with: datas["KEYWORDS"][prefix][j][1] ? datas["KEYWORDS"][prefix][j][1].replace('�', datas["KEYWORDS"][prefix][j][0] ) : '',
+ comment: datas["KEYWORDS"][prefix][j][2] ? datas["KEYWORDS"][prefix][j][2] : ''
+ };
+
+ // the replace with shouldn't be empty
+ if( tmp["keywords"][prefix]['datas'][j]['replace_with'].length == 0 )
+ tmp["keywords"][prefix]['datas'][j]['replace_with'] = tmp["keywords"][prefix]['datas'][j]['is_typing'];
+
+ // if the comment is empty, display the replace_with value
+ if( tmp["keywords"][prefix]['datas'][j]['comment'].length == 0 )
+ tmp["keywords"][prefix]['datas'][j]['comment'] = tmp["keywords"][prefix]['datas'][j]['replace_with'].replace(/{@}/g, '' );
+ }
+
+ }
+ tmp["max_text_length"]= datas["MAX_TEXT_LENGTH"];
+ parent.editAreaLoader.syntax[lang]['autocompletion'][i] = tmp;
+ }
+ }
+ }
+ }
+ }
+
+ ,_checkLetter: function(){
+ // check that syntax hasn't changed
+ if( this.curr_syntax_str != editArea.settings['syntax'] )
+ {
+ if( !parent.editAreaLoader.syntax[editArea.settings['syntax']]['autocompletion'] )
+ this._parseSyntaxAutoCompletionDatas();
+ this.curr_syntax= parent.editAreaLoader.syntax[editArea.settings['syntax']]['autocompletion'];
+ this.curr_syntax_str = editArea.settings['syntax'];
+ //console.log( this.curr_syntax );
+ }
+
+ if( editArea.is_editable )
+ {
+ time=new Date;
+ t1= time.getTime();
+ editArea.getIESelection();
+ this.selectIndex = -1;
+ start=editArea.textarea.selectionStart;
+ var str = editArea.textarea.value;
+ var results= [];
+
+
+ for(var i in this.curr_syntax)
+ {
+ var last_chars = str.substring(Math.max(0, start-this.curr_syntax[i]["max_text_length"]), start);
+ var matchNextletter = str.substring(start, start+1).match( this.curr_syntax[i]["match_next_letter"]);
+ // if not writting in the middle of a word or if forcing display
+ if( matchNextletter || this.forceDisplay )
+ {
+ // check if the last chars match a separator
+ var match_prefix_separator = last_chars.match(this.curr_syntax[i]["match_prefix_separator"]);
+
+ // check if it match a possible word
+ var match_word= last_chars.match(this.curr_syntax[i]["match_word"]);
+
+ //console.log( match_word );
+ if( match_word )
+ {
+ var begin_word= match_word[1];
+ var match_curr_word= new RegExp("^"+ parent.editAreaLoader.get_escaped_regexp( begin_word ), this.curr_syntax[i]["modifiers"]);
+ //console.log( match_curr_word );
+ for(var prefix in this.curr_syntax[i]["keywords"])
+ {
+ // parent.console.log( this.curr_syntax[i]["keywords"][prefix] );
+ for(var j=0; j<this.curr_syntax[i]["keywords"][prefix]['datas'].length; j++)
+ {
+ // parent.console.log( this.curr_syntax[i]["keywords"][prefix]['datas'][j]['is_typing'] );
+ // the key word match or force display
+ if( this.curr_syntax[i]["keywords"][prefix]['datas'][j]['is_typing'].match(match_curr_word) )
+ {
+ // parent.console.log('match');
+ hasMatch = false;
+ var before = last_chars.substr( 0, last_chars.length - begin_word.length );
+
+ // no prefix to match => it's valid
+ if( !match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length == 0 )
+ {
+ if( ! before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) )
+ hasMatch = true;
+ }
+ // we still need to check the prefix if there is one
+ else if( this.curr_syntax[i]["keywords"][prefix]['prefix'].length > 0 )
+ {
+ if( before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) )
+ hasMatch = true;
+ }
+
+ if( hasMatch )
+ results[results.length]= [ this.curr_syntax[i]["keywords"][prefix], this.curr_syntax[i]["keywords"][prefix]['datas'][j] ];
+ }
+ }
+ }
+ }
+ // it doesn't match any possible word but we want to display something
+ // we'll display to list of all available words
+ else if( this.forceDisplay || match_prefix_separator )
+ {
+ for(var prefix in this.curr_syntax[i]["keywords"])
+ {
+ for(var j=0; j<this.curr_syntax[i]["keywords"][prefix]['datas'].length; j++)
+ {
+ hasMatch = false;
+ // no prefix to match => it's valid
+ if( !match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length == 0 )
+ {
+ hasMatch = true;
+ }
+ // we still need to check the prefix if there is one
+ else if( match_prefix_separator && this.curr_syntax[i]["keywords"][prefix]['prefix'].length > 0 )
+ {
+ var before = last_chars; //.substr( 0, last_chars.length );
+ if( before.match( this.curr_syntax[i]["keywords"][prefix]['prefix_reg'] ) )
+ hasMatch = true;
+ }
+
+ if( hasMatch )
+ results[results.length]= [ this.curr_syntax[i]["keywords"][prefix], this.curr_syntax[i]["keywords"][prefix]['datas'][j] ];
+ }
+ }
+ }
+ }
+ }
+
+ // there is only one result, and we can select it automatically
+ if( results.length == 1 && this.autoSelectIfOneResult )
+ {
+ // console.log( results );
+ this._select( results[0][1]['replace_with'] );
+ }
+ else if( results.length == 0 )
+ {
+ this._hide();
+ }
+ else
+ {
+ // build the suggestion box content
+ var lines=[];
+ for(var i=0; i<results.length; i++)
+ {
+ var line= "<li><a href=\"#\" class=\"entry\" onmousedown=\"EditArea_autocompletion._select('"+ results[i][1]['replace_with'].replace(new RegExp('"', "g"), """) +"');return false;\">"+ results[i][1]['comment'];
+ if(results[i][0]['prefix_name'].length>0)
+ line+='<span class="prefix">'+ results[i][0]['prefix_name'] +'</span>';
+ line+='</a></li>';
+ lines[lines.length]=line;
+ }
+ // sort results
+ this.container.innerHTML = '<ul>'+ lines.sort().join('') +'</ul>';
+
+ var cursor = _$("cursor_pos");
+ this.container.style.top = ( cursor.cursor_top + editArea.lineHeight ) +"px";
+ this.container.style.left = ( cursor.cursor_left + 8 ) +"px";
+ this._show();
+ }
+
+ this.autoSelectIfOneResult = false;
+ time=new Date;
+ t2= time.getTime();
+
+ //parent.console.log( begin_word +"\n"+ (t2-t1) +"\n"+ html );
+ }
+ }
+};
+
+// Load as a plugin
+editArea.settings['plugins'][ editArea.settings['plugins'].length ] = 'autocompletion';
+editArea.add_plugin('autocompletion', EditArea_autocompletion);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.css
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.css b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.css
new file mode 100644
index 0000000..172b366
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.css
@@ -0,0 +1,530 @@
+body, html{
+ margin: 0;
+ padding: 0;
+ height: 100%;
+ border: none;
+ overflow: hidden;
+ background-color: #FFF;
+}
+
+body, html, table, form, textarea{
+ font: 12px monospace, sans-serif;
+}
+
+#editor{
+ border: solid #888 1px;
+ overflow: hidden;
+}
+
+#result{
+ z-index: 4;
+ overflow-x: auto;
+ overflow-y: scroll;
+ border-top: solid #888 1px;
+ border-bottom: solid #888 1px;
+ position: relative;
+ clear: both;
+}
+
+#result.empty{
+ overflow: hidden;
+}
+
+#container{
+ overflow: hidden;
+ border: solid blue 0;
+ position: relative;
+ z-index: 10;
+ padding: 0 5px 0 45px;
+ /*padding-right: 5px;*/
+}
+
+#textarea{
+ position: relative;
+ top: 0;
+ left: 0;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ z-index: 7;
+ border-width: 0;
+ background-color: transparent;
+ resize: none;
+}
+
+#textarea, #textarea:hover{
+ outline: none; /* safari outline fix */
+}
+
+#content_highlight{
+ white-space: pre;
+ margin: 0;
+ padding: 0;
+ position : absolute;
+ z-index: 4;
+ overflow: visible;
+}
+
+
+#selection_field, #selection_field_text{
+ margin: 0;
+ background-color: #E1F2F9;
+/* height: 1px; */
+ position: absolute;
+ z-index: 5;
+ top: -100px;
+ padding: 0;
+ white-space: pre;
+ overflow: hidden;
+}
+
+#selection_field.show_colors {
+ z-index: 3;
+ background-color:#EDF9FC;
+
+}
+
+#selection_field strong{
+ font-weight:normal;
+}
+
+#selection_field.show_colors *, #selection_field_text * {
+ visibility: hidden;
+}
+
+#selection_field_text{
+ background-color:transparent;
+}
+
+#selection_field_text strong{
+ font-weight:normal;
+ background-color:#3399FE;
+ color: #FFF;
+ visibility:visible;
+}
+
+#container.word_wrap #content_highlight,
+#container.word_wrap #selection_field,
+#container.word_wrap #selection_field_text,
+#container.word_wrap #test_font_size{
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+ width: 99%;
+}
+
+#line_number{
+ position: absolute;
+ overflow: hidden;
+ border-right: solid black 1px;
+ z-index:8;
+ width: 38px;
+ padding: 0 5px 0 0;
+ margin: 0 0 0 -45px;
+ text-align: right;
+ color: #AAAAAA;
+}
+
+#test_font_size{
+ padding: 0;
+ margin: 0;
+ visibility: hidden;
+ position: absolute;
+ white-space: pre;
+}
+
+pre{
+ margin: 0;
+ padding: 0;
+}
+
+.hidden{
+ opacity: 0.2;
+ filter:alpha(opacity=20);
+}
+
+#result .edit_area_cursor{
+ position: absolute;
+ z-index:6;
+ background-color: #FF6633;
+ top: -100px;
+ margin: 0;
+}
+
+#result .edit_area_selection_field .overline{
+ background-color: #996600;
+}
+
+
+/* area popup */
+.editarea_popup{
+ border: solid 1px #888888;
+ background-color: #ECE9D8;
+ width: 250px;
+ padding: 4px;
+ position: absolute;
+ visibility: hidden;
+ z-index: 15;
+ top: -500px;
+}
+
+.editarea_popup, .editarea_popup table{
+ font-family: sans-serif;
+ font-size: 10pt;
+}
+
+.editarea_popup img{
+ border: 0;
+}
+
+.editarea_popup .close_popup{
+ float: right;
+ line-height: 16px;
+ border: 0;
+ padding: 0;
+}
+
+.editarea_popup h1,.editarea_popup h2,.editarea_popup h3,.editarea_popup h4,.editarea_popup h5,.editarea_popup h6{
+ margin: 0;
+ padding: 0;
+}
+
+.editarea_popup .copyright{
+ text-align: right;
+}
+
+/* Area_search */
+div#area_search_replace{
+ /*width: 250px;*/
+}
+
+div#area_search_replace img{
+ border: 0;
+}
+
+div#area_search_replace div.button{
+ text-align: center;
+ line-height: 1.7em;
+}
+
+div#area_search_replace .button a{
+ cursor: pointer;
+ border: solid 1px #888888;
+ background-color: #DEDEDE;
+ text-decoration: none;
+ padding: 0 2px;
+ color: #000000;
+ white-space: nowrap;
+}
+
+div#area_search_replace a:hover{
+ /*border: solid 1px #888888;*/
+ background-color: #EDEDED;
+}
+
+div#area_search_replace #move_area_search_replace{
+ cursor: move;
+ border: solid 1px #888;
+}
+
+div#area_search_replace #close_area_search_replace{
+ text-align: right;
+ vertical-align: top;
+ white-space: nowrap;
+}
+
+div#area_search_replace #area_search_msg{
+ height: 18px;
+ overflow: hidden;
+ border-top: solid 1px #888;
+ margin-top: 3px;
+}
+
+/* area help */
+#edit_area_help{
+ width: 350px;
+}
+
+#edit_area_help div.close_popup{
+ float: right;
+}
+
+/* area_toolbar */
+.area_toolbar{
+ /*font: 11px sans-serif;*/
+ width: 100%;
+ /*height: 21px; */
+ margin: 0;
+ padding: 0;
+ background-color: #ECE9D8;
+ text-align: center;
+}
+
+.area_toolbar, .area_toolbar table{
+ font: 11px sans-serif;
+}
+
+.area_toolbar img{
+ border: 0;
+ vertical-align: middle;
+}
+
+.area_toolbar input{
+ margin: 0;
+ padding: 0;
+}
+
+.area_toolbar select{
+ font-family: 'MS Sans Serif',sans-serif,Verdana,Arial;
+ font-size: 7pt;
+ font-weight: normal;
+ margin: 2px 0 0 0 ;
+ padding: 0;
+ vertical-align: top;
+ background-color: #F0F0EE;
+}
+
+table.statusbar{
+ width: 100%;
+}
+
+.area_toolbar td.infos{
+ text-align: center;
+ width: 130px;
+ border-right: solid 1px #888;
+ border-width: 0 1px 0 0;
+ padding: 0;
+}
+
+.area_toolbar td.total{
+ text-align: right;
+ width: 50px;
+ padding: 0;
+}
+
+.area_toolbar td.resize{
+ text-align: right;
+}
+/*
+.area_toolbar span{
+ line-height: 1px;
+ padding: 0;
+ margin: 0;
+}*/
+
+.area_toolbar span#resize_area{
+ cursor: nw-resize;
+ visibility: hidden;
+}
+
+/* toolbar buttons */
+.editAreaButtonNormal, .editAreaButtonOver, .editAreaButtonDown, .editAreaSeparator, .editAreaSeparatorLine, .editAreaButtonDisabled, .editAreaButtonSelected {
+ border: 0; margin: 0; padding: 0; background: transparent;
+ margin-top: 0;
+ margin-left: 1px;
+ padding: 0;
+}
+
+.editAreaButtonNormal {
+ border: 1px solid #ECE9D8 !important;
+ cursor: pointer;
+}
+
+.editAreaButtonOver {
+ border: 1px solid #0A246A !important;
+ cursor: pointer;
+ background-color: #B6BDD2;
+}
+
+.editAreaButtonDown {
+ cursor: pointer;
+ border: 1px solid #0A246A !important;
+ background-color: #8592B5;
+}
+
+.editAreaButtonSelected {
+ border: 1px solid #C0C0BB !important;
+ cursor: pointer;
+ background-color: #F4F2E8;
+}
+
+.editAreaButtonDisabled {
+ filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
+ -moz-opacity:0.3;
+ opacity: 0.3;
+ border: 1px solid #F0F0EE !important;
+ cursor: pointer;
+}
+
+.editAreaSeparatorLine {
+ margin: 1px 2px;
+ background-color: #C0C0BB;
+ width: 2px;
+ height: 18px;
+}
+
+/* waiting screen */
+#processing{
+ display: none;
+ background-color:#ECE9D8;
+ border: solid #888 1px;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 100;
+ text-align: center;
+}
+
+#processing_text{
+ position:absolute;
+ left: 50%;
+ top: 50%;
+ width: 200px;
+ height: 20px;
+ margin-left: -100px;
+ margin-top: -10px;
+ text-align: center;
+}
+/* end */
+
+
+/**** tab browsing area ****/
+#tab_browsing_area{
+ display: none;
+ background-color: #CCC9A8;
+ border-top: 1px solid #888;
+ text-align: left;
+ margin: 0;
+}
+
+#tab_browsing_list {
+ padding: 0;
+ margin: 0;
+ list-style-type: none;
+ white-space: nowrap;
+}
+#tab_browsing_list li {
+ float: left;
+ margin: -1px;
+}
+#tab_browsing_list a {
+ position: relative;
+ display: block;
+ text-decoration: none;
+ float: left;
+ cursor: pointer;
+ line-height:14px;
+}
+
+#tab_browsing_list a span {
+ display: block;
+ color: #000;
+ background: #ECE9D8;
+ border: 1px solid #888;
+ border-width: 1px 1px 0;
+ text-align: center;
+ padding: 2px 2px 1px 4px;
+ position: relative; /*IE 6 hack */
+}
+
+#tab_browsing_list a b {
+ display: block;
+ border-bottom: 2px solid #617994;
+}
+
+#tab_browsing_list a .edited {
+ display: none;
+}
+
+#tab_browsing_list a.edited .edited {
+ display: inline;
+}
+
+#tab_browsing_list a img{
+ margin-left: 7px;
+}
+
+#tab_browsing_list a.edited img{
+ margin-left: 3px;
+}
+
+#tab_browsing_list a:hover span {
+ background: #F4F2E8;
+ border-color: #0A246A;
+}
+
+#tab_browsing_list .selected a span{
+ background: #046380;
+ color: #FFF;
+}
+
+
+#no_file_selected{
+ height: 100%;
+ width: 150%; /* Opera need more than 100% */
+ background: #CCC;
+ display: none;
+ z-index: 20;
+ position: absolute;
+}
+
+
+/*** Non-editable mode ***/
+.non_editable #editor
+{
+ border-width: 0 1px;
+}
+
+.non_editable .area_toolbar
+{
+ display: none;
+}
+
+/*** Auto completion ***/
+#auto_completion_area
+{
+ background: #FFF;
+ border: solid 1px #888;
+ position: absolute;
+ z-index: 15;
+ width: 280px;
+ height: 180px;
+ overflow: auto;
+ display:none;
+}
+
+#auto_completion_area a, #auto_completion_area a:visited
+{
+ display: block;
+ padding: 0 2px 1px;
+ color: #000;
+ text-decoration:none;
+}
+
+#auto_completion_area a:hover, #auto_completion_area a:focus, #auto_completion_area a.focus
+{
+ background: #D6E1FE;
+ text-decoration:none;
+}
+
+#auto_completion_area ul
+{
+ margin: 0;
+ padding: 0;
+ list-style: none inside;
+}
+#auto_completion_area li
+{
+ padding: 0;
+}
+#auto_completion_area .prefix
+{
+ font-style: italic;
+ padding: 0 3px;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.js
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.js b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.js
new file mode 100644
index 0000000..35ea553
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area.js
@@ -0,0 +1,529 @@
+/******
+ *
+ * EditArea
+ * Developped by Christophe Dolivet
+ * Released under LGPL, Apache and BSD licenses (use the one you want)
+ *
+******/
+
+ function EditArea(){
+ var t=this;
+ t.error= false; // to know if load is interrrupt
+
+ t.inlinePopup= [{popup_id: "area_search_replace", icon_id: "search"},
+ {popup_id: "edit_area_help", icon_id: "help"}];
+ t.plugins= {};
+
+ t.line_number=0;
+
+ parent.editAreaLoader.set_browser_infos(t); // navigator identification
+ // fix IE8 detection as we run in IE7 emulate mode through X-UA <meta> tag
+ if( t.isIE == 8 )
+ t.isIE = 7;
+ if( t.isIE == 9 )
+ t.isIE = false;
+
+ t.last_selection={};
+ t.last_text_to_highlight="";
+ t.last_hightlighted_text= "";
+ t.syntax_list= [];
+ t.allready_used_syntax= {};
+ t.check_line_selection_timer= 50; // the timer delay for modification and/or selection change detection
+
+ t.textareaFocused= false;
+ t.highlight_selection_line= null;
+ t.previous= [];
+ t.next= [];
+ t.last_undo="";
+ t.files= {};
+ t.filesIdAssoc= {};
+ t.curr_file= '';
+ //t.loaded= false;
+ t.assocBracket={};
+ t.revertAssocBracket= {};
+ // bracket selection init
+ t.assocBracket["("]=")";
+ t.assocBracket["{"]="}";
+ t.assocBracket["["]="]";
+ for(var index in t.assocBracket){
+ t.revertAssocBracket[t.assocBracket[index]]=index;
+ }
+ t.is_editable= true;
+
+
+ /*t.textarea="";
+
+ t.state="declare";
+ t.code = []; // store highlight syntax for languagues*/
+ // font datas
+ t.lineHeight= 16;
+ /*t.default_font_family= "monospace";
+ t.default_font_size= 10;*/
+ t.tab_nb_char= 8; //nb of white spaces corresponding to a tabulation
+ if(t.isOpera)
+ t.tab_nb_char= 6;
+
+ t.is_tabbing= false;
+
+ t.fullscreen= {'isFull': false};
+
+ t.isResizing=false; // resize var
+
+ // init with settings and ID (area_id is a global var defined by editAreaLoader on iframe creation
+ t.id= area_id;
+ t.settings= editAreas[t.id]["settings"];
+
+ if((""+t.settings['replace_tab_by_spaces']).match(/^[0-9]+$/))
+ {
+ t.tab_nb_char= t.settings['replace_tab_by_spaces'];
+ t.tabulation="";
+ for(var i=0; i<t.tab_nb_char; i++)
+ t.tabulation+=" ";
+ }else{
+ t.tabulation="\t";
+ }
+
+ // retrieve the init parameter for syntax
+ if(t.settings["syntax_selection_allow"] && t.settings["syntax_selection_allow"].length>0)
+ t.syntax_list= t.settings["syntax_selection_allow"].replace(/ /g,"").split(",");
+
+ if(t.settings['syntax'])
+ t.allready_used_syntax[t.settings['syntax']]=true;
+
+
+ };
+ EditArea.prototype.init= function(){
+ var t=this, a, s=t.settings;
+ t.textarea = _$("textarea");
+ t.container = _$("container");
+ t.result = _$("result");
+ t.content_highlight = _$("content_highlight");
+ t.selection_field = _$("selection_field");
+ t.selection_field_text= _$("selection_field_text");
+ t.processing_screen = _$("processing");
+ t.editor_area = _$("editor");
+ t.tab_browsing_area = _$("tab_browsing_area");
+ t.test_font_size = _$("test_font_size");
+ a = t.textarea;
+
+ if(!s['is_editable'])
+ t.set_editable(false);
+
+ t.set_show_line_colors( s['show_line_colors'] );
+
+ if(syntax_selec= _$("syntax_selection"))
+ {
+ // set up syntax selection lsit in the toolbar
+ for(var i=0; i<t.syntax_list.length; i++) {
+ var syntax= t.syntax_list[i];
+ var option= document.createElement("option");
+ option.value= syntax;
+ if(syntax==s['syntax'])
+ option.selected= "selected";
+ dispSyntax = parent.editAreaLoader.syntax_display_name[ syntax ];
+ option.innerHTML= typeof( dispSyntax ) == 'undefined' ? syntax.substring( 0, 1 ).toUpperCase() + syntax.substring( 1 ) : dispSyntax;//t.get_translation("syntax_" + syntax, "word");
+ syntax_selec.appendChild(option);
+ }
+ }
+
+ // add plugins buttons in the toolbar
+ spans= parent.getChildren(_$("toolbar_1"), "span", "", "", "all", -1);
+
+ for(var i=0; i<spans.length; i++){
+
+ id=spans[i].id.replace(/tmp_tool_(.*)/, "$1");
+ if(id!= spans[i].id){
+ for(var j in t.plugins){
+ if(typeof(t.plugins[j].get_control_html)=="function" ){
+ html=t.plugins[j].get_control_html(id);
+ if(html!=false){
+ html= t.get_translation(html, "template");
+ var new_span= document.createElement("span");
+ new_span.innerHTML= html;
+ var father= spans[i].parentNode;
+ spans[i].parentNode.replaceChild(new_span, spans[i]);
+ break; // exit the for loop
+ }
+ }
+ }
+ }
+ }
+
+ // init datas
+ //a.value = 'a';//editAreas[t.id]["textarea"].value;
+
+ if(s["debug"])
+ {
+ t.debug=parent.document.getElementById("edit_area_debug_"+t.id);
+ }
+ // init size
+ //this.update_size();
+
+ if(_$("redo") != null)
+ t.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true);
+
+ // insert css rules for highlight mode
+ if(typeof(parent.editAreaLoader.syntax[s["syntax"]])!="undefined"){
+ for(var i in parent.editAreaLoader.syntax){
+ if (typeof(parent.editAreaLoader.syntax[i]["styles"]) != "undefined"){
+ t.add_style(parent.editAreaLoader.syntax[i]["styles"]);
+ }
+ }
+ }
+
+ // init key events
+ if(t.isOpera)
+ _$("editor").onkeypress = keyDown;
+ else
+ _$("editor").onkeydown = keyDown;
+
+ for(var i=0; i<t.inlinePopup.length; i++){
+ if(t.isOpera)
+ _$(t.inlinePopup[i]["popup_id"]).onkeypress = keyDown;
+ else
+ _$(t.inlinePopup[i]["popup_id"]).onkeydown = keyDown;
+ }
+
+ if(s["allow_resize"]=="both" || s["allow_resize"]=="x" || s["allow_resize"]=="y")
+ t.allow_resize(true);
+
+ parent.editAreaLoader.toggle(t.id, "on");
+ //a.focus();
+ // line selection init
+ t.change_smooth_selection_mode(editArea.smooth_selection);
+ // highlight
+ t.execCommand("change_highlight", s["start_highlight"]);
+
+ // get font size datas
+ t.set_font(editArea.settings["font_family"], editArea.settings["font_size"]);
+
+ // set unselectable text
+ children= parent.getChildren(document.body, "", "selec", "none", "all", -1);
+ for(var i=0; i<children.length; i++){
+ if(t.isIE)
+ children[i].unselectable = true; // IE
+ else
+ children[i].onmousedown= function(){return false};
+ /* children[i].style.MozUserSelect = "none"; // Moz
+ children[i].style.KhtmlUserSelect = "none"; // Konqueror/Safari*/
+ }
+
+ a.spellcheck= s["gecko_spellcheck"];
+
+ /** Browser specific style fixes **/
+
+ // fix rendering bug for highlighted lines beginning with no tabs
+ if( t.isFirefox >= '3' ) {
+ t.content_highlight.style.paddingLeft= "1px";
+ t.selection_field.style.paddingLeft= "1px";
+ t.selection_field_text.style.paddingLeft= "1px";
+ }
+
+ if(t.isIE && t.isIE < 8 ){
+ a.style.marginTop= "-1px";
+ }
+ /*
+ if(t.isOpera){
+ t.editor_area.style.position= "absolute";
+ }*/
+
+ if( t.isSafari && t.isSafari < 4.1 ){
+ t.editor_area.style.position = "absolute";
+ a.style.marginLeft ="-3px";
+ if( t.isSafari < 3.2 ) // Safari 3.0 (3.1?)
+ a.style.marginTop ="1px";
+ }
+
+ // si le textarea n'est pas grand, un click sous le textarea doit provoquer un focus sur le textarea
+ parent.editAreaLoader.add_event(t.result, "click", function(e){ if((e.target || e.srcElement)==editArea.result) { editArea.area_select(editArea.textarea.value.length, 0);} });
+
+ if(s['is_multi_files']!=false)
+ t.open_file({'id': t.curr_file, 'text': ''});
+
+ t.set_word_wrap( s['word_wrap'] );
+
+ setTimeout("editArea.focus();editArea.manage_size();editArea.execCommand('EA_load');", 10);
+ //start checkup routine
+ t.check_undo();
+ t.check_line_selection(true);
+ t.scroll_to_view();
+
+ for(var i in t.plugins){
+ if(typeof(t.plugins[i].onload)=="function")
+ t.plugins[i].onload();
+ }
+ if(s['fullscreen']==true)
+ t.toggle_full_screen(true);
+
+ parent.editAreaLoader.add_event(window, "resize", editArea.update_size);
+ parent.editAreaLoader.add_event(parent.window, "resize", editArea.update_size);
+ parent.editAreaLoader.add_event(top.window, "resize", editArea.update_size);
+ parent.editAreaLoader.add_event(window, "unload", function(){
+ // in case where editAreaLoader have been already cleaned
+ if( parent.editAreaLoader )
+ {
+ parent.editAreaLoader.remove_event(parent.window, "resize", editArea.update_size);
+ parent.editAreaLoader.remove_event(top.window, "resize", editArea.update_size);
+ }
+ if(editAreas[editArea.id] && editAreas[editArea.id]["displayed"]){
+ editArea.execCommand("EA_unload");
+ }
+ });
+
+
+ /*date= new Date();
+ alert(date.getTime()- parent.editAreaLoader.start_time);*/
+ };
+
+
+
+ //called by the toggle_on
+ EditArea.prototype.update_size= function(){
+ var d=document,pd=parent.document,height,width,popup,maxLeft,maxTop;
+
+ if( typeof editAreas != 'undefined' && editAreas[editArea.id] && editAreas[editArea.id]["displayed"]==true){
+ if(editArea.fullscreen['isFull']){
+ pd.getElementById("frame_"+editArea.id).style.width = pd.getElementsByTagName("html")[0].clientWidth + "px";
+ pd.getElementById("frame_"+editArea.id).style.height = pd.getElementsByTagName("html")[0].clientHeight + "px";
+ }
+
+ if(editArea.tab_browsing_area.style.display=='block' && ( !editArea.isIE || editArea.isIE >= 8 ) )
+ {
+ editArea.tab_browsing_area.style.height = "0px";
+ editArea.tab_browsing_area.style.height = (editArea.result.offsetTop - editArea.tab_browsing_area.offsetTop -1)+"px";
+ }
+
+ height = d.body.offsetHeight - editArea.get_all_toolbar_height() - 4;
+ editArea.result.style.height = height +"px";
+
+ width = d.body.offsetWidth -2;
+ editArea.result.style.width = width+"px";
+ //alert("result h: "+ height+" w: "+width+"\ntoolbar h: "+this.get_all_toolbar_height()+"\nbody_h: "+document.body.offsetHeight);
+
+ // check that the popups don't get out of the screen
+ for( i=0; i < editArea.inlinePopup.length; i++ )
+ {
+ popup = _$(editArea.inlinePopup[i]["popup_id"]);
+ maxLeft = d.body.offsetWidth - popup.offsetWidth;
+ maxTop = d.body.offsetHeight - popup.offsetHeight;
+ if( popup.offsetTop > maxTop )
+ popup.style.top = maxTop+"px";
+ if( popup.offsetLeft > maxLeft )
+ popup.style.left = maxLeft+"px";
+ }
+
+ editArea.manage_size( true );
+ editArea.fixLinesHeight( editArea.textarea.value, 0,-1);
+ }
+ };
+
+
+ EditArea.prototype.manage_size= function(onlyOneTime){
+ if(!editAreas[this.id])
+ return false;
+
+ if(editAreas[this.id]["displayed"]==true && this.textareaFocused)
+ {
+ var area_height,resized= false;
+
+ //1) Manage display width
+ //1.1) Calc the new width to use for display
+ if( !this.settings['word_wrap'] )
+ {
+ var area_width= this.textarea.scrollWidth;
+ area_height= this.textarea.scrollHeight;
+ // bug on old opera versions
+ if(this.isOpera && this.isOpera < 9.6 ){
+ area_width=10000;
+ }
+ //1.2) the width is not the same, we must resize elements
+ if(this.textarea.previous_scrollWidth!=area_width)
+ {
+ this.container.style.width= area_width+"px";
+ this.textarea.style.width= area_width+"px";
+ this.content_highlight.style.width= area_width+"px";
+ this.textarea.previous_scrollWidth=area_width;
+ resized=true;
+ }
+ }
+ // manage wrap width
+ if( this.settings['word_wrap'] )
+ {
+ newW=this.textarea.offsetWidth;
+ if( this.isFirefox || this.isIE )
+ newW-=2;
+ if( this.isSafari )
+ newW-=6;
+ this.content_highlight.style.width=this.selection_field_text.style.width=this.selection_field.style.width=this.test_font_size.style.width=newW+"px";
+ }
+
+ //2) Manage display height
+ //2.1) Calc the new height to use for display
+ if( this.isOpera || this.isFirefox || this.isSafari ) {
+ area_height= this.getLinePosTop( this.last_selection["nb_line"] + 1 );
+ } else {
+ area_height = this.textarea.scrollHeight;
+ }
+ //2.2) the width is not the same, we must resize elements
+ if(this.textarea.previous_scrollHeight!=area_height)
+ {
+ this.container.style.height= (area_height+2)+"px";
+ this.textarea.style.height= area_height+"px";
+ this.content_highlight.style.height= area_height+"px";
+ this.textarea.previous_scrollHeight= area_height;
+ resized=true;
+ }
+
+ //3) if there is new lines, we add new line numbers in the line numeration area
+ if(this.last_selection["nb_line"] >= this.line_number)
+ {
+ var newLines= '', destDiv=_$("line_number"), start=this.line_number, end=this.last_selection["nb_line"]+100;
+ for( i = start+1; i < end; i++ )
+ {
+ newLines+='<div id="line_'+ i +'">'+i+"</div>";
+ this.line_number++;
+ }
+ destDiv.innerHTML= destDiv.innerHTML + newLines;
+ if(this.settings['word_wrap']){
+ this.fixLinesHeight( this.textarea.value, start, -1 );
+ }
+ }
+
+ //4) be sure the text is well displayed
+ this.textarea.scrollTop="0px";
+ this.textarea.scrollLeft="0px";
+ if(resized==true){
+ this.scroll_to_view();
+ }
+ }
+
+ if(!onlyOneTime)
+ setTimeout("editArea.manage_size();", 100);
+ };
+
+ EditArea.prototype.execCommand= function(cmd, param){
+
+ for(var i in this.plugins){
+ if(typeof(this.plugins[i].execCommand)=="function"){
+ if(!this.plugins[i].execCommand(cmd, param))
+ return;
+ }
+ }
+ switch(cmd){
+ case "save":
+ if(this.settings["save_callback"].length>0)
+ eval("parent."+this.settings["save_callback"]+"('"+ this.id +"', editArea.textarea.value);");
+ break;
+ case "load":
+ if(this.settings["load_callback"].length>0)
+ eval("parent."+this.settings["load_callback"]+"('"+ this.id +"');");
+ break;
+ case "onchange":
+ if(this.settings["change_callback"].length>0)
+ eval("parent."+this.settings["change_callback"]+"('"+ this.id +"');");
+ break;
+ case "EA_load":
+ if(this.settings["EA_load_callback"].length>0)
+ eval("parent."+this.settings["EA_load_callback"]+"('"+ this.id +"');");
+ break;
+ case "EA_unload":
+ if(this.settings["EA_unload_callback"].length>0)
+ eval("parent."+this.settings["EA_unload_callback"]+"('"+ this.id +"');");
+ break;
+ case "toggle_on":
+ if(this.settings["EA_toggle_on_callback"].length>0)
+ eval("parent."+this.settings["EA_toggle_on_callback"]+"('"+ this.id +"');");
+ break;
+ case "toggle_off":
+ if(this.settings["EA_toggle_off_callback"].length>0)
+ eval("parent."+this.settings["EA_toggle_off_callback"]+"('"+ this.id +"');");
+ break;
+ case "re_sync":
+ if(!this.do_highlight)
+ break;
+ case "file_switch_on":
+ if(this.settings["EA_file_switch_on_callback"].length>0)
+ eval("parent."+this.settings["EA_file_switch_on_callback"]+"(param);");
+ break;
+ case "file_switch_off":
+ if(this.settings["EA_file_switch_off_callback"].length>0)
+ eval("parent."+this.settings["EA_file_switch_off_callback"]+"(param);");
+ break;
+ case "file_close":
+ if(this.settings["EA_file_close_callback"].length>0)
+ return eval("parent."+this.settings["EA_file_close_callback"]+"(param);");
+ break;
+
+ default:
+ if(typeof(eval("editArea."+cmd))=="function")
+ {
+ if(this.settings["debug"])
+ eval("editArea."+ cmd +"(param);");
+ else
+ try{eval("editArea."+ cmd +"(param);");}catch(e){};
+ }
+ }
+ };
+
+ EditArea.prototype.get_translation= function(word, mode){
+ if(mode=="template")
+ return parent.editAreaLoader.translate(word, this.settings["language"], mode);
+ else
+ return parent.editAreaLoader.get_word_translation(word, this.settings["language"]);
+ };
+
+ EditArea.prototype.add_plugin= function(plug_name, plug_obj){
+ for(var i=0; i<this.settings["plugins"].length; i++){
+ if(this.settings["plugins"][i]==plug_name){
+ this.plugins[plug_name]=plug_obj;
+ plug_obj.baseURL=parent.editAreaLoader.baseURL + "plugins/" + plug_name + "/";
+ if( typeof(plug_obj.init)=="function" )
+ plug_obj.init();
+ }
+ }
+ };
+
+ EditArea.prototype.load_css= function(url){
+ try{
+ link = document.createElement("link");
+ link.type = "text/css";
+ link.rel= "stylesheet";
+ link.media="all";
+ link.href = url;
+ head = document.getElementsByTagName("head");
+ head[0].appendChild(link);
+ }catch(e){
+ document.write("<link href='"+ url +"' rel='stylesheet' type='text/css' />");
+ }
+ };
+
+ EditArea.prototype.load_script= function(url){
+ try{
+ script = document.createElement("script");
+ script.type = "text/javascript";
+ script.src = url;
+ script.charset= "UTF-8";
+ head = document.getElementsByTagName("head");
+ head[0].appendChild(script);
+ }catch(e){
+ document.write("<script type='text/javascript' src='" + url + "' charset=\"UTF-8\"><"+"/script>");
+ }
+ };
+
+ // add plugin translation to language translation array
+ EditArea.prototype.add_lang= function(language, values){
+ if(!parent.editAreaLoader.lang[language])
+ parent.editAreaLoader.lang[language]={};
+ for(var i in values)
+ parent.editAreaLoader.lang[language][i]= values[i];
+ };
+
+ // short cut for document.getElementById()
+ function _$(id){return document.getElementById( id );};
+
+ var editArea = new EditArea();
+ parent.editAreaLoader.add_event(window, "load", init);
+
+ function init(){
+ setTimeout("editArea.init(); ", 10);
+ };
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_compressor.php
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_compressor.php b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_compressor.php
new file mode 100644
index 0000000..518e1b7
--- /dev/null
+++ b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_compressor.php
@@ -0,0 +1,428 @@
+<?php
+ /******
+ *
+ * EditArea PHP compressor
+ * Developped by Christophe Dolivet
+ * Released under LGPL, Apache and BSD licenses
+ * v1.1.3 (2007/01/18)
+ *
+ ******/
+
+ // CONFIG
+ $param['cache_duration']= 3600 * 24 * 10; // 10 days util client cache expires
+ $param['compress'] = true; // enable the code compression, should be activated but it can be usefull to desactivate it for easier error retrieving (true or false)
+ $param['debug'] = false; // Enable this option if you need debuging info
+ $param['use_disk_cache']= true; // If you enable this option gzip files will be cached on disk.
+ $param['use_gzip']= true; // Enable gzip compression
+ // END CONFIG
+
+ $compressor= new Compressor($param);
+
+ class Compressor{
+
+
+ function compressor($param)
+ {
+ $this->__construct($param);
+ }
+
+ function __construct($param)
+ {
+ $this->start_time= $this->get_microtime();
+ $this->file_loaded_size=0;
+ $this->param= $param;
+ $this->script_list="";
+ $this->path= dirname(__FILE__)."/";
+ if(isset($_GET['plugins'])){
+ $this->load_all_plugins= true;
+ $this->full_cache_file= $this->path."edit_area_full_with_plugins.js";
+ $this->gzip_cache_file= $this->path."edit_area_full_with_plugins.gz";
+ }else{
+ $this->load_all_plugins= false;
+ $this->full_cache_file= $this->path."edit_area_full.js";
+ $this->gzip_cache_file= $this->path."edit_area_full.gz";
+ }
+
+ $this->check_gzip_use();
+ $this->send_headers();
+ $this->check_cache();
+ $this->load_files();
+ $this->send_datas();
+ }
+
+ function send_headers()
+ {
+ header("Content-type: text/javascript; charset: UTF-8");
+ header("Vary: Accept-Encoding"); // Handle proxies
+ header(sprintf("Expires: %s GMT", gmdate("D, d M Y H:i:s", time() + $this->param['cache_duration'])) );
+ if($this->use_gzip)
+ header("Content-Encoding: ".$this->gzip_enc_header);
+ }
+
+ function check_gzip_use()
+ {
+ $encodings = array();
+ $desactivate_gzip=false;
+
+ if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
+ $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
+
+ // desactivate gzip for IE version < 7
+ if(preg_match("/(?:msie )([0-9.]+)/i", $_SERVER['HTTP_USER_AGENT'], $ie))
+ {
+ if($ie[1]<7)
+ $desactivate_gzip=true;
+ }
+
+ // Check for gzip header or northon internet securities
+ if (!$desactivate_gzip && $this->param['use_gzip'] && (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
+ $this->gzip_enc_header= in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
+ $this->use_gzip=true;
+ $this->cache_file=$this->gzip_cache_file;
+ }else{
+ $this->use_gzip=false;
+ $this->cache_file=$this->full_cache_file;
+ }
+ }
+
+ function check_cache()
+ {
+ // Only gzip the contents if clients and server support it
+ if (file_exists($this->cache_file)) {
+ // check if cache file must be updated
+ $cache_date=0;
+ if ($dir = opendir($this->path)) {
+ while (($file = readdir($dir)) !== false) {
+ if(is_file($this->path.$file) && $file!="." && $file!="..")
+ $cache_date= max($cache_date, filemtime($this->path.$file));
+ }
+ closedir($dir);
+ }
+ if($this->load_all_plugins){
+ $plug_path= $this->path."plugins/";
+ if (($dir = @opendir($plug_path)) !== false)
+ {
+ while (($file = readdir($dir)) !== false)
+ {
+ if ($file !== "." && $file !== "..")
+ {
+ if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
+ $cache_date= max($cache_date, filemtime("plugins/".$file."/".$file.".js"));
+ }
+ }
+ closedir($dir);
+ }
+ }
+
+ if(filemtime($this->cache_file) >= $cache_date){
+ // if cache file is up to date
+ $last_modified = gmdate("D, d M Y H:i:s",filemtime($this->cache_file))." GMT";
+ if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && strcasecmp($_SERVER["HTTP_IF_MODIFIED_SINCE"], $last_modified) === 0)
+ {
+ header("HTTP/1.1 304 Not Modified");
+ header("Last-modified: ".$last_modified);
+ header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
+ header("Pragma:"); // Tells HTTP 1.0 clients to cache
+ }
+ else
+ {
+ header("Last-modified: ".$last_modified);
+ header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
+ header("Pragma:"); // Tells HTTP 1.0 clients to cache
+ header('Content-Length: '.filesize($this->cache_file));
+ echo file_get_contents($this->cache_file);
+ }
+ die;
+ }
+ }
+ return false;
+ }
+
+ function load_files()
+ {
+ $loader= $this->get_content("edit_area_loader.js")."\n";
+
+ // get the list of other files to load
+ $loader= preg_replace("/(t\.scripts_to_load=\s*)\[([^\]]*)\];/e"
+ , "\$this->replace_scripts('script_list', '\\1', '\\2')"
+ , $loader);
+
+ $loader= preg_replace("/(t\.sub_scripts_to_load=\s*)\[([^\]]*)\];/e"
+ , "\$this->replace_scripts('sub_script_list', '\\1', '\\2')"
+ , $loader);
+
+ // replace languages names
+ $reg_path= $this->path."reg_syntax/";
+ $a_displayName = array();
+ if (($dir = @opendir($reg_path)) !== false)
+ {
+ while (($file = readdir($dir)) !== false)
+ {
+ if( $file !== "." && $file !== ".." && ( $pos = strpos( $file, '.js' ) ) !== false )
+ {
+ $jsContent = $this->file_get_contents( $reg_path.$file );
+ if( preg_match( '@(\'|")DISPLAY_NAME\1\s*:\s*(\'|")(.*)\2@', $jsContent, $match ) )
+ {
+ $a_displayName[] = "'". substr( $file, 0, $pos ) ."':'". htmlspecialchars( $match[3], ENT_QUOTES ) ."'";
+ }
+ }
+ }
+ closedir($dir);
+ }
+ $loader = str_replace( '/*syntax_display_name_AUTO-FILL-BY-COMPRESSOR*/', implode( ",", $a_displayName ), $loader );
+
+ $this->datas= $loader;
+ $this->compress_javascript($this->datas);
+
+ // load other scripts needed for the loader
+ preg_match_all('/"([^"]*)"/', $this->script_list, $match);
+ foreach($match[1] as $key => $value)
+ {
+ $content= $this->get_content(preg_replace("/\\|\//i", "", $value).".js");
+ $this->compress_javascript($content);
+ $this->datas.= $content."\n";
+ }
+ //$this->datas);
+ //$this->datas= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $this->datas);
+
+ // improved compression step 1/2
+ $this->datas= preg_replace(array("/(\b)EditAreaLoader(\b)/", "/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/"), array("EAL", "eAL", "eAs"), $this->datas);
+ //$this->datas= str_replace(array("EditAreaLoader", "editAreaLoader", "editAreas"), array("EAL", "eAL", "eAs"), $this->datas);
+ $this->datas.= "var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;";
+
+ // load sub scripts
+ $sub_scripts="";
+ $sub_scripts_list= array();
+ preg_match_all('/"([^"]*)"/', $this->sub_script_list, $match);
+ foreach($match[1] as $value){
+ $sub_scripts_list[]= preg_replace("/\\|\//i", "", $value).".js";
+ }
+
+ if($this->load_all_plugins){
+ // load plugins scripts
+ $plug_path= $this->path."plugins/";
+ if (($dir = @opendir($plug_path)) !== false)
+ {
+ while (($file = readdir($dir)) !== false)
+ {
+ if ($file !== "." && $file !== "..")
+ {
+ if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
+ $sub_scripts_list[]= "plugins/".$file."/".$file.".js";
+ }
+ }
+ closedir($dir);
+ }
+ }
+
+ foreach($sub_scripts_list as $value){
+ $sub_scripts.= $this->get_javascript_content($value);
+ }
+ // improved compression step 2/2
+ $sub_scripts= preg_replace(array("/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/", "/(\b)editArea(\b)/", "/(\b)EditArea(\b)/"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
+ // $sub_scripts= str_replace(array("editAreaLoader", "editAreas", "editArea", "EditArea"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
+ $sub_scripts.= "var editArea= eA;EditArea=EA;";
+
+
+ // add the scripts
+ // $this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\";\n", $sub_scripts);
+
+
+ // add the script and use a last compression
+ if( $this->param['compress'] )
+ {
+ $last_comp = array( 'Á' => 'this',
+ 'Â' => 'textarea',
+ 'Ã' => 'function',
+ 'Ä' => 'prototype',
+ 'Å' => 'settings',
+ 'Æ' => 'length',
+ 'Ç' => 'style',
+ 'È' => 'parent',
+ 'É' => 'last_selection',
+ 'Ê' => 'value',
+ 'Ë' => 'true',
+ 'Ì' => 'false'
+ /*,
+ 'Î' => '"',
+ 'Ï' => "\n",
+ 'À' => "\r"*/);
+ }
+ else
+ {
+ $last_comp = array();
+ }
+
+ $js_replace= '';
+ foreach( $last_comp as $key => $val )
+ $js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')";
+
+ $this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\"%s;\n",
+ str_replace( array_values($last_comp), array_keys($last_comp), $sub_scripts ),
+ $js_replace);
+
+ if($this->load_all_plugins)
+ $this->datas.="editAreaLoader.all_plugins_loaded=true;\n";
+
+
+ // load the template
+ $this->datas.= sprintf("editAreaLoader.template= \"%s\";\n", $this->get_html_content("template.html"));
+ // load the css
+ $this->datas.= sprintf("editAreaLoader.iframe_css= \"<style>%s</style>\";\n", $this->get_css_content("edit_area.css"));
+
+ // $this->datas= "function editArea(){};editArea.prototype.loader= function(){alert('bouhbouh');} var a= new editArea();a.loader();";
+
+ }
+
+ function send_datas()
+ {
+ if($this->param['debug']){
+ $header=sprintf("/* USE PHP COMPRESSION\n");
+ $header.=sprintf("javascript size: based files: %s => PHP COMPRESSION => %s ", $this->file_loaded_size, strlen($this->datas));
+ if($this->use_gzip){
+ $gzip_datas= gzencode($this->datas, 9, FORCE_GZIP);
+ $header.=sprintf("=> GZIP COMPRESSION => %s", strlen($gzip_datas));
+ $ratio = round(100 - strlen($gzip_datas) / $this->file_loaded_size * 100.0);
+ }else{
+ $ratio = round(100 - strlen($this->datas) / $this->file_loaded_size * 100.0);
+ }
+ $header.=sprintf(", reduced by %s%%\n", $ratio);
+ $header.=sprintf("compression time: %s\n", $this->get_microtime()-$this->start_time);
+ $header.=sprintf("%s\n", implode("\n", $this->infos));
+ $header.=sprintf("*/\n");
+ $this->datas= $header.$this->datas;
+ }
+ $mtime= time(); // ensure that the 2 disk files will have the same update time
+ // generate gzip file and cahce it if using disk cache
+ if($this->use_gzip){
+ $this->gzip_datas= gzencode($this->datas, 9, FORCE_GZIP);
+ if($this->param['use_disk_cache'])
+ $this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime);
+ }
+
+ // generate full js file and cache it if using disk cache
+ if($this->param['use_disk_cache'])
+ $this->file_put_contents($this->full_cache_file, $this->datas, $mtime);
+
+ // generate output
+ if($this->use_gzip)
+ echo $this->gzip_datas;
+ else
+ echo $this->datas;
+
+// die;
+ }
+
+
+ function get_content($end_uri)
+ {
+ $end_uri=preg_replace("/\.\./", "", $end_uri); // Remove any .. (security)
+ $file= $this->path.$end_uri;
+ if(file_exists($file)){
+ $this->infos[]=sprintf("'%s' loaded", $end_uri);
+ /*$fd = fopen($file, 'rb');
+ $content = fread($fd, filesize($file));
+ fclose($fd);
+ return $content;*/
+ return $this->file_get_contents($file);
+ }else{
+ $this->infos[]=sprintf("'%s' not loaded", $end_uri);
+ return "";
+ }
+ }
+
+ function get_javascript_content($end_uri)
+ {
+ $val=$this->get_content($end_uri);
+
+ $this->compress_javascript($val);
+ $this->prepare_string_for_quotes($val);
+ return $val;
+ }
+
+ function compress_javascript(&$code)
+ {
+ if($this->param['compress'])
+ {
+ // remove all comments
+ // (\"(?:[^\"\\]*(?:\\\\)*(?:\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\]*(?:\\\\)*(?:\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))
+ $code= preg_replace("/(\"(?:[^\"\\\\]*(?:\\\\\\\\)*(?:\\\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\\\]*(?:\\\\\\\\)*(?:\\\\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
+ // remove line return, empty line and tabulation
+ $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
+ // add line break before "else" otherwise navigators can't manage to parse the file
+ $code= preg_replace('/(\b(else)\b)/', "\n$1", $code);
+ // remove unnecessary spaces
+ $code= preg_replace('/( |\t|\r)*(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)*/', "$2", $code);
+ }
+ }
+
+ function get_css_content($end_uri){
+ $code=$this->get_content($end_uri);
+ // remove comments
+ $code= preg_replace("/(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "", $code);
+ // remove spaces
+ $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $code);
+ // remove spaces
+ $code= preg_replace('/( |\t|\r)?(\:|,|\{|\})( |\t|\r)+/', "$2", $code);
+
+ $this->prepare_string_for_quotes($code);
+ return $code;
+ }
+
+ function get_html_content($end_uri){
+ $code=$this->get_content($end_uri);
+ //$code= preg_replace('/(\"(?:\\\"|[^\"])*(?:\"|$))|' . "(\'(?:\\\'|[^\'])*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
+ $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
+ $this->prepare_string_for_quotes($code);
+ return $code;
+ }
+
+ function prepare_string_for_quotes(&$str){
+ // prepare the code to be putted into quotes
+ /*$pattern= array("/(\\\\)?\"/", '/\\\n/' , '/\\\r/' , "/(\r?\n)/");
+ $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , '\\\n"$1+"');*/
+ $pattern= array("/(\\\\)?\"/", '/\\\n/' , '/\\\r/' , "/(\r?\n)/");
+ if($this->param['compress'])
+ $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , '\n');
+ else
+ $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r' , "\\n\"\n+\"");
+ $str= preg_replace($pattern, $replace, $str);
+ }
+
+ function replace_scripts($var, $param1, $param2)
+ {
+ $this->$var=stripslashes($param2);
+ return $param1."[];";
+ }
+
+ /* for php version that have not thoses functions */
+ function file_get_contents($file)
+ {
+ $fd = fopen($file, 'rb');
+ $content = fread($fd, filesize($file));
+ fclose($fd);
+ $this->file_loaded_size+= strlen($content);
+ return $content;
+ }
+
+ function file_put_contents($file, &$content, $mtime=-1)
+ {
+ if($mtime==-1)
+ $mtime=time();
+ $fp = @fopen($file, "wb");
+ if ($fp) {
+ fwrite($fp, $content);
+ fclose($fp);
+ touch($file, $mtime);
+ return true;
+ }
+ return false;
+ }
+
+ function get_microtime()
+ {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+ }
+ }
+?>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6b1dba58/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_full.gz
----------------------------------------------------------------------
diff --git a/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_full.gz b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_full.gz
new file mode 100644
index 0000000..114a670
Binary files /dev/null and b/dependencies/org.wso2.carbon.ui/src/main/resources/web/editarea/edit_area_full.gz differ