Working : New version of bootstrap-editable + Update of currency pages to bootstrap3

This commit is contained in:
mespeche
2013-09-05 09:56:06 +02:00
parent 86892f7af6
commit 75513c778a
5 changed files with 355 additions and 546 deletions

View File

@@ -1,8 +1,7 @@
/*! X-editable - v1.4.6 /*! X-editable - v1.4.7
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
.editableform { .editableform {
margin-bottom: 0; /* overwrites bootstrap margin */ margin-bottom: 0; /* overwrites bootstrap margin */
} }
@@ -18,45 +17,45 @@
vertical-align: top; vertical-align: top;
margin-left: 7px; margin-left: 7px;
/* inline-block emulation for IE7*/ /* inline-block emulation for IE7*/
zoom: 1; zoom: 1;
*display: inline; *display: inline;
} }
.editable-buttons.editable-buttons-bottom { .editable-buttons.editable-buttons-bottom {
display: block; display: block;
margin-top: 7px; margin-top: 7px;
margin-left: 0; margin-left: 0;
} }
.editable-input { .editable-input {
vertical-align: top; vertical-align: top;
display: inline-block; /* should be inline to take effect of parent's white-space: nowrap */ display: inline-block; /* should be inline to take effect of parent's white-space: nowrap */
width: auto; /* bootstrap-responsive has width: 100% that breakes layout */ width: auto; /* bootstrap-responsive has width: 100% that breakes layout */
white-space: normal; /* reset white-space decalred in parent*/ white-space: normal; /* reset white-space decalred in parent*/
/* display-inline emulation for IE7*/ /* display-inline emulation for IE7*/
zoom: 1; zoom: 1;
*display: inline; *display: inline;
} }
.editable-buttons .editable-cancel { .editable-buttons .editable-cancel {
margin-left: 7px; margin-left: 7px;
} }
/*for jquery-ui buttons need set height to look more pretty*/ /*for jquery-ui buttons need set height to look more pretty*/
.editable-buttons button.ui-button-icon-only { .editable-buttons button.ui-button-icon-only {
height: 24px; height: 24px;
width: 30px; width: 30px;
} }
.editableform-loading { .editableform-loading {
background: url('../img/loading.gif') center center no-repeat; background: url('../img/loading.gif') center center no-repeat;
height: 25px; height: 25px;
width: auto; width: auto;
min-width: 25px; min-width: 25px;
} }
.editable-inline .editableform-loading { .editable-inline .editableform-loading {
background-position: left 5px; background-position: left 5px;
} }
.editable-error-block { .editable-error-block {
@@ -68,17 +67,17 @@
/*add padding for jquery ui*/ /*add padding for jquery ui*/
.editable-error-block.ui-state-error { .editable-error-block.ui-state-error {
padding: 3px; padding: 3px;
} }
.editable-error { .editable-error {
color: red; color: red;
} }
/* ---- For specific types ---- */ /* ---- For specific types ---- */
.editableform .editable-date { .editableform .editable-date {
padding: 0; padding: 0;
margin: 0; margin: 0;
float: left; float: left;
} }
@@ -86,25 +85,25 @@
/* move datepicker icon to center of add-on button. See https://github.com/vitalets/x-editable/issues/183 */ /* move datepicker icon to center of add-on button. See https://github.com/vitalets/x-editable/issues/183 */
.editable-inline .add-on .icon-th { .editable-inline .add-on .icon-th {
margin-top: 3px; margin-top: 3px;
margin-left: 1px; margin-left: 1px;
} }
/* checklist vertical alignment */ /* checklist vertical alignment */
.editable-checklist label input[type="checkbox"], .editable-checklist label input[type="checkbox"],
.editable-checklist label span { .editable-checklist label span {
vertical-align: middle; vertical-align: middle;
margin: 0; margin: 0;
} }
.editable-checklist label { .editable-checklist label {
white-space: nowrap; white-space: nowrap;
} }
/* set exact width of textarea to fit buttons toolbar */ /* set exact width of textarea to fit buttons toolbar */
.editable-wysihtml5 { .editable-wysihtml5 {
width: 566px; width: 566px;
height: 250px; height: 250px;
} }
/* clear button shown as link in date inputs */ /* clear button shown as link in date inputs */
@@ -119,16 +118,16 @@
.editable-clear-x { .editable-clear-x {
background: url('../img/clear.png') center center no-repeat; background: url('../img/clear.png') center center no-repeat;
display: block; display: block;
width: 13px; width: 13px;
height: 13px; height: 13px;
position: absolute; position: absolute;
opacity: 0.6; opacity: 0.6;
z-index: 100; z-index: 100;
top: 50%; top: 50%;
right: 6px; right: 6px;
margin-top: -6px; margin-top: -6px;
} }
.editable-clear-x:hover { .editable-clear-x:hover {
@@ -140,49 +139,49 @@
} }
.editable-container.editable-popup { .editable-container.editable-popup {
max-width: none !important; /* without this rule poshytip/tooltip does not stretch */ max-width: none !important; /* without this rule poshytip/tooltip does not stretch */
} }
.editable-container.popover { .editable-container.popover {
width: auto; /* without this rule popover does not stretch */ width: auto; /* without this rule popover does not stretch */
} }
.editable-container.editable-inline { .editable-container.editable-inline {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
width: auto; width: auto;
/* inline-block emulation for IE7*/ /* inline-block emulation for IE7*/
zoom: 1; zoom: 1;
*display: inline; *display: inline;
} }
.editable-container.ui-widget { .editable-container.ui-widget {
font-size: inherit; /* jqueryui widget font 1.1em too big, overwrite it */ font-size: inherit; /* jqueryui widget font 1.1em too big, overwrite it */
z-index: 9990; /* should be less than select2 dropdown z-index to close dropdown first when click */ z-index: 9990; /* should be less than select2 dropdown z-index to close dropdown first when click */
} }
.editable-click, .editable-click,
a.editable-click, a.editable-click,
a.editable-click:hover { a.editable-click:hover {
text-decoration: none; text-decoration: none;
border-bottom: dotted 1px #0088cc; border-bottom: dashed 1px #0088cc;
} }
.editable-click.editable-disabled, .editable-click.editable-disabled,
a.editable-click.editable-disabled, a.editable-click.editable-disabled,
a.editable-click.editable-disabled:hover { a.editable-click.editable-disabled:hover {
color: #585858; color: #585858;
cursor: default; cursor: default;
border-bottom: none; border-bottom: none;
} }
.editable-empty, .editable-empty:hover, .editable-empty:focus{ .editable-empty, .editable-empty:hover, .editable-empty:focus{
font-style: italic; font-style: italic;
color: #DD1144; color: #DD1144;
/* border-bottom: none; */ /* border-bottom: none; */
text-decoration: none; text-decoration: none;
} }
.editable-unsaved { .editable-unsaved {
font-weight: bold; font-weight: bold;
} }
.editable-unsaved:after { .editable-unsaved:after {
@@ -194,12 +193,12 @@ a.editable-click.editable-disabled:hover {
-moz-transition: background-color 1400ms ease-out; -moz-transition: background-color 1400ms ease-out;
-o-transition: background-color 1400ms ease-out; -o-transition: background-color 1400ms ease-out;
-ms-transition: background-color 1400ms ease-out; -ms-transition: background-color 1400ms ease-out;
transition: background-color 1400ms ease-out; transition: background-color 1400ms ease-out;
} }
/*see https://github.com/vitalets/x-editable/issues/139 */ /*see https://github.com/vitalets/x-editable/issues/139 */
.form-horizontal .editable .form-horizontal .editable
{ {
padding-top: 5px; padding-top: 5px;
display:inline-block; display:inline-block;
} }

View File

@@ -1,8 +1,7 @@
/*! X-editable - v1.4.6 /*! X-editable - v1.4.7
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery * In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable * http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */ * Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
/** /**
Form with single input element, two buttons and two states: normal/loading. Form with single input element, two buttons and two states: normal/loading.
Applied as jQuery method to DIV tag (not to form tag!). This is because form can be in loading state when spinner shown. Applied as jQuery method to DIV tag (not to form tag!). This is because form can be in loading state when spinner shown.
@@ -33,6 +32,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//set initial value //set initial value
//todo: may be add check: typeof str === 'string' ? //todo: may be add check: typeof str === 'string' ?
this.value = this.input.str2value(this.options.value); this.value = this.input.str2value(this.options.value);
//prerender: get input.$input
this.input.prerender();
}, },
initTemplate: function() { initTemplate: function() {
this.$form = $($.fn.editableform.template); this.$form = $($.fn.editableform.template);
@@ -80,9 +82,8 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
this.initInput(); this.initInput();
//append input to form //append input to form
this.input.prerender();
this.$form.find('div.editable-input').append(this.input.$tpl); this.$form.find('div.editable-input').append(this.input.$tpl);
//append form to container //append form to container
this.$div.append(this.$form); this.$div.append(this.$form);
@@ -620,6 +621,9 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
//error class attached to editable-error-block //error class attached to editable-error-block
$.fn.editableform.errorBlockClass = 'editable-error'; $.fn.editableform.errorBlockClass = 'editable-error';
//engine
$.fn.editableform.engine = 'jqeury';
}(window.jQuery)); }(window.jQuery));
/** /**
@@ -898,6 +902,8 @@ Applied as jQuery method.
containerDataName: null, //object name in element's .data() containerDataName: null, //object name in element's .data()
innerCss: null, //tbd in child class innerCss: null, //tbd in child class
containerClass: 'editable-container editable-popup', //css class applied to container element containerClass: 'editable-container editable-popup', //css class applied to container element
defaults: {}, //container itself defaults
init: function(element, options) { init: function(element, options) {
this.$element = $(element); this.$element = $(element);
//since 1.4.1 container do not use data-* directly as they already merged into options. //since 1.4.1 container do not use data-* directly as they already merged into options.
@@ -975,10 +981,9 @@ Applied as jQuery method.
throw new Error(this.containerName + ' not found. Have you included corresponding js file?'); throw new Error(this.containerName + ' not found. Have you included corresponding js file?');
} }
var cDef = $.fn[this.containerName].defaults;
//keys defined in container defaults go to container, others go to form //keys defined in container defaults go to container, others go to form
for(var k in this.options) { for(var k in this.options) {
if(k in cDef) { if(k in this.defaults) {
this.containerOptions[k] = this.options[k]; this.containerOptions[k] = this.options[k];
} else { } else {
this.formOptions[k] = this.options[k]; this.formOptions[k] = this.options[k];
@@ -2249,7 +2254,7 @@ Makes editable any HTML element on the page. Applied as jQuery method.
@since 1.4.5 @since 1.4.5
@default #FFFF80 @default #FFFF80
**/ **/
highlight: '#FFFF80' highlight: '#FFFF80'
}; };
}(window.jQuery)); }(window.jQuery));
@@ -2415,7 +2420,7 @@ To create your own input you can inherit from this class.
}, },
// -------- helper functions -------- // -------- helper functions --------
setClass: function() { setClass: function() {
if(this.options.inputclass) { if(this.options.inputclass) {
this.$input.addClass(this.options.inputclass); this.$input.addClass(this.options.inputclass);
} }
@@ -2447,9 +2452,9 @@ To create your own input you can inherit from this class.
@property inputclass @property inputclass
@type string @type string
@default input-medium @default null
**/ **/
inputclass: 'input-medium', inputclass: null,
//scope for external methods (e.g. source defined as function) //scope for external methods (e.g. source defined as function)
//for internal use only //for internal use only
scope: null, scope: null,
@@ -3817,7 +3822,7 @@ $(function(){
@type string @type string
@default ', ' @default ', '
**/ **/
viewseparator: ', ' viewseparator: ', '
}); });
$.fn.editabletypes.select2 = Constructor; $.fn.editabletypes.select2 = Constructor;
@@ -4343,7 +4348,14 @@ $(function(){
$.extend(Constructor.prototype, { $.extend(Constructor.prototype, {
render: function () { render: function () {
this.$input.combodate(this.options.combodate); this.$input.combodate(this.options.combodate);
if($.fn.editableform.engine === 'bs3') {
this.$input.siblings().find('select').addClass('form-control');
}
if(this.options.inputclass) {
this.$input.siblings().find('select').addClass(this.options.inputclass);
}
//"clear" link //"clear" link
/* /*
if(this.options.clear) { if(this.options.clear) {
@@ -4468,29 +4480,71 @@ $(function(){
}(window.jQuery)); }(window.jQuery));
/* /*
Editableform based on Twitter Bootstrap Editableform based on Twitter Bootstrap 3
*/ */
(function ($) { (function ($) {
"use strict"; "use strict";
//store parent methods
var pInitInput = $.fn.editableform.Constructor.prototype.initInput;
$.extend($.fn.editableform.Constructor.prototype, { $.extend($.fn.editableform.Constructor.prototype, {
initTemplate: function() { initTemplate: function() {
this.$form = $($.fn.editableform.template); this.$form = $($.fn.editableform.template);
this.$form.find('.control-group').addClass('form-group');
this.$form.find('.editable-error-block').addClass('help-block'); this.$form.find('.editable-error-block').addClass('help-block');
} },
initInput: function() {
pInitInput.apply(this);
//for bs3 set default class `input-sm` to standard inputs
var emptyInputClass = this.input.options.inputclass === null || this.input.options.inputclass === false;
var defaultClass = 'input-sm';
//bs3 add `form-control` class to standard inputs
var stdtypes = 'text,select,textarea,password,email,url,tel,number,range,time'.split(',');
if(~$.inArray(this.input.type, stdtypes)) {
this.input.$input.addClass('form-control');
if(emptyInputClass) {
this.input.options.inputclass = defaultClass;
this.input.$input.addClass(defaultClass);
}
}
//apply bs3 size class also to buttons (to fit size of control)
var $btn = this.$form.find('.editable-buttons');
var classes = emptyInputClass ? [defaultClass] : this.input.options.inputclass.split(' ');
for(var i=0; i<classes.length; i++) {
// `btn-sm` is default now
/*
if(classes[i].toLowerCase() === 'input-sm') {
$btn.find('button').addClass('btn-sm');
}
*/
if(classes[i].toLowerCase() === 'input-lg') {
$btn.find('button').removeClass('btn-sm').addClass('btn-lg');
}
}
}
}); });
//buttons //buttons
$.fn.editableform.buttons = '<button type="submit" class="btn btn-primary editable-submit"><i class="icon-ok icon-white"></i></button>'+ $.fn.editableform.buttons =
'<button type="button" class="btn editable-cancel"><i class="icon-remove"></i></button>'; '<button type="submit" class="btn btn-primary btn-sm editable-submit">'+
'<i class="glyphicon glyphicon-ok"></i>'+
'</button>'+
'<button type="button" class="btn btn-default btn-sm editable-cancel">'+
'<i class="glyphicon glyphicon-remove"></i>'+
'</button>';
//error classes //error classes
$.fn.editableform.errorGroupClass = 'error'; $.fn.editableform.errorGroupClass = 'has-error';
$.fn.editableform.errorBlockClass = null; $.fn.editableform.errorBlockClass = null;
//engine
$.fn.editableform.engine = 'bs3';
}(window.jQuery)); }(window.jQuery));
/** /**
* Editable Popover * Editable Popover3 (for Bootstrap 3)
* --------------------- * ---------------------
* requires bootstrap-popover.js * requires bootstrap-popover.js
*/ */
@@ -4500,15 +4554,16 @@ Editableform based on Twitter Bootstrap
//extend methods //extend methods
$.extend($.fn.editableContainer.Popup.prototype, { $.extend($.fn.editableContainer.Popup.prototype, {
containerName: 'popover', containerName: 'popover',
//for compatibility with bootstrap <= 2.2.1 (content inserted into <p> instead of directly .popover-content) containerDataName: 'bs.popover',
innerCss: $.fn.popover && $($.fn.popover.defaults.template).find('p').length ? '.popover-content p' : '.popover-content', innerCss: '.popover-content',
defaults: $.fn.popover.Constructor.DEFAULTS,
initContainer: function(){ initContainer: function(){
$.extend(this.containerOptions, { $.extend(this.containerOptions, {
trigger: 'manual', trigger: 'manual',
selector: false, selector: false,
content: ' ', content: ' ',
template: $.fn.popover.defaults.template template: this.defaults.template
}); });
//as template property is used in inputs, hide it from popover //as template property is used in inputs, hide it from popover
@@ -4548,10 +4603,11 @@ Editableform based on Twitter Bootstrap
/** /**
* move popover to new position. This function mainly copied from bootstrap-popover. * move popover to new position. This function mainly copied from bootstrap-popover.
*/ */
/*jshint laxcomma: true*/ /*jshint laxcomma: true, eqeqeq: false*/
setPosition: function () { setPosition: function () {
(function() { (function() {
/*
var $tip = this.tip() var $tip = this.tip()
, inside , inside
, pos , pos
@@ -4661,9 +4717,27 @@ Editableform based on Twitter Bootstrap
.offset(tp) .offset(tp)
.addClass(placement) .addClass(placement)
.addClass('in'); .addClass('in');
*/
var $tip = this.tip();
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement;
var pos = this.getPosition();
var actualWidth = $tip[0].offsetWidth;
var actualHeight = $tip[0].offsetHeight;
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight);
this.applyPlacement(calculatedOffset, placement);
}).call(this.container()); }).call(this.container());
/*jshint laxcomma: false*/ /*jshint laxcomma: false, eqeqeq: true*/
} }
}); });
@@ -6555,273 +6629,4 @@ Automatically shown in inline mode.
$.fn.editabletypes.datetimefield = DateTimeField; $.fn.editabletypes.datetimefield = DateTimeField;
}(window.jQuery));
/**
Typeahead input (bootstrap only). Based on Twitter Bootstrap [typeahead](http://twitter.github.com/bootstrap/javascript.html#typeahead).
Depending on `source` format typeahead operates in two modes:
* **strings**:
When `source` defined as array of strings, e.g. `['text1', 'text2', 'text3' ...]`.
User can submit one of these strings or any text entered in input (even if it is not matching source).
* **objects**:
When `source` defined as array of objects, e.g. `[{value: 1, text: "text1"}, {value: 2, text: "text2"}, ...]`.
User can submit only values that are in source (otherwise `null` is submitted). This is more like *dropdown* behavior.
@class typeahead
@extends list
@since 1.4.1
@final
@example
<a href="#" id="country" data-type="typeahead" data-pk="1" data-url="/post" data-original-title="Input country"></a>
<script>
$(function(){
$('#country').editable({
value: 'ru',
source: [
{value: 'gb', text: 'Great Britain'},
{value: 'us', text: 'United States'},
{value: 'ru', text: 'Russia'}
]
});
});
</script>
**/
(function ($) {
"use strict";
var Constructor = function (options) {
this.init('typeahead', options, Constructor.defaults);
//overriding objects in config (as by default jQuery extend() is not recursive)
this.options.typeahead = $.extend({}, Constructor.defaults.typeahead, {
//set default methods for typeahead to work with objects
matcher: this.matcher,
sorter: this.sorter,
highlighter: this.highlighter,
updater: this.updater
}, options.typeahead);
};
$.fn.editableutils.inherit(Constructor, $.fn.editabletypes.list);
$.extend(Constructor.prototype, {
renderList: function() {
this.$input = this.$tpl.is('input') ? this.$tpl : this.$tpl.find('input[type="text"]');
//set source of typeahead
this.options.typeahead.source = this.sourceData;
//apply typeahead
this.$input.typeahead(this.options.typeahead);
//patch some methods in typeahead
var ta = this.$input.data('typeahead');
ta.render = $.proxy(this.typeaheadRender, ta);
ta.select = $.proxy(this.typeaheadSelect, ta);
ta.move = $.proxy(this.typeaheadMove, ta);
this.renderClear();
this.setClass();
this.setAttr('placeholder');
},
value2htmlFinal: function(value, element) {
if(this.getIsObjects()) {
var items = $.fn.editableutils.itemsByValue(value, this.sourceData);
$(element).text(items.length ? items[0].text : '');
} else {
$(element).text(value);
}
},
html2value: function (html) {
return html ? html : null;
},
value2input: function(value) {
if(this.getIsObjects()) {
var items = $.fn.editableutils.itemsByValue(value, this.sourceData);
this.$input.data('value', value).val(items.length ? items[0].text : '');
} else {
this.$input.val(value);
}
},
input2value: function() {
if(this.getIsObjects()) {
var value = this.$input.data('value'),
items = $.fn.editableutils.itemsByValue(value, this.sourceData);
if(items.length && items[0].text.toLowerCase() === this.$input.val().toLowerCase()) {
return value;
} else {
return null; //entered string not found in source
}
} else {
return this.$input.val();
}
},
/*
if in sourceData values <> texts, typeahead in "objects" mode:
user must pick some value from list, otherwise `null` returned.
if all values == texts put typeahead in "strings" mode:
anything what entered is submited.
*/
getIsObjects: function() {
if(this.isObjects === undefined) {
this.isObjects = false;
for(var i=0; i<this.sourceData.length; i++) {
if(this.sourceData[i].value !== this.sourceData[i].text) {
this.isObjects = true;
break;
}
}
}
return this.isObjects;
},
/*
Methods borrowed from text input
*/
activate: $.fn.editabletypes.text.prototype.activate,
renderClear: $.fn.editabletypes.text.prototype.renderClear,
postrender: $.fn.editabletypes.text.prototype.postrender,
toggleClear: $.fn.editabletypes.text.prototype.toggleClear,
clear: function() {
$.fn.editabletypes.text.prototype.clear.call(this);
this.$input.data('value', '');
},
/*
Typeahead option methods used as defaults
*/
/*jshint eqeqeq:false, curly: false, laxcomma: true, asi: true*/
matcher: function (item) {
return $.fn.typeahead.Constructor.prototype.matcher.call(this, item.text);
},
sorter: function (items) {
var beginswith = []
, caseSensitive = []
, caseInsensitive = []
, item
, text;
while (item = items.shift()) {
text = item.text;
if (!text.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item);
else if (~text.indexOf(this.query)) caseSensitive.push(item);
else caseInsensitive.push(item);
}
return beginswith.concat(caseSensitive, caseInsensitive);
},
highlighter: function (item) {
return $.fn.typeahead.Constructor.prototype.highlighter.call(this, item.text);
},
updater: function (item) {
this.$element.data('value', item.value);
return item.text;
},
/*
Overwrite typeahead's render method to store objects.
There are a lot of disscussion in bootstrap repo on this point and still no result.
See https://github.com/twitter/bootstrap/issues/5967
This function just store item via jQuery data() method instead of attr('data-value')
*/
typeaheadRender: function (items) {
var that = this;
items = $(items).map(function (i, item) {
// i = $(that.options.item).attr('data-value', item)
i = $(that.options.item).data('item', item);
i.find('a').html(that.highlighter(item));
return i[0];
});
//add option to disable autoselect of first line
//see https://github.com/twitter/bootstrap/pull/4164
if (this.options.autoSelect) {
items.first().addClass('active');
}
this.$menu.html(items);
return this;
},
//add option to disable autoselect of first line
//see https://github.com/twitter/bootstrap/pull/4164
typeaheadSelect: function () {
var val = this.$menu.find('.active').data('item')
if(this.options.autoSelect || val){
this.$element
.val(this.updater(val))
.change()
}
return this.hide()
},
/*
if autoSelect = false and nothing matched we need extra press onEnter that is not convinient.
This patch fixes it.
*/
typeaheadMove: function (e) {
if (!this.shown) return
switch(e.keyCode) {
case 9: // tab
case 13: // enter
case 27: // escape
if (!this.$menu.find('.active').length) return
e.preventDefault()
break
case 38: // up arrow
e.preventDefault()
this.prev()
break
case 40: // down arrow
e.preventDefault()
this.next()
break
}
e.stopPropagation()
}
/*jshint eqeqeq: true, curly: true, laxcomma: false, asi: false*/
});
Constructor.defaults = $.extend({}, $.fn.editabletypes.list.defaults, {
/**
@property tpl
@default <input type="text">
**/
tpl:'<input type="text">',
/**
Configuration of typeahead. [Full list of options](http://twitter.github.com/bootstrap/javascript.html#typeahead).
@property typeahead
@type object
@default null
**/
typeahead: null,
/**
Whether to show `clear` button
@property clear
@type boolean
@default true
**/
clear: true
});
$.fn.editabletypes.typeahead = Constructor;
}(window.jQuery)); }(window.jQuery));

File diff suppressed because one or more lines are too long

View File

@@ -189,149 +189,157 @@
{* Adding a new currency *} {* Adding a new currency *}
<div class="modal hide fade" id="add_currency_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="add_currency_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new currency"}</h3> <h3>{intl l="Create a new currency"}</h3>
</div>
{form name="thelia.admin.currency.creation"}
<form method="POST" action="{url path='/admin/configuration/currencies/create'}" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created currency ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies/update' currency_id='_ID_'}" />
{/form_field}
{* We do not allow users to create secured currencies from here *}
<div class="modal-body">
{if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if}
<div class="form-group">
<label class="control-label">
{intl l='Name *'}
</label>
<div class="controls">
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
<div class="input-group">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
</span>
{/form_field}
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the currency name in the default language ($TITLE)"}</div>
{/loop}
</div>
</div>
<div class="form-group">
<label class="control-label">
{intl l='ISO 4217 code *'}
</label>
<div class="controls">
{form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}">
</span>
<div class="help-block">
<a href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">{intl l='More information about ISO 4217'}</a>
</div>
{/form_field}
</div>
</div>
<div class="form-group">
<label class="control-label">
{intl l='Symbol *'}
</label>
<div class="controls">
{form_field form=$form field='symbol'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}">
</span>
{/form_field}
</div>
</div>
<div class="form-group">
<label class="control-label">
{intl l='Rate *'}
</label>
<div class="controls">
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" class="form-control" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}">
</span>
<div class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</div>
{/form_field}
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this currency"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
</div>
</form>
{/form}
</div> </div>
</div>
{form name="thelia.admin.currency.creation"}
<form method="POST" action="{url path='/admin/configuration/currencies/create'}" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created currency ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies/update' currency_id='_ID_'}" />
{/form_field}
{* We do not allow users to create secured currencies from here *}
<div class="modal-body">
{if $form_error}<div class="alert alert-block alert-error" id="add_currency_dialog_error">{$form_error_message}</div>{/if}
<div class="control-group">
<label class="control-label">
{intl l='Name *'}
</label>
<div class="controls">
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
<div class="input-group">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Currency name'}" placeholder="{intl l='Name'}">
</span>
{/form_field}
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the currency name in the default language ($TITLE)"}</div>
{/loop}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='ISO 4217 code *'}
</label>
<div class="controls">
{form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='ISO 4217 code'}" placeholder="{intl l='Code'}">
</span>
<div class="help-block">
<a href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">{intl l='More information about ISO 4217'}</a>
</div>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Symbol *'}
</label>
<div class="controls">
{form_field form=$form field='symbol'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}">
</span>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Rate *'}
</label>
<div class="controls">
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Currency rate'}" placeholder="{intl l='Rate'}">
</span>
<div class="help-block">{intl l="The rate from Euro (Price in Euro * rate = Price in this currency)"}</div>
{/form_field}
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this currency"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
</div>
</form>
{/form}
</div> </div>
{* Delete confirmation dialog *} {* Delete confirmation dialog *}
<div class="modal hide fade" id="delete_currency_dialog" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="delete_currency_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a currency"}</h3>
</div>
<div class="modal-header"> <div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <p>{intl l="Do you really want to delete this currency ?"}</p>
<h3>{intl l="Delete a currency"}</h3> </div>
<form method="post" action="{url path='/admin/configuration/currencies/delete'}">
<input type="hidden" name="currency_id" id="currency_delete_id" value="" />
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Yes"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
</div>
</form>
</div> </div>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this currency ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/currencies/delete'}">
<input type="hidden" name="currency_id" id="currency_delete_id" value="" />
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Yes"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
</div>
</form>
</div> </div>
{/block} {/block}
{block name="after-javascript-include"}
{javascripts file='assets/bootstrap-editable/js/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{/block}
{block name="javascript-initialization"} {block name="javascript-initialization"}
{javascripts file='assets/bootstrap-editable/js/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script> <script>
$(function() { $(function() {

View File

@@ -27,100 +27,95 @@
</div> </div>
<div class="form-container"> <div class="form-container">
<div class="form-horizontal col-md-12"> <div class="col-md-12">
{form name="thelia.admin.currency.modification"} {form name="thelia.admin.currency.modification"}
<form method="POST" action="{url path='/admin/configuration/currencies/save'}" {form_enctype form=$form}> <form method="POST" action="{url path='/admin/configuration/currencies/save'}" {form_enctype form=$form}>
<fieldset>
{* Be sure to get the currency ID, even if the form could not be validated *} {* Be sure to get the currency ID, even if the form could not be validated *}
<input type="hidden" name="currency_id" value="{$currency_id}" /> <input type="hidden" name="currency_id" value="{$currency_id}" />
{include file="includes/inner-form-toolbar.html"} {include file="includes/inner-form-toolbar.html"}
{form_hidden_fields form=$form} {form_hidden_fields form=$form}
{form_field form=$form field='success_url'} {form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies'}" /> <input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies'}" />
{/form_field} {/form_field}
{form_field form=$form field='locale'} {form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$edit_language_locale}" /> <input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field} {/form_field}
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if} {if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if}
<div class="col-md-6">
<div class="row"> <div class="form-group">
<div class="col-md-6"> <label class="control-label">
<div class="control-group"> {intl l='Name *'}
<label class="control-label"> </label>
{intl l='Name *'}
</label>
<div class="controls"> <div class="controls">
{form_field form=$form field='name'} {form_field form=$form field='name'}
<span {if $error}class="error"{/if}> <span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="input-medium"> <input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency name'}" placeholder="{intl l='Currency name'}" class="form-control input-medium">
</span> </span>
{/form_field} {/form_field}
</div> </div>
</div> </div>
<div class="control-group"> <div class="form-group">
<label class="control-label"> <label class="control-label">
{intl l='ISO 4217 Code *'} {intl l='ISO 4217 Code *'}
<span class="label-help-block"><a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">List of ISO 4217 code</a></span> <span class="label-help-block"><a title="{intl l='More information about ISO 4217'}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">List of ISO 4217 code</a></span>
</label> </label>
<div class="controls">
{form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="input-mini">
</span>
{/form_field}
</div>
</div>
</div>
<div class="col-md-6">
<div class="control-group">
<label class="control-label">
{intl l='Symbol *'}
<span class="label-help-block">The symbol, sur as $, £, &euro;...</span>
</label>
<div class="controls">
{form_field form=$form field='symbol'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="input-mini">
</span>
{/form_field}
</div>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Rate from &euro; *'}
<span class="label-help-block">The rate from Euro</span>
</label>
<div class="controls">
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="input-mini">
</span>
{/form_field}
<span class="help-block">Price in Euro x rate = Price in this currency</span>
</div>
</div>
</div>
</div>
<div class="control-group">
<div class="controls"> <div class="controls">
<p>{intl l='Currency created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p> {form_field form=$form field='code'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency ISO 4217 Code'}" placeholder="{intl l='Code'}" class="form-control input-mini">
</span>
{/form_field}
</div> </div>
</div> </div>
</div>
</fieldset> <div class="col-md-6">
<div class="form-group">
<label class="control-label">
{intl l='Symbol *'}
<span class="label-help-block">The symbol, sur as $, £, &euro;...</span>
</label>
<div class="controls">
{form_field form=$form field='symbol'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Currency symbol'}" placeholder="{intl l='Symbol'}" class="form-control input-mini">
</span>
{/form_field}
</div>
</div>
<div class="form-group">
<label class="control-label">
{intl l='Rate from &euro; *'}
<span class="label-help-block">The rate from Euro</span>
</label>
<div class="controls">
{form_field form=$form field='rate'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Rate from Euro'}" placeholder="{intl l='Rate'}" class="form-control input-mini">
</span>
{/form_field}
<span class="help-block">Price in Euro x rate = Price in this currency</span>
</div>
</div>
</div>
</form> </form>
{/form} {/form}
</div> </div>