modified country and date/time chooser

This commit is contained in:
severin
2014-01-05 01:26:11 +01:00
parent 25fe7c8725
commit ecfd5738ce
11 changed files with 3433 additions and 1178 deletions

View File

@@ -98,6 +98,11 @@ feature -- Change
end
end
set_type (t: STRING)
do
type := t
end
feature -- Implementation
value: STRING

View File

@@ -24,7 +24,7 @@ feature {NONE} -- Initialization
make (t: STRING)
-- Initialize with specified control name and text to be displayed in this textarea
do
make_input ( t)
make_input (t)
tag_name := "textarea"
end

View File

@@ -31,7 +31,7 @@ create
feature {NONE} -- Initialization
make (t: STRING)
-- Make a dropdown control with specified tag name (such as li) and menu title
-- Make a country chooser control with specified tag name (such as li) and menu title
local
temp: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
options: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]

View File

@@ -17,7 +17,6 @@
<library name="uri_template" location="..\..\..\library\text\parser\uri_template\uri_template-safe.ecf"/>
<library name="wsf" location="..\..\..\library\server\wsf\wsf-safe.ecf"/>
<cluster name="kernel" location=".\kernel\" recursive="true">
<cluster name="widgets" location="\home\severin\Documents\EWF\EWF\draft\library\wsf_js_widget\kernel\widgets\"/>
</cluster>
</target>
</system>

View File

