if (!skip_children) {
for(var i =0;i < items.length;i++) {
// Roo.log(['add child', items[i]]);
- nitems.push(cn.addxtype(Roo.apply({}, items[i])));
+ nitems.push(cn.addxtype(items[i].xns == false ? items[i] : Roo.apply({}, items[i])));
}
}
imgResponsive: true,
border: '',
- src: 'about:blank',
+ src: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=',
href: false,
target: false,
xsUrl: '',
var alpha = /^[a-zA-Z_]+$/;
var alphanum = /^[a-zA-Z0-9_]+$/;
var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
- var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
+ var url = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
+ var urlWeb = /^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
// All these messages and functions are configurable
return {
url : function(v){
return url.test(v);
},
+ /**
+ * The funciton used to validate URLs (only allow schemes 'https' and 'http')
+ * @param {String} v The URL
+ */
+ urlWeb : function(v) {
+ return urlWeb.test(v);
+ },
/**
* The error text to display when the url validation function returns false
* @type String
cls: 'glyphicon form-control-feedback'
};
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
inputblock = {
cls : 'has-feedback',
});
}
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
inputblock.cls += ' has-feedback';
inputblock.cn.push(feedback);
}
}
this.inputEl().on('change', this.onChange, this);
+
+ if(this.hasFeedback && this.inputType != 'hidden'){
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+
+ if(feedback) {
+ feedback.hide();
+ }
+ }
},
filterValidation : function(e){
*/
reset : function(){
this.setValue(this.originalValue);
- this.validate();
+ // this.validate();
+ this.el.removeClass([this.invalidClass, this.validClass]);
+ this.inputEl().removeClass(['is-valid', 'is-invalid']);
+
+ if(this.hasFeedback && this.inputType != 'hidden'){
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ feedback.update('');
+ feedback.hide();
+ }
+
+ }
},
/**
* Returns the name of the field
* @return {Mixed} value The field value
*/
getValue : function(){
-
var v = this.inputEl().getValue();
-
return v;
},
/**
this.el.removeClass([this.invalidClass, 'is-invalid']);
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
+
+ feedback.update('');
+ feedback.hide();
}
}
* Mark this field as valid
*/
markValid : function()
- {
+ {
if(!this.el || this.preventMark){ // not rendered...
return;
}
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ feedback.update('');
+ feedback.hide();
}
if(this.indicator){
this.inputEl().addClass('is-valid');
}
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass(
[this.invalidFeedbackClass, this.validFeedbackClass]);
+ feedback.update('');
+ feedback.hide();
}
if(this.disabled){
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
- if(this.getValue().length || this.forceFeedback){
- this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
+ this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
+
+ feedback.update(typeof(msg) == 'undefined' ? this.invalidText : msg);
+
+ if(!this.allowBlank && !this.getRawValue().length){
+ feedback.update(this.blankText);
+ }
+
+ if(feedback.dom.innerHTML) {
+ feedback.show();
}
}
var inputblock = input;
- if(this.hasFeedback && !this.allowBlank){
+ if(this.hasFeedback){
var feedback = {
tag: 'span',
inputblock.cn.push(input);
- if(this.hasFeedback && !this.allowBlank){
+ if(this.hasFeedback){
inputblock.cls += ' has-feedback';
inputblock.cn.push(feedback);
}
this.el.removeClass( this.validClass);
this.inputEl().removeClass('is-invalid');
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
+
+ feedback.update('');
+ feedback.hide();
}
}
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ feedback.update('');
+ feedback.hide();
}
if(this.disabled || this.allowBlank){
}
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ feedback.update('');
+ feedback.hide();
}
- if(this.disabled || this.allowBlank){
+ if(this.disabled){
return;
}
}
// fixme ... this may be depricated need to test..
- if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+ if(this.hasFeedback && this.inputType != 'hidden'){
var feedback = this.el.select('.form-control-feedback', true).first();
if(feedback){
this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
- if(this.getValue().length || this.forceFeedback){
- this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
+ this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
+
+ feedback.update(this.invalidText);
+
+ if(!this.allowBlank && !this.getRawValue().length){
+ feedback.update(this.blankText);
+ }
+
+ if(feedback.dom.innerHTML) {
+ feedback.show();
}
}
update: function()
{
-
+ // default minute is a multiple of minuteStep
+ if(typeof(this.time) === 'undefined') {
+ this.time = new Date();
+ this.time = this.time.add(Date.MINUTE, Math.round(parseInt(this.time.format('i')) / this.minuteStep) * this.minuteStep - parseInt(this.time.format('i')));
+ }
this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
this.fill();
* @class Roo.bootstrap.form.SecurePass
* @extends Roo.bootstrap.form.Input
* Bootstrap SecurePass class
+ * @cfg {Number} minimumStrength invalid if the strength of the password input is less than the minimum strength (from 0 to 3) (default 2)
*
*
* @constructor
*/
Roo.bootstrap.form.SecurePass = function (config) {
- // these go here, so the translation tool can replace them..
- this.errors = {
- PwdEmpty: "Please type a password, and then retype it to confirm.",
- PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
- PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
- PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
- IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
- FNInPwd: "Your password can't contain your first name. Please type a different password.",
- LNInPwd: "Your password can't contain your last name. Please type a different password.",
- TooWeak: "Your password is Too Weak."
- },
- this.meterLabel = "Password strength:";
- this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
- this.meterClass = [
- "roo-password-meter-tooweak",
- "roo-password-meter-weak",
- "roo-password-meter-medium",
- "roo-password-meter-strong",
- "roo-password-meter-grey"
- ];
-
- this.errors = {};
Roo.bootstrap.form.SecurePass.superclass.constructor.call(this, config);
}
Roo.extend(Roo.bootstrap.form.SecurePass, Roo.bootstrap.form.Input, {
- /**
- * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
- * {
- * PwdEmpty: "Please type a password, and then retype it to confirm.",
- * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
- * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
- * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
- * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
- * FNInPwd: "Your password can't contain your first name. Please type a different password.",
- * LNInPwd: "Your password can't contain your last name. Please type a different password."
- * })
- */
+ minimumStrength : 2,
// private
-
- meterWidth: 300,
- errorMsg :'',
- errors: false,
- imageRoot: '/',
- /**
- * @cfg {String/Object} Label for the strength meter (defaults to
- * 'Password strength:')
- */
- // private
- meterLabel: '',
- /**
- * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
- * ['Weak', 'Medium', 'Strong'])
- */
- // private
- pwdStrengths: false,
+ meterWidth: 300,
+ imageRoot: '/',
// private
strength: 0,
// private
//var pm = this.trigger.child('div/div/div').dom;
var pm = this.trigger.child('div/div');
- pm.removeClass(this.meterClass);
- pm.addClass(this.meterClass[strength]);
+ pm.removeClass(Roo.bootstrap.form.SecurePass.meterClass);
+ pm.addClass(Roo.bootstrap.form.SecurePass.meterClass[strength]);
var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
- pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
+ pt.innerHTML = Roo.bootstrap.form.SecurePass.meterLabel + ' ' + Roo.bootstrap.form.SecurePass.pwdStrengths[strength];
this._lastPwd = pwd;
},
this._lastPwd = '';
var pm = this.trigger.child('div/div');
- pm.removeClass(this.meterClass);
+ pm.removeClass(Roo.bootstrap.form.SecurePass.meterClass);
pm.addClass('roo-password-meter-grey');
return true;
}
- this.markInvalid(this.errors.PwdEmpty);
- this.errorMsg = this.errors.PwdEmpty;
+ this.invalidText = Roo.bootstrap.form.SecurePass.errors.PwdEmpty;
return false;
}
}
if (!value.match(/[\x21-\x7e]+/)) {
- this.markInvalid(this.errors.PwdBadChar);
- this.errorMsg = this.errors.PwdBadChar;
+ this.invalidText = Roo.bootstrap.form.SecurePass.errors.PwdBadChar;
return false;
}
if (value.length < 6) {
- this.markInvalid(this.errors.PwdShort);
- this.errorMsg = this.errors.PwdShort;
+ this.invalidText = Roo.bootstrap.form.SecurePass.errors.PwdShort;
return false;
}
if (value.length > 16) {
- this.markInvalid(this.errors.PwdLong);
- this.errorMsg = this.errors.PwdLong;
+ this.invalidText = Roo.bootstrap.form.SecurePass.errors.PwdLong;
return false;
}
var strength;
}
- if (strength < 2) {
- //this.markInvalid(this.errors.TooWeak);
- this.errorMsg = this.errors.TooWeak;
- //return false;
+ if (strength < this.minimumStrength) {
+ this.invalidText = Roo.bootstrap.form.SecurePass.errors.TooWeak;
+ return false;
}
//var pm = this.trigger.child('div/div/div').dom;
var pm = this.trigger.child('div/div');
- pm.removeClass(this.meterClass);
- pm.addClass(this.meterClass[strength]);
+ pm.removeClass(Roo.bootstrap.form.SecurePass.meterClass);
+ pm.addClass(Roo.bootstrap.form.SecurePass.meterClass[strength]);
var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
- pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
-
- this.errorMsg = '';
+ pt.innerHTML = Roo.bootstrap.form.SecurePass.meterLabel + ' ' + Roo.bootstrap.form.SecurePass.pwdStrengths[strength];
+
return true;
},
// private
return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
}
+});
+
+Roo.bootstrap.form.SecurePass.errors = {
+ PwdEmpty: "Please type a password, and then retype it to confirm.",
+ PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
+ PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
+ PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
+ IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
+ FNInPwd: "Your password can't contain your first name. Please type a different password.",
+ LNInPwd: "Your password can't contain your last name. Please type a different password.",
+ TooWeak: "Your password is Too Weak."
+};
+
+Roo.bootstrap.form.SecurePass.meterLabel = "Password strength:";
+Roo.bootstrap.form.SecurePass.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
+Roo.bootstrap.form.SecurePass.meterClass = [
+ "roo-password-meter-tooweak",
+ "roo-password-meter-weak",
+ "roo-password-meter-medium",
+ "roo-password-meter-strong",
+ "roo-password-meter-grey"
+];/**
+ * @class Roo.bootstrap.form.Password
+ * @extends Roo.bootstrap.form.Input
+ * Bootstrap Password class
+ *
+ *
+ *
+ *
+ * @constructor
+ * Create a new Password
+ * @param {Object} config The config object
+ */
+
+Roo.bootstrap.form.Password = function(config){
+ Roo.bootstrap.form.Password.superclass.constructor.call(this, config);
+
+ this.inputType = 'password';
+};
+
+Roo.extend(Roo.bootstrap.form.Password, Roo.bootstrap.form.Input, {
+
+ onRender : function(ct, position)
+ {
+ Roo.bootstrap.form.SecurePass.superclass.onRender.call(this, ct, position);
+
+ this.el.addClass('form-password');
+
+ this.wrap = this.inputEl().wrap({
+ cls : 'password-wrap'
+ });
+
+ this.toggle = this.wrap.createChild({
+ tag : 'Button',
+ cls : 'password-toggle'
+ });
+
+
+ this.toggleEl().addClass('password-hidden');
+
+ this.toggleEl().on('click', this.onToggleClick, this);;
+ },
+
+ toggleEl: function()
+ {
+ return this.el.select('button.password-toggle',true).first();
+ },
+
+ onToggleClick : function(e)
+ {
+ var input = this.inputEl();
+ var toggle = this.toggleEl();
+
+ toggle.removeClass(['password-visible', 'password-hidden']);
+
+ if(input.attr('type') == 'password') {
+ input.attr('type', 'text');
+ toggle.addClass('password-visible');
+ }
+ else {
+ input.attr('type', 'password');
+ toggle.addClass('password-hidden');
+ }
+ }
});Roo.rtf = {}; // namespace
Roo.rtf.Hex = function(hex)
{
}
},
-
+
{
xtype : 'Button',
text: 'Hide Caption',
var ret = {
tag: 'figure',
'data-block' : 'Figure',
- 'data-width' : this.width,
+ 'data-width' : this.width,
+ 'data-caption' : this.caption,
contenteditable : 'false',
style : {
this.image_src = this.getVal(node, 'img', 'src');
this.align = this.getVal(node, 'figure', 'align');
+
+ /// not really used - as hidden captions do not store the content here..
var figcaption = this.getVal(node, 'figcaption', false);
if (figcaption !== '') {
this.caption = this.getVal(figcaption, 'i', 'html');
this.caption_display = this.getVal(node, 'figcaption', 'data-display');
+ var dc = this.getVal(node, true, 'data-caption');
+ if (dc && dc.length) {
+ this.caption = dc;
+ }
//this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
this.width = this.getVal(node, true, 'data-width');
//this.margin = this.getVal(node, 'figure', 'style', 'margin');
* @param {Roo.HtmlEditorCore} this
*/
editorevent: true
-
+
});
'rowspan',
'data-display',
'data-width',
+ 'data-caption',
'start' ,
'style',
// youtube embed.
var cd = (e.browserEvent.clipboardData || window.clipboardData);
// check what type of paste - if it's an image, then handle it differently.
- if (cd.files && cd.files.length > 0) {
- // pasting images?
+ if (cd.files && cd.files.length > 0 && cd.types.indexOf('text/html') < 0) {
+ // pasting images?
var urlAPI = (window.createObjectURL && window) ||
(window.URL && URL.revokeObjectURL && URL) ||
(window.webkitURL && webkitURL);
var parser = new Roo.rtf.Parser(cd.getData('text/rtf'));
images = parser.doc ? parser.doc.getElementsByType('pict') : [];
}
- //Roo.log(images);
- //Roo.log(imgs);
+ // Roo.log(images);
+ // Roo.log(imgs);
// fixme..
images = images.filter(function(g) { return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/); }) // ignore headers/footers etc.
.map(function(g) { return g.toDataURL(); })
break;
case 'bold':
case 'italic':
+ case 'underline':
// if there is no selection, then we insert, and set the curson inside it..
this.execCmd('styleWithCSS', false);
break;
*/
Roo.bootstrap.form.HtmlEditor = function(config){
- Roo.bootstrap.form.HtmlEditor.superclass.constructor.call(this, config);
- if (!this.toolbars) {
- this.toolbars = [];
- }
-
- this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
+
this.addEvents({
/**
* @event initialize
* Fires when the editor is fully initialized (including the iframe)
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
initialize: true,
/**
* @event activate
* Fires when the editor is first receives the focus. Any insertion must wait
* until after this event.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
activate: true,
/**
* @event beforesync
* Fires before the textarea is updated with content from the editor iframe. Return false
* to cancel the sync.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
* @param {String} html
*/
beforesync: true,
* @event beforepush
* Fires before the iframe editor is updated with content from the textarea. Return false
* to cancel the push.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
* @param {String} html
*/
beforepush: true,
/**
* @event sync
* Fires when the textarea is updated with content from the editor iframe.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
* @param {String} html
*/
sync: true,
/**
* @event push
* Fires when the iframe editor is updated with content from the textarea.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
* @param {String} html
*/
push: true,
/**
* @event editmodechange
* Fires when the editor switches edit modes
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
* @param {Boolean} sourceEdit True if source edit, false if standard editing.
*/
editmodechange: true,
/**
* @event editorevent
* Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
editorevent: true,
/**
* @event firstfocus
* Fires when on first focus - needed by toolbars..
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
firstfocus: true,
/**
* @event autosave
* Auto save the htmlEditor value as a file into Events
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
autosave: true,
/**
* @event savedpreview
* preview the saved version of htmlEditor
- * @param {HtmlEditor} this
+ * @param {Roo.bootstrap.form.HtmlEditor} this
*/
- savedpreview: true
- });
+ savedpreview: true,
+ /**
+ * @event stylesheetsclick
+ * Fires when press the Sytlesheets button
+ * @param {Roo.HtmlEditorCore} this
+ */
+ stylesheetsclick: true,
+ /**
+ * @event paste
+ * Fires when press user pastes into the editor
+ * @param {Roo.HtmlEditorCore} this
+ */
+ paste: true,
+ /**
+ * @event imageadd
+ * Fires when on any editor when an image is added (excluding paste)
+ * @param {Roo.bootstrap.form.HtmlEditor} this
+ */
+ imageadd: true ,
+ /**
+ * @event imageupdated
+ * Fires when on any editor when an image is changed (excluding paste)
+ * @param {Roo.bootstrap.form.HtmlEditor} this
+ * @param {HTMLElement} img could also be a figure if blocks are enabled
+ */
+ imageupdate: true ,
+ /**
+ * @event imagedelete
+ * Fires when on any editor when an image is deleted
+ * @param {Roo.bootstrap.form.HtmlEditor} this
+ * @param {HTMLElement} img could also be a figure if blocks are enabled
+ * @param {HTMLElement} oldSrc source of image being replaced
+ */
+ imagedelete: true
+ });
+ Roo.bootstrap.form.HtmlEditor.superclass.constructor.call(this, config);
+ if (!this.toolbars) {
+ this.toolbars = [];
+ }
+
+ this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
+
};
tbContainer : false,
bodyCls : '',
+
+ linkDialogCls : '',
toolbarContainer :function() {
return this.wrap.select('.x-html-editor-tb',true).first();
//glyphicon : id,
btnid : id,
fa: id,
+ cls : 'roo-html-editor-btn-' + id,
cmd : cmd, // why id || cmd
enableToggle: toggle !== false,
html : html || '',
size : 'sm',
xns: Roo.bootstrap,
fa : 'font',
+ cls : 'roo-html-editor-font-chooser',
//html : 'submit'
menu : {
xtype: 'Menu',
});
children.push(style);
- btn('bold', false,true);
- btn('italic', false,true);
+ btn('bold', 'bold',true);
+ btn('italic', 'italic',true);
+ btn('underline', 'underline',true);
btn('align-left', 'justifyleft',true);
btn('align-center', 'justifycenter',true);
btn('align-right' , 'justifyright',true);
size : 'sm',
xtype: 'Button',
xns: Roo.bootstrap,
- fa: 'eraser',
- tooltip : "Clear Formating / Delete",
+ fa: 'trash',
listeners : {
click : this.onDelete.createDelegate(this)
}
}
- this.addFiles(Array.prototype.slice.call(this.input.dom.files));
+ this.addFiles(Array.prototype.slice.call(this.input.dom.files), false);
},
- addFiles : function(far) {
+ addFiles : function(far, fire_add) {
+
+ var editor = this.editorcore;
+
if (!far.length) {
+ if (fire_add) {
+ this.editor.syncValue();
+ editor.owner.fireEvent('editorevent', editor.owner, false);
+ editor.owner.fireEvent('imageadd', editor.owner, false);
+ }
return;
}
var f = far.pop();
if (!f.type.match(/^image/)) {
- this.addFiles(far);
+ this.addFiles(far, fire_add);
return;
}
var bl = sn && this.editorcore.enableBlocks ? Roo.htmleditor.Block.factory(sn) : false;
- var editor = this.editorcore;
var reader = new FileReader();
reader.addEventListener('load', (function() {
if (bl) {
+ var oldSrc = bl.image_src;
bl.image_src = reader.result;
//bl.caption = f.name;
bl.updateElement(sn);
- editor.owner.fireEvent('editorevent', editor, false);
+ this.editor.syncValue();
+ editor.owner.fireEvent('editorevent', editor.owner, false);
+ editor.owner.fireEvent('imageupdate', editor.owner, sn, oldSrc);
// we only do the first file!! and replace.
return;
}
caption_display : 'none' //default to hide captions..
});
editor.insertAtCursor(fig.toHTML());
- editor.owner.fireEvent('editorevent', editor, false);
+ this.addFiles(far, true);
return;
}
// just a standard img..
if (sn && sn.tagName.toUpperCase() == 'IMG') {
+ var oldSrc = sn.src;
sn.src = reader.result;
- editor.owner.fireEvent('editorevent', editor, false);
+ this.editor.syncValue();
+ editor.owner.fireEvent('editorevent', editor.owner, false);
+ editor.owner.fireEvent('imageupdate', editor.owner, sn, oldSrc);
return;
}
editor.insertAtCursor('<img src="' + reader.result +'">');
- editor.owner.fireEvent('editorevent', editor, false);
+ this.addFiles(far, true);
}).createDelegate(this));
reader.readAsDataURL(f);
}
if (url != '') {
this.selectedNode.setAttribute('href', newurl);
+ this.editor.syncValue();
return;
}
if(newurl && newurl .match(/http(s):\/\/.+/)) {
this.editorcore.relayCmd('createlink', newurl);
}
this.editorcore.focus();
- }
+ },
+ cls : this.editorcore.linkDialogCls
});
},
/**
var hasToggle = false;
btns.each(function(e) {
if (e.enableToggle && e.cmd) {
- hasToggle = hasToggle || (['align-left', 'align-right', 'align-center'].indexOf(e.btnid) < 0 && doc.queryCommandState(e.cmd));
+ hasToggle = hasToggle || (['align-left', 'align-right', 'align-center', 'image' , 'link', 'underline'].indexOf(e.btnid) < 0 && doc.queryCommandState(e.cmd));
e.setActive(doc.queryCommandState(e.cmd));
}
}, this);
}
btns.get('link').setActive(tn == 'A' && this.selectedNode.hasAttribute('href'));
+ btns.get('image').setActive(tn == 'IMG' || this.editorcore.enableBlocks && tn == 'FIGURE');
+ btns.get('underline').setActive(tn == 'U' || sel.closest('u') ? true : false);
Roo.bootstrap.menu.Manager.hideAll();
selection.removeAllRanges();
selection.addRange(range);
this.updateToolbar(null, null, null);
+ if (sn.tagName.toUpperCase() == 'FIGURE') {
+ this.editor.syncValue();
+ this.editor.fireEvent('imagedelete', this.editor, sn);
+ }
+
+ this.selectedNode = false;
this.editorcore.fireEditorEvent(false);
return;
}
selection.removeAllRanges();
selection.addRange(range);
+ if (sn.tagName.toUpperCase() == 'IMG"') {
+ this.editor.syncValue();
+ this.editor.fireEvent('imagedelete', this.editor, sn);
+ }
+
+ this.selectedNode = false;
this.editorcore.fireEditorEvent(false);
{
tag : 'iframe',
style : 'border: 0px',
- src : 'about:blank'
+ src : 'data:text/html,%3Cbody%3E%3C%2Fbody%3E'
}
];
}