Вход Регистрация
Файл: wysiwyg/live/scripts/common/codemirror/mode/htmlmixed/htmlmixed.js
Строк: 79
<?php
CodeMirror
.defineMode("htmlmixed", function(configparserConfig) {
  var 
htmlMode CodeMirror.getMode(config, {name"xml"htmlModetrue});
  var 
jsMode CodeMirror.getMode(config"javascript");
  var 
cssMode CodeMirror.getMode(config"css");

  function 
html(streamstate) {
    var 
style htmlMode.token(streamstate.htmlState);
    if (
style == "tag" && stream.current() == ">" && state.htmlState.context) {
      if (/^
script$/i.test(state.htmlState.context.tagName)) {
        
state.token javascript;
        
state.localState jsMode.startState(htmlMode.indent(state.htmlState""));
        
state.mode "javascript";
      }
      else if (/^
style$/i.test(state.htmlState.context.tagName)) {
        
state.token css;
        
state.localState cssMode.startState(htmlMode.indent(state.htmlState""));
        
state.mode "css";
      }
    }
    return 
style;
  }
  function 
maybeBackup(streampatstyle) {
    var 
cur stream.current();
    var 
close cur.search(pat);
    if (
close > -1stream.backUp(cur.length close);
    return 
style;
  }
  function 
javascript(streamstate) {
    if (
stream.match(/^</s*scripts*>/ifalse)) {
      
state.token html;
      
state.curState null;
      
state.mode "html";
      return 
html(streamstate);
    }
    return 
maybeBackup(stream, /</s*scripts*>/,
                       
jsMode.token(streamstate.localState));
  }
  function 
css(streamstate) {
    if (
stream.match(/^</s*styles*>/ifalse)) {
      
state.token html;
      
state.localState null;
      
state.mode "html";
      return 
html(streamstate);
    }
    return 
maybeBackup(stream, /</s*styles*>/,
                       
cssMode.token(streamstate.localState));
  }

  return {
    
startState: function() {
      var 
state htmlMode.startState();
      return {
tokenhtmllocalStatenullmode"html"htmlStatestate};
    },

    
copyState: function(state) {
      if (
state.localState)
        var 
local CodeMirror.copyState(state.token == css cssMode jsModestate.localState);
      return {
tokenstate.tokenlocalStatelocalmodestate.mode,
              
htmlStateCodeMirror.copyState(htmlModestate.htmlState)};
    },

    
token: function(streamstate) {
      return 
state.token(streamstate);
    },

    
indent: function(statetextAfter) {
      if (
state.token == html || /^s*<//.test(textAfter))
        
return htmlMode.indent(state.htmlStatetextAfter);
      else if (
state.token == javascript)
        return 
jsMode.indent(state.localStatetextAfter);
      else
        return 
cssMode.indent(state.localStatetextAfter);
    },

    
compareStates: function(ab) {
      return 
htmlMode.compareStates(a.htmlStateb.htmlState);
    },

    
electricChars"/{}:"
  
}
});

CodeMirror.defineMIME("text/html""htmlmixed");
?>
Онлайн: 1
Реклама