/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/ace/mode-ruby.js

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-30 12:02:31 UTC
  • mfrom: (85.1.28 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130530120231-ttqgqjqw2w8enn7g
Merged Ohlsons changes:
added function to get ssn and name for the registrationspages in the user model.
added the registrationpage for students.
edited the registration page for instructors
edited the css for both the registrationpages
minor fix to registration css

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Distributed under the BSD license:
 
3
 *
 
4
 * Copyright (c) 2010, Ajax.org B.V.
 
5
 * All rights reserved.
 
6
 * 
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are met:
 
9
 *     * Redistributions of source code must retain the above copyright
 
10
 *       notice, this list of conditions and the following disclaimer.
 
11
 *     * Redistributions in binary form must reproduce the above copyright
 
12
 *       notice, this list of conditions and the following disclaimer in the
 
13
 *       documentation and/or other materials provided with the distribution.
 
14
 *     * Neither the name of Ajax.org B.V. nor the
 
15
 *       names of its contributors may be used to endorse or promote products
 
16
 *       derived from this software without specific prior written permission.
 
17
 * 
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
 
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 *
 
29
 * ***** END LICENSE BLOCK ***** */
 
30
 
 
31
define('ace/mode/ruby', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/ruby_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/folding/coffee'], function(require, exports, module) {
 
32
 
 
33
 
 
34
var oop = require("../lib/oop");
 
35
var TextMode = require("./text").Mode;
 
36
var Tokenizer = require("../tokenizer").Tokenizer;
 
37
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
 
38
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
 
39
var Range = require("../range").Range;
 
40
var FoldMode = require("./folding/coffee").FoldMode;
 
41
 
 
42
var Mode = function() {
 
43
    this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules());
 
44
    this.$outdent = new MatchingBraceOutdent();
 
45
    this.foldingRules = new FoldMode();
 
46
};
 
47
oop.inherits(Mode, TextMode);
 
48
 
 
49
(function() {
 
50
 
 
51
       
 
52
    this.lineCommentStart = "#";
 
53
 
 
54
    this.getNextLineIndent = function(state, line, tab) {
 
55
        var indent = this.$getIndent(line);
 
56
 
 
57
        var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
 
58
        var tokens = tokenizedLine.tokens;
 
59
 
 
60
        if (tokens.length && tokens[tokens.length-1].type == "comment") {
 
61
            return indent;
 
62
        }
 
63
        
 
64
        if (state == "start") {
 
65
            var match = line.match(/^.*[\{\(\[]\s*$/);
 
66
            if (match) {
 
67
                indent += tab;
 
68
            }
 
69
        }
 
70
 
 
71
        return indent;
 
72
    };
 
73
 
 
74
    this.checkOutdent = function(state, line, input) {
 
75
        return this.$outdent.checkOutdent(line, input);
 
76
    };
 
77
 
 
78
    this.autoOutdent = function(state, doc, row) {
 
79
        this.$outdent.autoOutdent(doc, row);
 
80
    };
 
81
 
 
82
}).call(Mode.prototype);
 
83
 
 
84
exports.Mode = Mode;
 
85
});
 
86
 
 
87
define('ace/mode/ruby_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
88
 
 
89
 
 
90
var oop = require("../lib/oop");
 
91
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
92
var constantOtherSymbol = exports.constantOtherSymbol = {
 
93
    token : "constant.other.symbol.ruby", // symbol
 
94
    regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
 
95
};
 
96
 
 
97
var qString = exports.qString = {
 
98
    token : "string", // single line
 
99
    regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
 
100
};
 
101
 
 
102
var qqString = exports.qqString = {
 
103
    token : "string", // single line
 
104
    regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
 
105
};
 
106
 
 
107
var tString = exports.tString = {
 
108
    token : "string", // backtick string
 
109
    regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
 
110
};
 
111
 
 
112
var constantNumericHex = exports.constantNumericHex = {
 
113
    token : "constant.numeric", // hex
 
114
    regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
 
115
};
 
116
 
 
117
var constantNumericFloat = exports.constantNumericFloat = {
 
118
    token : "constant.numeric", // float
 
119
    regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
 
120
};
 
121
 
 
122
var RubyHighlightRules = function() {
 
123
 
 
124
    var builtinFunctions = (
 
125
        "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
 
126
        "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
 
127
        "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
 
128
        "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
 
129
        "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
 
130
        "assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" +
 
131
        "attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" +
 
132
        "caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" +
 
133
        "exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" +
 
134
        "gsub!|get_via_redirect|h|host!|https?|https!|include|Integer|lambda|link_to|" +
 
135
        "link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" +
 
136
        "p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" +
 
137
        "raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" +
 
138
        "set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" +
 
139
        "throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" +
 
140
        "render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" +
 
141
        "content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" +
 
142
        "fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" +
 
143
        "time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" +
 
144
        "select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" +
 
145
        "file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" +
 
146
        "protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" +
 
147
        "send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" +
 
148
        "validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" +
 
149
        "validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" +
 
150
        "authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" +
 
151
        "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
 
152
        "translate|localize|extract_locale_from_tld|t|l|caches_page|expire_page|caches_action|expire_action|" +
 
153
        "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
 
154
        "has_many|has_one|belongs_to|has_and_belongs_to_many"
 
155
    );
 
156
 
 
157
    var keywords = (
 
158
        "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
 
159
        "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
 
160
        "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield"
 
161
    );
 
162
 
 
163
    var buildinConstants = (
 
164
        "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
 
165
        "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING"
 
166
    );
 
167
 
 
168
    var builtinVariables = (
 
169
        "\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" +
 
170
        "$!|root_url|flash|session|cookies|params|request|response|logger|self"
 
171
    );
 
172
 
 
173
    var keywordMapper = this.$keywords = this.createKeywordMapper({
 
174
        "keyword": keywords,
 
175
        "constant.language": buildinConstants,
 
176
        "variable.language": builtinVariables,
 
177
        "support.function": builtinFunctions,
 
178
        "invalid.deprecated": "debugger" // TODO is this a remnant from js mode?
 
179
    }, "identifier");
 
180
 
 
181
    this.$rules = {
 
182
        "start" : [
 
183
            {
 
184
                token : "comment",
 
185
                regex : "#.*$"
 
186
            }, {
 
187
                token : "comment", // multi line comment
 
188
                regex : "^=begin(?:$|\\s.*$)",
 
189
                next : "comment"
 
190
            }, {
 
191
                token : "string.regexp",
 
192
                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
 
193
            },
 
194
 
 
195
            qString,
 
196
            qqString,
 
197
            tString,
 
198
 
 
199
            {
 
200
                token : "text", // namespaces aren't symbols
 
201
                regex : "::"
 
202
            }, {
 
203
                token : "variable.instance", // instance variable
 
204
                regex : "@{1,2}[a-zA-Z_\\d]+"
 
205
            }, {
 
206
                token : "support.class", // class name
 
207
                regex : "[A-Z][a-zA-Z_\\d]+"
 
208
            },
 
209
 
 
210
            constantOtherSymbol,
 
211
            constantNumericHex,
 
212
            constantNumericFloat,
 
213
 
 
214
            {
 
215
                token : "constant.language.boolean",
 
216
                regex : "(?:true|false)\\b"
 
217
            }, {
 
218
                token : keywordMapper,
 
219
                regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
 
220
            }, {
 
221
                token : "punctuation.separator.key-value",
 
222
                regex : "=>"
 
223
            }, {
 
224
                stateName: "heredoc",
 
225
                onMatch : function(value, currentState, stack) {
 
226
                    var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
 
227
                    var tokens = value.split(this.splitRegex);
 
228
                    stack.push(next, tokens[3]);
 
229
                    return [
 
230
                        {type:"constant", value: tokens[1]},
 
231
                        {type:"string", value: tokens[2]},
 
232
                        {type:"support.class", value: tokens[3]},
 
233
                        {type:"string", value: tokens[4]}
 
234
                    ];
 
235
                },
 
236
                regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)",
 
237
                rules: {
 
238
                    heredoc: [{
 
239
                        onMatch:  function(value, currentState, stack) {
 
240
                            if (value == stack[1]) {
 
241
                                stack.shift();
 
242
                                stack.shift();
 
243
                                return "support.class";
 
244
                            }
 
245
                            return "string";
 
246
                        },
 
247
                        regex: ".*$",
 
248
                        next: "start"
 
249
                    }],
 
250
                    indentedHeredoc: [{
 
251
                        token: "string",
 
252
                        regex: "^ +"
 
253
                    }, {
 
254
                        onMatch:  function(value, currentState, stack) {
 
255
                            if (value == stack[1]) {
 
256
                                stack.shift();
 
257
                                stack.shift();
 
258
                                return "support.class";
 
259
                            }
 
260
                            return "string";
 
261
                        },
 
262
                        regex: ".*$",
 
263
                        next: "start"
 
264
                    }]
 
265
                }
 
266
            }, {
 
267
                token : "keyword.operator",
 
268
                regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
 
269
            }, {
 
270
                token : "paren.lparen",
 
271
                regex : "[[({]"
 
272
            }, {
 
273
                token : "paren.rparen",
 
274
                regex : "[\\])}]"
 
275
            }, {
 
276
                token : "text",
 
277
                regex : "\\s+"
 
278
            }
 
279
        ],
 
280
        "comment" : [
 
281
            {
 
282
                token : "comment", // closing comment
 
283
                regex : "^=end(?:$|\\s.*$)",
 
284
                next : "start"
 
285
            }, {
 
286
                token : "comment", // comment spanning whole line
 
287
                regex : ".+"
 
288
            }
 
289
        ]
 
290
    };
 
291
 
 
292
    this.normalizeRules();
 
293
};
 
294
 
 
295
oop.inherits(RubyHighlightRules, TextHighlightRules);
 
296
 
 
297
exports.RubyHighlightRules = RubyHighlightRules;
 
298
});
 
