Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label button (WIP) #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions dist/bootstrap3-wysihtml5.all.min.js

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions dist/bootstrap3-wysihtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
if(key === 'image') {
this.initInsertImage(toolbar);
}

if(key === 'label') {
this.initInsertLabel(toolbar);
}
}
}

Expand Down Expand Up @@ -235,6 +239,59 @@
return true;
}
});
},

initInsertLabel: function(toolbar) {
var self = this;
var insertLabelModal = toolbar.find('.bootstrap-wysihtml5-insert-label-modal');
var labelClass = insertLabelModal.find('.bootstrap-wysihtml5-insert-label-type');
var insertButton = insertLabelModal.find('a.btn-primary');
var initialValue = labelClass.find(':selected').attr('name');
var caretBookmark;

var insertLabel = function() {
var lClass = labelClass.find(':selected').attr('name');
var className = 'label ' + lClass;
labelClass.find('[name="' + lClass + '"]').attr('selected', 'selected');

console.log(self.editor.composer.selection);
console.log(self.editor.composer.selection.getRange());

self.editor.currentView.element.focus();
if (caretBookmark) {
self.editor.composer.selection.setBookmark(caretBookmark);
caretBookmark = null;
}

self.editor.composer.commands.exec('formatInline', 'span', className, new RegExp('.+', "g"));
};

insertButton.click(insertLabel);

insertLabelModal.on('shown', function() {
labelClass.find(':selected').focus();
});

insertLabelModal.on('hide', function() {
self.editor.currentView.element.focus();
});

toolbar.find('a[data-wysihtml5-command=createLabel]').click(function() {
var activeButton = $(this).hasClass('wysihtml5-command-active');

if (!activeButton) {
self.editor.currentView.element.focus(false);
caretBookmark = self.editor.composer.selection.getBookmark();
insertLabelModal.appendTo('body').modal('show');
insertLabelModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
e.stopPropagation();
});
return false;
}
else {
return true;
}
});
}
};

Expand Down Expand Up @@ -286,6 +343,7 @@
'html': false,
'link': true,
'image': true,
'label': true,
events: {},
parserRules: {
classes: {
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap3-wysihtml5.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/bootstrap3-wysihtml5.min.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/locales/bootstrap-wysihtml5.ca-CT.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
navy: "Blau marí",
blue: "Blau",
orange: "Taronja"
}
},
label: {
insert : 'Afegir etiqueta',
default: 'Predeterminat',
primary: 'Primari',
success: 'Èxit',
info : 'Informaciò',
warning: 'Advertència',
danger : 'Perill',
cancel : 'Cancel.lar'
},
};
}(jQuery));
12 changes: 11 additions & 1 deletion dist/locales/bootstrap-wysihtml5.en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
navy: 'Navy',
blue: 'Blue',
orange: 'Orange'
}
},
label: {
insert : 'Insert label',
default: 'Default',
primary: 'Primary',
success: 'Success',
info : 'Info',
warning: 'Warning',
danger : 'Danger',
cancel : 'Cancel'
},
};
}(jQuery));
12 changes: 11 additions & 1 deletion dist/locales/bootstrap-wysihtml5.es-ES.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
navy: "Azul Marino",
blue: "Azul",
orange: "Naranja"
}
},
label: {
insert : 'Insertar etiqueta',
default: 'Predeterminado',
primary: 'Primario',
success: 'Éxito',
info : 'Información',
warning: 'Advertencia',
danger : 'Peligro',
cancel : 'Cancelar'
},
};
}(jQuery));
40 changes: 40 additions & 0 deletions dist/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,46 @@ function program1(depth0,data) {
return buffer;
});

this["wysihtml5"]["tpl"]["label"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this;

function program1(depth0,data) {

var buffer = "", stack1;
buffer += "btn-"
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.size)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1));
return buffer;
}

buffer += "<li>\n <div class=\"bootstrap-wysihtml5-insert-label-modal modal fade\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <a class=\"close\" data-dismiss=\"modal\">&times;</a>\n <h3>"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</h3>\n </div>\n <div class=\"modal-body\">\n <select class=\"bootstrap-wysihtml5-insert-label-type\">\n <option name=\"label-default\" selected=\"selected\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1['default'])),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-primary\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.primary)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-success\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.success)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-info\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.info)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-warning\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.warning)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-danger\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.danger)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n </select>\n </div>\n <div class=\"modal-footer\">\n <a class=\"btn btn-default\" data-dismiss=\"modal\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.cancel)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</a>\n <a href=\"#\" class=\"btn btn-primary\" data-dismiss=\"modal\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</a>\n </div>\n </div>\n </div>\n </div>\n <a class=\"btn ";
stack2 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.size), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += " btn-default\" data-wysihtml5-command=\"createLabel\" title=\""
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\" tabindex=\"-1\">\n <span class=\"glyphicon glyphicon-tag\"></span>\n </a>\n</li>\n";
return buffer;
});