@@ -0,0 +1,257 @@
/*!
* Datepicker for Bootstrap
*
* Copyright 2012 Stefan Petre
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
.clearfix {
*zoom: 1
}
.clearfix:before,.clearfix:after {
display: table;
content: "";
line-height: 0
}
.clearfix:after {
clear: both
}
.hide-text {
font: 0/0 a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0
}
.input-block-level {
display: block;
width: 100%;
min-height: 30px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.bootstrap-datetimepicker-widget {
top: 0;
left: 0;
width: 250px;
padding: 4px;
margin-top: 1px;
z-index: 3000;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px
}
.bootstrap-datetimepicker-widget:before {
content: '';
display: inline-block;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-bottom-color: rgba(0, 0, 0, 0.2);
position: absolute;
top: -7px;
left: 6px
}
.bootstrap-datetimepicker-widget:after {
content: '';
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
position: absolute;
top: -6px;
left: 7px
}
.bootstrap-datetimepicker-widget>ul {
list-style-type: none;
margin: 0
}
.bootstrap-datetimepicker-widget .timepicker-hour,.bootstrap-datetimepicker-widget .timepicker-minute,.bootstrap-datetimepicker-widget .timepicker-second
{
width: 100%;
font-weight: bold;
font-size: 1.2em
}
.bootstrap-datetimepicker-widget table[data-hour-format="12"] .separator
{
width: 4px;
padding: 0;
margin: 0
}
.bootstrap-datetimepicker-widget .datepicker>div {
display: none
}
.bootstrap-datetimepicker-widget .picker-switch {
text-align: center
}
.bootstrap-datetimepicker-widget table {
width: 100%;
margin: 0
}
.bootstrap-datetimepicker-widget td,.bootstrap-datetimepicker-widget th
{
text-align: center;
width: 20px;
height: 20px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px
}
.bootstrap-datetimepicker-widget td.day:hover,.bootstrap-datetimepicker-widget td.hour:hover,.bootstrap-datetimepicker-widget td.minute:hover,.bootstrap-datetimepicker-widget td.second:hover
{
background: #eee;
cursor: pointer
}
.bootstrap-datetimepicker-widget td.old,.bootstrap-datetimepicker-widget td.new
{
color: #999
}
.bootstrap-datetimepicker-widget td.active,.bootstrap-datetimepicker-widget td.active:hover
{
color: #fff;
background-color: #006dcc;
background-image: -moz-linear-gradient(top, #08c, #04c);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c),
to(#04c));
background-image: -webkit-linear-gradient(top, #08c, #04c);
background-image: -o-linear-gradient(top, #08c, #04c);
background-image: linear-gradient(to bottom, #08c, #04c);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',
endColorstr='#ff0044cc', GradientType=0);
border-color: #04c #04c #002a80;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #04c;
filter: progid:DXImageTransform.Microsoft.gradient(enabled= false);
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25)
}
.bootstrap-datetimepicker-widget td.active:hover,.bootstrap-datetimepicker-widget td.active:hover:hover,.bootstrap-datetimepicker-widget td.active:active,.bootstrap-datetimepicker-widget td.active:hover:active,.bootstrap-datetimepicker-widget td.active.active,.bootstrap-datetimepicker-widget td.active:hover.active,.bootstrap-datetimepicker-widget td.active.disabled,.bootstrap-datetimepicker-widget td.active:hover.disabled,.bootstrap-datetimepicker-widget td.active[disabled],.bootstrap-datetimepicker-widget td.active:hover[disabled]
{
color: #fff;
background-color: #04c;
*background-color: #003bb3
}
.bootstrap-datetimepicker-widget td.active:active,.bootstrap-datetimepicker-widget td.active:hover:active,.bootstrap-datetimepicker-widget td.active.active,.bootstrap-datetimepicker-widget td.active:hover.active
{
background-color: #039 \9
}
.bootstrap-datetimepicker-widget td.disabled,.bootstrap-datetimepicker-widget td.disabled:hover
{
background: 0;
color: #999;
cursor: not-allowed
}
.bootstrap-datetimepicker-widget td span {
display: block;
width: 47px;
height: 54px;
line-height: 54px;
float: left;
margin: 2px;
cursor: pointer;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px
}
.bootstrap-datetimepicker-widget td span:hover {
background: #eee
}
.bootstrap-datetimepicker-widget td span.active {
color: #fff;
background-color: #006dcc;
background-image: -moz-linear-gradient(top, #08c, #04c);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c),
to(#04c));
background-image: -webkit-linear-gradient(top, #08c, #04c);
background-image: -o-linear-gradient(top, #08c, #04c);
background-image: linear-gradient(to bottom, #08c, #04c);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',
endColorstr='#ff0044cc', GradientType=0);
border-color: #04c #04c #002a80;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #04c;
filter: progid:DXImageTransform.Microsoft.gradient(enabled= false);
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25)
}
.bootstrap-datetimepicker-widget td span.active:hover,.bootstrap-datetimepicker-widget td span.active:active,.bootstrap-datetimepicker-widget td span.active.active,.bootstrap-datetimepicker-widget td span.active.disabled,.bootstrap-datetimepicker-widget td span.active[disabled]
{
color: #fff;
background-color: #04c;
*background-color: #003bb3
}
.bootstrap-datetimepicker-widget td span.active:active,.bootstrap-datetimepicker-widget td span.active.active
{
background-color: #039 \9
}
.bootstrap-datetimepicker-widget td span.old {
color: #999
}
.bootstrap-datetimepicker-widget td span.disabled,.bootstrap-datetimepicker-widget td span.disabled:hover
{
background: 0;
color: #999;
cursor: not-allowed
}
.bootstrap-datetimepicker-widget th.switch {
width: 145px
}
.bootstrap-datetimepicker-widget th.next,.bootstrap-datetimepicker-widget th.prev
{
font-size: 21px
}
.bootstrap-datetimepicker-widget th.disabled,.bootstrap-datetimepicker-widget th.disabled:hover
{
background: 0;
color: #999;
cursor: not-allowed
}
.bootstrap-datetimepicker-widget thead tr:first-child th {
cursor: pointer
}
.bootstrap-datetimepicker-widget thead tr:first-child th:hover {
background: #eee
}
.input-append.date .add-on i,.input-prepend.date .add-on i {
display: block;
cursor: pointer;
width: 16px;
height: 16px
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,261 @@
/* ==========================================================
* bootstrap-formhelpers-countries.en_US.js
* https://github.com/vlamanna/BootstrapFormHelpers
* ==========================================================
* Copyright 2012 Vincent Lamanna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
var BFHCountriesList = {
'AF': 'Afghanistan',
'AL': 'Albania',
'DZ': 'Algeria',
'AS': 'American Samoa',
'AD': 'Andorra',
'AO': 'Angola',
'AI': 'Anguilla',
'AQ': 'Antarctica' ,
'AG': 'Antigua and Barbuda' ,
'AR': 'Argentina' ,
'AM': 'Armenia' ,
'AW': 'Aruba' ,
'AU': 'Australia' ,
'AT': 'Austria' ,
'AZ': 'Azerbaijan' ,
'BH': 'Bahrain' ,
'BD': 'Bangladesh',
'BB': 'Barbados' ,
'BY': 'Belarus',
'BE': 'Belgium',
'BZ': 'Belize',
'BJ': 'Benin',
'BM': 'Bermuda',
'BT': 'Bhutan',
'BO': 'Bolivia',
'BA': 'Bosnia and Herzegovina',
'BW': 'Botswana',
'BV': 'Bouvet Island',
'BR': 'Brazil',
'IO': 'British Indian Ocean Territory',
'VG': 'British Virgin Islands',
'BN': 'Brunei',
'BG': 'Bulgaria',
'BF': 'Burkina Faso',
'BI': 'Burundi',
'CI': 'Côte d\'Ivoire',
'KH': 'Cambodia',
'CM': 'Cameroon',
'CA': 'Canada',
'CV': 'Cape Verde',
'KY': 'Cayman Islands',
'CF': 'Central African Republic',
'TD': 'Chad',
'CL': 'Chile',
'CN': 'China',
'CX': 'Christmas Island',
'CC': 'Cocos (Keeling) Islands',
'CO': 'Colombia',
'KM': 'Comoros',
'CG': 'Congo',
'CK': 'Cook Islands',
'CR': 'Costa Rica',
'HR': 'Croatia',
'CU': 'Cuba',
'CY': 'Cyprus',
'CZ': 'Czech Republic',
'CD': 'Democratic Republic of the Congo',
'DK': 'Denmark',
'DJ': 'Djibouti',
'DM': 'Dominica',
'DO': 'Dominican Republic',
'TP': 'East Timor',
'EC': 'Ecuador',
'EG': 'Egypt',
'SV': 'El Salvador',
'GQ': 'Equatorial Guinea',
'ER': 'Eritrea',
'EE': 'Estonia',
'ET': 'Ethiopia',
'FO': 'Faeroe Islands',
'FK': 'Falkland Islands',
'FJ': 'Fiji',
'FI': 'Finland',
'MK': 'Former Yugoslav Republic of Macedonia',
'FR': 'France',
'FX': 'France, Metropolitan',
'GF': 'French Guiana',
'PF': 'French Polynesia',
'TF': 'French Southern Territories',
'GA': 'Gabon',
'GE': 'Georgia',
'DE': 'Germany',
'GH': 'Ghana',
'GI': 'Gibraltar',
'GR': 'Greece',
'GL': 'Greenland',
'GD': 'Grenada',
'GP': 'Guadeloupe',
'GU': 'Guam',
'GT': 'Guatemala',
'GN': 'Guinea',
'GW': 'Guinea-Bissau',
'GY': 'Guyana',
'HT': 'Haiti',
'HM': 'Heard and Mc Donald Islands',
'HN': 'Honduras',
'HK': 'Hong Kong',
'HU': 'Hungary',
'IS': 'Iceland',
'IN': 'India',
'ID': 'Indonesia',
'IR': 'Iran',
'IQ': 'Iraq',
'IE': 'Ireland',
'IL': 'Israel',
'IT': 'Italy',
'JM': 'Jamaica',
'JP': 'Japan',
'JO': 'Jordan',
'KZ': 'Kazakhstan',
'KE': 'Kenya',
'KI': 'Kiribati',
'KW': 'Kuwait',
'KG': 'Kyrgyzstan',
'LA': 'Laos',
'LV': 'Latvia',
'LB': 'Lebanon',
'LS': 'Lesotho',
'LR': 'Liberia',
'LY': 'Libya',
'LI': 'Liechtenstein',
'LT': 'Lithuania',
'LU': 'Luxembourg',
'MO': 'Macau',
'MG': 'Madagascar',
'MW': 'Malawi',
'MY': 'Malaysia',
'MV': 'Maldives',
'ML': 'Mali',
'MT': 'Malta',
'MH': 'Marshall Islands',
'MQ': 'Martinique',
'MR': 'Mauritania',
'MU': 'Mauritius',
'MT': 'Mayotte',
'MX': 'Mexico',
'FM': 'Micronesia',
'MD': 'Moldova',
'MC': 'Monaco',
'MN': 'Mongolia',
'ME': 'Montenegro',
'MS': 'Montserrat',
'MA': 'Morocco',
'MZ': 'Mozambique',
'MM': 'Myanmar',
'NA': 'Namibia',
'NR': 'Nauru',
'NP': 'Nepal',
'NL': 'Netherlands',
'AN': 'Netherlands Antilles',
'NC': 'New Caledonia',
'NZ': 'New Zealand',
'NI': 'Nicaragua',
'NE': 'Niger',
'NG': 'Nigeria',
'NU': 'Niue',
'NF': 'Norfolk Island',
'KP': 'North Korea',
'MP': 'Northern Marianas',
'NO': 'Norway',
'OM': 'Oman',
'PK': 'Pakistan',
'PW': 'Palau',
'PA': 'Panama',
'PG': 'Papua New Guinea',
'PY': 'Paraguay',
'PE': 'Peru',
'PH': 'Philippines',
'PN': 'Pitcairn Islands',
'PL': 'Poland',
'PT': 'Portugal',
'PR': 'Puerto Rico',
'QA': 'Qatar',
'RE': 'Reunion',
'RO': 'Romania',
'RU': 'Russia',
'RW': 'Rwanda',
'ST': 'São Tomé and Príncipe',
'SH': 'Saint Helena',
'PM': 'St. Pierre and Miquelon',
'KN': 'Saint Kitts and Nevis',
'LC': 'Saint Lucia',
'VC': 'Saint Vincent and the Grenadines',
'WS': 'Samoa',
'SM': 'San Marino',
'SA': 'Saudi Arabia',
'SN': 'Senegal',
'RS': 'Serbia',
'SC': 'Seychelles',
'SL': 'Sierra Leone',
'SG': 'Singapore',
'SK': 'Slovakia',
'SI': 'Slovenia',
'SB': 'Solomon Islands',
'SO': 'Somalia',
'ZA': 'South Africa',
'GS': 'South Georgia and the South Sandwich Islands',
'KR': 'South Korea',
'ES': 'Spain',
'LK': 'Sri Lanka',
'SD': 'Sudan',
'SR': 'Suriname',
'SJ': 'Svalbard and Jan Mayen Islands',
'SZ': 'Swaziland',
'SE': 'Sweden',
'CH': 'Switzerland',
'SY': 'Syria',
'TW': 'Taiwan',
'TJ': 'Tajikistan',
'TZ': 'Tanzania',
'TH': 'Thailand',
'BS': 'The Bahamas',
'GM': 'The Gambia',
'TG': 'Togo',
'TK': 'Tokelau',
'TO': 'Tonga',
'TT': 'Trinidad and Tobago',
'TN': 'Tunisia',
'TR': 'Turkey',
'TM': 'Turkmenistan',
'TC': 'Turks and Caicos Islands',
'TV': 'Tuvalu',
'VI': 'US Virgin Islands',
'UG': 'Uganda',
'UA': 'Ukraine',
'AE': 'United Arab Emirates',
'GB': 'United Kingdom',
'US': 'United States',
'UM': 'United States Minor Outlying Islands',
'UY': 'Uruguay',
'UZ': 'Uzbekistan',
'VU': 'Vanuatu',
'VA': 'Vatican City',
'VE': 'Venezuela',
'VN': 'Vietnam',
'WF': 'Wallis and Futuna Islands',
'EH': 'Western Sahara',
'YE': 'Yemen',
'ZM': 'Zambia',
'ZW': 'Zimbabwe'
}

View File

@@ -0,0 +1,155 @@
/* ==========================================================
* bootstrap-formhelpers-countries.js
* https://github.com/vlamanna/BootstrapFormHelpers
* ==========================================================
* Copyright 2012 Vincent Lamanna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* COUNTRIES CLASS DEFINITION
* ====================== */
var BFHCountries = function (element, options) {
this.options = $.extend({}, $.fn.bfhcountries.defaults, options)
this.$element = $(element)
if (this.options.countrylist) {
this.countryList = []
this.options.countrylist = this.options.countrylist.split(',')
for (var country in BFHCountriesList) {
if ($.inArray(country, this.options.countrylist) >= 0) {
this.countryList[country] = BFHCountriesList[country]
}
}
} else {
this.countryList = BFHCountriesList
}
if (this.$element.is("select")) {
this.addCountries()
}
if (this.$element.is("span")) {
this.displayCountry()
}
if (this.$element.hasClass("bfh-selectbox")) {
this.addBootstrapCountries()
}
}
BFHCountries.prototype = {
constructor: BFHCountries
, addCountries: function () {
var value = this.options.country
this.$element.html('')
this.$element.append('<option value=""></option>')
for (var country in this.countryList) {
this.$element.append('<option value="' + country + '">' + this.countryList[country] + '</option>')
}
this.$element.val(value)
}
, addBootstrapCountries: function() {
var $input
, $toggle
, $options
var value = this.options.country
$input = this.$element.find('input[type="hidden"]')
$toggle = this.$element.find('.bfh-selectbox-option')
$options = this.$element.find('[role=option]')
$options.html('')
$options.append('<li><a tabindex="-1" href="#" data-option=""></a></li>')
for (var country in this.countryList) {
if (this.options.flags == true) {
$options.append('<li><a tabindex="-1" href="#" data-option="' + country + '"><i class="icon-flag-' + country + '"></i>' + this.countryList[country] + '</a></li>')
} else {
$options.append('<li><a tabindex="-1" href="#" data-option="' + country + '">' + this.countryList[country] + '</a></li>')
}
}
$toggle.data('option', value)
if (value) {
if (this.options.flags == true) {
$toggle.html('<i class="icon-flag-' + value + '"></i> ' + this.countryList[value])
} else {
$toggle.html(this.countryList[value])
}
}
$input.val(value)
}
, displayCountry: function () {
var value = this.options.country
if (this.options.flags == true) {
this.$element.html('<i class="icon-flag-' + value + '"></i> ' + this.countryList[value])
} else {
this.$element.html(this.countryList[value])
}
}
}
/* COUNTRY PLUGIN DEFINITION
* ======================= */
$.fn.bfhcountries = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('bfhcountries')
, options = typeof option == 'object' && option
if (!data) $this.data('bfhcountries', (data = new BFHCountries(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.bfhcountries.Constructor = BFHCountries
$.fn.bfhcountries.defaults = {
country: "",
countryList: "",
flags: false
}
/* COUNTRY DATA-API
* ============== */
$(window).on('load', function () {
$('form select.bfh-countries, span.bfh-countries, div.bfh-countries').each(function () {
var $countries = $(this)
$countries.bfhcountries($countries.data())
})
})
}(window.jQuery);

View File

@@ -0,0 +1,244 @@
/* ==========================================================
* bootstrap-formhelpers-selectbox.js
* https://github.com/vlamanna/BootstrapFormHelpers
* ==========================================================
* Copyright 2012 Vincent Lamanna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* SELECTBOX CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle=bfh-selectbox]'
, BFHSelectBox = function (element) {
}
BFHSelectBox.prototype = {
constructor: BFHSelectBox
, toggle: function (e) {
var $this = $(this)
, $parent
, isActive
if ($this.is('.disabled, :disabled')) return false
$parent = getParent($this)
isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
$parent.toggleClass('open')
$parent.find('[role=option] > li > [data-option="' + $this.find('.bfh-selectbox-option').data('option') + '"]').focus()
}
return false
}
, filter: function(e) {
var $this
, $parent
, $items
$this = $(this)
$parent = $this.closest('.bfh-selectbox')
$items = $('[role=option] li a', $parent)
$items.hide()
$items.filter(function() { return ($(this).text().toUpperCase().indexOf($this.val().toUpperCase()) != -1) }).show()
}
, keydown: function (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
if (!/(38|40|27)/.test(e.keyCode) && !/[A-z]/.test(String.fromCharCode(e.which))) return
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return false
$parent = $this.closest('.bfh-selectbox')
isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
$items = $('[role=option] li a', $parent).filter(':visible')
if (!$items.length) return
$('body').off('mouseenter.bfh-selectbox.data-api', '[role=option] > li > a', BFHSelectBox.prototype.mouseenter)
index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (/[A-z]/.test(String.fromCharCode(e.which))) {
var $subItems = $items.filter(function() { return ($(this).text().charAt(0).toUpperCase() == String.fromCharCode(e.which)) })
var selectedIndex = $subItems.index($subItems.filter(':focus'))
if (!~selectedIndex) index = $items.index($subItems)
else if (selectedIndex >= $subItems.length - 1) index = $items.index($subItems)
else index++
}
if (!~index) index = 0
$items
.eq(index)
.focus()
$('body').on('mouseenter.bfh-selectbox.data-api', '[role=option] > li > a', BFHSelectBox.prototype.mouseenter)
}
, mouseenter: function (e) {
var $this
$this = $(this)
if ($this.is('.disabled, :disabled')) return false
$this.focus()
}
, select: function (e) {
var $this
, $parent
, $toggle
, $input
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return false
$parent = $this.closest('.bfh-selectbox')
$toggle = $parent.find('.bfh-selectbox-option')
$input = $parent.find('input[type="hidden"]')
$toggle.data('option', $this.data('option'))
$toggle.html($this.html())
$input.removeData()
$input.val($this.data('option'))
$.each($this.data(), function(i,e) {
$input.data(i,e);
});
$input.change()
clearMenus()
}
}
function clearMenus() {
getParent($(toggle))
.removeClass('open')
}
function getParent($this) {
var selector = $this.attr('data-target')
, $parent
if (!selector) {
selector = $this.attr('href')
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
$parent = $(selector)
$parent.length || ($parent = $this.parent())
return $parent
}
/* SELECTBOX PLUGIN DEFINITION
* ========================== */
$.fn.bfhselectbox = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('bfhselectbox')
this.type = 'bfhselectbox';
if (!data) $this.data('bfhselectbox', (data = new BFHSelectBox(this)))
if (typeof option == 'string') data[option].call($this)
})
}
$.fn.bfhselectbox.Constructor = BFHSelectBox
var origHook
// There might already be valhooks for the "text" type
if ($.valHooks.div){
// Preserve the original valhook function
origHook = $.valHooks.div
}
$.valHooks.div = {
get: function(el) {
if($(el).hasClass("bfh-selectbox")){
return $(el).find('input[type="hidden"]').val()
}else if (origHook){
return origHook.get(el)
}
},
set: function(el, val) {
if($(el).hasClass("bfh-selectbox")){
var $el = $(el)
, text = $el.find("li a[data-option='"+val+"']").text()
$el.find('input[type="hidden"]').val(val)
$el.find('.bfh-selectbox-option').text(text)
}else if (origHook){
return origHook.set(el,val)
}
}
}
/* APPLY TO STANDARD SELECTBOX ELEMENTS
* =================================== */
$(function () {
$('html')
.on('click.bfhselectbox.data-api', clearMenus)
$('body')
.on('click.bfhselectbox.data-api touchstart.bfhselectbox.data-api' , toggle, BFHSelectBox.prototype.toggle)
.on('keydown.bfhselectbox.data-api', toggle + ', [role=option]' , BFHSelectBox.prototype.keydown)
.on('mouseenter.bfhselectbox.data-api', '[role=option] > li > a', BFHSelectBox.prototype.mouseenter)
.on('click.bfhselectbox.data-api', '[role=option] > li > a', BFHSelectBox.prototype.select)
.on('click.bfhselectbox.data-api', '.bfh-selectbox-filter', function (e) { return false })
.on('propertychange.bfhselectbox.data-api change.bfhselectbox.data-api input.bfhselectbox.data-api paste.bfhselectbox.data-api', '.bfh-selectbox-filter', BFHSelectBox.prototype.filter)
})
}(window.jQuery);

