Changeset 524
- Timestamp:
- 08/15/08 13:00:25 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/wymeditor/jquery.wymeditor.js
r523 r524 844 844 var sName = jQuery(this).attr(WYMeditor.NAME); 845 845 846 var oClass = aClasses.findByName(sName);846 var oClass = WYMeditor.Helper.findByName(aClasses, sName); 847 847 848 848 if(oClass) { … … 2436 2436 for(var attribute in attributes) { 2437 2437 var value = attributes[attribute]; 2438 if(!this.skiped_attributes.contains(attribute) && !this.skiped_attribute_values.contains(value)){ 2439 if (typeof value != 'function' && possible_attributes.contains(attribute)) { 2438 var h = WYMeditor.Helper; 2439 if(!h.contains(this.skiped_attributes, attribute) && !h.contains(this.skiped_attribute_values, value)){ 2440 if (typeof value != 'function' && h.contains(possible_attributes, attribute)) { 2440 2441 if (this.doesAttributeNeedsValidation(tag, attribute)) { 2441 2442 if(this.validateAttribute(tag, attribute, value)){ … … 2493 2494 var defaults = default_attributes_and_events[key]; 2494 2495 if(typeof defaults == 'object'){ 2495 2496 if ((defaults['except'] && defaults['except'].contains(tag)) || (defaults['only'] && !defaults['only'].contains(tag))) {2496 var h = WYMeditor.Helper; 2497 if ((defaults['except'] && h.contains(defaults['except'], tag)) || (defaults['only'] && !h.contains(defaults['only'], tag))) { 2497 2498 continue; 2498 2499 } … … 2509 2510 doesAttributeNeedsValidation: function(tag, attribute) 2510 2511 { 2511 return this._tags[tag] && ((this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute]) || (this._tags[tag]['required'] && this._tags[tag]['required'].contains(attribute))); 2512 return this._tags[tag] && ((this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute]) || (this._tags[tag]['required'] && 2513 WYMeditor.Helper.contains(this._tags[tag]['required'], attribute))); 2512 2514 }, 2513 2515 validateAttribute : function(tag, attribute, value) … … 2515 2517 if ( this._tags[tag] && 2516 2518 (this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute] && value.length > 0 && !value.match(this._tags[tag]['attributes'][attribute])) || // invalid format 2517 (this._tags[tag] && this._tags[tag]['required'] && this._tags[tag]['required'].contains(attribute) && value.length == 0) // required attribute2519 (this._tags[tag] && this._tags[tag]['required'] && WYMeditor.Helper.contains(this._tags[tag]['required'], attribute) && value.length == 0) // required attribute 2518 2520 ) { 2519 2521 return false; … … 3616 3618 WYMeditor.XhtmlSaxListener.prototype.isBlockTag = function(tag) 3617 3619 { 3618 return ! this.avoided_tags.contains(tag) && this.block_tags.contains(tag);3620 return !WYMeditor.Helper.contains(this.avoided_tags, tag) && WYMeditor.Helper.contains(this.block_tags, tag); 3619 3621 }; 3620 3622 3621 3623 WYMeditor.XhtmlSaxListener.prototype.isInlineTag = function(tag) 3622 3624 { 3623 return ! this.avoided_tags.contains(tag) && this.inline_tags.contains(tag);3625 return !WYMeditor.Helper.contains(this.avoided_tags, tag) && WYMeditor.Helper.contains(this.inline_tags, tag); 3624 3626 }; 3625 3627 … … 3855 3857 }; 3856 3858 3857 // String helpers 3858 if(!String.prototype.insertAt) { 3859 String.prototype.insertAt = function(inserted, pos) { 3860 return(this.substr(0,pos) + inserted + this.substring(pos)); 3861 }; 3862 }; 3859 // String & array helpers 3863 3860 3864 3861 WYMeditor.Helper = { 3865 3862 3863 //replace all instances of 'old' by 'rep' in 'str' string 3866 3864 replaceAll: function(str, old, rep) { 3867 3865 var rExp = new RegExp(old, "g"); … … 3869 3867 }, 3870 3868 3869 //insert 'inserted' at position 'pos' in 'str' string 3870 insertAt: function(str, inserted, pos) { 3871 return(str.substr(0,pos) + inserted + str.substring(pos)); 3872 }, 3873 3874 //trim 'str' string 3871 3875 trim: function(str) { 3872 3876 return str.replace(/^(\s*)|(\s*)$/gm,''); 3873 } 3874 }; 3875 3876 // Array helpers 3877 3878 // from http://forum.de.selfhtml.org/archiv/2004/3/t76079/#m438193 (2007-02-06) 3879 if(!Array.prototype.contains) { 3880 Array.prototype.contains = function (elem) { 3881 for (var i = 0; i < this.length; i++) { 3882 if (this[i] === elem) return true; 3877 }, 3878 3879 //return true if 'arr' array contains 'elem', or false 3880 contains: function(arr, elem) { 3881 for (var i = 0; i < arr.length; i++) { 3882 if (arr[i] === elem) return true; 3883 3883 } 3884 3884 return false; 3885 }; 3886 }; 3887 3888 if(!Array.prototype.indexof) { 3889 Array.prototype.indexOf = function (item) { 3890 var ret=-1; 3891 for(var i = 0; i < this.length; i++) { 3892 if (this[i] == item) { 3893 ret=i; 3885 }, 3886 3887 //return 'item' position in 'arr' array, or -1 3888 indexOf: function(arr, item) { 3889 var ret=-1; 3890 for(var i = 0; i < arr.length; i++) { 3891 if (arr[i] == item) { 3892 ret = i; 3894 3893 break; 3895 3894 } 3896 3895 } 3897 3896 return(ret); 3898 }; 3899 }; 3900 3901 if(!Array.prototype.findByName) { 3902 Array.prototype.findByName = function (name) { 3903 for(var i = 0; i < this.length; i++) { 3904 var item = this[i]; 3897 }, 3898 3899 //return 'item' object in 'arr' array, checking its 'name' property, or null 3900 findByName: function(arr, name) { 3901 for(var i = 0; i < arr.length; i++) { 3902 var item = arr[i]; 3905 3903 if(item.name == name) return(item); 3906 3904 } 3907 3905 return(null); 3908 }; 3909 }; 3906 } 3907 }; 3908 3909 trunk/src/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js
r485 r524 37 37 var aClasses = eval(wym._options.classesItems); 38 38 var sName = jQuery(this).attr(WYMeditor.NAME); 39 var oClass = aClasses.findByName(sName);39 var oClass = WYMeditor.Helper.findByName(aClasses, sName); 40 40 41 41 if(oClass){