299
 
 
300
define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
 
301
 
 
302
 
 
303
var Range = require("../range").Range;
 
304
 
 
305
var MatchingBraceOutdent = function() {};
 
306
 
 
307
(function() {
 
308
 
 
309
    this.checkOutdent = function(line, input) {
 
310
        if (! /^\s+$/.test(line))
 
311
            return false;
 
312
 
 
313
        return /^\s*\}/.test(input);
 
314
    };
 
315
 
 
316
    this.autoOutdent = function(doc, row) {
 
317
        var line = doc.getLine(row);
 
318
        var match = line.match(/^(\s*\})/);
 
319
 
 
320
        if (!match) return 0;
 
321
 
 
322
        var column = match[1].length;
 
323
        var openBracePos = doc.findMatchingBracket({row: row, column: column});
 
324
 
 
325
        if (!openBracePos || openBracePos.row == row) return 0;
 
326
 
 
327
        var indent = this.$getIndent(doc.getLine(openBracePos.row));
 
328
        doc.replace(new Range(row, 0, row, column-1), indent);
 
329
    };
 
330
 
 
331
    this.$getIndent = function(line) {
 
332
        return line.match(/^\s*/)[0];
 
333
    };
 
334
 
 
335
}).call(MatchingBraceOutdent.prototype);
 