View File

@@ -552,6 +552,23 @@ class WSF_AUTOCOMPLETE_CONTROL extends WSF_INPUT_CONTROL
@$el.on 'typeahead:blured',()->
self.change()
class WSF_COUNTRY_CHOOSER_CONTROL extends WSF_INPUT_CONTROL
requirements: ['assets/bootstrap-formhelpers-countries.js', 'assets/bootstrap-formhelpers-countries-en-US.js', 'assets/bootstrap-formhelpers-selectbox.js']
class WSF_DATETIME_PICKER_CONTROL extends WSF_INPUT_CONTROL
requirements: ['assets/bootstrap-datetimepicker.css', 'assets/bootstrap-datetimepicker.js']
attach_events: () ->
super
self = @
console.log @$el
@$el.datetimepicker({
language : 'en',
pick12HourFormat : false,
startDate : new Date()
})
class WSF_CHECKBOX_CONTROL extends WSF_CONTROL
attach_events: ()->
super

View File

@@ -1,11 +1,12 @@
// Generated by CoffeeScript 1.6.1
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FILE_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, redirect, show_alert, start_modal, start_modal_big, template, tmpl,
(function() {
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_COUNTRY_CHOOSER_CONTROL, WSF_DATETIME_PICKER_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FILE_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, redirect, show_alert, start_modal, start_modal_big, template, tmpl,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
cache = {};
cache = {};
jQuery.cachedAsset = function(url, options) {
jQuery.cachedAsset = function(url, options) {
var head, onload, script, success, successful, timeoutHandle;
if (/\.css$/.test(url)) {
$("<link/>", {
@@ -64,9 +65,9 @@ jQuery.cachedAsset = function(url, options) {
}
};
}
};
};
jQuery.unparam = function(value) {
jQuery.unparam = function(value) {
var i, l, pair, params, pieces;
params = {};
pieces = value.split("&");
@@ -81,9 +82,9 @@ jQuery.unparam = function(value) {
i++;
}
return params;
};
};
template = tmpl = function(str, data) {
template = tmpl = function(str, data) {
var fn;
fn = (!/\W/.test(str) ? cache[str] = cache[str] || tmpl(str) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + str.replace(/[\r\t\n]/g, " ").split("{{").join("\t").replace(/((^|}})[^\t]*)'/g, "$1\r").replace(/\t=(.*?)}}/g, "',$1,'").split("\t").join("');").split("}}").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"));
if (data) {
@@ -91,17 +92,17 @@ template = tmpl = function(str, data) {
} else {
return fn;
}
};
};
Mini = {
Mini = {
compile: function(t) {
return {
render: template(t)
};
}
};
};
parseSuggestions = function(data) {
parseSuggestions = function(data) {
var a, d;
for (a in data) {
if (a === 'suggestions') {
@@ -114,11 +115,11 @@ parseSuggestions = function(data) {
}
}
return null;
};
};
loaded = {};
loaded = {};
lazy_load = function(requirements, fn, that) {
lazy_load = function(requirements, fn, that) {
if (requirements.length === 0) {
return function() {
var a;
@@ -152,9 +153,9 @@ lazy_load = function(requirements, fn, that) {
}
return done();
};
};
};
build_control = function(control_name, state, control) {
build_control = function(control_name, state, control) {
var $el, type, typeclass;
$el = control.$el.find('[data-name=' + control_name + ']').first();
type = $el.data('type');
@@ -168,9 +169,9 @@ build_control = function(control_name, state, control) {
return new typeclass(control, $el, control_name, state);
}
return null;
};
};
WSF_VALIDATOR = (function() {
WSF_VALIDATOR = (function() {
function WSF_VALIDATOR(parent_control, settings) {
this.parent_control = parent_control;
@@ -185,9 +186,9 @@ WSF_VALIDATOR = (function() {
return WSF_VALIDATOR;
})();
})();
WSF_REGEXP_VALIDATOR = (function(_super) {
WSF_REGEXP_VALIDATOR = (function(_super) {
__extends(WSF_REGEXP_VALIDATOR, _super);
@@ -205,9 +206,9 @@ WSF_REGEXP_VALIDATOR = (function(_super) {
return WSF_REGEXP_VALIDATOR;
})(WSF_VALIDATOR);
})(WSF_VALIDATOR);
WSF_MIN_VALIDATOR = (function(_super) {
WSF_MIN_VALIDATOR = (function(_super) {
__extends(WSF_MIN_VALIDATOR, _super);
@@ -223,9 +224,9 @@ WSF_MIN_VALIDATOR = (function(_super) {
return WSF_MIN_VALIDATOR;
})(WSF_VALIDATOR);
})(WSF_VALIDATOR);
WSF_MAX_VALIDATOR = (function(_super) {
WSF_MAX_VALIDATOR = (function(_super) {
__extends(WSF_MAX_VALIDATOR, _super);
@@ -241,9 +242,9 @@ WSF_MAX_VALIDATOR = (function(_super) {
return WSF_MAX_VALIDATOR;
})(WSF_VALIDATOR);
})(WSF_VALIDATOR);
WSF_CONTROL = (function() {
WSF_CONTROL = (function() {
WSF_CONTROL.prototype.requirements = [];
@@ -439,9 +440,9 @@ WSF_CONTROL = (function() {
return WSF_CONTROL;
})();
})();
WSF_PAGE_CONTROL = (function(_super) {
WSF_PAGE_CONTROL = (function(_super) {
__extends(WSF_PAGE_CONTROL, _super);
@@ -484,9 +485,9 @@ WSF_PAGE_CONTROL = (function(_super) {
return WSF_PAGE_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_SLIDER_CONTROL = (function(_super) {
WSF_SLIDER_CONTROL = (function(_super) {
__extends(WSF_SLIDER_CONTROL, _super);
@@ -507,9 +508,9 @@ WSF_SLIDER_CONTROL = (function(_super) {
return WSF_SLIDER_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_DROPDOWN_CONTROL = (function(_super) {
WSF_DROPDOWN_CONTROL = (function(_super) {
__extends(WSF_DROPDOWN_CONTROL, _super);
@@ -521,11 +522,11 @@ WSF_DROPDOWN_CONTROL = (function(_super) {
return WSF_DROPDOWN_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
controls = {};
controls = {};
WSF_BUTTON_CONTROL = (function(_super) {
WSF_BUTTON_CONTROL = (function(_super) {
__extends(WSF_BUTTON_CONTROL, _super);
@@ -562,9 +563,9 @@ WSF_BUTTON_CONTROL = (function(_super) {
return WSF_BUTTON_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_INPUT_CONTROL = (function(_super) {
WSF_INPUT_CONTROL = (function(_super) {
__extends(WSF_INPUT_CONTROL, _super);
@@ -606,9 +607,9 @@ WSF_INPUT_CONTROL = (function(_super) {
return WSF_INPUT_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_FILE_CONTROL = (function(_super) {
WSF_FILE_CONTROL = (function(_super) {
__extends(WSF_FILE_CONTROL, _super);
@@ -754,9 +755,9 @@ WSF_FILE_CONTROL = (function(_super) {
return WSF_FILE_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_PASSWORD_CONTROL = (function(_super) {
WSF_PASSWORD_CONTROL = (function(_super) {
__extends(WSF_PASSWORD_CONTROL, _super);
@@ -766,9 +767,9 @@ WSF_PASSWORD_CONTROL = (function(_super) {
return WSF_PASSWORD_CONTROL;
})(WSF_INPUT_CONTROL);
})(WSF_INPUT_CONTROL);
WSF_NAVLIST_ITEM_CONTROL = (function(_super) {
WSF_NAVLIST_ITEM_CONTROL = (function(_super) {
__extends(WSF_NAVLIST_ITEM_CONTROL, _super);
@@ -790,9 +791,9 @@ WSF_NAVLIST_ITEM_CONTROL = (function(_super) {
return WSF_NAVLIST_ITEM_CONTROL;
})(WSF_BUTTON_CONTROL);
})(WSF_BUTTON_CONTROL);
WSF_TEXTAREA_CONTROL = (function(_super) {
WSF_TEXTAREA_CONTROL = (function(_super) {
__extends(WSF_TEXTAREA_CONTROL, _super);
@@ -802,9 +803,9 @@ WSF_TEXTAREA_CONTROL = (function(_super) {
return WSF_TEXTAREA_CONTROL;
})(WSF_INPUT_CONTROL);
})(WSF_INPUT_CONTROL);
WSF_CODEVIEW_CONTROL = (function(_super) {
WSF_CODEVIEW_CONTROL = (function(_super) {
__extends(WSF_CODEVIEW_CONTROL, _super);
@@ -832,9 +833,9 @@ WSF_CODEVIEW_CONTROL = (function(_super) {
return WSF_CODEVIEW_CONTROL;
})(WSF_INPUT_CONTROL);
})(WSF_INPUT_CONTROL);
WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
__extends(WSF_AUTOCOMPLETE_CONTROL, _super);
@@ -881,9 +882,50 @@ WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
return WSF_AUTOCOMPLETE_CONTROL;
})(WSF_INPUT_CONTROL);
})(WSF_INPUT_CONTROL);
WSF_CHECKBOX_CONTROL = (function(_super) {
WSF_COUNTRY_CHOOSER_CONTROL = (function(_super) {
__extends(WSF_COUNTRY_CHOOSER_CONTROL, _super);
function WSF_COUNTRY_CHOOSER_CONTROL() {
return WSF_COUNTRY_CHOOSER_CONTROL.__super__.constructor.apply(this, arguments);
}
WSF_COUNTRY_CHOOSER_CONTROL.prototype.requirements = ['assets/bootstrap-formhelpers-countries.js', 'assets/bootstrap-formhelpers-countries-en-US.js', 'assets/bootstrap-formhelpers-selectbox.js'];
return WSF_COUNTRY_CHOOSER_CONTROL;
})(WSF_INPUT_CONTROL);
WSF_DATETIME_PICKER_CONTROL = (function(_super) {
__extends(WSF_DATETIME_PICKER_CONTROL, _super);
function WSF_DATETIME_PICKER_CONTROL() {
return WSF_DATETIME_PICKER_CONTROL.__super__.constructor.apply(this, arguments);
}
WSF_DATETIME_PICKER_CONTROL.prototype.requirements = ['assets/bootstrap-datetimepicker.css', 'assets/bootstrap-datetimepicker.js'];
WSF_DATETIME_PICKER_CONTROL.prototype.attach_events = function() {
var self;
WSF_DATETIME_PICKER_CONTROL.__super__.attach_events.apply(this, arguments);
self = this;
return console.log(this.$el);
};
return WSF_DATETIME_PICKER_CONTROL;
})(WSF_INPUT_CONTROL);
this.$el.datetimepicker({
language: 'en',
pick12HourFormat: false,
startDate: new Date()
});
WSF_CHECKBOX_CONTROL = (function(_super) {
__extends(WSF_CHECKBOX_CONTROL, _super);
@@ -922,9 +964,9 @@ WSF_CHECKBOX_CONTROL = (function(_super) {
return WSF_CHECKBOX_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_FORM_ELEMENT_CONTROL = (function(_super) {
WSF_FORM_ELEMENT_CONTROL = (function(_super) {
__extends(WSF_FORM_ELEMENT_CONTROL, _super);
@@ -993,9 +1035,9 @@ WSF_FORM_ELEMENT_CONTROL = (function(_super) {
return WSF_FORM_ELEMENT_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_HTML_CONTROL = (function(_super) {
WSF_HTML_CONTROL = (function(_super) {
__extends(WSF_HTML_CONTROL, _super);
@@ -1016,9 +1058,9 @@ WSF_HTML_CONTROL = (function(_super) {
return WSF_HTML_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_CHECKBOX_LIST_CONTROL = (function(_super) {
WSF_CHECKBOX_LIST_CONTROL = (function(_super) {
__extends(WSF_CHECKBOX_LIST_CONTROL, _super);
@@ -1055,9 +1097,9 @@ WSF_CHECKBOX_LIST_CONTROL = (function(_super) {
return WSF_CHECKBOX_LIST_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_PROGRESS_CONTROL = (function(_super) {
WSF_PROGRESS_CONTROL = (function(_super) {
__extends(WSF_PROGRESS_CONTROL, _super);
@@ -1093,9 +1135,9 @@ WSF_PROGRESS_CONTROL = (function(_super) {
return WSF_PROGRESS_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_PAGINATION_CONTROL = (function(_super) {
WSF_PAGINATION_CONTROL = (function(_super) {
__extends(WSF_PAGINATION_CONTROL, _super);
@@ -1132,9 +1174,9 @@ WSF_PAGINATION_CONTROL = (function(_super) {
return WSF_PAGINATION_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_GRID_CONTROL = (function(_super) {
WSF_GRID_CONTROL = (function(_super) {
__extends(WSF_GRID_CONTROL, _super);
@@ -1159,9 +1201,9 @@ WSF_GRID_CONTROL = (function(_super) {
return WSF_GRID_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
WSF_REPEATER_CONTROL = (function(_super) {
WSF_REPEATER_CONTROL = (function(_super) {
__extends(WSF_REPEATER_CONTROL, _super);
@@ -1187,17 +1229,17 @@ WSF_REPEATER_CONTROL = (function(_super) {
return WSF_REPEATER_CONTROL;
})(WSF_CONTROL);
})(WSF_CONTROL);
redirect = function(action) {
redirect = function(action) {
return document.location.href = action.url;
};
};
show_alert = function(action) {
show_alert = function(action) {
return alert(action.message);
};
};
start_modal = lazy_load(['/assets/bootstrap.min.js'], function(action) {
start_modal = lazy_load(['/assets/bootstrap.min.js'], function(action) {
var cssclass, modal;
cssclass = "";
if (action.type === "start_modal_big") {
@@ -1216,6 +1258,8 @@ start_modal = lazy_load(['/assets/bootstrap.min.js'], function(action) {
}).done(function(data) {
return modal.find('.modal-body').append(data);
});
});
});
start_modal_big = start_modal;
start_modal_big = start_modal;
}).call(this);