/[drupal]/contributions/modules/bueditor/library/bue.html.js
ViewVC logotype

Diff of /contributions/modules/bueditor/library/bue.html.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Oct 7 23:11:33 2009 UTC revision 1.1.2.1, Mon Nov 9 21:49:07 2009 UTC
# Line 2  Line 2 
2    
3  //Html creating and parsing methods.  //Html creating and parsing methods.
4  //Requires: none  //Requires: none
5  (function($) {  (function(E, $) {
6    
7  //html for a given tag. attributes having value=null are not printed.  //html for a given tag. attributes having value=null are not printed.
8  BUE.html = function(tag, ihtml, attr) {  BUE.html = function(tag, ihtml, attr) {
# Line 15  BUE.html = function(tag, ihtml, attr) { Line 15  BUE.html = function(tag, ihtml, attr) {
15    return tag ? H : I;    return tag ? H : I;
16  };  };
17    
18    //html for a given object.
19    BUE.objHtml = function(obj) {
20      return Html(obj.tag, obj.html, obj.attributes);
21    };
22    
23  //form input html.  //form input html.
24  BUE.input = function(t, n, v, a) {  BUE.input = function(t, n, v, a) {
25    return Html('input', '', $.extend({'type': t, 'name': n, 'value': v||null}, a));    return Html('input', '', $.extend({'type': t, 'name': n, 'value': v||null}, a));
# Line 68  BUE.parseHtml = function(s, tag) { Line 73  BUE.parseHtml = function(s, tag) {
73    return {tag: tag, attributes: attr, html: match[4]};    return {tag: tag, attributes: attr, html: match[4]};
74  };  };
75    
76    //Insert a parsed object into textarea by extending/replacing/tagging the current selection.
77    E.insertObj = function(obj, opt) {
78      if (!obj || !obj.tag) {
79        return this;
80      }
81      var E = this, tag = obj.tag, opt = $.extend({cursor: null, extend: true, toggle: false}, opt);
82      var sametag, sel = E.getSelection(), selobj = sel && opt.extend && BUE.parseHtml(sel);
83      //selection and new obj are of the same type
84      if (sametag = selobj && selobj.tag == tag) {
85        //toggle selected tag and exit
86        if (opt.toggle) return E.replaceSelection(selobj.html, opt.cursor);
87        //extend the object with the selected object
88        (typeof obj.html != 'string' || obj.html == sel) && (obj.html = selobj.html);
89        obj.attributes = $.extend(selobj.attributes, obj.attributes);
90      }
91      //replace selection
92      if (sametag || Nc(tag) || obj.html) {
93        return E.replaceSelection(BUE.objHtml(obj), opt.cursor);
94      }
95      //tag selection
96      var html = Html(tag, '', obj.attributes);
97      return E.tagSelection(html.substr(0, html.length - tag.length - 3), '</'+ tag +'>', opt.cursor);
98    };
99    
100  //shortcuts  //shortcuts
101  var Html = BUE.html;  var Html = BUE.html;
102  var Nc = BUE.nctag;  var Nc = BUE.nctag;
103    
104  })(jQuery);  })(BUE.instance.prototype, jQuery);
105    
106  //backward compatibility.  //backward compatibility.
107  eDefHTML = BUE.html;  eDefHTML = BUE.html;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2