336
 
 
337
exports.MatchingBraceOutdent = MatchingBraceOutdent;
 
338
});
 
339
 
 
340
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
 
341
 
 
342
 
 
343
var oop = require("../../lib/oop");
 
344
var BaseFoldMode = require("./fold_mode").FoldMode;
 
345
var Range = require("../../range").Range;
 
346
 
 
347
var FoldMode = exports.FoldMode = function() {};
 
348
oop.inherits(FoldMode, BaseFoldMode);
 
349
 
 
350
(function() {
 
351
 
 
352
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
353
        var range = this.indentationBlock(session, row);
 
354
        if (range)
 
355
            return range;
 
356
 
 
357
        var re = /\S/;
 
358
        var line = session.getLine(row);
 
359
        var startLevel = line.search(re);
 
360
        if (startLevel == -1 || line[startLevel] != "#")
 
361
            return;
 
362
 
 
363
        var startColumn = line.length;
 
364
        var maxRow = session.getLength();
 
365
        var startRow = row;
 
366
        var endRow = row;
 
367
 
 
368
        while (++row < maxRow) {
 
369
            line = session.getLine(row);
 
370
            var level = line.search(re);
 
371
 
 
372
            if (level == -1)
 
373
                continue;
 
374
 
 
375
            if (line[level] != "#")
 
376
                break;
 
377
 
 
378
            endRow = row;
 
379
        }
 
380
 
 
381
        if (endRow > startRow) {
 
382
            var endColumn = session.getLine(endRow).length;
 
383
            return new Range(startRow, startColumn, endRow, endColumn);
 
384
        }
 
385
    };
 
386
    this.getFoldWidget = function(session, foldStyle, row) {
 
387
        var line = session.getLine(row);
 
388
        var indent = line.search(/\S/);
 
389
        var next = session.getLine(row + 1);
 
390
        var prev = session.getLine(row - 1);
 
391
        var prevIndent = prev.search(/\S/);
 
392
        var nextIndent = next.search(/\S/);
 
393
 
 
394
        if (indent == -1) {
 
395
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
 
396
            return "";
 
397
        }
 
398
        if (prevIndent == -1) {
 
399
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
 
400
                session.foldWidgets[row - 1] = "";
 
401
                session.foldWidgets[row + 1] = "";
 
402
                return "start";
 
403
            }
 
404
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
 
405
            if (session.getLine(row - 2).search(/\S/) == -1) {
 
406
                session.foldWidgets[row - 1] = "start";
 
407
                session.foldWidgets[row + 1] = "";
 
408
                return "";
 
409
            }
 
410
        }
 
411
 
 
412
        if (prevIndent!= -1 && prevIndent < indent)
 
413
            session.foldWidgets[row - 1] = "start";
 
414
        else
 
415
            session.foldWidgets[row - 1] = "";
 
416
 
 
417
        if (indent < nextIndent)
 
418
            return "start";
 
419
        else
 
420
            return "";
 
421
    };
 
422
 
 
423
}).call(FoldMode.prototype);
 
424
 
 
425
});