diff --git a/VERSION b/VERSION index 57519c10..9b887f54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.3 (2011-12-05 11:26:15) dev +Version 1.99.3 (2011-12-05 11:39:10) dev diff --git a/__init__.py b/__init__.py index b28b04f6..fd40910d 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ + diff --git a/anyserver.py b/anyserver.py index e397ff8f..c21f9584 100644 --- a/anyserver.py +++ b/anyserver.py @@ -132,17 +132,17 @@ class Servers: def eventlet(app,address, **options): from eventlet import wsgi, listen wsgi.server(listen(address), app) - + @staticmethod def mongrel2(app,address,**options): import uuid sys.path.append(os.path.abspath(os.path.dirname(__file__))) from mongrel2 import handler - conn = handler.Connection(str(uuid.uuid4()), + conn = handler.Connection(str(uuid.uuid4()), "tcp://127.0.0.1:9997", "tcp://127.0.0.1:9996") mongrel2_handler(app,conn,debug=False) - + def run(servername,ip,port,softcron=True,logging=False,profiler=None): if logging: @@ -161,8 +161,8 @@ def mongrel2_handler(application,conn,debug=False): Based on : https://github.com/berry/Mongrel2-WSGI-Handler/blob/master/wsgi-handler.py - WSGI handler based on the Python wsgiref SimpleHandler. - A WSGI application should return a iterable op StringTypes. + WSGI handler based on the Python wsgiref SimpleHandler. + A WSGI application should return a iterable op StringTypes. Any encoding must be handled by the WSGI application itself. """ from wsgiref.handlers import SimpleHandler @@ -170,28 +170,28 @@ def mongrel2_handler(application,conn,debug=False): import cStringIO as StringIO except: import StringIO - - # TODO - this wsgi handler executes the application and renders a page - # in memory completely before returning it as a response to the client. - # Thus, it does not "stream" the result back to the client. It should be - # possible though. The SimpleHandler accepts file-like stream objects. So, - # it should be just a matter of connecting 0MQ requests/response streams to - # the SimpleHandler requests and response streams. However, the Python API - # for Mongrel2 doesn't seem to support file-like stream objects for requests + + # TODO - this wsgi handler executes the application and renders a page + # in memory completely before returning it as a response to the client. + # Thus, it does not "stream" the result back to the client. It should be + # possible though. The SimpleHandler accepts file-like stream objects. So, + # it should be just a matter of connecting 0MQ requests/response streams to + # the SimpleHandler requests and response streams. However, the Python API + # for Mongrel2 doesn't seem to support file-like stream objects for requests # and responses. Unless I have missed something. - + while True: if debug: print "WAITING FOR REQUEST" - + # receive a request req = conn.recv() if debug: print "REQUEST BODY: %r\n" % req.body - + if req.is_disconnect(): if debug: print "DISCONNECT" continue #effectively ignore the disconnect from the client - - # Set a couple of environment attributes a.k.a. header attributes + + # Set a couple of environment attributes a.k.a. header attributes # that are a must according to PEP 333 environ = req.headers environ['SERVER_PROTOCOL'] = 'HTTP/1.1' # SimpleHandler expects a server_protocol, lets assume it is HTTP 1.1 @@ -211,21 +211,21 @@ def mongrel2_handler(application,conn,debug=False): if environ.has_key('Content-Length'): environ['CONTENT_LENGTH'] = environ['Content-Length'] # necessary for POST to work with Django environ['wsgi.input'] = req.body - + if debug: print "ENVIRON: %r\n" % environ - + # SimpleHandler needs file-like stream objects for # requests, errors and responses reqIO = StringIO.StringIO(req.body) errIO = StringIO.StringIO() respIO = StringIO.StringIO() - + # execute the application handler = SimpleHandler(reqIO, respIO, errIO, environ, multithread = False, multiprocess = False) handler.run(application) - + # Get the response and filter out the response (=data) itself, - # the response headers, + # the response headers, # the response status code and the response status description response = respIO.getvalue() response = response.split("\r\n") @@ -233,22 +233,22 @@ def mongrel2_handler(application,conn,debug=False): headers = dict([r.split(": ") for r in response[1:-2]]) code = response[0][9:12] status = response[0][13:] - + # strip BOM's from response data # Especially the WSGI handler from Django seems to generate them (2 actually, huh?) # a BOM isn't really necessary and cause HTML parsing errors in Chrome and Safari # See also: http://www.xs4all.nl/~mechiel/projects/bomstrip/ # Although I still find this a ugly hack, it does work. data = data.replace('\xef\xbb\xbf', '') - + # Get the generated errors errors = errIO.getvalue() - + # return the response if debug: print "RESPONSE: %r\n" % response if errors: if debug: print "ERRORS: %r" % errors - data = "%s\r\n\r\n%s" % (data, errors) + data = "%s\r\n\r\n%s" % (data, errors) conn.reply_http(req, data, code = code, status = status, headers = headers) def main(): @@ -298,3 +298,4 @@ def main(): if __name__=='__main__': main() + diff --git a/appengine_config.py b/appengine_config.py index e1926ef6..cc30fc64 100644 --- a/appengine_config.py +++ b/appengine_config.py @@ -3,3 +3,4 @@ def webapp_add_wsgi_middleware(app): app = recording.appstats_wsgi_middleware(app) return app + diff --git a/applications/admin/controllers/appadmin.py b/applications/admin/controllers/appadmin.py index a177568b..927103b9 100644 --- a/applications/admin/controllers/appadmin.py +++ b/applications/admin/controllers/appadmin.py @@ -349,7 +349,7 @@ def ccache(): seconds = math.floor(seconds) return (hours, minutes, seconds) - + for key, value in cache.ram.storage.items(): if isinstance(value, dict): ram['hits'] = value['hit_total'] - value['misses'] @@ -388,7 +388,7 @@ def ccache(): if value[0] < disk['oldest']: disk['oldest'] = value[0] disk['keys'].append((key, GetInHMS(time.time() - value[0]))) - + finally: portalocker.unlock(locker) locker.close() @@ -417,14 +417,16 @@ def ccache(): def key_table(keys): return TABLE( TR(TD(B('Key')), TD(B('Time in Cache (h:m:s)'))), - *[TR(TD(k[0]), TD('%02d:%02d:%02d' % k[1])) for k in keys], + *[TR(TD(k[0]), TD('%02d:%02d:%02d' % k[1])) for k in keys], **dict(_class='cache-keys', _style="border-collapse: separate; border-spacing: .5em;")) - + ram['keys'] = key_table(ram['keys']) disk['keys'] = key_table(disk['keys']) total['keys'] = key_table(total['keys']) - + return dict(form=form, total=total, ram=ram, disk=disk, object_stats=hp != False) + + diff --git a/applications/admin/controllers/debug.py b/applications/admin/controllers/debug.py index d860b615..a2c8e31c 100644 --- a/applications/admin/controllers/debug.py +++ b/applications/admin/controllers/debug.py @@ -31,3 +31,5 @@ def reset(): session['debug_commands:'+app] = [] return 'done' + + diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 7d37b1a8..291cb471 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -271,7 +271,7 @@ def uninstall(): else: session.flash = T('no permission to uninstall "%s"', app) redirect(URL('site')) - if app_uninstall(app, request): + if app_uninstall(app, request): session.flash = T('application "%s" uninstalled', app) else: session.flash = T('unable to uninstall "%s"', app) @@ -946,7 +946,7 @@ def create_file(): raise SyntaxError msg = T('This is the %(filename)s template', - dict(filename=filename)) + dict(filename=filename)) if extension == 'html': text = dedent(""" {{extend 'layout.html'}} @@ -958,7 +958,7 @@ def create_file(): text = read_file(generic) else: text = '' - + elif path[-9:] == '/modules/': if request.vars.plugin and not filename.startswith('plugin_%s/' % request.vars.plugin): filename = 'plugin_%s/%s' % (request.vars.plugin, filename) @@ -1103,27 +1103,27 @@ def errors(): decorated.sort(key=operator.itemgetter(0), reverse=True) return dict(errors = [x[1] for x in decorated], app=app, method=method) - + elif method == 'dbnew': errors_path = apath('%s/errors' % app, r=request) tk_db, tk_table = get_ticket_storage(app) - + delete_hashes = [] for item in request.vars: if item[:7] == 'delete_': delete_hashes.append(item[7:]) hash2error = dict() - + for fn in tk_db(tk_table.id>0).select(): try: error = pickle.loads(fn.ticket_data) except AttributeError: tk_db(tk_table.id == fn.id).delete() tk_db.commit() - + hash = hashlib.md5(error['traceback']).hexdigest() - + if hash in delete_hashes: tk_db(tk_table.id == fn.id).delete() tk_db.commit() @@ -1140,9 +1140,9 @@ def errors(): hash=hash,ticket=fn.ticket_id) decorated = [(x['count'], x) for x in hash2error.values()] - + decorated.sort(key=operator.itemgetter(0), reverse=True) - + return dict(errors = [x[1] for x in decorated], app=app, method=method) elif method == 'dbold': @@ -1153,7 +1153,7 @@ def errors(): tk_db.commit() tickets_ = tk_db(tk_table.id>0).select(tk_table.ticket_id, tk_table.created_datetime, orderby=~tk_table.created_datetime) tickets = [row.ticket_id for row in tickets_] - times = dict([(row.ticket_id, row.created_datetime) for row in tickets_]) + times = dict([(row.ticket_id, row.created_datetime) for row in tickets_]) return dict(app=app, tickets=tickets, method=method, times=times) @@ -1323,7 +1323,7 @@ def twitter(): def user(): if MULTI_USER_MODE: if not db(db.auth_user).count(): - auth.settings.registration_requires_approval = False + auth.settings.registration_requires_approval = False return dict(form=auth()) else: return dict(form=T("Disabled")) @@ -1333,3 +1333,5 @@ def reload_routes(): import gluon.rewrite gluon.rewrite.load() redirect(URL('site')) + + diff --git a/applications/admin/controllers/gae.py b/applications/admin/controllers/gae.py index 290003c9..a2c535b2 100644 --- a/applications/admin/controllers/gae.py +++ b/applications/admin/controllers/gae.py @@ -7,7 +7,7 @@ try: import signal import os import shutil - from gluon.fileutils import read_file, write_file + from gluon.fileutils import read_file, write_file except: session.flash='sorry, only on Unix systems' redirect(URL(request.application,'default','site')) @@ -53,7 +53,7 @@ def deploy(): yaml = apath('../app.yaml', r=request) if not os.path.exists(yaml): example = apath('../app.example.yaml', r=request) - shutil.copyfile(example,yaml) + shutil.copyfile(example,yaml) data = read_file(yaml) data = re.sub('application:.*','application: %s' % form.vars.google_application_id,data) data = regex.sub('(applications/(%s)/.*)|' % '|'.join(ignore_apps),data) @@ -85,3 +85,5 @@ def callback(): except: errors='' return (output+errors).replace('\n','
') + + diff --git a/applications/admin/controllers/mercurial.py b/applications/admin/controllers/mercurial.py index 387d8335..a91b66a6 100644 --- a/applications/admin/controllers/mercurial.py +++ b/applications/admin/controllers/mercurial.py @@ -80,3 +80,5 @@ def revision(): desc=ctx.description(), form=form ) + + diff --git a/applications/admin/controllers/plugin_jqmobile.py b/applications/admin/controllers/plugin_jqmobile.py index b9265a63..bc72c15d 100644 --- a/applications/admin/controllers/plugin_jqmobile.py +++ b/applications/admin/controllers/plugin_jqmobile.py @@ -6,3 +6,5 @@ def index(): def about(): return locals() + + diff --git a/applications/admin/controllers/shell.py b/applications/admin/controllers/shell.py index 561e06eb..9ce45262 100644 --- a/applications/admin/controllers/shell.py +++ b/applications/admin/controllers/shell.py @@ -43,3 +43,5 @@ def reset(): session['commands:'+app] = [] session['history:'+app] = gluon.contrib.shell.History() return 'done' + + diff --git a/applications/admin/controllers/toolbar.py b/applications/admin/controllers/toolbar.py index 34a87651..25e83a3e 100644 --- a/applications/admin/controllers/toolbar.py +++ b/applications/admin/controllers/toolbar.py @@ -20,10 +20,12 @@ def profiler(): size = 0 if os.path.exists(filename): data = read_file('profiler.log','rb') - if size= allowed_number_of_attempts: return val[0] # locked out time.sleep(2**val[0]) - val = (val[0]+1,int(time.time())) + val = (val[0]+1,int(time.time())) denied_hosts[request.client] = val write_hosts_deny(denied_hosts) return val[0] - + # ########################################################### # ## session expiration @@ -144,3 +144,5 @@ if request.controller=='appadmin' and DEMO_MODE: session.flash = 'Appadmin disabled in demo mode' redirect(URL('default','sites')) + + diff --git a/applications/admin/models/buttons.py b/applications/admin/models/buttons.py index 1c986400..33a8811a 100644 --- a/applications/admin/models/buttons.py +++ b/applications/admin/models/buttons.py @@ -7,10 +7,10 @@ def button(href, label): def button_enable(href, app): if os.path.exists(os.path.join(apath(app,r=request),'DISABLED')): - label = SPAN(T('Enable'),_style='color:red') + label = SPAN(T('Enable'),_style='color:red') else: label = SPAN(T('Disable'),_style='color:green') - id = 'enable_'+app + id = 'enable_'+app return A(label,_class='button',_id=id,callback=href,target=id) def sp_button(href, label): @@ -21,3 +21,5 @@ def helpicon(): def searchbox(elementid): return TAG[''](LABEL(IMG(_src=URL('static', 'images/search.png'), _alt=T('filter')), _class='icon', _for=elementid), ' ', INPUT(_id=elementid, _type='text', _size=12)) + + diff --git a/applications/admin/models/db.py b/applications/admin/models/db.py index 395d1d21..28bf0134 100644 --- a/applications/admin/models/db.py +++ b/applications/admin/models/db.py @@ -9,7 +9,7 @@ if MULTI_USER_MODE: crud = Crud(globals(),db) # for CRUD helpers using auth service = Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc plugins = PluginManager() - + mail.settings.server = 'logging' or 'smtp.gmail.com:587' # your SMTP server mail.settings.sender = 'you@gmail.com' # your email mail.settings.login = 'username:password' # your credentials or None @@ -38,3 +38,5 @@ def is_manager(): return True else: return False + + diff --git a/applications/admin/models/menu.py b/applications/admin/models/menu.py index a1e2ca8b..6963c596 100644 --- a/applications/admin/models/menu.py +++ b/applications/admin/models/menu.py @@ -31,3 +31,5 @@ if os.path.exists('applications/examples'): response.menu.append((T('Help'), False, URL('examples','default','index'))) else: response.menu.append((T('Help'), False, 'http://web2py.com/examples')) + + diff --git a/applications/admin/models/plugin_multiselect.py b/applications/admin/models/plugin_multiselect.py index 0b4c9dcc..5265ccce 100644 --- a/applications/admin/models/plugin_multiselect.py +++ b/applications/admin/models/plugin_multiselect.py @@ -2,3 +2,5 @@ response.files.append(URL('static','plugin_multiselect/jquery.dimensions.js')) response.files.append(URL('static','plugin_multiselect/jquery.multiselect.js')) response.files.append(URL('static','plugin_multiselect/jquery.multiselect.css')) response.files.append(URL('static','plugin_multiselect/start.js')) + + diff --git a/applications/admin/modules/__init__.py b/applications/admin/modules/__init__.py index e69de29b..139597f9 100644 --- a/applications/admin/modules/__init__.py +++ b/applications/admin/modules/__init__.py @@ -0,0 +1,2 @@ + + diff --git a/applications/admin/static/css/calendar.css b/applications/admin/static/css/calendar.css index a340615f..660fe034 100644 --- a/applications/admin/static/css/calendar.css +++ b/applications/admin/static/css/calendar.css @@ -4,4 +4,4 @@ border-radius: 10px; -webkit-border-radius: 10px; }.calendar table{margin:0px;font-size:11px;color:#000;cursor:default;font-family:tahoma,verdana,sans-serif;}.calendar .button{text-align:center;padding:1px;color:#fff;background:#000;}.calendar .nav{background:#000;color:#fff}.calendar thead .title{font-weight:bold;padding:1px;background:#000;color:#fff;text-align:center;}.calendar thead .name{padding:2px;text-align:center;background:#bbb;}.calendar thead .weekend{color:#f00;}.calendar thead .hilite {background-color:#666;}.calendar thead .active{padding:2px 0 0 2px;background-color:#c4c0b8;}.calendar tbody .day{width:2em;text-align:right;padding:2px 4px 2px 2px;}.calendar tbody .day.othermonth{color:#aaa;}.calendar tbody .day.othermonth.oweekend{color:#faa;}.calendar table .wn{padding:2px 3px 2px 2px;background:#bbb;}.calendar tbody .rowhilite td{background:#ddd;}.calendar tbody td.hilite{background:#bbb;}.calendar tbody td.active{background:#bbb;}.calendar tbody td.selected{font-weight:bold;background:#ddd;}.calendar tbody td.weekend{color:#f00;}.calendar tbody td.today{font-weight:bold;color:#00f;}.calendar tbody .disabled{color:#999;}.calendar tbody .emptycell{visibility:hidden;}.calendar tbody .emptyrow{display:none;}.calendar tfoot .ttip{background:#bbb;padding:1px;background:#000;color:#fff;text-align:center;}.calendar tfoot .hilite{background:#ddd;}.calendar tfoot .active{}.calendar .combo{position:absolute;display:none;width:4em;top:0;left:0;cursor:default;background:#e4e0d8;padding:1px;z-index:100;}.calendar .combo .label,.calendar .combo .label-IEfix{text-align:center;padding:1px;}.calendar .combo .label-IEfix{width:4em;}.calendar .combo .active{background:#c4c0b8;}.calendar .combo .hilite{background:#048;color:#fea;}.calendar td.time{padding:1px 0;text-align:center;background-color:#bbb;}.calendar td.time .hour,.calendar td.time .minute,.calendar td.time .ampm{padding:0 3px 0 4px;font-weight:bold;}.calendar td.time .ampm{text-align:center;}.calendar td.time .colon{padding:0 2px 0 3px;font-weight:bold;}.calendar td.time span.hilite{}.calendar td.time span.active{border-color:#f00;background-color:#000;color:#0f0;}.hour,.minute{font-size:2em;} -#CP_hourcont{z-index:99;padding:0;position:absolute;border:1px dashed #666;background-color:#eee;display:none;}#CP_minutecont{z-index:99;background-color:#ddd;padding:1px;position:absolute;width:45px;display:none;}.floatleft{float:left;}.CP_hour{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:35px;}.CP_minute{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:auto;}.CP_over{background-color:#fff;z-index:99} \ No newline at end of file +#CP_hourcont{z-index:99;padding:0;position:absolute;border:1px dashed #666;background-color:#eee;display:none;}#CP_minutecont{z-index:99;background-color:#ddd;padding:1px;position:absolute;width:45px;display:none;}.floatleft{float:left;}.CP_hour{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:35px;}.CP_minute{z-index:99;padding:1px;font-family:Arial,Helvetica,sans-serif;font-size:9px;white-space:nowrap;cursor:pointer;width:auto;}.CP_over{background-color:#fff;z-index:99} diff --git a/applications/admin/static/css/jqueryMultiSelect.css b/applications/admin/static/css/jqueryMultiSelect.css index 6a26b85c..12cdaea4 100755 --- a/applications/admin/static/css/jqueryMultiSelect.css +++ b/applications/admin/static/css/jqueryMultiSelect.css @@ -11,7 +11,7 @@ background: right center no-repeat; } -.multiSelect.active, +.multiSelect.active, .multiSelect.focus { border: inset 1px #000; } @@ -44,4 +44,4 @@ .multiSelectOptions LABEL.hover { background: #CFCFCF; -} \ No newline at end of file +} diff --git a/applications/admin/static/css/styles.css b/applications/admin/static/css/styles.css index f7a562ed..abf9f399 100644 --- a/applications/admin/static/css/styles.css +++ b/applications/admin/static/css/styles.css @@ -181,7 +181,7 @@ fieldset.inline { float:left; width: 100%; } - + /* 4.4. Inline-block element must content any element inside (div, p, etc) for the correct visualization in FF<3 */ .inline-block-top,.inline-block-middle,.inline-block-bottom { float:none !important; @@ -330,7 +330,7 @@ a.button, padding: 4px 0 6px 10px; /*Padding-left: 10px */ margin: 0 0 0 -10px; /* Margin-left: -10px */ } - + /* 3. HACKS */ ul.button { @@ -348,7 +348,7 @@ a.button { -moz-box-orient: vertical; /* FF<3 */ *display: inline; /* IE */ } - + /** * cSans Tooltip pluging v0.1 * 2009 Copyright A navalla suíza http://anavallasuiza.com @@ -372,7 +372,7 @@ a.button { display:inline; position:absolute; } - + /** * cSans Flexible v0.1 * 2009 Copyright A navalla suíza http://anavallasuiza.com @@ -957,17 +957,17 @@ ul#snapshot > li { .shell #output pre { color: #e8953c; background: white; - border: 1px solid #333; + border: 1px solid #333; } -.shell .prompt, -.shell #output, +.shell .prompt, +.shell #output, .shell pre, .shell #caret { font-family: monospace; } -.shell .prompt, +.shell .prompt, .shell #output, .shell #caret { font-size: 10pt; @@ -977,7 +977,7 @@ ul#snapshot > li { .shell #shellwrapper { background: white; - border: 1px solid #333; + border: 1px solid #333; color: #e8953c; width: 75%; // padding: 6px; @@ -1063,3 +1063,4 @@ ul#snapshot > li { .translated { background-color: white; } .ui-multiselect { border: 1px solid #ccc; width:400px;} #editor_area textarea { height: 400px; width: 100% } + diff --git a/applications/admin/static/eamy/bundle_markup.js b/applications/admin/static/eamy/bundle_markup.js index e690eb0d..f164a24f 100644 --- a/applications/admin/static/eamy/bundle_markup.js +++ b/applications/admin/static/eamy/bundle_markup.js @@ -25,7 +25,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * * * This file is auto-generated from original Fry Framework and Amy Editor sources.. @@ -387,3 +387,4 @@ snippet = {tab_activation: '=', code: '{{=$0}}'}; eamy.snippets.push(snippet); + diff --git a/applications/admin/static/eamy/bundle_python.js b/applications/admin/static/eamy/bundle_python.js index f9aa9732..5c4ce301 100644 --- a/applications/admin/static/eamy/bundle_python.js +++ b/applications/admin/static/eamy/bundle_python.js @@ -25,7 +25,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * * * This file is auto-generated from original Fry Framework and Amy Editor sources.. @@ -294,3 +294,4 @@ snippet = {tab_activation: 're', code: 'redirect(\'$0\')'}; eamy.snippets.push(snippet); snippet = {tab_activation: 'rej', code: 'response.json=\'$0\''}; eamy.snippets.push(snippet); + diff --git a/applications/admin/static/eamy/eamy.js b/applications/admin/static/eamy/eamy.js index ccaa7887..63d42b4c 100644 --- a/applications/admin/static/eamy/eamy.js +++ b/applications/admin/static/eamy/eamy.js @@ -25,7 +25,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * * * This file is auto-generated from original Fry Framework and Amy Editor sources.. @@ -45,7 +45,7 @@ */ /* Reserving global `fry` object */ -var fry = +var fry = { version:1.0, __production_mode:false @@ -142,7 +142,7 @@ String.prototype.embed = function() } // Tuning helpers - dealing with user-agent differences -var $__tune = +var $__tune = { __prop:{}, isIE:('function' == typeof window.ActiveXObject), @@ -196,11 +196,11 @@ var $__tune = getPageScrollPosition:function() { var d = document.documentElement; - if ( d && d.scrollTop) + if ( d && d.scrollTop) { return [d.scrollLeft, d.scrollTop]; - } - else if (document.body) + } + else if (document.body) { return [document.body.scrollLeft, document.body.scrollTop]; } @@ -251,7 +251,7 @@ var $__tune = evt.offsetX = evt.pageX - pos.x; evt.offsetY = evt.pageY - pos.y; } - return evt.offsetY; + return evt.offsetY; } evt.isAnyControlKeyPressed = function() { @@ -286,8 +286,8 @@ var $__tune = else if ( node.removeEventListener ) { node.removeEventListener(type, listener, false); - } - } + } + } }, behavior: { @@ -395,7 +395,7 @@ function ACNode(node) this.$ = node; if ( node ) { - node.setAttribute('fryis', '1'); + node.setAttribute('fryis', '1'); } } // `$$` creates new node @@ -466,7 +466,7 @@ ACNode.prototype.e = function(t, c, oneUseOnly) evt = evt || self.event; if ( null != c ) { - c($__tune.event.get(evt)); + c($__tune.event.get(evt)); } if ( null != evt ) { @@ -478,7 +478,7 @@ ACNode.prototype.e = function(t, c, oneUseOnly) else if ( evt.stopped ) { // console.log('*E* stop self.%s for %s', hash, t); - evt = null; + evt = null; } } }; @@ -656,7 +656,7 @@ ACNode.prototype.d = function(d) return 'none' != this.$.style.display; } this.$.style.display = d ? 'block' : 'none'; - return this; + return this; } // *v*isibility ACNode.prototype.v = function(v) @@ -666,7 +666,7 @@ ACNode.prototype.v = function(v) return 'hidden' != this.$.style.visibility; } this.$.style.visibility = v ? 'visible' : 'hidden'; - return this; + return this; } // H*T*ML source (equivalent to infamous innerHTML, remember innerHTML is not considered *evil* here - see the KISS principle, plus it's actually faster than DOM) ACNode.prototype.t = function(t) @@ -892,7 +892,7 @@ ACNode.prototype.lc = function() { n = n.previousSibling; } - return null != n ? $(n) : null; + return null != n ? $(n) : null; } // *n*ext *s*ibling of the node - always returns first $-ed node (ignoring text, comment etc. nodes) ACNode.prototype.ns = function() @@ -912,7 +912,7 @@ ACNode.prototype.ps = function() { n = n.previousSibling; } - return null != n ? $(n) : null; + return null != n ? $(n) : null; } // *g*et *a*ttribute ACNode.prototype.ga = function(n) @@ -988,7 +988,7 @@ var $ = function(id) ====== Creates new class, multiple class inheritance is allowed. Usage: - + $class('AClass', { construct:function(a) @@ -1061,7 +1061,7 @@ var $class = function(className, methods) var preprocessSource = function(s, cn) { // parsing source code and replacing calls to base constructor or methods - eval('var re = /'+cn+'\.([^\\(]*)\\(([\\)]*)/g;'); + eval('var re = /'+cn+'\.([^\\(]*)\\(([\\)]*)/g;'); s = s.replace(re, function() { return 'this.__'+cn+'_'+arguments[1]+'.call(this'+(''==arguments[2].replace(/ /g, '')?',':'')+arguments[2]; @@ -1072,7 +1072,7 @@ var $class = function(className, methods) return 'this.__'+cn+'_construct.call(this'+(''==arguments[1].replace(/ /g, '')?',':'')+arguments[1]; }); return s; - } + } methods = methods || {}; var c_code = ''; var d_code = ''; @@ -1106,15 +1106,15 @@ var $class = function(className, methods) { if ( 'Object' != bases[i] ) { - oc_code = preprocessSource(oc_code, bases[i]); + oc_code = preprocessSource(oc_code, bases[i]); } } c_code += oc_code; - } + } d_code += methods.destruct ? getSource(methods.destruct) : ''; try { - eval('var newClass=function('+p.join(',')+'){'+c_code+'};'); + eval('var newClass=function('+p.join(',')+'){'+c_code+'};'); } catch (e) { @@ -1185,7 +1185,7 @@ var $delete = function(object) { if ( 'Object' != bases[i] ) { - $call(object, bases[i]+'.destruct()'); + $call(object, bases[i]+'.destruct()'); } } } @@ -1248,7 +1248,7 @@ var $runafter = function(t, c) var $runinterval = function(from, to, interval, c) { var i = from; - var control = + var control = { from:from, to:to, @@ -1322,7 +1322,7 @@ var $foreach = function(o, c) return; } var n = 'function' == typeof o.__length ? o.__length() : o.length; - var control = + var control = { stopped:false, stop:function() @@ -1392,7 +1392,7 @@ var $foreach = function(o, c) } } control = null; - c = null; + c = null; } var $notset = function(value) { @@ -1581,11 +1581,11 @@ fry.remote = }, 150 ); - }, + }, result:function(s, callbackOk, callbackError) { var httpStatus; - var responseObject; + var responseObject; try { httpStatus = s.status; @@ -1613,7 +1613,7 @@ fry.remote = } try { - callbackOk(r); + callbackOk(r); } catch(e) { @@ -1638,7 +1638,7 @@ fry.remote = else { callbackError('Invalid data returned from remote side: `?`.'.embed(s.responseText.substr('#E#'==code?3:0))); - } + } } } } @@ -1760,7 +1760,7 @@ fry.remote.upload.Adapter.prototype.onGetRemoteActionName = function() } -/* ---------------------------------------------------------------- +/* ---------------------------------------------------------------- fry.cookie namespace */ @@ -1772,14 +1772,14 @@ fry.cookie = var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); - if (begin == -1) + if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; - } + } else { - begin += 2; + begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) @@ -1790,7 +1790,7 @@ fry.cookie = }, remove:function(name, path, domain) { - if (getCookie(name)) + if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } @@ -1809,12 +1809,12 @@ var $rpost = function(params, callbackOk, callbackError, method, url) { method = method || 'POST'; url = url || client.conf.fry.backendURL; - $post( function(s) { $result( s, - function(r) + $post( function(s) { $result( s, + function(r) { callbackOk(r); }, - function(e) + function(e) { // result Error callbackError(e); @@ -1990,7 +1990,7 @@ function __fry_gc_recycle() $__tune.event.addListener(self, 'load', function(evt) { __gc_trash_node = document.getElementsByTagName('body').item(0).appendChild(document.createElement('div')); - __gc_trash_node.style.display = 'none'; + __gc_trash_node.style.display = 'none'; }); $__tune.event.addListener(self, 'unload', function(evt) { @@ -2003,7 +2003,7 @@ $__tune.event.addListener(self, 'unload', function(evt) /*--------*/ -fry.keyboard = +fry.keyboard = { initialized:false, last_down_evt: null, @@ -2035,7 +2035,7 @@ fry.keyboard.initialize = function() return; } var react_as = 'none'; - + if ($__tune.isGecko) { react_as = 'ff_' + ($__tune.isMac ? 'mac' : 'win'); @@ -2089,7 +2089,7 @@ fry.keyboard.initialize = function() code = code.replace(/fry\.keyboard\.([A-Z_]+)/g, function() {return fry.keyboard[arguments[1]];}); // alert(code); eval(code); - + code = "document.onkeypress = function(evt) {\n"; code += "if (fry.keyboard.stopped || fry.keyboard.ignore_further_events) { return; }\n"; code += "if (fry.keyboard.paste.was) {\n"; @@ -2112,7 +2112,7 @@ fry.keyboard.initialize = function() code = code.replace(/fry\.keyboard\.([A-Z_]+)/g, function() {return fry.keyboard[arguments[1]];}); // alert(code); eval(code); - + document.onkeydown2 = function(evt) { if (fry.keyboard.stopped) @@ -2142,7 +2142,7 @@ fry.keyboard.initialize = function() fry.keyboard.clipboard.ie.node.value = ''; fry.keyboard.clipboard.ie.node.focus(); } - } + } } return fry.keyboard.down[react_as](evt || event); } @@ -2458,7 +2458,7 @@ fry.keyboard.press.webkit = function(evt) } evt.preventDefault(); evt.stopPropagation(); - return false; + return false; } fry.keyboard.paste.ie = function(evt) @@ -2497,7 +2497,7 @@ fry.keyboard.down.ie = function(evt) return !fry.keyboard.pushKey(code, mask); } } - return true; + return true; } fry.keyboard.press.ie = function(evt) @@ -2507,7 +2507,7 @@ fry.keyboard.press.ie = function(evt) var mask = (evt.altKey ? 2 : 0) + (evt.ctrlKey ? 4 : 0) + (evt.shiftKey ? 8 : 0) + (evt.metaKey ? 16 : 0); return !fry.keyboard.pushKey(evt.keyCode, mask); } - return false; + return false; } @@ -2644,7 +2644,7 @@ fry.keyboard.getClipboardContent = function() /*--------*/ var client = {conf:{fry:{backendURL:''}}}; -var eamy = +var eamy = { snippets:[], instances:[] @@ -2659,7 +2659,7 @@ if ( 'undefined' == typeof ac ) var ac = {chap:{}}; } -ac.chap = +ac.chap = { state: { @@ -2672,7 +2672,7 @@ ac.chap = TOKEN_DOUBLE_QUOTED:3, TOKEN_NEWROW:4, TOKEN_WHITESPACE:5, - + ROWSTATE_NONE:0, ROWSTATE_FOLD_START:1, ROWSTATE_FOLD_STOP:2, @@ -2680,7 +2680,7 @@ ac.chap = ROWSTATE_FOLD_COLLAPSED:8, ROWSTATE_SELECTION:16, ROWSTATE_BOOKMARK:32, - + CHUNK_KEYWORD:4, CHUNK_NUMBER:5, CHUNK_OPERATOR:6, @@ -2689,7 +2689,7 @@ ac.chap = CHUNK_FUNCTION_NAME:9, CHUNK_LIBRARY:10, CHUNK_LIBRARY_CUSTOM:11, - + ACTION_CARET:1, ACTION_SELECTION:2, ACTION_INSERT:3, @@ -2699,25 +2699,25 @@ ac.chap = ACTION_UNDO:7, ACTION_REDO:8, ACTION_CUSTOM:9, - + ACTION_RES_REDRAWCARET:1, ACTION_RES_REDRAWTEXT:2, ACTION_RES_SELECTIONCHANGED:4, ACTION_RES_SCROLLTOCARET:8, - + CKEY_NONE:0, CKEY_ALT:2, CKEY_CTRL:4, CKEY_SHIFT:8, CKEY_META:16, - + TRANSLOG_TYPE_INSERT:1, TRANSLOG_TYPE_REMOVE:2, - + ACTION_LISTENER_BEFORE:1, ACTION_LISTENER_AFTER:2, ACTION_LISTENER_BOTH:3 - + } @@ -2822,7 +2822,7 @@ $class('ac.chap.Window', this.caret = null; this.options = null; this.state = null; - + this.views = []; this.activeView = null; this.viewLayoutNodes = []; @@ -2833,16 +2833,16 @@ $class('ac.chap.Window', this.style_map = []; this.row_id_sequence = 1; - + this.language = null; this.keymap = null; this.snippets = []; this.commands = []; - + this.selection = null; this.transaction_log = []; this.redo_log = []; - + this.setOptions(options||{}); this.setState(); }, @@ -2917,7 +2917,7 @@ ac.chap.Window.prototype.onPaste = function(selection, wasCut) ac.chap.Window.prototype.setOptions = function(options) { - this.options = + this.options = { initialCaretPosition:[0,0], tokenizerLazyLaunch:900, @@ -2968,7 +2968,7 @@ ac.chap.Window.prototype.setOptions = function(options) { if ($isset(options.font['size'])) { - this.options.font.size = options.font.size; + this.options.font.size = options.font.size; } if ($isset(options.font['family'])) { @@ -2996,7 +2996,7 @@ ac.chap.Window.prototype.setState = function() transactionListener:[null,800], passThroughKeysListener:null } - this.caret = + this.caret = { position:[this.options.initialCaretPosition[0], this.options.initialCaretPosition[1]], mode:1 // 1 normal, 2 overwrite @@ -3052,7 +3052,7 @@ ac.chap.Window.prototype.edit = function(text, setAsActive) this.row_id_sequence = 1; this.transaction_log = []; this.redo_log = []; - + this.insertIntoCharacterMap(text, 0, 0); this.tokenize(0); this.renderText(); @@ -3408,7 +3408,7 @@ ac.chap.Window.prototype.keyboardListener = function(code, mask) } else { - setTimeout(function(){listener[2](me, listener[1], ac.chap.ACTION_LISTENER_AFTER, result, action_type, params, caret_row, caret_col);}, 300); + setTimeout(function(){listener[2](me, listener[1], ac.chap.ACTION_LISTENER_AFTER, result, action_type, params, caret_row, caret_col);}, 300); } } } @@ -3456,7 +3456,7 @@ ac.chap.Window.prototype.keyboardListener = function(code, mask) return true; } -// called if chap is not a part of Fry MVC +// called if chap is not a part of Fry MVC ac.chap.Window.prototype.standaloneKeyboardListener = function(code, mask) { if (fry.keyboard.CONTROL_CODE == (mask & fry.keyboard.CONTROL_CODE)) @@ -3649,7 +3649,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) var key_code = params.keyCode; var control_key = params.controlKey; // console.log('action_type:%s, params:%o', actionType, params); - + switch ( actionType ) { case ac.chap.ACTION_CARET: @@ -3727,7 +3727,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) } this.setCaretPosition(caret_row+1, caret_col); return ac.chap.ACTION_RES_REDRAWCARET; - } + } } else if ( 'prev_word' == direction ) { @@ -3755,7 +3755,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) } } this.setCaretPosition(caret_row, caret_col); - return ac.chap.ACTION_RES_REDRAWCARET; + return ac.chap.ACTION_RES_REDRAWCARET; } else if ( 'next_word' == direction ) { @@ -3846,7 +3846,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) if ( 0 < caret_col ) { caret_col = 0; - this.setCaretPosition(caret_row, caret_col); + this.setCaretPosition(caret_row, caret_col); return ac.chap.ACTION_RES_REDRAWCARET; } } @@ -3855,7 +3855,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) if ( this.char_map[caret_row].length > caret_col ) { caret_col = this.char_map[caret_row].length; - this.setCaretPosition(caret_row, caret_col); + this.setCaretPosition(caret_row, caret_col); return ac.chap.ACTION_RES_REDRAWCARET; } } @@ -3986,7 +3986,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) // } this.insertIntoCharacterMap(ins_content); this.setCaretPosition(caret_row+1, caret_col); - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; } else if ( $isset(params.character) ) { @@ -4033,21 +4033,21 @@ ac.chap.Window.prototype.runAction = function(actionType, params) { if ( -1 == str.indexOf('\n') ) { - caret_col += str.length; + caret_col += str.length; } else { caret_row += str.length - str.replace(/\n/g, '').length; - caret_col = str.length - str.lastIndexOf('\n') - 1; + caret_col = str.length - str.lastIndexOf('\n') - 1; } - this.setCaretPosition(caret_row, caret_col); + this.setCaretPosition(caret_row, caret_col); } return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; - } + } };break; case ac.chap.ACTION_UPDATE: { - + };break; case ac.chap.ACTION_DELETE: { @@ -4063,7 +4063,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) else { this.removeFromCharacterMap(caret_row-1, this.char_map[caret_row-1].length, caret_row, this.char_map[caret_row].length); - this.setCaretPosition(caret_row-1, this.char_map[caret_row-1].length); + this.setCaretPosition(caret_row-1, this.char_map[caret_row-1].length); } } else @@ -4149,7 +4149,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) if ( proceed_delete ) { this.setCaretPosition(caret_row, caret_col-(after_caret?0:1)); - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; } } };break; @@ -4165,7 +4165,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) else if ( $isset(params.paste) ) { this.runAction(ac.chap.ACTION_INSERT, {string:params.content}) - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT; } };break; case ac.chap.ACTION_UNDO: @@ -4184,12 +4184,12 @@ ac.chap.Window.prototype.runAction = function(actionType, params) range_to[0] += (source.length - source.replace(/\n/g, '').length); var ix = source.lastIndexOf('\n'); range_to[1] = -1 == ix ? (range_from[1]+source.length) : (source.length - ix); - + // this.removeFromCharacterMap(range_from[0], range_from[1], range_to[0], range_to[1], this.redo_log); this.removeFromCharacterMap(range_from[0], range_from[1], range_to[0], range_to[1]);//, this.redo_log); caret_row = range_from[0]; caret_col = range_from[1]; - + } else if ( ac.chap.TRANSLOG_TYPE_REMOVE == operation_type ) { @@ -4199,7 +4199,7 @@ ac.chap.Window.prototype.runAction = function(actionType, params) } this.setCaretPosition(caret_row, caret_col); this.removeSelection(); - + this.redo_log = [].concat(this.redo_log, this.transaction_log.slice(num_trecords-3, num_trecords)); this.transaction_log = [].concat(this.transaction_log.slice(0, num_trecords-3)); @@ -4322,7 +4322,7 @@ ac.chap.Window.prototype.getWordAt = function(row, column, numWords) // word character found if ( direction_after ) { - words[words.length-1] += ch; + words[words.length-1] += ch; } else { @@ -4333,11 +4333,11 @@ ac.chap.Window.prototype.getWordAt = function(row, column, numWords) { if ( required_words == words.length ) { - break; + break; } next_word = true; } - + column += (direction_after ? 1 : -1); if ( 0 > column ) { @@ -4347,7 +4347,7 @@ ac.chap.Window.prototype.getWordAt = function(row, column, numWords) break; } next_word = true; - column = this.char_map[row].length-1; + column = this.char_map[row].length-1; } else if ( this.char_map[row].length <= column ) { @@ -4428,7 +4428,7 @@ ac.chap.Window.prototype.addAllSelection = function() this.row_id_map[ii][i][5][1] = this.char_map[i].length; } } - this.selection = + this.selection = { startPosition: [0, 0], endPosition: [num_rows-1, this.char_map[num_rows-1].length] @@ -4448,7 +4448,7 @@ ac.chap.Window.prototype.addSelection = function(range_to, range_from) if ( null == this.selection ) { // no previous selection - range_from = range_from || range_to; + range_from = range_from || range_to; this.selection = {}; this.selection.startPosition = [range_from[0], range_from[1]]; } @@ -4471,7 +4471,7 @@ ac.chap.Window.prototype.addSelection = function(range_to, range_from) } else { - range_to[1]--; + range_to[1]--; } this.selection.endPosition = [range_to[0], range_to[1]]; if ( (range_to[0] < range_from[0]) || (range_to[0] == range_from[0] && range_to[1] < range_from[1]) ) @@ -4539,7 +4539,7 @@ ac.chap.Window.prototype.getSelection = function() { var r = range_from; range_from = range_to; - range_to = r; + range_to = r; } if ( range_from[0] == range_to[0] ) { @@ -4552,7 +4552,7 @@ ac.chap.Window.prototype.getSelection = function() } // console.log('SELECTION: `%s`', selection_text.replace(/\n/g, '$')); } - return selection_text; + return selection_text; } ac.chap.Window.prototype.getCaretPosition = function() @@ -4631,7 +4631,7 @@ ac.chap.Window.prototype.captureEditAreaClick = function(evt, view) evt.stop(); this.hideInteractiveSearch(); this.activeView = view; - + var pos = evt.$.abspos(); var offset_x = evt.pageX - pos.x; var offset_y = evt.pageY - pos.y + ($__tune.isGecko ? view.nodeScrollArea.$.scrollTop : 0); @@ -4656,7 +4656,7 @@ ac.chap.Window.prototype.captureEditAreaClick = function(evt, view) { return; } - + var row_index = target.getAttribute ? parseInt(target.getAttribute('row-index')) : row_index; var num_subrows = 1; var col_index = 0; @@ -4688,7 +4688,7 @@ ac.chap.Window.prototype.captureEditAreaClick = function(evt, view) // last char col_index = i+1; break; - } + } } i++; } @@ -4771,7 +4771,7 @@ ac.chap.Window.prototype.foldingize = function() foldings[ix][2]--; if ( 0 == foldings[ix][2] ) { - foldings[ix][1] = ii; + foldings[ix][1] = ii; } break; } @@ -4799,7 +4799,7 @@ ac.chap.Window.prototype.foldingize = function() this.row_id_map[ii][fold[1]][3][0] = 0 this.row_id_map[ii][fold[1]][3][1] = fold[0]; } - } + } } ac.chap.Window.prototype.tokenize = function() @@ -4818,15 +4818,15 @@ ac.chap.Window.prototype.tokenize = function() var ml_start = this.language.multiRowCommentStartMarker; var ml_end = this.language.multiRowCommentEndMarker; // console.log(ml_end); - var sq = this.language.singleQuoteStringMarker; + var sq = this.language.singleQuoteStringMarker; var sq_exception = this.language.singleQuoteStringMarkerException; var dq = this.language.doubleQuoteStringMarker; var dq_exception = this.language.doubleQuoteStringMarkerException; var sl_markers = this.language.singleRowCommentStartMarkers; - + var cursor = {row:startRowIndex, col:0}; var col_offset = 0; - + var fillRowTokens = function(tokenType, fromRowIndex, toRowIndex, pars) { pars = pars || ''; @@ -4896,18 +4896,18 @@ ac.chap.Window.prototype.tokenize = function() var num_skipped_rows = skipped_source.split('\n').length; cursor.row += num_skipped_rows - 1; cursor.col = (1 == num_skipped_rows ? col_offset : 0) + skipped_source.length - ('\n'+skipped_source).lastIndexOf('\n'); - + if ( 'undefined' == typeof syntax_map[cursor.row] ) { syntax_map[cursor.row] = []; } - + var start_marker_len = ixs[found_marker_index][2].length; var end_marker_len = ixs[found_marker_index][3].length; source = source.substr(start_index+start_marker_len); var token_type = ixs[found_marker_index][0]; - + var end_index = source.indexOf(ixs[found_marker_index][3]); var sub_source = source; var end_index_offset = 0; @@ -5018,7 +5018,7 @@ ac.chap.Window.prototype.tokenize = function() } // console.log('%s marked as changed.', i); } - + delete syntax_map; delete fillRowTokens; } @@ -5050,7 +5050,7 @@ ac.chap.Window.prototype.insertIntoCharacterMap = function(source, atRow, atColu this.transaction_log.push([atRow, atColumn, userId]); this.transaction_log.push(source); } - + var num_existing_rows = this.char_map.length; var new_rows = source.split('\n'); var num_new_rows = new_rows.length; @@ -5065,9 +5065,9 @@ ac.chap.Window.prototype.insertIntoCharacterMap = function(source, atRow, atColu me = null; }, this.state.transactionListener[1]); } - + var i = ii = 0; - + if ( 'undefined' == typeof this.char_map[atRow] ) { this.char_map = this.char_map.concat(new_rows); @@ -5114,13 +5114,13 @@ ac.chap.Window.prototype.insertIntoCharacterMap = function(source, atRow, atColu } this.row_id_sequence = start_sequence; for ( i=0; i/g, '').length); return arguments[1]+(is_inside?'~`~`~`~`':' '); - }); + }); } return str.replace(/~`~`~`~`/g, ' '); } @@ -5473,7 +5473,7 @@ ac.chap.View.prototype.showCaret = function(skipScroll) { var caret_row = this.window.caret.position[0]; var caret_col = this.window.caret.position[1]; - + pos = this.getRenderedCharPosition(caret_row, caret_col); if ( null != pos ) { @@ -5501,7 +5501,7 @@ ac.chap.View.prototype.showCaret = function(skipScroll) this.theme.renderCaret(this.window.caret.mode, node); this.nodeCaret = node_row.appendChild(node); node_row.style.background = this.theme.caretRowStyleActive; - + if ( !skipScroll ) { // might be out of borders, at least partially @@ -5533,7 +5533,7 @@ ac.chap.View.prototype.showCaret = function(skipScroll) if ( !skipScroll ) { // scrolling into view - this.scrollToRow(caret_row - Math.floor(this.numRows/2)); + this.scrollToRow(caret_row - Math.floor(this.numRows/2)); } } } @@ -5613,7 +5613,7 @@ ac.chap.View.prototype.reloadOptions = function() this.recalculateNumRows(); this.recalculateVisibleRows(); this.renderSidebarStub(); - this.renderText(true); + this.renderText(true); } ac.chap.View.prototype.recalculateNumCols = function(node, withoutScrollbar) @@ -5683,14 +5683,14 @@ ac.chap.View.prototype.showInteractiveSearch = function() { evt.stopPropagation(); search(); - + }).$.focus(); node.g('img:0').e('click', function(evt) { evt.stopPropagation(); finish(true); }); - + function finish(canceled) { if (canceled) @@ -5703,12 +5703,12 @@ ac.chap.View.prototype.showInteractiveSearch = function() ac.chap.setActiveComponent(me.window); me.hideInteractiveSearch(); } - + function update_status(numFound) { status_node.t('Found ? results.'.embed(numFound)); } - + function search() { var keyword = search_key_node.$.value.trim(); @@ -5728,8 +5728,8 @@ ac.chap.View.prototype.showInteractiveSearch = function() me.window.runAction(ac.chap.ACTION_CUSTOM, {action:'SearchKeyword', direction:'down'}); me.scrollToRow(me.window.caret.position[0], false, true); me.window.processActionResult(true, true); - } - + } + if (null != selection) { search_key_node.$.value = selection; @@ -5738,8 +5738,8 @@ ac.chap.View.prototype.showInteractiveSearch = function() search(); } - - + + this.interactiveSearchNode = node; } @@ -5761,7 +5761,7 @@ ac.chap.View.prototype.render = function(node) var me = this; this.nodeRoot = node.a($$()).pos(true).w(w).h(h).n('acw-chap').s('background:?'.embed(this.theme.background)); this.interactiveSearchNode = null; - + var w_rows = 58; w -= w_rows; this.nodeSidebar = this.nodeRoot.a($$()).pos(true).x(0).y(0).w(w_rows).h(h).s('overflow:hidden').n('sidebar'); @@ -5802,7 +5802,7 @@ ac.chap.View.prototype.render = function(node) { if ( null == me.window.selection ) { - me.showCaret(true); + me.showCaret(true); } } }); @@ -5834,7 +5834,7 @@ ac.chap.View.prototype.renderSidebarStub = function() var node = this.nodeRoot; var h = node.$.offsetHeight; var w_rows = 58; - + this.nodeSidebar = $(this.nodeSidebar).rc(); var node_sidebar_scroll = this.nodeSidebar.a($$()).pos(true).w(w_rows).h(h).x(0).y(0).s('overflow:hidden'); var bar_offset = 0; @@ -5977,7 +5977,7 @@ ac.chap.View.prototype.renderChunk = function(chunk) rend_chunk += ch_encode_markup(chunk.substr(offset, i-offset)); if ( this.theme.colorScheme[token[0]] ) { - rend_chunk += '' + ch_encode_markup(token[1]) + ''; + rend_chunk += '' + ch_encode_markup(token[1]) + ''; } else { @@ -6057,7 +6057,7 @@ ac.chap.View.prototype.renderTextRow = function(node, rowIndex, renderedPrevious } else { - rendered_row += ''+ch_encode_markup(chunk)+''; + rendered_row += ''+ch_encode_markup(chunk)+''; // console.log(rendered_row); } } @@ -6066,7 +6066,7 @@ ac.chap.View.prototype.renderTextRow = function(node, rowIndex, renderedPrevious rendered_row += ch_encode_markup(chunk); } offset = -1 == end_offset ? row.length : end_offset; - } + } } rendered_row += this.renderChunk(row.substr(offset)); // console.log(rendered_row); @@ -6223,7 +6223,7 @@ ac.chap.View.prototype.renderTextRow = function(node, rowIndex, renderedPrevious rendered_row += '
'.embed(content); } node.setAttribute('num-subrows', num_subrows); - + if ( $__tune.isIE ) { // IE trims input source in innerHTML @@ -6308,12 +6308,12 @@ ac.chap.View.prototype.renderRowSidebar = function(position, rowIndex, rowNode, bar_node.firstChild.style.fontSize = (this.window.options.font.size-2) + 'px'; } // console.log(cache_id); - + var row_height = num_subrows * this.options.rowHeight; bar_node.parentNode.style.height = row_height + 'px'; if (forceCompleteRedraw) { - bar_node.firstChild.style.fontSize = (this.window.options.font.size-2) + 'px'; + bar_node.firstChild.style.fontSize = (this.window.options.font.size-2) + 'px'; } var ht = rowIndex+1; if ( this.options.wordWrap ) @@ -6342,7 +6342,7 @@ ac.chap.View.prototype.renderRowSidebar = function(position, rowIndex, rowNode, bar_node.lastChild.className = 'folding-expand'; } else - { + { if ( ac.chap.ROWSTATE_FOLD_START == (row_state & ac.chap.ROWSTATE_FOLD_START) ) { // folding starts @@ -6353,7 +6353,7 @@ ac.chap.View.prototype.renderRowSidebar = function(position, rowIndex, rowNode, { // folding stops bar_node.lastChild.className = 'folding-stop'; - } + } } } if ( ac.chap.ROWSTATE_BOOKMARK == (row_state & ac.chap.ROWSTATE_BOOKMARK) ) @@ -6364,7 +6364,7 @@ ac.chap.View.prototype.renderRowSidebar = function(position, rowIndex, rowNode, else { bar_node.firstChild.nextSibling.className = 'void'; - } + } } ac.chap.View.prototype.renderSelection = function() @@ -6482,12 +6482,12 @@ ac.chap.View.prototype.renderSelection = function() { // caret stays on the end of the row node_row_selection.style.left = (ix_c*this.options.colWidth) + 'px'; - node_row_selection.style.width = (node_row.offsetWidth - (ix_c*this.options.colWidth)) + 'px'; + node_row_selection.style.width = (node_row.offsetWidth - (ix_c*this.options.colWidth)) + 'px'; } else { node_row_selection.style.left = (offset[1]*this.options.colWidth) + 'px'; - node_row_selection.style.width = (node_row.offsetWidth - (offset[1]*this.options.colWidth)) + 'px'; + node_row_selection.style.width = (node_row.offsetWidth - (offset[1]*this.options.colWidth)) + 'px'; } // marking as non-cacheable node_row_selection.removeAttribute('cachid'); @@ -6502,7 +6502,7 @@ ac.chap.View.prototype.renderSelection = function() node_row_selection.style.height = this.options.rowHeight + 'px'; if ( ii != offset[2] ) { - node_row_selection.style.width = node_row.offsetWidth + 'px'; + node_row_selection.style.width = node_row.offsetWidth + 'px'; } else { @@ -6510,7 +6510,7 @@ ac.chap.View.prototype.renderSelection = function() } } } - + } else { @@ -6522,7 +6522,7 @@ ac.chap.View.prototype.renderSelection = function() } } // console.log('selection after range: %o', this.window.row_id_map[this.index][row_index][3]); - + } } // console.log('%o', this.window.row_id_map[this.index][0]); @@ -6602,7 +6602,7 @@ ac.chap.View.prototype.renderText = function(forceCompleteRedraw) // marking row as unchanged this.window.row_id_map[this.index][row_index][1] = true; - + var row_node = document.getElementById('row-'+this.window.instanceId+'-'+this.index+'-'+row_index); if ( !is_row_changed ) { @@ -6611,7 +6611,7 @@ ac.chap.View.prototype.renderText = function(forceCompleteRedraw) if ( null == row_node || null == row_node.parentNode ) { is_row_changed = true; - + // console.log(this.options.rowTemplate); row_node = this.options.rowTemplate.cloneNode(false); row_node.id = 'row-'+this.window.instanceId+'-'+this.index+'-'+row_index; @@ -6683,7 +6683,7 @@ ac.chap.View.prototype.renderText = function(forceCompleteRedraw) fill_area_h = this.nodeRoot.h()-$__tune.ui.scrollbarWidth; } this.nodeFillArea.h(fill_area_h); - + } else { @@ -6692,7 +6692,7 @@ ac.chap.View.prototype.renderText = function(forceCompleteRedraw) if ( parseInt(this.nodeSidebar.firstChild.style.top) != top_offset ) { this.nodeSidebar.firstChild.style.top = (top_offset)+'px'; - this.nodeSidebar.firstChild.style.height = (this.nodeSidebar.offsetHeight - $__tune.ui.scrollbarWidth - top_offset)+'px'; + this.nodeSidebar.firstChild.style.height = (this.nodeSidebar.offsetHeight - $__tune.ui.scrollbarWidth - top_offset)+'px'; } this.renderSelection(); } @@ -6839,7 +6839,7 @@ ac.chap.KeyMap.prototype.action_WordComplete = function(keyCode, controlKeysMask if ( words_next[i] && words_next[i].length > looking_for_len && words_next[i].substr(0, looking_for_len) == looking_for ) { if ( -1 == found_words_index.indexOf(' '+words_next[i]) ) - { + { found_words.push(words_next[i]); found_words_index += ' '+words_next[i]; } @@ -6915,7 +6915,7 @@ ac.chap.KeyMap.prototype.action_Indent = function(keyCode, controlKeysMask, care { if ('right' == params.direction) { - component.insertIntoCharacterMap(tab, i, 0); + component.insertIntoCharacterMap(tab, i, 0); } else { @@ -6928,7 +6928,7 @@ ac.chap.KeyMap.prototype.action_Indent = function(keyCode, controlKeysMask, care } } } - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; } ac.chap.KeyMap.prototype.action_Comment = function(keyCode, controlKeysMask, caretRow, caretCol, component, params) @@ -6962,13 +6962,13 @@ ac.chap.KeyMap.prototype.action_Comment = function(keyCode, controlKeysMask, car component.insertIntoCharacterMap(marker, i, 0); } } - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; } ac.chap.KeyMap.prototype.action_RuntimeOption = function(keyCode, controlKeysMask, caretRow, caretCol, component, params) { component.setRuntimeOption(params['key'], params['value']); - return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; + return ac.chap.ACTION_RES_REDRAWCARET | ac.chap.ACTION_RES_REDRAWTEXT | ac.chap.ACTION_RES_SELECTIONCHANGED; } ac.chap.KeyMap.prototype.action_SearchInteractive = function(keyCode, controlKeysMask, caretRow, caretCol, component, params) @@ -7075,7 +7075,7 @@ ac.chap.KeyMap.prototype.action_SmartIndent = function(keyCode, controlKeysMask, // console.log(prepend_text); if (params['split_line']) { - component.runAction(ac.chap.ACTION_INSERT, {row:true}); + component.runAction(ac.chap.ACTION_INSERT, {row:true}); } else { @@ -7116,7 +7116,7 @@ ac.chap.KeyMap.prototype.action_SmartUnindent = function(keyCode, controlKeysMas { proceed = true; break; - } + } } var prepend_text = null; if (proceed) @@ -7129,8 +7129,8 @@ ac.chap.KeyMap.prototype.action_SmartUnindent = function(keyCode, controlKeysMas line = component.getLineAt(row); var m = match_from_end ? line.match(/^([ \t]*)(.*)$/) : line.match(/([ \t]*)([^ \t]*)/); m[2] = m[2].trim(); - - + + for (i=0; i)/i, 0, ac.chap.CHUNK_OPERATOR], @@ -8064,10 +8064,10 @@ function showEditor(templateNode) templateNode = $(templateNode); var w = templateNode.w(); var h = templateNode.h(); - + var node = templateNode.p().ib($$(), templateNode).w(w).h(h); templateNode.d(false); - + var language = ac.chap.lang.JavaScript; var keymap = ac.chap.keymap.EAmyJavaScript; @@ -8113,7 +8113,7 @@ $__tune.event.addListener(self, 'load', function(evt) } break; } - } + } }); @@ -8137,7 +8137,8 @@ if (!self['console']) { var console = {info:function(){}}; console.log = console.error = console.warn = console.info; - + } + diff --git a/applications/admin/static/eamy/style.css b/applications/admin/static/eamy/style.css index 39c9ff55..d37fe893 100644 --- a/applications/admin/static/eamy/style.css +++ b/applications/admin/static/eamy/style.css @@ -16,7 +16,7 @@ .acw-chap .sidebar { background-image:url('chap-bg-sidebar.gif'); - line-height:11px; + line-height:11px; } /*.acw-chap .sidebar .row-number { @@ -52,5 +52,5 @@ } .acw-chap .void { - background-image:url('void.gif'); -} \ No newline at end of file + background-image:url('void.gif'); +} diff --git a/applications/admin/static/edit_area/autocompletion.js b/applications/admin/static/edit_area/autocompletion.js index c5d646a3..257da1ba 100755 --- a/applications/admin/static/edit_area/autocompletion.js +++ b/applications/admin/static/edit_area/autocompletion.js @@ -1,491 +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 || 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 || 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 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 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 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[i][1]['comment']; - if(results[i][0]['prefix_name'].length>0) - line+=''+ results[i][0]['prefix_name'] +''; - line+=''; - lines[lines.length]=line; - } - // sort results - this.container.innerHTML = '
    '+ lines.sort().join('') +'
'; - - 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 +/** + * 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 || 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 || 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 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 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 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[i][1]['comment']; + if(results[i][0]['prefix_name'].length>0) + line+=''+ results[i][0]['prefix_name'] +''; + line+=''; + lines[lines.length]=line; + } + // sort results + this.container.innerHTML = '
    '+ lines.sort().join('') +'
'; + + 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); diff --git a/applications/admin/static/edit_area/edit_area.css b/applications/admin/static/edit_area/edit_area.css index 172b366f..e78c0870 100755 --- a/applications/admin/static/edit_area/edit_area.css +++ b/applications/admin/static/edit_area/edit_area.css @@ -1,530 +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 +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; +} diff --git a/applications/admin/static/edit_area/edit_area.js b/applications/admin/static/edit_area/edit_area.js index 21e07a4c..4ec1339b 100755 --- a/applications/admin/static/edit_area/edit_area.js +++ b/applications/admin/static/edit_area/edit_area.js @@ -1,527 +1,528 @@ -/****** - * - * 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 tag - if( t.isIE >= 8 ) - t.isIE = 7; - - 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; i0) - 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= '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.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+='
'+i+"
"; - 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"); - } - }; - - 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("".replace(/Á/g,'this').replace(/Â/g,'textarea').replace(/Ã/g,'function').replace(/Ä/g,'prototype').replace(/Å/g,'settings').replace(/Æ/g,'length').replace(/Ç/g,'style').replace(/È/g,'parent').replace(/É/g,'last_selection').replace(/Ê/g,'value').replace(/Ë/g,'true').replace(/Ì/g,'false'); editAreaLoader.template= " EditArea [__CSSRULES__] [__JSCODE__]
[__TOOLBAR__]
 
 
{$position}: {$line_abbr} 0, {$char_abbr} 0 {$total}: {$line_abbr} 0, {$char_abbr} 0 resize
{$processing}
{$search} {$close_popup}
{$replace} {$move_popup}

{$find_next} {$replace} {$replace_all}
{$close_popup}

Editarea [__EA_VERSION__]


{$shortcuts}:

{$tab}: {$add_tab}
{$shift}+{$tab}: {$remove_tab}
{$ctrl}+f: {$search_command}
{$ctrl}+r: {$replace_command}
{$ctrl}+h: {$highlight}
{$ctrl}+g: {$go_to_line}
{$ctrl}+z: {$undo}
{$ctrl}+y: {$redo}
{$ctrl}+e: {$help}
{$ctrl}+q, {$esc}: {$close_popup}
{$accesskey} E: {$toggle}

{$about_notice}
"; editAreaLoader.iframe_css= ""; + diff --git a/applications/admin/static/edit_area/edit_area_full_with_plugins.js b/applications/admin/static/edit_area/edit_area_full_with_plugins.js index cf1492ea..26818a63 100755 --- a/applications/admin/static/edit_area/edit_area_full_with_plugins.js +++ b/applications/admin/static/edit_area/edit_area_full_with_plugins.js @@ -37,3 +37,4 @@ var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;editAreaLoader.ifra editAreaLoader.all_plugins_loaded=true; editAreaLoader.template= " EditArea [__CSSRULES__] [__JSCODE__]
[__TOOLBAR__]
 
 
{$position}: {$line_abbr} 0, {$char_abbr} 0 {$total}: {$line_abbr} 0, {$char_abbr} 0 resize
{$processing}
{$search} {$close_popup}
{$replace} {$move_popup}

{$find_next} {$replace} {$replace_all}
{$close_popup}

Editarea [__EA_VERSION__]


{$shortcuts}:

{$tab}: {$add_tab}
{$shift}+{$tab}: {$remove_tab}
{$ctrl}+f: {$search_command}
{$ctrl}+r: {$replace_command}
{$ctrl}+h: {$highlight}
{$ctrl}+g: {$go_to_line}
{$ctrl}+z: {$undo}
{$ctrl}+y: {$redo}
{$ctrl}+e: {$help}
{$ctrl}+q, {$esc}: {$close_popup}
{$accesskey} E: {$toggle}

{$about_notice}
"; editAreaLoader.iframe_css= ""; + diff --git a/applications/admin/static/edit_area/edit_area_functions.js b/applications/admin/static/edit_area/edit_area_functions.js index 4067b03a..539bcabb 100755 --- a/applications/admin/static/edit_area/edit_area_functions.js +++ b/applications/admin/static/edit_area/edit_area_functions.js @@ -1,1202 +1,1202 @@ - //replace tabulation by the good number of white spaces - EditArea.prototype.replace_tab= function(text){ - return text.replace(/((\n?)([^\t\n]*)\t)/gi, editArea.smartTab); // slower than simple replace... - }; - - // call by the replace_tab function - EditArea.prototype.smartTab= function(){ - val=" "; - return EditArea.prototype.smartTab.arguments[2] + EditArea.prototype.smartTab.arguments[3] + val.substr(0, editArea.tab_nb_char - (EditArea.prototype.smartTab.arguments[3].length)%editArea.tab_nb_char); - }; - - EditArea.prototype.show_waiting_screen= function(){ - width = this.editor_area.offsetWidth; - height = this.editor_area.offsetHeight; - if( !(this.isIE && this.isIE<6) ) - { - width -= 2; - height -= 2; - } - this.processing_screen.style.display= "block"; - this.processing_screen.style.width = width+"px"; - this.processing_screen.style.height = height+"px"; - this.waiting_screen_displayed = true; - }; - - EditArea.prototype.hide_waiting_screen= function(){ - this.processing_screen.style.display="none"; - this.waiting_screen_displayed= false; - }; - - EditArea.prototype.add_style= function(styles){ - if(styles.length>0){ - newcss = document.createElement("style"); - newcss.type="text/css"; - newcss.media="all"; - if(newcss.styleSheet){ // IE - newcss.styleSheet.cssText = styles; - } else { // W3C - newcss.appendChild(document.createTextNode(styles)); - } - document.getElementsByTagName("head")[0].appendChild(newcss); - } - }; - - EditArea.prototype.set_font= function(family, size){ - var t=this, a=this.textarea, s=this.settings, elem_font, i, elem; - // list all elements concerned by font changes - var elems= ["textarea", "content_highlight", "cursor_pos", "end_bracket", "selection_field", "selection_field_text", "line_number"]; - - if(family && family!="") - s["font_family"]= family; - if(size && size>0) - s["font_size"] = size; - if( t.isOpera && t.isOpera < 9.6 ) // opera<9.6 can't manage non monospace font - s['font_family']="monospace"; - - // update the select tag - if( elem_font = _$("area_font_size") ) - { - for( i = 0; i < elem_font.length; i++ ) - { - if( elem_font.options[i].value && elem_font.options[i].value == s["font_size"] ) - elem_font.options[i].selected=true; - } - } - - /* - * somethimes firefox has rendering mistake with non-monospace font for text width in textarea vs in div for changing font size (eg: verdana change between 11pt to 12pt) - * => looks like a browser internal random bug as text width can change while content_highlight is updated - * we'll check if the font-size produce the same text width inside textarea and div and if not, we'll increment the font-size - * - * This is an ugly fix - */ - if( t.isFirefox ) - { - var nbTry = 3; - do { - var div1 = document.createElement( 'div' ), text1 = document.createElement( 'textarea' ); - var styles = { - width: '40px', - overflow: 'scroll', - zIndex: 50, - visibility: 'hidden', - fontFamily: s["font_family"], - fontSize: s["font_size"]+"pt", - lineHeight: t.lineHeight+"px", - padding: '0', - margin: '0', - border: 'none', - whiteSpace: 'nowrap' - }; - var diff, changed = false; - for( i in styles ) - { - div1.style[ i ] = styles[i]; - text1.style[ i ] = styles[i]; - } - // no wrap for this text - text1.wrap = 'off'; - text1.setAttribute('wrap', 'off'); - t.container.appendChild( div1 ); - t.container.appendChild( text1 ); - // try to make FF to bug - div1.innerHTML = text1.value = 'azertyuiopqsdfghjklm'; - div1.innerHTML = text1.value = text1.value+'wxcvbn^p*ù$!:;,,'; + //replace tabulation by the good number of white spaces + EditArea.prototype.replace_tab= function(text){ + return text.replace(/((\n?)([^\t\n]*)\t)/gi, editArea.smartTab); // slower than simple replace... + }; + + // call by the replace_tab function + EditArea.prototype.smartTab= function(){ + val=" "; + return EditArea.prototype.smartTab.arguments[2] + EditArea.prototype.smartTab.arguments[3] + val.substr(0, editArea.tab_nb_char - (EditArea.prototype.smartTab.arguments[3].length)%editArea.tab_nb_char); + }; + + EditArea.prototype.show_waiting_screen= function(){ + width = this.editor_area.offsetWidth; + height = this.editor_area.offsetHeight; + if( !(this.isIE && this.isIE<6) ) + { + width -= 2; + height -= 2; + } + this.processing_screen.style.display= "block"; + this.processing_screen.style.width = width+"px"; + this.processing_screen.style.height = height+"px"; + this.waiting_screen_displayed = true; + }; + + EditArea.prototype.hide_waiting_screen= function(){ + this.processing_screen.style.display="none"; + this.waiting_screen_displayed= false; + }; + + EditArea.prototype.add_style= function(styles){ + if(styles.length>0){ + newcss = document.createElement("style"); + newcss.type="text/css"; + newcss.media="all"; + if(newcss.styleSheet){ // IE + newcss.styleSheet.cssText = styles; + } else { // W3C + newcss.appendChild(document.createTextNode(styles)); + } + document.getElementsByTagName("head")[0].appendChild(newcss); + } + }; + + EditArea.prototype.set_font= function(family, size){ + var t=this, a=this.textarea, s=this.settings, elem_font, i, elem; + // list all elements concerned by font changes + var elems= ["textarea", "content_highlight", "cursor_pos", "end_bracket", "selection_field", "selection_field_text", "line_number"]; + + if(family && family!="") + s["font_family"]= family; + if(size && size>0) + s["font_size"] = size; + if( t.isOpera && t.isOpera < 9.6 ) // opera<9.6 can't manage non monospace font + s['font_family']="monospace"; + + // update the select tag + if( elem_font = _$("area_font_size") ) + { + for( i = 0; i < elem_font.length; i++ ) + { + if( elem_font.options[i].value && elem_font.options[i].value == s["font_size"] ) + elem_font.options[i].selected=true; + } + } + + /* + * somethimes firefox has rendering mistake with non-monospace font for text width in textarea vs in div for changing font size (eg: verdana change between 11pt to 12pt) + * => looks like a browser internal random bug as text width can change while content_highlight is updated + * we'll check if the font-size produce the same text width inside textarea and div and if not, we'll increment the font-size + * + * This is an ugly fix + */ + if( t.isFirefox ) + { + var nbTry = 3; + do { + var div1 = document.createElement( 'div' ), text1 = document.createElement( 'textarea' ); + var styles = { + width: '40px', + overflow: 'scroll', + zIndex: 50, + visibility: 'hidden', + fontFamily: s["font_family"], + fontSize: s["font_size"]+"pt", + lineHeight: t.lineHeight+"px", + padding: '0', + margin: '0', + border: 'none', + whiteSpace: 'nowrap' + }; + var diff, changed = false; + for( i in styles ) + { + div1.style[ i ] = styles[i]; + text1.style[ i ] = styles[i]; + } + // no wrap for this text + text1.wrap = 'off'; + text1.setAttribute('wrap', 'off'); + t.container.appendChild( div1 ); + t.container.appendChild( text1 ); + // try to make FF to bug + div1.innerHTML = text1.value = 'azertyuiopqsdfghjklm'; + div1.innerHTML = text1.value = text1.value+'wxcvbn^p*ù$!:;,,'; diff = text1.scrollWidth - div1.scrollWidth; - - // firefox return here a diff of 1 px between equals scrollWidth (can't explain) - if( Math.abs( diff ) >= 2 ) - { - s["font_size"]++; - changed = true; - } - t.container.removeChild( div1 ); - t.container.removeChild( text1 ); - nbTry--; - }while( changed && nbTry > 0 ); - } - - - // calc line height - elem = t.test_font_size; - elem.style.fontFamily = ""+s["font_family"]; - elem.style.fontSize = s["font_size"]+"pt"; - elem.innerHTML = "0"; - t.lineHeight = elem.offsetHeight; - - // update font for all concerned elements - for( i=0; i tags - t.add_style("pre{font-family:"+s["font_family"]+"}"); - - // old opera and IE>=8 doesn't update font changes to the textarea - if( ( t.isOpera && t.isOpera < 9.6 ) || t.isIE >= 8 ) - { - var parNod = a.parentNode, nxtSib = a.nextSibling, start= a.selectionStart, end= a.selectionEnd; - parNod.removeChild(a); - parNod.insertBefore(a, nxtSib); - t.area_select(start, end-start); - } - - // force update of selection field - this.focus(); - this.update_size(); - this.check_line_selection(); - }; - - EditArea.prototype.change_font_size= function(){ - var size=_$("area_font_size").value; - if(size>0) - this.set_font("", size); - }; - - - EditArea.prototype.open_inline_popup= function(popup_id){ - this.close_all_inline_popup(); - var popup= _$(popup_id); - var editor= _$("editor"); - - // search matching icon - for(var i=0; i lines.length) - start= this.textarea.value.length; - else{ - for(var i=0; i0){ - //alert(miss_top); - zone.scrollTop= zone.scrollTop + miss_top; - }else if( zone.scrollTop > cursor_pos_top){ - // when erase all the content -> does'nt scroll back to the top - //alert("else: "+cursor_pos_top); - zone.scrollTop= cursor_pos_top; - } - - // manage left scroll - //var cursor_pos_left= parseInt(_$("cursor_pos").style.left.replace("px","")); - var cursor_pos_left= _$("cursor_pos").cursor_left; - var max_width_visible= zone.clientWidth + zone.scrollLeft; - var miss_left= cursor_pos_left + 10 - max_width_visible; - if(miss_left>0){ - zone.scrollLeft= zone.scrollLeft + miss_left + 50; - }else if( zone.scrollLeft > cursor_pos_left){ - zone.scrollLeft= cursor_pos_left ; - }else if( zone.scrollLeft == 45){ - // show the line numbers if textarea align to it's left - zone.scrollLeft=0; - } - }; - - EditArea.prototype.check_undo= function(only_once){ - if(!editAreas[this.id]) - return false; - if(this.textareaFocused && editAreas[this.id]["displayed"]==true){ - var text=this.textarea.value; - if(this.previous.length<=1) - this.switchClassSticky(_$("undo"), 'editAreaButtonDisabled', true); - - if(!this.previous[this.previous.length-1] || this.previous[this.previous.length-1]["text"] != text){ - this.previous.push({"text": text, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd}); - if(this.previous.length > this.settings["max_undo"]+1) - this.previous.shift(); - - } - if(this.previous.length >= 2) - this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false); - } - - if(!only_once) - setTimeout("editArea.check_undo()", 3000); - }; - - EditArea.prototype.undo= function(){ - //alert("undo"+this.previous.length); - if(this.previous.length > 0) - { - this.getIESelection(); - // var pos_cursor=this.textarea.selectionStart; - this.next.push( { "text": this.textarea.value, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd } ); - var prev= this.previous.pop(); - if( prev["text"] == this.textarea.value && this.previous.length > 0 ) - prev =this.previous.pop(); - this.textarea.value = prev["text"]; - this.last_undo = prev["text"]; - this.area_select(prev["selStart"], prev["selEnd"]-prev["selStart"]); - this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false); - this.resync_highlight(true); - //alert("undo"+this.previous.length); - this.check_file_changes(); - } - }; - - EditArea.prototype.redo= function(){ - if(this.next.length > 0) - { - /*this.getIESelection();*/ - //var pos_cursor=this.textarea.selectionStart; - var next= this.next.pop(); - this.previous.push(next); - this.textarea.value= next["text"]; - this.last_undo= next["text"]; - this.area_select(next["selStart"], next["selEnd"]-next["selStart"]); - this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false); - this.resync_highlight(true); - this.check_file_changes(); - } - if( this.next.length == 0) - this.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true); - }; - - EditArea.prototype.check_redo= function(){ - if(editArea.next.length == 0 || editArea.textarea.value!=editArea.last_undo){ - editArea.next= []; // undo the ability to use "redo" button - editArea.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true); - } - else - { - this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false); - } - }; - - - // functions that manage icons roll over, disabled, etc... - EditArea.prototype.switchClass = function(element, class_name, lock_state) { - var lockChanged = false; - - if (typeof(lock_state) != "undefined" && element != null) { - element.classLock = lock_state; - lockChanged = true; - } - - if (element != null && (lockChanged || !element.classLock)) { - element.oldClassName = element.className; - element.className = class_name; - } - }; - - EditArea.prototype.restoreAndSwitchClass = function(element, class_name) { - if (element != null && !element.classLock) { - this.restoreClass(element); - this.switchClass(element, class_name); - } - }; - - EditArea.prototype.restoreClass = function(element) { - if (element != null && element.oldClassName && !element.classLock) { - element.className = element.oldClassName; - element.oldClassName = null; - } - }; - - EditArea.prototype.setClassLock = function(element, lock_state) { - if (element != null) - element.classLock = lock_state; - }; - - EditArea.prototype.switchClassSticky = function(element, class_name, lock_state) { - var lockChanged = false; - if (typeof(lock_state) != "undefined" && element != null) { - element.classLock = lock_state; - lockChanged = true; - } - - if (element != null && (lockChanged || !element.classLock)) { - element.className = class_name; - element.oldClassName = class_name; - } - }; - - //make the "page up" and "page down" buttons works correctly - EditArea.prototype.scroll_page= function(params){ - var dir= params["dir"], shift_pressed= params["shift"]; - var lines= this.textarea.value.split("\n"); - var new_pos=0, length=0, char_left=0, line_nb=0, curLine=0; - var toScrollAmount = _$("result").clientHeight -30; - var nbLineToScroll = 0, diff= 0; - - if(dir=="up"){ - nbLineToScroll = Math.ceil( toScrollAmount / this.lineHeight ); - - // fix number of line to scroll - for( i = this.last_selection["line_start"]; i - diff > this.last_selection["line_start"] - nbLineToScroll ; i-- ) - { - if( elem = _$('line_'+ i) ) - { - diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight ); - } - } - nbLineToScroll -= diff; - - if(this.last_selection["selec_direction"]=="up"){ - for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]-nbLineToScroll, lines.length); line_nb++){ - new_pos+= lines[line_nb].length + 1; - } - char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); - if(shift_pressed) - length=this.last_selection["selectionEnd"]-new_pos-char_left; - this.area_select(new_pos+char_left, length); - view="top"; - }else{ - view="bottom"; - for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-1-nbLineToScroll, lines.length); line_nb++){ - new_pos+= lines[line_nb].length + 1; - } - char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); - if(shift_pressed){ - //length=this.last_selection["selectionEnd"]-new_pos-char_left; - start= Math.min(this.last_selection["selectionStart"], new_pos+char_left); - length= Math.max(new_pos+char_left, this.last_selection["selectionStart"] )- start ; - if(new_pos+char_left < this.last_selection["selectionStart"]) - view="top"; - }else - start=new_pos+char_left; - this.area_select(start, length); - - } - } - else - { - var nbLineToScroll= Math.floor( toScrollAmount / this.lineHeight ); - // fix number of line to scroll - for( i = this.last_selection["line_start"]; i + diff < this.last_selection["line_start"] + nbLineToScroll ; i++ ) - { - if( elem = _$('line_'+ i) ) - { - diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight ); - } - } - nbLineToScroll -= diff; - - if(this.last_selection["selec_direction"]=="down"){ - view="bottom"; - for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-2+nbLineToScroll, lines.length); line_nb++){ - if(line_nb==this.last_selection["line_start"]-1) - char_left= this.last_selection["selectionStart"] -new_pos; - new_pos+= lines[line_nb].length + 1; - - } - if(shift_pressed){ - length=Math.abs(this.last_selection["selectionStart"]-new_pos); - length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]); - //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); - this.area_select(Math.min(this.last_selection["selectionStart"], new_pos), length); - }else{ - this.area_select(new_pos+char_left, 0); - } - - }else{ - view="top"; - for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+nbLineToScroll-1, lines.length, lines.length); line_nb++){ - if(line_nb==this.last_selection["line_start"]-1) - char_left= this.last_selection["selectionStart"] -new_pos; - new_pos+= lines[line_nb].length + 1; - } - if(shift_pressed){ - length=Math.abs(this.last_selection["selectionEnd"]-new_pos-char_left); - length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"])- char_left-1; - //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); - this.area_select(Math.min(this.last_selection["selectionEnd"], new_pos+char_left), length); - if(new_pos+char_left > this.last_selection["selectionEnd"]) - view="bottom"; - }else{ - this.area_select(new_pos+char_left, 0); - } - - } - } - //console.log( new_pos, char_left, length, nbLineToScroll, toScrollAmount, _$("result").clientHeigh ); - this.check_line_selection(); - this.scroll_to_view(view); - }; - - EditArea.prototype.start_resize= function(e){ - parent.editAreaLoader.resize["id"] = editArea.id; - parent.editAreaLoader.resize["start_x"] = (e)? e.pageX : event.x + document.body.scrollLeft; - parent.editAreaLoader.resize["start_y"] = (e)? e.pageY : event.y + document.body.scrollTop; - if(editArea.isIE) - { - editArea.textarea.focus(); - editArea.getIESelection(); - } - parent.editAreaLoader.resize["selectionStart"] = editArea.textarea.selectionStart; - parent.editAreaLoader.resize["selectionEnd"] = editArea.textarea.selectionEnd; - parent.editAreaLoader.start_resize_area(); - }; - - EditArea.prototype.toggle_full_screen= function(to){ - var t=this, p=parent, a=t.textarea, html, frame, selStart, selEnd, old, icon; - if(typeof(to)=="undefined") - to= !t.fullscreen['isFull']; - old = t.fullscreen['isFull']; - t.fullscreen['isFull']= to; - icon = _$("fullscreen"); - selStart = t.textarea.selectionStart; - selEnd = t.textarea.selectionEnd; - html = p.document.getElementsByTagName("html")[0]; - frame = p.document.getElementById("frame_"+t.id); - - if(to && to!=old) - { // toogle on fullscreen - - t.fullscreen['old_overflow'] = p.get_css_property(html, "overflow"); - t.fullscreen['old_height'] = p.get_css_property(html, "height"); - t.fullscreen['old_width'] = p.get_css_property(html, "width"); - t.fullscreen['old_scrollTop'] = html.scrollTop; - t.fullscreen['old_scrollLeft'] = html.scrollLeft; - t.fullscreen['old_zIndex'] = p.get_css_property(frame, "z-index"); - if(t.isOpera){ - html.style.height = "100%"; - html.style.width = "100%"; - } - html.style.overflow = "hidden"; - html.scrollTop = 0; - html.scrollLeft = 0; - - frame.style.position = "absolute"; - frame.style.width = html.clientWidth+"px"; - frame.style.height = html.clientHeight+"px"; - frame.style.display = "block"; - frame.style.zIndex = "999999"; - frame.style.top = "0px"; - frame.style.left = "0px"; - - // if the iframe was in a div with position absolute, the top and left are the one of the div, - // so I fix it by seeing at witch position the iframe start and correcting it - frame.style.top = "-"+p.calculeOffsetTop(frame)+"px"; - frame.style.left = "-"+p.calculeOffsetLeft(frame)+"px"; - - // parent.editAreaLoader.execCommand(t.id, "update_size();"); - // var body=parent.document.getElementsByTagName("body")[0]; - // body.appendChild(frame); - - t.switchClassSticky(icon, 'editAreaButtonSelected', false); - t.fullscreen['allow_resize']= t.resize_allowed; - t.allow_resize(false); - - //t.area_select(selStart, selEnd-selStart); - - - // opera can't manage to do a direct size update - if(t.isFirefox){ - p.editAreaLoader.execCommand(t.id, "update_size();"); - t.area_select(selStart, selEnd-selStart); - t.scroll_to_view(); - t.focus(); - }else{ - setTimeout("parent.editAreaLoader.execCommand('"+ t.id +"', 'update_size();');editArea.focus();", 10); - } - - - } - else if(to!=old) - { // toogle off fullscreen - frame.style.position="static"; - frame.style.zIndex= t.fullscreen['old_zIndex']; - - if(t.isOpera) - { - html.style.height = "auto"; - html.style.width = "auto"; - html.style.overflow = "auto"; - } - else if(t.isIE && p!=top) - { // IE doesn't manage html overflow in frames like in normal page... - html.style.overflow = "auto"; - } - else - { - html.style.overflow = t.fullscreen['old_overflow']; - } - html.scrollTop = t.fullscreen['old_scrollTop']; - html.scrollLeft = t.fullscreen['old_scrollLeft']; - - p.editAreaLoader.hide(t.id); - p.editAreaLoader.show(t.id); - - t.switchClassSticky(icon, 'editAreaButtonNormal', false); - if(t.fullscreen['allow_resize']) - t.allow_resize(t.fullscreen['allow_resize']); - if(t.isFirefox){ - t.area_select(selStart, selEnd-selStart); - setTimeout("editArea.scroll_to_view();", 10); - } - - //p.editAreaLoader.remove_event(p.window, "resize", editArea.update_size); - } - - }; - - EditArea.prototype.allow_resize= function(allow){ - var resize= _$("resize_area"); - if(allow){ - - resize.style.visibility="visible"; - parent.editAreaLoader.add_event(resize, "mouseup", editArea.start_resize); - }else{ - resize.style.visibility="hidden"; - parent.editAreaLoader.remove_event(resize, "mouseup", editArea.start_resize); - } - this.resize_allowed= allow; - }; - - - EditArea.prototype.change_syntax= function(new_syntax, is_waiting){ - // alert("cahnge to "+new_syntax); - // the syntax is the same - if(new_syntax==this.settings['syntax']) - return true; - - // check that the syntax is one allowed - var founded= false; - for(var i=0; i"; - elem.innerHTML= "*"+ this.files[id]['title'] + close +""; - _$('tab_browsing_list').appendChild(elem); - var elem= document.createElement('text'); - this.update_size(); - } - - // open file callback (for plugin) - if(id!="") - this.execCommand('file_open', this.files[id]); - - this.switch_to_file(id, true); - return true; - } - else - return false; - }; - - // close the given file - EditArea.prototype.close_file= function(id){ - if(this.files[id]) - { - this.save_file(id); - - // close file callback - if(this.execCommand('file_close', this.files[id])!==false) - { - // remove the tab in the toolbar - var li= _$(this.files[id]['html_id']); - li.parentNode.removeChild(li); - // select a new file - if(id== this.curr_file) - { - var next_file= ""; - var is_next= false; - for(var i in this.files) - { - if( is_next ) - { - next_file = i; - break; - } - else if( i == id ) - is_next = true; - else - next_file = i; - } - // display the next file - this.switch_to_file(next_file); - } - // clear datas - delete (this.files[id]); - this.update_size(); - } - } - }; - - // backup current file datas - EditArea.prototype.save_file= function(id){ - var t= this, save, a_links, a_selects, save_butt, img, i; - if(t.files[id]) - { - var save= t.files[id]; - save['last_selection'] = t.last_selection; - save['last_text_to_highlight'] = t.last_text_to_highlight; - save['last_hightlighted_text'] = t.last_hightlighted_text; - save['previous'] = t.previous; - save['next'] = t.next; - save['last_undo'] = t.last_undo; - save['smooth_selection'] = t.smooth_selection; - save['do_highlight'] = t.do_highlight; - save['syntax'] = t.settings['syntax']; - save['text'] = t.textarea.value; - save['scroll_top'] = t.result.scrollTop; - save['scroll_left'] = t.result.scrollLeft; - save['selection_start'] = t.last_selection["selectionStart"]; - save['selection_end'] = t.last_selection["selectionEnd"]; - save['font_size'] = t.settings["font_size"]; - save['font_family'] = t.settings["font_family"]; - save['word_wrap'] = t.settings["word_wrap"]; - save['toolbar'] = {'links':{}, 'selects': {}}; - - // save toolbar buttons state for fileSpecific buttons - a_links= _$("toolbar_1").getElementsByTagName("a"); - for( i=0; i= 2 ) + { + s["font_size"]++; + changed = true; + } + t.container.removeChild( div1 ); + t.container.removeChild( text1 ); + nbTry--; + }while( changed && nbTry > 0 ); + } + + + // calc line height + elem = t.test_font_size; + elem.style.fontFamily = ""+s["font_family"]; + elem.style.fontSize = s["font_size"]+"pt"; + elem.innerHTML = "0"; + t.lineHeight = elem.offsetHeight; + + // update font for all concerned elements + for( i=0; i tags + t.add_style("pre{font-family:"+s["font_family"]+"}"); + + // old opera and IE>=8 doesn't update font changes to the textarea + if( ( t.isOpera && t.isOpera < 9.6 ) || t.isIE >= 8 ) + { + var parNod = a.parentNode, nxtSib = a.nextSibling, start= a.selectionStart, end= a.selectionEnd; + parNod.removeChild(a); + parNod.insertBefore(a, nxtSib); + t.area_select(start, end-start); + } + + // force update of selection field + this.focus(); + this.update_size(); + this.check_line_selection(); + }; + + EditArea.prototype.change_font_size= function(){ + var size=_$("area_font_size").value; + if(size>0) + this.set_font("", size); + }; + + + EditArea.prototype.open_inline_popup= function(popup_id){ + this.close_all_inline_popup(); + var popup= _$(popup_id); + var editor= _$("editor"); + + // search matching icon + for(var i=0; i lines.length) + start= this.textarea.value.length; + else{ + for(var i=0; i0){ + //alert(miss_top); + zone.scrollTop= zone.scrollTop + miss_top; + }else if( zone.scrollTop > cursor_pos_top){ + // when erase all the content -> does'nt scroll back to the top + //alert("else: "+cursor_pos_top); + zone.scrollTop= cursor_pos_top; + } + + // manage left scroll + //var cursor_pos_left= parseInt(_$("cursor_pos").style.left.replace("px","")); + var cursor_pos_left= _$("cursor_pos").cursor_left; + var max_width_visible= zone.clientWidth + zone.scrollLeft; + var miss_left= cursor_pos_left + 10 - max_width_visible; + if(miss_left>0){ + zone.scrollLeft= zone.scrollLeft + miss_left + 50; + }else if( zone.scrollLeft > cursor_pos_left){ + zone.scrollLeft= cursor_pos_left ; + }else if( zone.scrollLeft == 45){ + // show the line numbers if textarea align to it's left + zone.scrollLeft=0; + } + }; + + EditArea.prototype.check_undo= function(only_once){ + if(!editAreas[this.id]) + return false; + if(this.textareaFocused && editAreas[this.id]["displayed"]==true){ + var text=this.textarea.value; + if(this.previous.length<=1) + this.switchClassSticky(_$("undo"), 'editAreaButtonDisabled', true); + + if(!this.previous[this.previous.length-1] || this.previous[this.previous.length-1]["text"] != text){ + this.previous.push({"text": text, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd}); + if(this.previous.length > this.settings["max_undo"]+1) + this.previous.shift(); + + } + if(this.previous.length >= 2) + this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false); + } + + if(!only_once) + setTimeout("editArea.check_undo()", 3000); + }; + + EditArea.prototype.undo= function(){ + //alert("undo"+this.previous.length); + if(this.previous.length > 0) + { + this.getIESelection(); + // var pos_cursor=this.textarea.selectionStart; + this.next.push( { "text": this.textarea.value, "selStart": this.textarea.selectionStart, "selEnd": this.textarea.selectionEnd } ); + var prev= this.previous.pop(); + if( prev["text"] == this.textarea.value && this.previous.length > 0 ) + prev =this.previous.pop(); + this.textarea.value = prev["text"]; + this.last_undo = prev["text"]; + this.area_select(prev["selStart"], prev["selEnd"]-prev["selStart"]); + this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false); + this.resync_highlight(true); + //alert("undo"+this.previous.length); + this.check_file_changes(); + } + }; + + EditArea.prototype.redo= function(){ + if(this.next.length > 0) + { + /*this.getIESelection();*/ + //var pos_cursor=this.textarea.selectionStart; + var next= this.next.pop(); + this.previous.push(next); + this.textarea.value= next["text"]; + this.last_undo= next["text"]; + this.area_select(next["selStart"], next["selEnd"]-next["selStart"]); + this.switchClassSticky(_$("undo"), 'editAreaButtonNormal', false); + this.resync_highlight(true); + this.check_file_changes(); + } + if( this.next.length == 0) + this.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true); + }; + + EditArea.prototype.check_redo= function(){ + if(editArea.next.length == 0 || editArea.textarea.value!=editArea.last_undo){ + editArea.next= []; // undo the ability to use "redo" button + editArea.switchClassSticky(_$("redo"), 'editAreaButtonDisabled', true); + } + else + { + this.switchClassSticky(_$("redo"), 'editAreaButtonNormal', false); + } + }; + + + // functions that manage icons roll over, disabled, etc... + EditArea.prototype.switchClass = function(element, class_name, lock_state) { + var lockChanged = false; + + if (typeof(lock_state) != "undefined" && element != null) { + element.classLock = lock_state; + lockChanged = true; + } + + if (element != null && (lockChanged || !element.classLock)) { + element.oldClassName = element.className; + element.className = class_name; + } + }; + + EditArea.prototype.restoreAndSwitchClass = function(element, class_name) { + if (element != null && !element.classLock) { + this.restoreClass(element); + this.switchClass(element, class_name); + } + }; + + EditArea.prototype.restoreClass = function(element) { + if (element != null && element.oldClassName && !element.classLock) { + element.className = element.oldClassName; + element.oldClassName = null; + } + }; + + EditArea.prototype.setClassLock = function(element, lock_state) { + if (element != null) + element.classLock = lock_state; + }; + + EditArea.prototype.switchClassSticky = function(element, class_name, lock_state) { + var lockChanged = false; + if (typeof(lock_state) != "undefined" && element != null) { + element.classLock = lock_state; + lockChanged = true; + } + + if (element != null && (lockChanged || !element.classLock)) { + element.className = class_name; + element.oldClassName = class_name; + } + }; + + //make the "page up" and "page down" buttons works correctly + EditArea.prototype.scroll_page= function(params){ + var dir= params["dir"], shift_pressed= params["shift"]; + var lines= this.textarea.value.split("\n"); + var new_pos=0, length=0, char_left=0, line_nb=0, curLine=0; + var toScrollAmount = _$("result").clientHeight -30; + var nbLineToScroll = 0, diff= 0; + + if(dir=="up"){ + nbLineToScroll = Math.ceil( toScrollAmount / this.lineHeight ); + + // fix number of line to scroll + for( i = this.last_selection["line_start"]; i - diff > this.last_selection["line_start"] - nbLineToScroll ; i-- ) + { + if( elem = _$('line_'+ i) ) + { + diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight ); + } + } + nbLineToScroll -= diff; + + if(this.last_selection["selec_direction"]=="up"){ + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]-nbLineToScroll, lines.length); line_nb++){ + new_pos+= lines[line_nb].length + 1; + } + char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); + if(shift_pressed) + length=this.last_selection["selectionEnd"]-new_pos-char_left; + this.area_select(new_pos+char_left, length); + view="top"; + }else{ + view="bottom"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-1-nbLineToScroll, lines.length); line_nb++){ + new_pos+= lines[line_nb].length + 1; + } + char_left=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]-1); + if(shift_pressed){ + //length=this.last_selection["selectionEnd"]-new_pos-char_left; + start= Math.min(this.last_selection["selectionStart"], new_pos+char_left); + length= Math.max(new_pos+char_left, this.last_selection["selectionStart"] )- start ; + if(new_pos+char_left < this.last_selection["selectionStart"]) + view="top"; + }else + start=new_pos+char_left; + this.area_select(start, length); + + } + } + else + { + var nbLineToScroll= Math.floor( toScrollAmount / this.lineHeight ); + // fix number of line to scroll + for( i = this.last_selection["line_start"]; i + diff < this.last_selection["line_start"] + nbLineToScroll ; i++ ) + { + if( elem = _$('line_'+ i) ) + { + diff += Math.floor( ( elem.offsetHeight - 1 ) / this.lineHeight ); + } + } + nbLineToScroll -= diff; + + if(this.last_selection["selec_direction"]=="down"){ + view="bottom"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+this.last_selection["line_nb"]-2+nbLineToScroll, lines.length); line_nb++){ + if(line_nb==this.last_selection["line_start"]-1) + char_left= this.last_selection["selectionStart"] -new_pos; + new_pos+= lines[line_nb].length + 1; + + } + if(shift_pressed){ + length=Math.abs(this.last_selection["selectionStart"]-new_pos); + length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"]); + //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); + this.area_select(Math.min(this.last_selection["selectionStart"], new_pos), length); + }else{ + this.area_select(new_pos+char_left, 0); + } + + }else{ + view="top"; + for(line_nb=0; line_nb< Math.min(this.last_selection["line_start"]+nbLineToScroll-1, lines.length, lines.length); line_nb++){ + if(line_nb==this.last_selection["line_start"]-1) + char_left= this.last_selection["selectionStart"] -new_pos; + new_pos+= lines[line_nb].length + 1; + } + if(shift_pressed){ + length=Math.abs(this.last_selection["selectionEnd"]-new_pos-char_left); + length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, this.last_selection["curr_pos"])- char_left-1; + //length+=Math.min(lines[Math.min(lines.length-1, line_nb)].length, char_left); + this.area_select(Math.min(this.last_selection["selectionEnd"], new_pos+char_left), length); + if(new_pos+char_left > this.last_selection["selectionEnd"]) + view="bottom"; + }else{ + this.area_select(new_pos+char_left, 0); + } + + } + } + //console.log( new_pos, char_left, length, nbLineToScroll, toScrollAmount, _$("result").clientHeigh ); + this.check_line_selection(); + this.scroll_to_view(view); + }; + + EditArea.prototype.start_resize= function(e){ + parent.editAreaLoader.resize["id"] = editArea.id; + parent.editAreaLoader.resize["start_x"] = (e)? e.pageX : event.x + document.body.scrollLeft; + parent.editAreaLoader.resize["start_y"] = (e)? e.pageY : event.y + document.body.scrollTop; + if(editArea.isIE) + { + editArea.textarea.focus(); + editArea.getIESelection(); + } + parent.editAreaLoader.resize["selectionStart"] = editArea.textarea.selectionStart; + parent.editAreaLoader.resize["selectionEnd"] = editArea.textarea.selectionEnd; + parent.editAreaLoader.start_resize_area(); + }; + + EditArea.prototype.toggle_full_screen= function(to){ + var t=this, p=parent, a=t.textarea, html, frame, selStart, selEnd, old, icon; + if(typeof(to)=="undefined") + to= !t.fullscreen['isFull']; + old = t.fullscreen['isFull']; + t.fullscreen['isFull']= to; + icon = _$("fullscreen"); + selStart = t.textarea.selectionStart; + selEnd = t.textarea.selectionEnd; + html = p.document.getElementsByTagName("html")[0]; + frame = p.document.getElementById("frame_"+t.id); + + if(to && to!=old) + { // toogle on fullscreen + + t.fullscreen['old_overflow'] = p.get_css_property(html, "overflow"); + t.fullscreen['old_height'] = p.get_css_property(html, "height"); + t.fullscreen['old_width'] = p.get_css_property(html, "width"); + t.fullscreen['old_scrollTop'] = html.scrollTop; + t.fullscreen['old_scrollLeft'] = html.scrollLeft; + t.fullscreen['old_zIndex'] = p.get_css_property(frame, "z-index"); + if(t.isOpera){ + html.style.height = "100%"; + html.style.width = "100%"; + } + html.style.overflow = "hidden"; + html.scrollTop = 0; + html.scrollLeft = 0; + + frame.style.position = "absolute"; + frame.style.width = html.clientWidth+"px"; + frame.style.height = html.clientHeight+"px"; + frame.style.display = "block"; + frame.style.zIndex = "999999"; + frame.style.top = "0px"; + frame.style.left = "0px"; + + // if the iframe was in a div with position absolute, the top and left are the one of the div, + // so I fix it by seeing at witch position the iframe start and correcting it + frame.style.top = "-"+p.calculeOffsetTop(frame)+"px"; + frame.style.left = "-"+p.calculeOffsetLeft(frame)+"px"; + + // parent.editAreaLoader.execCommand(t.id, "update_size();"); + // var body=parent.document.getElementsByTagName("body")[0]; + // body.appendChild(frame); + + t.switchClassSticky(icon, 'editAreaButtonSelected', false); + t.fullscreen['allow_resize']= t.resize_allowed; + t.allow_resize(false); + + //t.area_select(selStart, selEnd-selStart); + + + // opera can't manage to do a direct size update + if(t.isFirefox){ + p.editAreaLoader.execCommand(t.id, "update_size();"); + t.area_select(selStart, selEnd-selStart); + t.scroll_to_view(); + t.focus(); + }else{ + setTimeout("parent.editAreaLoader.execCommand('"+ t.id +"', 'update_size();');editArea.focus();", 10); + } + + + } + else if(to!=old) + { // toogle off fullscreen + frame.style.position="static"; + frame.style.zIndex= t.fullscreen['old_zIndex']; + + if(t.isOpera) + { + html.style.height = "auto"; + html.style.width = "auto"; + html.style.overflow = "auto"; + } + else if(t.isIE && p!=top) + { // IE doesn't manage html overflow in frames like in normal page... + html.style.overflow = "auto"; + } + else + { + html.style.overflow = t.fullscreen['old_overflow']; + } + html.scrollTop = t.fullscreen['old_scrollTop']; + html.scrollLeft = t.fullscreen['old_scrollLeft']; + + p.editAreaLoader.hide(t.id); + p.editAreaLoader.show(t.id); + + t.switchClassSticky(icon, 'editAreaButtonNormal', false); + if(t.fullscreen['allow_resize']) + t.allow_resize(t.fullscreen['allow_resize']); + if(t.isFirefox){ + t.area_select(selStart, selEnd-selStart); + setTimeout("editArea.scroll_to_view();", 10); + } + + //p.editAreaLoader.remove_event(p.window, "resize", editArea.update_size); + } + + }; + + EditArea.prototype.allow_resize= function(allow){ + var resize= _$("resize_area"); + if(allow){ + + resize.style.visibility="visible"; + parent.editAreaLoader.add_event(resize, "mouseup", editArea.start_resize); + }else{ + resize.style.visibility="hidden"; + parent.editAreaLoader.remove_event(resize, "mouseup", editArea.start_resize); + } + this.resize_allowed= allow; + }; + + + EditArea.prototype.change_syntax= function(new_syntax, is_waiting){ + // alert("cahnge to "+new_syntax); + // the syntax is the same + if(new_syntax==this.settings['syntax']) + return true; + + // check that the syntax is one allowed + var founded= false; + for(var i=0; i"; + elem.innerHTML= "*"+ this.files[id]['title'] + close +""; + _$('tab_browsing_list').appendChild(elem); + var elem= document.createElement('text'); + this.update_size(); + } + + // open file callback (for plugin) + if(id!="") + this.execCommand('file_open', this.files[id]); + + this.switch_to_file(id, true); + return true; + } + else + return false; + }; + + // close the given file + EditArea.prototype.close_file= function(id){ + if(this.files[id]) + { + this.save_file(id); + + // close file callback + if(this.execCommand('file_close', this.files[id])!==false) + { + // remove the tab in the toolbar + var li= _$(this.files[id]['html_id']); + li.parentNode.removeChild(li); + // select a new file + if(id== this.curr_file) + { + var next_file= ""; + var is_next= false; + for(var i in this.files) + { + if( is_next ) + { + next_file = i; + break; + } + else if( i == id ) + is_next = true; + else + next_file = i; + } + // display the next file + this.switch_to_file(next_file); + } + // clear datas + delete (this.files[id]); + this.update_size(); + } + } + }; + + // backup current file datas + EditArea.prototype.save_file= function(id){ + var t= this, save, a_links, a_selects, save_butt, img, i; + if(t.files[id]) + { + var save= t.files[id]; + save['last_selection'] = t.last_selection; + save['last_text_to_highlight'] = t.last_text_to_highlight; + save['last_hightlighted_text'] = t.last_hightlighted_text; + save['previous'] = t.previous; + save['next'] = t.next; + save['last_undo'] = t.last_undo; + save['smooth_selection'] = t.smooth_selection; + save['do_highlight'] = t.do_highlight; + save['syntax'] = t.settings['syntax']; + save['text'] = t.textarea.value; + save['scroll_top'] = t.result.scrollTop; + save['scroll_left'] = t.result.scrollLeft; + save['selection_start'] = t.last_selection["selectionStart"]; + save['selection_end'] = t.last_selection["selectionEnd"]; + save['font_size'] = t.settings["font_size"]; + save['font_family'] = t.settings["font_family"]; + save['word_wrap'] = t.settings["word_wrap"]; + save['toolbar'] = {'links':{}, 'selects': {}}; + + // save toolbar buttons state for fileSpecific buttons + a_links= _$("toolbar_1").getElementsByTagName("a"); + for( i=0; i