this["wysihtml5"]["tpl"]["link"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
Expand Down
58 changes: 58 additions & 0 deletions src/bootstrap3-wysihtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
if(key === 'image') {
this.initInsertImage(toolbar);
}

if(key === 'label') {
this.initInsertLabel(toolbar);
}
}
}

Expand Down Expand Up @@ -235,6 +239,59 @@
return true;
}
});
},

initInsertLabel: function(toolbar) {
var self = this;
var insertLabelModal = toolbar.find('.bootstrap-wysihtml5-insert-label-modal');
var labelClass = insertLabelModal.find('.bootstrap-wysihtml5-insert-label-type');
var insertButton = insertLabelModal.find('a.btn-primary');
var initialValue = labelClass.find(':selected').attr('name');
var caretBookmark;

var insertLabel = function() {
var lClass = labelClass.find(':selected').attr('name');
var className = 'label ' + lClass;
labelClass.find('[name="' + lClass + '"]').attr('selected', 'selected');

console.log(self.editor.composer.selection);
console.log(self.editor.composer.selection.getRange());

self.editor.currentView.element.focus();
if (caretBookmark) {
self.editor.composer.selection.setBookmark(caretBookmark);
caretBookmark = null;
}

self.editor.composer.commands.exec('formatInline', 'span', className, new RegExp('.+', "g"));
};

insertButton.click(insertLabel);

insertLabelModal.on('shown', function() {
labelClass.find(':selected').focus();
});

insertLabelModal.on('hide', function() {
self.editor.currentView.element.focus();
});

toolbar.find('a[data-wysihtml5-command=createLabel]').click(function() {
var activeButton = $(this).hasClass('wysihtml5-command-active');

if (!activeButton) {
self.editor.currentView.element.focus(false);
caretBookmark = self.editor.composer.selection.getBookmark();
insertLabelModal.appendTo('body').modal('show');
insertLabelModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
e.stopPropagation();
});
return false;
}
else {
return true;
}
});
}
};

Expand Down Expand Up @@ -286,6 +343,7 @@
'html': false,
'link': true,
'image': true,
'label': true,
events: {},
parserRules: {
classes: {
Expand Down
12 changes: 11 additions & 1 deletion src/locales/bootstrap-wysihtml5.ca-CT.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
navy: "Blau marí",
blue: "Blau",
orange: "Taronja"
}
},
label: {
insert : 'Afegir etiqueta',
default: 'Predeterminat',
primary: 'Primari',
success: 'Èxit',
info : 'Informaciò',
warning: 'Advertència',
danger : 'Perill',
cancel : 'Cancel.lar'
},
};
}(jQuery));
12 changes: 11 additions & 1 deletion src/locales/bootstrap-wysihtml5.en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
navy: 'Navy',
blue: 'Blue',
orange: 'Orange'
}
},
label: {
insert : 'Insert label',
default: 'Default',
primary: 'Primary',
success: 'Success',
info : 'Info',
warning: 'Warning',
danger : 'Danger',
cancel : 'Cancel'
},
};
}(jQuery));
12 changes: 11 additions & 1 deletion src/locales/bootstrap-wysihtml5.es-ES.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
navy: "Azul Marino",
blue: "Azul",
orange: "Naranja"
}
},
label: {
insert : 'Insertar etiqueta',
default: 'Predeterminado',
primary: 'Primario',
success: 'Éxito',
info : 'Información',
warning: 'Advertencia',
danger : 'Peligro',
cancel : 'Cancelar'
},
};
}(jQuery));
40 changes: 40 additions & 0 deletions src/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,46 @@ function program1(depth0,data) {
return buffer;
});

this["wysihtml5"]["tpl"]["label"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this;

function program1(depth0,data) {

var buffer = "", stack1;
buffer += "btn-"
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.size)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1));
return buffer;
}

buffer += "<li>\n <div class=\"bootstrap-wysihtml5-insert-label-modal modal fade\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <a class=\"close\" data-dismiss=\"modal\">&times;</a>\n <h3>"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</h3>\n </div>\n <div class=\"modal-body\">\n <select class=\"bootstrap-wysihtml5-insert-label-type\">\n <option name=\"label-default\" selected=\"selected\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1['default'])),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-primary\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.primary)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-success\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.success)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-info\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.info)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-warning\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.warning)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n <option name=\"label-danger\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.danger)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</option>\n </select>\n </div>\n <div class=\"modal-footer\">\n <a class=\"btn btn-default\" data-dismiss=\"modal\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.cancel)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</a>\n <a href=\"#\" class=\"btn btn-primary\" data-dismiss=\"modal\">"
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</a>\n </div>\n </div>\n </div>\n </div>\n <a class=\"btn ";
stack2 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.size), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += " btn-default\" data-wysihtml5-command=\"createLabel\" title=\""
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = (depth0 && depth0.locale)),stack1 == null || stack1 === false ? stack1 : stack1.label)),stack1 == null || stack1 === false ? stack1 : stack1.insert)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\" tabindex=\"-1\">\n <span class=\"glyphicon glyphicon-tag\"></span>\n </a>\n</li>\n";
return buffer;
});

this["wysihtml5"]["tpl"]["link"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
Expand Down